From 0e3127240f52921bed377203a3fee0cb043fa250 Mon Sep 17 00:00:00 2001 From: moudgils <47460854+moudgils@users.noreply.github.com> Date: Wed, 23 Jun 2021 18:54:03 -0700 Subject: [PATCH] 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 --- .../Code/Source/RHI.Builders/ShaderPlatformInterface.cpp | 2 +- Gems/Atom/RPI/Code/Source/RPI.Public/Model/ModelLod.cpp | 4 ++-- .../Source/RPI.Public/Pass/FullscreenTrianglePass.cpp | 9 +++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Gems/Atom/RHI/Metal/Code/Source/RHI.Builders/ShaderPlatformInterface.cpp b/Gems/Atom/RHI/Metal/Code/Source/RHI.Builders/ShaderPlatformInterface.cpp index 20ccaea730..a614ad332d 100644 --- a/Gems/Atom/RHI/Metal/Code/Source/RHI.Builders/ShaderPlatformInterface.cpp +++ b/Gems/Atom/RHI/Metal/Code/Source/RHI.Builders/ShaderPlatformInterface.cpp @@ -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 diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Model/ModelLod.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Model/ModelLod.cpp index efa6418bf6..b24745ebe6 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Model/ModelLod.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Model/ModelLod.cpp @@ -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 diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/FullscreenTrianglePass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/FullscreenTrianglePass.cpp index 033ba680c8..6ee056b8dc 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/FullscreenTrianglePass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/FullscreenTrianglePass.cpp @@ -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(params.m_viewportState.m_maxX), targetImageSize.m_width); m_viewportState.m_maxY = AZStd::min(static_cast(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(params.m_scissorState.m_maxX), targetImageSize.m_width); m_scissorState.m_maxY = AZStd::min(static_cast(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); }