Directx HLSL插槽索引在不同资源类型之间共享还是分开?

Directx HLSL插槽索引在不同资源类型之间共享还是分开?,directx,hlsl,Directx,Hlsl,用于设置HLSL着色器参数的DirectX API为相应参数占用的插槽获取参数。这些插槽号是在所有资源类型之间全局共享的,还是每种类型都有自己唯一的插槽号集。所谓“类型”,我指的是固有的HLSL结构,如cbuffers、纹理、采样器等 下面是一个假设的HLSL着色器文件,它说明了我的问题 // Note the order I declare things here is for the purpose of the question, // not how I would declare th

用于设置HLSL着色器参数的DirectX API为相应参数占用的插槽获取参数。这些插槽号是在所有资源类型之间全局共享的,还是每种类型都有自己唯一的插槽号集。所谓“类型”,我指的是固有的HLSL结构,如cbuffers、纹理、采样器等

下面是一个假设的HLSL着色器文件,它说明了我的问题

// Note the order I declare things here is for the purpose of the question,
// not how I would declare them in a real shader file.

// First constant buffer and first item, definitely at index 0.
cbuffer PerFrameData
{
// stuff
};

// Is this texture at index 0 because its the first texture
// declared, or index 1 because it's the second item declared?
Texture2D firstTexture;

// Second cbuffer, third declared - index 1 or 2?
cbuffer PerObjectData
{
// stuff
};

// Second texture, fourth declared - index 1 or 3?
Texture2D secondTexture;

// This sampler is declared last, do I use index 0 or 4?
SamplerState texSampler;
它是按类型分类的

例如,
PerFrameData
位于插槽0上,
PerObjectData
位于插槽1上,等等。。。您可以使用
XXSetConstantBuffers
设置它们,XX是管道阶段

检查以查看在阶段中设置不同类型的所有方法。

它是按类型设置的

例如,
PerFrameData
位于插槽0上,
PerObjectData
位于插槽1上,等等。。。您可以使用
XXSetConstantBuffers
设置它们,XX是管道阶段

选中以查看在阶段中设置不同类型的所有方法