diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-09 14:01:28 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-09 14:01:28 +0100 |
| commit | dd41b296f9299ce1269005452d5db8d2854ac61b (patch) | |
| tree | bfb83a07bad430a5987e39d67d0c6d16dca47589 /src | |
| parent | 744bcadfe8f4bb1b2d4f1daf9f880fa511d65405 (diff) | |
fix(3d): VisualDebug uniform buffer size mismatch
Fixed validation error in test_3d_render:
- Uniform buffer was 64 bytes (mat4) but bind group expected 176 bytes (GlobalUniforms)
- Updated buffer creation to use sizeof(GlobalUniforms)
- Updated bind group entry size to match
- Updated update_buffers to write full GlobalUniforms struct
Error was:
Binding size 64 of Buffer with '' label is less than minimum 176
Root cause: VisualDebug uses same GlobalUniforms structure as main renderer
but was only allocating/binding mat4 portion.
Testing:
- All 34 tests passing (100%)
- test_3d_render runs without validation errors
- GPU procedural textures working (noise, perlin, grid)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/3d/visual_debug.cc | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/3d/visual_debug.cc b/src/3d/visual_debug.cc index 77311f6..cd4ccce 100644 --- a/src/3d/visual_debug.cc +++ b/src/3d/visual_debug.cc @@ -26,7 +26,7 @@ void VisualDebug::init(WGPUDevice device, WGPUTextureFormat format) { WGPUBufferDescriptor ub_desc = {}; ub_desc.usage = WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst; - ub_desc.size = sizeof(mat4); + ub_desc.size = sizeof(GlobalUniforms); uniform_buffer_ = wgpuDeviceCreateBuffer(device_, &ub_desc); } @@ -340,9 +340,12 @@ void VisualDebug::add_trajectory(const std::vector<vec3>& points, } void VisualDebug::update_buffers(const mat4& view_proj) { - // Update Uniforms + // Update Uniforms - fill entire GlobalUniforms structure + GlobalUniforms uniforms = {}; + uniforms.view_proj = view_proj; + // Other fields zeroed (not used by visual debug shader) wgpuQueueWriteBuffer(wgpuDeviceGetQueue(device_), uniform_buffer_, 0, - &view_proj, sizeof(mat4)); + &uniforms, sizeof(GlobalUniforms)); // Update Vertices size_t required_size = lines_.size() * 2 * sizeof(float) * 6; @@ -385,7 +388,7 @@ void VisualDebug::update_buffers(const mat4& view_proj) { WGPUBindGroupEntry bg_entry = {}; bg_entry.binding = 0; bg_entry.buffer = uniform_buffer_; - bg_entry.size = sizeof(mat4); + bg_entry.size = sizeof(GlobalUniforms); WGPUBindGroupDescriptor bg_desc = {}; bg_desc.layout = bind_group_layout_; |
