From de9bc553ed0e8bda42057ac441936c20a8185f60 Mon Sep 17 00:00:00 2001 From: skal Date: Sat, 21 Feb 2026 09:44:17 +0100 Subject: refactor(wgsl): Use vec*f alias for vector types Replaces all instances of `vec` with the more concise `vec*f` alias (e.g., `vec3f`) across all `.wgsl` shaders. This improves readability and aligns with common graphics programming conventions. Also adds a new coding style rule to `doc/CODING_STYLE.md` to enforce this standard going forward. Finally, this commit fixes a build error in `test_effect_base.cc` by replacing a call to the non-existent `wgpuDeviceTick` with `wgpuDevicePoll`, which resolves the test failure. --- common/shaders/camera_common.wgsl | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'common/shaders/camera_common.wgsl') diff --git a/common/shaders/camera_common.wgsl b/common/shaders/camera_common.wgsl index bd29775..c7daebf 100644 --- a/common/shaders/camera_common.wgsl +++ b/common/shaders/camera_common.wgsl @@ -9,17 +9,17 @@ struct CameraParams { } struct Ray { - origin: vec3, - direction: vec3, + origin: vec3f, + direction: vec3f, } // Generate camera ray for given UV coordinates (-1 to 1) fn getCameraRay(cam: CameraParams, uv: vec2) -> Ray { - let cam_pos = vec3(cam.inv_view[3].x, cam.inv_view[3].y, cam.inv_view[3].z); + let cam_pos = vec3f(cam.inv_view[3].x, cam.inv_view[3].y, cam.inv_view[3].z); // Compute ray direction from FOV and aspect ratio let tan_fov = tan(cam.fov * 0.5); - let ndc = vec3(uv.x * cam.aspect_ratio * tan_fov, uv.y * tan_fov, -1.0); + let ndc = vec3f(uv.x * cam.aspect_ratio * tan_fov, uv.y * tan_fov, -1.0); // Transform direction by inverse view matrix (rotation only) let dir = normalize( @@ -32,21 +32,21 @@ fn getCameraRay(cam: CameraParams, uv: vec2) -> Ray { } // Extract camera position from inverse view matrix -fn getCameraPosition(cam: CameraParams) -> vec3 { - return vec3(cam.inv_view[3].x, cam.inv_view[3].y, cam.inv_view[3].z); +fn getCameraPosition(cam: CameraParams) -> vec3f { + return vec3f(cam.inv_view[3].x, cam.inv_view[3].y, cam.inv_view[3].z); } // Extract camera forward vector (view direction) -fn getCameraForward(cam: CameraParams) -> vec3 { - return -normalize(vec3(cam.inv_view[2].x, cam.inv_view[2].y, cam.inv_view[2].z)); +fn getCameraForward(cam: CameraParams) -> vec3f { + return -normalize(vec3f(cam.inv_view[2].x, cam.inv_view[2].y, cam.inv_view[2].z)); } // Extract camera up vector -fn getCameraUp(cam: CameraParams) -> vec3 { - return normalize(vec3(cam.inv_view[1].x, cam.inv_view[1].y, cam.inv_view[1].z)); +fn getCameraUp(cam: CameraParams) -> vec3f { + return normalize(vec3f(cam.inv_view[1].x, cam.inv_view[1].y, cam.inv_view[1].z)); } // Extract camera right vector -fn getCameraRight(cam: CameraParams) -> vec3 { - return normalize(vec3(cam.inv_view[0].x, cam.inv_view[0].y, cam.inv_view[0].z)); +fn getCameraRight(cam: CameraParams) -> vec3f { + return normalize(vec3f(cam.inv_view[0].x, cam.inv_view[0].y, cam.inv_view[0].z)); } -- cgit v1.2.3