1Name 2 3 EXT_texture_snorm 4 5Name Strings 6 7 GL_EXT_texture_snorm 8 9Contributors 10 11 Bill Licea-Kane, AMD 12 Jon Leech, Khronos 13 Mais Alnasser, AMD 14 Nick Haemel, AMD 15 16Contact 17 18 Bill Licea-Kane, (bill.licea-kane 'at' amd.com) 19 20Status 21 22 Draft for OpenGL 3.1 23 24Version 25 26 Last Modified Date: 2009-07-10 27 Revision: 5 28 29Number 30 31 365 32 33Dependencies 34 35 OpenGL 3.0 is required. 36 37 This extension is written against the OpenGL 3.0 specification. 38 39Overview 40 41 Fixed-point textures in unextended OpenGL have integer components, 42 but those values are taken to represent floating-point values in 43 the range [0.0,1.0]. These integer components are considered 44 "unsigned normalized" integers. When such a texture is accessed by 45 a shader or by fixed-function fragment processing, floating-point 46 values are returned in the range [0.0,1.0]. 47 48 This extension provides a set of new "signed normalized" integer 49 texture formats. These are taken to represent a floating-point 50 value in the range [-1.0,1.0] with an exact 0.0. 51 52New Procedures and Functions 53 54 None 55 56New Tokens 57 58 59 Accepted by the <internalFormat> parameter of TexImage1D, 60 TexImage2D, and TexImage3D: 61 62 base internal formats 63 RED_SNORM 0x8F90 64 RG_SNORM 0x8F91 65 RGB_SNORM 0x8F92 66 RGBA_SNORM 0x8F93 67 ALPHA_SNORM 0x9010 68 LUMINANCE_SNORM 0x9011 69 LUMINANCE_ALPHA_SNORM 0x9012 70 INTENSITY_SNORM 0x9013 71 72 73 sized internal formats 74 R8_SNORM 0x8F94 75 RG8_SNORM 0x8F95 76 RGB8_SNORM 0x8F96 77 RGBA8_SNORM 0x8F97 78 ALPHA8_SNORM 0x9014 79 LUMINANCE8_SNORM 0x9015 80 LUMINANCE8_ALPHA8_SNORM 0x9016 81 INTENSITY8_SNORM 0x9017 82 83 R16_SNORM 0x8F98 84 RG16_SNORM 0x8F99 85 RGB16_SNORM 0x8F9A 86 RGBA16_SNORM 0x8F9B 87 ALPHA16_SNORM 0x9018 88 LUMINANCE16_SNORM 0x9019 89 LUMINANCE16_ALPHA16_SNORM 0x901A 90 INTENSITY16_SNORM 0x901B 91 92 Returned by GetTexLevelParmeter 93 94 SIGNED_NORMALIZED 0x8F9C 95 96Additions to Chapter 2 of the OpenGL 3.0 Specification (OpenGL Operation) 97 98 Modify Section 2.19 Colors and Coloring, p. 74 99 100 Replace Table 2.10: Component Conversions: 101 102 GL Type of <c> Conversion to internal floating-point 103 unsigned normalized, signed normalized 104 -------------- ------------------------------------- 105 ubyte <c>/(2^8-1), <c>/(2^7-1) 106 byte (2<c>+1)/(2^8-1), max ( <c>/(2^7-1), -1.0 ) 107 ushort <c>/(2^16-1), <c>/(2^15-1) 108 short (2<c>+1)/(2^16-1), max ( <c>/(2^15-1), -1.0 ) 109 uint <c>/(2^32-1), <c>/(2^31-1) 110 int (2<c>+1)/(2^32-1), max ( <c>/(2^31-1), -1.0 ) 111 half <c> 112 float <c> 113 double <c> 114 115 116Additions to Chapter 3 of the OpenGL 2.0 Specification (Rasterization) 117 118 Modify Section 3.9 (Texturing), p. 175 119 120 Modify second paragraph: 121 122 The internal data type of a texture may be signed normalized 123 fixed-point, unsigned normalized fixed-point, floating-point, 124 signed integer or unsigned integer, depending on the internal 125 format of the texture. The correspondence between internal format 126 and the internal data type is given in tables 3.16-3.18. 127 Fixed-point and floating-point textures return a floating-point 128 value and integer textures return signed or unsigned integer 129 values. When a fragment shader is active, the shader is responsible 130 for interpreting the result of a texture lookup as the correct data 131 type, otherwise the result is undefined. When not using a fragment 132 shader, unsigned floating-point texture values are assumed, and the 133 results of using either signed normalized fixed-point or integer 134 textures in this case are undefined. 135 136 Modify Section 3.9.1 (Texture Image Specification), p. 176 137 138 (modify last paragraph beginning p. 176): 139 140 The selected groups are processed exactly as for DrawPixels, 141 stopping just before final conversion. If the <internalformat> of 142 the texture is integer, the components are clamped to the 143 representable range of the internal format: for signed formats, 144 this is [-2^(n-1), 2^(n-1)-1] where n is the number of bits per 145 component; for unsigned formats, the range is [0, 2^n-1]. For R, G, 146 B, and A, if the <internalformat> of the texture is fixed-point, 147 the components are clamped to the representable range of the 148 internal format: for signed normalized formats, this is [-1.0, 149 1.0]; for unsigned normalized formats, this is [0.0, 1.0]. 150 Otherwise, the components are not modified. 151 152 153 (add the following required Color formats (texture-only), p. 179) 154 155 - R16_SNORM, RG16_SNORM, RGB16_SNORM, RGBA16_SNORM, 156 R8_SNORM, RG8_SNORM, RGB8_SNORM, RGBA8_SNORM 157 158 (add the following to table 3.16, beginning p. 181) 159 160 Sized Base R G B A L I 161 Internal Format Internal Format bits bits bits bits bits bits 162 ----------------------- --------------------- ---- ---- ---- ---- ---- ---- 163 R8_SNORM R_SNORM 8 164 RG8_SNORM RG_SNORM 8 8 165 RGB8_SNORM RGB_SNORM 8 8 8 166 RGBA8_SNORM RGBA_SNORM 8 8 8 8 167 ALPHA8_SNORM ALPHA8_SNORM 8 168 LUMINANCE8_SNORM LUMINANCE8_SNORM 8 169 LUMINANCE8_ALPHA8_SNORM LUMINANCE8_ALPHA8_SNORM 8 8 170 INTENSITY8_SNORM INTENSITY8_SNORM 8 171 172 R16_SNORM R_SNORM 16 173 RG16_SNORM RG_SNORM 16 16 174 RGB16_SNORM RGB_SNORm 16 16 16 175 RGBA16_SNORM RGBA_SNORM 16 16 16 16 176 ALPHA8_SNORM ALPHA8_SNORM 16 177 LUMINANCE16_SNORM LUMINANCE16_SNORM 16 178 LUMINANCE16_ALPHA16_SNORM LUMINANCE16_ALPHA16_SNORM 16 16 179 INTENSITY16_SNORM INTENSITY16_SNORM 16 180 181 Table 3.16: Correspondence of sized internal formats to base 182 internal formats, internal data type and desired component 183 resolutions for each sized internal format. The component 184 resolution prefix indicates the internal data type: <f> is floating 185 point, <i> is signed integer, <ui> is unsigned integer, and no 186 prefix is signed or unsigned normalized fixed-point. 187 188 Modify Section 3.12.2 Shader Execution 189 190 (modify Shader Outputs paragraph, p. 234) 191 192 XXXXX - Is this section broken? 193 194 The OpenGL Shading Language specification describes the values that 195 may be output by a fragment shader. These outputs are split into 196 two categories, user-defined varying out variables and built-in 197 variables. The built-in variables are gl_FragColor, gl_FragData[n], 198 and gl_FragDepth. If fragment color clamping is enabled and the 199 color buffer has a unsigned normalized fixed-point format, signed 200 normalized fixed-point format, or floating-point format, the final 201 fragment color, fragment data, or varying out variable values 202 written by a fragment shader are clamped to the range [0, 1] and 203 are optionally converted to normalized fixed-point as described in 204 section 2.19.9. 205 206 207Additions to Chapter 4 of the OpenGL 2.0 Specification (Per-Fragment 208Operations and the Frame Buffer) 209 210 Modify Chapter 4 Introduction, (p. 239) 211 212 (modify second paragraph, p. 239) 213 214 Each pixel in a color buffer consists of either a single unsigned 215 integer color index or up to four color components. The four color 216 components are named R, G, B, and A, in that order; color buffers 217 are not required to have all four color components. R, G, B, and A 218 components may be represented as unsigned normalized fixed-point, 219 signed normalized fixed-point, floating-point, signed integer, or 220 unsigned integer values; all components must have the same 221 representation.... 222 223 224 XXXX - Clear section needs changing? 225 226Additions to Chapter 6 of the OpenGL 2.0 Specification (State and 227State Requests) 228 229 Modify Section 6.1.3 (Enumerated Queries), p. 318 230 231 (Modify beginning paragraph starting on p. 318) 232 233 For texture images with uncompressed internal formats, queries of 234 value of TEXTURE_RED_TYPE, TEXTURE_GREEN_TYPE, TEXTURE_BLUE_TYPE, 235 TEXTURE_ALPHA_TYPE, TEXTURE_LUMINANCE_TYPE, TEXTURE_DEPTH_TYPE, 236 and TEXTURE_INTENSITY_TYPE return the data type used to store the 237 component. Types NONE, UNSIGNED_NORMALIZED, SIGNED_NORMALIZED, 238 FLOAT, INT,and UNSIGNED_INT respectively indicate missing, 239 unsigned normalized integer, signed normalized integer, 240 floating-point, signed unnormalized integer, and unsigned 241 unnormalized integer components.... 242 243GLX Protocol 244 245 TBD 246 247Errors 248 249 250Issues 251 252 1 - Should the internalformat enums contain an underscore? 253 254 RESOLVED: Yes. _SNORM internal format modifier is nearly 255 unreadable without it. (Especially for sized formats.) 256 257 2 - What are the required signed normalized formats? 258 259 RESOLVED: We require 8 and 16 bit R, RG, RGB, RGBA texturing. 260 It follows that these are filterable. 261 262 We are silent about requiring R, RG, RBA and RGBA rendering. 263 This is an implementation choice. Note that some "OpenGL 3.0 264 target hardware" (multiple implementations) have blending 265 limitations with signed normalized color formats. We are 266 restricted to "OpenGL 3.0 target hardware" for 3.1 candidates. 267 268 3 - Shader outputs broken? 269 270 Final color processing (Chapter 2), Clamping (Several) and 271 conversion to framebuffer are intertwined at several places 272 in the spec now. Some of the statements in this section 273 appear to conflict with statements in other sections. 274 275 4 - Clear? 276 277 Do we need to be able to clear a signed normalized fixed-point 278 buffer to the full range of [-1.0,1.0]? If so, any changes 279 needed here? 280 281 5 - Should this "extension spec" be updated to accurately reflect the 282 final 3.0 -> 3.1 deltas? 283 284 Resolved - Ideally, but not now. Jon made many major structural 285 changes to the core spec in 3.0 -> 3.1. See the core 3.1 spec 286 with differences tracked for details. 287 288 289Revision History: 290 291 Date: 2009-07-10 292 Revision: 5 (Jon Leech) 293 Assign extension number, minor formatting cleanups for registry. 294 295 Date: 2009-04-29 296 Revision: 4 (gsellers) 297 Add contributors. 298 299 Date: 2009-04-22 300 Revision: 3 (wwlk) 301 Add token values, for R,RG,RGB, RGBA and for "legacy" formats 302 alpha, luminace, luminance alpha and intensity. 303 Added unsigned conversions. 304 Fixed typos in enums: 305 LUMINANCE_ALPHA8_SNORM -> LUMINANCE8_ALPHA8_SNORM 306 LUMINANCE_ALPHA16_SNORM -> LUMINANCE16_ALPHA16_SNORM 307 308 Date: 2009-03-17 309 Revision: 2 (wwlk) 310 Fixed enum inconsistencies 311 312 Date: 2008-10-30 313 Revision: 1 (wwlk) 314 Initial version 315 316 317 318