i965: fix broken ARB fp fog options
authorBrian Paul <brianp@vmware.com>
Fri, 9 Jan 2009 22:52:04 +0000 (15:52 -0700)
committerBrian Paul <brianp@vmware.com>
Mon, 12 Jan 2009 21:24:45 +0000 (14:24 -0700)
Just call _mesa_append_fog_code() if the fragment program's FogOption is
not GL_NONE.
This allows us to remove some unnecessary i965 fog code.
Note, the arbfplight.c demo can be used to test this (see DO_FRAGMENT_FOG).

src/mesa/drivers/dri/i965/brw_program.c
src/mesa/drivers/dri/i965/brw_wm_fp.c

index a18dee8..0c86911 100644 (file)
@@ -111,9 +111,15 @@ static void brwProgramStringNotify( GLcontext *ctx,
                                    struct gl_program *prog )
 {
    if (target == GL_FRAGMENT_PROGRAM_ARB) {
+      struct gl_fragment_program *fprog = (struct gl_fragment_program *) prog;
       struct brw_context *brw = brw_context(ctx);
       struct brw_fragment_program *p = (struct brw_fragment_program *)prog;
       struct brw_fragment_program *fp = (struct brw_fragment_program *)brw->fragment_program;
+      if (fprog->FogOption) {
+         _mesa_append_fog_code(ctx, fprog);
+         fprog->FogOption = GL_NONE;
+      }
+
       if (p == fp)
         brw->state.dirty.brw |= BRW_NEW_FRAGMENT_PROGRAM;
       p->id = brw->program_id++;      
index f458387..1a00b69 100644 (file)
@@ -811,57 +811,6 @@ static void precalc_txp( struct brw_wm_compile *c,
 
 
 
-
-
-/***********************************************************************
- * Add instructions to perform fog blending
- */
-
-static void fog_blend( struct brw_wm_compile *c,
-                            struct prog_src_register fog_factor )
-{
-   struct prog_dst_register outcolor = dst_reg(PROGRAM_OUTPUT, FRAG_RESULT_COLR);
-   struct prog_src_register fogcolor = search_or_add_param5( c, STATE_FOG_COLOR, 0,0,0,0 );
-
-   /* color.xyz = LRP fog_factor.xxxx, output_color, fog_color */
-   
-   emit_op(c, 
-          OPCODE_LRP,
-          dst_mask(outcolor, WRITEMASK_XYZ),
-          0, 0, 0,
-          fog_factor,
-          src_reg_from_dst(outcolor),
-          fogcolor);
-}
-
-
-
-/* This one is simple - just take the interpolated fog coordinate and
- * use it as the fog blend factor.
- */
-static void fog_interpolated( struct brw_wm_compile *c )
-{
-   struct prog_src_register fogc = src_reg(PROGRAM_INPUT, FRAG_ATTRIB_FOGC);
-   
-   if (!(c->fp_interp_emitted & (1<<FRAG_ATTRIB_FOGC))) 
-      emit_interp(c, FRAG_ATTRIB_FOGC);
-
-   fog_blend( c, src_swizzle1(fogc, GET_SWZ(fogc.Swizzle,X)));
-}
-
-static void emit_fog( struct brw_wm_compile *c ) 
-{
-   if (!c->fp->program.FogOption)
-      return;
-
-   if (1) 
-      fog_interpolated( c );
-   else {
-      /* TODO: per-pixel fog */
-      assert(0);
-   }
-}
-
 static void emit_fb_write( struct brw_wm_compile *c )
 {
    struct prog_src_register payload_r0_depth = src_reg(PROGRAM_PAYLOAD, PAYLOAD_DEPTH);
@@ -1059,7 +1008,6 @@ void brw_wm_pass_fp( struct brw_wm_compile *c )
          emit_ddy(c, inst);
        break;
       case OPCODE_END:
-        emit_fog(c);
         emit_fb_write(c);
         break;
       case OPCODE_PRINT: