我是 MSFT 和 DirectX 的新手,所以请放轻松。
如果 hlsl 着色器使用该[RootSignature(SignatureName)]
属性,它会被代码中定义的根签名覆盖ID3D12RootSignature
吗?
例如,在示例代码中,我在一个着色器包含的 .hlsli 文件中有这个:
"RootFlags(ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT), " \
"CBV(b0, visibility = SHADER_VISIBILITY_VERTEX), " \
"CBV(b0, visibility = SHADER_VISIBILITY_PIXEL), " \
"DescriptorTable(SRV(t0, numDescriptors = 6), visibility = SHADER_VISIBILITY_PIXEL)," \
"DescriptorTable(SRV(t64, numDescriptors = 6), visibility = SHADER_VISIBILITY_PIXEL)," \
"RootConstants(b1, num32BitConstants = 2, visibility = SHADER_VISIBILITY_VERTEX), " \
"StaticSampler(s0, maxAnisotropy = 8, visibility = SHADER_VISIBILITY_PIXEL)," \
"StaticSampler(s1, visibility = SHADER_VISIBILITY_PIXEL," \
"addressU = TEXTURE_ADDRESS_CLAMP," \
"addressV = TEXTURE_ADDRESS_CLAMP," \
"addressW = TEXTURE_ADDRESS_CLAMP," \
"comparisonFunc = COMPARISON_GREATER_EQUAL," \
"filter = FILTER_MIN_MAG_LINEAR_MIP_POINT)"
在着色器中:
[RootSignature(ModelViewer_RootSig)]
VSOutput main(VSInput vsInput)
{
VSOutput vsOutput;
vsOutput.position = mul(modelToProjection, float4(vsInput.position, 1.0));
vsOutput.worldPos = vsInput.position;
vsOutput.texCoord = vsInput.texcoord0;
vsOutput.viewDir = vsInput.position - ViewerPos;
<etc>
是否会被使用以下内容创建的根签名覆盖或覆盖:
ASSERT_SUCCEEDED( g_Device->CreateRootSignature(1, pOutBlob->GetBufferPointer(), pOutBlob->GetBufferSize(), MY_IID_PPV_ARGS(&m_Signature)) );