[Mesa-dev] [PATCH 06/14] i965: Merge fail() for ir visitors

Topi Pohjolainen topi.pohjolainen at intel.com
Wed May 28 05:36:02 PDT 2014


Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
---
 src/mesa/drivers/dri/i965/brw_fs.cpp           | 30 ------------------
 src/mesa/drivers/dri/i965/brw_fs.h             |  4 ---
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp   |  3 +-
 src/mesa/drivers/dri/i965/brw_shader.cpp       | 44 ++++++++++++++++++++++++--
 src/mesa/drivers/dri/i965/brw_shader.h         | 13 +++++++-
 src/mesa/drivers/dri/i965/brw_vec4.h           |  6 ----
 src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 30 +-----------------
 7 files changed, 56 insertions(+), 74 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 5605db3..5de6b95 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -666,36 +666,6 @@ fs_visitor::emit_shader_time_write(enum shader_time_shader_type type,
                              fs_reg(), payload, offset, value));
 }
 
-void
-fs_visitor::vfail(const char *format, va_list va)
-{
-   char *msg;
-
-   if (failed)
-      return;
-
-   failed = true;
-
-   msg = ralloc_vasprintf(mem_ctx, format, va);
-   msg = ralloc_asprintf(mem_ctx, "FS compile failed: %s\n", msg);
-
-   this->fail_msg = msg;
-
-   if (INTEL_DEBUG & DEBUG_WM) {
-      fprintf(stderr, "%s",  msg);
-   }
-}
-
-void
-fs_visitor::fail(const char *format, ...)
-{
-   va_list va;
-
-   va_start(va, format);
-   vfail(format, va);
-   va_end(va);
-}
-
 /**
  * Mark this program as impossible to compile in SIMD16 mode.
  *
diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h
index 184725c..f430862 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -376,8 +376,6 @@ public:
    void insert_gen4_send_dependency_workarounds();
    void insert_gen4_pre_send_dependency_workarounds(fs_inst *inst);
    void insert_gen4_post_send_dependency_workarounds(fs_inst *inst);
-   void vfail(const char *msg, va_list args);
-   void fail(const char *msg, ...);
    void no16(const char *msg, ...);
    void lower_uniform_pull_constant_loads();
 
@@ -537,8 +535,6 @@ public:
    const void *base_ir;
    /** @} */
 
-   bool failed;
-   char *fail_msg;
    bool simd16_unsupported;
    char *no16_msg;
 
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index d4e02d2..e74b28e 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -2965,12 +2965,11 @@ fs_visitor::fs_visitor(struct brw_context *brw,
                        unsigned dispatch_width)
    : backend_visitor(shader_prog, &fp->Base, &prog_data->base,
                      MESA_SHADER_FRAGMENT),
-     backend_emitter(brw, mem_ctx),
+     backend_emitter(brw, mem_ctx, "FS", INTEL_DEBUG & DEBUG_WM),
      key(key), prog_data(prog_data),
      dispatch_width(dispatch_width)
 {
    this->fp = fp;
-   this->failed = false;
    this->simd16_unsupported = false;
    this->no16_msg = NULL;
 
diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp
index c73fa8b..7594713 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.cpp
+++ b/src/mesa/drivers/dri/i965/brw_shader.cpp
@@ -548,17 +548,57 @@ backend_visitor::backend_visitor(struct gl_shader_program *shader_prog,
 {
 }
 
-backend_emitter::backend_emitter(struct brw_context *brw, void *mem_ctx)
+backend_emitter::backend_emitter(struct brw_context *brw, void *mem_ctx,
+                                 const char *stage_name, bool debug_flag)
    : brw(brw),
      ctx(&brw->ctx),
      mem_ctx(mem_ctx),
      max_grf(brw->gen >= 7 ? GEN7_MRF_HACK_START : BRW_MAX_GRF),
      variable_ht(hash_table_ctor(0,
                                  hash_table_pointer_hash,
-                                 hash_table_pointer_compare))
+                                 hash_table_pointer_compare)),
+     fail_msg(NULL),
+     failed(false),
+     stage_name(stage_name),
+     debug_flag(debug_flag)
 {
 }
 
+backend_emitter::~backend_emitter()
+{
+   hash_table_dtor(variable_ht);
+}
+
+void
+backend_emitter::vfail(const char *format, va_list va) 
+{
+   char *msg;
+
+   if (failed)
+      return;
+
+   failed = true;
+
+   msg = ralloc_vasprintf(mem_ctx, format, va);
+   msg = ralloc_asprintf(mem_ctx, "%s compile failed: %s\n", stage_name, msg);
+
+   this->fail_msg = msg;
+
+   if (debug_flag) {
+      fprintf(stderr, "%s",  msg);
+   }
+}
+
+void
+backend_emitter::fail(const char *format, ...)
+{
+   va_list va;
+
+   va_start(va, format);
+   vfail(format, va);
+   va_end(va);
+}
+
 bool
 backend_instruction::is_tex() const
 {
diff --git a/src/mesa/drivers/dri/i965/brw_shader.h b/src/mesa/drivers/dri/i965/brw_shader.h
index 1c5c9f1..f7bb15e 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.h
+++ b/src/mesa/drivers/dri/i965/brw_shader.h
@@ -102,7 +102,13 @@ public:
 class backend_emitter {
 protected:
 
-   backend_emitter(struct brw_context *brw, void *mem_ctx);
+   backend_emitter(struct brw_context *brw, void *mem_ctx,
+                   const char *stage_name, bool debug_flag);
+
+   ~backend_emitter();
+
+   void vfail(const char *format, va_list va);
+   void fail(const char *format, ...);
 
 public:
 
@@ -123,6 +129,11 @@ public:
 
    struct hash_table * const variable_ht;
 
+   char *fail_msg;
+   bool failed;
+   const char * const stage_name;
+   const bool debug_flag;
+
    virtual void dump_instruction(backend_instruction *inst) = 0;
    virtual void dump_instructions();
 
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h
index b44a3dc..3726eb0 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -320,9 +320,6 @@ public:
    struct brw_vec4_prog_data * const prog_data;
    unsigned int sanity_param_count;
 
-   char *fail_msg;
-   bool failed;
-
    /**
     * GLSL IR currently being processed, which is associated with our
     * driver IR instructions for debugging purposes.
@@ -398,7 +395,6 @@ public:
    src_reg shader_start_time;
 
    bool run(void);
-   void fail(const char *msg, ...);
 
    int virtual_grf_alloc(int size);
    void setup_uniform_clipplane_values();
@@ -608,8 +604,6 @@ protected:
    virtual vec4_instruction *emit_urb_write_opcode(bool complete) = 0;
    virtual int compute_array_stride(ir_dereference_array *ir);
 
-   const bool debug_flag;
-
 private:
    /**
     * If true, then register allocation should fail instead of spilling.
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index a17d6f6..83c482b 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -3364,22 +3364,18 @@ vec4_visitor::vec4_visitor(struct brw_context *brw,
                            shader_time_shader_type st_written,
                            shader_time_shader_type st_reset)
    : backend_visitor(shader_prog, prog, &prog_data->base, stage),
-     backend_emitter(brw, mem_ctx),
+     backend_emitter(brw, mem_ctx, "vec4", debug_flag),
      c(c),
      key(key),
      prog_data(prog_data),
      sanity_param_count(0),
-     fail_msg(NULL),
      first_non_payload_grf(0),
      need_all_constants_in_pull_buffer(false),
-     debug_flag(debug_flag),
      no_spills(no_spills),
      st_base(st_base),
      st_written(st_written),
      st_reset(st_reset)
 {
-   this->failed = false;
-
    this->base_ir = NULL;
    this->current_annotation = NULL;
    memset(this->output_reg_annotation, 0, sizeof(this->output_reg_annotation));
@@ -3407,28 +3403,4 @@ vec4_visitor::vec4_visitor(struct brw_context *brw,
    this->uniform_vector_size = rzalloc_array(mem_ctx, int, this->uniform_array_size);
 }
 
-
-void
-vec4_visitor::fail(const char *format, ...)
-{
-   va_list va;
-   char *msg;
-
-   if (failed)
-      return;
-
-   failed = true;
-
-   va_start(va, format);
-   msg = ralloc_vasprintf(mem_ctx, format, va);
-   va_end(va);
-   msg = ralloc_asprintf(mem_ctx, "vec4 compile failed: %s\n", msg);
-
-   this->fail_msg = msg;
-
-   if (debug_flag) {
-      fprintf(stderr, "%s",  msg);
-   }
-}
-
 } /* namespace brw */
-- 
1.8.3.1



More information about the mesa-dev mailing list