1Name 2 3 NV_packed_float 4 NV_packed_float_linear 5 6Name Strings 7 8 GL_NV_packed_float 9 GL_NV_packed_float_linear 10 11Contributors 12 13 Mark J. Kilgard, NVIDIA 14 Mathias Heyer, NVIDIA 15 Koji Ashida, NVIDIA 16 Greg Roth, NVIDIA 17 18Contact 19 20 Mathias Heyer, NVIDIA (mheyer 'at' nvidia.com) 21 22Status 23 24 Complete 25 26Version 27 28 Last Modified: 2012/09/26 29 NVIDIA Revision: 3 30 31Number 32 33 OpenGL ES Extension #127 34 35 36Dependencies 37 38 Written against the OpenGL ES 2.0.25 (Nov. 2010) Specification. 39 40 EXT_color_buffer_half_float affects the definition of this 41 specification. 42 43 OES_texture_half_float affects the defintion of this specification. 44 45 NV_framebuffer_multisample affects the defintion of this 46 specification. 47 48 NV_texture_array affects the defintion of this specification. 49 50 EXT_texture_storage affects the defintion of this specification. 51 52 53Overview 54 55 This extension adds a new 3-component floating-point texture format 56 that fits within a single 32-bit word. This format stores 5 bits 57 of biased exponent per component in the same manner as 16-bit 58 floating-point formats, but rather than 10 mantissa bits, the red, 59 green, and blue components have 6, 6, and 5 bits respectively. 60 Each mantissa is assumed to have an implied leading one except in the 61 denorm exponent case. There is no sign bit so only non-negative 62 values can be represented. Positive infinity, positive denorms, 63 and positive NaN values are representable. The value of the fourth 64 component returned by a texture fetch is always 1.0. 65 66 This extension also provides support for rendering into an unsigned 67 floating-point rendering format with the assumption that the texture 68 format described above could also be advertised as an unsigned 69 floating-point format for rendering. 70 71 The extension also provides a pixel external format for specifying 72 packed float values directly. 73 74 75New Tokens 76 77 Accepted by the <internalformat> parameter of RenderbufferStorage 78 and RenderBufferStorageMultisampleNV, TexStorage2DEXT and 79 TexStorage3DEXT: 80 81 R11F_G11F_B10F_NV 0x8C3A 82 83 Accepted by the <type> parameter of ReadPixels, TexImage2D, 84 TexSubImage2D, TexImage3DNV, TexSubImage3DNV: 85 86 UNSIGNED_INT_10F_11F_11F_REV_NV 0x8C3B 87 88 89Changes to Chapter 2 of the OpenGL ES 2.0.25 Specification 90(OpenGL Operation) 91 92 Add two new sections after Section "Floating-Point Computation": 93 94 "Unsigned 11-Bit Floating-Point Numbers" 95 96 An unsigned 11-bit floating-point number has no sign bit, a 5-bit 97 exponent (E), and a 6-bit mantissa (M). The value of an unsigned 98 11-bit floating-point number (represented as an 11-bit unsigned 99 integer N) is determined by the following: 100 101 0.0, if E == 0 and M == 0, 102 2^-14 * (M / 64), if E == 0 and M != 0, 103 2^(E-15) * (1 + M/64), if 0 < E < 31, 104 INF, if E == 31 and M == 0, or 105 NaN, if E == 31 and M != 0, 106 107 where 108 109 E = floor(N / 64), and 110 M = N mod 64. 111 112 Implementations are also allowed to use any of the following 113 alternative encodings: 114 115 0.0, if E == 0 and M != 0 116 2^(E-15) * (1 + M/64) if E == 31 and M == 0 117 2^(E-15) * (1 + M/64) if E == 31 and M != 0 118 119 When a floating-point value is converted to an unsigned 11-bit 120 floating-point representation, finite values are rounded to the 121 closet representable finite value. While less accurate, 122 implementations are allowed to always round in the direction of 123 zero. This means negative values are converted to zero. 124 Likewise, finite positive values greater than 65024 (the maximum 125 finite representable unsigned 11-bit floating-point value) are 126 converted to 65024. Additionally: negative infinity is converted 127 to zero; positive infinity is converted to positive infinity; and 128 both positive and negative NaN are converted to positive NaN. 129 130 Any representable unsigned 11-bit floating-point value is legal 131 as input to a GL command that accepts 11-bit floating-point data. 132 The result of providing a value that is not a floating-point 133 number (such as infinity or NaN) to such a command is unspecified, 134 but must not lead to GL interruption or termination. Providing a 135 denormalized number or negative zero to GL must yield predictable 136 results. 137 138 "Unsigned 10-Bit Floating-Point Numbers" 139 140 An unsigned 10-bit floating-point number has no sign bit, a 5-bit 141 exponent (E), and a 5-bit mantissa (M). The value of an unsigned 142 10-bit floating-point number (represented as an 10-bit unsigned 143 integer N) is determined by the following: 144 145 0.0, if E == 0 and M == 0, 146 2^-14 * (M / 32), if E == 0 and M != 0, 147 2^(E-15) * (1 + M/32), if 0 < E < 31, 148 INF, if E == 31 and M == 0, or 149 NaN, if E == 31 and M != 0, 150 151 where 152 153 E = floor(N / 32), and 154 M = N mod 32. 155 156 When a floating-point value is converted to an unsigned 10-bit 157 floating-point representation, finite values are rounded to the 158 closet representable finite value. While less accurate, 159 implementations are allowed to always round in the direction of 160 zero. This means negative values are converted to zero. 161 Likewise, finite positive values greater than 64512 (the maximum 162 finite representable unsigned 10-bit floating-point value) are 163 converted to 64512. Additionally: negative infinity is converted 164 to zero; positive infinity is converted to positive infinity; and 165 both positive and negative NaN are converted to positive NaN. 166 167 Any representable unsigned 10-bit floating-point value is legal 168 as input to a GL command that accepts 10-bit floating-point data. 169 The result of providing a value that is not a floating-point 170 number (such as infinity or NaN) to such a command is 171 unspecified, but must not lead to GL interruption or termination. 172 Providing a denormalized number or negative zero to GL must yield 173 predictable results. 174 175 176Changes to Chapter 3 of the OpenGL ES 2.0.25 Specification (Rasterization) 177 178 Add to Table 3.2, p. 62: 179 180 type Parameter Corresponding Special 181 Token Name GL Data Type Interpretation 182 ------------------------------- ------------- -------------- 183 UNSIGNED_INT_10F_11F_11F_REV_NV uint Yes 184 185 Add to Table 3.4, p. 63: 186 187 Format Type Bytes per Pixel 188 --------- ------------------------------- --------------- 189 RGB UNSIGNED_INT_10F_11F_11F_REV_NV 4 190 191 Add to Table 3.5, p. 64: 192 193 type Parameter GL Data Number of Matching 194 Token Name Type Components Pixel Formats 195 ------------------------------- ------- ---------- -------------- 196 UNSIGNED_INT_10F_11F_11F_REV_NV uint 3 RGB 197 198 199 Add the following to section 3.6.2 Transfor of Pixel Rectangles, 200 subsection Unpacking 201 202 203 UNSIGNED_INT_10F_11F_11F_REV_NV: 204 205 31 30 ... 23 22 21 20 ... 12 11 10 9 ... 1 0 206 +---------------+---------------+---------------+ 207 | 3rd | 2nd | 1st | 208 +---------------+---------------+---------------+ 209 210 211Changes to Chapter 4 of the OpenGL ES 2.0.25 Specification 212(Per-Fragment Operations and the Framebuffer) 213 214 Add the following to the end of Section 4.3, subsection 215 "Final Color Conversion" 216 217 If an implementation allows calling ReadPixels with a <type> of 218 UNSIGNED_INT_10F_11F_11F_REV_NV and format of RGB, the conversion 219 is done as follows: The returned data are packed into a series of 220 GL uint values. The red, green, and blue components are converted 221 to unsigned 11-bit floating-point, unsigned 11-bit floating-point, 222 and unsigned 10-bit floating point as described in section 223 2.1.A and 2.1.B. The resulting red 11 bits, green 11 bits, and blue 224 10 bits are then packed as the 1st, 2nd, and 3rd components of the 225 UNSIGNED_INT_10F_11F_11F_REV_NV format as shown in Section 3.6. 226 227 228 Add to Table 4.4, p. 106: 229 230 type Parameter Component 231 Token Name GL Data Type Conversion Formula 232 -------------- ------------- ------------------ 233 UNSIGNED_INT_10F_11F_11F_REV_NV uint c = f 234 235 (modify "Final Conversion", p. 106): 236 If type is not FLOAT, HALF_FLOAT_OES or UNSIGNED_INT_10F_11F_11F_REV_NV, 237 each component is first clamped to [0,1]. Then the appropriate conversion... 238 239 Add to Table 4.5, p. 117: 240 241 Sized Renderable R G B A D S 242 Internal Format Type bits bits bits bits bits bits 243 --------------- ---------------- ---- ---- ---- ---- ---- ---- 244 R11F_G11F_B10F_NV color-renderable f11 f11 f10 245 246 247Errors 248 249 Relaxation of INVALID_ENUM errors 250 --------------------------------- 251 252 RenderbufferStorage and RenderBufferStorageMultisampleNV accept 253 the new R11F_G11F_B10F_EXT token for <internalformat>. 254 255 ReadPixels, TexImage2D, TexSubImage2D, TexImage3DNV and 256 TexSubImage3DNV accept the new UNSIGNED_INT_10F_11F_11F_REV_EXT 257 token for <type>. 258 259 260 New errors 261 ---------- 262 263 INVALID_OPERATION is generated by ReadPixels, TexImage2D, 264 TexSubImage2D, TexImage3DNV and TexSubImage3DNV if <type> is 265 UNSIGNED_INT_10F_11F_11F_REV_EXT and <format> is not RGB. 266 267 268Dependencies on OES_texture_half_float 269 270 If OES_texture_half_float is not supported, modify fifth paragraph 271 of 3.7.1 Texture Image Specification, p. 67: 272 273 "The selected groups are processed as described in section 3.6.2, stopping 274 after final expansion to RGBA. If the internal format of the texture is 275 fixed-point, components are clamped to [0,1]. Otherwise, values are not 276 modified." 277 278 Modify first sentence of "Unpacking", p. 62: 279 280 "Data are taken from client memory as a sequence of one of the GL data 281 types listed in Table 3.2. These elements are..." 282 283 Additionally, ignore all references to RGBA16F_EXT, RGB16F_EXT, 284 RG16F_EXT, R16F_EXT, HALF_FLOAT_OES and half. 285 286Dependencies on EXT_color_buffer_half_float 287 288 If EXT_color_buffer_half_float is not supported, do not consider 289 R11F_G11F_B10F_NV color-renderable. Remove all changes and additions 290 to Chapter 4 of the OpenGL ES 2.0 Specification. 291 292Dependencies on NV_packed_float_linear 293 294 If NV_packed_float_linear is not supported, using LINEAR 295 magnification filter and LINEAR, NEAREST_MIPMAP_LINEAR, 296 LINEAR_MIPMAP_NEAREST and LINEAR_MIPMAP_NEAREST minification 297 filters will cause packed float textures to be considered 298 incomplete. 299 300Dependencies on NV_framebuffer_multisample 301 302 If NV_framebuffer_multisample is missing, remove all refernences to 303 RenderBufferStorageMultisampleNV. 304 305Dependencies on NV_texture_array 306 307 If NV_texture_array is not supported, remove all references to 308 TexImage3DNV and TexSubImage3DNV. 309 310Dependencies on EXT_texture_storage 311 312 If EXT_texture_storage is not supported, remove all references to 313 TexStorage2DEXT and TexStorage3DEXT. 314 315Issues 316 317 1) Are the new formats allowed in window surface and pbuffer managed 318 by EGL? 319 320 No. Let's focus on framebuffer objects. 321 322 See EXT_packed_float for other relevant issues. 323 324Revision History 325 326#3 - 05.11.2012 (Mathias Heyer) 327 - Remove FRAMEBUFFER_ATTACHMENT_RGBA_SIGNED_COMPONENTS_NV, as its 328 neither in desktop GL nor ES3 329 330#2 - 26.09.2012 (Mathias Heyer) 331 - Make FRAMEBUFFER_ATTACHMENT_RGBA_SIGNED_COMPONENTS_NV a property of 332 framebuffer attachments, adjust the table entries for ES2.0 333 - add interactions with various other ES2.0 extensions 334 335#1 - 03.10.2008 336 337 First draft written based on EXT_packed_float. 338