1 | /* Copyright (c) 2001, Stanford University
|
---|
2 | * All rights reserved
|
---|
3 | *
|
---|
4 | * See the file LICENSE.txt for information on redistributing this software.
|
---|
5 | */
|
---|
6 |
|
---|
7 | #include "state.h"
|
---|
8 | #include "state/cr_statetypes.h"
|
---|
9 |
|
---|
10 |
|
---|
11 | #define UNUSED(x) ((void) (x))
|
---|
12 |
|
---|
13 |
|
---|
14 | void crStateRegCombinerInit( CRContext *ctx )
|
---|
15 | {
|
---|
16 | CRRegCombinerState *reg = &ctx->regcombiner;
|
---|
17 | CRStateBits *sb = GetCurrentBits(ctx->pStateTracker);
|
---|
18 | CRRegCombinerBits *rb = &(sb->regcombiner);
|
---|
19 | #ifndef CR_NV_register_combiners
|
---|
20 | UNUSED(reg)
|
---|
21 | #else
|
---|
22 | GLcolorf zero_color = {0.0f, 0.0f, 0.0f, 0.0f};
|
---|
23 | int i;
|
---|
24 |
|
---|
25 | reg->enabledRegCombiners = GL_FALSE;
|
---|
26 | RESET(rb->enable, ctx->bitid);
|
---|
27 | reg->constantColor0 = zero_color;
|
---|
28 | RESET(rb->regCombinerColor0, ctx->bitid);
|
---|
29 | reg->constantColor1 = zero_color;
|
---|
30 | RESET(rb->regCombinerColor1, ctx->bitid);
|
---|
31 | for( i=0; i<CR_MAX_GENERAL_COMBINERS; i++ )
|
---|
32 | {
|
---|
33 | /* RGB Portion */
|
---|
34 | reg->rgb[i].a = GL_PRIMARY_COLOR_NV;
|
---|
35 | reg->rgb[i].b = GL_ZERO;
|
---|
36 | reg->rgb[i].c = GL_ZERO;
|
---|
37 | reg->rgb[i].d = GL_ZERO;
|
---|
38 | reg->rgb[i].aMapping = GL_UNSIGNED_IDENTITY_NV;
|
---|
39 | reg->rgb[i].bMapping = GL_UNSIGNED_INVERT_NV;
|
---|
40 | reg->rgb[i].cMapping = GL_UNSIGNED_IDENTITY_NV;
|
---|
41 | reg->rgb[i].dMapping = GL_UNSIGNED_IDENTITY_NV;
|
---|
42 | reg->rgb[i].aPortion = GL_RGB;
|
---|
43 | reg->rgb[i].bPortion = GL_RGB;
|
---|
44 | reg->rgb[i].cPortion = GL_RGB;
|
---|
45 | reg->rgb[i].dPortion = GL_RGB;
|
---|
46 | reg->rgb[i].scale = GL_NONE;
|
---|
47 | reg->rgb[i].bias = GL_NONE;
|
---|
48 | reg->rgb[i].abOutput = GL_DISCARD_NV;
|
---|
49 | reg->rgb[i].cdOutput = GL_DISCARD_NV;
|
---|
50 | reg->rgb[i].sumOutput = GL_SPARE0_NV;
|
---|
51 | reg->rgb[i].abDotProduct = GL_FALSE;
|
---|
52 | reg->rgb[i].cdDotProduct = GL_FALSE;
|
---|
53 | reg->rgb[i].muxSum = GL_FALSE;
|
---|
54 |
|
---|
55 | /* Alpha Portion */
|
---|
56 | reg->alpha[i].a = GL_PRIMARY_COLOR_NV;
|
---|
57 | reg->alpha[i].b = GL_ZERO;
|
---|
58 | reg->alpha[i].c = GL_ZERO;
|
---|
59 | reg->alpha[i].d = GL_ZERO;
|
---|
60 | reg->alpha[i].aMapping = GL_UNSIGNED_IDENTITY_NV;
|
---|
61 | reg->alpha[i].bMapping = GL_UNSIGNED_INVERT_NV;
|
---|
62 | reg->alpha[i].cMapping = GL_UNSIGNED_IDENTITY_NV;
|
---|
63 | reg->alpha[i].dMapping = GL_UNSIGNED_IDENTITY_NV;
|
---|
64 | reg->alpha[i].aPortion = GL_ALPHA;
|
---|
65 | reg->alpha[i].bPortion = GL_ALPHA;
|
---|
66 | reg->alpha[i].cPortion = GL_ALPHA;
|
---|
67 | reg->alpha[i].dPortion = GL_ALPHA;
|
---|
68 | reg->alpha[i].scale = GL_NONE;
|
---|
69 | reg->alpha[i].bias = GL_NONE;
|
---|
70 | reg->alpha[i].abOutput = GL_DISCARD_NV;
|
---|
71 | reg->alpha[i].cdOutput = GL_DISCARD_NV;
|
---|
72 | reg->alpha[i].sumOutput = GL_SPARE0_NV;
|
---|
73 | reg->alpha[i].abDotProduct = GL_FALSE;
|
---|
74 | reg->alpha[i].cdDotProduct = GL_FALSE;
|
---|
75 | reg->alpha[i].muxSum = GL_FALSE;
|
---|
76 | RESET(rb->regCombinerInput[i], ctx->bitid);
|
---|
77 | RESET(rb->regCombinerOutput[i], ctx->bitid);
|
---|
78 | }
|
---|
79 | RESET(rb->regCombinerVars, ctx->bitid);
|
---|
80 | reg->numGeneralCombiners = 1;
|
---|
81 | reg->colorSumClamp = GL_TRUE;
|
---|
82 | reg->a = GL_FOG;
|
---|
83 | reg->b = GL_SPARE0_PLUS_SECONDARY_COLOR_NV;
|
---|
84 | reg->c = GL_FOG;
|
---|
85 | reg->d = GL_ZERO;
|
---|
86 | reg->e = GL_ZERO;
|
---|
87 | reg->f = GL_ZERO;
|
---|
88 | reg->g = GL_SPARE0_NV;
|
---|
89 | reg->aMapping = GL_UNSIGNED_IDENTITY_NV;
|
---|
90 | reg->bMapping = GL_UNSIGNED_IDENTITY_NV;
|
---|
91 | reg->cMapping = GL_UNSIGNED_IDENTITY_NV;
|
---|
92 | reg->dMapping = GL_UNSIGNED_IDENTITY_NV;
|
---|
93 | reg->eMapping = GL_UNSIGNED_IDENTITY_NV;
|
---|
94 | reg->fMapping = GL_UNSIGNED_IDENTITY_NV;
|
---|
95 | reg->gMapping = GL_UNSIGNED_IDENTITY_NV;
|
---|
96 | reg->aPortion = GL_ALPHA;
|
---|
97 | reg->bPortion = GL_RGB;
|
---|
98 | reg->cPortion = GL_RGB;
|
---|
99 | reg->dPortion = GL_RGB;
|
---|
100 | reg->ePortion = GL_RGB;
|
---|
101 | reg->fPortion = GL_RGB;
|
---|
102 | reg->gPortion = GL_ALPHA;
|
---|
103 | RESET(rb->regCombinerFinalInput, ctx->bitid);
|
---|
104 | #ifdef CR_NV_register_combiners2
|
---|
105 | reg->enabledPerStageConstants = GL_FALSE;
|
---|
106 | for( i=0; i<CR_MAX_GENERAL_COMBINERS; i++ )
|
---|
107 | {
|
---|
108 | reg->stageConstantColor0[i] = zero_color;
|
---|
109 | reg->stageConstantColor1[i] = zero_color;
|
---|
110 | RESET(rb->regCombinerStageColor0[i], ctx->bitid);
|
---|
111 | RESET(rb->regCombinerStageColor1[i], ctx->bitid);
|
---|
112 | }
|
---|
113 | #endif /* CR_NV_register_combiners2 */
|
---|
114 | #endif /* CR_NV_register_combiners */
|
---|
115 |
|
---|
116 | RESET(rb->dirty, ctx->bitid);
|
---|
117 | }
|
---|
118 |
|
---|
119 | void STATE_APIENTRY crStateCombinerParameterfvNV(PCRStateTracker pState, GLenum pname, const GLfloat *params )
|
---|
120 | {
|
---|
121 | CRContext *g = GetCurrentContext(pState);
|
---|
122 | CRRegCombinerState *r = &(g->regcombiner);
|
---|
123 | CRStateBits *sb = GetCurrentBits(pState);
|
---|
124 | CRRegCombinerBits *rb = &(sb->regcombiner);
|
---|
125 |
|
---|
126 | switch( pname )
|
---|
127 | {
|
---|
128 | case GL_CONSTANT_COLOR0_NV:
|
---|
129 | r->constantColor0.r = params[0];
|
---|
130 | r->constantColor0.g = params[1];
|
---|
131 | r->constantColor0.b = params[2];
|
---|
132 | r->constantColor0.a = params[3];
|
---|
133 | DIRTY(rb->regCombinerColor0, g->neg_bitid);
|
---|
134 | break;
|
---|
135 | case GL_CONSTANT_COLOR1_NV:
|
---|
136 | r->constantColor1.r = params[0];
|
---|
137 | r->constantColor1.g = params[1];
|
---|
138 | r->constantColor1.b = params[2];
|
---|
139 | r->constantColor1.a = params[3];
|
---|
140 | DIRTY(rb->regCombinerColor1, g->neg_bitid);
|
---|
141 | break;
|
---|
142 | case GL_NUM_GENERAL_COMBINERS_NV:
|
---|
143 | if( *params < 1 || *params > g->limits.maxGeneralCombiners )
|
---|
144 | {
|
---|
145 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_VALUE, "CombinerParameter passed invalid NUM_GENERAL_COMBINERS param: %d", (GLint)*params );
|
---|
146 | return;
|
---|
147 | }
|
---|
148 | r->numGeneralCombiners = (GLint)*params;
|
---|
149 | DIRTY(rb->regCombinerVars, g->neg_bitid);
|
---|
150 | break;
|
---|
151 | case GL_COLOR_SUM_CLAMP_NV:
|
---|
152 | r->colorSumClamp = (GLboolean)*params;
|
---|
153 | DIRTY(rb->regCombinerVars, g->neg_bitid);
|
---|
154 | break;
|
---|
155 | default:
|
---|
156 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "CombinerParameter passed bogus pname: 0x%x", pname );
|
---|
157 | return;
|
---|
158 | }
|
---|
159 |
|
---|
160 | DIRTY(rb->dirty, g->neg_bitid);
|
---|
161 | }
|
---|
162 |
|
---|
163 | void STATE_APIENTRY crStateCombinerParameterivNV(PCRStateTracker pState, GLenum pname, const GLint *params )
|
---|
164 | {
|
---|
165 | GLfloat fparams[4];
|
---|
166 | int i;
|
---|
167 |
|
---|
168 | if( pname == GL_CONSTANT_COLOR0_NV || pname == GL_CONSTANT_COLOR1_NV )
|
---|
169 | {
|
---|
170 | for( i=0; i<4; i++ )
|
---|
171 | {
|
---|
172 | fparams[i] = (GLfloat)params[i] * (GLfloat)(1.0/255.0);
|
---|
173 | }
|
---|
174 | }
|
---|
175 | else
|
---|
176 | {
|
---|
177 | /* Only one parameter: */
|
---|
178 | *fparams = (GLfloat) *params;
|
---|
179 | }
|
---|
180 | crStateCombinerParameterfvNV(pState, pname, fparams );
|
---|
181 | }
|
---|
182 |
|
---|
183 | void STATE_APIENTRY crStateCombinerParameterfNV(PCRStateTracker pState, GLenum pname, GLfloat param )
|
---|
184 | {
|
---|
185 | GLfloat fparam[1];
|
---|
186 | *fparam = (GLfloat) param;
|
---|
187 | if( pname == GL_CONSTANT_COLOR0_NV || pname == GL_CONSTANT_COLOR1_NV )
|
---|
188 | {
|
---|
189 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "Invalid pname (CONSTANT_COLOR%d) passed to CombinerParameterfNV: 0x%x", (GLint)param-GL_CONSTANT_COLOR0_NV, pname );
|
---|
190 | return;
|
---|
191 | }
|
---|
192 | crStateCombinerParameterfvNV(pState, pname, fparam );
|
---|
193 | }
|
---|
194 |
|
---|
195 | void STATE_APIENTRY crStateCombinerParameteriNV(PCRStateTracker pState, GLenum pname, GLint param )
|
---|
196 | {
|
---|
197 | GLfloat fparam[1];
|
---|
198 | *fparam = (GLfloat) param;
|
---|
199 | if( pname == GL_CONSTANT_COLOR0_NV || pname == GL_CONSTANT_COLOR1_NV )
|
---|
200 | {
|
---|
201 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "Invalid pname (CONSTANT_COLOR%d) passed to CombinerParameteriNV: 0x%x", param-GL_CONSTANT_COLOR0_NV, pname );
|
---|
202 | return;
|
---|
203 | }
|
---|
204 | crStateCombinerParameterfvNV(pState, pname, fparam );
|
---|
205 | }
|
---|
206 |
|
---|
207 | void STATE_APIENTRY crStateCombinerInputNV(PCRStateTracker pState, GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage )
|
---|
208 | {
|
---|
209 | CRContext *g = GetCurrentContext(pState);
|
---|
210 | CRRegCombinerState *r = &(g->regcombiner);
|
---|
211 | CRStateBits *sb = GetCurrentBits(pState);
|
---|
212 | CRRegCombinerBits *rb = &(sb->regcombiner);
|
---|
213 |
|
---|
214 | if( stage < GL_COMBINER0_NV || stage >= GL_COMBINER0_NV + g->limits.maxGeneralCombiners )
|
---|
215 | {
|
---|
216 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "CombinerInputNV passed bogus stage: 0x%x", stage );
|
---|
217 | return;
|
---|
218 | }
|
---|
219 | if( input != GL_ZERO && input != GL_CONSTANT_COLOR0_NV && input != GL_CONSTANT_COLOR1_NV && input != GL_FOG && input != GL_PRIMARY_COLOR_NV && input != GL_SECONDARY_COLOR_NV && input != GL_SPARE0_NV && input != GL_SPARE1_NV && ( input < GL_TEXTURE0_ARB || input >= GL_TEXTURE0_ARB + g->limits.maxTextureUnits ))
|
---|
220 | {
|
---|
221 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "CombinerInputNV passed bogus input: 0x%x", input );
|
---|
222 | return;
|
---|
223 | }
|
---|
224 | if( mapping != GL_UNSIGNED_IDENTITY_NV && mapping != GL_UNSIGNED_INVERT_NV && mapping != GL_EXPAND_NORMAL_NV && mapping != GL_EXPAND_NEGATE_NV && mapping != GL_HALF_BIAS_NORMAL_NV && mapping != GL_HALF_BIAS_NEGATE_NV && mapping != GL_SIGNED_IDENTITY_NV && mapping != GL_SIGNED_NEGATE_NV )
|
---|
225 | {
|
---|
226 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "CombinerInputNV passed bogus mapping: 0x%x", mapping );
|
---|
227 | return;
|
---|
228 | }
|
---|
229 | if( componentUsage != GL_RGB && componentUsage != GL_ALPHA && componentUsage != GL_BLUE )
|
---|
230 | {
|
---|
231 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "CombinerInputNV passed bogus componentUsage: 0x%x", componentUsage );
|
---|
232 | return;
|
---|
233 | }
|
---|
234 |
|
---|
235 | if(( componentUsage == GL_RGB && portion == GL_ALPHA )||( componentUsage == GL_BLUE && portion == GL_RGB ))
|
---|
236 | {
|
---|
237 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, "Incompatible portion and componentUsage passed to CombinerInputNV: portion = 0x%x, componentUsage = 0x%x", portion, componentUsage );
|
---|
238 | return;
|
---|
239 | }
|
---|
240 | if( componentUsage == GL_ALPHA && input == GL_FOG )
|
---|
241 | {
|
---|
242 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, "CombinerInputNV can not have input of GL_FOG if componentUsage is GL_ALPHA" );
|
---|
243 | return;
|
---|
244 | }
|
---|
245 |
|
---|
246 | stage -= GL_COMBINER0_NV;
|
---|
247 | if( portion == GL_RGB )
|
---|
248 | {
|
---|
249 | switch( variable )
|
---|
250 | {
|
---|
251 | case GL_VARIABLE_A_NV:
|
---|
252 | r->rgb[stage].a = input;
|
---|
253 | r->rgb[stage].aMapping = mapping;
|
---|
254 | r->rgb[stage].aPortion = componentUsage;
|
---|
255 | break;
|
---|
256 | case GL_VARIABLE_B_NV:
|
---|
257 | r->rgb[stage].b = input;
|
---|
258 | r->rgb[stage].bMapping = mapping;
|
---|
259 | r->rgb[stage].bPortion = componentUsage;
|
---|
260 | break;
|
---|
261 | case GL_VARIABLE_C_NV:
|
---|
262 | r->rgb[stage].c = input;
|
---|
263 | r->rgb[stage].cMapping = mapping;
|
---|
264 | r->rgb[stage].cPortion = componentUsage;
|
---|
265 | break;
|
---|
266 | case GL_VARIABLE_D_NV:
|
---|
267 | r->rgb[stage].d = input;
|
---|
268 | r->rgb[stage].dMapping = mapping;
|
---|
269 | r->rgb[stage].dPortion = componentUsage;
|
---|
270 | break;
|
---|
271 | default:
|
---|
272 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "CombinerInputNV passed bogus variable: 0x%x", variable );
|
---|
273 | return;
|
---|
274 | }
|
---|
275 | }
|
---|
276 | else if( portion == GL_ALPHA )
|
---|
277 | {
|
---|
278 | switch( variable )
|
---|
279 | {
|
---|
280 | case GL_VARIABLE_A_NV:
|
---|
281 | r->alpha[stage].a = input;
|
---|
282 | r->alpha[stage].aMapping = mapping;
|
---|
283 | r->alpha[stage].aPortion = componentUsage;
|
---|
284 | break;
|
---|
285 | case GL_VARIABLE_B_NV:
|
---|
286 | r->alpha[stage].b = input;
|
---|
287 | r->alpha[stage].bMapping = mapping;
|
---|
288 | r->alpha[stage].bPortion = componentUsage;
|
---|
289 | break;
|
---|
290 | case GL_VARIABLE_C_NV:
|
---|
291 | r->alpha[stage].c = input;
|
---|
292 | r->alpha[stage].cMapping = mapping;
|
---|
293 | r->alpha[stage].cPortion = componentUsage;
|
---|
294 | break;
|
---|
295 | case GL_VARIABLE_D_NV:
|
---|
296 | r->alpha[stage].d = input;
|
---|
297 | r->alpha[stage].dMapping = mapping;
|
---|
298 | r->alpha[stage].dPortion = componentUsage;
|
---|
299 | break;
|
---|
300 | default:
|
---|
301 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "CombinerInputNV passed bogus variable: 0x%x", variable );
|
---|
302 | return;
|
---|
303 | }
|
---|
304 | }
|
---|
305 | else
|
---|
306 | {
|
---|
307 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "CombinerInputNV passed bogus portion: 0x%x", portion );
|
---|
308 | return;
|
---|
309 | }
|
---|
310 |
|
---|
311 | DIRTY(rb->regCombinerInput[stage], g->neg_bitid);
|
---|
312 | DIRTY(rb->dirty, g->neg_bitid);
|
---|
313 | }
|
---|
314 |
|
---|
315 | void STATE_APIENTRY crStateCombinerOutputNV(PCRStateTracker pState, GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum )
|
---|
316 | {
|
---|
317 | CRContext *g = GetCurrentContext(pState);
|
---|
318 | CRRegCombinerState *r = &(g->regcombiner);
|
---|
319 | CRStateBits *sb = GetCurrentBits(pState);
|
---|
320 | CRRegCombinerBits *rb = &(sb->regcombiner);
|
---|
321 |
|
---|
322 | /*
|
---|
323 | crDebug("%s(stage=0x%x portion=0x%x abOutput=0x%x cdOutput=0x%x "
|
---|
324 | "sumOutput=0x%x scale=0x%x bias=0x%x abDotProduct=0x%x "
|
---|
325 | "cdDotProduct=%d muxSum=%d)\n",
|
---|
326 | __FUNCTION__,
|
---|
327 | stage, portion, abOutput, cdOutput, sumOutput, scale, bias,
|
---|
328 | abDotProduct, cdDotProduct, muxSum);
|
---|
329 | */
|
---|
330 | if( stage < GL_COMBINER0_NV || stage >= GL_COMBINER0_NV + g->limits.maxGeneralCombiners )
|
---|
331 | {
|
---|
332 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "CombinerOutputNV passed bogus stage: 0x%x", stage );
|
---|
333 | return;
|
---|
334 | }
|
---|
335 | if( abOutput != GL_DISCARD_NV && abOutput != GL_PRIMARY_COLOR_NV && abOutput != GL_SECONDARY_COLOR_NV && abOutput != GL_SPARE0_NV && abOutput != GL_SPARE1_NV && ( abOutput < GL_TEXTURE0_ARB || abOutput >= g->limits.maxTextureUnits + GL_TEXTURE0_ARB ))
|
---|
336 | {
|
---|
337 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "CombinerOutputNV passed bogus abOutput: 0x%x", abOutput );
|
---|
338 | return;
|
---|
339 | }
|
---|
340 | if( cdOutput != GL_DISCARD_NV && cdOutput != GL_PRIMARY_COLOR_NV && cdOutput != GL_SECONDARY_COLOR_NV && cdOutput != GL_SPARE0_NV && cdOutput != GL_SPARE1_NV && ( cdOutput < GL_TEXTURE0_ARB || cdOutput >= g->limits.maxTextureUnits + GL_TEXTURE0_ARB ))
|
---|
341 | {
|
---|
342 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "CombinerOutputNV passed bogus cdOutput: 0x%x", cdOutput );
|
---|
343 | return;
|
---|
344 | }
|
---|
345 | if( sumOutput != GL_DISCARD_NV && sumOutput != GL_PRIMARY_COLOR_NV && sumOutput != GL_SECONDARY_COLOR_NV && sumOutput != GL_SPARE0_NV && sumOutput != GL_SPARE1_NV && sumOutput != GL_TEXTURE0_ARB && sumOutput != GL_TEXTURE1_ARB )
|
---|
346 | {
|
---|
347 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "CombinerOutputNV passed bogus sumOutput: 0x%x", sumOutput );
|
---|
348 | return;
|
---|
349 | }
|
---|
350 | if( scale != GL_NONE && scale != GL_SCALE_BY_TWO_NV && scale != GL_SCALE_BY_FOUR_NV && scale != GL_SCALE_BY_ONE_HALF_NV )
|
---|
351 | {
|
---|
352 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, "CombinerOutputNV passed bogus scale: 0x%x", scale );
|
---|
353 | return;
|
---|
354 | }
|
---|
355 | if( bias != GL_NONE && bias != GL_BIAS_BY_NEGATIVE_ONE_HALF_NV )
|
---|
356 | {
|
---|
357 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, "CombinerOutputNV passed bogus bias: 0x%x", bias );
|
---|
358 | return;
|
---|
359 | }
|
---|
360 |
|
---|
361 | if( bias == GL_BIAS_BY_NEGATIVE_ONE_HALF_NV && ( scale == GL_SCALE_BY_ONE_HALF_NV || scale == GL_SCALE_BY_FOUR_NV ))
|
---|
362 | {
|
---|
363 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, "CombinerOutputNV can't accept bias of -1/2 if scale is by 1/2 or 4" );
|
---|
364 | return;
|
---|
365 | }
|
---|
366 | if(( abOutput == cdOutput && abOutput != GL_DISCARD_NV )||( abOutput == sumOutput && abOutput != GL_DISCARD_NV )||( cdOutput == sumOutput && cdOutput != GL_DISCARD_NV ))
|
---|
367 | {
|
---|
368 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, "CombinerOutputNV register output names must be unique unless discarded: abOutput = 0x%x, cdOutput = 0x%x, sumOutput = 0x%x", abOutput, cdOutput, sumOutput );
|
---|
369 | return;
|
---|
370 | }
|
---|
371 | if( abDotProduct || cdDotProduct )
|
---|
372 | {
|
---|
373 | if( portion == GL_ALPHA )
|
---|
374 | {
|
---|
375 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_VALUE, "CombinerOutputNV can not do Dot Products when portion = GL_ALPHA" );
|
---|
376 | return;
|
---|
377 | }
|
---|
378 | if( sumOutput != GL_DISCARD_NV )
|
---|
379 | {
|
---|
380 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, "CombinerOutputNV can not do Dot Products when sumOutput is not discarded" );
|
---|
381 | return;
|
---|
382 | }
|
---|
383 | }
|
---|
384 |
|
---|
385 | stage -= GL_COMBINER0_NV;
|
---|
386 | if( portion == GL_RGB )
|
---|
387 | {
|
---|
388 | r->rgb[stage].abOutput = abOutput;
|
---|
389 | r->rgb[stage].cdOutput = cdOutput;
|
---|
390 | r->rgb[stage].sumOutput = sumOutput;
|
---|
391 | r->rgb[stage].scale = scale;
|
---|
392 | r->rgb[stage].bias = bias;
|
---|
393 | r->rgb[stage].abDotProduct = abDotProduct;
|
---|
394 | r->rgb[stage].cdDotProduct = cdDotProduct;
|
---|
395 | r->rgb[stage].muxSum = muxSum;
|
---|
396 | }
|
---|
397 | else if( portion == GL_ALPHA )
|
---|
398 | {
|
---|
399 | r->alpha[stage].abOutput = abOutput;
|
---|
400 | r->alpha[stage].cdOutput = cdOutput;
|
---|
401 | r->alpha[stage].sumOutput = sumOutput;
|
---|
402 | r->alpha[stage].scale = scale;
|
---|
403 | r->alpha[stage].bias = bias;
|
---|
404 | r->alpha[stage].abDotProduct = abDotProduct;
|
---|
405 | r->alpha[stage].cdDotProduct = cdDotProduct;
|
---|
406 | r->alpha[stage].muxSum = muxSum;
|
---|
407 | }
|
---|
408 | else
|
---|
409 | {
|
---|
410 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "CombinerOutputNV passed bogus portion: 0x%x", portion );
|
---|
411 | return;
|
---|
412 | }
|
---|
413 |
|
---|
414 | DIRTY(rb->regCombinerOutput[stage], g->neg_bitid);
|
---|
415 | DIRTY(rb->dirty, g->neg_bitid);
|
---|
416 | }
|
---|
417 |
|
---|
418 | void STATE_APIENTRY crStateFinalCombinerInputNV(PCRStateTracker pState, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage )
|
---|
419 | {
|
---|
420 | CRContext *g = GetCurrentContext(pState);
|
---|
421 | CRRegCombinerState *r = &(g->regcombiner);
|
---|
422 | CRStateBits *sb = GetCurrentBits(pState);
|
---|
423 | CRRegCombinerBits *rb = &(sb->regcombiner);
|
---|
424 |
|
---|
425 | if( input != GL_ZERO && input != GL_CONSTANT_COLOR0_NV && input != GL_CONSTANT_COLOR1_NV && input != GL_FOG && input != GL_PRIMARY_COLOR_NV && input != GL_SECONDARY_COLOR_NV && input != GL_SPARE0_NV && input != GL_SPARE1_NV && ( input < GL_TEXTURE0_ARB || input >= GL_TEXTURE0_ARB + g->limits.maxTextureUnits ) && input != GL_E_TIMES_F_NV && input != GL_SPARE0_PLUS_SECONDARY_COLOR_NV )
|
---|
426 | {
|
---|
427 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "FinalCombinerInputNV passed bogus input: 0x%x", input );
|
---|
428 | return;
|
---|
429 | }
|
---|
430 | if( mapping != GL_UNSIGNED_IDENTITY_NV && mapping != GL_UNSIGNED_INVERT_NV && mapping != GL_EXPAND_NORMAL_NV && mapping != GL_EXPAND_NEGATE_NV && mapping != GL_HALF_BIAS_NORMAL_NV && mapping != GL_HALF_BIAS_NEGATE_NV && mapping != GL_SIGNED_IDENTITY_NV && mapping != GL_SIGNED_NEGATE_NV )
|
---|
431 | {
|
---|
432 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "FinalCombinerInputNV passed bogus mapping: 0x%x", mapping );
|
---|
433 | return;
|
---|
434 | }
|
---|
435 | if( componentUsage != GL_RGB && componentUsage != GL_ALPHA && componentUsage != GL_BLUE )
|
---|
436 | {
|
---|
437 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "FinalCombinerInputNV passed bogus componentUsage: 0x%x", componentUsage );
|
---|
438 | return;
|
---|
439 | }
|
---|
440 |
|
---|
441 | if( componentUsage == GL_ALPHA && ( input == GL_E_TIMES_F_NV || input == GL_SPARE0_PLUS_SECONDARY_COLOR_NV ))
|
---|
442 | {
|
---|
443 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, "FinalCombinerInputNV does not allow componentUsage of ALPHA when input is E_TIMES_F or SPARE0_PLUS_SECONDARY_COLOR" );
|
---|
444 | return;
|
---|
445 | }
|
---|
446 |
|
---|
447 | switch( variable )
|
---|
448 | {
|
---|
449 | case GL_VARIABLE_A_NV:
|
---|
450 | r->a = input;
|
---|
451 | r->aMapping = mapping;
|
---|
452 | r->aPortion = componentUsage;
|
---|
453 | break;
|
---|
454 | case GL_VARIABLE_B_NV:
|
---|
455 | r->b = input;
|
---|
456 | r->bMapping = mapping;
|
---|
457 | r->bPortion = componentUsage;
|
---|
458 | break;
|
---|
459 | case GL_VARIABLE_C_NV:
|
---|
460 | r->c = input;
|
---|
461 | r->cMapping = mapping;
|
---|
462 | r->cPortion = componentUsage;
|
---|
463 | break;
|
---|
464 | case GL_VARIABLE_D_NV:
|
---|
465 | r->d = input;
|
---|
466 | r->dMapping = mapping;
|
---|
467 | r->dPortion = componentUsage;
|
---|
468 | break;
|
---|
469 | case GL_VARIABLE_E_NV:
|
---|
470 | r->e = input;
|
---|
471 | r->eMapping = mapping;
|
---|
472 | r->ePortion = componentUsage;
|
---|
473 | break;
|
---|
474 | case GL_VARIABLE_F_NV:
|
---|
475 | r->f = input;
|
---|
476 | r->fMapping = mapping;
|
---|
477 | r->fPortion = componentUsage;
|
---|
478 | break;
|
---|
479 | case GL_VARIABLE_G_NV:
|
---|
480 | if( componentUsage != GL_ALPHA )
|
---|
481 | {
|
---|
482 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, "FinalCombinerInputNV can not have variable G when componentUsage is RGB or BLUE" );
|
---|
483 | return;
|
---|
484 | }
|
---|
485 | r->g = input;
|
---|
486 | r->gMapping = mapping;
|
---|
487 | r->gPortion = componentUsage;
|
---|
488 | break;
|
---|
489 | default:
|
---|
490 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "CombinerOutputNV passed bogus variable: 0x%x", variable );
|
---|
491 | return;
|
---|
492 | }
|
---|
493 |
|
---|
494 | DIRTY(rb->regCombinerFinalInput, g->neg_bitid);
|
---|
495 | DIRTY(rb->dirty, g->neg_bitid);
|
---|
496 | }
|
---|
497 |
|
---|
498 |
|
---|
499 | /* XXX Unfinished RegCombiner State functions */
|
---|
500 | void STATE_APIENTRY crStateGetCombinerOutputParameterfvNV(PCRStateTracker pState, GLenum stage, GLenum portion, GLenum pname, GLfloat *params )
|
---|
501 | {
|
---|
502 | RT_NOREF(pState);
|
---|
503 | (void) stage;
|
---|
504 | (void) portion;
|
---|
505 | (void) pname;
|
---|
506 | (void) params;
|
---|
507 | }
|
---|
508 |
|
---|
509 | void STATE_APIENTRY crStateGetCombinerOutputParameterivNV(PCRStateTracker pState, GLenum stage, GLenum portion, GLenum pname, GLint *params )
|
---|
510 | {
|
---|
511 | RT_NOREF(pState);
|
---|
512 | (void) stage;
|
---|
513 | (void) portion;
|
---|
514 | (void) pname;
|
---|
515 | (void) params;
|
---|
516 | }
|
---|
517 |
|
---|
518 | void STATE_APIENTRY crStateGetFinalCombinerInputParameterfvNV(PCRStateTracker pState, GLenum variable, GLenum pname, GLfloat *params )
|
---|
519 | {
|
---|
520 | RT_NOREF(pState);
|
---|
521 | (void) variable;
|
---|
522 | (void) pname;
|
---|
523 | (void) params;
|
---|
524 | }
|
---|
525 |
|
---|
526 | void STATE_APIENTRY crStateGetFinalCombinerInputParameterivNV(PCRStateTracker pState, GLenum variable, GLenum pname, GLint *params )
|
---|
527 | {
|
---|
528 | RT_NOREF(pState);
|
---|
529 | (void) variable;
|
---|
530 | (void) pname;
|
---|
531 | (void) params;
|
---|
532 | }
|
---|
533 |
|
---|
534 |
|
---|
535 | void STATE_APIENTRY crStateGetCombinerInputParameterivNV(PCRStateTracker pState, GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params )
|
---|
536 | {
|
---|
537 | CRContext *g = GetCurrentContext(pState);
|
---|
538 | CRRegCombinerState *r = &(g->regcombiner);
|
---|
539 | int i = stage - GL_COMBINER0_NV;
|
---|
540 | GLenum input = 0, mapping = 0, usage = 0;
|
---|
541 |
|
---|
542 | if (g->current.inBeginEnd)
|
---|
543 | {
|
---|
544 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
|
---|
545 | "glGetCombinerParameterivNV called in begin/end");
|
---|
546 | return;
|
---|
547 | }
|
---|
548 |
|
---|
549 | if (i < 0 || i >= CR_MAX_GENERAL_COMBINERS) {
|
---|
550 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
551 | "GetCombinerInputParameterivNV(stage=0x%x)", stage);
|
---|
552 | return;
|
---|
553 | }
|
---|
554 |
|
---|
555 | if (portion == GL_RGB) {
|
---|
556 | switch (variable) {
|
---|
557 | case GL_VARIABLE_A_NV:
|
---|
558 | input = r->rgb[i].a;
|
---|
559 | mapping = r->rgb[i].aMapping;
|
---|
560 | usage = r->rgb[i].aPortion;
|
---|
561 | break;
|
---|
562 | case GL_VARIABLE_B_NV:
|
---|
563 | input = r->rgb[i].b;
|
---|
564 | mapping = r->rgb[i].bMapping;
|
---|
565 | usage = r->rgb[i].bPortion;
|
---|
566 | break;
|
---|
567 | case GL_VARIABLE_C_NV:
|
---|
568 | input = r->rgb[i].c;
|
---|
569 | mapping = r->rgb[i].cMapping;
|
---|
570 | usage = r->rgb[i].cPortion;
|
---|
571 | break;
|
---|
572 | case GL_VARIABLE_D_NV:
|
---|
573 | input = r->rgb[i].d;
|
---|
574 | mapping = r->rgb[i].dMapping;
|
---|
575 | usage = r->rgb[i].dPortion;
|
---|
576 | break;
|
---|
577 | default:
|
---|
578 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
579 | "glGetCombinerInputParameterivNV(variable=0x%x)", variable);
|
---|
580 | return;
|
---|
581 | }
|
---|
582 | }
|
---|
583 | else if (portion == GL_ALPHA) {
|
---|
584 | switch (variable) {
|
---|
585 | case GL_VARIABLE_A_NV:
|
---|
586 | input = r->alpha[i].a;
|
---|
587 | mapping = r->alpha[i].aMapping;
|
---|
588 | usage = r->alpha[i].aPortion;
|
---|
589 | break;
|
---|
590 | case GL_VARIABLE_B_NV:
|
---|
591 | input = r->alpha[i].b;
|
---|
592 | mapping = r->alpha[i].bMapping;
|
---|
593 | usage = r->alpha[i].bPortion;
|
---|
594 | break;
|
---|
595 | case GL_VARIABLE_C_NV:
|
---|
596 | input = r->alpha[i].c;
|
---|
597 | mapping = r->alpha[i].cMapping;
|
---|
598 | usage = r->alpha[i].cPortion;
|
---|
599 | break;
|
---|
600 | case GL_VARIABLE_D_NV:
|
---|
601 | input = r->alpha[i].d;
|
---|
602 | mapping = r->alpha[i].dMapping;
|
---|
603 | usage = r->alpha[i].dPortion;
|
---|
604 | break;
|
---|
605 | default:
|
---|
606 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
607 | "glGetCombinerInputParameterivNV(variable=0x%x)", variable);
|
---|
608 | return;
|
---|
609 | }
|
---|
610 | }
|
---|
611 | else {
|
---|
612 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
613 | "glGetCombinerInputParameterivNV(portion=0x%x)", portion);
|
---|
614 | }
|
---|
615 | switch (pname) {
|
---|
616 | case GL_COMBINER_INPUT_NV:
|
---|
617 | *params = input;
|
---|
618 | return;
|
---|
619 | case GL_COMBINER_MAPPING_NV:
|
---|
620 | *params = mapping;
|
---|
621 | return;
|
---|
622 | case GL_COMBINER_COMPONENT_USAGE_NV:
|
---|
623 | *params = usage;
|
---|
624 | return;
|
---|
625 | default:
|
---|
626 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
627 | "glGetCombinerInputParameterivNV(pname=0x%x)", pname);
|
---|
628 | return;
|
---|
629 | }
|
---|
630 | }
|
---|
631 |
|
---|
632 |
|
---|
633 | void STATE_APIENTRY crStateGetCombinerInputParameterfvNV(PCRStateTracker pState, GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params )
|
---|
634 | {
|
---|
635 | GLint iparams;
|
---|
636 | crStateGetCombinerInputParameterivNV(pState, stage, portion, variable, pname, &iparams);
|
---|
637 | *params = (GLfloat) iparams;
|
---|
638 | }
|
---|
639 |
|
---|
640 |
|
---|
641 | void STATE_APIENTRY crStateCombinerStageParameterfvNV(PCRStateTracker pState, GLenum stage, GLenum pname, const GLfloat *params )
|
---|
642 | {
|
---|
643 | CRContext *g = GetCurrentContext(pState);
|
---|
644 | CRRegCombinerState *r = &(g->regcombiner);
|
---|
645 | CRStateBits *sb = GetCurrentBits(pState);
|
---|
646 | CRRegCombinerBits *rb = &(sb->regcombiner);
|
---|
647 |
|
---|
648 | stage -= GL_COMBINER0_NV;
|
---|
649 | if( stage >= g->limits.maxGeneralCombiners )
|
---|
650 | {
|
---|
651 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "CombinerStageParameterfvNV passed bogus stage: 0x%x", stage+GL_COMBINER0_NV );
|
---|
652 | return;
|
---|
653 | }
|
---|
654 |
|
---|
655 | switch( pname )
|
---|
656 | {
|
---|
657 | case GL_CONSTANT_COLOR0_NV:
|
---|
658 | r->stageConstantColor0[stage].r = params[0];
|
---|
659 | r->stageConstantColor0[stage].g = params[1];
|
---|
660 | r->stageConstantColor0[stage].b = params[2];
|
---|
661 | r->stageConstantColor0[stage].a = params[3];
|
---|
662 | DIRTY(rb->regCombinerStageColor0[stage], g->neg_bitid);
|
---|
663 | break;
|
---|
664 | case GL_CONSTANT_COLOR1_NV:
|
---|
665 | r->stageConstantColor1[stage].r = params[0];
|
---|
666 | r->stageConstantColor1[stage].g = params[1];
|
---|
667 | r->stageConstantColor1[stage].b = params[2];
|
---|
668 | r->stageConstantColor1[stage].a = params[3];
|
---|
669 | DIRTY(rb->regCombinerStageColor1[stage], g->neg_bitid);
|
---|
670 | break;
|
---|
671 | default:
|
---|
672 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "CombinerStageParameter passed bogus pname: 0x%x", pname );
|
---|
673 | return;
|
---|
674 | }
|
---|
675 |
|
---|
676 | DIRTY(rb->dirty, g->neg_bitid);
|
---|
677 | }
|
---|
678 |
|
---|
679 | void STATE_APIENTRY crStateGetCombinerStageParameterfvNV(PCRStateTracker pState, GLenum stage, GLenum pname, GLfloat *params )
|
---|
680 | {
|
---|
681 | CRContext *g = GetCurrentContext(pState);
|
---|
682 | CRRegCombinerState *r = &(g->regcombiner);
|
---|
683 |
|
---|
684 | stage -= GL_COMBINER0_NV;
|
---|
685 | if( stage >= g->limits.maxGeneralCombiners )
|
---|
686 | {
|
---|
687 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "GetCombinerStageParameterfvNV passed bogus stage: 0x%x", stage+GL_COMBINER0_NV );
|
---|
688 | return;
|
---|
689 | }
|
---|
690 | switch( pname )
|
---|
691 | {
|
---|
692 | case GL_CONSTANT_COLOR0_NV:
|
---|
693 | params[0] = r->stageConstantColor0[stage].r;
|
---|
694 | params[1] = r->stageConstantColor0[stage].g;
|
---|
695 | params[2] = r->stageConstantColor0[stage].b;
|
---|
696 | params[3] = r->stageConstantColor0[stage].a;
|
---|
697 | break;
|
---|
698 | case GL_CONSTANT_COLOR1_NV:
|
---|
699 | params[0] = r->stageConstantColor1[stage].r;
|
---|
700 | params[1] = r->stageConstantColor1[stage].g;
|
---|
701 | params[2] = r->stageConstantColor1[stage].b;
|
---|
702 | params[3] = r->stageConstantColor1[stage].a;
|
---|
703 | break;
|
---|
704 | default:
|
---|
705 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "GetCombinerStageParameter passed bogus pname: 0x%x", pname );
|
---|
706 | return;
|
---|
707 | }
|
---|
708 | return;
|
---|
709 | }
|
---|