-
Notifications
You must be signed in to change notification settings - Fork 34
Open
Description
Compiling this small shader:
cbuffer vertexCB { uniform float4x4 matrix; }
cbuffer pixelCB { uniform Texture2D texture; }
uniform uint data[3];
struct VertexInputs { float3 p : POSITION; }
[shader("vertex")]
float4 vertexMain(VertexInputs vi) : SV_Position
{
return mul(float4(vi.p, 1.0), matrix);
}
[shader("fragment")]
float4 fragmentMain(float4 SV_Position : SV_Position) : SV_Target
{
return float4(SV_Position.xyz, 1.0);
}
Results in this error when creating pipeline for D3D12.
D3D12 ERROR: ID3D12Device::CreateGraphicsPipelineState: Root Signature doesn't match Vertex Shader: Shader CBV descriptor range (BaseShaderRegister=1, NumDescriptors=1, RegisterSpace=0) is not fully bound in root signature
[ STATE_CREATION ERROR #688: CREATEGRAPHICSPIPELINESTATE_VS_ROOT_SIGNATURE_MISMATCH]
If the uniform uint data[3]; is not present at all, or is part of either of the two cbuffers, things work as you'd expect.
Also, if I comment out the indicated line in d3d12-shader-object-layout.cpp in:
void RootShaderObjectLayoutImpl::RootSignatureDescBuilder::addAsConstantBuffer(
slang::TypeLayoutReflection* typeLayout,
uint32_t physicalDescriptorSetIndex,
BindingRegisterOffsetPair offsetForChildrenThatNeedNewSpace,
BindingRegisterOffsetPair offsetForOrdinaryChildren
)
{
if (typeLayout->getSize(SLANG_PARAMETER_CATEGORY_UNIFORM) != 0)
{
auto descriptorRangeType = D3D12_DESCRIPTOR_RANGE_TYPE_CBV;
auto& offsetForRangeType = offsetForOrdinaryChildren.primary.offsetForRangeType[descriptorRangeType];
addDescriptorRange(
physicalDescriptorSetIndex,
descriptorRangeType,
offsetForRangeType,
offsetForOrdinaryChildren.primary.spaceOffset,
1,
false
);
// offsetForRangeType++; // <-- This line
}
addAsValue(typeLayout, physicalDescriptorSetIndex, offsetForChildrenThatNeedNewSpace, offsetForOrdinaryChildren);
}
Things work (and no other test seems to break). But I cannot propose this change as a fix, because I do not understand all the implications. So it can at best serve as an indication of where the problem lies.