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

Topi Pohjolainen topi.pohjolainen at intel.com
Fri Apr 11 00:28:49 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             |  2 --
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp   |  2 +-
 src/mesa/drivers/dri/i965/brw_shader.cpp       | 38 ++++++++++++++++++++++++--
 src/mesa/drivers/dri/i965/brw_shader.h         | 10 ++++++-
 src/mesa/drivers/dri/i965/brw_vec4.h           |  3 --
 src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 27 +-----------------
 7 files changed, 47 insertions(+), 65 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 85a5463..b5f327e 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -646,36 +646,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 3d2a613..78c53dd 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -380,8 +380,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();
 
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 5aa8d6c..d6cd53c 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -2953,7 +2953,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 eec1f61..8fe7798 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.cpp
+++ b/src/mesa/drivers/dri/i965/brw_shader.cpp
@@ -548,7 +548,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)),
@@ -567,7 +569,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)
 {
 }
 
@@ -577,6 +581,36 @@ backend_emitter::~backend_emitter()
    ralloc_free(mem_ctx);
 }
 
+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 068991a..bc36a8c 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.h
+++ b/src/mesa/drivers/dri/i965/brw_shader.h
@@ -89,9 +89,15 @@ 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 vfail(const char *format, va_list va);
+   void fail(const char *format, ...);
+
 public:
 
    struct brw_context * const brw;
@@ -133,6 +139,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 f9f6467..e91a122 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -382,7 +382,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();
@@ -592,8 +591,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 497b3b5..637272a 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -3352,12 +3352,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),
@@ -3381,28 +3380,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