Skip to content

Commit 783220d

Browse files
committed
add screenshot and performance metrics
1 parent b35b317 commit 783220d

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed
Loading

examples/webgpu_compute_prefix_sum.html

+23-9
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<br /> Prefix sum performance comparisons.
1313
<br /> Each display loops through initialization, sum, and validation steps.
1414
<br/>
15-
<div id="local_swap" style="
15+
<div id="left_side" style="
1616
position: absolute;
1717
top: 150px;
1818
left: 0;
@@ -25,7 +25,7 @@
2525
pointer-events: none;
2626
text-align: left;
2727
"></div>
28-
<div id="global_swap" style="
28+
<div id="right_side" style="
2929
position: absolute;
3030
top: 150px;
3131
right: 0;
@@ -66,23 +66,26 @@
6666
rightGridDim: uniform( Math.sqrt( maxElements ) ),
6767
validate: uniform( 0 ),
6868
// Algorithm being displayed
69-
'Left Method Name': 'Fake Prefix',
69+
'Left Method Name': 'Fake',
7070
'Right Method Name': 'Kogge-Stone',
7171
};
7272

7373
const algorithms = [
7474
'Sklansky',
7575
'Kogge-Stone',
76-
'Fake Prefix',
76+
'Fake',
7777
'Incorrect'
7878
];
7979

8080
const gui = new GUI();
81-
8281
gui.add( effectController, 'Left Method Name', algorithms );
83-
8482
gui.add( effectController, 'Right Method Name', algorithms );
8583

84+
const timestamps = {
85+
left_side: document.getElementById( 'left_side' ),
86+
right_side: document.getElementById( 'right_side' )
87+
};
88+
8689
// Initialize Two Views
8790
init( false );
8891
init( true );
@@ -134,7 +137,7 @@
134137
// Emulates a prefix sum by manually assigning the instanceIndex to the storage buffer.
135138
// This method should only be used to validate the correctness of new algorithms, and not as
136139
// a yardstick for performance.
137-
'Fake Prefix': {
140+
'Fake': {
138141
threads: [ maxElements ],
139142
runMethod: ( currentElements ) => {
140143

@@ -373,9 +376,12 @@
373376
}
374377

375378
let stepType = 'Init';
379+
renderer.info.autoReset = false;
376380

377381
const stepAnimation = async function () {
378382

383+
renderer.info.reset();
384+
379385
const methodName = rightSide ?
380386
effectController[ 'Right Method Name' ] :
381387
effectController[ 'Left Method Name' ];
@@ -404,7 +410,6 @@
404410
case 'Validate': {
405411

406412
const currentElements = new Uint32Array( await renderer.getArrayBufferAsync( currentElementsBuffer ) );
407-
//console.log( currentElements );
408413

409414
effectController.validate.value = 1;
410415
stepType = 'Init';
@@ -415,6 +420,8 @@
415420

416421
case 'Init': {
417422

423+
effectController.validate.value = 0;
424+
418425
renderer.compute( method.initFunction );
419426

420427
stepType = 'Run';
@@ -429,7 +436,14 @@
429436

430437
renderer.render( scene, camera );
431438

432-
effectController.validate.value = 0;
439+
console.log( renderer.info );
440+
441+
timestamps[ rightSide ? 'right_side' : 'left_side' ].innerHTML = `
442+
443+
Compute ${rightSide ? effectController[ 'Right Method Name' ] : effectController[ 'Left Method Name' ]} Prefix Sum: ${renderer.info.compute.frameCalls} pass in ${renderer.info.compute.timestamp.toFixed( 6 )}ms<br>
444+
Draw ${renderer.info.render.drawCalls} pass in ${renderer.info.render.timestamp.toFixed( 6 )}ms
445+
`;
446+
433447

434448
setTimeout( stepAnimation, 1000 );
435449

0 commit comments

Comments
 (0)