X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fdrivers%2Fdri%2Fi915%2Fi915_state.c;h=4c83073e6927e634786b06d2677d007f4078749e;hb=0febd0ecfd1e2a36381ab7793811b9c7891ed82f;hp=3b1af4c455e2f90a3125621ecff31eb99e98edc9;hpb=2bf95c519e755146704f4942b1703d47d18bfeaa;p=mesa.git diff --git a/src/mesa/drivers/dri/i915/i915_state.c b/src/mesa/drivers/dri/i915/i915_state.c index 3b1af4c455e..4c83073e692 100644 --- a/src/mesa/drivers/dri/i915/i915_state.c +++ b/src/mesa/drivers/dri/i915/i915_state.c @@ -1,6 +1,6 @@ /************************************************************************** * - * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. + * Copyright 2003 VMware, Inc. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -18,7 +18,7 @@ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -30,13 +30,14 @@ #include "main/context.h" #include "main/macros.h" #include "main/enums.h" +#include "main/fbobject.h" #include "main/dd.h" #include "main/state.h" +#include "main/stencil.h" +#include "main/viewport.h" #include "tnl/tnl.h" #include "tnl/t_context.h" -#include "texmem.h" - #include "drivers/common/driverfuncs.h" #include "intel_fbo.h" @@ -64,14 +65,14 @@ i915_update_stencil(struct gl_context * ctx) */ /* _NEW_POLYGON | _NEW_STENCIL */ if (ctx->Polygon.FrontFace == GL_CW) { - front_ref = ctx->Stencil.Ref[0]; + front_ref = _mesa_get_stencil_ref(ctx, 0); front_mask = ctx->Stencil.ValueMask[0]; front_writemask = ctx->Stencil.WriteMask[0]; front_func = ctx->Stencil.Function[0]; front_fail = ctx->Stencil.FailFunc[0]; front_pass_z_fail = ctx->Stencil.ZFailFunc[0]; front_pass_z_pass = ctx->Stencil.ZPassFunc[0]; - back_ref = ctx->Stencil.Ref[ctx->Stencil._BackFace]; + back_ref = _mesa_get_stencil_ref(ctx, ctx->Stencil._BackFace); back_mask = ctx->Stencil.ValueMask[ctx->Stencil._BackFace]; back_writemask = ctx->Stencil.WriteMask[ctx->Stencil._BackFace]; back_func = ctx->Stencil.Function[ctx->Stencil._BackFace]; @@ -79,14 +80,14 @@ i915_update_stencil(struct gl_context * ctx) back_pass_z_fail = ctx->Stencil.ZFailFunc[ctx->Stencil._BackFace]; back_pass_z_pass = ctx->Stencil.ZPassFunc[ctx->Stencil._BackFace]; } else { - front_ref = ctx->Stencil.Ref[ctx->Stencil._BackFace]; + front_ref = _mesa_get_stencil_ref(ctx, ctx->Stencil._BackFace); front_mask = ctx->Stencil.ValueMask[ctx->Stencil._BackFace]; front_writemask = ctx->Stencil.WriteMask[ctx->Stencil._BackFace]; front_func = ctx->Stencil.Function[ctx->Stencil._BackFace]; front_fail = ctx->Stencil.FailFunc[ctx->Stencil._BackFace]; front_pass_z_fail = ctx->Stencil.ZFailFunc[ctx->Stencil._BackFace]; front_pass_z_pass = ctx->Stencil.ZPassFunc[ctx->Stencil._BackFace]; - back_ref = ctx->Stencil.Ref[0]; + back_ref = _mesa_get_stencil_ref(ctx, 0); back_mask = ctx->Stencil.ValueMask[0]; back_writemask = ctx->Stencil.WriteMask[0]; back_func = ctx->Stencil.Function[0]; @@ -196,9 +197,9 @@ i915AlphaFunc(struct gl_context * ctx, GLenum func, GLfloat ref) } /* This function makes sure that the proper enables are - * set for LogicOp, Independant Alpha Blend, and Blending. + * set for LogicOp, Independent Alpha Blend, and Blending. * It needs to be called from numerous places where we - * could change the LogicOp or Independant Alpha Blend without subsequent + * could change the LogicOp or Independent Alpha Blend without subsequent * calls to glEnable. */ static void @@ -210,7 +211,7 @@ i915EvalLogicOpBlendState(struct gl_context * ctx) dw0 = i915->state.Ctx[I915_CTXREG_LIS5]; dw1 = i915->state.Ctx[I915_CTXREG_LIS6]; - if (_mesa_rgba_logicop_enabled(ctx)) { + if (ctx->Color.ColorLogicOpEnabled) { dw0 |= S5_LOGICOP_ENABLE; dw1 &= ~S6_CBUF_BLEND_ENABLE; } @@ -240,7 +241,7 @@ i915BlendColor(struct gl_context * ctx, const GLfloat color[4]) GLubyte r, g, b, a; GLuint dw; - DBG("%s\n", __FUNCTION__); + DBG("%s\n", __func__); UNCLAMPED_FLOAT_TO_UBYTE(r, color[RCOMP]); UNCLAMPED_FLOAT_TO_UBYTE(g, color[GCOMP]); @@ -356,7 +357,7 @@ i915DepthFunc(struct gl_context * ctx, GLenum func) int test = intel_translate_compare_func(func); GLuint dw; - DBG("%s\n", __FUNCTION__); + DBG("%s\n", __func__); dw = i915->state.Ctx[I915_CTXREG_LIS6]; dw &= ~S6_DEPTH_TEST_FUNC_MASK; @@ -373,7 +374,10 @@ i915DepthMask(struct gl_context * ctx, GLboolean flag) struct i915_context *i915 = I915_CONTEXT(ctx); GLuint dw; - DBG("%s flag (%d)\n", __FUNCTION__, flag); + DBG("%s flag (%d)\n", __func__, flag); + + if (!ctx->DrawBuffer || !ctx->DrawBuffer->Visual.depthBits) + flag = false; dw = i915->state.Ctx[I915_CTXREG_LIS6]; if (flag && ctx->Depth.Test) @@ -398,46 +402,23 @@ void intelCalcViewport(struct gl_context * ctx) { struct intel_context *intel = intel_context(ctx); - const GLfloat *v = ctx->Viewport._WindowMap.m; - const GLfloat depthScale = 1.0F / ctx->DrawBuffer->_DepthMaxF; - GLfloat *m = intel->ViewportMatrix.m; - GLfloat yScale, yBias; - - if (ctx->DrawBuffer->Name) { - /* User created FBO */ - /* y=0=bottom */ - yScale = 1.0; - yBias = 0.0; - } - else { - /* window buffer, y=0=top */ - yScale = -1.0; - yBias = ctx->DrawBuffer->Height; - } - - m[MAT_SX] = v[MAT_SX]; - m[MAT_TX] = v[MAT_TX]; - - m[MAT_SY] = v[MAT_SY] * yScale; - m[MAT_TY] = v[MAT_TY] * yScale + yBias; + float scale[3], translate[3]; - m[MAT_SZ] = v[MAT_SZ] * depthScale; - m[MAT_TZ] = v[MAT_TZ] * depthScale; -} + _mesa_get_viewport_xform(ctx, 0, scale, translate); + if (_mesa_is_winsys_fbo(ctx->DrawBuffer)) { + scale[1] = -scale[1]; + translate[1] = ctx->DrawBuffer->Height - translate[1]; + } -/** Called from ctx->Driver.Viewport() */ -static void -i915Viewport(struct gl_context * ctx, - GLint x, GLint y, GLsizei width, GLsizei height) -{ - intelCalcViewport(ctx); + _math_matrix_viewport(&intel->ViewportMatrix, + scale, translate, 1.0); } /** Called from ctx->Driver.DepthRange() */ static void -i915DepthRange(struct gl_context * ctx, GLclampd nearval, GLclampd farval) +i915DepthRange(struct gl_context *ctx) { intelCalcViewport(ctx); } @@ -512,7 +493,7 @@ i915PolygonStipple(struct gl_context * ctx, const GLubyte * mask) * Hardware clipping */ static void -i915Scissor(struct gl_context * ctx, GLint x, GLint y, GLsizei w, GLsizei h) +i915Scissor(struct gl_context * ctx) { struct i915_context *i915 = I915_CONTEXT(ctx); int x1, y1, x2, y2; @@ -520,23 +501,29 @@ i915Scissor(struct gl_context * ctx, GLint x, GLint y, GLsizei w, GLsizei h) if (!ctx->DrawBuffer) return; - DBG("%s %d,%d %dx%d\n", __FUNCTION__, x, y, w, h); - - if (ctx->DrawBuffer->Name == 0) { - x1 = x; - y1 = ctx->DrawBuffer->Height - (y + h); - x2 = x + w - 1; - y2 = y1 + h - 1; - DBG("%s %d..%d,%d..%d (inverted)\n", __FUNCTION__, x1, x2, y1, y2); + DBG("%s %d,%d %dx%d\n", __func__, + ctx->Scissor.ScissorArray[0].X, ctx->Scissor.ScissorArray[0].Y, + ctx->Scissor.ScissorArray[0].Width, ctx->Scissor.ScissorArray[0].Height); + + if (_mesa_is_winsys_fbo(ctx->DrawBuffer)) { + x1 = ctx->Scissor.ScissorArray[0].X; + y1 = ctx->DrawBuffer->Height - (ctx->Scissor.ScissorArray[0].Y + + ctx->Scissor.ScissorArray[0].Height); + x2 = ctx->Scissor.ScissorArray[0].X + + ctx->Scissor.ScissorArray[0].Width - 1; + y2 = y1 + ctx->Scissor.ScissorArray[0].Height - 1; + DBG("%s %d..%d,%d..%d (inverted)\n", __func__, x1, x2, y1, y2); } else { /* FBO - not inverted */ - x1 = x; - y1 = y; - x2 = x + w - 1; - y2 = y + h - 1; - DBG("%s %d..%d,%d..%d (not inverted)\n", __FUNCTION__, x1, x2, y1, y2); + x1 = ctx->Scissor.ScissorArray[0].X; + y1 = ctx->Scissor.ScissorArray[0].Y; + x2 = ctx->Scissor.ScissorArray[0].X + + ctx->Scissor.ScissorArray[0].Width - 1; + y2 = ctx->Scissor.ScissorArray[0].Y + + ctx->Scissor.ScissorArray[0].Height - 1; + DBG("%s %d..%d,%d..%d (not inverted)\n", __func__, x1, x2, y1, y2); } x1 = CLAMP(x1, 0, ctx->DrawBuffer->Width - 1); @@ -544,7 +531,7 @@ i915Scissor(struct gl_context * ctx, GLint x, GLint y, GLsizei w, GLsizei h) x2 = CLAMP(x2, 0, ctx->DrawBuffer->Width - 1); y2 = CLAMP(y2, 0, ctx->DrawBuffer->Height - 1); - DBG("%s %d..%d,%d..%d (clamped)\n", __FUNCTION__, x1, x2, y1, y2); + DBG("%s %d..%d,%d..%d (clamped)\n", __func__, x1, x2, y1, y2); I915_STATECHANGE(i915, I915_UPLOAD_BUFFERS); i915->state.Buffer[I915_DESTREG_SR1] = (y1 << 16) | (x1 & 0xffff); @@ -557,7 +544,7 @@ i915LogicOp(struct gl_context * ctx, GLenum opcode) struct i915_context *i915 = I915_CONTEXT(ctx); int tmp = intel_translate_logic_op(opcode); - DBG("%s\n", __FUNCTION__); + DBG("%s\n", __func__); I915_STATECHANGE(i915, I915_UPLOAD_CTX); i915->state.Ctx[I915_CTXREG_STATE4] &= ~LOGICOP_MASK; @@ -572,7 +559,7 @@ i915CullFaceFrontFace(struct gl_context * ctx, GLenum unused) struct i915_context *i915 = I915_CONTEXT(ctx); GLuint mode, dw; - DBG("%s %d\n", __FUNCTION__, + DBG("%s %d\n", __func__, ctx->DrawBuffer ? ctx->DrawBuffer->Name : 0); if (!ctx->Polygon.CullFlag) { @@ -581,7 +568,7 @@ i915CullFaceFrontFace(struct gl_context * ctx, GLenum unused) else if (ctx->Polygon.CullFaceMode != GL_FRONT_AND_BACK) { mode = S4_CULLMODE_CW; - if (ctx->DrawBuffer && ctx->DrawBuffer->Name != 0) + if (ctx->DrawBuffer && _mesa_is_user_fbo(ctx->DrawBuffer)) mode ^= (S4_CULLMODE_CW ^ S4_CULLMODE_CCW); if (ctx->Polygon.CullFaceMode == GL_FRONT) mode ^= (S4_CULLMODE_CW ^ S4_CULLMODE_CCW); @@ -608,7 +595,7 @@ i915LineWidth(struct gl_context * ctx, GLfloat widthf) int lis4 = i915->state.Ctx[I915_CTXREG_LIS4] & ~S4_LINE_WIDTH_MASK; int width; - DBG("%s\n", __FUNCTION__); + DBG("%s\n", __func__); width = (int) (widthf * 2); width = CLAMP(width, 1, 0xf); @@ -627,7 +614,7 @@ i915PointSize(struct gl_context * ctx, GLfloat size) int lis4 = i915->state.Ctx[I915_CTXREG_LIS4] & ~S4_POINT_WIDTH_MASK; GLint point_size = (int) round(size); - DBG("%s\n", __FUNCTION__); + DBG("%s\n", __func__); point_size = CLAMP(point_size, 1, 255); lis4 |= point_size << S4_POINT_WIDTH_SHIFT; @@ -656,6 +643,48 @@ i915PointParameterfv(struct gl_context * ctx, GLenum pname, const GLfloat *param } } +void +i915_update_sprite_point_enable(struct gl_context *ctx) +{ + struct intel_context *intel = intel_context(ctx); + /* _NEW_PROGRAM */ + struct i915_fragment_program *p = + (struct i915_fragment_program *) ctx->FragmentProgram._Current; + const GLbitfield64 inputsRead = p->FragProg.Base.InputsRead; + struct i915_context *i915 = i915_context(ctx); + GLuint s4 = i915->state.Ctx[I915_CTXREG_LIS4] & ~S4_VFMT_MASK; + int i; + GLuint coord_replace_bits = 0x0; + GLuint tex_coord_unit_bits = 0x0; + + for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) { + /* _NEW_POINT */ + if (ctx->Point.CoordReplace[i] && ctx->Point.PointSprite) + coord_replace_bits |= (1 << i); + if (inputsRead & VARYING_BIT_TEX(i)) + tex_coord_unit_bits |= (1 << i); + } + + /* + * Here we can't enable the SPRITE_POINT_ENABLE bit when the mis-match + * of tex_coord_unit_bits and coord_replace_bits, or this will make all + * the other non-point-sprite coords(like varying inputs, as we now use + * tex coord to implement varying inputs) be replaced to value (0, 0)-(1, 1). + * + * Thus, do fallback when needed. + */ + FALLBACK(intel, I915_FALLBACK_COORD_REPLACE, + coord_replace_bits && coord_replace_bits != tex_coord_unit_bits); + + s4 &= ~S4_SPRITE_POINT_ENABLE; + s4 |= (coord_replace_bits && coord_replace_bits == tex_coord_unit_bits) ? + S4_SPRITE_POINT_ENABLE : 0; + if (s4 != i915->state.Ctx[I915_CTXREG_LIS4]) { + i915->state.Ctx[I915_CTXREG_LIS4] = s4; + I915_STATECHANGE(i915, I915_UPLOAD_CTX); + } +} + /* ============================================================= * Color masks @@ -668,7 +697,7 @@ i915ColorMask(struct gl_context * ctx, struct i915_context *i915 = I915_CONTEXT(ctx); GLuint tmp = i915->state.Ctx[I915_CTXREG_LIS5] & ~S5_WRITEDISABLE_MASK; - DBG("%s r(%d) g(%d) b(%d) a(%d)\n", __FUNCTION__, r, g, b, + DBG("%s r(%d) g(%d) b(%d) a(%d)\n", __func__, r, g, b, a); if (!r) @@ -697,7 +726,7 @@ update_specular(struct gl_context * ctx) static void i915LightModelfv(struct gl_context * ctx, GLenum pname, const GLfloat * param) { - DBG("%s\n", __FUNCTION__); + DBG("%s\n", __func__); if (pname == GL_LIGHT_MODEL_COLOR_CONTROL) { update_specular(ctx); @@ -724,157 +753,17 @@ i915ShadeModel(struct gl_context * ctx, GLenum mode) /* ============================================================= * Fog + * + * This empty function remains because _mesa_init_driver_state calls + * dd_function_table::Fogfv unconditionally. We have to have some function + * there so that it doesn't try to call a NULL pointer. */ -void -i915_update_fog(struct gl_context * ctx) -{ - struct i915_context *i915 = I915_CONTEXT(ctx); - GLenum mode; - GLboolean enabled; - GLboolean try_pixel_fog; - GLuint dw; - - if (ctx->FragmentProgram._Current) { - /* Pull in static fog state from program */ - mode = ctx->FragmentProgram._Current->FogOption; - enabled = (mode != GL_NONE); - try_pixel_fog = 0; - } - else { - enabled = ctx->Fog.Enabled; - mode = ctx->Fog.Mode; -#if 0 - /* XXX - DISABLED -- Need ortho fallback */ - try_pixel_fog = (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT - && ctx->Hint.Fog == GL_NICEST); -#else - try_pixel_fog = 0; -#endif - } - - if (!enabled) { - i915->vertex_fog = I915_FOG_NONE; - } - else if (try_pixel_fog) { - I915_STATECHANGE(i915, I915_UPLOAD_FOG); - i915->state.Fog[I915_FOGREG_MODE1] &= ~FMC1_FOGFUNC_MASK; - i915->vertex_fog = I915_FOG_PIXEL; - - switch (mode) { - case GL_LINEAR: - if (ctx->Fog.End <= ctx->Fog.Start) { - /* XXX - this won't work with fragment programs. Need to - * either fallback or append fog instructions to end of - * program in the case of linear fog. - */ - printf("vertex fog!\n"); - i915->state.Fog[I915_FOGREG_MODE1] |= FMC1_FOGFUNC_VERTEX; - i915->vertex_fog = I915_FOG_VERTEX; - } - else { - GLfloat c2 = 1.0 / (ctx->Fog.End - ctx->Fog.Start); - GLfloat c1 = ctx->Fog.End * c2; - - i915->state.Fog[I915_FOGREG_MODE1] &= ~FMC1_C1_MASK; - i915->state.Fog[I915_FOGREG_MODE1] |= FMC1_FOGFUNC_PIXEL_LINEAR; - i915->state.Fog[I915_FOGREG_MODE1] |= - ((GLuint) (c1 * FMC1_C1_ONE)) & FMC1_C1_MASK; - - if (i915->state.Fog[I915_FOGREG_MODE1] & FMC1_FOGINDEX_Z) { - i915->state.Fog[I915_FOGREG_MODE2] - = (GLuint) (c2 * FMC2_C2_ONE); - } - else { - fi_type fi; - fi.f = c2; - i915->state.Fog[I915_FOGREG_MODE2] = fi.i; - } - } - break; - case GL_EXP: - i915->state.Fog[I915_FOGREG_MODE1] |= FMC1_FOGFUNC_PIXEL_EXP; - break; - case GL_EXP2: - i915->state.Fog[I915_FOGREG_MODE1] |= FMC1_FOGFUNC_PIXEL_EXP2; - break; - default: - break; - } - } - else { /* if (i915->vertex_fog != I915_FOG_VERTEX) */ - I915_STATECHANGE(i915, I915_UPLOAD_FOG); - i915->state.Fog[I915_FOGREG_MODE1] &= ~FMC1_FOGFUNC_MASK; - i915->state.Fog[I915_FOGREG_MODE1] |= FMC1_FOGFUNC_VERTEX; - i915->vertex_fog = I915_FOG_VERTEX; - } - - I915_ACTIVESTATE(i915, I915_UPLOAD_FOG, enabled); - dw = i915->state.Ctx[I915_CTXREG_LIS5]; - if (enabled) - dw |= S5_FOG_ENABLE; - else - dw &= ~S5_FOG_ENABLE; - if (dw != i915->state.Ctx[I915_CTXREG_LIS5]) { - i915->state.Ctx[I915_CTXREG_LIS5] = dw; - I915_STATECHANGE(i915, I915_UPLOAD_CTX); - } - - /* Always enable pixel fog. Vertex fog using fog coord will conflict - * with fog code appended onto fragment program. - */ - _tnl_allow_vertex_fog( ctx, 0 ); - _tnl_allow_pixel_fog( ctx, 1 ); -} - static void i915Fogfv(struct gl_context * ctx, GLenum pname, const GLfloat * param) { - struct i915_context *i915 = I915_CONTEXT(ctx); - - switch (pname) { - case GL_FOG_COORDINATE_SOURCE_EXT: - case GL_FOG_MODE: - case GL_FOG_START: - case GL_FOG_END: - break; - - case GL_FOG_DENSITY: - I915_STATECHANGE(i915, I915_UPLOAD_FOG); - - if (i915->state.Fog[I915_FOGREG_MODE1] & FMC1_FOGINDEX_Z) { - i915->state.Fog[I915_FOGREG_MODE3] = - (GLuint) (ctx->Fog.Density * FMC3_D_ONE); - } - else { - fi_type fi; - fi.f = ctx->Fog.Density; - i915->state.Fog[I915_FOGREG_MODE3] = fi.i; - } - break; - - case GL_FOG_COLOR: - I915_STATECHANGE(i915, I915_UPLOAD_FOG); - i915->state.Fog[I915_FOGREG_COLOR] = - (_3DSTATE_FOG_COLOR_CMD | - ((GLubyte) (ctx->Fog.Color[0] * 255.0F) << 16) | - ((GLubyte) (ctx->Fog.Color[1] * 255.0F) << 8) | - ((GLubyte) (ctx->Fog.Color[2] * 255.0F) << 0)); - break; - - default: - break; - } -} - -static void -i915Hint(struct gl_context * ctx, GLenum target, GLenum state) -{ - switch (target) { - case GL_FOG_HINT: - break; - default: - break; - } + (void) ctx; + (void) pname; + (void) param; } /* ============================================================= @@ -937,6 +826,10 @@ i915Enable(struct gl_context * ctx, GLenum cap, GLboolean state) case GL_DEPTH_TEST: dw = i915->state.Ctx[I915_CTXREG_LIS6]; + + if (!ctx->DrawBuffer || !ctx->DrawBuffer->Visual.depthBits) + state = false; + if (state) dw |= S6_DEPTH_TEST_ENABLE; else @@ -971,35 +864,22 @@ i915Enable(struct gl_context * ctx, GLenum cap, GLboolean state) } break; - case GL_FOG: - break; - case GL_CULL_FACE: i915CullFaceFrontFace(ctx, 0); break; case GL_STENCIL_TEST: - { - GLboolean hw_stencil = GL_FALSE; - if (ctx->DrawBuffer) { - struct intel_renderbuffer *irbStencil - = intel_get_renderbuffer(ctx->DrawBuffer, BUFFER_STENCIL); - hw_stencil = (irbStencil && irbStencil->region); - } - if (hw_stencil) { - dw = i915->state.Ctx[I915_CTXREG_LIS5]; - if (state) - dw |= (S5_STENCIL_TEST_ENABLE | S5_STENCIL_WRITE_ENABLE); - else - dw &= ~(S5_STENCIL_TEST_ENABLE | S5_STENCIL_WRITE_ENABLE); - if (dw != i915->state.Ctx[I915_CTXREG_LIS5]) { - i915->state.Ctx[I915_CTXREG_LIS5] = dw; - I915_STATECHANGE(i915, I915_UPLOAD_CTX); - } - } - else { - FALLBACK(&i915->intel, I915_FALLBACK_STENCIL, state); - } + if (!ctx->DrawBuffer || !ctx->DrawBuffer->Visual.stencilBits) + state = false; + + dw = i915->state.Ctx[I915_CTXREG_LIS5]; + if (state) + dw |= (S5_STENCIL_TEST_ENABLE | S5_STENCIL_WRITE_ENABLE); + else + dw &= ~(S5_STENCIL_TEST_ENABLE | S5_STENCIL_WRITE_ENABLE); + if (dw != i915->state.Ctx[I915_CTXREG_LIS5]) { + i915->state.Ctx[I915_CTXREG_LIS5] = dw; + I915_STATECHANGE(i915, I915_UPLOAD_CTX); } break; @@ -1022,18 +902,7 @@ i915Enable(struct gl_context * ctx, GLenum cap, GLboolean state) break; case GL_POINT_SPRITE: - /* This state change is handled in i915_reduced_primitive_state because - * the hardware bit should only be set when rendering points. - */ - dw = i915->state.Ctx[I915_CTXREG_LIS4]; - if (state) - dw |= S4_SPRITE_POINT_ENABLE; - else - dw &= ~S4_SPRITE_POINT_ENABLE; - if (dw != i915->state.Ctx[I915_CTXREG_LIS4]) { - i915->state.Ctx[I915_CTXREG_LIS4] = dw; - I915_STATECHANGE(i915, I915_UPLOAD_CTX); - } + /* Handle it at i915_update_sprite_point_enable () */ break; case GL_POINT_SMOOTH: @@ -1107,28 +976,15 @@ i915_init_packets(struct i915_context *i915) i915->state.Stipple[I915_STPREG_ST0] = _3DSTATE_STIPPLE; } - - { - I915_STATECHANGE(i915, I915_UPLOAD_FOG); - i915->state.Fog[I915_FOGREG_MODE0] = _3DSTATE_FOG_MODE_CMD; - i915->state.Fog[I915_FOGREG_MODE1] = (FMC1_FOGFUNC_MODIFY_ENABLE | - FMC1_FOGFUNC_VERTEX | - FMC1_FOGINDEX_MODIFY_ENABLE | - FMC1_FOGINDEX_W | - FMC1_C1_C2_MODIFY_ENABLE | - FMC1_DENSITY_MODIFY_ENABLE); - i915->state.Fog[I915_FOGREG_COLOR] = _3DSTATE_FOG_COLOR_CMD; - } - { i915->state.Buffer[I915_DESTREG_DV0] = _3DSTATE_DST_BUF_VARS_CMD; /* scissor */ - i915->state.Buffer[I915_DESTREG_SENABLE] = - (_3DSTATE_SCISSOR_ENABLE_CMD | DISABLE_SCISSOR_RECT); i915->state.Buffer[I915_DESTREG_SR0] = _3DSTATE_SCISSOR_RECT_0_CMD; i915->state.Buffer[I915_DESTREG_SR1] = 0; i915->state.Buffer[I915_DESTREG_SR2] = 0; + i915->state.Buffer[I915_DESTREG_SENABLE] = + (_3DSTATE_SCISSOR_ENABLE_CMD | DISABLE_SCISSOR_RECT); } i915->state.RasterRules[I915_RASTER_RULES] = _3DSTATE_RASTER_RULES_CMD | @@ -1188,6 +1044,15 @@ i915_update_provoking_vertex(struct gl_context * ctx) } } +/* Fallback to swrast for select and feedback. + */ +static void +i915RenderMode(struct gl_context *ctx, GLenum mode) +{ + struct intel_context *intel = intel_context(ctx); + FALLBACK(intel, INTEL_FALLBACK_RENDERMODE, (mode != GL_RENDER)); +} + void i915InitStateFunctions(struct dd_function_table *functions) { @@ -1202,20 +1067,19 @@ i915InitStateFunctions(struct dd_function_table *functions) functions->Enable = i915Enable; functions->Fogfv = i915Fogfv; functions->FrontFace = i915CullFaceFrontFace; - functions->Hint = i915Hint; functions->LightModelfv = i915LightModelfv; functions->LineWidth = i915LineWidth; functions->LogicOpcode = i915LogicOp; functions->PointSize = i915PointSize; functions->PointParameterfv = i915PointParameterfv; functions->PolygonStipple = i915PolygonStipple; + functions->RenderMode = i915RenderMode; functions->Scissor = i915Scissor; functions->ShadeModel = i915ShadeModel; functions->StencilFuncSeparate = i915StencilFuncSeparate; functions->StencilMaskSeparate = i915StencilMaskSeparate; functions->StencilOpSeparate = i915StencilOpSeparate; functions->DepthRange = i915DepthRange; - functions->Viewport = i915Viewport; }