diff options
Diffstat (limited to 'src/gpu/gpu.cc')
| -rw-r--r-- | src/gpu/gpu.cc | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/gpu/gpu.cc b/src/gpu/gpu.cc index 707ffe2..79498e3 100644 --- a/src/gpu/gpu.cc +++ b/src/gpu/gpu.cc @@ -26,7 +26,7 @@ static WGPURenderPipeline g_render_pipeline = nullptr; static WGPUBuffer g_uniform_buffer = nullptr; static WGPUBindGroup g_bind_group = nullptr; -static WGPUStringView str_view(const char *str) { +static WGPUStringView label_view(const char *str) { #ifndef STRIP_ALL if (!str) return {nullptr, 0}; return {str, strlen(str)}; @@ -36,6 +36,11 @@ static WGPUStringView str_view(const char *str) { #endif } +static WGPUStringView str_view(const char *str) { + if (!str) return {nullptr, 0}; + return {str, strlen(str)}; +} + #ifndef STRIP_ALL static void handle_request_adapter(WGPURequestAdapterStatus status, WGPUAdapter adapter, WGPUStringView message, @@ -147,7 +152,7 @@ void gpu_init(GLFWwindow *window) { } WGPUDeviceDescriptor device_desc = {}; - device_desc.label = str_view("Demo Device"); + device_desc.label = label_view("Demo Device"); #ifndef STRIP_ALL device_desc.uncapturedErrorCallbackInfo.callback = handle_device_error; #endif @@ -173,13 +178,13 @@ void gpu_init(GLFWwindow *window) { WGPUShaderModuleDescriptor shader_module_desc = {}; shader_module_desc.nextInChain = &wgsl_src.chain; - shader_module_desc.label = str_view("Demo Shader"); + shader_module_desc.label = label_view("Demo Shader"); WGPUShaderModule shader_module = wgpuDeviceCreateShaderModule(g_device, &shader_module_desc); WGPUBufferDescriptor uniform_buffer_desc = {}; - uniform_buffer_desc.label = str_view("Uniform Buffer"); + uniform_buffer_desc.label = label_view("Uniform Buffer"); uniform_buffer_desc.usage = WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst; uniform_buffer_desc.size = sizeof(float) * 2; g_uniform_buffer = wgpuDeviceCreateBuffer(g_device, &uniform_buffer_desc); @@ -191,6 +196,7 @@ void gpu_init(GLFWwindow *window) { bgl_entry.buffer.minBindingSize = sizeof(float) * 2; WGPUBindGroupLayoutDescriptor bgl_desc = {}; + bgl_desc.label = label_view("Uniform Bind Group Layout"); bgl_desc.entryCount = 1; bgl_desc.entries = &bgl_entry; WGPUBindGroupLayout bind_group_layout = @@ -202,12 +208,14 @@ void gpu_init(GLFWwindow *window) { bg_entry.size = sizeof(float) * 2; WGPUBindGroupDescriptor bg_desc = {}; + bg_desc.label = label_view("Uniform Bind Group"); bg_desc.layout = bind_group_layout; bg_desc.entryCount = 1; bg_desc.entries = &bg_entry; g_bind_group = wgpuDeviceCreateBindGroup(g_device, &bg_desc); WGPUPipelineLayoutDescriptor pl_desc = {}; + pl_desc.label = label_view("Render Pipeline Layout"); pl_desc.bindGroupLayoutCount = 1; pl_desc.bindGroupLayouts = &bind_group_layout; WGPUPipelineLayout pipeline_layout = @@ -224,6 +232,7 @@ void gpu_init(GLFWwindow *window) { fragment_state.targets = &color_target; WGPURenderPipelineDescriptor pipeline_desc = {}; + pipeline_desc.label = label_view("Render Pipeline"); pipeline_desc.layout = pipeline_layout; pipeline_desc.vertex.module = shader_module; pipeline_desc.vertex.entryPoint = str_view("vs_main"); @@ -263,6 +272,7 @@ void gpu_draw(float audio_peak, float aspect_ratio) { wgpuQueueWriteBuffer(g_queue, g_uniform_buffer, 0, &uniforms, sizeof(uniforms)); WGPUCommandEncoderDescriptor encoder_desc = {}; + encoder_desc.label = label_view("Command Encoder"); WGPUCommandEncoder encoder = wgpuDeviceCreateCommandEncoder(g_device, &encoder_desc); @@ -275,6 +285,7 @@ void gpu_draw(float audio_peak, float aspect_ratio) { color_attachment.depthSlice = WGPU_DEPTH_SLICE_UNDEFINED; WGPURenderPassDescriptor render_pass_desc = {}; + render_pass_desc.label = label_view("Render Pass"); render_pass_desc.colorAttachmentCount = 1; render_pass_desc.colorAttachments = &color_attachment; @@ -288,6 +299,7 @@ void gpu_draw(float audio_peak, float aspect_ratio) { wgpuRenderPassEncoderEnd(pass); WGPUCommandBufferDescriptor cmd_desc = {}; + cmd_desc.label = label_view("Command Buffer"); WGPUCommandBuffer commands = wgpuCommandEncoderFinish(encoder, &cmd_desc); wgpuQueueSubmit(g_queue, 1, &commands); wgpuSurfacePresent(g_surface); |
