Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
DirectX 11中的GetResourceBindingDescByName只能获取第一个cbuffer_Directx_Shader_Directx 11_Hlsl - Fatal编程技术网

DirectX 11中的GetResourceBindingDescByName只能获取第一个cbuffer

DirectX 11中的GetResourceBindingDescByName只能获取第一个cbuffer,directx,shader,directx-11,hlsl,Directx,Shader,Directx 11,Hlsl,我正在学习DirectX 11,并已达到基本的HLSL部分。我想在顶点着色器中使用多个常量缓冲区,因此我需要为VSSetConstantBuffers找到正确的StartSlot。我在谷歌上搜索,发现有人建议使用GetResourceBindingDescByName 我尝试了GetResourceBindingDescByName,但发现它只能为第一个cbuffer获取正确的StartSlot。例如,在我的顶点着色器中: cbuffer Test1 { float4 a; }; cb

我正在学习DirectX 11,并已达到基本的HLSL部分。我想在顶点着色器中使用多个常量缓冲区,因此我需要为
VSSetConstantBuffers
找到正确的
StartSlot
。我在谷歌上搜索,发现有人建议使用
GetResourceBindingDescByName

我尝试了
GetResourceBindingDescByName
,但发现它只能为第一个cbuffer获取正确的
StartSlot
。例如,在我的顶点着色器中:

cbuffer Test1
{
    float4 a;
};

cbuffer Test2
{
    float4 b;
};
现在
GetResourceBindingDescByName(“Test1”)和bind_desc)
工作正常,但
GetResourceBindingDescByName(“Test2”和bind_desc)
将失败(返回
E_INVAILDARG


有人能帮我吗?

反射只包含着色器使用的符号。正如在评论中确认的那样,b没有被使用,问题是一旦b在代码中被引用并且没有被优化去除,问题就解决了。

b是否在着色器中被使用?它可能已经被优化条带化了。谢谢。我只是在着色器中使用了一个。我在着色器代码中添加了对b的引用,问题就解决了。你能回答这个问题吗?这样我就可以把它作为这个问题的答案了?