1Name 2 3 NV_register_combiners2 4 5Name Strings 6 7 GL_NV_register_combiners2 8 9Contact 10 11 Mark J. Kilgard, NVIDIA Corporation (mjk 'at' nvidia.com) 12 13Contributors 14 15 Thomas Roell 16 17Notice 18 19 Copyright NVIDIA Corporation, 2000, 2001, 2004. 20 21IP Status 22 23 NVIDIA Proprietary. 24 25Status 26 27 Implemented. 28 29Version 30 31 NVIDIA Date: December 13, 2004 32 Version 1.2 33 34Number 35 36 227 37 38Dependencies 39 40 Written based on the wording of the OpenGL 1.2.1 specification. 41 42 Assumes support for the NV_register_combiners extension (version 1.4). 43 44Overview 45 46 The NV_register_combiners extension provides a powerful fragment 47 coloring mechanism. This specification extends the register combiners 48 functionality to support more color constant values that are unique 49 for each general combiner stage. 50 51 The base register combiners functionality supports only two color 52 constants. These two constants are available in every general 53 combiner stage and in the final combiner. 54 55 When many general combiner stages are supported, more than two 56 unique color constants is often required. The obvious way to extend 57 the register combiners is to add several more color constant 58 registers. But adding new unique color constant registers is 59 expensive for hardware implementation because every color constant 60 register must be available as an input to any stage. 61 62 In practice however, it is the total set of general combiner stages 63 that requires more color constants, not each and every individual 64 general combiner stage. Each individual general combiner stage 65 typically requires only one or two color constants. 66 67 By keeping two color constant registers but making these two registers 68 contain two unique color constant values for each general combiner 69 stage, the hardware expense of supporting multiple color constants 70 is minimized. Additionally, this scheme scales appropriately as 71 more general combiner stages are added. 72 73Issues 74 75 How do is compatibility maintained with the original register 76 combiners? 77 78 RESOLUTION: Initially, per general combiner stage constants are 79 disabled and the register combiners operate as described in the 80 original NV_register_combiners specification. A distinct "per 81 stage constants" enable exposes this extension's new functionality. 82 83 Where do the final combiner color constant values come from? 84 85 RESOLUTION: When "per stage constants" is enabled, the final 86 combiner color constants continue to use the constant colors set 87 with glCombinerParameterfvNV. 88 89 Is the alpha component of the SECONDARY_COLOR_NV register now 90 initialized with the expected interpolated secondary color's alpha 91 component. 92 93 RESOLUTION: Yes, see Revision History for details. 94 95New Procedures and Functions 96 97 void CombinerStageParameterfvNV(GLenum stage, 98 GLenum pname, 99 const GLfloat *params); 100 101 void GetCombinerStageParameterfvNV(GLenum stage, 102 GLenum pname, 103 GLfloat *params); 104 105New Tokens 106 107 Accepted by the <cap> parameter of Disable, Enable, and IsEnabled, 108 and by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, 109 and GetDoublev: 110 111 PER_STAGE_CONSTANTS_NV 0x8535 112 113 Accepted by the <pname> parameter of CombinerStageParameterfvNV 114 and GetCombinerStageParameterfvNV: 115 116 CONSTANT_COLOR0_NV (see NV_register_combiners) 117 CONSTANT_COLOR1_NV (see NV_register_combiners) 118 119 Accepted by the <stage> parameter of CombinerStageParameterfvNV and 120 GetCombinerStageParameterfvNV: 121 122 COMBINER0_NV (see NV_register_combiners) 123 COMBINER1_NV (see NV_register_combiners) 124 COMBINER2_NV (see NV_register_combiners) 125 COMBINER3_NV (see NV_register_combiners) 126 COMBINER4_NV (see NV_register_combiners) 127 COMBINER5_NV (see NV_register_combiners) 128 COMBINER6_NV (see NV_register_combiners) 129 COMBINER7_NV (see NV_register_combiners) 130 131Additions to Chapter 2 of the 1.2 Specification (OpenGL Operation) 132 133 None 134 135Additions to Chapter 3 of the 1.2 Specification (Rasterization) 136 137 -- Section 3.8.12 "Register Combiners Application" 138 139 Because the alpha component of the SECONDARY_COLOR_NV register is 140 well-defined now (see Revision History) to be the alpha value of csec, 141 STRIKE this sentence: 142 143 "The initial value of the alpha portion of register SECONDARY_COLOR_NV 144 is undefined." 145 146 Add a paragraph immediately before section 3.8.12.1: 147 148 "The ccc0 and ccc1 values map to particular constant color values. 149 The ccc0 and ccc1 mappings depend on whether per-stage constants 150 are enabled or not. Per-stage constants are enabled and disabled 151 with the Enable and Disable commands using the symbolic constant 152 PER_STAGE_CONSTANTS_NV. 153 154 When per-stage constants are disabled, ccc0 and ccc1 are mapped to 155 the register combiners' global color constant values, gccc0 and 156 gccc1. 157 158 When per-stage constants are enabled, ccc0 and ccc1 depend 159 on the combiner stage that inputs the COLOR_CONSTANT0_NV and 160 COLOR_CONSTANT1_NV registers. Each general combiner stage # maps 161 ccc0 and ccc1 to the per-stage values s#ccc0 and s#ccc1 respectively. 162 The final combiner maps ccc0 and ccc1 to the values gccc0 and gccc1 163 (the same as if per-stage constants are disabled). 164 165 gccc0, gccc1, s#ccc0, and s#ccc1 are further described in the 166 following section." 167 168 -- Section 3.8.12.1 "Combiner Parameters" 169 170 Change Table NV_register_combiners.3 to read "gccc0" instead of 171 "ccc0" and "gccc1" instead of "ccc1". 172 173 Change the first sentence of the last paragraph to read: 174 175 "The values gccc0 and gccc1 named by CONSTANT_COLOR0_NV and 176 CONSTANT_COLOR1_NV are global constant colors available for inputs to 177 the final combiner stage and, when per-stage constants is disabled, 178 to the general combiner stages." 179 180 Add the following after the last paragraph in the section: 181 182 "Per-stage combiner parameters are specified by 183 184 void CombinerStageParameterfvNV(GLenum stage, 185 GLenum pname, 186 const GLfloat *params); 187 188 The <stage> parameter is a symbolic constant of the form 189 COMBINER<#>_NV, indicating the general combiner stage <#> whose 190 parameter named by <pname> is to be updated. <pname> must be either 191 CONSTANT_COLOR0_NV or CONSTANT_COLOR1_NV. <params> is a pointer 192 to a group of four values to which to set the indicated parameter. 193 The parameter names CONSTANT_COLOR0_NV and CONSTANT_COLOR1_NV 194 update the per-stage color constants s#ccc0 and s#ccc1 respectively 195 where # is the number of the specified general combiner stage. 196 The floating-point color values are clamped to the range [0,1] 197 when specified." 198 199Additions to Chapter 4 of the 1.2 Specification (Per-Fragment Operations 200and the Frame Buffer) 201 202 None 203 204Additions to Chapter 5 of the 1.2 Specification (Special Functions) 205 206 None 207 208Additions to Chapter 6 of the 1.2 Specification (State and State Requests) 209 210 -- Section 6.1.3 "Enumerated Queries" 211 212 Add to the bottom of the list of function prototypes (page 183): 213 214 void GetCombinerStageParameterfvNV(GLenum stage, 215 GLenum pname, 216 GLfloat *params); 217 218 Change the first sentence describing the register combiner queries 219 to mention GetCombinerStageParameterfvNV so the sentence reads: 220 221 "The GetCombinerInputParameterfvNV, GetCombinerInputParameterivNV, 222 GetCombinerOutputParameterfvNV, GetCombinerOutputParameterivNV, 223 and GetCombinerStageParameterfvNV parameter <stage> may be one of 224 COMBINER0_NV, COMBINER1_NV, and so on, indicating which general 225 combiner stage to query." 226 227Additions to the GLX Specification 228 229 None 230 231GLX Protocol 232 233 Two new GL commands are added. 234 235 The following rendering command is sent to the sever as part of a 236 glXRender request: 237 238 CombinerStageParameterfvNV 239 2 12+4*n rendering command length 240 2 4280 rendering command opcode 241 4 ENUM stage 242 4 ENUM pname 243 0x852A n=4 GL_CONSANT_COLOR0_NV 244 0x852B n=4 GL_CONSANT_COLOR1_NV 245 else n=0 246 4*n LISTofFLOAT32 params 247 248 The remaining command is a non-rendering command. This commands 249 is sent separately (i.e., not as part of a glXRender or glXRenderLarge 250 request), using the glXVendorPrivateWithReply request: 251 252 GetCombinerStageParameterfvNV 253 1 CARD8 opcode (X assigned) 254 1 17 GLX opcode (glXVendorPrivateWithReply) 255 2 5 request length 256 4 1327 vendor specific opcode 257 4 GLX_CONTEXT_TAG context tag 258 4 ENUM stage 259 4 ENUM pname 260 => 261 1 1 reply 262 1 unused 263 2 CARD16 sequence number 264 4 m reply length, m = (n==1 ? 0 : n) 265 4 unused 266 4 CARD32 unused 267 268 if (n=1) this follows: 269 270 4 FLOAT32 params 271 12 unused 272 273 otherwise this follows: 274 275 16 unused 276 n*4 LISTofFLOAT32 params 277 278Errors 279 280 None 281 282New State 283 284Get Value Type Get Command Initial Value Description Sec Attribute 285---------------------- ---- ----------------------------- ------------- ------------------ -------- -------------- 286PER_STAGE_CONSTANTS_NV B IsEnabled False enable for 3.8.12 texture/enable 287CONSTANT_COLOR0_NV Cx# GetCombinerStageParameterfvNV 0,0,0,0 per-stage constant 3.8.12.1 texture 288 color zero 289CONSTANT_COLOR1_NV Cx# GetCombinerStageParameterfvNV 0,0,0,0 per-stage constant 3.8.12.1 texture 290 color one 291 292[ where # is the value of MAX_GENERAL_COMBINERS_NV ] 293 294New Implementation State 295 296 None 297 298Revision History 299 300 December 13, 2004: Assigned GLX protocl opcodes and fixed protocol 301 with help from Thomas Roell. 302 303 Version 1.2 (February 11, 2004) - When describing the 304 per-fragment register initialization within the combiners, the 305 NV_register_combiners specification says "The initial value of the 306 alpha portion of register SECONDARY_COLOR_NV is undefined." While 307 this is true of NV1x GPUs, NV2x and beyond GPUs can properly 308 initialize the alpha component of the SECONDARY_COLOR_NV 309 register with the expected interpolated secondary color alpha. 310 Unfortunately, due to a driver bug, the alpha components was always 311 initialized to 1.0 in driver versions 56.90 (circa February 2004) 312 and before. Drivers subsequent to 56.90 have this problem fixed. 313 This specification is updated to indicate that SECONDARY_COLOR_NV 314 initialization is well-defined and what you would expect now. 315 316 Version 1.1 (April 28, 2003) - The original specification failed 317 to specify what should happen if a color component parameter for 318 CombinerStageParameter*NV is outside the [0,1] range. Such values 319 should be clamped to the [0,1] range. 320 321 NVIDIA drivers prior to May 2003 incorrectly failed to clamp color 322 component values specified with CombinerStageParameter*NV to [0,1]. 323 Instead, approximately "x-floor(x)" where x is a component value 324 is used for rendering. 325