From 9e937ecd82264f0cc1efda2da97ecbdab2ba0fa9 Mon Sep 17 00:00:00 2001 From: Olli Etuaho Date: Sat, 14 Jan 2017 21:34:18 +0000 Subject: [PATCH] Fill in missing details in WEBGL_multiview spec (#2256) This adds specs for getFramebufferAttachmentParameter(), and extension macros in shaders. The added tokens, added functions and errors are documented with the correct syntax. --- .../proposals/WEBGL_multiview/extension.xml | 108 +++++++++++++++++- 1 file changed, 102 insertions(+), 6 deletions(-) diff --git a/extensions/proposals/WEBGL_multiview/extension.xml b/extensions/proposals/WEBGL_multiview/extension.xml index 647191af4a..98d2da9ffb 100644 --- a/extensions/proposals/WEBGL_multiview/extension.xml +++ b/extensions/proposals/WEBGL_multiview/extension.xml @@ -152,9 +152,6 @@ Likewise the shading language preprocessor #define GL_OVR_multiview, will be defined to 1 if the extension is supported. - - The maximum number of views can be queried by calling getParameter with the pname parameter set to MAX_VIEWS_OVR. The implementation must support at least 2 views. - Two levels of acceleration are exposed through alternative extension directives: GL_OVR_multiview and GL_OVR_multiview2. Using GL_OVR_multiview instead of GL_OVR_multiview2 restricts what can be done in shaders but may enable the WebGL implementation to accelerate multiview rendering using fixed-function hardware specifically designed for this purpose. @@ -185,9 +182,6 @@ Attempting to enable both GL_OVR_multiview and GL_OVR_multiview2 in the same shader results in a compile error. - - Attempting to draw when the number of views in the draw framebuffer does not match the number of views specified in the active program generates an INVALID_OPERATION error. - When the number of views specified in the active program is one, gl_ViewID_OVR will always evaluate to zero. @@ -202,6 +196,18 @@ Adds support for rendering into multiple views simultaneously. + + When a shader enables, requires, or warns either GL_OVR_multiview or GL_OVR_multiview2 with an extension directive: + + + + The GLSL macro GL_OVR_multiview is defined as 1. + + + The GLSL macro GL_OVR_multiview2 is defined as 1. + @@ -217,6 +223,92 @@ interface WEBGL_multiview { void framebufferTextureMultiviewWEBGL(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews); }; + + + + + + + + + + + + + + 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
+
+
+ + + + + + 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
+
+
+ + + The error INVALID_OPERATION is generated by attempting to enable this extension when the EXT_disjoint_timer_query_webgl2 extension is enabled. + + + The error INVALID_OPERATION is generated by attempting to enable the EXT_disjoint_timer_query_webgl2 extension when this extension is enabled. + + + The error INVALID_OPERATION is generated by calling framebufferTextureMultiviewWEBGL when transform feedback is active. + + + The error INVALID_OPERATION is generated by calling drawBuffer with the buf parameter set to BACK_LEFT_AND_RIGHT_MULTIVIEW_WEBGL when transform feedback is active. + + + The error INVALID_OPERATION is generated by calling bindFramebuffer with a framebuffer parameter that has multi-view attachments when transform feedback is active. + + + The error INVALID_OPERATION is generated by calling bindFramebuffer to bind the default framebuffer when both the left and right buffers of the stereo default framebuffer are chosen for rendering and transform feedback is active. + + + The error INVALID_OPERATION is generated by calling beginTransformFeedback when a framebuffer with multi-view attachments is bound as the draw framebuffer, or the default framebuffer is bound as the draw framebuffer and both left and right buffers of the stereo default framebuffer are chosen for rendering. + + + The error INVALID_OPERATION is generated by calling framebufferTextureMultiviewWEBGL with a texture parameter that does not identify a 2D array texture. + + + The error INVALID_VALUE is generated by calling framebufferTextureMultiviewWEBGL if numViews is less than 1, if numViews is more than MAX_VIEWS_OVR or with the parameters set so that baseViewIndex + numViews exceeds the value of MAX_ARRAY_TEXTURE_LAYERS. + + + The error INVALID_OPERATION is generated by attempting to bind a framebuffer that has multi-view attachments to READ_FRAMEBUFFER. + + + 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 1. + + + The error INVALID_OPERATION is generated by attempting to draw if the number of views in the draw framebuffer does not match the number of views declared in the active program. + + + +
+    var gl = document.createElement('canvas').getContext('webgl2', {'stereo': true});
+    var ext = gl.getExtension('WEBGL_multiview');
+    gl.drawBuffer(ext.BACK_LEFT_AND_RIGHT_MULTIVIEW_WEBGL);
+    gl.drawElements(...);  // draw will be broadcasted to both left and right buffers.
+    
+
     #version 300 es
@@ -244,5 +336,9 @@ interface WEBGL_multiview {
     
       Specified what happens on invalid num_views declarations and if assignment to gl_Position.x is inside a larger expression.
     
+
+    
+      Filled in getFramebufferAttachmentParameter and extension macro specs, formatted the documentation better, and added a simple API usage example.
+