[Mesa-dev] [RFC PATCH 29/56] glsl: keep track of which inputs/outputs are per-patch

Chris Forbes chrisf at ijw.co.nz
Sat Sep 20 18:41:09 PDT 2014


From: Ilia Mirkin <imirkin at alum.mit.edu>

---
 src/glsl/ir_set_program_inouts.cpp | 21 +++++++++++++++------
 src/mesa/main/mtypes.h             |  3 +++
 2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/src/glsl/ir_set_program_inouts.cpp b/src/glsl/ir_set_program_inouts.cpp
index ff15362..91c7ba3 100644
--- a/src/glsl/ir_set_program_inouts.cpp
+++ b/src/glsl/ir_set_program_inouts.cpp
@@ -83,7 +83,7 @@ is_shader_inout(ir_variable *var)
 
 static void
 mark(struct gl_program *prog, ir_variable *var, int offset, int len,
-     bool is_fragment_shader)
+     gl_shader_stage stage)
 {
    /* As of GLSL 1.20, varyings can only be floats, floating-point
     * vectors or matrices, or arrays of them.  For Mesa programs using
@@ -97,8 +97,8 @@ mark(struct gl_program *prog, ir_variable *var, int offset, int len,
       GLbitfield64 bitfield =
          BITFIELD64_BIT(var->data.location + var->data.index + offset + i);
       if (var->data.mode == ir_var_shader_in) {
-	 prog->InputsRead |= bitfield;
-         if (is_fragment_shader) {
+         prog->InputsRead |= bitfield;
+         if (stage == MESA_SHADER_FRAGMENT) {
             gl_fragment_program *fprog = (gl_fragment_program *) prog;
             fprog->InterpQualifier[var->data.location +
                                    var->data.index + offset + i] =
@@ -107,12 +107,21 @@ mark(struct gl_program *prog, ir_variable *var, int offset, int len,
                fprog->IsCentroid |= bitfield;
             if (var->data.sample)
                fprog->IsSample |= bitfield;
+         } else if (stage == MESA_SHADER_TESS_EVAL) {
+            gl_tess_eval_program *tprog = (gl_tess_eval_program *)prog;
+            if (var->data.patch)
+               tprog->IsPatch |= bitfield;
          }
       } else if (var->data.mode == ir_var_system_value) {
          prog->SystemValuesRead |= bitfield;
       } else {
          assert(var->data.mode == ir_var_shader_out);
-	 prog->OutputsWritten |= bitfield;
+         prog->OutputsWritten |= bitfield;
+         if (stage == MESA_SHADER_TESS_CTRL) {
+            gl_tess_ctrl_program *tprog = (gl_tess_ctrl_program *)prog;
+            if (var->data.patch)
+               tprog->IsPatch |= bitfield;
+         }
       }
    }
 }
@@ -149,7 +158,7 @@ ir_set_program_inouts_visitor::mark_whole_variable(ir_variable *var)
    }
 
    mark(this->prog, var, 0, type->count_attribute_slots(),
-        this->shader_stage == MESA_SHADER_FRAGMENT);
+        this->shader_stage);
 }
 
 /* Default handler: Mark all the locations in the variable as used. */
@@ -279,7 +288,7 @@ ir_set_program_inouts_visitor::try_mark_partial_variable(ir_variable *var,
    }
 
    mark(this->prog, var, index_as_constant->value.u[0] * elem_width,
-        elem_width, this->shader_stage == MESA_SHADER_FRAGMENT);
+        elem_width, this->shader_stage);
    return true;
 }
 
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index ef3fee8..e3420f2 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2295,6 +2295,8 @@ struct gl_tess_ctrl_program
 {
    struct gl_program Base;   /**< base class */
 
+   GLbitfield64 IsPatch;
+
    /* output layout */
    GLint VerticesOut;
 };
@@ -2305,6 +2307,7 @@ struct gl_tess_eval_program
 {
    struct gl_program Base;   /**< base class */
 
+   GLbitfield64 IsPatch;
    /* input layout */
    GLenum PrimitiveMode; /* GL_TRIANGLES, GL_QUADS or GL_ISOLINES */
    GLenum Spacing;       /* GL_EQUAL, GL_FRACTIONAL_EVEN or
-- 
2.1.0



More information about the mesa-dev mailing list