Prechádzať zdrojové kódy

Merge pull request #659 from aws-lumberyard-dev/Atom/dmcdiar/ATOM-15511

[ATOM-15511] Change AtomSampleViewer BindlessPrototype sample to use an unbounded array
dmcdiarmid-ly 4 rokov pred
rodič
commit
a0cb4714c0

+ 3 - 0
Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/DeviceFeatures.h

@@ -76,6 +76,9 @@ namespace AZ
             //! Whether Ray Tracing support is available.
             bool m_rayTracing = false;
 
+            //! Whether Unbounded Array support is available.
+            bool m_unboundedArrays = false;
+
             /// Additional features here.
         };
     }

+ 2 - 0
Gems/Atom/RHI/DX12/Code/Source/RHI/Device.cpp

@@ -166,6 +166,8 @@ namespace AZ
             m_features.m_rayTracing = false;
 #endif
 
+            m_features.m_unboundedArrays = true;
+
             m_limits.m_maxImageDimension1D = D3D12_REQ_TEXTURE1D_U_DIMENSION;
             m_limits.m_maxImageDimension2D = D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION;
             m_limits.m_maxImageDimension3D = D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION;

+ 1 - 0
Gems/Atom/RHI/Vulkan/Code/Source/RHI/Device.cpp

@@ -720,6 +720,7 @@ namespace AZ
             StringList deviceExtensions = physicalDevice.GetDeviceExtensionNames();
             StringList::iterator itRayTracingExtension = AZStd::find(deviceExtensions.begin(), deviceExtensions.end(), VK_KHR_RAY_TRACING_PIPELINE_EXTENSION_NAME);
             m_features.m_rayTracing = (itRayTracingExtension != deviceExtensions.end());
+            m_features.m_unboundedArrays = true;
 
             const auto& deviceLimits = physicalDevice.GetDeviceLimits();
             m_limits.m_maxImageDimension1D = deviceLimits.maxImageDimension1D;

+ 3 - 4
Gems/Atom/RPI/Assets/ShaderLib/Atom/RPI/ShaderResourceGroups/BindlessPrototypeSrg.azsli

@@ -31,10 +31,6 @@ ShaderResourceGroupSemantic FloatBufferSemanticId
 
 ShaderResourceGroup ImageSrg : FrequencyPerScene
 {
-    // Array of textures
-    // NOTE: The size of the texture array has to match the number of textures in the example
-    Texture2D m_textureArray[8];
-
     Sampler m_sampler
     {
         MaxAnisotropy = 16;
@@ -42,6 +38,9 @@ ShaderResourceGroup ImageSrg : FrequencyPerScene
         AddressV = Wrap;
         AddressW = Wrap;
     };
+
+    // Array of textures
+    Texture2D m_textureArray[];
 }
 
 ShaderResourceGroup FloatBufferSrg : FloatBufferSemanticId

+ 3 - 0
Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Shader/ShaderResourceGroup.h

@@ -75,6 +75,9 @@ namespace AZ
             RHI::ShaderInputSamplerIndex   FindShaderInputSamplerIndex(const Name& name) const;
             RHI::ShaderInputConstantIndex  FindShaderInputConstantIndex(const Name& name) const;
 
+            RHI::ShaderInputBufferUnboundedArrayIndex FindShaderInputBufferUnboundedArrayIndex(const Name& name) const;
+            RHI::ShaderInputImageUnboundedArrayIndex  FindShaderInputImageUnboundedArrayIndex(const Name& name) const;
+
             /// Returns the parent shader resource group asset.
             const Data::Asset<ShaderResourceGroupAsset>& GetAsset() const;
 

+ 10 - 0
Gems/Atom/RPI/Code/Source/RPI.Public/Shader/ShaderResourceGroup.cpp

@@ -118,6 +118,16 @@ namespace AZ
             return m_layout->FindShaderInputConstantIndex(name);
         }
 
+        RHI::ShaderInputBufferUnboundedArrayIndex ShaderResourceGroup::FindShaderInputBufferUnboundedArrayIndex(const Name& name) const
+        {
+            return m_layout->FindShaderInputBufferUnboundedArrayIndex(name);
+        }
+
+        RHI::ShaderInputImageUnboundedArrayIndex  ShaderResourceGroup::FindShaderInputImageUnboundedArrayIndex(const Name& name) const
+        {
+            return m_layout->FindShaderInputImageUnboundedArrayIndex(name);
+        }
+
         const Data::Asset<ShaderResourceGroupAsset>& ShaderResourceGroup::GetAsset() const
         {
             return m_asset;