Skip to content

Commit

Permalink
Switch memory model tests to use PRNG
Browse files Browse the repository at this point in the history
* Switch to PRNG from Math.random
  • Loading branch information
alan-baker committed Feb 12, 2024
1 parent 5d354c0 commit 3de97e5
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { GPUTest } from '../../../gpu_test.js';
import { checkElementsPassPredicate } from '../../../util/check_contents.js';
import { align } from '../../../util/math.js';
import { PRNG } from '../../../util/prng.js';

/* All buffer sizes are counted in units of 4-byte words. */

Expand Down Expand Up @@ -191,6 +192,7 @@ export class MemoryModelTester {
protected testBindGroup: GPUBindGroup;
protected resultPipeline: GPUComputePipeline;
protected resultBindGroup: GPUBindGroup;
protected prng: PRNG;

/** Sets up a memory model test by initializing buffers and pipeline layouts. */
constructor(
Expand All @@ -200,6 +202,7 @@ export class MemoryModelTester {
resultShader: string,
accessValueType: AccessValueType = 'u32'
) {
this.prng = new PRNG(1);
this.test = t;
this.params = params;

Expand Down Expand Up @@ -521,7 +524,7 @@ export class MemoryModelTester {

/** Returns a random integer between 0 and the max. */
protected getRandomInt(max: number): number {
return Math.floor(Math.random() * max);
return this.prng.randomU32() % max;
}

/** Returns a random number in between the min and max values. */
Expand Down

0 comments on commit 3de97e5

Please sign in to comment.