[Mesa-dev] [PATCH 06/19] st_glsl_to_tgsi: apply usagemasks to array temporaries

Nicolai Hähnle nhaehnle at gmail.com
Tue Aug 9 10:36:35 UTC 2016


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

---
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 0913dbb..f2663bc 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -341,20 +341,21 @@ static st_dst_reg undef_dst = st_dst_reg(PROGRAM_UNDEFINED, SWIZZLE_NOOP, GLSL_T
 
 struct array_decl {
    unsigned mesa_index;
    unsigned array_id;
    unsigned array_size;
    enum glsl_base_type array_type;
 };
 
 struct temp_array_decl {
    unsigned size;
+   unsigned usagemask;
 };
 
 static enum glsl_base_type
 find_array_type(struct array_decl *arrays, unsigned count, unsigned array_id)
 {
    unsigned i;
 
    for (i = 0; i < count; i++) {
       struct array_decl *decl = &arrays[i];
 
@@ -1221,20 +1222,21 @@ glsl_to_tgsi_visitor::get_temp(const glsl_type *type)
    if (!options->EmitNoIndirectTemp && type_has_array_or_matrix(type)) {
       if (num_temp_arrays >= max_num_temp_arrays) {
          max_num_temp_arrays += 32;
          temp_arrays = (temp_array_decl*)
             realloc(temp_arrays, sizeof(temp_arrays[0]) * max_num_temp_arrays);
       }
 
       src.file = PROGRAM_ARRAY;
       src.index = num_temp_arrays << 16 | 0x8000;
       temp_arrays[num_temp_arrays].size = type_size(type);
+      temp_arrays[num_temp_arrays].usagemask = st_glsl_type_usagemask(type);
       ++num_temp_arrays;
 
    } else {
       src.file = PROGRAM_TEMPORARY;
       src.index = next_temp;
       next_temp += type_size(type);
    }
 
    if (type->is_array() || type->is_record()) {
       src.swizzle = SWIZZLE_NOOP;
@@ -6037,21 +6039,22 @@ st_translate_program(
 
    /*
     * Declare temporary arrays.
     */
    t->num_temp_arrays = program->num_temp_arrays;
    if (t->num_temp_arrays) {
       t->temp_arrays = (struct ureg_dst*)
                        calloc(1, sizeof(t->temp_arrays[0]) * t->num_temp_arrays);
       for (i = 0; i < t->num_temp_arrays; ++i)
          t->temp_arrays[i] = ureg_DECL_array_temporary(
-            t->ureg, program->temp_arrays[i].size, TGSI_WRITEMASK_XYZW, TRUE);
+            t->ureg, program->temp_arrays[i].size,
+            program->temp_arrays[i].usagemask, TRUE);
    }
 
    /*
     * Declare input attributes.
     */
    switch (procType) {
    case PIPE_SHADER_FRAGMENT:
       for (i = 0; i < numInputs; i++) {
          unsigned array_id = 0;
          unsigned array_size;
-- 
2.7.4



More information about the mesa-dev mailing list