I'm learning DirectX 11 and have reached basic HLSL part. I want to use multiple constant buffers in vertex shader, so I need to find the correct StartSlot
for VSSetConstantBuffers
. I searched on Google and found that someone suggested using GetResourceBindingDescByName
.
I tried GetResourceBindingDescByName
, but found that it can only get the correct StartSlot
for the first cbuffer. For example, in my vertex shader:
cbuffer Test1
{
float4 a;
};
cbuffer Test2
{
float4 b;
};
Now GetResourceBindingDescByName("Test1", &bind_desc)
works correctly, but GetResourceBindingDescByName("Test2", &bind_desc)
will fail (return E_INVAILDARG
).
Could anyone help me?
The reflection only contains symbols use by a shader. As confirmed in the comments, b was not use, and the problem is solve once b is referenced in the code and not strip away by an optimisation.