Enabling timestamp queries

80 views
Skip to first unread message

Mark Sibly

unread,
Jan 31, 2023, 1:16:26 PM1/31/23
to Dawn Graphics
Hi,

I've been enabling timestamp queries by passing this descriptor to CreateDevice.

dawn::native::DawnDeviceDescriptor ddDesc;
ddDesc.requiredFeatures = {"timestamp-query", "timestamp-query-inside-passes"};
ddDesc.forceDisabledToggles = {"disallow_unsafe_apis"};

But DawnDeviceDescriptor is apparently deprecated - I just noticed dawn complaining about it and telling me I should use WGPUDeviceDescriptor instead.

However, this is missing the forceDisabledToggles bit so I wont be able to use it to 'allow' the unsafe timestamp API can I?

What's the correct way to 'enable' timestamp queries?

Bye!
Mark

Hao Li

unread,
Feb 1, 2023, 2:02:14 AM2/1/23
to Dawn Graphics
@Mark, there is a 'nextInChain' in wgpu::DeviceDescriptor, which can be used to pass wgpu::DawnTogglesDescriptor for enabling/disabling toggles.

For example, enable timestamp queries:
wgpu::DeviceDescriptor deviceDescriptor;
std::vector<wgpu::FeatureName> requiredFeatures = { wgpu::FeatureName::TimestampQuery };
deviceDescriptor.requiredFeatures = requiredFeatures.data();
deviceDescriptor.requiredFeaturesCount = requiredFeatures.size();

wgpu::DawnTogglesDescriptor deviceTogglesDesc;
deviceDescriptor.nextInChain = &deviceTogglesDesc;
const char* const disabledToggles[] = {"disallow_unsafe_apis"};
deviceTogglesDesc.disabledToggles = disabledToggles;
deviceTogglesDesc.disabledTogglesCount = 1;

wgpu::Device device = adapter.CreateDevice(&deviceDescriptor);

The wgpu::FeatureName::TimestampQuery is enough if you just want to sample timestamps in passes level.
And the wgpu::FeatureName::TimestampQueryInsidePasses can used alone for sampling timestamps between render/compute commands inside passes.

Mark Sibly

unread,
Feb 1, 2023, 2:53:27 AM2/1/23
to Dawn Graphics
Thanks very much for this, I am finding the timestamp queries to be very useful, if a little awkward to use at first!

Mark Sibly

unread,
Feb 1, 2023, 2:39:22 PM2/1/23
to Dawn Graphics
OK, got it working, just a quick note though: if you want timestamp queries within renderpasses, you need to enable both a feature and a toggle, eg:

wgpu::FeatureName requiredFeatures[]{wgpu::FeatureName::TimestampQuery,  wgpu::FeatureName::TimestampQueryInsidePasses};

const char* disabledToggles[]{"disallow_unsafe_apis", "timestamp-query-inside-passes"};

Just enabling the feature or the toggle alone doesn't work, you need to enable both. Not sure if this is intended behaviour so thought I'd mention it, seems a bit odd to me.


--
You received this message because you are subscribed to the Google Groups "Dawn Graphics" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dawn-graphic...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dawn-graphics/f1075247-7176-4936-bedc-513d86076576n%40googlegroups.com.

Hao Li

unread,
Feb 2, 2023, 10:03:27 PM2/2/23
to Dawn Graphics
The reason we need to enable both feature and toggle is that current the timestamp query is an experimental feature which is implemented behind unsafe api flag, the disable toggle won't be needed when the feature comes to stable. 

> const char* disabledToggles[]{"disallow_unsafe_apis", "timestamp-query-inside-passes"};
And there is no toggle named "timestamp-query-inside-passes", "disallow_unsafe_apis" is enough.

Message has been deleted

Austin Eng

unread,
May 15, 2023, 11:30:24 AM5/15/23
to Jean-Colas Prunier, Dawn Graphics
heads up: forceDisabledToggles "disallow_unsafe_apis" has been renamed to forceEnabledToggles "allow_unsafe_apis". You should be getting a warning in the latest version of Dawn if you use the old toggle name.

On Sat, May 13, 2023 at 11:25 AM Jean-Colas Prunier <j...@jean-colas.com> wrote:
Updating Hao example code:

wgpu::DeviceDescriptor deviceDescriptor;
std::vector<wgpu::FeatureName> requiredFeatures = { wgpu::FeatureName::TimestampQuery };
deviceDescriptor.requiredFeatures = requiredFeatures.data();
deviceDescriptor.requiredFeaturesCount = requiredFeatures.size();

wgpu::DawnTogglesDeviceDescriptor deviceTogglesDesc;

deviceDescriptor.nextInChain = &deviceTogglesDesc;
const char* const disabledToggles[] = {"disallow_unsafe_apis"};
deviceTogglesDesc.forceDisabledToggles = disabledToggles;
deviceTogglesDesc.forceDisabledTogglesCount = 1;

        device = wgpu::Device::Acquire(chosenAdapter.CreateDevice(&deviceDescriptor));

--
You received this message because you are subscribed to the Google Groups "Dawn Graphics" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dawn-graphic...@googlegroups.com.

j...@jean-colas.com

unread,
May 15, 2023, 5:21:26 PM5/15/23
to Austin Eng, Dawn Graphics
Yes thanks Austin

I deleted the post I believe. I realized I had not pulled the code from the repo for a while to look for some stability while testing the API and that I should have pulled it before making the assumption that the example provided needed to be updated. I eventually pulled the last version and of course, the example worked.

Apologize for the nuisance.Sometimes all goes wrong.

I had no problem with the latest of everything but noticed the error reporting mechanism wasn’t printing in the console anymore. Only when the window was eventually killed would the errors flushed. I need to look into that but beside that it all worked fine.

Mark Sibly

unread,
May 15, 2023, 5:57:15 PM5/15/23
to j...@jean-colas.com, Austin Eng, Dawn Graphics
> heads up: forceDisabledToggles "disallow_unsafe_apis" has been renamed to forceEnabledToggles "allow_unsafe_apis".

Yay, death to double negatives in APIs!

> the error reporting mechanism wasn’t printing in the console anymore

You may be missing  wgpuInstanceProcessEvents() - this is now needed to cause errors/logging to happen.

I think I preferred it the old way, I'm pretty sure you used to be able to place a breakpoint on the error callback, and be able to tell exactly where an error occurred via callstack. It's a bit harder now, although errors are so much better than GL days I won't be complaining too loudly.

Bye,
Mark


You received this message because you are subscribed to a topic in the Google Groups "Dawn Graphics" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dawn-graphics/Y7Xu6a4n_T0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dawn-graphic...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dawn-graphics/53C3CF8D-EA45-452B-BE3C-50A48E4D73D9%40jean-colas.com.

j...@jean-colas.com

unread,
May 15, 2023, 6:01:13 PM5/15/23
to Mark Sibly, Austin Eng, Dawn Graphics
Thanks Mark

Yes I remember a post in which you mentioned this issue and was provided with an answer. You made my life easier ). I will test this soon. Thanks again.

Reply all
Reply to author
Forward
0 new messages