Part generated by gemini with antigravity.
Converted to bindless first step
This commit is contained in:
Binary file not shown.
@@ -9,31 +9,31 @@ struct Output
|
||||
float4 Position : SV_Position;
|
||||
};
|
||||
|
||||
// Bindless storage buffer access
|
||||
// We assume DescriptorIndex 0 is our buffer for this example, or passed via push constant
|
||||
// Since we don't have push constants hooked up in the C++ simplified example yet,
|
||||
// we will assume the First descriptor in the heap is our buffer (Index 0).
|
||||
// In a real app, 'bufferIndex' would be passed as a Root Constant.
|
||||
|
||||
Output main(Input input)
|
||||
{
|
||||
Output output;
|
||||
float2 pos;
|
||||
if (input.VertexIndex == 0)
|
||||
{
|
||||
pos = (-1.0f).xx;
|
||||
output.Color = float4(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (input.VertexIndex == 1)
|
||||
{
|
||||
pos = float2(1.0f, -1.0f);
|
||||
output.Color = float4(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (input.VertexIndex == 2)
|
||||
{
|
||||
pos = float2(0.0f, 1.0f);
|
||||
output.Color = float4(0.0f, 0.0f, 1.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Retrieve the buffer using SM6.6 bindless syntax
|
||||
// heap index 0 is used for simplicity.
|
||||
uint bufferIndex = 0;
|
||||
ByteAddressBuffer buffer = ResourceDescriptorHeap[bufferIndex];
|
||||
|
||||
// Read position from buffer (Index * stride)
|
||||
// Stride = 2 float (pos) + 4 float (color) = 6 * 4 = 24 bytes ?
|
||||
// Let's assume just position 2D (8 bytes) + Color (16 bytes)
|
||||
uint stride = 24;
|
||||
uint offset = input.VertexIndex * stride;
|
||||
|
||||
float2 pos = asfloat(buffer.Load2(offset));
|
||||
float4 col = asfloat(buffer.Load4(offset + 8));
|
||||
|
||||
output.Position = float4(pos, 0.0f, 1.0f);
|
||||
output.Color = col;
|
||||
return output;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user