这是indexloc提供的服务,不要输入任何密码
Skip to content

Only 32 timestamp queries allowed on Metal MacOS? #5261

@greggman

Description

@greggman

I recently started running into timestamp-query limits on my M1 Mac. In particular, it appears Metal only allows 32 query objects.

https://jsgist.org/?src=89c0411946f59b8ccdfafc89b295b049

Tested on Safari TP, Chrome, and Firefox Nightly.

This is problematic because the limit, at least in all of those browsers, is shared across tabs. If one tab uses 32 or 2 tabs use 16, another tab gets 0 (and so will get an unexpected error).

Imagine a maps or video conferencing site was to use a timestamp-query to choose between technique A and B and then the user finds that they randomly can't use either site depending on what other sites are open.

Even in one tab this limits its usefulness. I was timing mipmap generation using render passes. a 4k texture needs 12 render passes and timing has to be done per-pass so I used 12 query objects to do the timing. A larger app trying time a much larger set of render passes would likely run into this limit.

I don't have solutions but a few thoughts

  • Suggest implementation don't advertise timestamp-query on Mac browsers (except via dev flags)

    This would at least mean sites don't run into this issue where their app crashes when some other site is using the queries. Though devs might run into these issues where sites suddenly start failing when they enable the flag.

    For consistency maybe no platforms should advertise this feature except via dev flags?

  • Browsers that want to support queries should virtualize them.

    This is difficult because it would mean breaking up command buffers
    and/or render bundles anytime one of them uses more than the max supported
    timer queries.

    or, alternatively, you could virtualize them for the tab issue but add a limit
    per command buffer limit that when you use the max queries in a single command
    buffer you get an error.

  • Document that you must check for errors when using timestamp-query

    In all current browsers the error happens on usage, not creation.
    That implies you probably don't want to use timestamp queries in
    a render loop as checking for errors is async, and your rendering
    will fail. It might be okay to use them to select between techniques
    at startup provided you handle the unexpected error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiWebGPU APIneeds investigationRequires an investigation into implementation constraints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions