0
votes

If I have a load of constant buffers full of data cbuffer1, cbuffer2, cbuffer3 etc in my shader. Is there any way in hlsl that I can access a specific constant buffer dynamically at runtime? Something like this...

cbuffers[1].MyValue

Or is the only way to have a massive if statement like this...

if(index == 0){
    return cbuffer0.MyValue;
} else if(index == 1){
    return cbuffer1.MyValue;
} else if(index == 2){
    return cbuffer2.MyValue;
}

Which seems like it wont perform well.

1

1 Answers

0
votes

If all 3 constant buffers have their data laid out in the same format why not just have 1 constant buffer with an array of 3 structures contained within it?