@@ -995,11 +995,10 @@ export class Program {
995
995
}
996
996
997
997
/**
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: ...
1003
1002
*
1004
1003
* This is not generated for maximal style cases because it is not clear what
1005
1004
* convergence should be expected. There are multiple valid lowerings of a
@@ -2279,18 +2278,15 @@ ${this.functions[i]}`;
2279
2278
* Equivalent to:
2280
2279
*
2281
2280
* ballot(); // fully uniform
2282
- * if (inputs[1] == 1) {
2281
+ * if (inputs[1] == 1)
2283
2282
* ballot(); // fullly uniform
2284
- * for (var i = 0; i < 3; i++) {
2283
+ * for (var i = 0; i < 3; i++)
2285
2284
* 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))
2287
2286
* ballot(); // non-uniform
2288
2287
* continue;
2289
- * }
2290
2288
* ballot(); // non-uniform
2291
- * }
2292
2289
* ballot(); // fully uniform
2293
- * }
2294
2290
* ballot(); // fully uniform
2295
2291
*
2296
2292
* @param beginLoop The loop type
@@ -2344,18 +2340,16 @@ ${this.functions[i]}`;
2344
2340
* Equivalent to:
2345
2341
*
2346
2342
* ballot(); // uniform
2347
- * if (subgroup_id < 16) {
2343
+ * if (subgroup_id < 16)
2348
2344
* ballot(); // 0xffff
2349
- * if (testbit(vec4u(0x00ff00ff,00ff00ff,00ff00ff,00ff00ff), subgroup_id)) {
2345
+ * if (testbit(vec4u(0x00ff00ff,00ff00ff,00ff00ff,00ff00ff), subgroup_id))
2350
2346
* ballot(); // 0xff
2351
- * if (inputs[1] == 1) {
2347
+ * if (inputs[1] == 1)
2352
2348
* ballot(); // 0xff
2353
- * }
2354
2349
* ballot(); // 0xff
2355
- * } else {
2350
+ * else
2356
2351
* ballot(); // 0xF..0000
2357
2352
* return;
2358
- * }
2359
2353
* ballot; // 0xffff
2360
2354
*
2361
2355
* In this program, subgroups larger than 16 invocations diverge at the first if.
@@ -2407,19 +2401,16 @@ ${this.functions[i]}`;
2407
2401
/**
2408
2402
* Equivalent to:
2409
2403
*
2410
- * if subgroup_id < inputs[107] {
2411
- * if subgroup_id < inputs[112] {
2404
+ * if subgroup_id < inputs[107]
2405
+ * if subgroup_id < inputs[112]
2412
2406
* ballot();
2413
- * if testBit(vec4u(0xd2f269c6,0xffe83b3f,0xa279f695,0x58899224), subgroup_id) {
2407
+ * if testBit(vec4u(0xd2f269c6,0xffe83b3f,0xa279f695,0x58899224), subgroup_id)
2414
2408
* ballot();
2415
- * } else {
2409
+ * else
2416
2410
* ballot()
2417
- * }
2418
2411
* ballot();
2419
- * } else {
2412
+ * else
2420
2413
* ballot();
2421
- * }
2422
- * }
2423
2414
*
2424
2415
* The first two if statements are uniform for subgroup sizes 64 or less.
2425
2416
* The third if statement is non-uniform for all subgroup sizes.
@@ -2463,13 +2454,11 @@ ${this.functions[i]}`;
2463
2454
/**
2464
2455
* Equivalent to:
2465
2456
*
2466
- * for (var i = 0; ; i++, ballot()) {
2457
+ * for (var i = 0; ; i++, ballot())
2467
2458
* ballot();
2468
- * if (subgroupElect()) {
2459
+ * if (subgroupElect())
2469
2460
* ballot();
2470
2461
* break;
2471
- * }
2472
- * }
2473
2462
* ballot();
2474
2463
*
2475
2464
* @param beginType The loop type
@@ -2501,13 +2490,11 @@ ${this.functions[i]}`;
2501
2490
/**
2502
2491
* Equivalent to:
2503
2492
*
2504
- * for (var i = 0; i < subgroup_invocation_id + 1; i++) {
2493
+ * for (var i = 0; i < subgroup_invocation_id + 1; i++)
2505
2494
* ballot();
2506
- * }
2507
2495
* ballot();
2508
- * for (var i = 0; i < subgroup_invocation_id + 1; i++) {
2496
+ * for (var i = 0; i < subgroup_invocation_id + 1; i++)
2509
2497
* ballot();
2510
- * }
2511
2498
* ballot();
2512
2499
*/
2513
2500
public predefinedProgramForVar ( ) {
@@ -2534,31 +2521,24 @@ ${this.functions[i]}`;
2534
2521
* Equivalent to:
2535
2522
*
2536
2523
* fn f0() {
2537
- * for (var i = 0; i < inputs[3]; i++) {
2524
+ * for (var i = 0; i < inputs[3]; i++)
2538
2525
* f1(i);
2539
2526
* ballot();
2540
- * }
2541
2527
* ballot();
2542
- * if (inputs[3] == 3) {
2528
+ * if (inputs[3] == 3)
2543
2529
* f2();
2544
2530
* ballot();
2545
- * }
2546
2531
* ballot()
2547
- * }
2548
- * fn f1(i : u32) {
2532
+ * fn f1(i : u32)
2549
2533
* ballot();
2550
- * if (subgroup_invocation_id == i) {
2534
+ * if (subgroup_invocation_id == i)
2551
2535
* ballot();
2552
2536
* return;
2553
- * }
2554
- * }
2555
- * fn f2() {
2537
+ * fn f2()
2556
2538
* ballot();
2557
- * if (testBit(vec4u(0xaaaaaaaa,0xaaaaaaaa,0xaaaaaaaa,0xaaaaaaaa), local_invocation_index)) {
2539
+ * if (testBit(vec4u(0xaaaaaaaa,0xaaaaaaaa,0xaaaaaaaa,0xaaaaaaaa), local_invocation_index))
2558
2540
* ballot();
2559
2541
* return;
2560
- * }
2561
- * }
2562
2542
*/
2563
2543
public predefinedProgramCall ( ) {
2564
2544
this . masks [ 4 + 0 ] = 0xaaaaaaaa ;
@@ -2609,12 +2589,11 @@ ${this.functions[i]}`;
2609
2589
* Equivalent to:
2610
2590
*
2611
2591
* 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();
2618
2597
* ballot();
2619
2598
*
2620
2599
*/
@@ -2644,13 +2623,12 @@ ${this.functions[i]}`;
2644
2623
* Equivalent to:
2645
2624
*
2646
2625
* 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();
2654
2632
* ballot();
2655
2633
*/
2656
2634
public predefinedProgramSwitchVar ( ) {
@@ -2681,19 +2659,15 @@ ${this.functions[i]}`;
2681
2659
/**
2682
2660
* Equivalent to:
2683
2661
*
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++)
2687
2665
* 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();
2693
2670
* ballot();
2694
- * }
2695
- * }
2696
- * }
2697
2671
*/
2698
2672
public predefinedProgramSwitchLoopCount ( loop : number ) {
2699
2673
this . ops . push ( new Op ( OpType . ForUniform , 1 ) ) ;
@@ -2731,11 +2705,10 @@ ${this.functions[i]}`;
2731
2705
/**
2732
2706
* Equivalent to:
2733
2707
*
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();
2739
2712
*/
2740
2713
public predefinedProgramSwitchMulticase ( ) {
2741
2714
this . ops . push ( new Op ( OpType . Store , this . storeBase + this . ops . length ) ) ;
@@ -2761,12 +2734,10 @@ ${this.functions[i]}`;
2761
2734
* Equivalent to:
2762
2735
*
2763
2736
* ballot();
2764
- * for (var i = 0; i < inputs[3]; i++) {
2737
+ * for (var i = 0; i < inputs[3]; i++)
2765
2738
* ballot();
2766
- * if (subgroupElect()) {
2739
+ * if (subgroupElect())
2767
2740
* continue;
2768
- * }
2769
- * }
2770
2741
* ballot();
2771
2742
*
2772
2743
* This case can distinguish between Workgroup and WGSLv1 reconvergence.
0 commit comments