Skip to content

Commit

Permalink
Merge pull request #55 from vertver/d3d12-pipeline-layout-fix
Browse files Browse the repository at this point in the history
Fixed D3D12 crash with bindless samplers
  • Loading branch information
dzhdanNV authored Apr 15, 2024
2 parents 1b958ed + d97292e commit 84f312a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Source/D3D12/PipelineLayoutD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ Result PipelineLayoutD3D12::Create(const PipelineLayoutDesc& pipelineLayoutDesc)
D3D12_ROOT_PARAMETER1 rootParameter = {};
rootParameter.ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE;

D3D12_DESCRIPTOR_RANGE_FLAGS descriptorRangeFlags =
descriptorSetDesc.partiallyBound ? D3D12_DESCRIPTOR_RANGE_FLAG_DESCRIPTORS_VOLATILE | D3D12_DESCRIPTOR_RANGE_FLAG_DATA_VOLATILE : D3D12_DESCRIPTOR_RANGE_FLAG_NONE;

uint32_t groupedRangeNum = 0;
D3D12_DESCRIPTOR_RANGE_TYPE groupedRangeType = {};
for (uint32_t j = 0; j < descriptorSetDesc.rangeNum; j++) {
Expand All @@ -97,6 +94,16 @@ Result PipelineLayoutD3D12::Create(const PipelineLayoutDesc& pipelineLayoutDesc)
rootParameter.ShaderVisibility = shaderVisibility;
rootParameter.DescriptorTable.pDescriptorRanges = &descriptorRanges[totalRangeNum];

D3D12_DESCRIPTOR_RANGE_FLAGS descriptorRangeFlags = D3D12_DESCRIPTOR_RANGE_FLAG_NONE;
if (descriptorSetDesc.partiallyBound)
{
descriptorRangeFlags |= D3D12_DESCRIPTOR_RANGE_FLAG_DESCRIPTORS_VOLATILE;
if (rangeType != D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER)
{
descriptorRangeFlags |= D3D12_DESCRIPTOR_RANGE_FLAG_DATA_VOLATILE;
}
}

D3D12_DESCRIPTOR_RANGE1& descriptorRange = descriptorRanges[totalRangeNum + groupedRangeNum];
descriptorRange.RangeType = rangeType;
descriptorRange.NumDescriptors = descriptorSetDesc.ranges[j].descriptorNum;
Expand Down

0 comments on commit 84f312a

Please sign in to comment.