Skip to content

Communicate projection layer texture size outside the frame loop #224

Closed

Description

@toji

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?

Activity

  1. cabanier commented on Oct 29, 2020

    @cabanier
    Member

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

  2. nkronlage commented on Jan 15, 2021

    @nkronlage

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

    How about calling it textureLayerLength or textureLayerSize?

  3. cabanier commented on Jan 15, 2021

    @cabanier
    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?

  4. toji commented on Jan 16, 2021

    @toji
    MemberAuthor

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

  5. cabanier commented on Jan 16, 2021

    @cabanier
    Member

    Would a better name be textureArrayLength?

  6. toji commented on Jan 17, 2021

    @toji
    MemberAuthor

    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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions