Fix metal shader pipeline crashes for LuminanceHistogramGenerator and MorphTargetCS due to the use of atomic operations with typed buffers. Switching them to use Structured buffers. Plus misc cleanup

main
moudgils 5 years ago
parent 3fb2e60291
commit 0d5247be34

@ -10,7 +10,5 @@
"type": "Compute"
}
]
},
"DisabledRHIBackends": ["metal"]
}
}

@ -16,7 +16,7 @@
ShaderResourceGroup MorphTargetPassSrg : SRG_PerPass
{
RWBuffer<int> m_accumulatedDeltas;
RWStruturedBuffer<int> m_accumulatedDeltas;
}
// This class represents the data that is passed to the morph target compute shader of an individual delta

@ -1,4 +1,4 @@
/*
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
@ -37,7 +37,7 @@ ShaderResourceGroup PassSrg : SRG_PerPass
Texture2D<float4> m_sceneLuminance;
// This should be of size NUM_HISTOGRAM_BINS.
Buffer<uint> m_histogram;
StructuredBuffer<uint> m_histogram;
Sampler LinearSampler
{

@ -20,7 +20,7 @@
ShaderResourceGroup PassSrg : SRG_PerPass
{
Texture2D<float4> m_inputTexture;
RWBuffer<uint> m_outputTexture;
RWStructuredBuffer<uint> m_outputTexture;
}
groupshared uint shared_histogramBins[NUM_HISTOGRAM_BINS];

@ -12,7 +12,5 @@
"type": "Compute"
}
]
},
"DisabledRHIBackends": ["metal"]
}
}

@ -16,7 +16,7 @@
ShaderResourceGroup PassSrg : SRG_PerPass
{
RWBuffer<float> m_skinnedMeshOutputStream;
RWStructuredBuffer<float> m_skinnedMeshOutputStream;
}
ShaderResourceGroup InstanceSrg : SRG_PerDraw

@ -72,7 +72,7 @@ namespace AZ
desc.m_bufferName = AZStd::string::format("LuminanceHistogramBuffer_%s", uuidString.c_str());
desc.m_elementSize = sizeof(uint32_t);
desc.m_byteCount = NumHistogramBins * sizeof(uint32_t);
desc.m_elementFormat = RHI::Format::R32_UINT;
desc.m_elementFormat = RHI::Format::Unknown;
m_histogram = RPI::BufferSystemInterface::Get()->CreateBufferFromCommonPool(desc);
AZ_Assert(m_histogram != nullptr, "Unable to allocate buffer");
}

@ -67,8 +67,8 @@ namespace AZ
creator.SetBuffer(nullptr, 0, bufferDescriptor);
RHI::BufferViewDescriptor viewDescriptor;
viewDescriptor.m_elementFormat = RHI::Format::R32_FLOAT;
viewDescriptor.m_elementSize = RHI::GetFormatSize(viewDescriptor.m_elementFormat);
viewDescriptor.m_elementFormat = RHI::Format::Unknown;
viewDescriptor.m_elementSize = sizeof(float);
viewDescriptor.m_elementCount = aznumeric_cast<uint32_t>(m_sizeInBytes) / viewDescriptor.m_elementSize;
viewDescriptor.m_elementOffset = 0;
creator.SetBufferViewDescriptor(viewDescriptor);

@ -410,7 +410,6 @@ namespace AZ
// For any other type the buffer view's element size should match the stride.
if (shaderInputBuffer.m_strideSize != bufferViewDescriptor.m_elementSize)
{
// [GFX TODO][ATOM-5735][AZSL] ByteAddressBuffer shader input is setting a stride of 16 instead of 4
AZ_Error("ShaderResourceGroupData", false, "Buffer Input '%s[%d]': Does not match expected stride size %d",
shaderInputBuffer.m_name.GetCStr(), arrayIndex, bufferViewDescriptor.m_elementSize);
return false;

@ -271,6 +271,12 @@ namespace AZ
ShaderResourceBindings& bindings = GetShaderResourceBindingsByPipelineType(pipelineType);
const PipelineState* pipelineState = static_cast<const PipelineState*>(item.m_pipelineState);
if(!pipelineState)
{
AZ_Assert(false, "Pipeline state not provided");
return false;
}
bool updatePipelineState = m_state.m_pipelineState != pipelineState;
// The pipeline state gets set first.
if (updatePipelineState)

Loading…
Cancel
Save