diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-14 14:03:58 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-14 14:03:58 +0100 |
| commit | 61ced8aa1946cc32de4328cc75b5faf6b77723be (patch) | |
| tree | 142bad05c24362d7051e80acabaddd6bac2bb753 /src/gpu/effect.cc | |
| parent | 197a03c24baba3acc35327e0e126ec49754f9945 (diff) | |
Refactor: add gpu_create_texture_view_2d helper
Reduces WGPUTextureViewDescriptor boilerplate from 5-7 lines to 1-2.
Helper supports optional mip_levels parameter (defaults to 1).
Updated 17 call sites across gpu/, tests/, and tools/.
Net: -82 lines. All tests passing (34/34).
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'src/gpu/effect.cc')
| -rw-r--r-- | src/gpu/effect.cc | 30 |
1 files changed, 6 insertions, 24 deletions
diff --git a/src/gpu/effect.cc b/src/gpu/effect.cc index 3ee2acd..52128c4 100644 --- a/src/gpu/effect.cc +++ b/src/gpu/effect.cc @@ -127,14 +127,10 @@ void MainSequence::create_framebuffers(int width, int height) { framebuffer_a_ = wgpuDeviceCreateTexture(gpu_ctx.device, &desc); framebuffer_b_ = wgpuDeviceCreateTexture(gpu_ctx.device, &desc); - WGPUTextureViewDescriptor view_desc = {}; - view_desc.dimension = WGPUTextureViewDimension_2D; - view_desc.format = gpu_ctx.format; - view_desc.mipLevelCount = 1; - view_desc.arrayLayerCount = 1; - - framebuffer_view_a_ = wgpuTextureCreateView(framebuffer_a_, &view_desc); - framebuffer_view_b_ = wgpuTextureCreateView(framebuffer_b_, &view_desc); + framebuffer_view_a_ = + gpu_create_texture_view_2d(framebuffer_a_, gpu_ctx.format); + framebuffer_view_b_ = + gpu_create_texture_view_2d(framebuffer_b_, gpu_ctx.format); // Depth Buffer WGPUTextureDescriptor depth_desc = {}; @@ -478,14 +474,7 @@ void MainSequence::register_auxiliary_texture(const char* name, int width, FATAL_CHECK(!texture, "Failed to create auxiliary texture: %s\n", name); // Create view - const WGPUTextureViewDescriptor view_desc = { - .format = gpu_ctx.format, - .dimension = WGPUTextureViewDimension_2D, - .mipLevelCount = 1, - .arrayLayerCount = 1, - }; - - WGPUTextureView view = wgpuTextureCreateView(texture, &view_desc); + WGPUTextureView view = gpu_create_texture_view_2d(texture, gpu_ctx.format); FATAL_CHECK(!view, "Failed to create auxiliary texture view: %s\n", name); // Store in registry @@ -535,14 +524,7 @@ void MainSequence::resize_auxiliary_texture(const char* name, int width, FATAL_CHECK(!texture, "Failed to resize auxiliary texture: %s\n", name); // Create view - const WGPUTextureViewDescriptor view_desc = { - .format = gpu_ctx.format, - .dimension = WGPUTextureViewDimension_2D, - .mipLevelCount = 1, - .arrayLayerCount = 1, - }; - - WGPUTextureView view = wgpuTextureCreateView(texture, &view_desc); + WGPUTextureView view = gpu_create_texture_view_2d(texture, gpu_ctx.format); FATAL_CHECK(!view, "Failed to create resized auxiliary texture view: %s\n", name); |
