HLSL: cast non-int types to uint on Load/Store indexes
Some texture and SB operations can take non-integer indexes, which should be cast to integers before use if they are not already. This adds makeIntegerIndex() for the purpose. Int types are left alone. (This was done before for operator[], but needs to apply to some other things too, hence its extraction into common function now)
This commit is contained in:
19
Test/hlsl.structbuffer.floatidx.comp
Normal file
19
Test/hlsl.structbuffer.floatidx.comp
Normal file
@@ -0,0 +1,19 @@
|
||||
struct sb_t
|
||||
{
|
||||
float4 color;
|
||||
uint2 threadId;
|
||||
};
|
||||
|
||||
RWTexture2D<float4> outtx;
|
||||
ConsumeStructuredBuffer<sb_t> csb : register(u1);
|
||||
RWStructuredBuffer<float4> rwsb;
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void main(uint3 nThreadId : SV_DispatchThreadID)
|
||||
{
|
||||
sb_t data = csb.Consume();
|
||||
float2 coord = float2(data.threadId.xy);
|
||||
outtx[coord] = data.color;
|
||||
|
||||
rwsb[coord.x] = rwsb.Load(coord.y);
|
||||
}
|
||||
Reference in New Issue
Block a user