Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/typegpu-color/src/oklab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ const findGamutIntersection = tgpu.fn(
[f32, f32, f32, f32, f32, LC],
f32,
)((a, b, L1, C1, L0, cusp) => {
const FLT_MAX = f32(3.40282346e38);
const FLT_MAX = 3.40282346e38;

// Find the intersection for upper and lower half separately
let t = f32(0);
Expand Down
3 changes: 3 additions & 0 deletions packages/typegpu/src/tgsl/generationHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ export function getTypeForIndexAccess(
}

export function numericLiteralToSnippet(value: number): Snippet {
if (Math.abs(value) > 2 ** 63) {
return snip(value, abstractFloat);
}
// WGSL AbstractInt uses 64-bit precision, but JS numbers are only safe up to 2^53 - 1.
// Warn when values exceed this range to prevent precision loss.
if (Number.isInteger(value)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/typegpu/tests/examples/individual/oklab.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ describe('oklab example', () => {
}

fn findGamutIntersection_13(a: f32, b: f32, L1: f32, C1: f32, L0: f32, cusp: LC_12) -> f32 {
var FLT_MAX = 3.4028234663852886e+38f;
var FLT_MAX = 3.40282346e+38;
var t = 0f;
if (((((L1 - L0) * cusp.C) - ((cusp.L - L0) * C1)) <= 0)) {
t = ((cusp.C * L0) / ((C1 * cusp.L) + (cusp.C * (L0 - L1))));
Expand Down