0

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.

Dean North
  • 3,741
  • 2
  • 29
  • 30

1 Answers1

0

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?

Adam Miles
  • 3,504
  • 17
  • 15
  • The data is the same layout, but the buffers used will vary. So I cant store all of the data in a single buffer without having to create a new buffer that contains the combined data each frame. – Dean North Jul 28 '14 at 09:26