Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Update resolve test
  • Loading branch information
Aleksander Katan committed Aug 26, 2025
commit 02caa8a1588d57e7fa1680c9bec3cf16edb6ac01
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now, in indexAccess, the index is resolved first, thus the reordering in this file

Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@ describe('fluid with atomics example', () => {
@builtin(global_invocation_id) gid: vec3u,
}

@group(0) @binding(0) var<storage, read_write> nextState_5: array<atomic<u32>, 1048576>;
@group(0) @binding(0) var<uniform> size_6: vec2u;

@group(0) @binding(1) var<uniform> size_7: vec2u;

fn getIndex_6(x: u32, y: u32) -> u32 {
var h = size_7.y;
var w = size_7.x;
fn getIndex_5(x: u32, y: u32) -> u32 {
var h = size_6.y;
var w = size_6.x;
return (((y % h) * w) + (x % w));
}

@group(0) @binding(1) var<storage, read_write> nextState_7: array<atomic<u32>, 1048576>;

fn updateCell_4(x: u32, y: u32, value: u32) {
atomicStore(&nextState_5[getIndex_6(x, y)], value);
atomicStore(&nextState_7[getIndex_5(x, y)], value);
}

@group(0) @binding(2) var<storage, read> currentStateBuffer_10: array<u32, 1048576>;

fn getCell_9(x: u32, y: u32) -> u32 {
return currentStateBuffer_10[getIndex_6(x, y)];
return currentStateBuffer_10[getIndex_5(x, y)];
}

fn isClearCell_8(x: u32, y: u32) -> bool {
Expand All @@ -59,14 +59,14 @@ describe('fluid with atomics example', () => {
}

fn getCellNext_15(x: u32, y: u32) -> u32 {
return atomicLoad(&nextState_5[getIndex_6(x, y)]);
return atomicLoad(&nextState_7[getIndex_5(x, y)]);
}

fn addToCell_14(x: u32, y: u32, value: u32) {
var cell = getCellNext_15(x, y);
var waterLevel = (cell & MAX_WATER_LEVEL_12);
var newWaterLevel = min((waterLevel + value), MAX_WATER_LEVEL_12);
atomicAdd(&nextState_5[getIndex_6(x, y)], (newWaterLevel - waterLevel));
atomicAdd(&nextState_7[getIndex_5(x, y)], (newWaterLevel - waterLevel));
}

fn isWaterSource_16(x: u32, y: u32) -> bool {
Expand All @@ -81,7 +81,7 @@ describe('fluid with atomics example', () => {
var cell = getCellNext_15(x, y);
var waterLevel = (cell & MAX_WATER_LEVEL_12);
var newWaterLevel = max((waterLevel - min(value, waterLevel)), 0);
atomicSub(&nextState_5[getIndex_6(x, y)], (waterLevel - newWaterLevel));
atomicSub(&nextState_7[getIndex_5(x, y)], (waterLevel - newWaterLevel));
}

fn getWaterLevel_19(x: u32, y: u32) -> u32 {
Expand All @@ -107,7 +107,7 @@ describe('fluid with atomics example', () => {
updateCell_4(x, y, (3 << 24));
return true;
}
if (((((y == 0) || (y == (size_7.y - 1))) || (x == 0)) || (x == (size_7.x - 1)))) {
if (((((y == 0) || (y == (size_6.y - 1))) || (x == 0)) || (x == (size_6.x - 1)))) {
subtractFromCell_18(x, y, getWaterLevel_19(x, y));
return true;
}
Expand Down