1Name 2 3 OVR_multiview_multisampled_render_to_texture 4 5Name Strings 6 7 GL_OVR_multiview_multisampled_render_to_texture 8 9Contact 10 11 Cass Everitt (cass.everitt 'at' oculus.com) 12 13Contributors 14 15 Jason Allen, NVIDIA Corporation 16 Sam Holmes, Qualcomm 17 Jan-Harald Fredriksen, ARM 18 19Status 20 21 Incomplete 22 23Version 24 25 Last Modified Date: June 25, 2015 26 Revision: 0.4 27 28Number 29 30 OpenGL ES Extension #250 31 32Dependencies 33 34 OpenGL ES 3.0, EXT_multisampled_render_to_texture, and at least 35 one of OVR_multiview or OVR_multiview2 are required. This 36 extension is written against the OpenGL ES 3.0 Specification. 37 38Overview 39 40 This extension brings to multiview rendering the functionality 41 originally introduced in EXT_multisampled_render_to_texture. 42 Essentially this just means adding one new function for 43 multisample multiview array attachments in the framebuffer object. 44 45IP Status 46 47 No known IP claims. 48 49New Procedures and Functions 50 51 void FramebufferTextureMultisampleMultiviewOVR( 52 enum target, enum attachment, 53 uint texture, int level, sizei samples, 54 int baseViewIndex, sizei numViews); 55 56New Tokens 57 58 None. 59 60Additions to Section 4.4.2 of the OpenGL ES 3.0 Specification 61(Attaching Images to Framebuffer Objects) 62 63 Add the following after the paragraph describing FramebufferTexture2D: 64 (Logically, this follows after the paragraph in GL_OVR_multiview 65 describing FramebufferTextureMultiviewOVR and the paragraph in GL_EXT_- 66 multisampled_render_to_texture describing FramebufferTexture2D- 67 MultisampleEXT) 68 69 The command 70 void FramebufferTextureMultisampleMultiviewOVR( 71 enum target, enum attachment, 72 uint texture, int level, sizei samples, 73 int baseViewIndex, sizei numViews); 74 75 operates similarly to FramebufferTextureMultiviewOVR, except that it 76 also enables multisampled rendering into the images of a non-multisampled 77 texture object similarly to FramebufferTexture2DMultisampleEXT. 78 79 <target>, <attachment>, <texture>, <level>, <baseViewIndex>, and 80 <numViews> correspond to the same parameters for FramebufferTexture- 81 MultiviewOVR and have the same restrictions and errors. <samples> 82 corresponds to the same parameter for FramebufferTexture2DMultisampleEXT 83 and has the same restrictions and errors. 84 85 The contents of the multisample buffer of the texture level become 86 undefined under the same conditions and operations as for 87 FramebufferTexture2DMultisampleEXT. 88 89Dependencies on GL and ES profiles, versions, and other extensions 90 91 This extension requires EXT_multisampled_render_to_texture, and at least 92 one of OVR_multiview or OVR_multiview2 and inherits their dependencies. 93 94Errors 95 96 INVALID_FRAMEBUFFER_OPERATION is generated by commands that read from the 97 framebuffer such as ReadPixels, CopyTexImage*, and CopyTexSubImage*, if 98 the number of views in the current read framebuffer is greater than 1. 99 100 INVALID_VALUE is generated by FramebufferTextureMultisampleMultiviewOVR if 101 numViews is less than 1, if numViews is more than MAX_VIEWS_OVR or if 102 (baseViewIndex + numViews) exceeds GL_MAX_ARRAY_TEXTURE_LAYERS. 103 104 INVALID_VALUE is generated by FramebufferTextureMultisampleMultiviewOVR if 105 samples is greater than MAX_SAMPLES. 106 107 INVALID_OPERATION is generated if a rendering command is issued and the 108 number of views in the current draw framebuffer is not equal to the number 109 of views declared in the currently bound program. 110 111 INVALID_OPERATION is generated if the target type of <texture> specified 112 in FramebufferTextureMultisampleMultiviewOVR is not TEXTURE_2D_ARRAY. 113 114New State 115 116 None. 117 118New Implementation Dependent State 119 120 None. 121 122Sample code 123 124 GLsizei width = ...; 125 GLsizei height = ...; 126 GLint samples = ...; 127 GLsizei views = 2; 128 129 glGenTextures(views, tex); 130 glBindTexture(GL_TEXTURE_2D_ARRAY, tex[0]); 131 /* Create a color texture */ 132 glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, GL_RGBA8, width, height, views ); 133 /* Create a depth texture */ 134 glBindTexture(GL_TEXTURE_2D_ARRAY, tex[1]); 135 glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, GL_DEPTH_COMPONENT24, width, height, views ) 136 137 /* attach the render targets */ 138 glFramebufferTextureMultisampleMultiviewOVR(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex[0], 0, samples, 0, views); 139 glFramebufferTextureMultisampleMultiviewOVR(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, tex[1], 0, samples, 0, views); 140 141 /* .. draw to multisampled multiview .. */ 142 143Issues 144 145 1. Should there be a way for applications to preserve the multisample 146 buffer after a resolve? 147 148 RESOLVED: No. This spec is intended as a lightweight addition to multiview 149 support and the added complexity of allowing resolves with preservation goes 150 against this intention. 151 152 2. Should there be a way for applications to guarantee preservation of 153 the multisample buffer mid-frame. 154 155 RESOLVED: No. On tiling architectures application behavior may implicitly 156 trigger a mid-frame resolve. There is no requirement for a backing store 157 to be maintained for the samples and in the case of a mid-frame resolve 158 sample data may be lost. 159 160 3. Are there any implications on the framebuffer completeness check? 161 162 RESOLVED: No. The framebuffer completeness rules are fully specified 163 by the combination of the added rules in EXT_multisampled_render_to_texture 164 and OVR_multiview, i.e., the number of views and the number of samples 165 must both match across attachments. 166 167 4. Why does reading from multi-view framebuffers generate INVALID_- 168 FRAMEBUFFER_OPERATION? 169 170 PROPOSED. 171 172 GL_OVR_multiview tried to avoid reading from multi-view framebuffers 173 by specifying that INVALID_OPERATION is generated by FramebufferTexture- 174 MultiviewOVR if target is GL_READ_FRAMEBUFFER. This error is not 175 sufficient to prevent reads from multi-view targets. It disallows 176 attaching a multi-view texture to the current read framebuffer, but 177 there is no error that disallows attaching the multi-view texture to the 178 current write framebuffer, and later binding that as the read framebuffer. 179 180 Multiple options for resolving this is outlined below. As written, this 181 specification assumes Option B. 182 183 Option A: Detect the error on attach / bind 184 - keep the existing error on FramebufferTextureMultiviewOVR, but change it 185 to also generate an error on GL_FRAMEBUFFER (since that includes 186 GL_READ_FRAMEBUFFER). 187 - add an error on BindFramebuffer to prevent a multiview framebuffer to 188 be bound as the current draw framebuffer 189 - extend the error conditions on FramebufferTextureMultiviewOVR to also 190 generate an error if <target> is GL_WRITE_FRAMEBUFFER and the current 191 write framebuffer is the same as the current read framebuffer. 192 193 This has the benefit of maintaining compatibility with GL_OVR_multiview, 194 but it is a complex error condition, and interactions with other 195 features / extensions would also need to be considered. 196 197 Option B: Detect the error on read operations. 198 - remove the existing error on FramebufferTextureMultiviewOVR 199 - add an error condition that applies to all read operations 200 201 This has the benefit of being simple (the error is only generated when 202 the illegal operation is detected) and robust (i.e., there are no corner 203 cases to consider). The downside is that the error is detected late. 204 205 Option C: Remove the error and define what happens on reads. 206 - remove the existing error on FramebufferTextureMultiviewOVR 207 - add language similar to that for layered framebuffers, like: 208 "When commands such as ReadPixels read from a multi-view framebuffer, 209 the image at view zero of the selected attachment is always used to 210 obtain pixel values. 211 212 This has the benefit of being aligned with other GL features. The down- 213 side is that this adds implementation cost without providing a good 214 use-case (i.e., it could only read a single view). 215 216Revision History 217 218 Rev. Date Author Changes 219 ---- ---------- -------- ----------------------------------------- 220 0.1 04/29/2015 cass Initial draft 221 0.2 05/04/2015 sam Clarify issues around sample preservation 222 0.3 06/01/2015 cass Remove renderbuffer support 223 0.4 06/25/2015 jhf Clarify error conditions, add language. 224