Description
I've been experimenting with wgpu's write_timestamp functionality to measure the execution time of compute shaders. Unfortunately, the lack of control of when they happen in relation to pipeline barriers seems to be preventing them from being of much use.
Repro steps
Execute two compute dispatches, and measure how long the second one takes:
cpass.dispatch(...);
cpass.write_timestamp(...);
cpass.dispatch(...);
cpass.write_timestamp(...);
Expected vs observed behavior
I would expect that the difference between the timestamps would reflect the execution time of the second dispatch. Instead, I observed that the measurement would sometimes be an order of magnitude larger, presumably including much of the time executing the first dispatch.
I assume this is related to vkCmdWriteTimestamp happening too early. Partial trace:
47 vkCmdBindPipeline(pipeline.generate.displacements)
48 vkCmdBindDescriptorSets(0, { bindgroup.generate.displacements })
49 vkCmdResetQueryPool(Query Pool 250)
50 vkCmdWriteTimestamp(Query Pool 250, 6)
51 vkCmdPipelineBarrier({ buffer.nodes })
52 vkCmdPipelineBarrier({ texture.tiles.displacements })
53 vkCmdDispatch(9, 9, 1)
54 vkCmdResetQueryPool(Query Pool 250)
55 vkCmdWriteTimestamp(Query Pool 250, 7)
Platform
I'm using Linux with an AMD GPU + mesa drivers, though I imagine this applies more broadly.
Description
I've been experimenting with wgpu's
write_timestampfunctionality to measure the execution time of compute shaders. Unfortunately, the lack of control of when they happen in relation to pipeline barriers seems to be preventing them from being of much use.Repro steps
Execute two compute dispatches, and measure how long the second one takes:
Expected vs observed behavior
I would expect that the difference between the timestamps would reflect the execution time of the second dispatch. Instead, I observed that the measurement would sometimes be an order of magnitude larger, presumably including much of the time executing the first dispatch.
I assume this is related to vkCmdWriteTimestamp happening too early. Partial trace:
Platform
I'm using Linux with an AMD GPU + mesa drivers, though I imagine this applies more broadly.