@@ -598,7 +598,7 @@ <h2><center>Web graphics workload simulator</center></h2>
598
598
} , 0 , 2 ) ;
599
599
const useTimestampQueries = adapter . features . has ( 'timestamp-query' ) ;
600
600
device = await adapter . requestDevice ( {
601
- nonGuaranteedFeatures : useTimestampQueries ? [ 'timestamp-query' ] : [ ] ,
601
+ requiredFeatures : useTimestampQueries ? [ 'timestamp-query' ] : [ ] ,
602
602
} ) ;
603
603
device . addEventListener ( 'uncapturederror' , ( e ) => {
604
604
if ( ! errorMessage . textContent ) errorMessage . textContent = 'Uncaptured error: ' + e . error . message ;
@@ -731,14 +731,16 @@ <h2><center>Web graphics workload simulator</center></h2>
731
731
}
732
732
try {
733
733
const canvasView = canvasContext . getCurrentTexture ( ) . createView ( ) ;
734
- const commandBuffers = [ ] ;
735
- device . queue . writeBuffer ( uniformBuffer , 0 , new Float32Array ( [ position [ 0 ] / size * 2 - 1 , 1 - position [ 1 ] * 2 / size ] ) ) ;
736
- let buffer = null ;
737
734
738
735
// Start off by writing a timestamp for the beginning of the frame.
739
- const timestampEncoder = device . createCommandEncoder ( ) ;
740
- if ( querySet ) timestampEncoder . writeTimestamp ( querySet , 0 ) ;
741
- device . queue . submit ( [ timestampEncoder . finish ( ) ] ) ;
736
+ if ( querySet ) {
737
+ const timestampEncoder = device . createCommandEncoder ( ) ;
738
+ timestampEncoder . beginComputePass ( { timestampWrites : { querySet, beginningOfPassWriteIndex : 0 , } } ) . end ( ) ;
739
+ device . queue . submit ( [ timestampEncoder . finish ( ) ] ) ;
740
+ }
741
+
742
+ device . queue . writeBuffer ( uniformBuffer , 0 , new Float32Array ( [ position [ 0 ] / size * 2 - 1 , 1 - position [ 1 ] * 2 / size ] ) ) ;
743
+ let buffer = null ;
742
744
743
745
// Upload data using createBuffer with mappedAtCreation.
744
746
if ( bufferData . value > 0 ) {
@@ -815,6 +817,7 @@ <h2><center>Web graphics workload simulator</center></h2>
815
817
clearValue : [ 1 , 1 , 1 , 1 ] ,
816
818
storeOp : multisampling . checked ? 'discard' : 'store' ,
817
819
} , ] ,
820
+ timestampWrites : querySet ? { querySet, endOfPassWriteIndex : 1 } : undefined ,
818
821
} ) ;
819
822
if ( useRenderBundles . checked && renderBundle && instances == renderBundleInstances && renderBundleNumDrawCalls == numDrawCalls ) {
820
823
// If we have valid RenderBundles to use, execute them and we're done.
@@ -892,8 +895,6 @@ <h2><center>Web graphics workload simulator</center></h2>
892
895
if ( buffer ) buffer . destroy ( ) ;
893
896
let queryBuffer ;
894
897
if ( querySet ) {
895
- // Timestamp for the end of the frame.
896
- commandEncoder . writeTimestamp ( querySet , 1 ) ;
897
898
// We create a queue of staging buffers to hold the timestamps while we
898
899
// map them into CPU memory. If the queue is empty, create a new buffer.
899
900
if ( queryBuffers . length == 0 ) {
@@ -908,8 +909,7 @@ <h2><center>Web graphics workload simulator</center></h2>
908
909
commandEncoder . resolveQuerySet ( querySet , 0 , 2 , queryResolveBuffer , 0 ) ;
909
910
commandEncoder . copyBufferToBuffer ( queryResolveBuffer , 0 , queryBuffer , 0 , 16 ) ;
910
911
}
911
- commandBuffers . push ( commandEncoder . finish ( ) ) ;
912
- device . queue . submit ( commandBuffers ) ;
912
+ device . queue . submit ( [ commandEncoder . finish ( ) ] ) ;
913
913
if ( querySet ) {
914
914
// Once the staging buffer is mapped we can finally calculate the frame duration
915
915
// and put the staging buffer back into the queue.
0 commit comments