Enable 16 byte alignment for root constants and a minor cleanup (#1522)

* Enable 16 byte alignment for root constants 
* Switching to R8G8B8A8_UINT for dummy stream buffers
* Clamping min values for scissor/viewport for fullscreen pass
This commit is contained in:
moudgils
2021-06-23 18:54:03 -07:00
committed by GitHub
parent 07243c3eee
commit 0e3127240f
3 changed files with 8 additions and 7 deletions
@@ -156,7 +156,7 @@ namespace AZ
// Note: all platforms use DirectX packing rules. We enable vk namespace as well to allow
// for vk syntax to carry through from dxc to spirv-cross.
return shaderCompilerArguments.MakeAdditionalAzslcCommandLineString() +
" --use-spaces --unique-idx --namespace=mt,vk --root-const=128";
" --use-spaces --unique-idx --namespace=mt,vk --root-const=128 --pad-root-const";
}
AZStd::string ShaderPlatformInterface::GetAzslCompilerWarningParameters(const RHI::ShaderCompilerArguments& shaderCompilerArguments) const
@@ -280,10 +280,10 @@ namespace AZ
{
if (contractStreamChannel.m_isOptional)
{
RHI::Format formatDoesntReallyMatter = RHI::Format::R8_UNORM;
RHI::Format formatDoesntReallyMatter = RHI::Format::R8G8B8A8_UINT;
layoutBuilder.AddBuffer()->Channel(contractStreamChannel.m_semantic, formatDoesntReallyMatter);
// We can't just use a null buffer pointer here because vulkan will occasionally crash. So we bind some valid non-null buffer and view it with length 0.
RHI::StreamBufferView dummyBuffer{*mesh.m_indexBufferView.GetBuffer(), 0, 0, 1};
RHI::StreamBufferView dummyBuffer{*mesh.m_indexBufferView.GetBuffer(), 0, 0, 4};
streamBufferViewsOut.push_back(dummyBuffer);
// Note that all of the below scenarios seem to work find on PC, for both dx12 and vulkan. If the above approach proves to be incompatible
@@ -177,15 +177,16 @@ namespace AZ
RHI::Size targetImageSize = outputAttachment->m_descriptor.m_image.m_size;
m_viewportState.m_minX = 0.0f;
m_viewportState.m_minY = 0.0f;
m_viewportState.m_maxX = AZStd::min(static_cast<uint32_t>(params.m_viewportState.m_maxX), targetImageSize.m_width);
m_viewportState.m_maxY = AZStd::min(static_cast<uint32_t>(params.m_viewportState.m_maxY), targetImageSize.m_height);
m_viewportState.m_minX = AZStd::min(params.m_viewportState.m_minX, m_viewportState.m_maxX);
m_viewportState.m_minY = AZStd::min(params.m_viewportState.m_minY, m_viewportState.m_maxY);
m_scissorState.m_minX = 0.0f;
m_scissorState.m_minY = 0.0f;
m_scissorState.m_maxX = AZStd::min(static_cast<uint32_t>(params.m_scissorState.m_maxX), targetImageSize.m_width);
m_scissorState.m_maxY = AZStd::min(static_cast<uint32_t>(params.m_scissorState.m_maxY), targetImageSize.m_height);
m_scissorState.m_minX = AZStd::min(params.m_scissorState.m_minX, m_scissorState.m_maxX);
m_scissorState.m_minY = AZStd::min(params.m_scissorState.m_minY, m_scissorState.m_maxY);
RenderPass::FrameBeginInternal(params);
}