2
$\begingroup$

I'm using queries to profile my Direct3D renderer.

What precision and consistency should I expect from them?

Those are some values for a full-screen draw I do each frame as an example:

|Full-Screen shader: 714.16 us
|Full-Screen shader: 709.72 us
|Full-Screen shader: 706.44 us
|Full-Screen shader: 707.44 us
|Full-Screen shader: 710.76 us
|Full-Screen shader: 707.76 us
|Full-Screen shader: 706.48 us
|Full-Screen shader: 712.88 us
|Full-Screen shader: 715.36 us
|Full-Screen shader: 704.72 us
|Full-Screen shader: 708.32 us
|Full-Screen shader: 702.32 us
|Full-Screen shader: 707.8 us
|Full-Screen shader: 720.6 us
|Full-Screen shader: 711.12 us
|Full-Screen shader: 715.36 us
|Full-Screen shader: 713.84 us
|Full-Screen shader: 716.52 us
|Full-Screen shader: 711.52 us
|Full-Screen shader: 1228.57 us
|Full-Screen shader: 1202.5 us
|Full-Screen shader: 706.44 us
|Full-Screen shader: 712.68 us
|Full-Screen shader: 715.32 us

The shader used while profiling has nothing parametrized with time and while it contains branching to early-exit when certain conditions are met, the scene was "static" while profiling.

Is it the expected behavior to have so much variance?

Or is it an indicator that something is wrong with my code?

$\endgroup$

1 Answer 1

3
$\begingroup$

It looks like a normal amount of variance to me. Profiling results naturally fluctuate because there can be nondeterministic cache effects, changes in how the work is scheduled, there can be other applications and the OS submitting work at the same time as yours, etc. This applies to both CPU and GPU.

There can also be changes in clock rate that can screw up profiling data, though that causes larger and longer-lasting changes, not this kind of micro-variance. (The two samples where it jumped up to over 1200 us could be due to a clock speed change, for instance; or they could be due to some other work being on the GPU at the same time.)

It's common to average the measurements over some number of frames, or even do more complicated statistics on them, to account for this.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.