The DirectX API for setting HLSL shader parameters takes arguments for the slot that the respective parameter occupies. Are these slot numbers globally shared between all resource types, or does each type have its own unique set of slot numbers. By ‘type’, I mean intrinsic HLSL structures like cbuffers, textures, samplers, and so forth.
Here’s a hypothetical HLSL shader file that illustrates my question.
// 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;
It’s by type.
For instance
PerFrameDatais on slot 0,PerObjectDataon slot 1, etc… and you set them usingXXSetConstantBuffers, XX being the pipeline stage.Check the man to see all methods to set the different types in a stage.