Repository navigation
Add GPUCanvasContext getConfiguration() method - #4899
Conversation
|
Previews, as seen when this build job started (3271365): |
fd51e20 to
a193c2e
Compare
kainino0x
left a comment
There was a problem hiding this comment.
LGTM, that's explained well!
Sounds like a foot gun. Most people are going to write const isReallyHDR = context.getConfiguration().toneMapping.mode === 'extended';and then have their app crash when Also, when does it return |
They should write We could do the same as with getCurrentTexture() and throw an InvalidStateError if
It returns |
Thanks. I see that now.
They shouldn't have to write this given that it only returns null before |
An external app monitoring the canvas configuration would have to do that but you're right, the app in control of the canvas would know. |
This CL adds the GPUCanvasContext getConfiguration() method bebhind the experimental WebGPUExperimentalFeatures blink runtime feature. It will allow us to write tests for the WebGPU CTS. Spec PR: gpuweb/gpuweb#4899 Bug: 370109829 Change-Id: I50aee0a52cd229c5fb1f4a2e518af72d548e1879 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5890176 Reviewed-by: Kai Ninomiya <kainino@chromium.org> Commit-Queue: Fr <beaufort.francois@gmail.com> Reviewed-by: Brandon Jones <bajones@chromium.org> Cr-Commit-Position: refs/heads/main@{#1361869}
| {{GPUCanvasConfiguration/toneMapping}} is implemented and the <l>'@media/dynamic-range'</l> media | ||
| query indicates HDR support, then WebGPU canvas **should** render content using the full | ||
| HDR range instead of clamping values to the SDR range of the HDR display. | ||
| </div> |
There was a problem hiding this comment.
-
I find it a bit odd that the getter for GPUCanvasContext configuration would document behavior of how HDR tone mapping should work. Wouldn't this documentation be better suited to exist in
GPUCanvasContext.configure()where these fields are established? -
Also, there is
**Returns:** {{GPUCanvasConfiguration}} or `null`
When is this function allowed to return null? Can an implementation return null as a "eh, we didn't care to implement this function. We consider our WebGPU implementation to be a "pure" rendering device implementation (in the same philosophy of [D3DCREATE_PUREDEVICE](https://learn.microsoft.com/en-us/windows/win32/direct3d9/d3dcreate)) - track this information yourself."
- Is this function guaranteed to return the exact same fields that were fed to
GPUCanvasContext.configure()? Or can there be differences? For example, in the sense of "I configure()d with X, and now I'm calling getConfiguration() to see if I actually got Y" behavior? Can an implementation do that?
There was a problem hiding this comment.
- There are notes in the definitions for both
toneMappingandconfigure()pointing toward it. Fair point it's an odd spot for that note though. - It returns null if and only if the canvas is not configured.
- There aren't any steps which modify the configuration passed into
configure()so the only change should be that keys not known by the browser are dropped, or if the requested configuration is invalid thenconfigure()will fail andgetConfiguration()will return null.
per specs for getConfiguration(), configure()
As discussed in #4828, this PR exposes a way for web apps to feature-detect whether WebGPU can do HDR canvas. It does so by exposing a new GPUCanvasContext
getConfiguration()method that returns the context configuration which includes device, format, usage, viewFormats, colorSpace, toneMapping, and alphaMode members.