[Mesa-dev] [PATCH 01/17] i965/vs: Make type of vec4_visitor::vp more generic.

Paul Berry stereotype441 at gmail.com
Sun Apr 7 15:53:54 PDT 2013


The vec4_visitor functions don't use any VS specific data from
vec4_visitor::vp.  So rename it to just "p" and change its type from
struct gl_vertex_program * to struct gl_program *.  This will allow
the code to be re-used for geometry shaders.
---
 src/mesa/drivers/dri/i965/brw_vec4.cpp         | 7 +++----
 src/mesa/drivers/dri/i965/brw_vec4.h           | 2 +-
 src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 8 ++++----
 src/mesa/drivers/dri/i965/brw_vec4_vp.cpp      | 6 +++---
 4 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index c58fb44..7eac6c9 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -1363,8 +1363,7 @@ void
 vec4_visitor::emit_shader_time_write(enum shader_time_shader_type type,
                                      src_reg value)
 {
-   int shader_time_index = brw_get_shader_time_index(brw, prog, &vp->Base,
-                                                     type);
+   int shader_time_index = brw_get_shader_time_index(brw, prog, p, type);
 
    dst_reg dst =
       dst_reg(this, glsl_type::get_array_instance(glsl_type::vec4_type, 2));
@@ -1385,7 +1384,7 @@ vec4_visitor::emit_shader_time_write(enum shader_time_shader_type type,
 bool
 vec4_visitor::run()
 {
-   sanity_param_count = vp->Base.Parameters->NumParameters;
+   sanity_param_count = p->Parameters->NumParameters;
 
    if (INTEL_DEBUG & DEBUG_SHADER_TIME)
       emit_shader_time_begin();
@@ -1469,7 +1468,7 @@ vec4_visitor::run()
     * _mesa_associate_uniform_storage() would point to freed memory.  Make
     * sure that didn't happen.
     */
-   assert(sanity_param_count == vp->Base.Parameters->NumParameters);
+   assert(sanity_param_count == p->Parameters->NumParameters);
 
    return !failed;
 }
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h
index 8f130e1..a9d99b1 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -226,7 +226,7 @@ public:
       return dst_reg(retype(brw_null_reg(), BRW_REGISTER_TYPE_D));
    }
 
-   struct gl_vertex_program *vp;
+   struct gl_program *p;
    struct brw_vs_compile *c;
    struct brw_vs_prog_data *prog_data;
    unsigned int sanity_param_count;
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index ca1cfe8..a7cfc9e 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -676,9 +676,9 @@ vec4_visitor::setup_builtin_uniform_values(ir_variable *ir)
        * ParameterValues directly, since unlike brw_fs.cpp, we never
        * add new state references during compile.
        */
-      int index = _mesa_add_state_reference(this->vp->Base.Parameters,
+      int index = _mesa_add_state_reference(this->p->Parameters,
 					    (gl_state_index *)slots[i].tokens);
-      float *values = &this->vp->Base.Parameters->ParameterValues[index][0].f;
+      float *values = &this->p->Parameters->ParameterValues[index][0].f;
 
       this->uniform_vector_size[this->uniforms] = 0;
       /* Add each of the unique swizzled channels of the element.
@@ -2077,7 +2077,7 @@ vec4_visitor::visit(ir_call *ir)
 void
 vec4_visitor::visit(ir_texture *ir)
 {
-   int sampler = _mesa_get_sampler_uniform_value(ir->sampler, prog, &vp->Base);
+   int sampler = _mesa_get_sampler_uniform_value(ir->sampler, prog, p);
 
    /* Should be lowered by do_lower_texture_projection */
    assert(!ir->projector);
@@ -2993,7 +2993,7 @@ vec4_visitor::vec4_visitor(struct brw_context *brw,
    memset(this->output_reg_annotation, 0, sizeof(this->output_reg_annotation));
 
    this->c = c;
-   this->vp = &c->vp->program;
+   this->p = &c->vp->program.Base;
    this->prog_data = &c->prog_data;
 
    this->variable_ht = hash_table_ctor(0,
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_vp.cpp b/src/mesa/drivers/dri/i965/brw_vec4_vp.cpp
index 1acdd52..fc3a878 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_vp.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_vp.cpp
@@ -84,8 +84,8 @@ vec4_visitor::emit_vertex_program_code()
    src_reg one = src_reg(this, glsl_type::float_type);
    emit(MOV(dst_reg(one), src_reg(1.0f)));
 
-   for (unsigned int insn = 0; insn < vp->Base.NumInstructions; insn++) {
-      const struct prog_instruction *vpi = &vp->Base.Instructions[insn];
+   for (unsigned int insn = 0; insn < p->NumInstructions; insn++) {
+      const struct prog_instruction *vpi = &p->Instructions[insn];
       base_ir = vpi;
 
       dst_reg dst;
@@ -423,7 +423,7 @@ void
 vec4_visitor::setup_vp_regs()
 {
    /* PROGRAM_TEMPORARY */
-   int num_temp = vp->Base.NumTemporaries;
+   int num_temp = p->NumTemporaries;
    vp_temp_regs = rzalloc_array(mem_ctx, src_reg, num_temp);
    for (int i = 0; i < num_temp; i++)
       vp_temp_regs[i] = src_reg(this, glsl_type::vec4_type);
-- 
1.8.2



More information about the mesa-dev mailing list