Skip to content

Commit d56629e

Browse files
committed
Use Slang pointer syntax for buffer device address sample
1 parent 261b63f commit d56629e

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

shaders/slang/bufferdeviceaddress/cube.slang

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,10 @@ struct VSInput
1414
float3 Color;
1515
};
1616

17-
struct MatrixReference {
18-
float4x4 matrix;
19-
};
20-
17+
// Pointers to the matrices, addresses are set in the application
2118
struct PushConsts {
22-
// Pointer to the buffer with the scene's MVP matrix
23-
ConstBufferPointer<MatrixReference> sceneDataReference;
24-
// Pointer to the buffer for the data for each model
25-
ConstBufferPointer<MatrixReference> modelDataReference;
19+
float4x4 *sceneMatrices;
20+
float4x4 *modelMatrices;
2621
};
2722

2823
struct VSOutput
@@ -36,14 +31,11 @@ struct VSOutput
3631
[shader("vertex")]
3732
VSOutput vertexMain(VSInput input, uniform PushConsts pushConstants)
3833
{
39-
MatrixReference sceneData = pushConstants.sceneDataReference.get();
40-
MatrixReference modelData = pushConstants.modelDataReference.get();
41-
4234
VSOutput output;
4335
output.Normal = input.Normal;
4436
output.Color = input.Color;
4537
output.UV = input.UV;
46-
output.Pos = mul(sceneData.matrix, mul(modelData.matrix, float4(input.Pos.xyz, 1.0)));
38+
output.Pos = mul(*pushConstants.sceneMatrices, mul(*pushConstants.modelMatrices, float4(input.Pos.xyz, 1.0)));
4739
return output;
4840
}
4941

-320 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)