| 1 | <?xml version="1.0"?> |
| 2 | |
| 3 | <ratified href="WEBGL_depth_texture/"> |
| 4 | <name>WEBGL_depth_texture</name> |
| 5 | <aliases> |
| 6 | <alias>WEBKIT_WEBGL_depth_texture</alias> |
| 7 | <alias>MOZ_WEBGL_depth_texture</alias> |
| 8 | </aliases> |
| 9 | <contact> |
| 10 | <a href="https://www.khronos.org/webgl/public-mailing-list/">WebGL working group</a> (public_webgl 'at' khronos.org) |
| 11 | </contact> |
| 12 | <contributors> |
| 13 | <contributor>Members of the WebGL working group</contributor> |
| 14 | <contributor>Florian Bösch (pyalot 'at' gmail.com)</contributor> |
| 15 | </contributors> |
| 16 | <number>9</number> |
| 17 | <depends> |
| 18 | <api version="1.0"/> |
| 19 | <removed version="2.0" /> |
| 20 | </depends> |
| 21 | <overview> |
| 22 | <p>This extension exposes the |
| 23 | <a href="http://angleproject.googlecode.com/svn/trunk/extensions/ANGLE_depth_texture.txt">ANGLE_depth_texture</a> |
| 24 | functionality to WebGL. ANGLE_depth_texture provides a subset of the |
| 25 | functionality from the OpenGL ES 2.0 extensions |
| 26 | <a href="http://www.khronos.org/registry/gles/extensions/OES/OES_depth_texture.txt">OES_depth_texture</a> |
| 27 | and |
| 28 | <a href="http://www.khronos.org/registry/gles/extensions/OES/OES_packed_depth_stencil.txt">OES_packed_depth_stencil</a>, with certain restrictions added for portability reasons. Specifically:</p> |
| 29 | |
| 30 | <ul> |
| 31 | <li> ANGLE_depth_texture provides both depth and depth/stencil textures. </li> |
| 32 | <li> ANGLE_depth_texture does not provide the <code>DEPTH24_STENCIL8_OES</code> renderbuffer internal format from the OES_packed_depth_stencil extension. The core WebGL specification already supports allocation of depth/stencil renderbuffers. </li> |
| 33 | <li> ANGLE_depth_texture does not support loading image data via the TexImage or TexSubImage commands. Depth and depth/stencil textures created via this extension can only have their contents specified by rendering to them. </li> |
| 34 | </ul> |
| 35 | |
| 36 | <p>Consult the Errors section below for specific restrictions. |
| 37 | </p> |
| 38 | |
| 39 | <features> |
| 40 | <feature> |
| 41 | The <code>texImage2D</code> entry point is extended to accept the |
| 42 | <code>format</code> parameter <code>DEPTH_COMPONENT</code> and |
| 43 | <code>DEPTH_STENCIL</code> |
| 44 | </feature> |
| 45 | <feature> |
| 46 | The <code>texImage2D</code> entry point is extended to accept the |
| 47 | <code>internalFormat</code> parameter <code>DEPTH_COMPONENT</code> |
| 48 | and <code>DEPTH_STENCIL</code> |
| 49 | </feature> |
| 50 | <feature> |
| 51 | The <code>texImage2D</code> entry point is extended to accept |
| 52 | the <code>type</code> parameter <code>UNSIGNED_SHORT</code>, |
| 53 | <code>UNSIGNED_INT</code>, and |
| 54 | <code>UNSIGNED_INT_24_8_WEBGL</code> |
| 55 | </feature> |
| 56 | <feature> |
| 57 | The <code>framebufferTexture2D</code> entry point is extended to |
| 58 | accept the <code>target</code> parameter |
| 59 | <code>DEPTH_ATTACHMENT</code> and |
| 60 | <code>DEPTH_STENCIL_ATTACHMENT</code> |
| 61 | </feature> |
| 62 | <feature> |
| 63 | The <code>texImage2D</code> entry point is extended to accept |
| 64 | <code>ArrayBufferView</code> of type <code>Uint16Array</code> and |
| 65 | <code>Uint32Array</code> |
| 66 | </feature> |
| 67 | <feature> |
| 68 | <p> |
| 69 | The WebGL-specific constraints about <a href="http://www.khronos.org/registry/webgl/specs/1.0/#FBO_ATTACHMENTS">Framebuffer Object Attachments</a> are extended:</p> |
| 70 | |
| 71 | <ul> |
| 72 | <li> A texture attached to an FBO's <code>DEPTH_ATTACHMENT</code> attachment point must be allocated with the <code>DEPTH_COMPONENT</code> internal format. </li> |
| 73 | <li> A texture attached to the <code>DEPTH_STENCIL_ATTACHMENT</code> attachment point must be allocated with the <code>DEPTH_STENCIL</code> internal format. </li> |
| 74 | </ul> |
| 75 | |
| 76 | <p> |
| 77 | In the WebGL API, it is an error to concurrently attach either |
| 78 | renderbuffers or textures to the following combinations of |
| 79 | attachment points:</p> |
| 80 | |
| 81 | <ul> |
| 82 | <li> <code>DEPTH_ATTACHMENT</code> + <code>DEPTH_STENCIL_ATTACHMENT</code> </li> |
| 83 | <li> <code>STENCIL_ATTACHMENT</code> + <code>DEPTH_STENCIL_ATTACHMENT</code> </li> |
| 84 | <li> <code>DEPTH_ATTACHMENT</code> + <code>STENCIL_ATTACHMENT</code> </li> |
| 85 | </ul> |
| 86 | |
| 87 | <p> |
| 88 | See the section |
| 89 | <a href="http://www.khronos.org/registry/webgl/specs/1.0/#FBO_ATTACHMENTS">Framebuffer Object Attachments</a> |
| 90 | in the WebGL specification for the behavior if these |
| 91 | constraints are violated. |
| 92 | </p> |
| 93 | </feature> |
| 94 | <feature> |
| 95 | <p> |
| 96 | As per the OpenGL ES spec, there is no guarantee that the OpenGL ES implementation |
| 97 | will use the texture type to determine how to store the depth texture internally. |
| 98 | It may choose to downsample the 32-bit depth values to 16-bit or even 24-bit. |
| 99 | When a depth or depth/stencil texture is attached to a framebuffer object, calls to getParameter |
| 100 | with the DEPTH_BITS and STENCIL_BITS enums return the following: |
| 101 | <table> |
| 102 | <tr> |
| 103 | <th>Texture Type</th> |
| 104 | <th>DEPTH_BITS (GLint)</th> |
| 105 | <th>STENCIL_BITS (GLint)</th> |
| 106 | </tr> |
| 107 | <tr> |
| 108 | <td>UNSIGNED_SHORT</td> |
| 109 | <td>>= 16</td> |
| 110 | <td>0</td> |
| 111 | </tr> |
| 112 | <tr> |
| 113 | <td>UNSIGNED_INT</td> |
| 114 | <td>>= 16</td> |
| 115 | <td>0</td> |
| 116 | </tr> |
| 117 | <tr> |
| 118 | <td>UNSIGNED_INT_24_8_WEBGL</td> |
| 119 | <td>>= 24</td> |
| 120 | <td>>= 8</td> |
| 121 | </tr> |
| 122 | </table> |
| 123 | </p> |
| 124 | </feature> |
| 125 | </features> |
| 126 | </overview> |
| 127 | <idl xml:space="preserve"> |
| 128 | [NoInterfaceObject] |
| 129 | interface WEBGL_depth_texture { |
| 130 | const GLenum UNSIGNED_INT_24_8_WEBGL = 0x84FA; |
| 131 | }; |
| 132 | </idl> |
| 133 | <errors> |
| 134 | <error> |
| 135 | The error <code>INVALID_OPERATION</code> is generated by |
| 136 | <code>texImage2D</code> if the <code>format</code> parameter is |
| 137 | <code>DEPTH_COMPONENT</code> or <code>DEPTH_STENCIL</code> and the |
| 138 | <code>target</code> is |
| 139 | <code>TEXTURE_CUBE_MAP_{POSITIVE,NEGATIVE}_{X,Y,Z}</code>. |
| 140 | </error> |
| 141 | <error> |
| 142 | The error <code>INVALID_OPERATION</code> is generated by |
| 143 | <code>texImage2D</code> if <code>format</code> and |
| 144 | <code>internalformat</code> are <code>DEPTH_COMPONENT</code> and |
| 145 | <code>type</code> is not <code>UNSIGNED_SHORT</code> or |
| 146 | <code>UNSIGNED_INT</code>. |
| 147 | </error> |
| 148 | <error> |
| 149 | The error <code>INVALID_OPERATION</code> is generated by |
| 150 | <code>texImage2D</code> if <code>format</code> and |
| 151 | <code>internalformat</code> are not <code>DEPTH_COMPONENT</code> |
| 152 | and <code>type</code> is <code>UNSIGNED_SHORT</code> or |
| 153 | <code>UNSIGNED_INT</code>. |
| 154 | </error> |
| 155 | <error> |
| 156 | The error <code>INVALID_OPERATION</code> is generated by |
| 157 | <code>texImage2D</code> if <code>format</code> and |
| 158 | <code>internalformat</code> are <code>DEPTH_STENCIL</code> and |
| 159 | <code>type</code> is not <code>UNSIGNED_INT_24_8_WEBGL</code>. |
| 160 | </error> |
| 161 | <error> |
| 162 | The error <code>INVALID_OPERATION</code> is generated by |
| 163 | <code>texImage2D</code> if <code>format</code> and |
| 164 | <code>internalformat</code> are not <code>DEPTH_STENCIL</code> and |
| 165 | <code>type</code> is <code>UNSIGNED_INT_24_8_WEBGL</code>. |
| 166 | </error> |
| 167 | <error> |
| 168 | The error <code>INVALID_OPERATION</code> is generated in the following situations: |
| 169 | <ul> |
| 170 | <li> |
| 171 | <code>texImage2D</code> is called with <code>format</code> and |
| 172 | <code>internalformat</code> of <code>DEPTH_COMPONENT</code> or |
| 173 | <code>DEPTH_STENCIL</code> and |
| 174 | <ul> |
| 175 | <li> <code>target</code> is not TEXTURE_2D, </li> |
| 176 | <li> <code>data</code> is not NULL, or </li> |
| 177 | <li> <code>level</code> is not zero. </li> |
| 178 | </ul> |
| 179 | </li> |
| 180 | <li> |
| 181 | <code>texSubImage2D</code> is called with <code>format</code> of |
| 182 | <code>DEPTH_COMPONENT</code> or <code>DEPTH_STENCIL</code>. |
| 183 | </li> |
| 184 | <li> |
| 185 | <code>copyTexImage2D</code> is called with an |
| 186 | <code>internalformat</code> that has a base internal format of |
| 187 | <code>DEPTH_COMPONENT</code> or <code>DEPTH_STENCIL</code>. |
| 188 | </li> |
| 189 | <li> |
| 190 | <code>copyTexSubImage2D</code> is called with a target texture |
| 191 | that has a base internal format of <code>DEPTH_COMPONENT</code> |
| 192 | or <code>DEPTH_STENCIL</code>. |
| 193 | </li> |
| 194 | <li> |
| 195 | <code>generateMipmap</code> is called on a texture that has a |
| 196 | base internal format of <code>DEPTH_COMPONENT</code> or |
| 197 | <code>DEPTH_STENCIL</code>. |
| 198 | </li> |
| 199 | </ul> |
| 200 | </error> |
| 201 | </errors> |
| 202 | <issues> |
| 203 | <p> |
| 204 | As per the ANGLE_depth_texture specification, when a depth |
| 205 | texture is sampled, the value is stored into the RED channel. |
| 206 | The contents of the GREEN, BLUE and ALPHA channels are |
| 207 | implementation dependent. It is therefore recommended to use |
| 208 | only the <code>r</code> component of variables in GLSL shaders |
| 209 | that are used to reference depth textures. |
| 210 | </p> |
| 211 | </issues> |
| 212 | <history> |
| 213 | <revision date="2012/01/23"> |
| 214 | <change>Initial revision.</change> |
| 215 | </revision> |
| 216 | <revision date="2012/01/25"> |
| 217 | <change>Added provisions to exclude cube depth textures.</change> |
| 218 | </revision> |
| 219 | <revision date="2012/02/06"> |
| 220 | <change>Changed referenced WebGL API version from 2.0 to 1.0</change> |
| 221 | </revision> |
| 222 | <revision date="2012/02/24"> |
| 223 | <change>Removed the enumerants from the IDL which are contained in the context and added aliases to the extension name</change> |
| 224 | </revision> |
| 225 | <revision date="2012/03/01"> |
| 226 | <change> |
| 227 | Renamed with OES prefix and removed the addendum due to expected harmonization between OES_depth_texture and ARB_depth_texture |
| 228 | (depth cube maps). |
| 229 | </change> |
| 230 | </revision> |
| 231 | <revision date="2012/06/04"> |
| 232 | <change> |
| 233 | Renamed to WEBGL prefix, and changed to reference ANGLE_depth_texture, because of |
| 234 | limitations preventing the current ANGLE library from loading of image data to depth |
| 235 | textures. Incorporated errors from ANGLE_depth_texure extension specification. |
| 236 | </change> |
| 237 | </revision> |
| 238 | <revision date="2012/06/20"> |
| 239 | <change> |
| 240 | Incorporated depth/stencil support and UNSIGNED_INT_24_8_WEBGL enum after discussion on |
| 241 | public_webgl mailing list, including supported behavior and additional error behavior. |
| 242 | Extended rules in Section 6.5 ("Framebuffer Object Attachments") to handle texture |
| 243 | attachments. |
| 244 | </change> |
| 245 | </revision> |
| 246 | <revision date="2012/06/27"> |
| 247 | <change> |
| 248 | Updated references to texSubImage2D. Added |
| 249 | DEPTH_STENCIL_ATTACHMENT to framebufferTexture2D. |
| 250 | </change> |
| 251 | </revision> |
| 252 | <revision date="2013/01/26"> |
| 253 | <change>Moved from draft to community approved status</change> |
| 254 | </revision> |
| 255 | <revision date="2013/02/28"> |
| 256 | <change>Updated to track ANGLE_depth_texture, indicating that only red channel is guaranteed.</change> |
| 257 | </revision> |
| 258 | <revision date="2013/05/15"> |
| 259 | <change>Ratified by Khronos Board of Promoters.</change> |
| 260 | </revision> |
| 261 | <revision date="2014/07/15"> |
| 262 | <change>Added NoInterfaceObject extended attribute.</change> |
| 263 | </revision> |
| 264 | </history> |
| 265 | </ratified> |