Skip to content

Commit e0caebb

Browse files
committed
change native select approach
1 parent fec32c7 commit e0caebb

File tree

2 files changed

+93
-78
lines changed

2 files changed

+93
-78
lines changed

examples/webgpu_compute_reduce.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@
519519
workgroupBarrier();
520520

521521
// Thread 0 - subgroupsInWorkgroup will assign a value to total
522-
total.assign( nativeSelect( 0, subgroupSums.element( invocationLocalIndex ), invocationLocalIndex.lessThan( delta ) ) );
522+
total.assign( nativeSelect( invocationLocalIndex.lessThan( delta ), subgroupSums.element( invocationLocalIndex ), 0 ) );
523523
// # of subgroups in workgroup is invariably less than # of threads in subgroup, so subgroupAdd will still sync here
524524
total.assign( subgroupAdd( total ) );
525525

@@ -544,9 +544,9 @@
544544
// Select either 0 or number of elements left,
545545
// otherwise, select existing ROW_SIZE
546546
const currentRowSize = nativeSelect(
547+
( rowOffset.add( ROW_SIZE ) ).greaterThan( inputSize ),
548+
nativeSelect( inputSize.greaterThan( rowOffset ), inputSize.sub( rowOffset ), 0 ),
547549
ROW_SIZE,
548-
nativeSelect( 0, inputSize.sub( rowOffset ), inputSize.greaterThan( rowOffset ) ),
549-
( rowOffset.add( ROW_SIZE ) ).greaterThan( inputSize )
550550
);
551551

552552
const total = uint( 0 ).toVar( 'total' );

0 commit comments

Comments
 (0)