I am learning DirectCompute and I am stuck with StructuredBufferes. The thing is I learned that to supply data to shader I need to use a View - SRV or UAV, depending on what I am trying to achieve. But code examples from Microsoft site do not explain, how does a view defined in C++ code correspond to a specific Buffer defined in shader code. However, there is a hlsl keyword I dont really understand - register()
. In sample there were three bufferes:
StructuredBuffer<BuffType> Buff0 : register(t0);
StructuredBuffer<BuffType> Buff1 : register(t1);
RWStructuredBuffer<BuffType> BuffOut : register(u0);
In C++ code the authors just set ComputeShader, 1 UAV, 2 SRV's and then call Context.Dispatch(,,) (assuming they have prepared all buffers and views before). So the question is - how do I understand that the particular SRV (there are two of them) provide data for the particaular StructuredBuffer? Is it controlled by register number(e.g. register(t0) is filled first, register(t1) - second). If yes, what if I want to provide data to second buffer first, and then fill the first one? I feel myself that I miss something very important, but in previous tutorials I used everything was a lot easier because of EffectVariales and .GetVariableBy methods. Thanks in advance.