{gfx,examples}: add labels to gpu objects

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2024-04-21 19:47:08 -07:00
parent 2b8bfcaa3e
commit bffc668005
10 changed files with 78 additions and 34 deletions

View file

@ -202,7 +202,8 @@ fn tick(
sprite_pipeline.send(.pre_render, .{});
// Create a command encoder for this frame
game.state().frame_encoder = mach.core.device.createCommandEncoder(null);
const label = @tagName(name) ++ ".tick";
game.state().frame_encoder = mach.core.device.createCommandEncoder(&.{ .label = label });
// Grab the back buffer of the swapchain
const back_buffer_view = mach.core.swap_chain.getCurrentTextureView().?;
@ -216,9 +217,10 @@ fn tick(
.load_op = .clear,
.store_op = .store,
}};
game.state().frame_encoder = mach.core.device.createCommandEncoder(null);
// TODO: can we eliminate this assignment
game.state().frame_encoder = mach.core.device.createCommandEncoder(&.{ .label = label });
game.state().frame_render_pass = game.state().frame_encoder.beginRenderPass(&gpu.RenderPassDescriptor.init(.{
.label = "main render pass",
.label = label,
.color_attachments = &color_attachments,
}));
@ -235,7 +237,8 @@ fn tick(
fn endFrame(game: *Mod) !void {
// Finish render pass
game.state().frame_render_pass.end();
var command = game.state().frame_encoder.finish(null);
const label = @tagName(name) ++ ".endFrame";
var command = game.state().frame_encoder.finish(&.{ .label = label });
game.state().frame_encoder.release();
defer command.release();
mach.core.queue.submit(&[_]*gpu.CommandBuffer{command});

View file

@ -48,7 +48,9 @@ fn init(
const img_size = gpu.Extent3D{ .width = 1024, .height = 1024 };
// Create a GPU texture
const label = @tagName(name) ++ ".init";
const texture = device.createTexture(&.{
.label = label,
.size = img_size,
.format = .rgba8_unorm,
.usage = .{