[Mesa-dev] [RFC 17/27] i965: Merge fail() for ir visitors

Topi Pohjolainen topi.pohjolainen at intel.com
Sat Feb 22 01:05:43 PST 2014


Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
---
 src/mesa/drivers/dri/i965/brw_fs.cpp           | 23 -------------------
 src/mesa/drivers/dri/i965/brw_fs.h             |  1 -
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp   |  2 +-
 src/mesa/drivers/dri/i965/brw_shader.cpp       | 31 ++++++++++++++++++++++++--
 src/mesa/drivers/dri/i965/brw_shader.h         |  9 +++++++-
 src/mesa/drivers/dri/i965/brw_vec4.h           |  3 ---
 src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 27 +---------------------
 7 files changed, 39 insertions(+), 57 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 0fd9e90..bad3333 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -645,29 +645,6 @@ fs_visitor::emit_shader_time_write(enum shader_time_shader_type type,
                 fs_reg(), payload, offset, value));
 }
 
-void
-fs_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, "FS compile failed: %s\n", msg);
-
-   this->fail_msg = msg;
-
-   if (INTEL_DEBUG & DEBUG_WM) {
-      fprintf(stderr, "%s",  msg);
-   }
-}
-
 fs_inst *
 fs_visitor::emit(enum opcode opcode)
 {
diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h
index 9ad2049..8427937 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -377,7 +377,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 fail(const char *msg, ...);
    void lower_uniform_pull_constant_loads();
 
    void push_force_uncompressed();
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index b1ca533..0fadc51 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -2949,7 +2949,7 @@ fs_visitor::fs_visitor(struct brw_context *brw,
                        unsigned dispatch_width)
    : backend_visitor(shader_prog, &fp->Base, &c->prog_data.base,
                      MESA_SHADER_FRAGMENT),
-     backend_emitter(brw),
+     backend_emitter(brw, "FS", INTEL_DEBUG & DEBUG_WM),
      dispatch_width(dispatch_width)
 {
    this->c = c;
diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp
index 2722011..38b268b 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.cpp
+++ b/src/mesa/drivers/dri/i965/brw_shader.cpp
@@ -549,7 +549,9 @@ backend_visitor::backend_visitor(struct gl_shader_program *shader_prog,
 {
 }
 
-backend_emitter::backend_emitter(struct brw_context *brw)
+backend_emitter::backend_emitter(struct brw_context *brw,
+                                 const char *stage_name,
+                                 bool debug_flag)
    : brw(brw),
      ctx(&brw->ctx),
      mem_ctx(ralloc_context(NULL)),
@@ -568,7 +570,9 @@ backend_emitter::backend_emitter(struct brw_context *brw)
      current_annotation(NULL),
      first_non_payload_grf(0),
      fail_msg(NULL),
-     failed(false)
+     failed(false),
+     stage_name(stage_name),
+     debug_flag(debug_flag)
 {
 }
 
@@ -578,6 +582,29 @@ backend_emitter::~backend_emitter()
    ralloc_free(mem_ctx);
 }
 
+void
+backend_emitter::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, "%s compile failed: %s\n", stage_name, msg);
+
+   this->fail_msg = msg;
+
+   if (debug_flag) {
+      fprintf(stderr, "%s",  msg);
+   }
+}
+
 bool
 backend_instruction::is_tex()
 {
diff --git a/src/mesa/drivers/dri/i965/brw_shader.h b/src/mesa/drivers/dri/i965/brw_shader.h
index 3af6ace..53e40d9 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.h
+++ b/src/mesa/drivers/dri/i965/brw_shader.h
@@ -88,9 +88,14 @@ public:
 class backend_emitter {
 protected:
 
-   explicit backend_emitter(struct brw_context *brw);
+   explicit backend_emitter(struct brw_context *brw,
+                            const char *stage_name,
+                            bool debug_flag);
+
    ~backend_emitter();
 
+   void fail(const char *msg, ...);
+
 public:
 
    struct brw_context * const brw;
@@ -132,6 +137,8 @@ public:
 
    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 0076bde..4e89b83 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -373,7 +373,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();
@@ -580,8 +579,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 67ba63d..a96fb19 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -3315,12 +3315,11 @@ 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),
+     backend_emitter(brw, "vec4", debug_flag),
      c(c),
      key(key),
      prog_data(prog_data),
      need_all_constants_in_pull_buffer(false),
-     debug_flag(debug_flag),
      no_spills(no_spills),
      st_base(st_base),
      st_written(st_written),
@@ -3333,28 +3332,4 @@ vec4_visitor::vec4_visitor(struct brw_context *brw,
    this->live_intervals_valid = false;
 }
 
-
-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