{gfx,examples}: fix refcounting bugs, improve sysgpu compatability

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2024-05-01 20:17:16 -07:00
parent cbb728c37a
commit ca08255ec2
11 changed files with 39 additions and 24 deletions

View file

@ -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);