You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While looking at the pipeline statistics queries and how it would change webgpu.h, I had the following two questions:
Should they be allowed in GPURenderBundle? They currently are, but it seems to conflict with our earlier decision to disallow occlusion queries on render bundles.
Are pipeline statistics queries allowed to be nested, or even interleaved? If not, then endPipelineStatisticsQuery should not take any argument.
Should they be allowed in GPURenderBundle? They currently are, but it seems to conflict with our earlier decision to disallow occlusion queries on render bundles.
Yes, you're right, D3D12 and Metal don't support Query API on render bundles. I will move the Pipeline Statistcs APIs to GPURenderPassEncoder and GPUComputePassEncoder.
queryPool must have been created with a queryType that differs from that of any queries that are active within commandBuffer.
It only does not allow to create queryPool with same query type, but we can nest the query operation for a same query type, even for different query types, such as:
Maybe we can remove the args of queryset becase we have seprate api for different queries, but if removed, we need told users which the queryset the results are stored in, and the created queryset is only used when resolving, maybe also considerring not expose queryset, and resolving the data with query type instead, becasue there is only one queryset for each type, we can handle them in native. I think it will increase the complexity of the implementation, so currently I prefer to keep these arguments.
It only does not allow to create queryPool with same query type, but we can nest the query operation for a same query type, even for different query types, such as:
I'm pretty sure that's not allowed, because when there is the first beginPipelineStatisticsQuery call, that query becomes active, and the validation text I quoted above will be triggered in the second call to beginPipelineStatisticsQuery. The Vulkan spec doesn't have any special text to allow additional queries if the query pool is already "active", it only cares whether any query is active for that type.
Oh, understand what you mean, but strangely, I can test this case pass with Vulkan validation layers, I will file the issue for the validation and add description on spec to disallow the nesting.
I'm a tiny bit concerned about how the pipeline statistics are going to be specified. In Vulkan the spec allows a lot of freedom to implementors, e.g.:
VK_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT specifies that queries managed by the pool will count the number of compute shader invocations. The counter’s value is incremented every time the compute shader is invoked. Implementations may skip the execution of certain compute shader invocations or execute additional compute shader invocations for implementation-dependent reasons as long as the results of rendering otherwise remain unchanged.
We can't put more strict wording, as we are constrained by the backend APIs. At the same time, if we have loose requirements like in Vulkan, we might as well just make it a part of WebGPU core and return zeroes where it's not supported :/
@kvark Now we use an array of enum in GPUPipelineStatisticName to specified pipeline statistics, and also return 0 if the specified pipeline statistics is not supported. Difference is the number and order of the results written to buffer match the number and order of the specified pipeline statistics, in Vulkan, they are fixed.
I don't think my concern is understood. What I'm saying is that it seems perfectly valid for a Vulkan implementation to return 0 for the number of compute shader invocation. We have no way of knowing that behavior and detecting it explicitly, so that we could make a decision to not expose this extension.
The pipeline statistics are purely informational because the hardware / driver / WebGPU implementation can do whatever it wants. For example any of these could decide to implement some copies with a compute shader, and that will modify the hardware counter. This is fine as long as the extension is exposed in more trusted contexts, or that it influences the privacy budget.
Because of the privacy implications, I think it is actually better to have the feature listed separately, so web pages know they will pay some privacy budget, or know they are not trusted to have this feature that can improve fingerprinting.
I'm just worried about this extension because we can't strictly specify what it does. The information it provides is unreliable, at least when it comes to Vulkan backend. I.e. how do we describe the semantics of the numbers here? The Web has a higher bar for specifying behaviour than native.
Perhaps, a deeper investigation is needed - to find out if Metal and D3D12 have more strict guarantees about the numbers.
Or perhaps, we should just say that this extension will only be available locally for developers having dev-tools enabled, and isn't useful/available for applications that ship.
Or perhaps, we should just say that this extension will only be available locally for developers having dev-tools enabled, and isn't useful/available for applications that ship.
Yeah basically it would be 100% informational. We might want to make this slightly less restrictive so it can be used for telemetry too but the intent of the extension should definitely to give numbers that can't really be used for accurate accounting during the frame.
@kvark Thanks for clarify. Metal just specify what the returned values are stand for. D3D12 has some descriptions to explain what will affect the results.
I think these values are intended to measure relative complexity of different parts of applications and get insights into the GPU operations while performance tuning. So how about add description to reminder users like this:
Note: These values are intended to measure relative statistics generated by operations of the device. Be careful to use these values in the release version of applications, because various device architectures may count these values differently.
Here is a radical proposal: let's not have pipeline statistics in the main specification.
First, we can't specify this. We can't just say this is a bunch of numbers.
Secondly, it may expose the details of driver/HW that makes fingerprinting easier. For example, a particular driver decides to work around a hardware bug by using compute shaders for copying data between buffers and textures (internally!). This is now observable.
We already know (and I think we agree?) that this isn't useful for shipped applications. It's only useful during development, so in some sort of "dev-tools" mode of the API. So I think it's best to have a separate document for the dev-tools side of the API, explaining the synchronous error modes, additional extensions, etc.
We already know (and I think we agree?) that this isn't useful for shipped applications. It's only useful during development, so in some sort of "dev-tools" mode of the API. So I think it's best to have a separate document for the dev-tools side of the API, explaining the synchronous error modes, additional extensions, etc.
I don't exactly agree. Things like timestamps are also super useful for telemetry. Also imagine something like the three.js debugger, you don't want to tell people to add the debugger in a <script> tag but also go and flip a couple scary switches in the devtools. It's better if it is broadly available but explains that you can get varying numbers back.
I think timestamps are needed in core for dynamic performance tuning (and telemetry). But I agree that pipeline statistics don't seem that useful in shipped applications.
I think it's okay to require developers to open dev tools and check a box (#814) in order to e.g. get extra features in the three.js debugger.
Issue triage: These particular topics above may still need some investigation. The feature itself may or may not need to move to a separate doc; we still need to discuss more. (Is this feature something we want to expose on end user machines? Can the results be fuzzed enough to avoid privacy issues?)
We currently don't see a need to make this a web-exposed feature, so I'm going to propose removing it from the main spec (probably moving it into an "extension" document - #814). I think we had already tentatively agreed on this a while ago.
@haoxli just want to make sure, is this OK with you? Or do you know of a use-case for exposing pipeline statistics queries to the Web (that would justify including the feature and doing the work to figure out how to round the results to combat fingerprinting)?
@kainino0x It's OK to move pipeline statistics queries to a seperate documents now. I think it could be used for pipeline profiling by developers, but I don’t have specific scenarios yet. We can implement it when we need.
Activity
Kangz commentedon May 20, 2020
For nesting, the Vulkan spec says:
So I think that should be disallowed, and
endPipelineStatisticsQuerycan have no argument.haoxli commentedon May 21, 2020
Yes, you're right, D3D12 and Metal don't support Query API on render bundles. I will move the Pipeline Statistcs APIs to
GPURenderPassEncoderandGPUComputePassEncoder.It only does not allow to create queryPool with same query type, but we can nest the query operation for a same query type, even for different query types, such as:
or
Maybe we can remove the args of queryset becase we have seprate api for different queries, but if removed, we need told users which the queryset the results are stored in, and the created queryset is only used when resolving, maybe also considerring not expose queryset, and resolving the data with query type instead, becasue there is only one queryset for each type, we can handle them in native. I think it will increase the complexity of the implementation, so currently I prefer to keep these arguments.
Kangz commentedon May 21, 2020
I'm pretty sure that's not allowed, because when there is the first
beginPipelineStatisticsQuerycall, that query becomes active, and the validation text I quoted above will be triggered in the second call tobeginPipelineStatisticsQuery. The Vulkan spec doesn't have any special text to allow additional queries if the query pool is already "active", it only cares whether any query is active for that type.haoxli commentedon May 21, 2020
Oh, understand what you mean, but strangely, I can test this case pass with Vulkan validation layers, I will file the issue for the validation and add description on spec to disallow the nesting.
kvark commentedon May 21, 2020
I'm a tiny bit concerned about how the pipeline statistics are going to be specified. In Vulkan the spec allows a lot of freedom to implementors, e.g.:
We can't put more strict wording, as we are constrained by the backend APIs. At the same time, if we have loose requirements like in Vulkan, we might as well just make it a part of WebGPU core and return zeroes where it's not supported :/
haoxli commentedon May 25, 2020
I filed an issue for the nested queries in Vulkan validation layers: KhronosGroup/Vulkan-ValidationLayers#1874.
@kvark Now we use an array of enum in
GPUPipelineStatisticNameto specified pipeline statistics, and also return 0 if the specified pipeline statistics is not supported. Difference is the number and order of the results written to buffer match the number and order of the specified pipeline statistics, in Vulkan, they are fixed.kvark commentedon May 25, 2020
I don't think my concern is understood. What I'm saying is that it seems perfectly valid for a Vulkan implementation to return 0 for the number of compute shader invocation. We have no way of knowing that behavior and detecting it explicitly, so that we could make a decision to not expose this extension.
Kangz commentedon May 26, 2020
The pipeline statistics are purely informational because the hardware / driver / WebGPU implementation can do whatever it wants. For example any of these could decide to implement some copies with a compute shader, and that will modify the hardware counter. This is fine as long as the extension is exposed in more trusted contexts, or that it influences the privacy budget.
Because of the privacy implications, I think it is actually better to have the feature listed separately, so web pages know they will pay some privacy budget, or know they are not trusted to have this feature that can improve fingerprinting.
kvark commentedon May 26, 2020
I'm just worried about this extension because we can't strictly specify what it does. The information it provides is unreliable, at least when it comes to Vulkan backend. I.e. how do we describe the semantics of the numbers here? The Web has a higher bar for specifying behaviour than native.
Perhaps, a deeper investigation is needed - to find out if Metal and D3D12 have more strict guarantees about the numbers.
Or perhaps, we should just say that this extension will only be available locally for developers having dev-tools enabled, and isn't useful/available for applications that ship.
Kangz commentedon May 26, 2020
Yeah basically it would be 100% informational. We might want to make this slightly less restrictive so it can be used for telemetry too but the intent of the extension should definitely to give numbers that can't really be used for accurate accounting during the frame.
haoxli commentedon May 27, 2020
@kvark Thanks for clarify. Metal just specify what the returned values are stand for. D3D12 has some descriptions to explain what will affect the results.
I think these values are intended to measure relative complexity of different parts of applications and get insights into the GPU operations while performance tuning. So how about add description to reminder users like this:
Note: These values are intended to measure relative statistics generated by operations of the device. Be careful to use these values in the release version of applications, because various device architectures may count these values differently.
kvark commentedon May 28, 2020
Here is a radical proposal: let's not have pipeline statistics in the main specification.
First, we can't specify this. We can't just say this is a bunch of numbers.
Secondly, it may expose the details of driver/HW that makes fingerprinting easier. For example, a particular driver decides to work around a hardware bug by using compute shaders for copying data between buffers and textures (internally!). This is now observable.
We already know (and I think we agree?) that this isn't useful for shipped applications. It's only useful during development, so in some sort of "dev-tools" mode of the API. So I think it's best to have a separate document for the dev-tools side of the API, explaining the synchronous error modes, additional extensions, etc.
Kangz commentedon May 28, 2020
I don't exactly agree. Things like timestamps are also super useful for telemetry. Also imagine something like the three.js debugger, you don't want to tell people to add the debugger in a <script> tag but also go and flip a couple scary switches in the devtools. It's better if it is broadly available but explains that you can get varying numbers back.
kainino0x commentedon May 28, 2020
I think timestamps are needed in core for dynamic performance tuning (and telemetry). But I agree that pipeline statistics don't seem that useful in shipped applications.
I think it's okay to require developers to open dev tools and check a box (#814) in order to e.g. get extra features in the three.js debugger.
Kangz commentedon Sep 20, 2021
For V1, we need to move the extension to a separate doc anyway.
kainino0x commentedon Nov 4, 2021
Issue triage: These particular topics above may still need some investigation. The feature itself may or may not need to move to a separate doc; we still need to discuss more. (Is this feature something we want to expose on end user machines? Can the results be fuzzed enough to avoid privacy issues?)
kainino0x commentedon Nov 10, 2021
We currently don't see a need to make this a web-exposed feature, so I'm going to propose removing it from the main spec (probably moving it into an "extension" document - #814). I think we had already tentatively agreed on this a while ago.
@haoxli just want to make sure, is this OK with you? Or do you know of a use-case for exposing pipeline statistics queries to the Web (that would justify including the feature and doing the work to figure out how to round the results to combat fingerprinting)?
haoxli commentedon Nov 11, 2021
@kainino0x It's OK to move pipeline statistics queries to a seperate documents now. I think it could be used for pipeline profiling by developers, but I don’t have specific scenarios yet. We can implement it when we need.
Delete pipeline statistics queries
litherum commentedon Nov 11, 2021
#2296 is a PR to tentatively delete pipeline statistics from the main spec (presumably so it can possibly be moved to a separate document).
Delete pipeline statistics queries