From: Marek Olšák
---
src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 31 ++
1 file changed, 19 insertions(+), 12 deletions(-)
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index fd2485d..5bc2661 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -83,54 +83,57 @@ static int swizzle_for_type(const glsl_type *type, int
component = 0)
swizzle += component * MAKE_SWIZZLE4(1, 1, 1, 1);
return swizzle;
}
/**
* This struct is a corresponding struct to TGSI ureg_src.
*/
class st_src_reg {
public:
st_src_reg(gl_register_file file, int index, const glsl_type *type,
- int component = 0)
+ int component = 0, unsigned array_id = 0)
{
+ assert(file != PROGRAM_ARRAY || array_id != 0);
this->file = file;
this->index = index;
this->swizzle = swizzle_for_type(type, component);
this->negate = 0;
this->index2D = 0;
this->type = type ? type->base_type : GLSL_TYPE_ERROR;
this->reladdr = NULL;
this->reladdr2 = NULL;
this->has_index2 = false;
this->double_reg2 = false;
- this->array_id = 0;
+ this->array_id = array_id;
this->is_double_vertex_input = false;
}
st_src_reg(gl_register_file file, int index, enum glsl_base_type type)
{
+ assert(file != PROGRAM_ARRAY); /* need array_id > 0 */
this->type = type;
this->file = file;
this->index = index;
this->index2D = 0;
this->swizzle = SWIZZLE_XYZW;
this->negate = 0;
this->reladdr = NULL;
this->reladdr2 = NULL;
this->has_index2 = false;
this->double_reg2 = false;
this->array_id = 0;
this->is_double_vertex_input = false;
}
st_src_reg(gl_register_file file, int index, enum glsl_base_type type, int
index2D)
{
+ assert(file != PROGRAM_ARRAY); /* need array_id > 0 */
this->type = type;
this->file = file;
this->index = index;
this->index2D = index2D;
this->swizzle = SWIZZLE_XYZW;
this->negate = 0;
this->reladdr = NULL;
this->reladdr2 = NULL;
this->has_index2 = false;
this->double_reg2 = false;
@@ -172,33 +175,35 @@ public:
*/
bool double_reg2;
unsigned array_id;
bool is_double_vertex_input;
};
class st_dst_reg {
public:
st_dst_reg(gl_register_file file, int writemask, enum glsl_base_type type,
int index)
{
+ assert(file != PROGRAM_ARRAY); /* need array_id > 0 */
this->file = file;
this->index = index;
this->index2D = 0;
this->writemask = writemask;
this->reladdr = NULL;
this->reladdr2 = NULL;
this->has_index2 = false;
this->type = type;
this->array_id = 0;
}
st_dst_reg(gl_register_file file, int writemask, enum glsl_base_type type)
{
+ assert(file != PROGRAM_ARRAY); /* need array_id > 0 */
this->file = file;
this->index = 0;
this->index2D = 0;
this->writemask = writemask;
this->reladdr = NULL;
this->reladdr2 = NULL;
this->has_index2 = false;
this->type = type;
this->array_id = 0;
}
@@ -289,21 +294,21 @@ public:
class function_entry *function; /* Set on TGSI_OPCODE_CAL or
TGSI_OPCODE_BGNSUB */
const struct tgsi_opcode_info *info;
};
class variable_storage : public exec_node {
public:
variable_storage(ir_variable *var, gl_register_file file, int index,
unsigned array_id = 0)
: file(file), index(index), component(0), var(var), array_id(array_id)
{
- /* empty */
+ assert(file != PROGRAM_ARRAY || array_id != 0);
}
gl_register_file file;
int index;
/* Explicit component location. This is given in terms of the GLSL-style
* swizzles where each double is a single component, i.e. for 64-bit types
* it can only be 0 or 1.
*/
int component;
@@ -1255,21 +1260,22 @@ glsl_to_tgsi_visitor::get_temp(const glsl_type *type)
src.negate = 0;
if (!options->EmitNoIndirectTemp && type_has_array_or_matrix(type)) {
if (next_array >= max_num_arrays) {
max_num_arrays += 32;
array_sizes = (unsigned*)
realloc(array_sizes, sizeof(array_sizes[0]) * max_num_arrays);
}
src.file = PROGRAM_ARRAY;
- src.index = next_array << 16 | 0x8000;
+ src.index = 0;
+ src.array_id = next_array + 1;
array_sizes[next_array] = type_size(type);
++next_array;
} else {
src.file = PROGRAM_TEMPORARY;
src.index = next_temp;
next_temp += type_size(type);
}
if (type->is_array() || type->is_record()) {
@@ -1330,21 +1336,22 @@ glsl_to_tgsi_visitor::visit(ir_variable *ir)
dst = undef_dst;
} else {
/* The variable_storage