WebGL
Khronos
 

WebGL OVR_multiview2 Extension Specification

Name

OVR_multiview2

Contact

WebGL working group (public_webgl 'at' khronos.org)

Contributors

Olli Etuaho, NVIDIA

Mingyu Hu, Microsoft

Members of the WebGL working group

Version

Last modified date: July 24, 2019
Revision: 16

Number

WebGL extension #36

Dependencies

Written against the WebGL API 2.0 specification.

Overview

This extension exposes the OVR_multiview2 functionality to WebGL.

The following WebGL-specific behavioral changes apply:

Consult the above extension for documentation, issues and new functions and enumerants.

When this extension is enabled:

IDL

[NoInterfaceObject]
interface OVR_multiview2 {
    const GLenum FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR = 0x9630;
    const GLenum FRAMEBUFFER_ATTACHMENT_TEXTURE_BASE_VIEW_INDEX_OVR = 0x9632;
    const GLenum MAX_VIEWS_OVR = 0x9631;
    const GLenum FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR = 0x9633;

    void framebufferTextureMultiviewOVR(GLenum target, GLenum attachment, WebGLTexture? texture, GLint level, GLint baseViewIndex, GLsizei numViews);
};
  

New Functions

void framebufferTextureMultiviewOVR(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews)

New Tokens

any getParameter(GLenum pname)
Calling with the pname set to MAX_VIEWS_OVR returns the maximum number of views. The implementation must support at least 2 views.
The return type depends on the parameter queried:
pnamereturned type
MAX_VIEWS_OVRGLint
any getFramebufferAttachmentParameter(GLenum target, GLenum attachment, GLenum pname)
Calling with the pname parameter set to FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR returns the number of views of the framebuffer object attachment. Calling with the pname parameter set to FRAMEBUFFER_ATTACHMENT_TEXTURE_BASE_VIEW_INDEX_OVR returns the base view index of the framebuffer object attachment.
The return type depends on the parameter queried:
pnamereturned type
FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVRGLsizei
FRAMEBUFFER_ATTACHMENT_TEXTURE_BASE_VIEW_INDEX_OVRGLint

Errors

The error INVALID_OPERATION is generated by calling framebufferTextureMultiviewOVR with a texture parameter that does not identify a 2D array texture.
The error INVALID_VALUE is generated by calling framebufferTextureMultiviewOVR with a non-null texture in the following cases:
The error INVALID_FRAMEBUFFER_OPERATION is generated by commands that read from the framebuffer such as BlitFramebuffer, ReadPixels, CopyTexImage*, and CopyTexSubImage*, if the number of views in the current read framebuffer is greater than one.
The error INVALID_OPERATION is generated by attempting to draw if the active program declares a number of views and the number of views in the draw framebuffer does not match the number of views declared in the active program.
The error INVALID_OPERATION is generated by attempting to draw if the number of views in the current draw framebuffer is greater than one and the active program does not declare a number of views.
The error INVALID_OPERATION is generated by attempting to draw if the number of views in the current draw framebuffer is greater than one and transform feedback is active and not paused.
The error INVALID_OPERATION is generated by attempting to draw or calling clear if the number of views in the current draw framebuffer is greater than one and a timer query is active.

Sample Code

    var gl = document.createElement('canvas').getContext('webgl2');
    var ext = gl.getExtension('OVR_multiview2');
    var fb = gl.createFramebuffer();
    gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, fb);
    var colorTex = gl.createTexture();
    gl.bindTexture(gl.TEXTURE_2D_ARRAY, colorTex);
    gl.texStorage3D(gl.TEXTURE_2D_ARRAY, 1, gl.RGBA8, 512, 512, 2);
    ext.framebufferTextureMultiviewOVR(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, colorTex, 0, 0, 2);
    var depthStencilTex = gl.createTexture();
    gl.bindTexture(gl.TEXTURE_2D_ARRAY, depthStencilTex);
    gl.texStorage3D(gl.TEXTURE_2D_ARRAY, 1, gl.DEPTH32F_STENCIL8, 512, 512, 2);
    ext.framebufferTextureMultiviewOVR(gl.DRAW_FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, depthStencilTex, 0, 0, 2);
    gl.drawElements(...);  // draw will be broadcasted to the layers of colorTex and depthStencilTex.
    
    #version 300 es
    #extension GL_OVR_multiview2 : require
    precision mediump float;
    layout (num_views = 2) in;
    in vec4 inPos;
    uniform mat4 u_viewMatrices[2];
    void main() {
      gl_Position = u_viewMatrices[gl_ViewID_OVR] * inPos;
    }
    

Revision History

Revision 1, 2016/11/11

Revision 2, 2016/11/25

Revision 3, 2016/12/21

Revision 4, 2017/01/12

Revision 5, 2017/03/10

Revision 6, 2017/05/19

Revision 7, 2017/05/23

Revision 8, 2017/07/21

Revision 9, 2017/08/08

Revision 10, 2017/08/17

Revision 11, 2017/10/26

Revision 12, 2018/01/03

Revision 13, 2018/07/26

Revision 14, 2019/03/06

Revision 15, 2019/04/25

Revision 16, 2019/07/24