diff options
author | Brian <brian@yutani.localnet.net> | 2006-12-13 15:05:23 -0700 |
---|---|---|
committer | Brian <brian@yutani.localnet.net> | 2006-12-13 15:05:23 -0700 |
commit | 12ef1fbefcee964b715783d3ade6b69b2c699ed8 (patch) | |
tree | 4daf73a2c8aec72103b064c48b98c34a249771a6 /src/mesa/swrast | |
parent | a328e469d328f8b6fd5afdfc21d576fa1a2c43fc (diff) |
Checkpoint for GLSL compiler changes.
In brief:
Check for enabled fragment program by looking at ctx->FragmentProgram._Current.
New code for varying variables.
Diffstat (limited to 'src/mesa/swrast')
-rw-r--r-- | src/mesa/swrast/s_aalinetemp.h | 4 | ||||
-rw-r--r-- | src/mesa/swrast/s_context.c | 27 | ||||
-rw-r--r-- | src/mesa/swrast/s_nvfragprog.c | 41 | ||||
-rw-r--r-- | src/mesa/swrast/s_pointtemp.h | 2 | ||||
-rw-r--r-- | src/mesa/swrast/s_span.c | 48 | ||||
-rw-r--r-- | src/mesa/swrast/s_triangle.c | 15 |
6 files changed, 76 insertions, 61 deletions
diff --git a/src/mesa/swrast/s_aalinetemp.h b/src/mesa/swrast/s_aalinetemp.h index 34c95fc34e..68291afeea 100644 --- a/src/mesa/swrast/s_aalinetemp.h +++ b/src/mesa/swrast/s_aalinetemp.h @@ -80,7 +80,7 @@ NAME(plot)(GLcontext *ctx, struct LineInfo *line, int ix, int iy) #ifdef DO_TEX { GLfloat invQ; - if (ctx->FragmentProgram._Active) { + if (ctx->FragmentProgram._Current) { invQ = 1.0F; } else { @@ -100,7 +100,7 @@ NAME(plot)(GLcontext *ctx, struct LineInfo *line, int ix, int iy) 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 { diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c index 52d560ffdb..e304789154 100644 --- a/src/mesa/swrast/s_context.c +++ b/src/mesa/swrast/s_context.c @@ -98,7 +98,7 @@ _swrast_update_rasterflags( GLcontext *ctx ) rasterMask |= MULTI_DRAW_BIT; /* all color index bits disabled */ } - if (ctx->FragmentProgram._Enabled) { + if (ctx->FragmentProgram._Current) { rasterMask |= FRAGPROG_BIT; } @@ -165,7 +165,7 @@ _swrast_update_fog_hint( GLcontext *ctx ) { SWcontext *swrast = SWRAST_CONTEXT(ctx); swrast->_PreferPixelFog = (!swrast->AllowVertexFog || - ctx->FragmentProgram._Enabled || /* not _Active! */ + ctx->FragmentProgram._Current || (ctx->Hint.Fog == GL_NICEST && swrast->AllowPixelFog)); } @@ -198,17 +198,14 @@ static void _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) { @@ -225,8 +222,8 @@ _swrast_update_fog_state( GLcontext *ctx ) 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. @@ -301,7 +298,7 @@ _swrast_validate_triangle( GLcontext *ctx, 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; @@ -325,7 +322,7 @@ _swrast_validate_line( GLcontext *ctx, const SWvertex *v0, const SWvertex *v1 ) 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; } @@ -348,7 +345,7 @@ _swrast_validate_point( GLcontext *ctx, const SWvertex *v0 ) 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; } diff --git a/src/mesa/swrast/s_nvfragprog.c b/src/mesa/swrast/s_nvfragprog.c index 028ddc0090..df583bb29c 100644 --- a/src/mesa/swrast/s_nvfragprog.c +++ b/src/mesa/swrast/s_nvfragprog.c @@ -53,9 +53,9 @@ */ 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 */ @@ -161,14 +161,14 @@ get_register_pointer( GLcontext *ctx, { 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); @@ -180,6 +180,8 @@ get_register_pointer( GLcontext *ctx, /* 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]; @@ -539,7 +541,7 @@ init_machine_deriv( GLcontext *ctx, const SWspan *span, char xOrY, struct fp_machine *dMachine ) { - GLuint u; + GLuint u, v; ASSERT(xOrY == 'X' || xOrY == 'Y'); @@ -626,6 +628,17 @@ init_machine_deriv( GLcontext *ctx, } } + 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; @@ -1531,7 +1544,7 @@ init_machine( GLcontext *ctx, struct fp_machine *machine, const SWspan *span, GLuint col ) { GLuint inputsRead = program->Base.InputsRead; - GLuint u; + GLuint u, v; if (ctx->FragmentProgram.CallbackEnabled) inputsRead = ~0; @@ -1583,6 +1596,18 @@ init_machine( GLcontext *ctx, struct fp_machine *machine, /*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; diff --git a/src/mesa/swrast/s_pointtemp.h b/src/mesa/swrast/s_pointtemp.h index 6316833a68..b41776b017 100644 --- a/src/mesa/swrast/s_pointtemp.h +++ b/src/mesa/swrast/s_pointtemp.h @@ -120,7 +120,7 @@ NAME ( GLcontext *ctx, const SWvertex *vert ) #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)) { diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c index c74b98facf..69ecfa9558 100644 --- a/src/mesa/swrast/s_span.c +++ b/src/mesa/swrast/s_span.c @@ -130,7 +130,7 @@ _swrast_span_default_texcoords( GLcontext *ctx, SWspan *span ) 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) { @@ -555,7 +555,7 @@ interpolate_texcoords(GLcontext *ctx, SWspan *span) 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; } @@ -580,8 +580,8 @@ interpolate_texcoords(GLcontext *ctx, SWspan *span) 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; @@ -632,8 +632,8 @@ interpolate_texcoords(GLcontext *ctx, SWspan *span) 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; @@ -691,7 +691,7 @@ interpolate_texcoords(GLcontext *ctx, SWspan *span) 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; } @@ -716,8 +716,8 @@ interpolate_texcoords(GLcontext *ctx, SWspan *span) 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; @@ -768,8 +768,8 @@ interpolate_texcoords(GLcontext *ctx, SWspan *span) 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; @@ -1340,8 +1340,7 @@ shade_texture_span(GLcontext *ctx, SWspan *span) 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 */ @@ -1367,12 +1366,11 @@ shade_texture_span(GLcontext *ctx, SWspan *span) 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 { @@ -1403,10 +1401,8 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span) 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; @@ -1429,20 +1425,16 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span) 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; diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c index b17c435460..9b775928cd 100644 --- a/src/mesa/swrast/s_triangle.c +++ b/src/mesa/swrast/s_triangle.c @@ -883,8 +883,8 @@ fast_persp_span(GLcontext *ctx, SWspan *span, /* * 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 @@ -1073,8 +1073,9 @@ _swrast_choose_triangle( GLcontext *ctx ) } } - 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; @@ -1089,9 +1090,8 @@ _swrast_choose_triangle( GLcontext *ctx ) /* 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 @@ -1137,7 +1137,8 @@ _swrast_choose_triangle( GLcontext *ctx ) } else { /* general case textured triangles */ - if (ctx->Texture._EnabledCoordUnits > 1) { + if (ctx->Texture._EnabledCoordUnits > 1 || + ctx->FragmentProgram._Current) { USE(multitextured_triangle); } else { |