i965: Merge resolving of shader program source
authorTopi Pohjolainen <topi.pohjolainen@intel.com>
Tue, 18 Feb 2014 20:50:13 +0000 (22:50 +0200)
committerTopi Pohjolainen <topi.pohjolainen@intel.com>
Wed, 5 Mar 2014 08:31:44 +0000 (10:31 +0200)
Reviewed-by: Matt Turner <mattst88@gmail.com>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
src/mesa/drivers/dri/i965/brw_shader.cpp
src/mesa/drivers/dri/i965/brw_shader.h
src/mesa/drivers/dri/i965/brw_vec4.cpp
src/mesa/drivers/dri/i965/brw_vec4.h
src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp
src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.h
src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
src/mesa/drivers/dri/i965/brw_vec4_vs_visitor.cpp
src/mesa/drivers/dri/i965/brw_vs.h
src/mesa/drivers/dri/i965/test_vec4_register_coalesce.cpp

index 424763bd6cb453b7f85b86e12d9c4c84b1176a31..90272eb68f5a13cbd647c095aa26e93f7b17c888 100644 (file)
@@ -2942,17 +2942,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,
index 747137e4a430a8119a8b15ca682152c8aeb0cb23..407319b4d8de5804a70d2cb1ffd01499038095e6 100644 (file)
@@ -539,9 +539,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)
index 0163414cecc39da460af26781dc0340f8634494b..33295549b7a93508517b1496cdf38dc02813656f 100644 (file)
@@ -74,7 +74,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:
 
index c30afaecda6a1f1cfe035aacc93e3c4939856b04..87825f1349708da7665858d8fa565e7f7606ae01 100644 (file)
@@ -1668,7 +1668,7 @@ brw_vs_emit(struct brw_context *brw,
    if (unlikely(INTEL_DEBUG & DEBUG_VS))
       brw_dump_ir(brw, "vertex", prog, &shader->base, &c->vp->program.Base);
 
-   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;
index cb0586fdcbc714a0bc54497edc6d837cec173bdf..eb375e2fc6882836d12b0da7b8303292cc7a6c66 100644 (file)
@@ -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,
index 92b2e8d6f082b87e85c92c9a5b22ed31a7717349..13d6d385a2f2d4c127cf49af7001d7a1a57024fc 100644 (file)
@@ -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)
@@ -585,11 +584,12 @@ 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];
 
-   if (unlikely(INTEL_DEBUG & DEBUG_GS))
       brw_dump_ir(brw, "geometry", prog, &shader->base, NULL);
+   }
 
    /* Compile the geometry shader in DUAL_OBJECT dispatch mode, if we can do
     * so without spilling. If the GS invocations count > 1, then we can't use
@@ -599,7 +599,7 @@ brw_gs_emit(struct brw_context *brw,
        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,
@@ -619,7 +619,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);
index 68756f74904e65aa52ea349ef7e3f65123119845..25415ea3df1e7d776af150f79c376b5966fa96f4 100644 (file)
@@ -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);
 
index 87b13614186fff6e17e1a67fd60c6015e87c6fe6..921e9099e08241a7eae167b30e36c70a7c111f08 100644 (file)
@@ -3356,14 +3356,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),
@@ -3377,8 +3377,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;
 
index c739e41d1d44aeaafcd19ef0e20f13278fb4d7f6..79cb40f297766131a3bdce11090e6f9d92fa4f2d 100644 (file)
@@ -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),
index 207cd5c94d006bbc3fb71a722df055af23646d22..97308a78a3ca61f91fbccdf21bd2990f15f62665 100644 (file)
@@ -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:
index 4e971b54d029f7331deca82e410170be97c4409b..7563aef8bf28cc335a0ebac85ee1e04e7ecba691 100644 (file)
@@ -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, NULL,
                      false, false /* no_spills */,
                      ST_NONE, ST_NONE, ST_NONE)
    {