From 4d12f229d6315192ba97350d9d9ebbfab3f1383d Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Sun, 6 Mar 2022 15:27:29 -0700 Subject: [PATCH] gpu: document coordinate system, WebGPU spec location Signed-off-by: Stephen Gutekanst --- gpu/src/main.zig | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/gpu/src/main.zig b/gpu/src/main.zig index ecfeade1..66c72a83 100644 --- a/gpu/src/main.zig +++ b/gpu/src/main.zig @@ -1,10 +1,18 @@ +//! WebGPU interface for Zig +//! +//! # Coordinate Systems +//! +//! * Y-axis is up in normalized device coordinate (NDC): point(-1.0, -1.0) in NDC is located at +//! the bottom-left corner of NDC. In addition, x and y in NDC should be between -1.0 and 1.0 +//! inclusive, while z in NDC should be between 0.0 and 1.0 inclusive. Vertices out of this range +//! in NDC will not introduce any errors, but they will be clipped. +//! * Y-axis is down in framebuffer coordinate, viewport coordinate and fragment/pixel coordinate: +//! origin(0, 0) is located at the top-left corner in these coordinate systems. +//! * Window/present coordinate matches framebuffer coordinate. +//! * UV of origin(0, 0) in texture coordinate represents the first texel (the lowest byte) in +//! texture memory. +//! +//! Note: WebGPU’s coordinate systems match DirectX’s coordinate systems in a graphics pipeline. +//! +//! https://gpuweb.github.io/gpuweb const std = @import("std"); -const testing = std.testing; - -export fn add(a: i32, b: i32) i32 { - return a + b; -} - -test "basic add functionality" { - try testing.expect(add(3, 7) == 10); -}