{gfx,examples}: fix refcounting bugs, improve sysgpu compatability
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
cbb728c37a
commit
ca08255ec2
11 changed files with 39 additions and 24 deletions
|
|
@ -107,6 +107,7 @@ fn updatePipeline(
|
|||
encoder.writeBuffer(built.transforms, 0, gfx.SpritePipeline.cp_transforms[0..i]);
|
||||
encoder.writeBuffer(built.uv_transforms, 0, gfx.SpritePipeline.cp_uv_transforms[0..i]);
|
||||
encoder.writeBuffer(built.sizes, 0, gfx.SpritePipeline.cp_sizes[0..i]);
|
||||
|
||||
var command = encoder.finish(&.{ .label = label });
|
||||
defer command.release();
|
||||
core.state().queue.submit(&[_]*gpu.CommandBuffer{command});
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ pub const components = .{
|
|||
};
|
||||
|
||||
pub const events = .{
|
||||
.init = .{ .handler = fn () void },
|
||||
.init = .{ .handler = init },
|
||||
.deinit = .{ .handler = deinit },
|
||||
.update = .{ .handler = update },
|
||||
.pre_render = .{ .handler = preRender },
|
||||
|
|
@ -119,6 +119,10 @@ pub const BuiltPipeline = struct {
|
|||
}
|
||||
};
|
||||
|
||||
fn init(sprite_pipeline: *Mod) void {
|
||||
sprite_pipeline.init(.{});
|
||||
}
|
||||
|
||||
fn deinit(sprite_pipeline: *Mod) void {
|
||||
var archetypes_iter = sprite_pipeline.entities.query(.{ .all = &.{
|
||||
.{ .mach_gfx_sprite_pipeline = &.{
|
||||
|
|
@ -131,8 +135,6 @@ fn deinit(sprite_pipeline: *Mod) void {
|
|||
}
|
||||
|
||||
fn update(core: *mach.Core.Mod, sprite_pipeline: *Mod) !void {
|
||||
sprite_pipeline.init(.{});
|
||||
|
||||
// Destroy all sprite render pipelines. We will rebuild them all.
|
||||
deinit(sprite_pipeline);
|
||||
|
||||
|
|
|
|||
|
|
@ -267,10 +267,22 @@ fn buildPipeline(
|
|||
.label = label,
|
||||
.layout = bind_group_layout,
|
||||
.entries = &.{
|
||||
gpu.BindGroup.Entry.buffer(0, uniforms, 0, @sizeOf(Uniforms)),
|
||||
gpu.BindGroup.Entry.buffer(1, transforms, 0, @sizeOf(math.Mat4x4) * texts_buffer_cap),
|
||||
gpu.BindGroup.Entry.buffer(2, colors, 0, @sizeOf(math.Vec4) * texts_buffer_cap),
|
||||
gpu.BindGroup.Entry.buffer(3, glyphs, 0, @sizeOf(Glyph) * texts_buffer_cap),
|
||||
if (mach.use_sysgpu)
|
||||
gpu.BindGroup.Entry.buffer(0, uniforms, 0, @sizeOf(Uniforms), @sizeOf(Uniforms))
|
||||
else
|
||||
gpu.BindGroup.Entry.buffer(0, uniforms, 0, @sizeOf(Uniforms)),
|
||||
if (mach.use_sysgpu)
|
||||
gpu.BindGroup.Entry.buffer(1, transforms, 0, @sizeOf(math.Mat4x4) * texts_buffer_cap, @sizeOf(math.Mat4x4))
|
||||
else
|
||||
gpu.BindGroup.Entry.buffer(1, transforms, 0, @sizeOf(math.Mat4x4) * texts_buffer_cap),
|
||||
if (mach.use_sysgpu)
|
||||
gpu.BindGroup.Entry.buffer(2, colors, 0, @sizeOf(math.Vec4) * texts_buffer_cap, @sizeOf(math.Vec4))
|
||||
else
|
||||
gpu.BindGroup.Entry.buffer(2, colors, 0, @sizeOf(math.Vec4) * texts_buffer_cap),
|
||||
if (mach.use_sysgpu)
|
||||
gpu.BindGroup.Entry.buffer(3, glyphs, 0, @sizeOf(Glyph) * texts_buffer_cap, @sizeOf(Glyph))
|
||||
else
|
||||
gpu.BindGroup.Entry.buffer(3, glyphs, 0, @sizeOf(Glyph) * texts_buffer_cap),
|
||||
gpu.BindGroup.Entry.sampler(4, texture_sampler),
|
||||
gpu.BindGroup.Entry.textureView(5, texture_view),
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue