state_regcombiner.c revision 31e6a5dbf0e52ca0f184afaa457c6700d718ffae
/* Copyright (c) 2001, Stanford University
* All rights reserved
*
* See the file LICENSE.txt for information on redistributing this software.
*/
#include "state.h"
#include "state/cr_statetypes.h"
#define UNUSED(x) ((void) (x))
{
#ifndef CR_NV_register_combiners
#else
int i;
for( i=0; i<CR_MAX_GENERAL_COMBINERS; i++ )
{
/* RGB Portion */
/* Alpha Portion */
}
reg->g = GL_SPARE0_NV;
#ifdef CR_NV_register_combiners2
for( i=0; i<CR_MAX_GENERAL_COMBINERS; i++ )
{
}
#endif /* CR_NV_register_combiners2 */
#endif /* CR_NV_register_combiners */
}
{
CRContext *g = GetCurrentContext();
CRRegCombinerState *r = &(g->regcombiner);
switch( pname )
{
case GL_CONSTANT_COLOR0_NV:
r->constantColor0.r = params[0];
break;
case GL_CONSTANT_COLOR1_NV:
r->constantColor1.r = params[0];
break;
{
crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "CombinerParameter passed invalid NUM_GENERAL_COMBINERS param: %d", (GLint)*params );
return;
}
break;
case GL_COLOR_SUM_CLAMP_NV:
break;
default:
crStateError( __LINE__, __FILE__, GL_INVALID_ENUM, "CombinerParameter passed bogus pname: 0x%x", pname );
return;
}
}
{
int i;
{
for( i=0; i<4; i++ )
{
}
}
else
{
/* Only one parameter: */
}
}
{
{
crStateError( __LINE__, __FILE__, GL_INVALID_ENUM, "Invalid pname (CONSTANT_COLOR%d) passed to CombinerParameterfNV: 0x%x", (GLint)param-GL_CONSTANT_COLOR0_NV, pname );
return;
}
}
{
{
crStateError( __LINE__, __FILE__, GL_INVALID_ENUM, "Invalid pname (CONSTANT_COLOR%d) passed to CombinerParameteriNV: 0x%x", param-GL_CONSTANT_COLOR0_NV, pname );
return;
}
}
void STATE_APIENTRY crStateCombinerInputNV( GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage )
{
CRContext *g = GetCurrentContext();
CRRegCombinerState *r = &(g->regcombiner);
{
crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerInputNV passed bogus stage: 0x%x", stage );
return;
}
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 ))
{
crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerInputNV passed bogus input: 0x%x", input );
return;
}
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 )
{
crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerInputNV passed bogus mapping: 0x%x", mapping );
return;
}
{
crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerInputNV passed bogus componentUsage: 0x%x", componentUsage );
return;
}
if(( componentUsage == GL_RGB && portion == GL_ALPHA )||( componentUsage == GL_BLUE && portion == GL_RGB ))
{
crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "Incompatible portion and componentUsage passed to CombinerInputNV: portion = 0x%x, componentUsage = 0x%x", portion, componentUsage );
return;
}
{
crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "CombinerInputNV can not have input of GL_FOG if componentUsage is GL_ALPHA" );
return;
}
stage -= GL_COMBINER0_NV;
{
switch( variable )
{
case GL_VARIABLE_A_NV:
break;
case GL_VARIABLE_B_NV:
break;
case GL_VARIABLE_C_NV:
break;
case GL_VARIABLE_D_NV:
break;
default:
crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerInputNV passed bogus variable: 0x%x", variable );
return;
}
}
{
switch( variable )
{
case GL_VARIABLE_A_NV:
break;
case GL_VARIABLE_B_NV:
break;
case GL_VARIABLE_C_NV:
break;
case GL_VARIABLE_D_NV:
break;
default:
crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerInputNV passed bogus variable: 0x%x", variable );
return;
}
}
else
{
crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerInputNV passed bogus portion: 0x%x", portion );
return;
}
}
void STATE_APIENTRY crStateCombinerOutputNV( GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum )
{
CRContext *g = GetCurrentContext();
CRRegCombinerState *r = &(g->regcombiner);
/*
crDebug("%s(stage=0x%x portion=0x%x abOutput=0x%x cdOutput=0x%x "
"sumOutput=0x%x scale=0x%x bias=0x%x abDotProduct=0x%x "
"cdDotProduct=%d muxSum=%d)\n",
__FUNCTION__,
stage, portion, abOutput, cdOutput, sumOutput, scale, bias,
abDotProduct, cdDotProduct, muxSum);
*/
{
crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerOutputNV passed bogus stage: 0x%x", stage );
return;
}
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 ))
{
crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerOutputNV passed bogus abOutput: 0x%x", abOutput );
return;
}
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 ))
{
crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerOutputNV passed bogus cdOutput: 0x%x", cdOutput );
return;
}
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 )
{
crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerOutputNV passed bogus sumOutput: 0x%x", sumOutput );
return;
}
if( scale != GL_NONE && scale != GL_SCALE_BY_TWO_NV && scale != GL_SCALE_BY_FOUR_NV && scale != GL_SCALE_BY_ONE_HALF_NV )
{
crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "CombinerOutputNV passed bogus scale: 0x%x", scale );
return;
}
{
crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "CombinerOutputNV passed bogus bias: 0x%x", bias );
return;
}
if( bias == GL_BIAS_BY_NEGATIVE_ONE_HALF_NV && ( scale == GL_SCALE_BY_ONE_HALF_NV || scale == GL_SCALE_BY_FOUR_NV ))
{
crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "CombinerOutputNV can't accept bias of -1/2 if scale is by 1/2 or 4" );
return;
}
if(( abOutput == cdOutput && abOutput != GL_DISCARD_NV )||( abOutput == sumOutput && abOutput != GL_DISCARD_NV )||( cdOutput == sumOutput && cdOutput != GL_DISCARD_NV ))
{
crStateError(__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 );
return;
}
if( abDotProduct || cdDotProduct )
{
{
crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "CombinerOutputNV can not do Dot Products when portion = GL_ALPHA" );
return;
}
if( sumOutput != GL_DISCARD_NV )
{
crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "CombinerOutputNV can not do Dot Products when sumOutput is not discarded" );
return;
}
}
stage -= GL_COMBINER0_NV;
{
}
{
}
else
{
crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerOutputNV passed bogus portion: 0x%x", portion );
return;
}
}
void STATE_APIENTRY crStateFinalCombinerInputNV( GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage )
{
CRContext *g = GetCurrentContext();
CRRegCombinerState *r = &(g->regcombiner);
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 )
{
crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "FinalCombinerInputNV passed bogus input: 0x%x", input );
return;
}
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 )
{
crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "FinalCombinerInputNV passed bogus mapping: 0x%x", mapping );
return;
}
{
crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "FinalCombinerInputNV passed bogus componentUsage: 0x%x", componentUsage );
return;
}
if( componentUsage == GL_ALPHA && ( input == GL_E_TIMES_F_NV || input == GL_SPARE0_PLUS_SECONDARY_COLOR_NV ))
{
crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "FinalCombinerInputNV does not allow componentUsage of ALPHA when input is E_TIMES_F or SPARE0_PLUS_SECONDARY_COLOR" );
return;
}
switch( variable )
{
case GL_VARIABLE_A_NV:
r->a = input;
r->aPortion = componentUsage;
break;
case GL_VARIABLE_B_NV:
r->b = input;
r->bPortion = componentUsage;
break;
case GL_VARIABLE_C_NV:
r->c = input;
r->cPortion = componentUsage;
break;
case GL_VARIABLE_D_NV:
r->d = input;
r->dPortion = componentUsage;
break;
case GL_VARIABLE_E_NV:
r->e = input;
r->ePortion = componentUsage;
break;
case GL_VARIABLE_F_NV:
r->f = input;
r->fPortion = componentUsage;
break;
case GL_VARIABLE_G_NV:
if( componentUsage != GL_ALPHA )
{
crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION, "FinalCombinerInputNV can not have variable G when componentUsage is RGB or BLUE" );
return;
}
r->g = input;
r->gPortion = componentUsage;
break;
default:
crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerOutputNV passed bogus variable: 0x%x", variable );
return;
}
}
/* XXX Unfinished RegCombiner State functions */
void STATE_APIENTRY crStateGetCombinerOutputParameterfvNV( GLenum stage, GLenum portion, GLenum pname, GLfloat *params )
{
(void) stage;
(void) portion;
(void) pname;
(void) params;
}
void STATE_APIENTRY crStateGetCombinerOutputParameterivNV( GLenum stage, GLenum portion, GLenum pname, GLint *params )
{
(void) stage;
(void) portion;
(void) pname;
(void) params;
}
void STATE_APIENTRY crStateGetFinalCombinerInputParameterfvNV( GLenum variable, GLenum pname, GLfloat *params )
{
(void) variable;
(void) pname;
(void) params;
}
void STATE_APIENTRY crStateGetFinalCombinerInputParameterivNV( GLenum variable, GLenum pname, GLint *params )
{
(void) variable;
(void) pname;
(void) params;
}
void STATE_APIENTRY crStateGetCombinerInputParameterivNV( GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params )
{
CRContext *g = GetCurrentContext();
CRRegCombinerState *r = &(g->regcombiner);
int i = stage - GL_COMBINER0_NV;
if (g->current.inBeginEnd)
{
return;
}
if (i < 0 || i >= CR_MAX_GENERAL_COMBINERS) {
"GetCombinerInputParameterivNV(stage=0x%x)", stage);
return;
}
switch (variable) {
case GL_VARIABLE_A_NV:
break;
case GL_VARIABLE_B_NV:
break;
case GL_VARIABLE_C_NV:
break;
case GL_VARIABLE_D_NV:
break;
default:
"glGetCombinerInputParameterivNV(variable=0x%x)", variable);
return;
}
}
switch (variable) {
case GL_VARIABLE_A_NV:
break;
case GL_VARIABLE_B_NV:
break;
case GL_VARIABLE_C_NV:
break;
case GL_VARIABLE_D_NV:
break;
default:
"glGetCombinerInputParameterivNV(variable=0x%x)", variable);
return;
}
}
else {
"glGetCombinerInputParameterivNV(portion=0x%x)", portion);
}
switch (pname) {
case GL_COMBINER_INPUT_NV:
return;
case GL_COMBINER_MAPPING_NV:
return;
return;
default:
"glGetCombinerInputParameterivNV(pname=0x%x)", pname);
return;
}
}
void STATE_APIENTRY crStateGetCombinerInputParameterfvNV( GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params )
{
}
void STATE_APIENTRY crStateCombinerStageParameterfvNV( GLenum stage, GLenum pname, const GLfloat *params )
{
CRContext *g = GetCurrentContext();
CRRegCombinerState *r = &(g->regcombiner);
stage -= GL_COMBINER0_NV;
{
crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerStageParameterfvNV passed bogus stage: 0x%x", stage+GL_COMBINER0_NV );
return;
}
switch( pname )
{
case GL_CONSTANT_COLOR0_NV:
break;
case GL_CONSTANT_COLOR1_NV:
break;
default:
crStateError( __LINE__, __FILE__, GL_INVALID_ENUM, "CombinerStageParameter passed bogus pname: 0x%x", pname );
return;
}
}
void STATE_APIENTRY crStateGetCombinerStageParameterfvNV( GLenum stage, GLenum pname, GLfloat *params )
{
CRContext *g = GetCurrentContext();
CRRegCombinerState *r = &(g->regcombiner);
stage -= GL_COMBINER0_NV;
{
crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "GetCombinerStageParameterfvNV passed bogus stage: 0x%x", stage+GL_COMBINER0_NV );
return;
}
switch( pname )
{
case GL_CONSTANT_COLOR0_NV:
break;
case GL_CONSTANT_COLOR1_NV:
break;
default:
crStateError( __LINE__, __FILE__, GL_INVALID_ENUM, "GetCombinerStageParameter passed bogus pname: 0x%x", pname );
return;
}
return;
}