[Mesa-dev] [PATCH 13/14] i965: Clean up fs_visitor::run and rename to run_fs

Kristian Høgsberg krh at bitplanet.net
Tue Oct 28 15:17:56 PDT 2014


Now that fs_visitor::run is back to being only fragment
shader compilation, we can clean up a few stage == MESA_SHADER_FRAGMENT
conditions and rename it to run_fs.

Signed-off-by: Kristian Høgsberg <krh at bitplanet.net>
---
 src/mesa/drivers/dri/i965/brw_fs.cpp | 31 +++++++++++++------------------
 src/mesa/drivers/dri/i965/brw_fs.h   |  2 +-
 2 files changed, 14 insertions(+), 19 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 93f6a49..8d320d5 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -3701,8 +3701,12 @@ fs_visitor::run_vs()
 }
 
 bool
-fs_visitor::run()
+fs_visitor::run_fs()
 {
+   brw_wm_prog_data *wm_prog_data = (brw_wm_prog_data *) this->prog_data;
+   brw_wm_prog_key *wm_key = (brw_wm_prog_key *) this->key;
+   assert(stage == MESA_SHADER_FRAGMENT);
+
    sanity_param_count = prog->Parameters->NumParameters;
 
    assign_binding_table_offsets();
@@ -3731,13 +3735,7 @@ fs_visitor::run()
       /* We handle discards by keeping track of the still-live pixels in f0.1.
        * Initialize it with the dispatched pixels.
        */
-      bool uses_kill =
-         (stage == MESA_SHADER_FRAGMENT) &&
-         ((brw_wm_prog_data*) this->prog_data)->uses_kill;
-      bool alpha_test_func =
-         (stage == MESA_SHADER_FRAGMENT) &&
-         ((brw_wm_prog_key*) this->key)->alpha_test_func;
-      if (uses_kill || alpha_test_func) {
+      if (wm_prog_data->uses_kill || wm_key->alpha_test_func) {
          fs_inst *discard_init = emit(FS_OPCODE_MOV_DISPATCH_TO_FLAGS);
          discard_init->flag_subreg = 1;
       }
@@ -3760,7 +3758,7 @@ fs_visitor::run()
 
       emit(FS_OPCODE_PLACEHOLDER_HALT);
 
-      if (alpha_test_func)
+      if (wm_key->alpha_test_func)
          emit_alpha_test();
 
       emit_fb_writes();
@@ -3775,13 +3773,10 @@ fs_visitor::run()
          return false;
    }
 
-   if (stage == MESA_SHADER_FRAGMENT) {
-      brw_wm_prog_data *prog_data = (brw_wm_prog_data*) this->prog_data;
-      if (dispatch_width == 8)
-         prog_data->reg_blocks = brw_register_blocks(grf_used);
-      else
-         prog_data->reg_blocks_16 = brw_register_blocks(grf_used);
-   }
+   if (dispatch_width == 8)
+      wm_prog_data->reg_blocks = brw_register_blocks(grf_used);
+   else
+      wm_prog_data->reg_blocks_16 = brw_register_blocks(grf_used);
 
    /* If any state parameters were appended, then ParameterValues could have
     * been realloced, in which case the driver uniform storage set up by
@@ -3821,7 +3816,7 @@ brw_wm_fs_emit(struct brw_context *brw,
    /* Now the main event: Visit the shader IR and generate our FS IR for it.
     */
    fs_visitor v(brw, mem_ctx, key, prog_data, prog, fp, 8);
-   if (!v.run()) {
+   if (!v.run_fs()) {
       if (prog) {
          prog->LinkStatus = false;
          ralloc_strcat(&prog->InfoLog, v.fail_msg);
@@ -3840,7 +3835,7 @@ brw_wm_fs_emit(struct brw_context *brw,
       if (!v.simd16_unsupported) {
          /* Try a SIMD16 compile */
          v2.import_uniforms(&v);
-         if (!v2.run()) {
+         if (!v2.run_fs()) {
             perf_debug("SIMD16 shader failed to compile, falling back to "
                        "SIMD8 at a 10-20%% performance cost: %s", v2.fail_msg);
          } else {
diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h
index 1a44704..86c0ca0 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -416,7 +416,7 @@ public:
                                         const fs_reg &varying_offset,
                                         uint32_t const_offset);
 
-   bool run();
+   bool run_fs();
    bool run_vs();
    void optimize();
    void allocate_registers();
-- 
2.1.0



More information about the mesa-dev mailing list