Skip to content

Commit ec31f66

Browse files
committed
no more warnings about absent seeds
1 parent 8da1ac8 commit ec31f66

4 files changed

Lines changed: 8 additions & 16 deletions

File tree

apps/typegpu-docs/src/examples/tests/uniformity/constants.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import type { PRNGKey } from './prngs.ts';
2-
31
export const gridSizes = [8, 16, 32, 64, 128, 256, 512, 1024];
42
export const initialGridSize = gridSizes[4];
53
export const samplesPerThread = [1, 8, 16, 64, 256, 1024, 131072, 262144];

apps/typegpu-docs/src/examples/tests/uniformity/index.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@ const presentationFormat = navigator.gpu.getPreferredCanvasFormat();
1414
const Config = d.struct({
1515
gridSize: d.f32,
1616
canvasRatio: d.f32,
17-
useSeed2: d.u32,
1817
samplesPerThread: d.u32,
1918
takeAverage: d.u32,
2019
});
2120

2221
const configUniform = root.createUniform(Config, {
2322
gridSize: c.initialGridSize,
2423
canvasRatio: canvas.width / canvas.height,
25-
useSeed2: d.u32(prngs[initialPRNG].useSeed2),
2624
samplesPerThread: c.initialSamplesPerThread,
2725
takeAverage: d.u32(c.initialTakeAverage),
2826
});
@@ -38,7 +36,7 @@ const layouts = {
3836

3937
const bindGroups = Object.fromEntries(
4038
c.gridSizes.map((size) => {
41-
const texture = root['~unstable']
39+
const texture = root
4240
.createTexture({ size: [size, size], format: 'r32float' })
4341
.$usage('storage', 'sampled');
4442
return [
@@ -68,10 +66,10 @@ const computeFn = (x: number, y: number) => {
6866
'use gpu';
6967
const gridSize = configUniform.$.gridSize;
7068

71-
if (configUniform.$.useSeed2 === 1) {
72-
randf.seed2(d.vec2f(x, y) + 1);
73-
} else {
69+
if (!randomGeneratorSlot.$.seed2) {
7470
randf.seed(d.f32(x + 1) * gridSize + d.f32(y + 1));
71+
} else {
72+
randf.seed2(d.vec2f(x, y) + 1);
7573
}
7674

7775
let i = d.u32(0);
@@ -120,7 +118,6 @@ export const controls = defineControls({
120118
options: prngKeys,
121119
onSelectChange: (value) => {
122120
prng = value;
123-
configUniform.writePartial({ useSeed2: d.u32(prngs[value].useSeed2) });
124121
redraw();
125122
},
126123
},

apps/typegpu-docs/src/examples/tests/uniformity/prngs.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@ import { BPETER, LCG32, LCG64, XOROSHIRO64STARSTAR, type StatefulGenerator } fro
22

33
interface PRNGOptions {
44
name: string;
5-
useSeed2: boolean;
65
generator: StatefulGenerator;
76
}
87

98
export const prngs = {
10-
bpeter: { name: 'bpeter (default)', useSeed2: true, generator: BPETER },
11-
lcg32: { name: 'lcg32', useSeed2: false, generator: LCG32 },
12-
lcg64: { name: 'lcg64', useSeed2: true, generator: LCG64 },
13-
xoroshiro64: { name: 'xoroshiro64', useSeed2: true, generator: XOROSHIRO64STARSTAR },
9+
bpeter: { name: 'bpeter (default)', generator: BPETER },
10+
lcg32: { name: 'lcg32', generator: LCG32 },
11+
lcg64: { name: 'lcg64', generator: LCG64 },
12+
xoroshiro64: { name: 'xoroshiro64', generator: XOROSHIRO64STARSTAR },
1413
} as const satisfies Record<string, PRNGOptions>;
1514

1615
export type PRNGKey = keyof typeof prngs;

packages/typegpu-noise/src/random.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ const warnIfNotProvided = tgpu.comptime((seedFnName: keyof typeof randomGenerato
99
if (!randomGeneratorSlot.$[seedFnName]) {
1010
console.warn(`Called \`randf.${seedFnName}\`, but it wasn't provided`);
1111
}
12-
13-
return undefined;
1412
});
1513

1614
export const randSeed = tgpu.fn([d.f32])((seed) => {

0 commit comments

Comments
 (0)