diff options
author | Chad Versace <[email protected]> | 2012-01-25 19:38:10 -0800 |
---|---|---|
committer | Chad Versace <[email protected]> | 2012-01-27 13:34:26 -0800 |
commit | 1c0f1dd42a50464eeb81de4aad8eecf24b3d6c89 (patch) | |
tree | 356acdc359c537d38265763a84552f712c45bc53 /src/mesa/swrast/s_context.c | |
parent | 5665b5cc31da70e833f80e7a17bfa034d2f7ba44 (diff) |
swrast: Fix fixed-function fragment processing
On i965, _mesa_ir_link_shader is never called. As a consequence, the
current fragment program (ctx->FragmentProgram->_Current) exists but is
invalid because it has no instructions. Yet swrast continued to attempt to
use the empty program.
To avoid using the empty program, this patch 1) defines a new function,
_swrast_use_fragment_program, which checks if the current fragment program
exists and differs from the fixed function fragment program, and, when
appropriate, 2) replaces checks of the form
if (ctx->FragmentProgram->_Current == NULL)
with
if (_swrast_use_fragment_program(ctx))
Fixes the following oglconform regressions on i965/gen6:
api-fogcoord(basic.allCases.log)
api-mtexcoord(basic.allCases.log)
api-seccolor(basic.allCases.log)
api-texcoord(basic.allCases.log)
blend-separate(basic.allCases)
colorsum(basic.allCases.log)
The tests were ran with the GLXFBConfig:
visual x bf lv rg d st colorbuffer sr ax dp st accumbuffer ms cav
id dep cl sp sz l ci b ro r g b a F gb bf th cl r g b a ns b eat
----------------------------------------------------------------------------
0x021 24 tc 0 32 0 r y . 8 8 8 8 . . 0 24 8 0 0 0 0 0 0 None
(Note: I originally believed that the hunk in
_swrast_update_fragment_program was unnecessary. But it is required to fix
blend-separate.)
Note: This is a candidate for the 8.0 branch.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=43327
Reveiwed-by: Eric Anholt <[email protected]>
Reviewed-by: Ian Romanick <[email protected]>
Signed-off-by: Chad Versace <[email protected]>
Diffstat (limited to 'src/mesa/swrast/s_context.c')
-rw-r--r-- | src/mesa/swrast/s_context.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c index 14cb9b180c3..cc304d70c06 100644 --- a/src/mesa/swrast/s_context.c +++ b/src/mesa/swrast/s_context.c @@ -105,7 +105,7 @@ _swrast_update_rasterflags( struct gl_context *ctx ) } - if (ctx->FragmentProgram._Current) { + if (_swrast_use_fragment_program(ctx)) { rasterMask |= FRAGPROG_BIT; } @@ -170,7 +170,7 @@ _swrast_update_fog_hint( struct gl_context *ctx ) { SWcontext *swrast = SWRAST_CONTEXT(ctx); swrast->_PreferPixelFog = (!swrast->AllowVertexFog || - ctx->FragmentProgram._Current || + _swrast_use_fragment_program(ctx) || (ctx->Hint.Fog == GL_NICEST && swrast->AllowPixelFog)); } @@ -220,13 +220,14 @@ _swrast_update_deferred_texture(struct gl_context *ctx) swrast->_DeferredTexture = GL_FALSE; } else { + GLboolean use_fprog = _swrast_use_fragment_program(ctx); const struct gl_fragment_program *fprog = ctx->FragmentProgram._Current; - if (fprog && (fprog->Base.OutputsWritten & (1 << FRAG_RESULT_DEPTH))) { + if (use_fprog && (fprog->Base.OutputsWritten & (1 << FRAG_RESULT_DEPTH))) { /* Z comes from fragment program/shader */ swrast->_DeferredTexture = GL_FALSE; } - else if (fprog && fprog->UsesKill) { + else if (use_fprog && fprog->UsesKill) { swrast->_DeferredTexture = GL_FALSE; } else if (ctx->Query.CurrentOcclusionObject) { @@ -254,7 +255,8 @@ _swrast_update_fog_state( struct gl_context *ctx ) (fp->Base.Target == GL_FRAGMENT_PROGRAM_NV)); /* determine if fog is needed, and if so, which fog mode */ - swrast->_FogEnabled = (fp == NULL && ctx->Fog.Enabled); + swrast->_FogEnabled = (!_swrast_use_fragment_program(ctx) && + ctx->Fog.Enabled); } @@ -265,10 +267,11 @@ _swrast_update_fog_state( struct gl_context *ctx ) static void _swrast_update_fragment_program(struct gl_context *ctx, GLbitfield newState) { - const struct gl_fragment_program *fp = ctx->FragmentProgram._Current; - if (fp) { - _mesa_load_state_parameters(ctx, fp->Base.Parameters); - } + if (!_swrast_use_fragment_program(ctx)) + return; + + _mesa_load_state_parameters(ctx, + ctx->FragmentProgram._Current->Base.Parameters); } @@ -286,7 +289,7 @@ _swrast_update_specular_vertex_add(struct gl_context *ctx) swrast->SpecularVertexAdd = (separateSpecular && ctx->Texture._EnabledUnits == 0x0 - && !ctx->FragmentProgram._Current + && !_swrast_use_fragment_program(ctx) && !ctx->ATIFragmentShader._Enabled); } @@ -497,7 +500,7 @@ _swrast_update_active_attribs(struct gl_context *ctx) /* * Compute _ActiveAttribsMask = which fragment attributes are needed. */ - if (ctx->FragmentProgram._Current) { + if (_swrast_use_fragment_program(ctx)) { /* fragment program/shader */ attribsMask = ctx->FragmentProgram._Current->Base.InputsRead; attribsMask &= ~FRAG_BIT_WPOS; /* WPOS is always handled specially */ |