#ifdef DO_TEX
{
GLfloat invQ;
- if (ctx->FragmentProgram._Active) {
+ if (ctx->FragmentProgram._Current) {
invQ = 1.0F;
}
else {
for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
if (ctx->Texture.Unit[unit]._ReallyEnabled) {
GLfloat invQ;
- if (ctx->FragmentProgram._Active) {
+ if (ctx->FragmentProgram._Current) {
invQ = 1.0F;
}
else {
rasterMask |= MULTI_DRAW_BIT; /* all color index bits disabled */
}
- if (ctx->FragmentProgram._Enabled) {
+ if (ctx->FragmentProgram._Current) {
rasterMask |= FRAGPROG_BIT;
}
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
swrast->_PreferPixelFog = (!swrast->AllowVertexFog ||
- ctx->FragmentProgram._Enabled || /* not _Active! */
+ ctx->FragmentProgram._Current ||
(ctx->Hint.Fog == GL_NICEST &&
swrast->AllowPixelFog));
}
_swrast_update_fog_state( GLcontext *ctx )
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ const struct gl_fragment_program *fp = ctx->FragmentProgram._Current;
/* determine if fog is needed, and if so, which fog mode */
swrast->_FogEnabled = GL_FALSE;
- if (ctx->FragmentProgram._Enabled) {
- if (ctx->FragmentProgram._Current->Base.Target==GL_FRAGMENT_PROGRAM_ARB) {
- const struct gl_fragment_program *fp
- = ctx->FragmentProgram._Current;
- if (fp->FogOption != GL_NONE) {
- swrast->_FogEnabled = GL_TRUE;
- swrast->_FogMode = fp->FogOption;
- }
+ if (fp && fp->Base.Target == GL_FRAGMENT_PROGRAM_ARB) {
+ if (fp->FogOption != GL_NONE) {
+ swrast->_FogEnabled = GL_TRUE;
+ swrast->_FogMode = fp->FogOption;
}
}
else if (ctx->Fog.Enabled) {
static void
_swrast_update_fragment_program(GLcontext *ctx, GLbitfield newState)
{
- if (ctx->FragmentProgram._Enabled) {
- const struct gl_fragment_program *fp = ctx->FragmentProgram._Current;
+ const struct gl_fragment_program *fp = ctx->FragmentProgram._Current;
+ if (fp) {
#if 0
/* XXX Need a way to trigger the initial loading of parameters
* even when there's no recent state changes.
if (ctx->Texture._EnabledUnits == 0
&& NEED_SECONDARY_COLOR(ctx)
- && !ctx->FragmentProgram._Enabled) {
+ && !ctx->FragmentProgram._Current) {
/* separate specular color, but no texture */
swrast->SpecTriangle = swrast->Triangle;
swrast->Triangle = _swrast_add_spec_terms_triangle;
if (ctx->Texture._EnabledUnits == 0
&& NEED_SECONDARY_COLOR(ctx)
- && !ctx->FragmentProgram._Enabled) {
+ && !ctx->FragmentProgram._Current) {
swrast->SpecLine = swrast->Line;
swrast->Line = _swrast_add_spec_terms_line;
}
if (ctx->Texture._EnabledUnits == 0
&& NEED_SECONDARY_COLOR(ctx)
- && !ctx->FragmentProgram._Enabled) {
+ && !ctx->FragmentProgram._Current) {
swrast->SpecPoint = swrast->Point;
swrast->Point = _swrast_add_spec_terms_point;
}
*/
struct fp_machine
{
- GLfloat Temporaries[MAX_NV_FRAGMENT_PROGRAM_TEMPS][4];
- GLfloat Inputs[MAX_NV_FRAGMENT_PROGRAM_INPUTS][4];
- GLfloat Outputs[MAX_NV_FRAGMENT_PROGRAM_OUTPUTS][4];
+ GLfloat Temporaries[MAX_PROGRAM_TEMPS][4];
+ GLfloat Inputs[FRAG_ATTRIB_MAX][4];
+ GLfloat Outputs[FRAG_RESULT_MAX][4];
GLuint CondCodes[4]; /**< COND_* value for x/y/z/w */
GLuint CallStack[MAX_PROGRAM_CALL_DEPTH]; /**< For CAL/RET instructions */
{
switch (source->File) {
case PROGRAM_TEMPORARY:
- ASSERT(source->Index < MAX_NV_FRAGMENT_PROGRAM_TEMPS);
+ ASSERT(source->Index < MAX_PROGRAM_TEMPS);
return machine->Temporaries[source->Index];
case PROGRAM_INPUT:
- ASSERT(source->Index < MAX_NV_FRAGMENT_PROGRAM_INPUTS);
+ ASSERT(source->Index < FRAG_ATTRIB_MAX);
return machine->Inputs[source->Index];
case PROGRAM_OUTPUT:
/* This is only for PRINT */
- ASSERT(source->Index < MAX_NV_FRAGMENT_PROGRAM_OUTPUTS);
+ ASSERT(source->Index < FRAG_RESULT_MAX);
return machine->Outputs[source->Index];
case PROGRAM_LOCAL_PARAM:
ASSERT(source->Index < MAX_PROGRAM_LOCAL_PARAMS);
/* Fallthrough */
case PROGRAM_CONSTANT:
/* Fallthrough */
+ case PROGRAM_UNIFORM:
+ /* Fallthrough */
case PROGRAM_NAMED_PARAM:
ASSERT(source->Index < (GLint) program->Base.Parameters->NumParameters);
return program->Base.Parameters->ParameterValues[source->Index];
const SWspan *span, char xOrY,
struct fp_machine *dMachine )
{
- GLuint u;
+ GLuint u, v;
ASSERT(xOrY == 'X' || xOrY == 'Y');
}
}
+ for (v = 0; v < ctx->Const.MaxVarying; v++) {
+ if (program->Base.InputsRead & (1 << (FRAG_ATTRIB_VAR0 + v))) {
+ GLfloat *var = (GLfloat*) machine->Inputs[FRAG_ATTRIB_VAR0 + v];
+ /* XXXX finish this */
+ var[0] += span->varStepX[v][0];
+ var[1] += span->varStepX[v][1];
+ var[2] += span->varStepX[v][2];
+ var[3] += span->varStepX[v][3];
+ }
+ }
+
/* init condition codes */
dMachine->CondCodes[0] = COND_EQ;
dMachine->CondCodes[1] = COND_EQ;
const SWspan *span, GLuint col )
{
GLuint inputsRead = program->Base.InputsRead;
- GLuint u;
+ GLuint u, v;
if (ctx->FragmentProgram.CallbackEnabled)
inputsRead = ~0;
/*ASSERT(tex[0] != 0 || tex[1] != 0 || tex[2] != 0);*/
}
}
+ for (v = 0; v < ctx->Const.MaxVarying; v++) {
+ if (inputsRead & (1 << (FRAG_ATTRIB_VAR0 + v))) {
+#if 0
+ printf("Frag Var %d: %f %f %f\n", col,
+ span->array->varying[col][v][0],
+ span->array->varying[col][v][1],
+ span->array->varying[col][v][2]);
+#endif
+ COPY_4V(machine->Inputs[FRAG_ATTRIB_VAR0 + v],
+ span->array->varying[col][v]);
+ }
+ }
/* init condition codes */
machine->CondCodes[0] = COND_EQ;
#endif
#if FLAGS & TEXTURE
span->arrayMask |= (SPAN_TEXTURE | SPAN_LAMBDA);
- if (ctx->FragmentProgram._Active) {
+ if (ctx->FragmentProgram._Current) {
/* Don't divide texture s,t,r by q (use TXP to do that) */
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
if (ctx->Texture._EnabledCoordUnits & (1 << u)) {
GLuint i;
for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
const GLfloat *tc = ctx->Current.RasterTexCoords[i];
- if (ctx->FragmentProgram._Enabled || ctx->ATIFragmentShader._Enabled) {
+ if (ctx->FragmentProgram._Current || ctx->ATIFragmentShader._Enabled) {
COPY_4V(span->tex[i], tc);
}
else if (tc[3] > 0.0F) {
if (obj) {
const struct gl_texture_image *img = obj->Image[0][obj->BaseLevel];
needLambda = (obj->MinFilter != obj->MagFilter)
- || ctx->FragmentProgram._Enabled;
+ || ctx->FragmentProgram._Current;
texW = img->WidthScale;
texH = img->HeightScale;
}
GLfloat r = span->tex[u][2];
GLfloat q = span->tex[u][3];
GLuint i;
- if (ctx->FragmentProgram._Enabled || ctx->ATIFragmentShader._Enabled ||
- ctx->ShaderObjects._FragmentShaderPresent) {
+ if (ctx->FragmentProgram._Current
+ || ctx->ATIFragmentShader._Enabled) {
/* do perspective correction but don't divide s, t, r by q */
const GLfloat dwdx = span->dwdx;
GLfloat w = span->w;
GLfloat r = span->tex[u][2];
GLfloat q = span->tex[u][3];
GLuint i;
- if (ctx->FragmentProgram._Enabled || ctx->ATIFragmentShader._Enabled ||
- ctx->ShaderObjects._FragmentShaderPresent) {
+ if (ctx->FragmentProgram._Current ||
+ ctx->ATIFragmentShader._Enabled) {
/* do perspective correction but don't divide s, t, r by q */
const GLfloat dwdx = span->dwdx;
GLfloat w = span->w;
if (obj) {
const struct gl_texture_image *img = obj->Image[0][obj->BaseLevel];
needLambda = (obj->MinFilter != obj->MagFilter)
- || ctx->FragmentProgram._Enabled;
+ || ctx->FragmentProgram._Current;
texW = (GLfloat) img->WidthScale;
texH = (GLfloat) img->HeightScale;
}
GLfloat r = span->tex[0][2];
GLfloat q = span->tex[0][3];
GLuint i;
- if (ctx->FragmentProgram._Enabled || ctx->ATIFragmentShader._Enabled ||
- ctx->ShaderObjects._FragmentShaderPresent) {
+ if (ctx->FragmentProgram._Current
+ || ctx->ATIFragmentShader._Enabled) {
/* do perspective correction but don't divide s, t, r by q */
const GLfloat dwdx = span->dwdx;
GLfloat w = span->w;
GLfloat r = span->tex[0][2];
GLfloat q = span->tex[0][3];
GLuint i;
- if (ctx->FragmentProgram._Enabled || ctx->ATIFragmentShader._Enabled ||
- ctx->ShaderObjects._FragmentShaderPresent) {
+ if (ctx->FragmentProgram._Current
+ || ctx->ATIFragmentShader._Enabled) {
/* do perspective correction but don't divide s, t, r by q */
const GLfloat dwdx = span->dwdx;
GLfloat w = span->w;
if (ctx->Texture._EnabledCoordUnits && (span->interpMask & SPAN_TEXTURE))
interpolate_texcoords(ctx, span);
- if (ctx->ShaderObjects._FragmentShaderPresent ||
- ctx->FragmentProgram._Enabled ||
+ if (ctx->FragmentProgram._Current ||
ctx->ATIFragmentShader._Enabled) {
/* use float colors if running a fragment program or shader */
if (span->interpMask & SPAN_Z)
_swrast_span_interpolate_z (ctx, span);
- /* Run fragment program/shader now */
- if (ctx->ShaderObjects._FragmentShaderPresent) {
+ if (ctx->ShaderObjects.Linked && span->interpMask & SPAN_VARYING)
interpolate_varying(ctx, span);
- _swrast_exec_arbshader(ctx, span);
- }
- else if (ctx->FragmentProgram._Enabled) {
+
+ /* Run fragment program/shader now */
+ if (ctx->FragmentProgram._Current) {
_swrast_exec_fragment_program(ctx, span);
}
else {
const GLbitfield origInterpMask = span->interpMask;
const GLbitfield origArrayMask = span->arrayMask;
const GLenum chanType = span->array->ChanType;
- const GLboolean shader
- = ctx->FragmentProgram._Enabled
- || ctx->ShaderObjects._FragmentShaderPresent
- || ctx->ATIFragmentShader._Enabled;
+ const GLboolean shader = (ctx->FragmentProgram._Current
+ || ctx->ATIFragmentShader._Enabled);
const GLboolean shaderOrTexture = shader || ctx->Texture._EnabledUnits;
GLboolean deferredTexture;
deferredTexture = GL_FALSE;
}
else if (shaderOrTexture) {
- if (ctx->FragmentProgram._Enabled) {
+ if (ctx->FragmentProgram._Current) {
if (ctx->FragmentProgram.Current->Base.OutputsWritten
& (1 << FRAG_RESULT_DEPR)) {
- /* Z comes from fragment program */
+ /* Z comes from fragment program/shader */
deferredTexture = GL_FALSE;
}
else {
deferredTexture = GL_TRUE;
}
}
- else if (ctx->ShaderObjects._FragmentShaderPresent) {
- /* XXX how do we test if Z is written by shader? */
- deferredTexture = GL_FALSE; /* never defer to be safe */
- }
else {
/* ATI frag shader or conventional texturing */
deferredTexture = GL_TRUE;
/*
* This is the big one!
- * Interpolate Z, RGB, Alpha, specular, fog, N sets of texture coordinates, and varying floats.
- * Yup, it's slow.
+ * Interpolate Z, RGB, Alpha, specular, fog, N sets of texture coordinates,
+ * and varying floats. Yup, it's slow.
*/
#define NAME multitextured_triangle
#define INTERP_Z 1
}
}
- if (ctx->Texture._EnabledCoordUnits || ctx->FragmentProgram._Enabled ||
- ctx->ATIFragmentShader._Enabled || ctx->ShaderObjects._FragmentShaderPresent) {
+ if (ctx->Texture._EnabledCoordUnits ||
+ ctx->FragmentProgram._Current ||
+ ctx->ATIFragmentShader._Enabled) {
/* Ugh, we do a _lot_ of tests to pick the best textured tri func */
const struct gl_texture_object *texObj2D;
const struct gl_texture_image *texImg;
/* First see if we can use an optimized 2-D texture function */
if (ctx->Texture._EnabledCoordUnits == 0x1
- && !ctx->FragmentProgram._Enabled
+ && !ctx->FragmentProgram._Current
&& !ctx->ATIFragmentShader._Enabled
- && !ctx->ShaderObjects._FragmentShaderPresent
&& ctx->Texture.Unit[0]._ReallyEnabled == TEXTURE_2D_BIT
&& texObj2D->WrapS == GL_REPEAT
&& texObj2D->WrapT == GL_REPEAT
}
else {
/* general case textured triangles */
- if (ctx->Texture._EnabledCoordUnits > 1) {
+ if (ctx->Texture._EnabledCoordUnits > 1 ||
+ ctx->FragmentProgram._Current) {
USE(multitextured_triangle);
}
else {