Add labels to GPU objects

main
copygirl 8 months ago
parent 8e9be881dd
commit 42619616cc
  1. 9
      src/renderer.zig

@ -37,12 +37,16 @@ primitive_data: []PrimitiveData,
object_data: []ObjectData,
pub fn init(app: *App) !*Renderer {
// A string buffer used to format objects' labels.
var label_buffer: [256]u8 = undefined;
const shader_module = core.device.createShaderModuleWGSL("shader.wgsl", @embedFile("shader.wgsl"));
defer shader_module.release();
// Define layouts for our bind groups and pipeline.
// This helps find errors with missing or mismatching shader properties.
var camera_bind_group_layout = core.device.createBindGroupLayout(&gpu.BindGroupLayout.Descriptor.init(.{
.label = "Camera Bind Group Layout",
.entries = &.{
gpu.BindGroupLayout.Entry.buffer(0, .{ .vertex = true }, .uniform, false, 0),
},
@ -50,6 +54,7 @@ pub fn init(app: *App) !*Renderer {
defer camera_bind_group_layout.release();
var model_bind_group_layout = core.device.createBindGroupLayout(&gpu.BindGroupLayout.Descriptor.init(.{
.label = "Model Bind Group Layout",
.entries = &.{
gpu.BindGroupLayout.Entry.buffer(0, .{ .vertex = true }, .uniform, false, 0),
gpu.BindGroupLayout.Entry.buffer(1, .{ .vertex = true }, .uniform, false, 0),
@ -104,6 +109,7 @@ pub fn init(app: *App) !*Renderer {
// "Bind groups" are used to associate data from buffers with shader parameters.
// So for example the `camera_bind_group` is accessible via `@group(0)` in our shader.
const camera_bind_group = core.device.createBindGroup(&gpu.BindGroup.Descriptor.init(.{
.label = "Camera Bind Group",
.layout = camera_bind_group_layout,
.entries = &.{
gpu.BindGroup.Entry.buffer(0, view_proj_buffer, 0, @sizeOf(zm.Mat)),
@ -160,7 +166,9 @@ pub fn init(app: *App) !*Renderer {
const model_color_buffer = createAndWriteBuffer([3]f32, &.{model_color}, .{ .copy_dst = true, .uniform = true });
defer model_color_buffer.release();
const model_bind_group_label = try std.fmt.bufPrintZ(&label_buffer, "Model Bind Group {d}", .{i});
const model_bind_group = core.device.createBindGroup(&gpu.BindGroup.Descriptor.init(.{
.label = model_bind_group_label,
.layout = model_bind_group_layout,
.entries = &.{
gpu.BindGroup.Entry.buffer(0, model_matrix_buffer, 0, @sizeOf(zm.Mat)),
@ -319,6 +327,7 @@ pub fn recreateDepthTexture(self: *Renderer) void {
if (self.depth_texture_view) |v| v.release();
self.depth_texture = core.device.createTexture(&.{
.label = "Depth Texture",
.usage = .{ .render_attachment = true },
.size = .{ .width = core.descriptor.width, .height = core.descriptor.height },
.format = .depth24_plus,

Loading…
Cancel
Save