-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Supported texture formats #10
Comments
Following the WebGPU approach seems reasonable. Specifically, supporting the
|
I already got a bug that Quest browser was unacceptably slow with its non-preferred texture format. I think we should only allow the preferred one since WebXR is so sensitive to performance. |
What device has srgb as its native format?
I originally tried to use views to work around the gamma problem but they weren't consistently implemented so gamma was sometimes still applied :-\ |
That's a good point, and it makes me wonder if we need to start breaking the texture info out into mini descriptors so that we can get more specific about how each surface is used. ie: gpuBinding.createProjectionLayer({
color: {
format: 'bgra8unorm',
viewFormats: ['bgra8unorm-srgb'],
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_DST
},
depthStencil: { format: 'depth24plus' }
});
This is definitely a factor worth considering, though I think it would introduce a bit of dev pain. We'd want to report the format on the binding rather than wait for devs to find it out from the first frame's texture. Also, we should consider how HDR is supported eventually. Out of curiosity, what is the preferred format for the Quest and AVP? I'm gonna guess Quest is
I don't think any devices consume sRGB formats, but all of them assume that the data in the texture is sRGB encoded anyway, which... sigh. Using an sRGB view of a non-sRGB format is an easy way for devs to get the right formatting of the values in their output without doing silly gamma conversions in their shaders. |
True
No, it's |
Apple Vision Pro uses either MTLPixelFormatBGRA8Unorm_sRGB or MTLPixelFormatRGBA16Float for the texture format with DisplayP3 for BGRA8 and ExtendedLinearDisplayP3 for RGBA16Float color space. These are the textures that come from the compositor's triple buffering mechanism. So if this is limited to a 'preferred' format then we would need to allow multiple preferred formats, to support HDR as mentioned. @cabanier the gamma correction should be fixed in https://bugs.webkit.org/show_bug.cgi?id=273603 but if you are still seeing it on visionOS 2.0 betas, certainly a bug report or simply a website where it reproduces would be great. |
Huh. I'm surprised that everyone's preferred LDR format is BGRA! It's tempting to say that devs either get that or an agreed upon HDR format (if supported) but I'm also pretty sure that we'll run into some Android-based devices (Pico or HTC maybe?) that prefer RGBA, since that's generally what the Android SurfaceFlinger requires. |
/tpac |
After discussion at TPAC the tentative resolution is that we will attempt to support the same set of formats that WebGPU supports for canvas rendering ( HDR rendering is only partically resolved. We decided that |
I'd like to do some more investigation before we make this decision. |
Yes, agreed that we need more investigation. The language in my previous comment is perhaps a little too strong. Where I said "tentative resolution" it would be more accurate to say "the direction the group wants to investigate, and report back on issues that we encounter." We have not concretely committed to supporting all of those formats in all cases, simply stated that it would be nice if we aligned with WebGPU in this regard and are going to attempt that during prototyping. |
Does Vulkan support texture swizzles on Quest similar to MTLTextureSwizzle? I see some references in the Vulkan documentation to VkComponentSwizzle but not sure if this can be used in a way similar to Metal: if a backend requests RGBA for instance, we can create a texture view of the BGRA compositor texture with a swizzle mask which is almost free, avoiding the copy. I think it is only during pixel read backs from the canvas APIs where a copy is needed, which seems rare for the immersive session textures. I didn't fully work through if there are any issues with that approach, but should be possible to avoid the copy if texture swizzle is supported. |
I don't think there's any way to specify to OpenXR the VkImageView that you want to use, which is where the component swizzle would be applied. Instead it takes SwapChains directly with arguments for the viewport and imageArrayIndex. Vulkan's spec also says that you can't apply swizzles to framebuffer attachements:
So I don't think it could be applied at the WebGPU rendering side either, unfortunately. 😞 |
It was brought up that we will definitely want to limit the WebGPU texture formats which are accepted by the layer creation methods. For example: We probably don't want users requesting an
r8sint
color format with astencil8
depth/stencil format.WebGPU's solution for this regarding canvas integration is to limit the context to a narrow set of supported context formats. Specifically:
bgra8unorm
rgba8unorm
rgba16float
(There is no limit on depthStencil formats because unlike WebGL the canvas does not supply depthStencil buffers. They are managed manually by the developer.)
We should determine how we want to limit WebXR's accepted texture formats. Either by putting a static list in the spec like WebGPU or by explicitly advertising the formats that may be used (though even in that case I would advocate for picking a format or two that are always guaranteed to be supported.)
Also worth considering is that WebGPU advertises a "preferred" format for the device which will avoid unnecessary copies. We will likely want the same, and the explainer already contains a
getPreferredColorFormat()
method. We should consider if that needs to be updated based on how we handle the supported format list, and whether or not agetPreferredDepthStencil()
format is also necessary.CC @mwyrzykowski, @cabanier
The text was updated successfully, but these errors were encountered: