summaryrefslogtreecommitdiffstats
path: root/src/mesa/swrast
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2005-05-04 11:44:44 +0000
committerKeith Whitwell <[email protected]>2005-05-04 11:44:44 +0000
commit47b29f511a8e917c65536fde90397d54d2ad23d3 (patch)
treec8db61607defe55b4540af3e4614df9831d2021d /src/mesa/swrast
parentc3f764f7bb5a0571ddb0bc8b37aff9d663188d79 (diff)
Add a facility to route all rasterization through a fragment program
which is automatically generated to match the current texture environment state. Introduces a new value ctx->FragmentProgram._Active which is true when either _Enabled is true or there is such a fragment program ready to run. To test out on a driver running the software rasterizer, set MESA_TEX_PROG=t in the environment. It goes without saying that performance is lower for the software rasterizer in this mode.
Diffstat (limited to 'src/mesa/swrast')
-rw-r--r--src/mesa/swrast/s_aalinetemp.h4
-rw-r--r--src/mesa/swrast/s_context.c20
-rw-r--r--src/mesa/swrast/s_fragprog_to_c.c2
-rw-r--r--src/mesa/swrast/s_nvfragprog.c4
-rw-r--r--src/mesa/swrast/s_pointtemp.h2
-rw-r--r--src/mesa/swrast/s_span.c20
-rw-r--r--src/mesa/swrast/s_triangle.c4
7 files changed, 28 insertions, 28 deletions
diff --git a/src/mesa/swrast/s_aalinetemp.h b/src/mesa/swrast/s_aalinetemp.h
index aa78ef7b596..4a1e1ebda2a 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._Enabled) {
+ if (ctx->FragmentProgram._Active) {
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._Enabled) {
+ if (ctx->FragmentProgram._Active) {
invQ = 1.0F;
}
else {
diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c
index b923f0a673e..f6dcdbb9644 100644
--- a/src/mesa/swrast/s_context.c
+++ b/src/mesa/swrast/s_context.c
@@ -104,7 +104,7 @@ _swrast_update_rasterflags( GLcontext *ctx )
rasterMask |= MULTI_DRAW_BIT; /* all color index bits disabled */
}
- if (ctx->FragmentProgram._Enabled) {
+ if (ctx->FragmentProgram._Active) {
rasterMask |= FRAGPROG_BIT;
}
@@ -161,7 +161,7 @@ _swrast_update_fog_hint( GLcontext *ctx )
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
swrast->_PreferPixelFog = (!swrast->AllowVertexFog ||
- ctx->FragmentProgram._Enabled ||
+ ctx->FragmentProgram._Active ||
(ctx->Hint.Fog == GL_NICEST &&
swrast->AllowPixelFog));
}
@@ -202,10 +202,10 @@ _swrast_update_fog_state( GLcontext *ctx )
/* 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) {
+ if (ctx->FragmentProgram._Active) {
+ if (ctx->FragmentProgram._Current->Base.Target==GL_FRAGMENT_PROGRAM_ARB) {
const struct fragment_program *p
- = (struct fragment_program *) ctx->FragmentProgram.Current;
+ = (struct fragment_program *) ctx->FragmentProgram._Current;
if (p->FogOption != GL_NONE) {
swrast->_FogEnabled = GL_TRUE;
swrast->_FogMode = p->FogOption;
@@ -226,8 +226,8 @@ _swrast_update_fog_state( GLcontext *ctx )
static void
_swrast_update_fragment_program( GLcontext *ctx )
{
- if (ctx->FragmentProgram._Enabled) {
- struct fragment_program *program = ctx->FragmentProgram.Current;
+ if (ctx->FragmentProgram._Active) {
+ struct fragment_program *program = ctx->FragmentProgram._Current;
_mesa_load_state_parameters(ctx, program->Parameters);
}
}
@@ -295,7 +295,7 @@ _swrast_validate_triangle( GLcontext *ctx,
if (ctx->Texture._EnabledUnits == 0
&& NEED_SECONDARY_COLOR(ctx)
- && !ctx->FragmentProgram._Enabled) {
+ && !ctx->FragmentProgram._Active) {
/* separate specular color, but no texture */
swrast->SpecTriangle = swrast->Triangle;
swrast->Triangle = _swrast_add_spec_terms_triangle;
@@ -318,7 +318,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._Active) {
swrast->SpecLine = swrast->Line;
swrast->Line = _swrast_add_spec_terms_line;
}
@@ -341,7 +341,7 @@ _swrast_validate_point( GLcontext *ctx, const SWvertex *v0 )
if (ctx->Texture._EnabledUnits == 0
&& NEED_SECONDARY_COLOR(ctx)
- && !ctx->FragmentProgram._Enabled) {
+ && !ctx->FragmentProgram._Active) {
swrast->SpecPoint = swrast->Point;
swrast->Point = _swrast_add_spec_terms_point;
}
diff --git a/src/mesa/swrast/s_fragprog_to_c.c b/src/mesa/swrast/s_fragprog_to_c.c
index fa669693307..1953e8c73cc 100644
--- a/src/mesa/swrast/s_fragprog_to_c.c
+++ b/src/mesa/swrast/s_fragprog_to_c.c
@@ -808,7 +808,7 @@ static void translate_program( struct fragment_program *p )
void _swrast_translate_program( GLcontext *ctx )
{
- struct fragment_program *p = ctx->FragmentProgram.Current;
+ struct fragment_program *p = ctx->FragmentProgram._Current;
if (p) {
p->c_strlen = 0;
diff --git a/src/mesa/swrast/s_nvfragprog.c b/src/mesa/swrast/s_nvfragprog.c
index 2fea568cc90..51d36c0a2b5 100644
--- a/src/mesa/swrast/s_nvfragprog.c
+++ b/src/mesa/swrast/s_nvfragprog.c
@@ -1410,7 +1410,7 @@ init_machine( GLcontext *ctx, struct fp_machine *machine,
void
_swrast_exec_fragment_program( GLcontext *ctx, struct sw_span *span )
{
- const struct fragment_program *program = ctx->FragmentProgram.Current;
+ const struct fragment_program *program = ctx->FragmentProgram._Current;
GLuint i;
ctx->_CurrentProgram = GL_FRAGMENT_PROGRAM_ARB; /* or NV, doesn't matter */
@@ -1418,7 +1418,7 @@ _swrast_exec_fragment_program( GLcontext *ctx, struct sw_span *span )
for (i = 0; i < span->end; i++) {
if (span->array->mask[i]) {
init_machine(ctx, &ctx->FragmentProgram.Machine,
- ctx->FragmentProgram.Current, span, i);
+ ctx->FragmentProgram._Current, span, i);
#ifdef USE_TCC
if (!_swrast_execute_codegen_program(ctx, program, ~0,
diff --git a/src/mesa/swrast/s_pointtemp.h b/src/mesa/swrast/s_pointtemp.h
index ef48d239ec4..b0c110f3007 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;
- if (ctx->FragmentProgram._Enabled) {
+ if (ctx->FragmentProgram._Active) {
/* 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 a541b66ceb5..e6afee1eaa0 100644
--- a/src/mesa/swrast/s_span.c
+++ b/src/mesa/swrast/s_span.c
@@ -128,7 +128,7 @@ _swrast_span_default_texcoords( GLcontext *ctx, struct sw_span *span )
GLuint i;
for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
const GLfloat *tc = ctx->Current.RasterTexCoords[i];
- if (ctx->FragmentProgram._Enabled || ctx->ATIFragmentShader._Enabled) {
+ if (ctx->FragmentProgram._Active || ctx->ATIFragmentShader._Enabled) {
COPY_4V(span->tex[i], tc);
}
else if (tc[3] > 0.0F) {
@@ -406,7 +406,7 @@ interpolate_texcoords(GLcontext *ctx, struct sw_span *span)
if (obj) {
const struct gl_texture_image *img = obj->Image[0][obj->BaseLevel];
needLambda = (obj->MinFilter != obj->MagFilter)
- || ctx->FragmentProgram._Enabled;
+ || ctx->FragmentProgram._Active;
texW = img->WidthScale;
texH = img->HeightScale;
}
@@ -431,7 +431,7 @@ interpolate_texcoords(GLcontext *ctx, struct sw_span *span)
GLfloat r = span->tex[u][2];
GLfloat q = span->tex[u][3];
GLuint i;
- if (ctx->FragmentProgram._Enabled) {
+ if (ctx->FragmentProgram._Active) {
/* do perspective correction but don't divide s, t, r by q */
const GLfloat dwdx = span->dwdx;
GLfloat w = span->w;
@@ -482,7 +482,7 @@ interpolate_texcoords(GLcontext *ctx, struct sw_span *span)
GLfloat r = span->tex[u][2];
GLfloat q = span->tex[u][3];
GLuint i;
- if (ctx->FragmentProgram._Enabled) {
+ if (ctx->FragmentProgram._Active) {
/* do perspective correction but don't divide s, t, r by q */
const GLfloat dwdx = span->dwdx;
GLfloat w = span->w;
@@ -540,7 +540,7 @@ interpolate_texcoords(GLcontext *ctx, struct sw_span *span)
if (obj) {
const struct gl_texture_image *img = obj->Image[0][obj->BaseLevel];
needLambda = (obj->MinFilter != obj->MagFilter)
- || ctx->FragmentProgram._Enabled;
+ || ctx->FragmentProgram._Active;
texW = (GLfloat) img->WidthScale;
texH = (GLfloat) img->HeightScale;
}
@@ -565,7 +565,7 @@ interpolate_texcoords(GLcontext *ctx, struct sw_span *span)
GLfloat r = span->tex[0][2];
GLfloat q = span->tex[0][3];
GLuint i;
- if (ctx->FragmentProgram._Enabled) {
+ if (ctx->FragmentProgram._Active) {
/* do perspective correction but don't divide s, t, r by q */
const GLfloat dwdx = span->dwdx;
GLfloat w = span->w;
@@ -616,7 +616,7 @@ interpolate_texcoords(GLcontext *ctx, struct sw_span *span)
GLfloat r = span->tex[0][2];
GLfloat q = span->tex[0][3];
GLuint i;
- if (ctx->FragmentProgram._Enabled) {
+ if (ctx->FragmentProgram._Active) {
/* do perspective correction but don't divide s, t, r by q */
const GLfloat dwdx = span->dwdx;
GLfloat w = span->w;
@@ -1174,7 +1174,7 @@ _swrast_write_rgba_span( GLcontext *ctx, struct sw_span *span)
interpolate_fog(ctx, span);
/* Compute fragment colors with fragment program or texture lookups */
- if (ctx->FragmentProgram._Enabled)
+ if (ctx->FragmentProgram._Active)
/* XXX interpolate depth values here??? */
_swrast_exec_fragment_program( ctx, span );
else if (ctx->ATIFragmentShader._Enabled)
@@ -1252,7 +1252,7 @@ _swrast_write_rgba_span( GLcontext *ctx, struct sw_span *span)
if (span->interpMask & SPAN_FOG)
interpolate_fog(ctx, span);
- if (ctx->FragmentProgram._Enabled)
+ if (ctx->FragmentProgram._Active)
_swrast_exec_fragment_program( ctx, span );
else if (ctx->ATIFragmentShader._Enabled)
_swrast_exec_fragment_shader( ctx, span );
@@ -1262,7 +1262,7 @@ _swrast_write_rgba_span( GLcontext *ctx, struct sw_span *span)
ASSERT(span->arrayMask & SPAN_RGBA);
- if (!ctx->FragmentProgram._Enabled) {
+ if (!ctx->FragmentProgram._Active) {
/* Add base and specular colors */
if (ctx->Fog.ColorSumEnabled ||
(ctx->Light.Enabled &&
diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c
index c236e525709..4533980455e 100644
--- a/src/mesa/swrast/s_triangle.c
+++ b/src/mesa/swrast/s_triangle.c
@@ -1075,7 +1075,7 @@ _swrast_choose_triangle( GLcontext *ctx )
}
}
- if (ctx->Texture._EnabledCoordUnits || ctx->FragmentProgram._Enabled) {
+ if (ctx->Texture._EnabledCoordUnits || ctx->FragmentProgram._Active) {
/* 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;
@@ -1090,7 +1090,7 @@ _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._Active
&& ctx->Texture.Unit[0]._ReallyEnabled == TEXTURE_2D_BIT
&& texObj2D->WrapS == GL_REPEAT
&& texObj2D->WrapT == GL_REPEAT