[Mesa-dev] [PATCH 19/23] i965: Add a fs_visitor constructor that takes a brw_gs_compile.

Kenneth Graunke kenneth at whitecape.org
Wed Sep 30 00:58:23 PDT 2015


Unlike the vs/wm structs, brw_gs_compile is actually useful: it contains
the input VUE map and information about the control data headers.
Passing this in allows us to share that code in brw_gs.c, and calculate
them before deciding on vec4 vs. scalar mode, as it's independent of
that choice.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/drivers/dri/i965/brw_fs.h           | 10 ++++++++-
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 32 ++++++++++++++++++++++++++--
 2 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h
index 41b6622..b4175fe 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -62,6 +62,8 @@ namespace brw {
    class fs_live_variables;
 }
 
+struct brw_gs_compile;
+
 static inline fs_reg
 offset(fs_reg reg, const brw::fs_builder& bld, unsigned delta)
 {
@@ -100,7 +102,11 @@ public:
               struct gl_program *prog,
               unsigned dispatch_width,
               int shader_time_index);
-
+   fs_visitor(const struct brw_compiler *compiler, void *log_data,
+              void *mem_ctx,
+              struct brw_gs_compile *gs_compile,
+              struct gl_shader_program *shader_prog);
+   void init();
    ~fs_visitor();
 
    fs_reg vgrf(const glsl_type *const type);
@@ -308,6 +314,8 @@ public:
    const void *const key;
    const struct brw_sampler_prog_key_data *key_tex;
 
+   struct brw_gs_compile *gs_compile;
+
    struct brw_stage_prog_data *prog_data;
    unsigned int sanity_param_count;
 
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 316b7d6..6db437f 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -41,6 +41,7 @@
 #include "brw_wm.h"
 #include "brw_cs.h"
 #include "brw_vec4.h"
+#include "brw_vec4_gs_visitor.h"
 #include "brw_fs.h"
 #include "main/uniforms.h"
 #include "glsl/glsl_types.h"
@@ -1083,12 +1084,35 @@ fs_visitor::fs_visitor(const struct brw_compiler *compiler, void *log_data,
                        int shader_time_index)
    : backend_shader(compiler, log_data, mem_ctx,
                     shader_prog, prog, prog_data, stage),
-     key(key), prog_data(prog_data),
+     key(key),
+     gs_compile(NULL),
      dispatch_width(dispatch_width),
      shader_time_index(shader_time_index),
-     promoted_constants(0),
      bld(fs_builder(this, dispatch_width).at_end())
 {
+   init();
+}
+
+fs_visitor::fs_visitor(const struct brw_compiler *compiler, void *log_data,
+                       void *mem_ctx,
+                       struct brw_gs_compile *c,
+                       struct gl_shader_program *shader_prog)
+   : backend_shader(compiler, log_data, mem_ctx, shader_prog,
+                    &c->gp->program.Base, &c->prog_data.base.base,
+                    MESA_SHADER_GEOMETRY),
+     key(&c->key),
+     gs_compile(c),
+     dispatch_width(8),
+     shader_time_index(ST_GS),
+     bld(fs_builder(this, dispatch_width).at_end())
+{
+   init();
+}
+
+
+void
+fs_visitor::init()
+{
    switch (stage) {
    case MESA_SHADER_FRAGMENT:
       key_tex = &((const brw_wm_prog_key *) key)->tex;
@@ -1106,6 +1130,8 @@ fs_visitor::fs_visitor(const struct brw_compiler *compiler, void *log_data,
       unreachable("unhandled shader stage");
    }
 
+   this->prog_data = this->stage_prog_data;
+
    this->failed = false;
    this->simd16_unsupported = false;
    this->no16_msg = NULL;
@@ -1131,6 +1157,8 @@ fs_visitor::fs_visitor(const struct brw_compiler *compiler, void *log_data,
    this->pull_constant_loc = NULL;
    this->push_constant_loc = NULL;
 
+   this->promoted_constants = 0,
+
    this->spilled_any_registers = false;
    this->do_dual_src = false;
 
-- 
2.5.3



More information about the mesa-dev mailing list