[Mesa-dev] [RFC 10/27] i965: Merge resolving of shader program source

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


Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
---
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp              |  8 ++------
 src/mesa/drivers/dri/i965/brw_shader.cpp                  |  5 ++++-
 src/mesa/drivers/dri/i965/brw_shader.h                    |  3 ++-
 src/mesa/drivers/dri/i965/brw_vec4.cpp                    |  2 +-
 src/mesa/drivers/dri/i965/brw_vec4.h                      |  2 +-
 src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp         | 13 ++++++-------
 src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.h           |  1 -
 src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp            |  6 ++----
 src/mesa/drivers/dri/i965/brw_vec4_vs_visitor.cpp         |  4 ++--
 src/mesa/drivers/dri/i965/brw_vs.h                        |  1 -
 src/mesa/drivers/dri/i965/test_vec4_register_coalesce.cpp |  3 ++-
 11 files changed, 22 insertions(+), 26 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index f89183b..ba370a0 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -2947,17 +2947,13 @@ fs_visitor::fs_visitor(struct brw_context *brw,
                        struct gl_shader_program *shader_prog,
                        struct gl_fragment_program *fp,
                        unsigned dispatch_width)
-   : backend_visitor(brw, shader_prog, &fp->Base, &c->prog_data.base),
+   : backend_visitor(brw, shader_prog, &fp->Base, &c->prog_data.base,
+                     MESA_SHADER_FRAGMENT),
      dispatch_width(dispatch_width)
 {
    this->c = c;
    this->fp = fp;
    this->mem_ctx = ralloc_context(NULL);
-   if (shader_prog)
-      shader = (struct brw_shader *)
-         shader_prog->_LinkedShaders[MESA_SHADER_FRAGMENT];
-   else
-      shader = NULL;
    this->failed = false;
    this->variable_ht = hash_table_ctor(0,
                                        hash_table_pointer_hash,
diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp
index 2f20835..077d961 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.cpp
+++ b/src/mesa/drivers/dri/i965/brw_shader.cpp
@@ -540,9 +540,12 @@ brw_instruction_name(enum opcode op)
 backend_visitor::backend_visitor(struct brw_context *brw,
                                  struct gl_shader_program *shader_prog,
                                  struct gl_program *prog,
-                                 struct brw_stage_prog_data *stage_prog_data)
+                                 struct brw_stage_prog_data *stage_prog_data,
+                                 gl_shader_stage stage)
    : brw(brw),
      ctx(&brw->ctx),
+     shader(shader_prog ?
+        (struct brw_shader *)shader_prog->_LinkedShaders[stage] : NULL),
      shader_prog(shader_prog),
      prog(prog),
      stage_prog_data(stage_prog_data)
diff --git a/src/mesa/drivers/dri/i965/brw_shader.h b/src/mesa/drivers/dri/i965/brw_shader.h
index ac03a2f..4e41c84 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.h
+++ b/src/mesa/drivers/dri/i965/brw_shader.h
@@ -73,7 +73,8 @@ protected:
    backend_visitor(struct brw_context *brw,
                    struct gl_shader_program *shader_prog,
                    struct gl_program *prog,
-                   struct brw_stage_prog_data *stage_prog_data);
+                   struct brw_stage_prog_data *stage_prog_data,
+                   gl_shader_stage stage);
 
 public:
 
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index fbf7fb9..14790d9 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -1675,7 +1675,7 @@ brw_vs_emit(struct brw_context *brw,
       }
    }
 
-   vec4_vs_visitor v(brw, c, prog_data, prog, shader, mem_ctx);
+   vec4_vs_visitor v(brw, c, prog_data, prog, mem_ctx);
    if (!v.run()) {
       if (prog) {
          prog->LinkStatus = false;
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h
index a79a289..52e9b51 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -287,7 +287,7 @@ public:
                 const struct brw_vec4_prog_key *key,
                 struct brw_vec4_prog_data *prog_data,
 		struct gl_shader_program *shader_prog,
-		struct brw_shader *shader,
+                gl_shader_stage stage,
 		void *mem_ctx,
                 bool debug_flag,
                 bool no_spills,
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp
index d57c619..f6ae3e4 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp
@@ -36,11 +36,10 @@ namespace brw {
 vec4_gs_visitor::vec4_gs_visitor(struct brw_context *brw,
                                  struct brw_gs_compile *c,
                                  struct gl_shader_program *prog,
-                                 struct brw_shader *shader,
                                  void *mem_ctx,
                                  bool no_spills)
    : vec4_visitor(brw, &c->base, &c->gp->program.Base, &c->key.base,
-                  &c->prog_data.base, prog, shader, mem_ctx,
+                  &c->prog_data.base, prog, MESA_SHADER_GEOMETRY, mem_ctx,
                   INTEL_DEBUG & DEBUG_GS, no_spills,
                   ST_GS, ST_GS_WRITTEN, ST_GS_RESET),
      c(c)
@@ -575,10 +574,10 @@ brw_gs_emit(struct brw_context *brw,
             void *mem_ctx,
             unsigned *final_assembly_size)
 {
-   struct brw_shader *shader =
-      (brw_shader *) prog->_LinkedShaders[MESA_SHADER_GEOMETRY];
-
    if (unlikely(INTEL_DEBUG & DEBUG_GS)) {
+      struct brw_shader *shader =
+         (brw_shader *) prog->_LinkedShaders[MESA_SHADER_GEOMETRY];
+
       printf("GLSL IR for native geometry shader %d:\n", prog->Name);
       _mesa_print_ir(shader->base.ir, NULL);
       printf("\n\n");
@@ -590,7 +589,7 @@ brw_gs_emit(struct brw_context *brw,
    if (likely(!(INTEL_DEBUG & DEBUG_NO_DUAL_OBJECT_GS))) {
       c->prog_data.dual_instanced_dispatch = false;
 
-      vec4_gs_visitor v(brw, c, prog, shader, mem_ctx, true /* no_spills */);
+      vec4_gs_visitor v(brw, c, prog, mem_ctx, true /* no_spills */);
       if (v.run()) {
          return generate_assembly(brw, prog, &c->gp->program.Base,
                                   &c->prog_data.base, mem_ctx, &v.instructions,
@@ -610,7 +609,7 @@ brw_gs_emit(struct brw_context *brw,
     */
    c->prog_data.dual_instanced_dispatch = true;
 
-   vec4_gs_visitor v(brw, c, prog, shader, mem_ctx, false /* no_spills */);
+   vec4_gs_visitor v(brw, c, prog, mem_ctx, false /* no_spills */);
    if (!v.run()) {
       prog->LinkStatus = false;
       ralloc_strcat(&prog->InfoLog, v.fail_msg);
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.h b/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.h
index 68756f7..25415ea 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.h
@@ -80,7 +80,6 @@ public:
    vec4_gs_visitor(struct brw_context *brw,
                    struct brw_gs_compile *c,
                    struct gl_shader_program *prog,
-                   struct brw_shader *shader,
                    void *mem_ctx,
                    bool no_spills);
 
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index 7ffa338..d841fec 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -3308,14 +3308,14 @@ vec4_visitor::vec4_visitor(struct brw_context *brw,
                            const struct brw_vec4_prog_key *key,
                            struct brw_vec4_prog_data *prog_data,
 			   struct gl_shader_program *shader_prog,
-			   struct brw_shader *shader,
+                           gl_shader_stage stage,
 			   void *mem_ctx,
                            bool debug_flag,
                            bool no_spills,
                            shader_time_shader_type st_base,
                            shader_time_shader_type st_written,
                            shader_time_shader_type st_reset)
-   : backend_visitor(brw, shader_prog, prog, &prog_data->base),
+   : backend_visitor(brw, shader_prog, prog, &prog_data->base, stage),
      c(c),
      key(key),
      prog_data(prog_data),
@@ -3329,8 +3329,6 @@ vec4_visitor::vec4_visitor(struct brw_context *brw,
      st_written(st_written),
      st_reset(st_reset)
 {
-   this->shader = shader;
-
    this->mem_ctx = mem_ctx;
    this->failed = false;
 
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_vs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_vs_visitor.cpp
index c739e41..79cb40f 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_vs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_vs_visitor.cpp
@@ -211,10 +211,10 @@ vec4_vs_visitor::vec4_vs_visitor(struct brw_context *brw,
                                  struct brw_vs_compile *vs_compile,
                                  struct brw_vs_prog_data *vs_prog_data,
                                  struct gl_shader_program *prog,
-                                 struct brw_shader *shader,
                                  void *mem_ctx)
    : vec4_visitor(brw, &vs_compile->base, &vs_compile->vp->program.Base,
-                  &vs_compile->key.base, &vs_prog_data->base, prog, shader,
+                  &vs_compile->key.base, &vs_prog_data->base, prog,
+                  MESA_SHADER_VERTEX,
                   mem_ctx, INTEL_DEBUG & DEBUG_VS, false /* no_spills */,
                   ST_VS, ST_VS_WRITTEN, ST_VS_RESET),
      vs_compile(vs_compile),
diff --git a/src/mesa/drivers/dri/i965/brw_vs.h b/src/mesa/drivers/dri/i965/brw_vs.h
index 207cd5c..97308a7 100644
--- a/src/mesa/drivers/dri/i965/brw_vs.h
+++ b/src/mesa/drivers/dri/i965/brw_vs.h
@@ -108,7 +108,6 @@ public:
                    struct brw_vs_compile *vs_compile,
                    struct brw_vs_prog_data *vs_prog_data,
                    struct gl_shader_program *prog,
-                   struct brw_shader *shader,
                    void *mem_ctx);
 
 protected:
diff --git a/src/mesa/drivers/dri/i965/test_vec4_register_coalesce.cpp b/src/mesa/drivers/dri/i965/test_vec4_register_coalesce.cpp
index 4e971b5..27fb86e 100644
--- a/src/mesa/drivers/dri/i965/test_vec4_register_coalesce.cpp
+++ b/src/mesa/drivers/dri/i965/test_vec4_register_coalesce.cpp
@@ -48,7 +48,8 @@ class register_coalesce_vec4_visitor : public vec4_visitor
 public:
    register_coalesce_vec4_visitor(struct brw_context *brw,
                                   struct gl_shader_program *shader_prog)
-      : vec4_visitor(brw, NULL, NULL, NULL, NULL, shader_prog, NULL, NULL,
+      : vec4_visitor(brw, NULL, NULL, NULL, NULL, shader_prog,
+                     MESA_SHADER_VERTEX,
                      false, false /* no_spills */,
                      ST_NONE, ST_NONE, ST_NONE)
    {
-- 
1.8.3.1



More information about the mesa-dev mailing list