HLSL槽索引在不同资源类型之间共享或分离?

时间:2012-12-02 01:52:27

标签: directx hlsl

用于设置HLSL着色器参数的DirectX API接受相应参数占用的插槽的参数。这些插槽号是否在所有资源类型之间全局共享,或者每种类型都有自己唯一的插槽号集。 'type',我的意思是内在的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;

1 个答案:

答案 0 :(得分:1)

这是按类型。

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

检查man以查看在舞台中设置不同类型的所有方法。