[Mesa-dev] [PATCH 4/6] i965/fs: Pass key->render_to_fbo via src1 of FS_OPCODE_DDY_*.

Kenneth Graunke kenneth at whitecape.org
Mon Nov 24 22:03:13 PST 2014


This means the generator doesn't have to look at the key, which is a
little nicer - we're pretty close to no key dependencies at all.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/drivers/dri/i965/brw_defines.h        | 4 ++++
 src/mesa/drivers/dri/i965/brw_fs_generator.cpp | 9 ++-------
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp   | 8 ++++----
 3 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_defines.h b/src/mesa/drivers/dri/i965/brw_defines.h
index d684406..b016405 100644
--- a/src/mesa/drivers/dri/i965/brw_defines.h
+++ b/src/mesa/drivers/dri/i965/brw_defines.h
@@ -910,6 +910,10 @@ enum opcode {
 
    FS_OPCODE_DDX_COARSE,
    FS_OPCODE_DDX_FINE,
+   /**
+    * Compute dFdy(), dFdyCoarse(), or dFdyFine().
+    * src1 is an immediate storing the key->render_to_fbo boolean.
+    */
    FS_OPCODE_DDY_COARSE,
    FS_OPCODE_DDY_FINE,
    FS_OPCODE_PIXEL_X,
diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
index 4cc968d..f61e7a1 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
@@ -1857,13 +1857,8 @@ fs_generator::generate_code(const cfg_t *cfg, int dispatch_width)
          break;
       case FS_OPCODE_DDY_COARSE:
       case FS_OPCODE_DDY_FINE:
-         /* Make sure fp->UsesDFdy flag got set (otherwise there's no
-          * guarantee that key->render_to_fbo is set).
-          */
-         assert(stage == MESA_SHADER_FRAGMENT &&
-                ((gl_fragment_program *) prog)->UsesDFdy);
-         generate_ddy(inst->opcode, dst, src[0],
-                      ((brw_wm_prog_key * const) this->key)->render_to_fbo);
+         assert(src[1].file == BRW_IMMEDIATE_VALUE);
+         generate_ddy(inst->opcode, dst, src[0], src[1].dw1.ud);
 	 break;
 
       case SHADER_OPCODE_GEN4_SCRATCH_WRITE:
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 1b0edaf..0b62496 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -620,17 +620,17 @@ fs_visitor::visit(ir_expression *ir)
    case ir_unop_dFdy:
       /* Select one of the two opcodes based on the glHint value. */
       if (fs_key->high_quality_derivatives)
-         emit(FS_OPCODE_DDY_FINE, this->result, op[0]);
+         emit(FS_OPCODE_DDY_FINE, result, op[0], fs_reg(fs_key->render_to_fbo));
       else
-         emit(FS_OPCODE_DDY_COARSE, this->result, op[0]);
+         emit(FS_OPCODE_DDY_COARSE, result, op[0], fs_reg(fs_key->render_to_fbo));
       break;
 
    case ir_unop_dFdy_coarse:
-      emit(FS_OPCODE_DDY_COARSE, this->result, op[0]);
+      emit(FS_OPCODE_DDY_COARSE, result, op[0], fs_reg(fs_key->render_to_fbo));
       break;
 
    case ir_unop_dFdy_fine:
-      emit(FS_OPCODE_DDY_FINE, this->result, op[0]);
+      emit(FS_OPCODE_DDY_FINE, result, op[0], fs_reg(fs_key->render_to_fbo));
       break;
 
    case ir_binop_add:
-- 
2.1.3



More information about the mesa-dev mailing list