i915: Gut all remaining bits of hardware fog
authorIan Romanick <ian.d.romanick@intel.com>
Sat, 16 Apr 2011 05:20:09 +0000 (22:20 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 22 Apr 2011 00:33:41 +0000 (17:33 -0700)
None of this ever gets used.  Fog is always calculated by a fragment
program.  Even though the fixed-function fog unit is never used, state
updates are still sent to the hardware.  Removing those spurious state
updates can't hurt performance.

Reviewed-by: Eric Anholt <eric@anholt.net>
Acked-by: Corbin Simpson <MostAwesomeDude@gmail.com>
Acked-by: Alex Deucher <alexdeucher@gmail.com>
src/mesa/drivers/dri/i915/i915_context.c
src/mesa/drivers/dri/i915/i915_context.h
src/mesa/drivers/dri/i915/i915_state.c
src/mesa/drivers/dri/i915/i915_vtbl.c

index 7389a1d57a90750b54eaa2153290b43fa629ca80..f02f2d782678e707db0c0ace3c41141f25949a3b 100644 (file)
@@ -69,8 +69,6 @@ i915InvalidateState(struct gl_context * ctx, GLuint new_state)
          p->params_uptodate = 0;
    }
 
-   if (new_state & (_NEW_FOG | _NEW_HINT | _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS))
-      i915_update_fog(ctx);
    if (new_state & (_NEW_STENCIL | _NEW_BUFFERS | _NEW_POLYGON))
       i915_update_stencil(ctx);
    if (new_state & (_NEW_LIGHT))
@@ -209,5 +207,11 @@ i915CreateContext(int api,
 
    i915InitState(i915);
 
+   /* 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);
+
    return GL_TRUE;
 }
index 9a09f0adc0acae9fc5066f2659cda68d196114f7..577a01e290ce9eb83e9829b7a484f71c7910de5d 100644 (file)
@@ -46,7 +46,6 @@
 #define I915_UPLOAD_STIPPLE          0x4
 #define I915_UPLOAD_PROGRAM          0x8
 #define I915_UPLOAD_CONSTANTS        0x10
-#define I915_UPLOAD_FOG              0x20
 #define I915_UPLOAD_INVARIENT        0x40
 #define I915_UPLOAD_DEFAULTS         0x80
 #define I915_UPLOAD_RASTER_RULES     0x100
 #define I915_BLENDREG_BLENDCOLOR1      2
 #define I915_BLEND_SETUP_SIZE          3
 
-#define I915_FOGREG_COLOR              0
-#define I915_FOGREG_MODE0              1
-#define I915_FOGREG_MODE1              2
-#define I915_FOGREG_MODE2              3
-#define I915_FOGREG_MODE3              4
-#define I915_FOG_SETUP_SIZE            5
-
 #define I915_STPREG_ST0        0
 #define I915_STPREG_ST1        1
 #define I915_STP_SETUP_SIZE    2
@@ -227,7 +219,6 @@ struct i915_hw_state
    GLuint Blend[I915_BLEND_SETUP_SIZE];
    GLuint Buffer[I915_DEST_SETUP_SIZE];
    GLuint Stipple[I915_STP_SETUP_SIZE];
-   GLuint Fog[I915_FOG_SETUP_SIZE];
    GLuint Defaults[I915_DEF_SETUP_SIZE];
    GLuint RasterRules[I915_RASTER_RULES_SETUP_SIZE];
    GLuint Tex[I915_TEX_UNITS][I915_TEX_SETUP_SIZE];
@@ -345,7 +336,6 @@ extern void i915_print_ureg(const char *msg, GLuint ureg);
  */
 extern void i915InitStateFunctions(struct dd_function_table *functions);
 extern void i915InitState(struct i915_context *i915);
-extern void i915_update_fog(struct gl_context * ctx);
 extern void i915_update_stencil(struct gl_context * ctx);
 extern void i915_update_provoking_vertex(struct gl_context *ctx);
 
index d027426e2ab9356c54025d61bfef2977129d0a1f..99212ad4fd1c7a18bb66f1fa1d3a6a43023ff8cc 100644 (file)
@@ -724,79 +724,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);
-   GLuint dw;
-
-   assert(ctx->FragmentProgram._Current);
-
-   I915_ACTIVESTATE(i915, I915_UPLOAD_FOG, 0);
-   dw = i915->state.Ctx[I915_CTXREG_LIS5] & ~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;
 }
 
 /* =============================================================
@@ -893,9 +831,6 @@ i915Enable(struct gl_context * ctx, GLenum cap, GLboolean state)
       }
       break;
 
-   case GL_FOG:
-      break;
-
    case GL_CULL_FACE:
       i915CullFaceFrontFace(ctx, 0);
       break;
@@ -1029,19 +964,6 @@ 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;
 
@@ -1124,7 +1046,6 @@ 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;
index 942ebec29bd192e435a7edb254d88125c8de32d3..89650b618e45e645cc289bdf802fb233b40f53b4 100644 (file)
@@ -260,9 +260,6 @@ get_state_size(struct i915_hw_state *state)
    if (dirty & I915_UPLOAD_STIPPLE)
       sz += sizeof(state->Stipple);
 
-   if (dirty & I915_UPLOAD_FOG)
-      sz += sizeof(state->Fog);
-
    if (dirty & I915_UPLOAD_TEX_ALL) {
       int nr = 0;
       for (i = 0; i < I915_TEX_UNITS; i++)
@@ -429,12 +426,6 @@ i915_emit_state(struct intel_context *intel)
       emit(intel, state->Stipple, sizeof(state->Stipple));
    }
 
-   if (dirty & I915_UPLOAD_FOG) {
-      if (INTEL_DEBUG & DEBUG_STATE)
-         fprintf(stderr, "I915_UPLOAD_FOG:\n");
-      emit(intel, state->Fog, sizeof(state->Fog));
-   }
-
    /* Combine all the dirty texture state into a single command to
     * avoid lockups on I915 hardware. 
     */