Skip to content
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

Communicate projection layer texture size outside the frame loop #224

Closed
toji opened this issue Oct 28, 2020 · 6 comments · Fixed by #241 or #242
Closed

Communicate projection layer texture size outside the frame loop #224

toji opened this issue Oct 28, 2020 · 6 comments · Fixed by #241 or #242
Assignees

Comments

@toji
Copy link
Member

toji commented Oct 28, 2020

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:

  1. 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 like XRMediaBinding 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;
};
  1. If we want this to work a bit more generally and sidestep complications with XRMediaBinding we could also make it a query on XRWebGLBinding, similar to getSubImage() 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?
@cabanier
Copy link
Member

I prefer option 1. Projection layers will always have an pixel size so there's no need to have a helper method.

@nkronlage
Copy link

The textureLayers name makes it sound like an array of XRLayers to me.

How about calling it textureLayerLength or textureLayerSize?

@cabanier
Copy link
Member

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?

@toji
Copy link
Member Author

toji commented Jan 16, 2021

My intent was to indicate the number of textures in the texture array. (The texture "depth")

@cabanier
Copy link
Member

Would a better name be textureArrayLength?

@toji
Copy link
Member Author

toji commented Jan 17, 2021

textureArrayLayers would probably match the WebGL 2 verbiage best, but in order to avoid the namespace conflict with XRLayer I think textureArrayLength is fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants