Use push constants for fixed object data, some minor code cleanup
This commit is contained in:
parent
fbc3526c58
commit
e04c084312
9 changed files with 80 additions and 128 deletions
|
|
@ -14,25 +14,23 @@ struct Node
|
|||
uint next;
|
||||
};
|
||||
|
||||
struct ObjectUBO
|
||||
{
|
||||
float4x4 model;
|
||||
float4 color;
|
||||
};
|
||||
|
||||
cbuffer ubo : register(b1) { ObjectUBO objectUBO; }
|
||||
|
||||
struct GeometrySBO
|
||||
{
|
||||
uint count;
|
||||
uint maxNodeCount;
|
||||
};
|
||||
// Binding 0 : Position storage buffer
|
||||
RWStructuredBuffer<GeometrySBO> geometrySBO : register(u2);
|
||||
RWStructuredBuffer<GeometrySBO> geometrySBO : register(u1);
|
||||
|
||||
RWTexture2D<uint> headIndexImage : register(u3);
|
||||
RWTexture2D<uint> headIndexImage : register(u2);
|
||||
|
||||
RWStructuredBuffer<Node> nodes : register(u4);
|
||||
RWStructuredBuffer<Node> nodes : register(u3);
|
||||
|
||||
struct PushConsts {
|
||||
float4x4 model;
|
||||
float4 color;
|
||||
};
|
||||
[[vk::push_constant]] PushConsts pushConsts;
|
||||
|
||||
[earlydepthstencil]
|
||||
void main(VSOutput input)
|
||||
|
|
@ -49,7 +47,7 @@ void main(VSOutput input)
|
|||
InterlockedExchange(headIndexImage[uint2(input.Pos.xy)], nodeIdx, prevHeadIdx);
|
||||
|
||||
// Store node data
|
||||
nodes[nodeIdx].color = objectUBO.color;
|
||||
nodes[nodeIdx].color = pushConsts.color;
|
||||
nodes[nodeIdx].depth = input.Pos.z;
|
||||
nodes[nodeIdx].next = prevHeadIdx;
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -13,13 +13,11 @@ struct RenderPassUBO
|
|||
|
||||
cbuffer renderPassUBO : register(b0) { RenderPassUBO renderPassUBO; }
|
||||
|
||||
struct ObjectUBO
|
||||
{
|
||||
float4x4 model;
|
||||
float4 color;
|
||||
struct PushConsts {
|
||||
float4x4 model;
|
||||
float4 color;
|
||||
};
|
||||
|
||||
cbuffer objectUBO : register(b1) { ObjectUBO objectUBO; }
|
||||
[[vk::push_constant]] PushConsts pushConsts;
|
||||
|
||||
struct VSOutput
|
||||
{
|
||||
|
|
@ -29,6 +27,6 @@ struct VSOutput
|
|||
VSOutput main(VSInput input)
|
||||
{
|
||||
VSOutput output = (VSOutput)0;
|
||||
output.Pos = mul(renderPassUBO.projection, mul(renderPassUBO.view, mul(objectUBO.model, input.Pos)));
|
||||
output.Pos = mul(renderPassUBO.projection, mul(renderPassUBO.view, mul(pushConsts.model, input.Pos)));
|
||||
return output;
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue