{gfx,examples}: improve sysgpu compatibility with higher-level examples

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2024-04-29 18:29:41 -07:00 committed by Stephen Gutekanst
parent 15fd2c3a64
commit cbf066ade5
3 changed files with 22 additions and 5 deletions

View file

@ -79,7 +79,10 @@ fn init(
.label = label, .label = label,
.layout = bind_group_layout, .layout = bind_group_layout,
.entries = &.{ .entries = &.{
gpu.BindGroup.Entry.buffer(0, uniform_buffer, uniform_offset * i, @sizeOf(UniformBufferObject)), if (mach.use_sysgpu)
gpu.BindGroup.Entry.buffer(0, uniform_buffer, uniform_offset * i, @sizeOf(UniformBufferObject), @sizeOf(UniformBufferObject))
else
gpu.BindGroup.Entry.buffer(0, uniform_buffer, uniform_offset * i, @sizeOf(UniformBufferObject)),
}, },
}), }),
); );

View file

@ -249,10 +249,22 @@ fn buildPipeline(
.label = label, .label = label,
.layout = bind_group_layout, .layout = bind_group_layout,
.entries = &.{ .entries = &.{
gpu.BindGroup.Entry.buffer(0, uniforms, 0, @sizeOf(Uniforms)), if (mach.use_sysgpu)
gpu.BindGroup.Entry.buffer(1, transforms, 0, @sizeOf(math.Mat4x4) * sprite_buffer_cap), gpu.BindGroup.Entry.buffer(0, uniforms, 0, @sizeOf(Uniforms), @sizeOf(Uniforms))
gpu.BindGroup.Entry.buffer(2, uv_transforms, 0, @sizeOf(math.Mat3x3) * sprite_buffer_cap), else
gpu.BindGroup.Entry.buffer(3, sizes, 0, @sizeOf(math.Vec2) * sprite_buffer_cap), gpu.BindGroup.Entry.buffer(0, uniforms, 0, @sizeOf(Uniforms)),
if (mach.use_sysgpu)
gpu.BindGroup.Entry.buffer(1, transforms, 0, @sizeOf(math.Mat4x4) * sprite_buffer_cap, @sizeOf(math.Mat4x4))
else
gpu.BindGroup.Entry.buffer(1, transforms, 0, @sizeOf(math.Mat4x4) * sprite_buffer_cap),
if (mach.use_sysgpu)
gpu.BindGroup.Entry.buffer(2, uv_transforms, 0, @sizeOf(math.Mat3x3) * sprite_buffer_cap, @sizeOf(math.Mat3x3))
else
gpu.BindGroup.Entry.buffer(2, uv_transforms, 0, @sizeOf(math.Mat3x3) * sprite_buffer_cap),
if (mach.use_sysgpu)
gpu.BindGroup.Entry.buffer(3, sizes, 0, @sizeOf(math.Vec2) * sprite_buffer_cap, @sizeOf(math.Vec2))
else
gpu.BindGroup.Entry.buffer(3, sizes, 0, @sizeOf(math.Vec2) * sprite_buffer_cap),
gpu.BindGroup.Entry.sampler(4, texture_sampler), gpu.BindGroup.Entry.sampler(4, texture_sampler),
gpu.BindGroup.Entry.textureView(5, texture_view), gpu.BindGroup.Entry.textureView(5, texture_view),
gpu.BindGroup.Entry.textureView(6, texture2_view), gpu.BindGroup.Entry.textureView(6, texture2_view),
@ -261,6 +273,7 @@ fn buildPipeline(
}, },
}), }),
); );
defer bind_group.release();
const blend_state = opt_blend_state orelse gpu.BlendState{ const blend_state = opt_blend_state orelse gpu.BlendState{
.color = .{ .color = .{

View file

@ -287,6 +287,7 @@ fn buildPipeline(
}, },
}), }),
); );
defer bind_group.release();
const blend_state = opt_blend_state orelse gpu.BlendState{ const blend_state = opt_blend_state orelse gpu.BlendState{
.color = .{ .color = .{