[Mesa-dev] [PATCH 07/13] i965 vs: Streamline the way fail is tracked.

Paul Berry stereotype441 at gmail.com
Wed Nov 16 11:07:14 PST 2011


Previously, vec4_visitor flagged a failure by setting the "failed"
boolean and storing a string in "fail_msg" (which, up until the point
of failure, was undefined).  This is redundant--it's just as easy to
have fail_msg be NULL when there is no failure, and a string pointer
when there is a failure.

This patch also adds trivial inline functions failed() and
get_fail_msg() so that this simplification doesn't make client code
any less clear.
---
 src/mesa/drivers/dri/i965/brw_vec4.h           |   13 +++++++++++--
 src/mesa/drivers/dri/i965/brw_vec4_emit.cpp    |   15 +++++++--------
 src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp |    6 ++----
 3 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h
index 3e30514..6fafc97 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -309,7 +309,6 @@ public:
    exec_list instructions;
 
    char *fail_msg;
-   bool failed;
 
    /**
     * GLSL IR currently being processed, which is associated with our
@@ -337,6 +336,16 @@ public:
 
    dst_reg *variable_storage(ir_variable *var);
 
+   bool failed() const
+   {
+      return fail_msg != NULL;
+   }
+
+   char *get_fail_msg() const
+   {
+      return fail_msg;
+   }
+
    src_reg src_reg_for_float(float val);
 
    /**
@@ -379,7 +388,7 @@ public:
 
    struct hash_table *variable_ht;
 
-   bool run(void);
+   void run(void);
    void fail(const char *msg, ...);
 
    int virtual_grf_alloc(int size);
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
index 284cb86..e5dc763 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
@@ -619,7 +619,7 @@ vec4_visitor::generate_vs_instruction(vec4_instruction *instruction,
    }
 }
 
-bool
+void
 vec4_visitor::run()
 {
    if (c->key.userclip_active && !c->key.uses_clip_distance)
@@ -653,13 +653,11 @@ vec4_visitor::run()
    } while (progress);
 
 
-   if (failed)
-      return false;
+   if (failed())
+      return;
 
    int first_non_payload_grf = setup_payload();
    prog_data->total_grf = generate_code(first_non_payload_grf);
-
-   return !failed;
 }
 
 int
@@ -680,7 +678,7 @@ vec4_visitor::generate_code(int first_non_payload_grf)
 
    int total_grf = reg_allocate(first_non_payload_grf);
 
-   if (failed)
+   if (failed())
       return 0;
 
    if (unlikely(INTEL_DEBUG & DEBUG_VS)) {
@@ -930,9 +928,10 @@ brw_vs_emit(struct gl_shader_program *prog, struct brw_vs_compile *c)
    }
 
    vec4_visitor v(c, prog, shader);
-   if (!v.run()) {
+   v.run();
+   if (v.failed()) {
       prog->LinkStatus = false;
-      ralloc_strcat(&prog->InfoLog, v.fail_msg);
+      ralloc_strcat(&prog->InfoLog, v.get_fail_msg());
       return false;
    }
 
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index 42214d4..338106c 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -2375,7 +2375,7 @@ vec4_visitor::vec4_visitor(struct brw_vs_compile *c,
    this->shader = shader;
 
    this->mem_ctx = ralloc_context(NULL);
-   this->failed = false;
+   this->fail_msg = NULL;
 
    this->base_ir = NULL;
    this->current_annotation = NULL;
@@ -2418,11 +2418,9 @@ vec4_visitor::fail(const char *format, ...)
    va_list va;
    char *msg;
 
-   if (failed)
+   if (failed())
       return;
 
-   failed = true;
-
    va_start(va, format);
    msg = ralloc_vasprintf(mem_ctx, format, va);
    va_end(va);
-- 
1.7.6.4



More information about the mesa-dev mailing list