1

用于设置 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;
4

1 回答 1

1

这是按类型。

例如PerFrameData,在插槽 0、插槽 1 上,PerObjectData等等......您使用XX设置它们是流水线阶段。XXSetConstantBuffers

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

于 2012-12-08T11:35:59.830 回答