Communicate projection layer texture size outside the frame loop
toji opened this issue · comments
Brought up in discussion on #223
Most layer types accept a user-specified texture size, but projection layers only accept a scalar and the final size is determined by the UA/hardware. Currently this size is only reported in the XRSubImage
, which can only be accessed inside the frame loop.
The problem is that currently if the application wants to manage their own depth buffer (which will be necessary for WebGL 1 apps that aren't using the WEBGL_depth_texture
extension or that don't want their depth buffer to be used by the compositor), or any other supplemental buffers, it would have to wait until the first frame after layer creation to determine the required dimensions for those buffers. Ideally that allocation could happen outside of the frame loop, probably immediately after the layer creation.
I can think of one of two ways to approach this:
- We report the texture dimensions on the
XRProjectionLayer
directly. (This would likely be ONLY for the projection layer, since other layer types may be used with things likeXRMediaBinding
and the sizes would be moot.) In order for applications to allocate a matching buffer we'd want to report both the size and layer count for array textures.
[Exposed=Window] interface XRProjectionLayer : XRCompositionLayer {
readonly attribute unsigned long textureWidth;
readonly attribute unsigned long textureHeight;
readonly attribute unsigned long textureLayers;
};
- If we want this to work a bit more generally and sidestep complications with
XRMediaBinding
we could also make it a query onXRWebGLBinding
, similar togetSubImage()
but without the frame requirements:
partial interface XRWebGLBinding {
XRImageDimensions getImageDimensions(XRCompositionLayer layer);
};
interface XRImageDimensions {
readonly attribute unsigned long textureWidth;
readonly attribute unsigned long textureHeight;
readonly attribute unsigned long textureLayers;
};
// Probably want to use that in XRWebGLSubImage too?
I prefer option 1. Projection layers will always have an pixel size so there's no need to have a helper method.
The textureLayers
name makes it sound like an array of XRLayers to me.
How about calling it textureLayerLength
or textureLayerSize
?
The
textureLayers
name makes it sound like an array of XRLayers to me.
Good point. @toji , was this attribute meant to indicate the number of textures in the texture array, or the number of textures in the internal array or both?
My intent was to indicate the number of textures in the texture array. (The texture "depth")
Would a better name be textureArrayLength
?
textureArrayLayers
would probably match the WebGL 2 verbiage best, but in order to avoid the namespace conflict with XRLayer
I think textureArrayLength
is fine.