fixing FragCoord derivatives
Test / build_and_test (push) Successful in 1m35s
Build / build (push) Successful in 3m10s

This commit is contained in:
2026-07-04 01:49:17 +02:00
parent bfc5c3933c
commit e6538d221f
2 changed files with 10 additions and 4 deletions
+8 -2
View File
@@ -70,8 +70,14 @@ pub fn shaderInvocation(
};
if (rt.getBuiltinResult(.FragCoord)) |frag_coord_word| {
const frag_coord_dx = zm.f32x4(1.0, 0.0, 0.0, 0.0);
const frag_coord_dy = zm.f32x4(0.0, 1.0, 0.0, 0.0);
const pixel_x: i32 = @intFromFloat(position[0]);
const pixel_y: i32 = @intFromFloat(position[1]);
const dx: f32 = if (@mod(pixel_x, 2) == 0) 1.0 else -1.0;
const dy: f32 = if (@mod(pixel_y, 2) == 0) 1.0 else -1.0;
rt.derivative_sign_x = dx;
rt.derivative_sign_y = dy;
const frag_coord_dx = zm.f32x4(dx, 0.0, 0.0, 0.0);
const frag_coord_dy = zm.f32x4(0.0, dy, 0.0, 0.0);
try rt.setDerivativeFromMemory(allocator, frag_coord_word, std.mem.asBytes(&frag_coord_dx), std.mem.asBytes(&frag_coord_dy));
}