From 21b061b951ec3a65bc479fabeb2d9565e08a807e Mon Sep 17 00:00:00 2001 From: skal Date: Sun, 8 Mar 2026 10:38:19 +0100 Subject: fix: transpose matrices on GPU upload (row-major → column-major) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mini_math mat4 is row-major; WGSL mat4x4f is column-major. Matrices uploaded without transposing were interpreted as their own transpose on the GPU, causing RotatingCube and Renderer3D to render upside-down. - Add gpu_upload_mat4() to post_process_helper for standalone uploads - Add Uniforms::make() to RotatingCube::Uniforms (handles transpose) - Add GlobalUniforms::make() and ObjectData::make() to renderer.h - Update renderer_draw.cc and visual_debug.cc to use make() handoff(Gemini): matrix layout bug fixed across all rasterized effects. Co-Authored-By: Claude Sonnet 4.6 --- src/3d/visual_debug.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/3d/visual_debug.cc') diff --git a/src/3d/visual_debug.cc b/src/3d/visual_debug.cc index cd4ccce..f6796d5 100644 --- a/src/3d/visual_debug.cc +++ b/src/3d/visual_debug.cc @@ -340,10 +340,9 @@ void VisualDebug::add_trajectory(const std::vector& points, } void VisualDebug::update_buffers(const mat4& view_proj) { - // Update Uniforms - fill entire GlobalUniforms structure - GlobalUniforms uniforms = {}; - uniforms.view_proj = view_proj; - // Other fields zeroed (not used by visual debug shader) + // Update Uniforms - only view_proj used by visual debug shader + const GlobalUniforms uniforms = GlobalUniforms::make( + view_proj, vec4(0, 0, 0, 0), vec4(0, 0, 0, 0), vec2(0, 0)); wgpuQueueWriteBuffer(wgpuDeviceGetQueue(device_), uniform_buffer_, 0, &uniforms, sizeof(GlobalUniforms)); -- cgit v1.2.3