Mesa (master): st/glsl_to_tgsi: handle different attrib size
Dave Airlie
airlied at kemper.freedesktop.org
Fri Jan 1 00:22:39 UTC 2016
Module: Mesa
Branch: master
Commit: d214ce86cf0d5f5bd0135f1558194391e72501d0
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d214ce86cf0d5f5bd0135f1558194391e72501d0
Author: Dave Airlie <airlied at redhat.com>
Date: Sat Dec 19 14:43:18 2015 +1000
st/glsl_to_tgsi: handle different attrib size
vertex inputs are counted differently in some cases, with
vertex inputs we need to make sure we don't double count them.
Signed-off-by: Dave Airlie <airlied at redhat.com>
---
src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 9f0efb8..d7b3e0e 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -1085,7 +1085,7 @@ glsl_to_tgsi_visitor::st_src_reg_for_type(int type, int val)
}
static int
-type_size(const struct glsl_type *type)
+attrib_type_size(const struct glsl_type *type, bool is_vs_input)
{
unsigned int i;
int size;
@@ -1108,7 +1108,7 @@ type_size(const struct glsl_type *type)
break;
case GLSL_TYPE_DOUBLE:
if (type->is_matrix()) {
- if (type->vector_elements <= 2)
+ if (type->vector_elements <= 2 || is_vs_input)
return type->matrix_columns;
else
return type->matrix_columns * 2;
@@ -1116,7 +1116,7 @@ type_size(const struct glsl_type *type)
/* For doubles if we have a double or dvec2 they fit in one
* vec4, else they need 2 vec4s.
*/
- if (type->vector_elements <= 2)
+ if (type->vector_elements <= 2 || is_vs_input)
return 1;
else
return 2;
@@ -1124,11 +1124,11 @@ type_size(const struct glsl_type *type)
break;
case GLSL_TYPE_ARRAY:
assert(type->length > 0);
- return type_size(type->fields.array) * type->length;
+ return attrib_type_size(type->fields.array, is_vs_input) * type->length;
case GLSL_TYPE_STRUCT:
size = 0;
for (i = 0; i < type->length; i++) {
- size += type_size(type->fields.structure[i].type);
+ size += attrib_type_size(type->fields.structure[i].type, is_vs_input);
}
return size;
case GLSL_TYPE_SAMPLER:
@@ -1148,6 +1148,11 @@ type_size(const struct glsl_type *type)
return 0;
}
+static int
+type_size(const struct glsl_type *type)
+{
+ return attrib_type_size(type, false);
+}
/**
* If the given GLSL type is an array or matrix or a structure containing
@@ -2454,6 +2459,10 @@ glsl_to_tgsi_visitor::visit(ir_dereference_array *ir)
element_size = 1;
if (index) {
+
+ if (this->prog->Target == GL_VERTEX_PROGRAM_ARB &&
+ src.file == PROGRAM_INPUT)
+ element_size = attrib_type_size(ir->type, true);
if (is_2D) {
src.index2D = index->value.i[0];
src.has_index2 = true;
More information about the mesa-commit
mailing list