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/gpu/post_process_helper.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/gpu/post_process_helper.cc') diff --git a/src/gpu/post_process_helper.cc b/src/gpu/post_process_helper.cc index b0121e4..79fda20 100644 --- a/src/gpu/post_process_helper.cc +++ b/src/gpu/post_process_helper.cc @@ -67,6 +67,12 @@ create_post_process_pipeline_simple(WGPUDevice device, WGPUTextureFormat format, return pipeline; } +void gpu_upload_mat4(WGPUQueue queue, WGPUBuffer buffer, size_t offset, + const mat4& m) { + const mat4 t = mat4::transpose(m); + wgpuQueueWriteBuffer(queue, buffer, offset, &t, sizeof(mat4)); +} + // --- PostProcess Implementation Helper --- static GpuBuffer g_dummy_buffer = {nullptr, 0}; -- cgit v1.2.3