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_span.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_span.c')
-rw-r--r-- | src/mesa/swrast/s_span.c | 38 |
1 files changed, 11 insertions, 27 deletions
diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c index ccdbe5f79c4..28f2f3d3fff 100644 --- a/src/mesa/swrast/s_span.c +++ b/src/mesa/swrast/s_span.c @@ -139,7 +139,8 @@ _swrast_span_default_attribs(struct gl_context *ctx, SWspan *span) for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) { const GLuint attr = FRAG_ATTRIB_TEX0 + i; const GLfloat *tc = ctx->Current.RasterTexCoords[i]; - if (ctx->FragmentProgram._Current || ctx->ATIFragmentShader._Enabled) { + if (_swrast_use_fragment_program(ctx) || + ctx->ATIFragmentShader._Enabled) { COPY_4V(span->attrStart[attr], tc); } else if (tc[3] > 0.0F) { @@ -498,7 +499,7 @@ interpolate_texcoords(struct gl_context *ctx, SWspan *span) swrast_texture_image_const(img); needLambda = (obj->Sampler.MinFilter != obj->Sampler.MagFilter) - || ctx->FragmentProgram._Current; + || _swrast_use_fragment_program(ctx); /* LOD is calculated directly in the ansiotropic filter, we can * skip the normal lambda function as the result is ignored. */ @@ -518,7 +519,7 @@ interpolate_texcoords(struct gl_context *ctx, SWspan *span) if (needLambda) { GLuint i; - if (ctx->FragmentProgram._Current + if (_swrast_use_fragment_program(ctx) || ctx->ATIFragmentShader._Enabled) { /* do perspective correction but don't divide s, t, r by q */ const GLfloat dwdx = span->attrStepX[FRAG_ATTRIB_WPOS][3]; @@ -559,7 +560,7 @@ interpolate_texcoords(struct gl_context *ctx, SWspan *span) } else { GLuint i; - if (ctx->FragmentProgram._Current || + if (_swrast_use_fragment_program(ctx) || ctx->ATIFragmentShader._Enabled) { /* do perspective correction but don't divide s, t, r by q */ const GLfloat dwdx = span->attrStepX[FRAG_ATTRIB_WPOS][3]; @@ -833,7 +834,7 @@ add_specular(struct gl_context *ctx, SWspan *span) GLfloat (*col1)[4] = span->array->attribs[FRAG_ATTRIB_COL1]; GLuint i; - ASSERT(!ctx->FragmentProgram._Current); + ASSERT(!_swrast_use_fragment_program(ctx)); ASSERT(span->arrayMask & SPAN_RGBA); ASSERT(swrast->_ActiveAttribMask & FRAG_BIT_COL1); (void) swrast; /* silence warning */ @@ -971,25 +972,7 @@ convert_color_type(SWspan *span, GLenum newType, GLuint output) static inline void shade_texture_span(struct gl_context *ctx, SWspan *span) { - /* This is a hack to work around drivers such as i965 that: - * - * - Set _MaintainTexEnvProgram to generate GLSL IR for - * fixed-function fragment processing. - * - Don't call _mesa_ir_link_shader to generate Mesa IR from - * the GLSL IR. - * - May use swrast to handle glDrawPixels. - * - * Since _mesa_ir_link_shader is never called, there is no Mesa IR - * to execute. Instead do regular fixed-function processing. - * - * It is also worth noting that the software fixed-function path is - * much faster than the software shader path. - */ - const bool use_fragment_program = - ctx->FragmentProgram._Current - && ctx->FragmentProgram._Current != ctx->FragmentProgram._TexEnvProgram; - - if (use_fragment_program || + if (_swrast_use_fragment_program(ctx) || ctx->ATIFragmentShader._Enabled) { /* programmable shading */ if (span->primitive == GL_BITMAP && span->array->ChanType != GL_FLOAT) { @@ -1018,7 +1001,7 @@ shade_texture_span(struct gl_context *ctx, SWspan *span) interpolate_wpos(ctx, span); /* Run fragment program/shader now */ - if (use_fragment_program) { + if (_swrast_use_fragment_program(ctx)) { _swrast_exec_fragment_program(ctx, span); } else { @@ -1151,7 +1134,7 @@ _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span) const GLbitfield64 origArrayAttribs = span->arrayAttribs; const GLenum origChanType = span->array->ChanType; void * const origRgba = span->array->rgba; - const GLboolean shader = (ctx->FragmentProgram._Current + const GLboolean shader = (_swrast_use_fragment_program(ctx) || ctx->ATIFragmentShader._Enabled); const GLboolean shaderOrTexture = shader || ctx->Texture._EnabledCoordUnits; struct gl_framebuffer *fb = ctx->DrawBuffer; @@ -1326,7 +1309,8 @@ _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span) const GLuint numBuffers = fb->_NumColorDrawBuffers; const struct gl_fragment_program *fp = ctx->FragmentProgram._Current; const GLboolean multiFragOutputs = - (fp && fp->Base.OutputsWritten >= (1 << FRAG_RESULT_DATA0)); + _swrast_use_fragment_program(ctx) + && fp->Base.OutputsWritten >= (1 << FRAG_RESULT_DATA0); GLuint buf; for (buf = 0; buf < numBuffers; buf++) { |