Skip to content

Commit b61f81d

Browse files
authored
fix: Keep entry function argument names as close the the originals (#2507)
1 parent 56ae1c8 commit b61f81d

20 files changed

Lines changed: 140 additions & 140 deletions

apps/typegpu-docs/tests/individual-example-tests/3d-fish.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,11 @@ describe('3d fish example', () => {
285285
@location(5) @interpolate(flat) applySeaDesaturation: u32,
286286
}
287287
288-
@vertex fn vertexShader(@location(0) _arg_modelPosition: vec3f, @location(1) _arg_modelNormal: vec3f, @location(2) _arg_textureUV: vec2f, @builtin(instance_index) _arg_instanceIndex: u32) -> vertexShader_Output {
289-
let currentModelData = (&modelData[_arg_instanceIndex]);
290-
var wavedVertex = PosAndNormal(_arg_modelPosition, _arg_modelNormal);
288+
@vertex fn vertexShader(@location(0) modelPosition: vec3f, @location(1) modelNormal: vec3f, @location(2) textureUV: vec2f, @builtin(instance_index) instanceIndex: u32) -> vertexShader_Output {
289+
let currentModelData = (&modelData[instanceIndex]);
290+
var wavedVertex = PosAndNormal(modelPosition, modelNormal);
291291
if (((*currentModelData).applySinWave == 1u)) {
292-
wavedVertex = applySinWave(_arg_instanceIndex, PosAndNormal(_arg_modelPosition, _arg_modelNormal), currentTime);
292+
wavedVertex = applySinWave(instanceIndex, PosAndNormal(modelPosition, modelNormal), currentTime);
293293
}
294294
let direction = normalize((*currentModelData).direction);
295295
let yaw = (-(atan2(direction.z, direction.x)) + 3.141592653589793f);
@@ -302,7 +302,7 @@ describe('3d fish example', () => {
302302
let worldNormal = normalize(((yawMatrix * pitchMatrix) * vec4f(wavedVertex.normal, 1f)).xyz);
303303
let worldPositionUniform = (&worldPosition);
304304
let canvasPosition = ((camera.projection * camera.view) * (*worldPositionUniform));
305-
return vertexShader_Output(worldPosition.xyz, worldNormal, canvasPosition, (*currentModelData).variant, _arg_textureUV, (*currentModelData).applySeaFog, (*currentModelData).applySeaDesaturation);
305+
return vertexShader_Output(worldPosition.xyz, worldNormal, canvasPosition, (*currentModelData).variant, textureUV, (*currentModelData).applySeaFog, (*currentModelData).applySeaDesaturation);
306306
}
307307
308308
@group(0) @binding(1) var modelTexture: texture_2d<f32>;

apps/typegpu-docs/tests/individual-example-tests/bitonic-sort.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ describe('bitonic sort example', () => {
3333
3434
@group(0) @binding(0) var<storage, read> src: array<u32>;
3535
36-
@compute @workgroup_size(256) fn copyPadKernel(@builtin(global_invocation_id) _arg_gid: vec3u, @builtin(num_workgroups) _arg_numWorkgroups: vec3u) {
37-
let spanX = (_arg_numWorkgroups.x * 256u);
38-
let spanY = (_arg_numWorkgroups.y * spanX);
39-
let idx = ((_arg_gid.x + (_arg_gid.y * spanX)) + (_arg_gid.z * spanY));
36+
@compute @workgroup_size(256) fn copyPadKernel(@builtin(global_invocation_id) gid: vec3u, @builtin(num_workgroups) numWorkgroups: vec3u) {
37+
let spanX = (numWorkgroups.x * 256u);
38+
let spanY = (numWorkgroups.y * spanX);
39+
let idx = ((gid.x + (gid.y * spanX)) + (gid.z * spanY));
4040
let dstLength = params.dstLength;
4141
let srcLength = params.srcLength;
4242
if ((idx >= dstLength)) {
@@ -58,10 +58,10 @@ describe('bitonic sort example', () => {
5858
return (a < b);
5959
}
6060
61-
@compute @workgroup_size(256) fn bitonicStepKernel(@builtin(global_invocation_id) _arg_gid: vec3u, @builtin(num_workgroups) _arg_numWorkgroups: vec3u) {
62-
let spanX = (_arg_numWorkgroups.x * 256u);
63-
let spanY = (_arg_numWorkgroups.y * spanX);
64-
let tid = ((_arg_gid.x + (_arg_gid.y * spanX)) + (_arg_gid.z * spanY));
61+
@compute @workgroup_size(256) fn bitonicStepKernel(@builtin(global_invocation_id) gid: vec3u, @builtin(num_workgroups) numWorkgroups: vec3u) {
62+
let spanX = (numWorkgroups.x * 256u);
63+
let spanY = (numWorkgroups.y * spanX);
64+
let tid = ((gid.x + (gid.y * spanX)) + (gid.z * spanY));
6565
let k = uniforms.k;
6666
let shift = uniforms.jShift;
6767
let dataLength = arrayLength(&data);
@@ -97,10 +97,10 @@ describe('bitonic sort example', () => {
9797
9898
@group(0) @binding(0) var<storage, read> src: array<u32>;
9999
100-
@compute @workgroup_size(256) fn copyBackKernel(@builtin(global_invocation_id) _arg_gid: vec3u, @builtin(num_workgroups) _arg_numWorkgroups: vec3u) {
101-
let spanX = (_arg_numWorkgroups.x * 256u);
102-
let spanY = (_arg_numWorkgroups.y * spanX);
103-
let idx = ((_arg_gid.x + (_arg_gid.y * spanX)) + (_arg_gid.z * spanY));
100+
@compute @workgroup_size(256) fn copyBackKernel(@builtin(global_invocation_id) gid: vec3u, @builtin(num_workgroups) numWorkgroups: vec3u) {
101+
let spanX = (numWorkgroups.x * 256u);
102+
let spanY = (numWorkgroups.y * spanX);
103+
let idx = ((gid.x + (gid.y * spanX)) + (gid.z * spanY));
104104
if ((idx < params.srcLength)) {
105105
dst[idx] = src[idx];
106106
}

apps/typegpu-docs/tests/individual-example-tests/boids.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ describe('boids example', () => {
106106
@location(0) color: vec4f,
107107
}
108108
109-
@vertex fn mainVert(@location(0) _arg_v: vec2f, @location(1) _arg_center: vec2f, @location(2) _arg_velocity: vec2f) -> mainVert_Output {
110-
let angle = getRotationFromVelocity(_arg_velocity);
111-
let rotated = rotate(_arg_v, angle);
112-
let pos = vec4f((rotated + _arg_center), 0f, 1f);
109+
@vertex fn mainVert(@location(0) v: vec2f, @location(1) center: vec2f, @location(2) velocity: vec2f) -> mainVert_Output {
110+
let angle = getRotationFromVelocity(velocity);
111+
let rotated = rotate(v, angle);
112+
let pos = vec4f((rotated + center), 0f, 1f);
113113
let color = vec4f(((sin((colorPalette + angle)) * 0.45f) + 0.45f), 1f);
114114
return mainVert_Output(pos, color);
115115
}

apps/typegpu-docs/tests/individual-example-tests/cubemap-reflection.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ describe('cubemap reflection example', () => {
6363
return vec2u(xy, zw);
6464
}
6565
66-
@compute @workgroup_size(256, 1, 1) fn computeFn(@builtin(global_invocation_id) _arg_gid: vec3u) {
66+
@compute @workgroup_size(256, 1, 1) fn computeFn(@builtin(global_invocation_id) gid: vec3u) {
6767
let prevVertices = (&prevVertices_1);
6868
let nextVertices = (&nextVertices_1);
6969
let smoothFlag = smoothFlag_1;
7070
let triangleCount = u32((f32(arrayLength(&(*prevVertices))) / 3f));
71-
let triangleIndex = (_arg_gid.x + (_arg_gid.y * 65535u));
71+
let triangleIndex = (gid.x + (gid.y * 65535u));
7272
if ((triangleIndex >= triangleCount)) {
7373
return;
7474
}
@@ -252,9 +252,9 @@ describe('cubemap reflection example', () => {
252252
@location(0) texCoord: vec3f,
253253
}
254254
255-
@vertex fn cubeVertexFn(@location(0) _arg_position: vec3f) -> cubeVertexFn_Output {
256-
let viewPos = (camera.view * vec4f(_arg_position.xyz, 0f)).xyz;
257-
return cubeVertexFn_Output((camera.projection * vec4f(viewPos, 1f)), _arg_position.xyz);
255+
@vertex fn cubeVertexFn(@location(0) position: vec3f) -> cubeVertexFn_Output {
256+
let viewPos = (camera.view * vec4f(position.xyz, 0f)).xyz;
257+
return cubeVertexFn_Output((camera.projection * vec4f(viewPos, 1f)), position.xyz);
258258
}
259259
260260
@group(1) @binding(0) var cubemap: texture_cube<f32>;
@@ -283,8 +283,8 @@ describe('cubemap reflection example', () => {
283283
@location(1) worldPos: vec4f,
284284
}
285285
286-
@vertex fn vertexFn(@location(0) _arg_position: vec4f, @location(1) _arg_normal: vec4f) -> vertexFn_Output {
287-
return vertexFn_Output((camera.projection * (camera.view * _arg_position)), _arg_normal, _arg_position);
286+
@vertex fn vertexFn(@location(0) position: vec4f, @location(1) normal: vec4f) -> vertexFn_Output {
287+
return vertexFn_Output((camera.projection * (camera.view * position)), normal, position);
288288
}
289289
290290
struct DirectionalLight {

apps/typegpu-docs/tests/individual-example-tests/fluid-double-buffering.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,10 +552,10 @@ describe('fluid double buffering example', () => {
552552
@location(0) uv: vec2f,
553553
}
554554
555-
@vertex fn vertexMain(@builtin(vertex_index) _arg_idx: u32) -> vertexMain_Output {
555+
@vertex fn vertexMain(@builtin(vertex_index) idx: u32) -> vertexMain_Output {
556556
let pos = array<vec2f, 4>(vec2f(1), vec2f(-1, 1), vec2f(1, -1), vec2f(-1));
557557
let uv = array<vec2f, 4>(vec2f(1), vec2f(0, 1), vec2f(1, 0), vec2f());
558-
return vertexMain_Output(vec4f(pos[_arg_idx].x, pos[_arg_idx].y, 0f, 1f), uv[_arg_idx]);
558+
return vertexMain_Output(vec4f(pos[idx].x, pos[idx].y, 0f, 1f), uv[idx]);
559559
}
560560
561561
fn coordsToIndex(x: i32, y: i32) -> i32 {

apps/typegpu-docs/tests/individual-example-tests/fluid-with-atomics.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@ describe('fluid with atomics example', () => {
190190
}
191191
}
192192
193-
@compute @workgroup_size(1, 1) fn compute(@builtin(global_invocation_id) _arg_gid: vec3u) {
194-
decideWaterLevel(_arg_gid.x, _arg_gid.y);
193+
@compute @workgroup_size(1, 1) fn compute(@builtin(global_invocation_id) gid: vec3u) {
194+
decideWaterLevel(gid.x, gid.y);
195195
}
196196
197197
@group(0) @binding(0) var<uniform> size: vec2u;
@@ -201,16 +201,16 @@ describe('fluid with atomics example', () => {
201201
@location(0) cell: f32,
202202
}
203203
204-
@vertex fn vertex(@location(0) _arg_squareData: vec2f, @location(1) _arg_currentStateData: u32, @builtin(instance_index) _arg_idx: u32) -> vertex_Output {
204+
@vertex fn vertex(@location(0) squareData: vec2f, @location(1) currentStateData: u32, @builtin(instance_index) idx: u32) -> vertex_Output {
205205
let w = size.x;
206206
let h = size.y;
207-
let gridX = (_arg_idx % w);
208-
let gridY = u32((f32(_arg_idx) / f32(w)));
207+
let gridX = (idx % w);
208+
let gridY = u32((f32(idx) / f32(w)));
209209
let maxDim = max(w, h);
210-
let x = (((2f * (f32(gridX) + _arg_squareData.x)) - f32(w)) / f32(maxDim));
211-
let y = (((2f * (f32(gridY) + _arg_squareData.y)) - f32(h)) / f32(maxDim));
212-
let cellFlags = (_arg_currentStateData >> 24u);
213-
var cell = f32((_arg_currentStateData & 16777215u));
210+
let x = (((2f * (f32(gridX) + squareData.x)) - f32(w)) / f32(maxDim));
211+
let y = (((2f * (f32(gridY) + squareData.y)) - f32(h)) / f32(maxDim));
212+
let cellFlags = (currentStateData >> 24u);
213+
var cell = f32((currentStateData & 16777215u));
214214
if ((cellFlags == 1u)) {
215215
cell = -1f;
216216
}

apps/typegpu-docs/tests/individual-example-tests/gravity.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ describe('gravity example', () => {
8787
8888
@group(0) @binding(2) var<storage, read_write> outState: array<CelestialBody>;
8989
90-
@compute @workgroup_size(1) fn computeCollisionsShader(@builtin(global_invocation_id) _arg_gid: vec3u) {
91-
let currentId = _arg_gid.x;
90+
@compute @workgroup_size(1) fn computeCollisionsShader(@builtin(global_invocation_id) gid: vec3u) {
91+
let currentId = gid.x;
9292
var current = inState[currentId];
9393
if ((current.destroyed == 0u)) {
9494
for (var otherId = 0u; (otherId < u32(celestialBodiesCount)); otherId++) {
@@ -151,9 +151,9 @@ describe('gravity example', () => {
151151
152152
@group(1) @binding(2) var<storage, read_write> outState: array<CelestialBody>;
153153
154-
@compute @workgroup_size(1) fn computeGravityShader(@builtin(global_invocation_id) _arg_gid: vec3u) {
154+
@compute @workgroup_size(1) fn computeGravityShader(@builtin(global_invocation_id) gid: vec3u) {
155155
let dt = (time.passed * time.multiplier);
156-
let currentId = _arg_gid.x;
156+
let currentId = gid.x;
157157
var current = inState[currentId];
158158
if ((current.destroyed == 0u)) {
159159
for (var otherId = 0u; (otherId < u32(celestialBodiesCount)); otherId++) {
@@ -187,9 +187,9 @@ describe('gravity example', () => {
187187
@location(0) texCoord: vec3f,
188188
}
189189
190-
@vertex fn skyBoxVertex(@location(0) _arg_position: vec3f) -> skyBoxVertex_Output {
191-
let viewPos = (camera.view * vec4f(_arg_position, 0f)).xyz;
192-
return skyBoxVertex_Output((camera.projection * vec4f(viewPos, 1f)), _arg_position.xyz);
190+
@vertex fn skyBoxVertex(@location(0) position: vec3f) -> skyBoxVertex_Output {
191+
let viewPos = (camera.view * vec4f(position, 0f)).xyz;
192+
return skyBoxVertex_Output((camera.projection * vec4f(viewPos, 1f)), position.xyz);
193193
}
194194
195195
@group(0) @binding(1) var skyBox: texture_cube<f32>;
@@ -242,12 +242,12 @@ describe('gravity example', () => {
242242
@location(5) ambientLightFactor: f32,
243243
}
244244
245-
@vertex fn mainVertex(@location(0) _arg_position: vec3f, @location(1) _arg_normal: vec3f, @location(2) _arg_uv: vec2f, @builtin(instance_index) _arg_instanceIndex: u32) -> mainVertex_Output {
246-
let currentBody = (&celestialBodies[_arg_instanceIndex]);
247-
let worldPosition = ((*currentBody).position + (_arg_position.xyz * radiusOf((*currentBody))));
245+
@vertex fn mainVertex(@location(0) position: vec3f, @location(1) normal: vec3f, @location(2) uv: vec2f, @builtin(instance_index) instanceIndex: u32) -> mainVertex_Output {
246+
let currentBody = (&celestialBodies[instanceIndex]);
247+
let worldPosition = ((*currentBody).position + (position.xyz * radiusOf((*currentBody))));
248248
let camera = (&camera_1);
249249
let positionOnCanvas = (((*camera).projection * (*camera).view) * vec4f(worldPosition, 1f));
250-
return mainVertex_Output(positionOnCanvas, _arg_uv, _arg_normal, worldPosition, (*currentBody).textureIndex, (*currentBody).destroyed, (*currentBody).ambientLightFactor);
250+
return mainVertex_Output(positionOnCanvas, uv, normal, worldPosition, (*currentBody).textureIndex, (*currentBody).destroyed, (*currentBody).ambientLightFactor);
251251
}
252252
253253
@group(1) @binding(0) var celestialBodyTextures: texture_2d_array<f32>;

apps/typegpu-docs/tests/individual-example-tests/log-test.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,9 +1448,9 @@ describe('console log example', () => {
14481448
@builtin(position) pos: vec4f,
14491449
}
14501450
1451-
@vertex fn mainVertex(@builtin(vertex_index) _arg_vertexIndex: u32) -> mainVertex_Output {
1451+
@vertex fn mainVertex(@builtin(vertex_index) vertexIndex: u32) -> mainVertex_Output {
14521452
let positions = array<vec2f, 3>(vec2f(0, 0.5), vec2f(-0.5), vec2f(0.5, -0.5));
1453-
return mainVertex_Output(vec4f(positions[_arg_vertexIndex], 0f, 1f));
1453+
return mainVertex_Output(vec4f(positions[vertexIndex], 0f, 1f));
14541454
}
14551455
14561456
@group(0) @binding(0) var<storage, read_write> indexBuffer: atomic<u32>;
@@ -1501,9 +1501,9 @@ describe('console log example', () => {
15011501
@builtin(position) pos: vec4f,
15021502
}
15031503
1504-
@vertex fn mainVertex(@builtin(vertex_index) _arg_vertexIndex: u32) -> mainVertex_Output {
1504+
@vertex fn mainVertex(@builtin(vertex_index) vertexIndex: u32) -> mainVertex_Output {
15051505
let positions = array<vec2f, 3>(vec2f(0, 0.5), vec2f(-0.5), vec2f(0.5, -0.5));
1506-
return mainVertex_Output(vec4f(positions[_arg_vertexIndex], 0f, 1f));
1506+
return mainVertex_Output(vec4f(positions[vertexIndex], 0f, 1f));
15071507
}
15081508
15091509
@group(0) @binding(0) var<storage, read_write> indexBuffer: atomic<u32>;

apps/typegpu-docs/tests/individual-example-tests/matrix-next.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ describe('matrix(next) example', () => {
4747
4848
@group(0) @binding(2) var<storage, read_write> resultMatrix: array<i32>;
4949
50-
@compute @workgroup_size(16, 16) fn computeSharedMemory(@builtin(local_invocation_id) _arg_lid: vec3u, @builtin(workgroup_id) _arg_wid: vec3u) {
50+
@compute @workgroup_size(16, 16) fn computeSharedMemory(@builtin(local_invocation_id) lid: vec3u, @builtin(workgroup_id) wid: vec3u) {
5151
let dimensions = (&dimensions_1);
5252
let numTiles = u32((f32((((*dimensions).firstColumnCount + 16u) - 1u)) / 16f));
53-
let globalRow = ((_arg_wid.x * 16u) + _arg_lid.x);
54-
let globalCol = ((_arg_wid.y * 16u) + _arg_lid.y);
55-
let localRow = _arg_lid.x;
56-
let localCol = _arg_lid.y;
53+
let globalRow = ((wid.x * 16u) + lid.x);
54+
let globalCol = ((wid.y * 16u) + lid.y);
55+
let localRow = lid.x;
56+
let localCol = lid.y;
5757
let tileIdx = getTileIndex(localRow, localCol);
5858
var accumulatedResult = 0;
5959
for (var tileIndex = 0u; (tileIndex < numTiles); tileIndex++) {

apps/typegpu-docs/tests/individual-example-tests/phong-reflection.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ describe('phong reflection example', () => {
4747
@builtin(position) canvasPosition: vec4f,
4848
}
4949
50-
@vertex fn vertexShader(@location(0) _arg_modelPosition: vec3f, @location(1) _arg_modelNormal: vec3f) -> vertexShader_Output {
51-
let worldPosition = vec4f(_arg_modelPosition, 1f);
50+
@vertex fn vertexShader(@location(0) modelPosition: vec3f, @location(1) modelNormal: vec3f) -> vertexShader_Output {
51+
let worldPosition = vec4f(modelPosition, 1f);
5252
let camera = (&cameraUniform);
5353
let canvasPosition = (((*camera).projection * (*camera).view) * worldPosition);
54-
return vertexShader_Output(_arg_modelPosition, _arg_modelNormal, canvasPosition);
54+
return vertexShader_Output(modelPosition, modelNormal, canvasPosition);
5555
}
5656
5757
struct ExampleControls {

0 commit comments

Comments
 (0)