Skip to content

Commit af52f07

Browse files
committed
Comments
* switch code fragments in comments to drop { } because the linter is over aggressive
1 parent 6a80aaa commit af52f07

File tree

1 file changed

+50
-79
lines changed
  • src/webgpu/shader/execution/reconvergence

1 file changed

+50
-79
lines changed

src/webgpu/shader/execution/reconvergence/util.ts

Lines changed: 50 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -995,11 +995,10 @@ export class Program {
995995
}
996996

997997
/**
998-
* switch (subgroup_invocation_id & 3) {
999-
* default { }
1000-
* case 0x3: { ... }
1001-
* case 0xc: { ... }
1002-
* }
998+
* switch (subgroup_invocation_id & 3)
999+
* default
1000+
* case 0x3: ...
1001+
* case 0xc: ...
10031002
*
10041003
* This is not generated for maximal style cases because it is not clear what
10051004
* convergence should be expected. There are multiple valid lowerings of a
@@ -2279,18 +2278,15 @@ ${this.functions[i]}`;
22792278
* Equivalent to:
22802279
*
22812280
* ballot(); // fully uniform
2282-
* if (inputs[1] == 1) {
2281+
* if (inputs[1] == 1)
22832282
* ballot(); // fullly uniform
2284-
* for (var i = 0; i < 3; i++) {
2283+
* for (var i = 0; i < 3; i++)
22852284
* ballot(); // Simulation expects fully uniform, WGSL does not.
2286-
* if (testBit(vec4u(0xaaaaaaaa,0xaaaaaaa,0xaaaaaaaa,0xaaaaaaaa), subgroup_id)) {
2285+
* if (testBit(vec4u(0xaaaaaaaa,0xaaaaaaa,0xaaaaaaaa,0xaaaaaaaa), subgroup_id))
22872286
* ballot(); // non-uniform
22882287
* continue;
2289-
* }
22902288
* ballot(); // non-uniform
2291-
* }
22922289
* ballot(); // fully uniform
2293-
* }
22942290
* ballot(); // fully uniform
22952291
*
22962292
* @param beginLoop The loop type
@@ -2344,18 +2340,16 @@ ${this.functions[i]}`;
23442340
* Equivalent to:
23452341
*
23462342
* ballot(); // uniform
2347-
* if (subgroup_id < 16) {
2343+
* if (subgroup_id < 16)
23482344
* ballot(); // 0xffff
2349-
* if (testbit(vec4u(0x00ff00ff,00ff00ff,00ff00ff,00ff00ff), subgroup_id)) {
2345+
* if (testbit(vec4u(0x00ff00ff,00ff00ff,00ff00ff,00ff00ff), subgroup_id))
23502346
* ballot(); // 0xff
2351-
* if (inputs[1] == 1) {
2347+
* if (inputs[1] == 1)
23522348
* ballot(); // 0xff
2353-
* }
23542349
* ballot(); // 0xff
2355-
* } else {
2350+
* else
23562351
* ballot(); // 0xF..0000
23572352
* return;
2358-
* }
23592353
* ballot; // 0xffff
23602354
*
23612355
* In this program, subgroups larger than 16 invocations diverge at the first if.
@@ -2407,19 +2401,16 @@ ${this.functions[i]}`;
24072401
/**
24082402
* Equivalent to:
24092403
*
2410-
* if subgroup_id < inputs[107] {
2411-
* if subgroup_id < inputs[112] {
2404+
* if subgroup_id < inputs[107]
2405+
* if subgroup_id < inputs[112]
24122406
* ballot();
2413-
* if testBit(vec4u(0xd2f269c6,0xffe83b3f,0xa279f695,0x58899224), subgroup_id) {
2407+
* if testBit(vec4u(0xd2f269c6,0xffe83b3f,0xa279f695,0x58899224), subgroup_id)
24142408
* ballot();
2415-
* } else {
2409+
* else
24162410
* ballot()
2417-
* }
24182411
* ballot();
2419-
* } else {
2412+
* else
24202413
* ballot();
2421-
* }
2422-
* }
24232414
*
24242415
* The first two if statements are uniform for subgroup sizes 64 or less.
24252416
* The third if statement is non-uniform for all subgroup sizes.
@@ -2463,13 +2454,11 @@ ${this.functions[i]}`;
24632454
/**
24642455
* Equivalent to:
24652456
*
2466-
* for (var i = 0; ; i++, ballot()) {
2457+
* for (var i = 0; ; i++, ballot())
24672458
* ballot();
2468-
* if (subgroupElect()) {
2459+
* if (subgroupElect())
24692460
* ballot();
24702461
* break;
2471-
* }
2472-
* }
24732462
* ballot();
24742463
*
24752464
* @param beginType The loop type
@@ -2501,13 +2490,11 @@ ${this.functions[i]}`;
25012490
/**
25022491
* Equivalent to:
25032492
*
2504-
* for (var i = 0; i < subgroup_invocation_id + 1; i++) {
2493+
* for (var i = 0; i < subgroup_invocation_id + 1; i++)
25052494
* ballot();
2506-
* }
25072495
* ballot();
2508-
* for (var i = 0; i < subgroup_invocation_id + 1; i++) {
2496+
* for (var i = 0; i < subgroup_invocation_id + 1; i++)
25092497
* ballot();
2510-
* }
25112498
* ballot();
25122499
*/
25132500
public predefinedProgramForVar() {
@@ -2534,31 +2521,24 @@ ${this.functions[i]}`;
25342521
* Equivalent to:
25352522
*
25362523
* fn f0() {
2537-
* for (var i = 0; i < inputs[3]; i++) {
2524+
* for (var i = 0; i < inputs[3]; i++)
25382525
* f1(i);
25392526
* ballot();
2540-
* }
25412527
* ballot();
2542-
* if (inputs[3] == 3) {
2528+
* if (inputs[3] == 3)
25432529
* f2();
25442530
* ballot();
2545-
* }
25462531
* ballot()
2547-
* }
2548-
* fn f1(i : u32) {
2532+
* fn f1(i : u32)
25492533
* ballot();
2550-
* if (subgroup_invocation_id == i) {
2534+
* if (subgroup_invocation_id == i)
25512535
* ballot();
25522536
* return;
2553-
* }
2554-
* }
2555-
* fn f2() {
2537+
* fn f2()
25562538
* ballot();
2557-
* if (testBit(vec4u(0xaaaaaaaa,0xaaaaaaaa,0xaaaaaaaa,0xaaaaaaaa), local_invocation_index)) {
2539+
* if (testBit(vec4u(0xaaaaaaaa,0xaaaaaaaa,0xaaaaaaaa,0xaaaaaaaa), local_invocation_index))
25582540
* ballot();
25592541
* return;
2560-
* }
2561-
* }
25622542
*/
25632543
public predefinedProgramCall() {
25642544
this.masks[4 + 0] = 0xaaaaaaaa;
@@ -2609,12 +2589,11 @@ ${this.functions[i]}`;
26092589
* Equivalent to:
26102590
*
26112591
* ballot()
2612-
* switch (inputs[5]) {
2613-
* default { }
2614-
* case 6 { ballot(); }
2615-
* case 5 { ballot(); }
2616-
* case 7 { ballot(); }
2617-
* }
2592+
* switch (inputs[5])
2593+
* default
2594+
* case 6 ballot();
2595+
* case 5 ballot();
2596+
* case 7 ballot();
26182597
* ballot();
26192598
*
26202599
*/
@@ -2644,13 +2623,12 @@ ${this.functions[i]}`;
26442623
* Equivalent to:
26452624
*
26462625
* ballot();
2647-
* switch subgroup_invocation_id & 3 {
2648-
* default { }
2649-
* case 0: { ballot(); }
2650-
* case 1: { ballot(); }
2651-
* case 2: { ballot(); }
2652-
* case 3: { ballot(); }
2653-
* }
2626+
* switch subgroup_invocation_id & 3
2627+
* default
2628+
* case 0: ballot();
2629+
* case 1: ballot();
2630+
* case 2: ballot();
2631+
* case 3: ballot();
26542632
* ballot();
26552633
*/
26562634
public predefinedProgramSwitchVar() {
@@ -2681,19 +2659,15 @@ ${this.functions[i]}`;
26812659
/**
26822660
* Equivalent to:
26832661
*
2684-
* for (var i0 = 0u; i0 < inputs[3]; i0++) {
2685-
* for (var i1 = 0u; i1 < inputs[3]; i1++) {
2686-
* for (var i2 = 0u; i2 < subgroup_invocation_id + 1; i2++) {
2662+
* for (var i0 = 0u; i0 < inputs[3]; i0++)
2663+
* for (var i1 = 0u; i1 < inputs[3]; i1++)
2664+
* for (var i2 = 0u; i2 < subgroup_invocation_id + 1; i2++)
26872665
* ballot();
2688-
* switch i_loop {
2689-
* case 1 { ballot(); }
2690-
* case 2 { ballot(); }
2691-
* default { ballot(); }
2692-
* }
2666+
* switch i_loop
2667+
* case 1 ballot();
2668+
* case 2 ballot();
2669+
* default ballot();
26932670
* ballot();
2694-
* }
2695-
* }
2696-
* }
26972671
*/
26982672
public predefinedProgramSwitchLoopCount(loop: number) {
26992673
this.ops.push(new Op(OpType.ForUniform, 1));
@@ -2731,11 +2705,10 @@ ${this.functions[i]}`;
27312705
/**
27322706
* Equivalent to:
27332707
*
2734-
* switch subgroup_invocation_id & 0x3 {
2735-
* default { }
2736-
* case 0,1 { ballot(); }
2737-
* case 2,3 { ballot(); }
2738-
* }
2708+
* switch subgroup_invocation_id & 0x3
2709+
* default
2710+
* case 0,1 ballot();
2711+
* case 2,3 ballot();
27392712
*/
27402713
public predefinedProgramSwitchMulticase() {
27412714
this.ops.push(new Op(OpType.Store, this.storeBase + this.ops.length));
@@ -2761,12 +2734,10 @@ ${this.functions[i]}`;
27612734
* Equivalent to:
27622735
*
27632736
* ballot();
2764-
* for (var i = 0; i < inputs[3]; i++) {
2737+
* for (var i = 0; i < inputs[3]; i++)
27652738
* ballot();
2766-
* if (subgroupElect()) {
2739+
* if (subgroupElect())
27672740
* continue;
2768-
* }
2769-
* }
27702741
* ballot();
27712742
*
27722743
* This case can distinguish between Workgroup and WGSLv1 reconvergence.

0 commit comments

Comments
 (0)