glsl: Use glsl_type C helpers
Acked-by: Jesse Natalie <jenatali@microsoft.com> Acked-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26707>
This commit is contained in:
@@ -145,19 +145,19 @@ _mesa_ast_array_index_to_hir(void *mem_ctx,
|
||||
ir_rvalue *array, ir_rvalue *idx,
|
||||
YYLTYPE &loc, YYLTYPE &idx_loc)
|
||||
{
|
||||
if (!array->type->is_error()
|
||||
&& !array->type->is_array()
|
||||
&& !array->type->is_matrix()
|
||||
&& !array->type->is_vector()) {
|
||||
if (!glsl_type_is_error(array->type)
|
||||
&& !glsl_type_is_array(array->type)
|
||||
&& !glsl_type_is_matrix(array->type)
|
||||
&& !glsl_type_is_vector(array->type)) {
|
||||
_mesa_glsl_error(& idx_loc, state,
|
||||
"cannot dereference non-array / non-matrix / "
|
||||
"non-vector");
|
||||
}
|
||||
|
||||
if (!idx->type->is_error()) {
|
||||
if (!idx->type->is_integer_32()) {
|
||||
if (!glsl_type_is_error(idx->type)) {
|
||||
if (!glsl_type_is_integer_32(idx->type)) {
|
||||
_mesa_glsl_error(& idx_loc, state, "array index must be integer type");
|
||||
} else if (!idx->type->is_scalar()) {
|
||||
} else if (!glsl_type_is_scalar(idx->type)) {
|
||||
_mesa_glsl_error(& idx_loc, state, "array index must be scalar");
|
||||
}
|
||||
}
|
||||
@@ -168,7 +168,7 @@ _mesa_ast_array_index_to_hir(void *mem_ctx,
|
||||
* declared size.
|
||||
*/
|
||||
ir_constant *const const_index = idx->constant_expression_value(mem_ctx);
|
||||
if (const_index != NULL && idx->type->is_integer_32()) {
|
||||
if (const_index != NULL && glsl_type_is_integer_32(idx->type)) {
|
||||
const int idx = const_index->value.i[0];
|
||||
const char *type_name = "error";
|
||||
unsigned bound = 0;
|
||||
@@ -181,12 +181,12 @@ _mesa_ast_array_index_to_hir(void *mem_ctx,
|
||||
* declared size. It is also illegal to index an array with a
|
||||
* negative constant expression."
|
||||
*/
|
||||
if (array->type->is_matrix()) {
|
||||
if (array->type->row_type()->vector_elements <= idx) {
|
||||
if (glsl_type_is_matrix(array->type)) {
|
||||
if (glsl_get_row_type(array->type)->vector_elements <= idx) {
|
||||
type_name = "matrix";
|
||||
bound = array->type->row_type()->vector_elements;
|
||||
bound = glsl_get_row_type(array->type)->vector_elements;
|
||||
}
|
||||
} else if (array->type->is_vector()) {
|
||||
} else if (glsl_type_is_vector(array->type)) {
|
||||
if (array->type->vector_elements <= idx) {
|
||||
type_name = "vector";
|
||||
bound = array->type->vector_elements;
|
||||
@@ -196,10 +196,10 @@ _mesa_ast_array_index_to_hir(void *mem_ctx,
|
||||
* that we don't need to verify that the type is an array before
|
||||
* doing the bounds checking.
|
||||
*/
|
||||
if ((array->type->array_size() > 0)
|
||||
&& (array->type->array_size() <= idx)) {
|
||||
if ((glsl_array_size(array->type) > 0)
|
||||
&& (glsl_array_size(array->type) <= idx)) {
|
||||
type_name = "array";
|
||||
bound = array->type->array_size();
|
||||
bound = glsl_array_size(array->type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,10 +210,10 @@ _mesa_ast_array_index_to_hir(void *mem_ctx,
|
||||
_mesa_glsl_error(& loc, state, "%s index must be >= 0", type_name);
|
||||
}
|
||||
|
||||
if (array->type->is_array())
|
||||
if (glsl_type_is_array(array->type))
|
||||
update_max_array_access(array, idx, &loc, state);
|
||||
} else if (const_index == NULL && array->type->is_array()) {
|
||||
if (array->type->is_unsized_array()) {
|
||||
} else if (const_index == NULL && glsl_type_is_array(array->type)) {
|
||||
if (glsl_type_is_unsized_array(array->type)) {
|
||||
int implicit_size = get_implicit_array_size(state, array);
|
||||
if (implicit_size) {
|
||||
ir_variable *v = array->whole_variable_referenced();
|
||||
@@ -239,7 +239,7 @@ _mesa_ast_array_index_to_hir(void *mem_ctx,
|
||||
*/
|
||||
ir_variable *var = array->variable_referenced();
|
||||
const glsl_type *iface_type = var->get_interface_type();
|
||||
int field_index = iface_type->field_index(var->name);
|
||||
int field_index = glsl_get_field_index(iface_type, var->name);
|
||||
/* Field index can be < 0 for instance arrays */
|
||||
if (field_index >= 0 &&
|
||||
field_index != (int) iface_type->length - 1) {
|
||||
@@ -248,7 +248,7 @@ _mesa_ast_array_index_to_hir(void *mem_ctx,
|
||||
"SSBO.");
|
||||
}
|
||||
}
|
||||
} else if (array->type->without_array()->is_interface()
|
||||
} else if (glsl_type_is_interface(glsl_without_array(array->type))
|
||||
&& ((array->variable_referenced()->data.mode == ir_var_uniform
|
||||
&& !state->is_version(400, 320)
|
||||
&& !state->ARB_gpu_shader5_enable
|
||||
@@ -277,7 +277,7 @@ _mesa_ast_array_index_to_hir(void *mem_ctx,
|
||||
*/
|
||||
ir_variable *v = array->whole_variable_referenced();
|
||||
if (v != NULL)
|
||||
v->data.max_array_access = array->type->array_size() - 1;
|
||||
v->data.max_array_access = glsl_array_size(array->type) - 1;
|
||||
}
|
||||
|
||||
/* From page 23 (29 of the PDF) of the GLSL 1.30 spec:
|
||||
@@ -305,7 +305,7 @@ _mesa_ast_array_index_to_hir(void *mem_ctx,
|
||||
* "Samplers aggregated into arrays within a shader (using square
|
||||
* brackets []) can be indexed with arbitrary integer expressions."
|
||||
*/
|
||||
if (array->type->without_array()->is_sampler()) {
|
||||
if (glsl_type_is_sampler(glsl_without_array(array->type))) {
|
||||
if (!state->is_version(400, 320) &&
|
||||
!state->ARB_gpu_shader5_enable &&
|
||||
!state->EXT_gpu_shader5_enable &&
|
||||
@@ -339,7 +339,7 @@ _mesa_ast_array_index_to_hir(void *mem_ctx,
|
||||
* non-constant indexing of image arrays, but behavior is left undefined
|
||||
* in cases where the indexing expression is not dynamically uniform.
|
||||
*/
|
||||
if (state->es_shader && array->type->without_array()->is_image()) {
|
||||
if (state->es_shader && glsl_type_is_image(glsl_without_array(array->type))) {
|
||||
_mesa_glsl_error(&loc, state,
|
||||
"image arrays indexed with non-constant "
|
||||
"expressions are forbidden in GLSL ES.");
|
||||
@@ -349,11 +349,11 @@ _mesa_ast_array_index_to_hir(void *mem_ctx,
|
||||
/* After performing all of the error checking, generate the IR for the
|
||||
* expression.
|
||||
*/
|
||||
if (array->type->is_array()
|
||||
|| array->type->is_matrix()
|
||||
|| array->type->is_vector()) {
|
||||
if (glsl_type_is_array(array->type)
|
||||
|| glsl_type_is_matrix(array->type)
|
||||
|| glsl_type_is_vector(array->type)) {
|
||||
return new(mem_ctx) ir_dereference_array(array, idx);
|
||||
} else if (array->type->is_error()) {
|
||||
} else if (glsl_type_is_error(array->type)) {
|
||||
return array;
|
||||
} else {
|
||||
ir_rvalue *result = new(mem_ctx) ir_dereference_array(array, idx);
|
||||
|
||||
@@ -353,7 +353,7 @@ verify_parameter_modes(_mesa_glsl_parse_state *state,
|
||||
}
|
||||
}
|
||||
|
||||
if (formal->type->is_image() &&
|
||||
if (glsl_type_is_image(formal->type) &&
|
||||
actual->variable_referenced()) {
|
||||
if (!verify_image_parameter(&loc, state, formal,
|
||||
actual->variable_referenced()))
|
||||
@@ -563,7 +563,7 @@ generate_call(exec_list *instructions, ir_function_signature *sig,
|
||||
ir_rvalue *actual = (ir_rvalue *) actual_node;
|
||||
ir_variable *formal = (ir_variable *) formal_node;
|
||||
|
||||
if (formal->type->is_numeric() || formal->type->is_boolean()) {
|
||||
if (glsl_type_is_numeric(formal->type) || glsl_type_is_boolean(formal->type)) {
|
||||
switch (formal->data.mode) {
|
||||
case ir_var_const_in:
|
||||
case ir_var_function_in: {
|
||||
@@ -643,7 +643,7 @@ generate_call(exec_list *instructions, ir_function_signature *sig,
|
||||
}
|
||||
|
||||
ir_dereference_variable *deref = NULL;
|
||||
if (!sig->return_type->is_void()) {
|
||||
if (!glsl_type_is_void(sig->return_type)) {
|
||||
/* Create a new temporary to hold the return value. */
|
||||
char *const name = ir_variable::temporaries_allocate_names
|
||||
? ralloc_asprintf(ctx, "%s_retval", sig->function_name())
|
||||
@@ -742,7 +742,7 @@ match_subroutine_by_name(const char *name,
|
||||
|
||||
for (int i = 0; i < state->num_subroutine_types; i++) {
|
||||
f = state->subroutine_types[i];
|
||||
if (strcmp(f->name, glsl_get_type_name(var->type->without_array())))
|
||||
if (strcmp(f->name, glsl_get_type_name(glsl_without_array(var->type))))
|
||||
continue;
|
||||
found = f;
|
||||
break;
|
||||
@@ -874,7 +874,7 @@ convert_component(ir_rvalue *src, const glsl_type *desired_type)
|
||||
const unsigned b = src->type->base_type;
|
||||
ir_expression *result = NULL;
|
||||
|
||||
if (src->type->is_error())
|
||||
if (glsl_type_is_error(src->type))
|
||||
return src;
|
||||
|
||||
assert(a <= GLSL_TYPE_IMAGE);
|
||||
@@ -1109,9 +1109,9 @@ implicitly_convert_component(ir_rvalue * &from, const glsl_base_type to,
|
||||
|
||||
if (to != from->type->base_type) {
|
||||
const glsl_type *desired_type =
|
||||
glsl_type::get_instance(to,
|
||||
from->type->vector_elements,
|
||||
from->type->matrix_columns);
|
||||
glsl_simple_type(to,
|
||||
from->type->vector_elements,
|
||||
from->type->matrix_columns);
|
||||
|
||||
if (_mesa_glsl_can_implicitly_convert(from->type, desired_type, state)) {
|
||||
/* Even though convert_component() implements the constructor
|
||||
@@ -1144,7 +1144,7 @@ static ir_rvalue *
|
||||
dereference_component(ir_rvalue *src, unsigned component)
|
||||
{
|
||||
void *ctx = ralloc_parent(src);
|
||||
assert(component < src->type->components());
|
||||
assert(component < glsl_get_components(src->type));
|
||||
|
||||
/* If the source is a constant, just create a new constant instead of a
|
||||
* dereference of the existing constant.
|
||||
@@ -1153,23 +1153,23 @@ dereference_component(ir_rvalue *src, unsigned component)
|
||||
if (constant)
|
||||
return new(ctx) ir_constant(constant, component);
|
||||
|
||||
if (src->type->is_scalar()) {
|
||||
if (glsl_type_is_scalar(src->type)) {
|
||||
return src;
|
||||
} else if (src->type->is_vector()) {
|
||||
} else if (glsl_type_is_vector(src->type)) {
|
||||
return new(ctx) ir_swizzle(src, component, 0, 0, 0, 1);
|
||||
} else {
|
||||
assert(src->type->is_matrix());
|
||||
assert(glsl_type_is_matrix(src->type));
|
||||
|
||||
/* Dereference a row of the matrix, then call this function again to get
|
||||
* a specific element from that row.
|
||||
*/
|
||||
const int c = component / src->type->column_type()->vector_elements;
|
||||
const int r = component % src->type->column_type()->vector_elements;
|
||||
const int c = component / glsl_get_column_type(src->type)->vector_elements;
|
||||
const int r = component % glsl_get_column_type(src->type)->vector_elements;
|
||||
ir_constant *const col_index = new(ctx) ir_constant(c);
|
||||
ir_dereference *const col = new(ctx) ir_dereference_array(src,
|
||||
col_index);
|
||||
|
||||
col->type = src->type->column_type();
|
||||
col->type = glsl_get_column_type(src->type);
|
||||
|
||||
return dereference_component(col, r);
|
||||
}
|
||||
@@ -1206,12 +1206,12 @@ process_vec_mat_constructor(exec_list *instructions,
|
||||
process_parameters(instructions, &actual_parameters, parameters, state);
|
||||
|
||||
if (parameter_count == 0
|
||||
|| (constructor_type->is_vector() &&
|
||||
|| (glsl_type_is_vector(constructor_type) &&
|
||||
constructor_type->vector_elements != parameter_count)
|
||||
|| (constructor_type->is_matrix() &&
|
||||
|| (glsl_type_is_matrix(constructor_type) &&
|
||||
constructor_type->matrix_columns != parameter_count)) {
|
||||
_mesa_glsl_error(loc, state, "%s constructor must have %u parameters",
|
||||
constructor_type->is_vector() ? "vector" : "matrix",
|
||||
glsl_type_is_vector(constructor_type) ? "vector" : "matrix",
|
||||
constructor_type->vector_elements);
|
||||
return ir_rvalue::error_value(ctx);
|
||||
}
|
||||
@@ -1229,18 +1229,18 @@ process_vec_mat_constructor(exec_list *instructions,
|
||||
all_parameters_are_constant &=
|
||||
implicitly_convert_component(ir, constructor_type->base_type, state);
|
||||
|
||||
if (constructor_type->is_matrix()) {
|
||||
if (ir->type != constructor_type->column_type()) {
|
||||
if (glsl_type_is_matrix(constructor_type)) {
|
||||
if (ir->type != glsl_get_column_type(constructor_type)) {
|
||||
_mesa_glsl_error(loc, state, "type error in matrix constructor: "
|
||||
"expected: %s, found %s",
|
||||
glsl_get_type_name(constructor_type->column_type()),
|
||||
glsl_get_type_name(glsl_get_column_type(constructor_type)),
|
||||
glsl_get_type_name(ir->type));
|
||||
return ir_rvalue::error_value(ctx);
|
||||
}
|
||||
} else if (ir->type != constructor_type->get_scalar_type()) {
|
||||
} else if (ir->type != glsl_get_scalar_type(constructor_type)) {
|
||||
_mesa_glsl_error(loc, state, "type error in vector constructor: "
|
||||
"expected: %s, found %s",
|
||||
glsl_get_type_name(constructor_type->get_scalar_type()),
|
||||
glsl_get_type_name(glsl_get_scalar_type(constructor_type)),
|
||||
glsl_get_type_name(ir->type));
|
||||
return ir_rvalue::error_value(ctx);
|
||||
}
|
||||
@@ -1258,13 +1258,13 @@ process_vec_mat_constructor(exec_list *instructions,
|
||||
foreach_in_list(ir_rvalue, rhs, &actual_parameters) {
|
||||
ir_instruction *assignment = NULL;
|
||||
|
||||
if (var->type->is_matrix()) {
|
||||
if (glsl_type_is_matrix(var->type)) {
|
||||
ir_rvalue *lhs =
|
||||
new(ctx) ir_dereference_array(var, new(ctx) ir_constant(i));
|
||||
assignment = new(ctx) ir_assignment(lhs, rhs);
|
||||
} else {
|
||||
/* use writemask rather than index for vector */
|
||||
assert(var->type->is_vector());
|
||||
assert(glsl_type_is_vector(var->type));
|
||||
assert(i < 4);
|
||||
ir_dereference *lhs = new(ctx) ir_dereference_variable(var);
|
||||
assignment = new(ctx) ir_assignment(lhs, rhs, 1u << i);
|
||||
@@ -1309,7 +1309,7 @@ process_array_constructor(exec_list *instructions,
|
||||
exec_list actual_parameters;
|
||||
const unsigned parameter_count =
|
||||
process_parameters(instructions, &actual_parameters, parameters, state);
|
||||
bool is_unsized_array = constructor_type->is_unsized_array();
|
||||
bool is_unsized_array = glsl_type_is_unsized_array(constructor_type);
|
||||
|
||||
if ((parameter_count == 0) ||
|
||||
(!is_unsized_array && (constructor_type->length != parameter_count))) {
|
||||
@@ -1325,8 +1325,8 @@ process_array_constructor(exec_list *instructions,
|
||||
|
||||
if (is_unsized_array) {
|
||||
constructor_type =
|
||||
glsl_type::get_array_instance(constructor_type->fields.array,
|
||||
parameter_count);
|
||||
glsl_array_type(constructor_type->fields.array,
|
||||
parameter_count, 0);
|
||||
assert(constructor_type != NULL);
|
||||
assert(constructor_type->length == parameter_count);
|
||||
}
|
||||
@@ -1345,7 +1345,7 @@ process_array_constructor(exec_list *instructions,
|
||||
all_parameters_are_constant &=
|
||||
implicitly_convert_component(ir, element_type->base_type, state);
|
||||
|
||||
if (constructor_type->fields.array->is_unsized_array()) {
|
||||
if (glsl_type_is_unsized_array(constructor_type->fields.array)) {
|
||||
/* As the inner parameters of the constructor are created without
|
||||
* knowledge of each other we need to check to make sure unsized
|
||||
* parameters of unsized constructors all end up with the same size.
|
||||
@@ -1355,7 +1355,7 @@ process_array_constructor(exec_list *instructions,
|
||||
* vec4[](vec4(0.0), vec4(1.0), vec4(1.0)),
|
||||
* vec4[](vec4(0.0), vec4(1.0)));
|
||||
*/
|
||||
if (element_type->is_unsized_array()) {
|
||||
if (glsl_type_is_unsized_array(element_type)) {
|
||||
/* This is the first parameter so just get the type */
|
||||
element_type = ir->type;
|
||||
} else if (element_type != ir->type) {
|
||||
@@ -1376,10 +1376,9 @@ process_array_constructor(exec_list *instructions,
|
||||
}
|
||||
}
|
||||
|
||||
if (constructor_type->fields.array->is_unsized_array()) {
|
||||
if (glsl_type_is_unsized_array(constructor_type->fields.array)) {
|
||||
constructor_type =
|
||||
glsl_type::get_array_instance(element_type,
|
||||
parameter_count);
|
||||
glsl_array_type(element_type, parameter_count, 0);
|
||||
assert(constructor_type != NULL);
|
||||
assert(constructor_type->length == parameter_count);
|
||||
}
|
||||
@@ -1415,7 +1414,7 @@ single_scalar_parameter(exec_list *parameters)
|
||||
const ir_rvalue *const p = (ir_rvalue *) parameters->get_head_raw();
|
||||
assert(((ir_rvalue *)p)->as_rvalue() != NULL);
|
||||
|
||||
return (p->type->is_scalar() && p->next->is_tail_sentinel());
|
||||
return (glsl_type_is_scalar(p->type) && p->next->is_tail_sentinel());
|
||||
}
|
||||
|
||||
|
||||
@@ -1454,7 +1453,7 @@ emit_inline_vector_constructor(const glsl_type *type,
|
||||
* scalars. The components of the constructor parameters are assigned
|
||||
* to the vector in order until the vector is full.
|
||||
*/
|
||||
const unsigned lhs_components = type->components();
|
||||
const unsigned lhs_components = glsl_get_components(type);
|
||||
if (single_scalar_parameter(parameters)) {
|
||||
ir_rvalue *first_param = (ir_rvalue *)parameters->get_head_raw();
|
||||
return new(ctx) ir_swizzle(first_param, 0, 0, 0, 0, lhs_components);
|
||||
@@ -1467,7 +1466,7 @@ emit_inline_vector_constructor(const glsl_type *type,
|
||||
memset(&data, 0, sizeof(data));
|
||||
|
||||
foreach_in_list(ir_rvalue, param, parameters) {
|
||||
unsigned rhs_components = param->type->components();
|
||||
unsigned rhs_components = glsl_get_components(param->type);
|
||||
|
||||
/* Do not try to assign more components to the vector than it has! */
|
||||
if ((rhs_components + base_lhs_component) > lhs_components) {
|
||||
@@ -1520,9 +1519,7 @@ emit_inline_vector_constructor(const glsl_type *type,
|
||||
if (constant_mask != 0) {
|
||||
ir_dereference *lhs = new(ctx) ir_dereference_variable(var);
|
||||
const glsl_type *rhs_type =
|
||||
glsl_type::get_instance(var->type->base_type,
|
||||
constant_components,
|
||||
1);
|
||||
glsl_simple_type(var->type->base_type, constant_components, 1);
|
||||
ir_rvalue *rhs = new(ctx) ir_constant(rhs_type, &data);
|
||||
|
||||
ir_instruction *inst =
|
||||
@@ -1532,7 +1529,7 @@ emit_inline_vector_constructor(const glsl_type *type,
|
||||
|
||||
base_component = 0;
|
||||
foreach_in_list(ir_rvalue, param, parameters) {
|
||||
unsigned rhs_components = param->type->components();
|
||||
unsigned rhs_components = glsl_get_components(param->type);
|
||||
|
||||
/* Do not try to assign more components to the vector than it has! */
|
||||
if ((rhs_components + base_component) > lhs_components) {
|
||||
@@ -1595,8 +1592,8 @@ assign_to_matrix_column(ir_variable *var, unsigned column, unsigned row_base,
|
||||
ir_dereference *column_ref = new(mem_ctx) ir_dereference_array(var,
|
||||
col_idx);
|
||||
|
||||
assert(column_ref->type->components() >= (row_base + count));
|
||||
assert(src->type->components() >= (src_base + count));
|
||||
assert(glsl_get_components(column_ref->type) >= (row_base + count));
|
||||
assert(glsl_get_components(src->type) >= (src_base + count));
|
||||
|
||||
/* Generate a swizzle that extracts the number of components from the source
|
||||
* that are to be assigned to the column of the matrix.
|
||||
@@ -1657,16 +1654,16 @@ emit_inline_matrix_constructor(const glsl_type *type,
|
||||
* components with zero.
|
||||
*/
|
||||
glsl_base_type param_base_type = first_param->type->base_type;
|
||||
assert(first_param->type->is_float() || first_param->type->is_double());
|
||||
assert(glsl_type_is_float(first_param->type) || glsl_type_is_double(first_param->type));
|
||||
ir_variable *rhs_var =
|
||||
new(ctx) ir_variable(glsl_type::get_instance(param_base_type, 4, 1),
|
||||
new(ctx) ir_variable(glsl_simple_type(param_base_type, 4, 1),
|
||||
"mat_ctor_vec",
|
||||
ir_var_temporary);
|
||||
instructions->push_tail(rhs_var);
|
||||
|
||||
ir_constant_data zero;
|
||||
for (unsigned i = 0; i < 4; i++)
|
||||
if (first_param->type->is_float())
|
||||
if (glsl_type_is_float(first_param->type))
|
||||
zero.f[i] = 0.0;
|
||||
else
|
||||
zero.d[i] = 0.0;
|
||||
@@ -1722,7 +1719,7 @@ emit_inline_matrix_constructor(const glsl_type *type,
|
||||
inst = new(ctx) ir_assignment(col_ref, rhs);
|
||||
instructions->push_tail(inst);
|
||||
}
|
||||
} else if (first_param->type->is_matrix()) {
|
||||
} else if (glsl_type_is_matrix(first_param->type)) {
|
||||
/* From page 50 (56 of the PDF) of the GLSL 1.50 spec:
|
||||
*
|
||||
* "If a matrix is constructed from a matrix, then each component
|
||||
@@ -1750,11 +1747,11 @@ emit_inline_matrix_constructor(const glsl_type *type,
|
||||
(src_matrix->type->vector_elements < var->type->vector_elements)
|
||||
? 0 : src_matrix->type->matrix_columns;
|
||||
|
||||
const glsl_type *const col_type = var->type->column_type();
|
||||
const glsl_type *const col_type = glsl_get_column_type(var->type);
|
||||
for (/* empty */; col < var->type->matrix_columns; col++) {
|
||||
ir_constant_data ident;
|
||||
|
||||
if (!col_type->is_double()) {
|
||||
if (!glsl_type_is_double(col_type)) {
|
||||
ident.f[0] = 0.0f;
|
||||
ident.f[1] = 0.0f;
|
||||
ident.f[2] = 0.0f;
|
||||
@@ -1839,7 +1836,7 @@ emit_inline_matrix_constructor(const glsl_type *type,
|
||||
unsigned row_idx = 0;
|
||||
|
||||
foreach_in_list(ir_rvalue, rhs, parameters) {
|
||||
unsigned rhs_components = rhs->type->components();
|
||||
unsigned rhs_components = glsl_get_components(rhs->type);
|
||||
unsigned rhs_base = 0;
|
||||
|
||||
if (remaining_slots == 0)
|
||||
@@ -2034,8 +2031,8 @@ ast_function_expression::handle_method(exec_list *instructions,
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (op->type->is_array()) {
|
||||
if (op->type->is_unsized_array()) {
|
||||
if (glsl_type_is_array(op->type)) {
|
||||
if (glsl_type_is_unsized_array(op->type)) {
|
||||
if (!state->has_shader_storage_buffer_objects()) {
|
||||
_mesa_glsl_error(&loc, state,
|
||||
"length called on unsized array"
|
||||
@@ -2054,9 +2051,9 @@ ast_function_expression::handle_method(exec_list *instructions,
|
||||
ir_expression(ir_unop_implicitly_sized_array_length, op);
|
||||
}
|
||||
} else {
|
||||
result = new(ctx) ir_constant(op->type->array_size());
|
||||
result = new(ctx) ir_constant(glsl_array_size(op->type));
|
||||
}
|
||||
} else if (op->type->is_vector()) {
|
||||
} else if (glsl_type_is_vector(op->type)) {
|
||||
if (state->has_420pack()) {
|
||||
/* .length() returns int. */
|
||||
result = new(ctx) ir_constant((int) op->type->vector_elements);
|
||||
@@ -2065,7 +2062,7 @@ ast_function_expression::handle_method(exec_list *instructions,
|
||||
" available with ARB_shading_language_420pack");
|
||||
goto fail;
|
||||
}
|
||||
} else if (op->type->is_matrix()) {
|
||||
} else if (glsl_type_is_matrix(op->type)) {
|
||||
if (state->has_420pack()) {
|
||||
/* .length() returns int. */
|
||||
result = new(ctx) ir_constant((int) op->type->matrix_columns);
|
||||
@@ -2090,8 +2087,8 @@ ast_function_expression::handle_method(exec_list *instructions,
|
||||
static inline bool is_valid_constructor(const glsl_type *type,
|
||||
struct _mesa_glsl_parse_state *state)
|
||||
{
|
||||
return type->is_numeric() || type->is_boolean() ||
|
||||
(state->has_bindless() && (type->is_sampler() || type->is_image()));
|
||||
return glsl_type_is_numeric(type) || glsl_type_is_boolean(type) ||
|
||||
(state->has_bindless() && (glsl_type_is_sampler(type) || glsl_type_is_image(type)));
|
||||
}
|
||||
|
||||
ir_rvalue *
|
||||
@@ -2137,22 +2134,22 @@ ast_function_expression::hir(exec_list *instructions,
|
||||
* "Images are represented using 64-bit integer handles, and may be
|
||||
* converted to and from 64-bit integers using constructors."
|
||||
*/
|
||||
if (constructor_type->contains_atomic() ||
|
||||
(!state->has_bindless() && constructor_type->contains_opaque())) {
|
||||
if (glsl_contains_atomic(constructor_type) ||
|
||||
(!state->has_bindless() && glsl_contains_opaque(constructor_type))) {
|
||||
_mesa_glsl_error(& loc, state, "cannot construct %s type `%s'",
|
||||
state->has_bindless() ? "atomic" : "opaque",
|
||||
glsl_get_type_name(constructor_type));
|
||||
return ir_rvalue::error_value(ctx);
|
||||
}
|
||||
|
||||
if (constructor_type->is_subroutine()) {
|
||||
if (glsl_type_is_subroutine(constructor_type)) {
|
||||
_mesa_glsl_error(& loc, state,
|
||||
"subroutine name cannot be a constructor `%s'",
|
||||
glsl_get_type_name(constructor_type));
|
||||
return ir_rvalue::error_value(ctx);
|
||||
}
|
||||
|
||||
if (constructor_type->is_array()) {
|
||||
if (glsl_type_is_array(constructor_type)) {
|
||||
if (!state->check_version(state->allow_glsl_120_subset_in_110 ? 110 : 120,
|
||||
300, &loc, "array constructors forbidden")) {
|
||||
return ir_rvalue::error_value(ctx);
|
||||
@@ -2177,7 +2174,7 @@ ast_function_expression::hir(exec_list *instructions,
|
||||
* must have the exact number of arguments with matching types in the
|
||||
* correct order.
|
||||
*/
|
||||
if (constructor_type->is_struct()) {
|
||||
if (glsl_type_is_struct(constructor_type)) {
|
||||
return process_record_constructor(instructions, constructor_type,
|
||||
&loc, &this->expressions,
|
||||
state);
|
||||
@@ -2187,7 +2184,7 @@ ast_function_expression::hir(exec_list *instructions,
|
||||
return ir_rvalue::error_value(ctx);
|
||||
|
||||
/* Total number of components of the type being constructed. */
|
||||
const unsigned type_components = constructor_type->components();
|
||||
const unsigned type_components = glsl_get_components(constructor_type);
|
||||
|
||||
/* Number of components from parameters that have actually been
|
||||
* consumed. This is used to perform several kinds of error checking.
|
||||
@@ -2223,13 +2220,13 @@ ast_function_expression::hir(exec_list *instructions,
|
||||
/* Count the number of matrix and nonmatrix parameters. This
|
||||
* is used below to enforce some of the constructor rules.
|
||||
*/
|
||||
if (result->type->is_matrix())
|
||||
if (glsl_type_is_matrix(result->type))
|
||||
matrix_parameters++;
|
||||
else
|
||||
nonmatrix_parameters++;
|
||||
|
||||
actual_parameters.push_tail(result);
|
||||
components_used += result->type->components();
|
||||
components_used += glsl_get_components(result->type);
|
||||
}
|
||||
|
||||
/* From page 28 (page 34 of the PDF) of the GLSL 1.10 spec:
|
||||
@@ -2238,7 +2235,7 @@ ast_function_expression::hir(exec_list *instructions,
|
||||
* is reserved for future use."
|
||||
*/
|
||||
if (matrix_parameters > 0
|
||||
&& constructor_type->is_matrix()
|
||||
&& glsl_type_is_matrix(constructor_type)
|
||||
&& !state->check_version(120, 100, &loc,
|
||||
"cannot construct `%s' from a matrix",
|
||||
glsl_get_type_name(constructor_type))) {
|
||||
@@ -2252,7 +2249,7 @@ ast_function_expression::hir(exec_list *instructions,
|
||||
*/
|
||||
if ((matrix_parameters > 0)
|
||||
&& ((matrix_parameters + nonmatrix_parameters) > 1)
|
||||
&& constructor_type->is_matrix()) {
|
||||
&& glsl_type_is_matrix(constructor_type)) {
|
||||
_mesa_glsl_error(& loc, state, "for matrix `%s' constructor, "
|
||||
"matrix must be only parameter",
|
||||
glsl_get_type_name(constructor_type));
|
||||
@@ -2277,9 +2274,9 @@ ast_function_expression::hir(exec_list *instructions,
|
||||
* constructors. If the constructor type is not matrix, always break the
|
||||
* matrix up into a series of column vectors.
|
||||
*/
|
||||
if (!constructor_type->is_matrix()) {
|
||||
if (!glsl_type_is_matrix(constructor_type)) {
|
||||
foreach_in_list_safe(ir_rvalue, matrix, &actual_parameters) {
|
||||
if (!matrix->type->is_matrix())
|
||||
if (!glsl_type_is_matrix(matrix->type))
|
||||
continue;
|
||||
|
||||
/* Create a temporary containing the matrix. */
|
||||
@@ -2322,7 +2319,7 @@ ast_function_expression::hir(exec_list *instructions,
|
||||
* any image type(uvec2) // Converts a pair of 32-bit unsigned integers to
|
||||
* // an image type
|
||||
*/
|
||||
if (ir->type->is_sampler() || ir->type->is_image()) {
|
||||
if (glsl_type_is_sampler(ir->type) || glsl_type_is_image(ir->type)) {
|
||||
/* Convert a sampler/image type to a pair of 32-bit unsigned
|
||||
* integers as defined by ARB_bindless_texture.
|
||||
*/
|
||||
@@ -2332,8 +2329,8 @@ ast_function_expression::hir(exec_list *instructions,
|
||||
"integers");
|
||||
}
|
||||
desired_type = &glsl_type_builtin_uvec2;
|
||||
} else if (constructor_type->is_sampler() ||
|
||||
constructor_type->is_image()) {
|
||||
} else if (glsl_type_is_sampler(constructor_type) ||
|
||||
glsl_type_is_image(constructor_type)) {
|
||||
/* Convert a pair of 32-bit unsigned integers to a sampler or image
|
||||
* type as defined by ARB_bindless_texture.
|
||||
*/
|
||||
@@ -2345,9 +2342,9 @@ ast_function_expression::hir(exec_list *instructions,
|
||||
desired_type = constructor_type;
|
||||
} else {
|
||||
desired_type =
|
||||
glsl_type::get_instance(constructor_type->base_type,
|
||||
ir->type->vector_elements,
|
||||
ir->type->matrix_columns);
|
||||
glsl_simple_type(constructor_type->base_type,
|
||||
ir->type->vector_elements,
|
||||
ir->type->matrix_columns);
|
||||
}
|
||||
|
||||
ir_rvalue *result = convert_component(ir, desired_type);
|
||||
@@ -2373,17 +2370,17 @@ ast_function_expression::hir(exec_list *instructions,
|
||||
*/
|
||||
if (all_parameters_are_constant) {
|
||||
return new(ctx) ir_constant(constructor_type, &actual_parameters);
|
||||
} else if (constructor_type->is_scalar()) {
|
||||
} else if (glsl_type_is_scalar(constructor_type)) {
|
||||
return dereference_component((ir_rvalue *)
|
||||
actual_parameters.get_head_raw(),
|
||||
0);
|
||||
} else if (constructor_type->is_vector()) {
|
||||
} else if (glsl_type_is_vector(constructor_type)) {
|
||||
return emit_inline_vector_constructor(constructor_type,
|
||||
instructions,
|
||||
&actual_parameters,
|
||||
ctx);
|
||||
} else {
|
||||
assert(constructor_type->is_matrix());
|
||||
assert(glsl_type_is_matrix(constructor_type));
|
||||
return emit_inline_matrix_constructor(constructor_type,
|
||||
instructions,
|
||||
&actual_parameters,
|
||||
@@ -2540,12 +2537,12 @@ ast_aggregate_initializer::hir(exec_list *instructions,
|
||||
return ir_rvalue::error_value(ctx);
|
||||
}
|
||||
|
||||
if (constructor_type->is_array()) {
|
||||
if (glsl_type_is_array(constructor_type)) {
|
||||
return process_array_constructor(instructions, constructor_type, &loc,
|
||||
&this->expressions, state);
|
||||
}
|
||||
|
||||
if (constructor_type->is_struct()) {
|
||||
if (glsl_type_is_struct(constructor_type)) {
|
||||
return process_record_constructor(instructions, constructor_type, &loc,
|
||||
&this->expressions, state);
|
||||
}
|
||||
|
||||
+241
-241
File diff suppressed because it is too large
Load Diff
@@ -944,7 +944,7 @@ ast_layout_expression::process_qualifier_constant(struct _mesa_glsl_parse_state
|
||||
ir_constant *const const_int =
|
||||
ir->constant_expression_value(ralloc_parent(ir));
|
||||
|
||||
if (const_int == NULL || !const_int->type->is_integer_32()) {
|
||||
if (const_int == NULL || !glsl_type_is_integer_32(const_int->type)) {
|
||||
YYLTYPE loc = const_expression->get_location();
|
||||
_mesa_glsl_error(&loc, state, "%s must be an integral constant "
|
||||
"expression", qual_indentifier);
|
||||
@@ -1000,7 +1000,7 @@ process_qualifier_constant(struct _mesa_glsl_parse_state *state,
|
||||
|
||||
ir_constant *const const_int =
|
||||
ir->constant_expression_value(ralloc_parent(ir));
|
||||
if (const_int == NULL || !const_int->type->is_integer_32()) {
|
||||
if (const_int == NULL || !glsl_type_is_integer_32(const_int->type)) {
|
||||
_mesa_glsl_error(loc, state, "%s must be an integral constant "
|
||||
"expression", qual_indentifier);
|
||||
return false;
|
||||
|
||||
@@ -5719,7 +5719,7 @@ builtin_builder::imm(const glsl_type *type, const ir_constant_data &data)
|
||||
return new(mem_ctx) ir_constant(type, &data);
|
||||
}
|
||||
|
||||
#define IMM_FP(type, val) (type->is_double()) ? imm(val) : imm((float)val)
|
||||
#define IMM_FP(type, val) (glsl_type_is_double(type)) ? imm(val) : imm((float)val)
|
||||
|
||||
ir_dereference_variable *
|
||||
builtin_builder::var_ref(ir_variable *var)
|
||||
@@ -5917,7 +5917,7 @@ builtin_builder::call(ir_function *f, ir_variable *ret, exec_list params)
|
||||
return NULL;
|
||||
|
||||
ir_dereference_variable *deref =
|
||||
(sig->return_type->is_void() ? NULL : var_ref(ret));
|
||||
(glsl_type_is_void(sig->return_type) ? NULL : var_ref(ret));
|
||||
|
||||
return new(mem_ctx) ir_call(sig, deref, &actual_params);
|
||||
}
|
||||
@@ -6147,14 +6147,14 @@ builtin_builder::_step(builtin_available_predicate avail, const glsl_type *edge_
|
||||
ir_variable *t = body.make_temp(x_type, "t");
|
||||
if (x_type->vector_elements == 1) {
|
||||
/* Both are floats */
|
||||
if (edge_type->is_double())
|
||||
if (glsl_type_is_double(edge_type))
|
||||
body.emit(assign(t, f2d(b2f(gequal(x, edge)))));
|
||||
else
|
||||
body.emit(assign(t, b2f(gequal(x, edge))));
|
||||
} else if (edge_type->vector_elements == 1) {
|
||||
/* x is a vector but edge is a float */
|
||||
for (int i = 0; i < x_type->vector_elements; i++) {
|
||||
if (edge_type->is_double())
|
||||
if (glsl_type_is_double(edge_type))
|
||||
body.emit(assign(t, f2d(b2f(gequal(swizzle(x, i, 1), edge))), 1 << i));
|
||||
else
|
||||
body.emit(assign(t, b2f(gequal(swizzle(x, i, 1), edge)), 1 << i));
|
||||
@@ -6162,7 +6162,7 @@ builtin_builder::_step(builtin_available_predicate avail, const glsl_type *edge_
|
||||
} else {
|
||||
/* Both are vectors */
|
||||
for (int i = 0; i < x_type->vector_elements; i++) {
|
||||
if (edge_type->is_double())
|
||||
if (glsl_type_is_double(edge_type))
|
||||
body.emit(assign(t, f2d(b2f(gequal(swizzle(x, i, 1), swizzle(edge, i, 1)))),
|
||||
1 << i));
|
||||
else
|
||||
@@ -6204,7 +6204,7 @@ ir_function_signature *
|
||||
builtin_builder::_isnan(builtin_available_predicate avail, const glsl_type *type)
|
||||
{
|
||||
ir_variable *x = in_var(type, "x");
|
||||
MAKE_SIG(glsl_type::bvec(type->vector_elements), avail, 1, x);
|
||||
MAKE_SIG(glsl_bvec_type(type->vector_elements), avail, 1, x);
|
||||
|
||||
body.emit(ret(nequal(x, x)));
|
||||
|
||||
@@ -6215,7 +6215,7 @@ ir_function_signature *
|
||||
builtin_builder::_isinf(builtin_available_predicate avail, const glsl_type *type)
|
||||
{
|
||||
ir_variable *x = in_var(type, "x");
|
||||
MAKE_SIG(glsl_type::bvec(type->vector_elements), avail, 1, x);
|
||||
MAKE_SIG(glsl_bvec_type(type->vector_elements), avail, 1, x);
|
||||
|
||||
ir_constant_data infinities;
|
||||
for (int i = 0; i < type->vector_elements; i++) {
|
||||
@@ -6246,7 +6246,7 @@ ir_function_signature *
|
||||
builtin_builder::_floatBitsToInt(const glsl_type *type)
|
||||
{
|
||||
ir_variable *x = in_var(type, "x");
|
||||
MAKE_SIG(glsl_type::ivec(type->vector_elements), shader_bit_encoding, 1, x);
|
||||
MAKE_SIG(glsl_ivec_type(type->vector_elements), shader_bit_encoding, 1, x);
|
||||
body.emit(ret(bitcast_f2i(as_highp(body, x))));
|
||||
return sig;
|
||||
}
|
||||
@@ -6255,7 +6255,7 @@ ir_function_signature *
|
||||
builtin_builder::_floatBitsToUint(const glsl_type *type)
|
||||
{
|
||||
ir_variable *x = in_var(type, "x");
|
||||
MAKE_SIG(glsl_type::uvec(type->vector_elements), shader_bit_encoding, 1, x);
|
||||
MAKE_SIG(glsl_uvec_type(type->vector_elements), shader_bit_encoding, 1, x);
|
||||
body.emit(ret(bitcast_f2u(as_highp(body, x))));
|
||||
return sig;
|
||||
}
|
||||
@@ -6264,7 +6264,7 @@ ir_function_signature *
|
||||
builtin_builder::_intBitsToFloat(const glsl_type *type)
|
||||
{
|
||||
ir_variable *x = in_var(type, "x");
|
||||
MAKE_SIG(glsl_type::vec(type->vector_elements), shader_bit_encoding, 1, x);
|
||||
MAKE_SIG(glsl_vec_type(type->vector_elements), shader_bit_encoding, 1, x);
|
||||
body.emit(ret(bitcast_i2f(as_highp(body, x))));
|
||||
return sig;
|
||||
}
|
||||
@@ -6273,7 +6273,7 @@ ir_function_signature *
|
||||
builtin_builder::_uintBitsToFloat(const glsl_type *type)
|
||||
{
|
||||
ir_variable *x = in_var(type, "x");
|
||||
MAKE_SIG(glsl_type::vec(type->vector_elements), shader_bit_encoding, 1, x);
|
||||
MAKE_SIG(glsl_vec_type(type->vector_elements), shader_bit_encoding, 1, x);
|
||||
body.emit(ret(bitcast_u2f(as_highp(body, x))));
|
||||
return sig;
|
||||
}
|
||||
@@ -6282,7 +6282,7 @@ ir_function_signature *
|
||||
builtin_builder::_doubleBitsToInt64(builtin_available_predicate avail, const glsl_type *type)
|
||||
{
|
||||
ir_variable *x = in_var(type, "x");
|
||||
MAKE_SIG(glsl_type::i64vec(type->vector_elements), avail, 1, x);
|
||||
MAKE_SIG(glsl_i64vec_type(type->vector_elements), avail, 1, x);
|
||||
body.emit(ret(bitcast_d2i64(x)));
|
||||
return sig;
|
||||
}
|
||||
@@ -6291,7 +6291,7 @@ ir_function_signature *
|
||||
builtin_builder::_doubleBitsToUint64(builtin_available_predicate avail, const glsl_type *type)
|
||||
{
|
||||
ir_variable *x = in_var(type, "x");
|
||||
MAKE_SIG(glsl_type::u64vec(type->vector_elements), avail, 1, x);
|
||||
MAKE_SIG(glsl_u64vec_type(type->vector_elements), avail, 1, x);
|
||||
body.emit(ret(bitcast_d2u64(x)));
|
||||
return sig;
|
||||
}
|
||||
@@ -6300,7 +6300,7 @@ ir_function_signature *
|
||||
builtin_builder::_int64BitsToDouble(builtin_available_predicate avail, const glsl_type *type)
|
||||
{
|
||||
ir_variable *x = in_var(type, "x");
|
||||
MAKE_SIG(glsl_type::dvec(type->vector_elements), avail, 1, x);
|
||||
MAKE_SIG(glsl_dvec_type(type->vector_elements), avail, 1, x);
|
||||
body.emit(ret(bitcast_i642d(x)));
|
||||
return sig;
|
||||
}
|
||||
@@ -6309,7 +6309,7 @@ ir_function_signature *
|
||||
builtin_builder::_uint64BitsToDouble(builtin_available_predicate avail, const glsl_type *type)
|
||||
{
|
||||
ir_variable *x = in_var(type, "x");
|
||||
MAKE_SIG(glsl_type::dvec(type->vector_elements), avail, 1, x);
|
||||
MAKE_SIG(glsl_dvec_type(type->vector_elements), avail, 1, x);
|
||||
body.emit(ret(bitcast_u642d(x)));
|
||||
return sig;
|
||||
}
|
||||
@@ -6473,7 +6473,7 @@ ir_function_signature *
|
||||
builtin_builder::_length(builtin_available_predicate avail, const glsl_type *type)
|
||||
{
|
||||
ir_variable *x = in_var(type, "x");
|
||||
MAKE_SIG(type->get_base_type(), avail, 1, x);
|
||||
MAKE_SIG(glsl_get_base_glsl_type(type), avail, 1, x);
|
||||
|
||||
body.emit(ret(sqrt(dot(x, x))));
|
||||
|
||||
@@ -6485,7 +6485,7 @@ builtin_builder::_distance(builtin_available_predicate avail, const glsl_type *t
|
||||
{
|
||||
ir_variable *p0 = in_var(type, "p0");
|
||||
ir_variable *p1 = in_var(type, "p1");
|
||||
MAKE_SIG(type->get_base_type(), avail, 2, p0, p1);
|
||||
MAKE_SIG(glsl_get_base_glsl_type(type), avail, 2, p0, p1);
|
||||
|
||||
if (type->vector_elements == 1) {
|
||||
body.emit(ret(abs(sub(p0, p1))));
|
||||
@@ -6505,7 +6505,7 @@ builtin_builder::_dot(builtin_available_predicate avail, const glsl_type *type)
|
||||
return binop(avail, ir_binop_mul, type, type, type);
|
||||
|
||||
return binop(avail, ir_binop_dot,
|
||||
type->get_base_type(), type, type);
|
||||
glsl_get_base_glsl_type(type), type, type);
|
||||
}
|
||||
|
||||
ir_function_signature *
|
||||
@@ -6583,10 +6583,10 @@ builtin_builder::_refract(builtin_available_predicate avail, const glsl_type *ty
|
||||
{
|
||||
ir_variable *I = in_var(type, "I");
|
||||
ir_variable *N = in_var(type, "N");
|
||||
ir_variable *eta = in_var(type->get_base_type(), "eta");
|
||||
ir_variable *eta = in_var(glsl_get_base_glsl_type(type), "eta");
|
||||
MAKE_SIG(type, avail, 3, I, N, eta);
|
||||
|
||||
ir_variable *n_dot_i = body.make_temp(type->get_base_type(), "n_dot_i");
|
||||
ir_variable *n_dot_i = body.make_temp(glsl_get_base_glsl_type(type), "n_dot_i");
|
||||
body.emit(assign(n_dot_i, dot(N, I)));
|
||||
|
||||
/* From the GLSL 1.10 specification:
|
||||
@@ -6596,7 +6596,7 @@ builtin_builder::_refract(builtin_available_predicate avail, const glsl_type *ty
|
||||
* else
|
||||
* return eta * I - (eta * dot(N, I) + sqrt(k)) * N
|
||||
*/
|
||||
ir_variable *k = body.make_temp(type->get_base_type(), "k");
|
||||
ir_variable *k = body.make_temp(glsl_get_base_glsl_type(type), "k");
|
||||
body.emit(assign(k, sub(IMM_FP(type, 1.0),
|
||||
mul(eta, mul(eta, sub(IMM_FP(type, 1.0),
|
||||
mul(n_dot_i, n_dot_i)))))));
|
||||
@@ -6630,12 +6630,12 @@ builtin_builder::_outerProduct(builtin_available_predicate avail, const glsl_typ
|
||||
ir_variable *c;
|
||||
ir_variable *r;
|
||||
|
||||
if (type->is_double()) {
|
||||
r = in_var(glsl_type::dvec(type->matrix_columns), "r");
|
||||
c = in_var(glsl_type::dvec(type->vector_elements), "c");
|
||||
if (glsl_type_is_double(type)) {
|
||||
r = in_var(glsl_dvec_type(type->matrix_columns), "r");
|
||||
c = in_var(glsl_dvec_type(type->vector_elements), "c");
|
||||
} else {
|
||||
r = in_var(glsl_type::vec(type->matrix_columns), "r");
|
||||
c = in_var(glsl_type::vec(type->vector_elements), "c");
|
||||
r = in_var(glsl_vec_type(type->matrix_columns), "r");
|
||||
c = in_var(glsl_vec_type(type->vector_elements), "c");
|
||||
}
|
||||
MAKE_SIG(type, avail, 2, c, r);
|
||||
|
||||
@@ -6652,9 +6652,9 @@ ir_function_signature *
|
||||
builtin_builder::_transpose(builtin_available_predicate avail, const glsl_type *orig_type)
|
||||
{
|
||||
const glsl_type *transpose_type =
|
||||
glsl_type::get_instance(orig_type->base_type,
|
||||
orig_type->matrix_columns,
|
||||
orig_type->vector_elements);
|
||||
glsl_simple_type(orig_type->base_type,
|
||||
orig_type->matrix_columns,
|
||||
orig_type->vector_elements);
|
||||
|
||||
ir_variable *m = in_var(orig_type, "m");
|
||||
MAKE_SIG(transpose_type, avail, 1, m);
|
||||
@@ -6676,7 +6676,7 @@ ir_function_signature *
|
||||
builtin_builder::_determinant_mat2(builtin_available_predicate avail, const glsl_type *type)
|
||||
{
|
||||
ir_variable *m = in_var(type, "m");
|
||||
MAKE_SIG(type->get_base_type(), avail, 1, m);
|
||||
MAKE_SIG(glsl_get_base_glsl_type(type), avail, 1, m);
|
||||
|
||||
body.emit(ret(sub(mul(matrix_elt(m, 0, 0), matrix_elt(m, 1, 1)),
|
||||
mul(matrix_elt(m, 1, 0), matrix_elt(m, 0, 1)))));
|
||||
@@ -6688,7 +6688,7 @@ ir_function_signature *
|
||||
builtin_builder::_determinant_mat3(builtin_available_predicate avail, const glsl_type *type)
|
||||
{
|
||||
ir_variable *m = in_var(type, "m");
|
||||
MAKE_SIG(type->get_base_type(), avail, 1, m);
|
||||
MAKE_SIG(glsl_get_base_glsl_type(type), avail, 1, m);
|
||||
|
||||
ir_expression *f1 =
|
||||
sub(mul(matrix_elt(m, 1, 1), matrix_elt(m, 2, 2)),
|
||||
@@ -6713,7 +6713,7 @@ ir_function_signature *
|
||||
builtin_builder::_determinant_mat4(builtin_available_predicate avail, const glsl_type *type)
|
||||
{
|
||||
ir_variable *m = in_var(type, "m");
|
||||
const glsl_type *btype = type->get_base_type();
|
||||
const glsl_type *btype = glsl_get_base_glsl_type(type);
|
||||
MAKE_SIG(btype, avail, 1, m);
|
||||
|
||||
ir_variable *SubFactor00 = body.make_temp(btype, "SubFactor00");
|
||||
@@ -6808,7 +6808,7 @@ ir_function_signature *
|
||||
builtin_builder::_inverse_mat3(builtin_available_predicate avail, const glsl_type *type)
|
||||
{
|
||||
ir_variable *m = in_var(type, "m");
|
||||
const glsl_type *btype = type->get_base_type();
|
||||
const glsl_type *btype = glsl_get_base_glsl_type(type);
|
||||
MAKE_SIG(type, avail, 1, m);
|
||||
|
||||
ir_variable *f11_22_21_12 = body.make_temp(btype, "f11_22_21_12");
|
||||
@@ -6870,7 +6870,7 @@ ir_function_signature *
|
||||
builtin_builder::_inverse_mat4(builtin_available_predicate avail, const glsl_type *type)
|
||||
{
|
||||
ir_variable *m = in_var(type, "m");
|
||||
const glsl_type *btype = type->get_base_type();
|
||||
const glsl_type *btype = glsl_get_base_glsl_type(type);
|
||||
MAKE_SIG(type, avail, 1, m);
|
||||
|
||||
ir_variable *SubFactor00 = body.make_temp(btype, "SubFactor00");
|
||||
@@ -7015,7 +7015,7 @@ builtin_builder::_lessThan(builtin_available_predicate avail,
|
||||
const glsl_type *type)
|
||||
{
|
||||
return binop(avail, ir_binop_less,
|
||||
glsl_type::bvec(type->vector_elements), type, type);
|
||||
glsl_bvec_type(type->vector_elements), type, type);
|
||||
}
|
||||
|
||||
ir_function_signature *
|
||||
@@ -7023,7 +7023,7 @@ builtin_builder::_lessThanEqual(builtin_available_predicate avail,
|
||||
const glsl_type *type)
|
||||
{
|
||||
return binop(avail, ir_binop_gequal,
|
||||
glsl_type::bvec(type->vector_elements), type, type,
|
||||
glsl_bvec_type(type->vector_elements), type, type,
|
||||
true);
|
||||
}
|
||||
|
||||
@@ -7032,7 +7032,7 @@ builtin_builder::_greaterThan(builtin_available_predicate avail,
|
||||
const glsl_type *type)
|
||||
{
|
||||
return binop(avail, ir_binop_less,
|
||||
glsl_type::bvec(type->vector_elements), type, type,
|
||||
glsl_bvec_type(type->vector_elements), type, type,
|
||||
true);
|
||||
}
|
||||
|
||||
@@ -7041,7 +7041,7 @@ builtin_builder::_greaterThanEqual(builtin_available_predicate avail,
|
||||
const glsl_type *type)
|
||||
{
|
||||
return binop(avail, ir_binop_gequal,
|
||||
glsl_type::bvec(type->vector_elements), type, type);
|
||||
glsl_bvec_type(type->vector_elements), type, type);
|
||||
}
|
||||
|
||||
ir_function_signature *
|
||||
@@ -7049,7 +7049,7 @@ builtin_builder::_equal(builtin_available_predicate avail,
|
||||
const glsl_type *type)
|
||||
{
|
||||
return binop(avail, ir_binop_equal,
|
||||
glsl_type::bvec(type->vector_elements), type, type);
|
||||
glsl_bvec_type(type->vector_elements), type, type);
|
||||
}
|
||||
|
||||
ir_function_signature *
|
||||
@@ -7057,7 +7057,7 @@ builtin_builder::_notEqual(builtin_available_predicate avail,
|
||||
const glsl_type *type)
|
||||
{
|
||||
return binop(avail, ir_binop_nequal,
|
||||
glsl_type::bvec(type->vector_elements), type, type);
|
||||
glsl_bvec_type(type->vector_elements), type, type);
|
||||
}
|
||||
|
||||
ir_function_signature *
|
||||
@@ -7089,7 +7089,7 @@ UNOP(not, ir_unop_logic_not, always_available)
|
||||
static bool
|
||||
has_lod(const glsl_type *sampler_type)
|
||||
{
|
||||
assert(sampler_type->is_sampler());
|
||||
assert(glsl_type_is_sampler(sampler_type));
|
||||
|
||||
switch (sampler_type->sampler_dimensionality) {
|
||||
case GLSL_SAMPLER_DIM_RECT:
|
||||
@@ -7183,7 +7183,7 @@ builtin_builder::_texture(ir_texture_opcode opcode,
|
||||
ir_texture *tex = new(mem_ctx) ir_texture(opcode, flags & TEX_SPARSE);
|
||||
tex->set_sampler(var_ref(s), return_type);
|
||||
|
||||
const int coord_size = sampler_type->coordinate_components();
|
||||
const int coord_size = glsl_get_sampler_coordinate_components(sampler_type);
|
||||
|
||||
if (coord_size == coord_type->vector_elements) {
|
||||
tex->coordinate = var_ref(P);
|
||||
@@ -7220,8 +7220,8 @@ builtin_builder::_texture(ir_texture_opcode opcode,
|
||||
tex->lod_info.lod = var_ref(lod);
|
||||
} else if (opcode == ir_txd) {
|
||||
int grad_size = coord_size - (sampler_type->sampler_array ? 1 : 0);
|
||||
ir_variable *dPdx = in_var(glsl_type::vec(grad_size), "dPdx");
|
||||
ir_variable *dPdy = in_var(glsl_type::vec(grad_size), "dPdy");
|
||||
ir_variable *dPdx = in_var(glsl_vec_type(grad_size), "dPdx");
|
||||
ir_variable *dPdy = in_var(glsl_vec_type(grad_size), "dPdy");
|
||||
sig->parameters.push_tail(dPdx);
|
||||
sig->parameters.push_tail(dPdy);
|
||||
tex->lod_info.grad.dPdx = var_ref(dPdx);
|
||||
@@ -7231,7 +7231,7 @@ builtin_builder::_texture(ir_texture_opcode opcode,
|
||||
if (flags & (TEX_OFFSET | TEX_OFFSET_NONCONST)) {
|
||||
int offset_size = coord_size - (sampler_type->sampler_array ? 1 : 0);
|
||||
ir_variable *offset =
|
||||
new(mem_ctx) ir_variable(glsl_type::ivec(offset_size), "offset",
|
||||
new(mem_ctx) ir_variable(glsl_ivec_type(offset_size), "offset",
|
||||
(flags & TEX_OFFSET) ? ir_var_const_in : ir_var_function_in);
|
||||
sig->parameters.push_tail(offset);
|
||||
tex->offset = var_ref(offset);
|
||||
@@ -7239,7 +7239,7 @@ builtin_builder::_texture(ir_texture_opcode opcode,
|
||||
|
||||
if (flags & TEX_OFFSET_ARRAY) {
|
||||
ir_variable *offsets =
|
||||
new(mem_ctx) ir_variable(glsl_type::get_array_instance(&glsl_type_builtin_ivec2, 4),
|
||||
new(mem_ctx) ir_variable(glsl_array_type(&glsl_type_builtin_ivec2, 4, 0),
|
||||
"offsets", ir_var_const_in);
|
||||
sig->parameters.push_tail(offsets);
|
||||
tex->offset = var_ref(offsets);
|
||||
@@ -7673,7 +7673,7 @@ ir_function_signature *
|
||||
builtin_builder::_bitCount(const glsl_type *type)
|
||||
{
|
||||
ir_variable *x = in_var(type, "x");
|
||||
MAKE_SIG(glsl_type::ivec(type->vector_elements), gpu_shader5_or_es31_or_integer_functions, 1, x);
|
||||
MAKE_SIG(glsl_ivec_type(type->vector_elements), gpu_shader5_or_es31_or_integer_functions, 1, x);
|
||||
sig->return_precision = GLSL_PRECISION_LOW;
|
||||
body.emit(ret(expr(ir_unop_bit_count, x)));
|
||||
return sig;
|
||||
@@ -7683,7 +7683,7 @@ ir_function_signature *
|
||||
builtin_builder::_findLSB(const glsl_type *type)
|
||||
{
|
||||
ir_variable *x = in_highp_var(type, "x");
|
||||
MAKE_SIG(glsl_type::ivec(type->vector_elements), gpu_shader5_or_es31_or_integer_functions, 1, x);
|
||||
MAKE_SIG(glsl_ivec_type(type->vector_elements), gpu_shader5_or_es31_or_integer_functions, 1, x);
|
||||
sig->return_precision = GLSL_PRECISION_LOW;
|
||||
body.emit(ret(expr(ir_unop_find_lsb, x)));
|
||||
return sig;
|
||||
@@ -7693,7 +7693,7 @@ ir_function_signature *
|
||||
builtin_builder::_findMSB(const glsl_type *type)
|
||||
{
|
||||
ir_variable *x = in_highp_var(type, "x");
|
||||
MAKE_SIG(glsl_type::ivec(type->vector_elements), gpu_shader5_or_es31_or_integer_functions, 1, x);
|
||||
MAKE_SIG(glsl_ivec_type(type->vector_elements), gpu_shader5_or_es31_or_integer_functions, 1, x);
|
||||
sig->return_precision = GLSL_PRECISION_LOW;
|
||||
body.emit(ret(expr(ir_unop_find_msb, x)));
|
||||
return sig;
|
||||
@@ -7704,7 +7704,7 @@ builtin_builder::_countLeadingZeros(builtin_available_predicate avail,
|
||||
const glsl_type *type)
|
||||
{
|
||||
return unop(avail, ir_unop_clz,
|
||||
glsl_type::uvec(type->vector_elements), type);
|
||||
glsl_uvec_type(type->vector_elements), type);
|
||||
}
|
||||
|
||||
ir_function_signature *
|
||||
@@ -7712,7 +7712,7 @@ builtin_builder::_countTrailingZeros(builtin_available_predicate avail,
|
||||
const glsl_type *type)
|
||||
{
|
||||
ir_variable *a = in_var(type, "a");
|
||||
MAKE_SIG(glsl_type::uvec(type->vector_elements), avail, 1, a);
|
||||
MAKE_SIG(glsl_uvec_type(type->vector_elements), avail, 1, a);
|
||||
|
||||
body.emit(ret(ir_builder::min2(
|
||||
ir_builder::i2u(ir_builder::expr(ir_unop_find_lsb, a)),
|
||||
@@ -7739,7 +7739,7 @@ builtin_builder::_ldexp(const glsl_type *x_type, const glsl_type *exp_type)
|
||||
{
|
||||
ir_variable *x = in_highp_var(x_type, "x");
|
||||
ir_variable *y = in_highp_var(exp_type, "y");
|
||||
MAKE_SIG(x_type, x_type->is_double() ? fp64 : gpu_shader5_or_es31_or_integer_functions, 2, x, y);
|
||||
MAKE_SIG(x_type, glsl_type_is_double(x_type) ? fp64 : gpu_shader5_or_es31_or_integer_functions, 2, x, y);
|
||||
sig->return_precision = GLSL_PRECISION_HIGH;
|
||||
body.emit(ret(expr(ir_binop_ldexp, x, y)));
|
||||
return sig;
|
||||
@@ -7750,7 +7750,7 @@ builtin_builder::_frexp(const glsl_type *x_type, const glsl_type *exp_type)
|
||||
{
|
||||
ir_variable *x = in_highp_var(x_type, "x");
|
||||
ir_variable *exponent = out_var(exp_type, "exp");
|
||||
MAKE_SIG(x_type, x_type->is_double() ? fp64 : gpu_shader5_or_es31_or_integer_functions,
|
||||
MAKE_SIG(x_type, glsl_type_is_double(x_type) ? fp64 : gpu_shader5_or_es31_or_integer_functions,
|
||||
2, x, exponent);
|
||||
sig->return_precision = GLSL_PRECISION_HIGH;
|
||||
|
||||
@@ -7812,8 +7812,8 @@ builtin_builder::_absoluteDifference(builtin_available_predicate avail,
|
||||
* bits and number of vector elements as the type of the operands.
|
||||
*/
|
||||
return binop(avail, ir_binop_abs_sub,
|
||||
glsl_type::get_instance(glsl_unsigned_base_type_of(type->base_type),
|
||||
type->vector_elements, 1),
|
||||
glsl_simple_type(glsl_unsigned_base_type_of(type->base_type),
|
||||
type->vector_elements, 1),
|
||||
type, type);
|
||||
}
|
||||
|
||||
@@ -7842,11 +7842,11 @@ builtin_builder::_mulExtended(const glsl_type *type)
|
||||
|
||||
if (type->base_type == GLSL_TYPE_INT) {
|
||||
unpack_op = ir_unop_unpack_int_2x32;
|
||||
mul_type = glsl_type::get_instance(GLSL_TYPE_INT64, type->vector_elements, 1);
|
||||
mul_type = glsl_simple_type(GLSL_TYPE_INT64, type->vector_elements, 1);
|
||||
unpack_type = &glsl_type_builtin_ivec2;
|
||||
} else {
|
||||
unpack_op = ir_unop_unpack_uint_2x32;
|
||||
mul_type = glsl_type::get_instance(GLSL_TYPE_UINT64, type->vector_elements, 1);
|
||||
mul_type = glsl_simple_type(GLSL_TYPE_UINT64, type->vector_elements, 1);
|
||||
unpack_type = &glsl_type_builtin_uvec2;
|
||||
}
|
||||
|
||||
@@ -8161,7 +8161,7 @@ builtin_builder::_image_prototype(const glsl_type *image_type,
|
||||
unsigned num_arguments,
|
||||
unsigned flags)
|
||||
{
|
||||
const glsl_type *data_type = glsl_type::get_instance(
|
||||
const glsl_type *data_type = glsl_simple_type(
|
||||
image_type->sampled_type,
|
||||
(flags & IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE ? 4 : 1),
|
||||
1);
|
||||
@@ -8178,7 +8178,7 @@ builtin_builder::_image_prototype(const glsl_type *image_type,
|
||||
glsl_struct_field(&glsl_type_builtin_int, "code"),
|
||||
glsl_struct_field(data_type, "texel"),
|
||||
};
|
||||
ret_type = glsl_type::get_struct_instance(fields, 2, "struct");
|
||||
ret_type = glsl_struct_type(fields, 2, "struct", false /* packed */);
|
||||
}
|
||||
} else
|
||||
ret_type = data_type;
|
||||
@@ -8186,7 +8186,7 @@ builtin_builder::_image_prototype(const glsl_type *image_type,
|
||||
/* Addressing arguments that are always present. */
|
||||
ir_variable *image = in_var(image_type, "image");
|
||||
ir_variable *coord = in_var(
|
||||
glsl_type::ivec(image_type->coordinate_components()), "coord");
|
||||
glsl_ivec_type(glsl_get_sampler_coordinate_components(image_type)), "coord");
|
||||
|
||||
ir_function_signature *sig = new_sig(
|
||||
ret_type, get_image_available_predicate(image_type, flags),
|
||||
@@ -8225,7 +8225,7 @@ builtin_builder::_image_size_prototype(const glsl_type *image_type,
|
||||
unsigned /* flags */)
|
||||
{
|
||||
const glsl_type *ret_type;
|
||||
unsigned num_components = image_type->coordinate_components();
|
||||
unsigned num_components = glsl_get_sampler_coordinate_components(image_type);
|
||||
|
||||
/* From the ARB_shader_image_size extension:
|
||||
* "Cube images return the dimensions of one face."
|
||||
@@ -8238,7 +8238,7 @@ builtin_builder::_image_size_prototype(const glsl_type *image_type,
|
||||
/* FIXME: Add the highp precision qualifier for GLES 3.10 when it is
|
||||
* supported by mesa.
|
||||
*/
|
||||
ret_type = glsl_type::get_instance(GLSL_TYPE_INT, num_components, 1);
|
||||
ret_type = glsl_simple_type(GLSL_TYPE_INT, num_components, 1);
|
||||
|
||||
ir_variable *image = in_var(image_type, "image");
|
||||
ir_function_signature *sig = new_sig(ret_type, shader_image_size, 1, image);
|
||||
|
||||
@@ -259,7 +259,7 @@ _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state)
|
||||
* copy of the struct types.
|
||||
*/
|
||||
{
|
||||
#define GET_STRUCT_TYPE(NAME) glsl_type::get_struct_instance(NAME##_fields, ARRAY_SIZE(NAME##_fields), #NAME)
|
||||
#define GET_STRUCT_TYPE(NAME) glsl_struct_type(NAME##_fields, ARRAY_SIZE(NAME##_fields), #NAME, false /* packed */)
|
||||
|
||||
if (state->is_version(110, 100)) {
|
||||
add_type(symbols, GET_STRUCT_TYPE(gl_DepthRangeParameters));
|
||||
|
||||
@@ -409,10 +409,10 @@ per_vertex_accumulator::add_field(int slot, const glsl_type *type,
|
||||
const glsl_type *
|
||||
per_vertex_accumulator::construct_interface_instance() const
|
||||
{
|
||||
return glsl_type::get_interface_instance(this->fields, this->num_fields,
|
||||
GLSL_INTERFACE_PACKING_STD140,
|
||||
false,
|
||||
"gl_PerVertex");
|
||||
return glsl_interface_type(this->fields, this->num_fields,
|
||||
GLSL_INTERFACE_PACKING_STD140,
|
||||
false,
|
||||
"gl_PerVertex");
|
||||
}
|
||||
|
||||
|
||||
@@ -435,7 +435,7 @@ public:
|
||||
private:
|
||||
const glsl_type *array(const glsl_type *base, unsigned elements)
|
||||
{
|
||||
return glsl_type::get_array_instance(base, elements);
|
||||
return glsl_array_type(base, elements, 0);
|
||||
}
|
||||
|
||||
const glsl_type *type(const char *name)
|
||||
@@ -669,7 +669,7 @@ builtin_variable_generator::add_uniform(const glsl_type *type,
|
||||
_mesa_glsl_get_builtin_uniform_desc(name);
|
||||
assert(statevar != NULL);
|
||||
|
||||
const unsigned array_count = type->is_array() ? type->length : 1;
|
||||
const unsigned array_count = glsl_type_is_array(type) ? type->length : 1;
|
||||
|
||||
ir_state_slot *slots =
|
||||
uni->allocate_state_slots(array_count * statevar->num_elements);
|
||||
@@ -680,7 +680,7 @@ builtin_variable_generator::add_uniform(const glsl_type *type,
|
||||
&statevar->elements[j];
|
||||
|
||||
memcpy(slots->tokens, element->tokens, sizeof(element->tokens));
|
||||
if (type->is_array())
|
||||
if (glsl_type_is_array(type))
|
||||
slots->tokens[1] = a;
|
||||
|
||||
slots++;
|
||||
|
||||
@@ -896,7 +896,7 @@ function_header:
|
||||
|
||||
if ($1->qualifier.is_subroutine_decl()) {
|
||||
/* add type for IDENTIFIER search */
|
||||
state->symbols->add_type($2, glsl_type::get_subroutine_instance($2));
|
||||
state->symbols->add_type($2, glsl_subroutine_type($2));
|
||||
} else
|
||||
state->symbols->add_function(new(state) ir_function($2));
|
||||
state->symbols->push_scope();
|
||||
|
||||
@@ -837,7 +837,7 @@ static const char *find_extension_alias(_mesa_glsl_parse_state *state, const cha
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
free(exts);
|
||||
}
|
||||
return ext_alias;
|
||||
@@ -854,7 +854,7 @@ static const _mesa_glsl_extension *find_extension(_mesa_glsl_parse_state *state,
|
||||
ext_alias = find_extension_alias(state, name);
|
||||
name = ext_alias ? ext_alias : name;
|
||||
}
|
||||
|
||||
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(_mesa_glsl_supported_extensions); ++i) {
|
||||
if (strcmp(name, _mesa_glsl_supported_extensions[i].name) == 0) {
|
||||
free((void *)ext_alias);
|
||||
@@ -979,7 +979,7 @@ _mesa_glsl_can_implicitly_convert(const glsl_type *from, const glsl_type *desire
|
||||
return false;
|
||||
|
||||
/* int and uint can be converted to float. */
|
||||
if (desired->is_float() && from->is_integer_32())
|
||||
if (glsl_type_is_float(desired) && glsl_type_is_integer_32(from))
|
||||
return true;
|
||||
|
||||
/* With GLSL 4.0, ARB_gpu_shader5, or MESA_shader_integer_functions, int
|
||||
@@ -993,14 +993,14 @@ _mesa_glsl_can_implicitly_convert(const glsl_type *from, const glsl_type *desire
|
||||
return true;
|
||||
|
||||
/* No implicit conversions from double. */
|
||||
if ((!state || state->has_double()) && from->is_double())
|
||||
if ((!state || state->has_double()) && glsl_type_is_double(from))
|
||||
return false;
|
||||
|
||||
/* Conversions from different types to double. */
|
||||
if ((!state || state->has_double()) && desired->is_double()) {
|
||||
if (from->is_float())
|
||||
if ((!state || state->has_double()) && glsl_type_is_double(desired)) {
|
||||
if (glsl_type_is_float(from))
|
||||
return true;
|
||||
if (from->is_integer_32())
|
||||
if (glsl_type_is_integer_32(from))
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1061,7 +1061,7 @@ _mesa_ast_set_aggregate_type(const glsl_type *type,
|
||||
ai->constructor_type = type;
|
||||
|
||||
/* If the aggregate is an array, recursively set its elements' types. */
|
||||
if (type->is_array()) {
|
||||
if (glsl_type_is_array(type)) {
|
||||
/* Each array element has the type type->fields.array.
|
||||
*
|
||||
* E.g., if <type> if struct S[2] we want to set each element's type to
|
||||
@@ -1078,7 +1078,7 @@ _mesa_ast_set_aggregate_type(const glsl_type *type,
|
||||
}
|
||||
|
||||
/* If the aggregate is a struct, recursively set its fields' types. */
|
||||
} else if (type->is_struct()) {
|
||||
} else if (glsl_type_is_struct(type)) {
|
||||
exec_node *expr_node = ai->expressions.get_head_raw();
|
||||
|
||||
/* Iterate through the struct's fields. */
|
||||
@@ -1092,7 +1092,7 @@ _mesa_ast_set_aggregate_type(const glsl_type *type,
|
||||
}
|
||||
}
|
||||
/* If the aggregate is a matrix, set its columns' types. */
|
||||
} else if (type->is_matrix()) {
|
||||
} else if (glsl_type_is_matrix(type)) {
|
||||
for (exec_node *expr_node = ai->expressions.get_head_raw();
|
||||
!expr_node->is_tail_sentinel();
|
||||
expr_node = expr_node->next) {
|
||||
@@ -1100,7 +1100,7 @@ _mesa_ast_set_aggregate_type(const glsl_type *type,
|
||||
link);
|
||||
|
||||
if (expr->oper == ast_aggregate)
|
||||
_mesa_ast_set_aggregate_type(type->column_type(), expr);
|
||||
_mesa_ast_set_aggregate_type(glsl_get_column_type(type), expr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public:
|
||||
symbol_table_entry(const glsl_type *t, enum ir_variable_mode mode) :
|
||||
v(0), f(0), t(0), ibu(0), iss(0), ibi(0), ibo(0), a(0)
|
||||
{
|
||||
assert(t->is_interface());
|
||||
assert(glsl_type_is_interface(t));
|
||||
add_interface(t, mode);
|
||||
}
|
||||
symbol_table_entry(const class ast_type_specifier *a):
|
||||
@@ -175,7 +175,7 @@ bool glsl_symbol_table::add_type(const char *name, const glsl_type *t)
|
||||
bool glsl_symbol_table::add_interface(const char *name, const glsl_type *i,
|
||||
enum ir_variable_mode mode)
|
||||
{
|
||||
assert(i->is_interface());
|
||||
assert(glsl_type_is_interface(i));
|
||||
symbol_table_entry *entry = get_entry(name);
|
||||
if (entry == NULL) {
|
||||
symbol_table_entry *entry =
|
||||
|
||||
@@ -385,7 +385,7 @@ void
|
||||
nir_visitor::adjust_sparse_variable(nir_deref_instr *var_deref, const glsl_type *type,
|
||||
nir_def *dest)
|
||||
{
|
||||
const glsl_type *texel_type = type->field_type("texel");
|
||||
const glsl_type *texel_type = glsl_get_field_type(type, "texel");
|
||||
assert(texel_type);
|
||||
|
||||
assert(var_deref->deref_type == nir_deref_type_var);
|
||||
@@ -395,8 +395,8 @@ nir_visitor::adjust_sparse_variable(nir_deref_instr *var_deref, const glsl_type
|
||||
* Because the nir_variable is created with struct type from ir_variable,
|
||||
* but sparse nir instructions output with vector dest.
|
||||
*/
|
||||
var->type = glsl_type::get_instance(texel_type->get_base_type()->base_type,
|
||||
dest->num_components, 1);
|
||||
var->type = glsl_simple_type(glsl_get_base_glsl_type(texel_type)->base_type,
|
||||
dest->num_components, 1);
|
||||
|
||||
var_deref->type = var->type;
|
||||
|
||||
@@ -482,7 +482,7 @@ nir_visitor::visit(ir_variable *ir)
|
||||
case ir_var_uniform:
|
||||
if (ir->get_interface_type())
|
||||
var->data.mode = nir_var_mem_ubo;
|
||||
else if (ir->type->contains_image() && !ir->data.bindless)
|
||||
else if (glsl_type_contains_image(ir->type) && !ir->data.bindless)
|
||||
var->data.mode = nir_var_image;
|
||||
else
|
||||
var->data.mode = nir_var_uniform;
|
||||
@@ -521,11 +521,11 @@ nir_visitor::visit(ir_variable *ir)
|
||||
/* For UBO and SSBO variables, we need explicit types */
|
||||
if (var->data.mode & (nir_var_mem_ubo | nir_var_mem_ssbo)) {
|
||||
const glsl_type *explicit_ifc_type =
|
||||
ir->get_interface_type()->get_explicit_interface_type(supports_std430);
|
||||
glsl_get_explicit_interface_type(ir->get_interface_type(), supports_std430);
|
||||
|
||||
var->interface_type = explicit_ifc_type;
|
||||
|
||||
if (ir->type->without_array()->is_interface()) {
|
||||
if (glsl_type_is_interface(glsl_without_array(ir->type))) {
|
||||
/* If the type contains the interface, wrap the explicit type in the
|
||||
* right number of arrays.
|
||||
*/
|
||||
@@ -590,7 +590,7 @@ nir_visitor::visit(ir_variable *ir)
|
||||
var->data.offset = ir->data.offset;
|
||||
var->data.access = (gl_access_qualifier)mem_access;
|
||||
|
||||
if (var->type->without_array()->is_image()) {
|
||||
if (glsl_type_is_image(glsl_without_array(var->type))) {
|
||||
var->data.image.format = ir->data.image_format;
|
||||
} else if (var->data.mode == nir_var_shader_out) {
|
||||
var->data.xfb.buffer = ir->data.xfb_buffer;
|
||||
@@ -665,7 +665,7 @@ nir_visitor::create_function(ir_function_signature *ir)
|
||||
|
||||
foreach_in_list(ir_variable, param, &ir->parameters) {
|
||||
/* FINISHME: pass arrays, structs, etc by reference? */
|
||||
assert(param->type->is_vector() || param->type->is_scalar());
|
||||
assert(glsl_type_is_vector(param->type) || glsl_type_is_scalar(param->type));
|
||||
|
||||
if (param->data.mode == ir_var_function_in) {
|
||||
func->params[np].num_components = param->type->vector_elements;
|
||||
@@ -822,7 +822,7 @@ nir_visitor::visit(ir_return *ir)
|
||||
static void
|
||||
intrinsic_set_std430_align(nir_intrinsic_instr *intrin, const glsl_type *type)
|
||||
{
|
||||
unsigned bit_size = type->is_boolean() ? 32 : glsl_get_bit_size(type);
|
||||
unsigned bit_size = glsl_type_is_boolean(type) ? 32 : glsl_get_bit_size(type);
|
||||
unsigned pow2_components = util_next_power_of_two(type->vector_elements);
|
||||
nir_intrinsic_set_align(intrin, (bit_size / 8) * pow2_components, 0);
|
||||
}
|
||||
@@ -843,7 +843,7 @@ deref_get_qualifier(nir_deref_instr *deref)
|
||||
for (nir_deref_instr **cur_ptr = &path.path[1]; *cur_ptr; cur_ptr++) {
|
||||
nir_deref_instr *cur = *cur_ptr;
|
||||
|
||||
if (parent_type->is_interface()) {
|
||||
if (glsl_type_is_interface(parent_type)) {
|
||||
const struct glsl_struct_field *field =
|
||||
&parent_type->fields.structure[cur->strct.index];
|
||||
if (field->memory_read_only)
|
||||
@@ -878,7 +878,7 @@ nir_visitor::visit(ir_call *ir)
|
||||
switch (ir->callee->intrinsic_id) {
|
||||
case ir_intrinsic_generic_atomic_add:
|
||||
op = nir_intrinsic_deref_atomic;
|
||||
atomic_op = ir->return_deref->type->is_integer_32_64()
|
||||
atomic_op = glsl_type_is_integer_32_64(ir->return_deref->type)
|
||||
? nir_atomic_op_iadd : nir_atomic_op_fadd;
|
||||
break;
|
||||
case ir_intrinsic_generic_atomic_and:
|
||||
@@ -927,7 +927,7 @@ nir_visitor::visit(ir_call *ir)
|
||||
break;
|
||||
case ir_intrinsic_generic_atomic_comp_swap:
|
||||
op = nir_intrinsic_deref_atomic_swap;
|
||||
atomic_op = ir->return_deref->type->is_integer_32_64()
|
||||
atomic_op = glsl_type_is_integer_32_64(ir->return_deref->type)
|
||||
? nir_atomic_op_cmpxchg
|
||||
: nir_atomic_op_fcmpxchg;
|
||||
break;
|
||||
@@ -972,7 +972,7 @@ nir_visitor::visit(ir_call *ir)
|
||||
break;
|
||||
case ir_intrinsic_image_atomic_add:
|
||||
op = nir_intrinsic_image_deref_atomic;
|
||||
atomic_op = ir->return_deref->type->is_integer_32_64()
|
||||
atomic_op = glsl_type_is_integer_32_64(ir->return_deref->type)
|
||||
? nir_atomic_op_iadd
|
||||
: nir_atomic_op_fadd;
|
||||
break;
|
||||
@@ -1122,7 +1122,7 @@ nir_visitor::visit(ir_call *ir)
|
||||
|
||||
/* Atomic result */
|
||||
assert(ir->return_deref);
|
||||
if (ir->return_deref->type->is_integer_64()) {
|
||||
if (glsl_type_is_integer_64(ir->return_deref->type)) {
|
||||
nir_def_init(&instr->instr, &instr->def,
|
||||
ir->return_deref->type->vector_elements, 64);
|
||||
} else {
|
||||
@@ -1202,7 +1202,7 @@ nir_visitor::visit(ir_call *ir)
|
||||
unsigned num_components;
|
||||
if (op == nir_intrinsic_image_deref_sparse_load) {
|
||||
const glsl_type *dest_type =
|
||||
ir->return_deref->type->field_type("texel");
|
||||
glsl_get_field_type(ir->return_deref->type, "texel");
|
||||
/* One extra component to hold residency code. */
|
||||
num_components = dest_type->vector_elements + 1;
|
||||
} else
|
||||
@@ -1243,7 +1243,7 @@ nir_visitor::visit(ir_call *ir)
|
||||
nir_def *srcs[4];
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (i < type->coordinate_components())
|
||||
if (i < glsl_get_sampler_coordinate_components(type))
|
||||
srcs[i] = nir_channel(&b, src_addr, i);
|
||||
else
|
||||
srcs[i] = nir_undef(&b, 1, 32);
|
||||
@@ -1366,7 +1366,7 @@ nir_visitor::visit(ir_call *ir)
|
||||
assert(write_mask);
|
||||
|
||||
nir_def *nir_val = evaluate_rvalue(val);
|
||||
if (val->type->is_boolean())
|
||||
if (glsl_type_is_boolean(val->type))
|
||||
nir_val = nir_b2i32(&b, nir_val);
|
||||
|
||||
instr->src[0] = nir_src_for_ssa(nir_val);
|
||||
@@ -1391,14 +1391,14 @@ nir_visitor::visit(ir_call *ir)
|
||||
intrinsic_set_std430_align(instr, type);
|
||||
|
||||
/* Setup destination register */
|
||||
unsigned bit_size = type->is_boolean() ? 32 : glsl_get_bit_size(type);
|
||||
unsigned bit_size = glsl_type_is_boolean(type) ? 32 : glsl_get_bit_size(type);
|
||||
nir_def_init(&instr->instr, &instr->def, type->vector_elements,
|
||||
bit_size);
|
||||
|
||||
nir_builder_instr_insert(&b, &instr->instr);
|
||||
|
||||
/* The value in shared memory is a 32-bit value */
|
||||
if (type->is_boolean())
|
||||
if (glsl_type_is_boolean(type))
|
||||
ret = nir_b2b1(&b, &instr->def);
|
||||
break;
|
||||
}
|
||||
@@ -1420,7 +1420,7 @@ nir_visitor::visit(ir_call *ir)
|
||||
|
||||
nir_def *nir_val = evaluate_rvalue(val);
|
||||
/* The value in shared memory is a 32-bit value */
|
||||
if (val->type->is_boolean())
|
||||
if (glsl_type_is_boolean(val->type))
|
||||
nir_val = nir_b2b32(&b, nir_val);
|
||||
|
||||
instr->src[0] = nir_src_for_ssa(nir_val);
|
||||
@@ -1605,7 +1605,7 @@ nir_visitor::visit(ir_assignment *ir)
|
||||
bool is_sparse = tex && tex->is_sparse;
|
||||
|
||||
if (!is_sparse)
|
||||
assert(ir->rhs->type->is_scalar() || ir->rhs->type->is_vector());
|
||||
assert(glsl_type_is_scalar(ir->rhs->type) || glsl_type_is_vector(ir->rhs->type));
|
||||
|
||||
ir->lhs->accept(this);
|
||||
nir_deref_instr *lhs_deref = this->deref;
|
||||
@@ -2224,7 +2224,7 @@ nir_visitor::visit(ir_expression *ir)
|
||||
result = nir_bcsel(&b, srcs[0], srcs[1], srcs[2]);
|
||||
break;
|
||||
case ir_triop_bitfield_extract:
|
||||
result = ir->type->is_int_16_32() ?
|
||||
result = glsl_type_is_int_16_32(ir->type) ?
|
||||
nir_ibitfield_extract(&b, nir_i2i32(&b, srcs[0]), nir_i2i32(&b, srcs[1]), nir_i2i32(&b, srcs[2])) :
|
||||
nir_ubitfield_extract(&b, nir_u2u32(&b, srcs[0]), nir_i2i32(&b, srcs[1]), nir_i2i32(&b, srcs[2]));
|
||||
|
||||
@@ -2346,7 +2346,7 @@ nir_visitor::visit(ir_texture *ir)
|
||||
if (ir->shadow_comparator != NULL)
|
||||
num_srcs++;
|
||||
/* offsets are constants we store inside nir_tex_intrs.offsets */
|
||||
if (ir->offset != NULL && !ir->offset->type->is_array())
|
||||
if (ir->offset != NULL && !glsl_type_is_array(ir->offset->type))
|
||||
num_srcs++;
|
||||
if (ir->clamp != NULL)
|
||||
num_srcs++;
|
||||
@@ -2363,7 +2363,7 @@ nir_visitor::visit(ir_texture *ir)
|
||||
instr->is_shadow = ir->sampler->type->sampler_shadow;
|
||||
|
||||
const glsl_type *dest_type
|
||||
= ir->is_sparse ? ir->type->field_type("texel") : ir->type;
|
||||
= ir->is_sparse ? glsl_get_field_type(ir->type, "texel") : ir->type;
|
||||
assert(dest_type != &glsl_type_builtin_error);
|
||||
if (instr->is_shadow)
|
||||
instr->is_new_style_shadow = (dest_type->vector_elements == 1);
|
||||
@@ -2407,8 +2407,8 @@ nir_visitor::visit(ir_texture *ir)
|
||||
}
|
||||
|
||||
if (ir->offset != NULL) {
|
||||
if (ir->offset->type->is_array()) {
|
||||
for (int i = 0; i < ir->offset->type->array_size(); i++) {
|
||||
if (glsl_type_is_array(ir->offset->type)) {
|
||||
for (int i = 0; i < glsl_array_size(ir->offset->type); i++) {
|
||||
const ir_constant *c =
|
||||
ir->offset->as_constant()->get_array_element(i);
|
||||
|
||||
@@ -2418,7 +2418,7 @@ nir_visitor::visit(ir_texture *ir)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
assert(ir->offset->type->is_vector() || ir->offset->type->is_scalar());
|
||||
assert(glsl_type_is_vector(ir->offset->type) || glsl_type_is_scalar(ir->offset->type));
|
||||
|
||||
instr->src[src_number] = nir_tex_src_for_ssa(nir_tex_src_offset,
|
||||
evaluate_rvalue(ir->offset));
|
||||
@@ -2540,11 +2540,11 @@ nir_visitor::visit(ir_dereference_record *ir)
|
||||
|
||||
nir_def *ssa;
|
||||
const glsl_type *type = ir->record->type;
|
||||
if (field_index == type->field_index("code")) {
|
||||
if (field_index == glsl_get_field_index(type, "code")) {
|
||||
/* last channel holds residency code */
|
||||
ssa = nir_channel(&b, load, load->num_components - 1);
|
||||
} else {
|
||||
assert(field_index == type->field_index("texel"));
|
||||
assert(field_index == glsl_get_field_index(type, "texel"));
|
||||
|
||||
unsigned mask = BITFIELD_MASK(load->num_components - 1);
|
||||
ssa = nir_channels(&b, load, mask);
|
||||
|
||||
@@ -44,19 +44,19 @@ _mesa_ast_field_selection_to_hir(const ast_expression *expr,
|
||||
* being applied.
|
||||
*/
|
||||
YYLTYPE loc = expr->get_location();
|
||||
if (op->type->is_error()) {
|
||||
if (glsl_type_is_error(op->type)) {
|
||||
/* silently propagate the error */
|
||||
} else if (op->type->is_struct() || op->type->is_interface()) {
|
||||
} else if (glsl_type_is_struct(op->type) || glsl_type_is_interface(op->type)) {
|
||||
result = new(ctx) ir_dereference_record(op,
|
||||
expr->primary_expression.identifier);
|
||||
|
||||
if (result->type->is_error()) {
|
||||
if (glsl_type_is_error(result->type)) {
|
||||
_mesa_glsl_error(& loc, state, "cannot access field `%s' of "
|
||||
"structure",
|
||||
expr->primary_expression.identifier);
|
||||
}
|
||||
} else if (op->type->is_vector() ||
|
||||
(state->has_420pack() && op->type->is_scalar())) {
|
||||
} else if (glsl_type_is_vector(op->type) ||
|
||||
(state->has_420pack() && glsl_type_is_scalar(op->type))) {
|
||||
ir_swizzle *swiz = ir_swizzle::create(op,
|
||||
expr->primary_expression.identifier,
|
||||
op->type->vector_elements);
|
||||
|
||||
+96
-116
@@ -133,10 +133,10 @@ ir_assignment::whole_variable_written()
|
||||
if (v == NULL)
|
||||
return NULL;
|
||||
|
||||
if (v->type->is_scalar())
|
||||
if (glsl_type_is_scalar(v->type))
|
||||
return v;
|
||||
|
||||
if (v->type->is_vector()) {
|
||||
if (glsl_type_is_vector(v->type)) {
|
||||
const unsigned mask = (1U << v->type->vector_elements) - 1;
|
||||
|
||||
if (mask != this->write_mask)
|
||||
@@ -157,7 +157,7 @@ ir_assignment::ir_assignment(ir_dereference *lhs, ir_rvalue *rhs,
|
||||
this->lhs = lhs;
|
||||
this->write_mask = write_mask;
|
||||
|
||||
if (lhs->type->is_scalar() || lhs->type->is_vector())
|
||||
if (glsl_type_is_scalar(lhs->type) || glsl_type_is_vector(lhs->type))
|
||||
assert(util_bitcount(write_mask) == this->rhs->type->vector_elements);
|
||||
}
|
||||
|
||||
@@ -173,9 +173,9 @@ ir_assignment::ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs)
|
||||
*
|
||||
* (assign (...) (xyz) (var_ref lhs) (var_ref rhs))
|
||||
*/
|
||||
if (rhs->type->is_vector())
|
||||
if (glsl_type_is_vector(rhs->type))
|
||||
this->write_mask = (1U << rhs->type->vector_elements) - 1;
|
||||
else if (rhs->type->is_scalar())
|
||||
else if (glsl_type_is_scalar(rhs->type))
|
||||
this->write_mask = 1;
|
||||
else
|
||||
this->write_mask = 0;
|
||||
@@ -266,8 +266,7 @@ ir_expression::ir_expression(int op, ir_rvalue *op0)
|
||||
case ir_unop_subroutine_to_int:
|
||||
case ir_unop_i642i:
|
||||
case ir_unop_u642i:
|
||||
this->type = glsl_type::get_instance(GLSL_TYPE_INT,
|
||||
op0->type->vector_elements, 1);
|
||||
this->type = glsl_simple_type(GLSL_TYPE_INT, op0->type->vector_elements, 1);
|
||||
break;
|
||||
|
||||
case ir_unop_b2f:
|
||||
@@ -279,47 +278,39 @@ ir_expression::ir_expression(int op, ir_rvalue *op0)
|
||||
case ir_unop_bitcast_u2f:
|
||||
case ir_unop_i642f:
|
||||
case ir_unop_u642f:
|
||||
this->type = glsl_type::get_instance(GLSL_TYPE_FLOAT,
|
||||
op0->type->vector_elements, 1);
|
||||
this->type = glsl_simple_type(GLSL_TYPE_FLOAT, op0->type->vector_elements, 1);
|
||||
break;
|
||||
|
||||
case ir_unop_f2f16:
|
||||
case ir_unop_f2fmp:
|
||||
case ir_unop_b2f16:
|
||||
this->type = glsl_type::get_instance(GLSL_TYPE_FLOAT16,
|
||||
op0->type->vector_elements, 1);
|
||||
this->type = glsl_simple_type(GLSL_TYPE_FLOAT16, op0->type->vector_elements, 1);
|
||||
break;
|
||||
|
||||
case ir_unop_i2imp:
|
||||
this->type = glsl_type::get_instance(GLSL_TYPE_INT16,
|
||||
op0->type->vector_elements, 1);
|
||||
this->type = glsl_simple_type(GLSL_TYPE_INT16, op0->type->vector_elements, 1);
|
||||
break;
|
||||
|
||||
case ir_unop_i2i:
|
||||
if (op0->type->base_type == GLSL_TYPE_INT) {
|
||||
this->type = glsl_type::get_instance(GLSL_TYPE_INT16,
|
||||
op0->type->vector_elements, 1);
|
||||
this->type = glsl_simple_type(GLSL_TYPE_INT16, op0->type->vector_elements, 1);
|
||||
} else {
|
||||
assert(op0->type->base_type == GLSL_TYPE_INT16);
|
||||
this->type = glsl_type::get_instance(GLSL_TYPE_INT,
|
||||
op0->type->vector_elements, 1);
|
||||
this->type = glsl_simple_type(GLSL_TYPE_INT, op0->type->vector_elements, 1);
|
||||
}
|
||||
break;
|
||||
|
||||
case ir_unop_u2u:
|
||||
if (op0->type->base_type == GLSL_TYPE_UINT) {
|
||||
this->type = glsl_type::get_instance(GLSL_TYPE_UINT16,
|
||||
op0->type->vector_elements, 1);
|
||||
this->type = glsl_simple_type(GLSL_TYPE_UINT16, op0->type->vector_elements, 1);
|
||||
} else {
|
||||
assert(op0->type->base_type == GLSL_TYPE_UINT16);
|
||||
this->type = glsl_type::get_instance(GLSL_TYPE_UINT,
|
||||
op0->type->vector_elements, 1);
|
||||
this->type = glsl_simple_type(GLSL_TYPE_UINT, op0->type->vector_elements, 1);
|
||||
}
|
||||
break;
|
||||
|
||||
case ir_unop_u2ump:
|
||||
this->type = glsl_type::get_instance(GLSL_TYPE_UINT16,
|
||||
op0->type->vector_elements, 1);
|
||||
this->type = glsl_simple_type(GLSL_TYPE_UINT16, op0->type->vector_elements, 1);
|
||||
break;
|
||||
|
||||
case ir_unop_f2b:
|
||||
@@ -327,8 +318,7 @@ ir_expression::ir_expression(int op, ir_rvalue *op0)
|
||||
case ir_unop_d2b:
|
||||
case ir_unop_f162b:
|
||||
case ir_unop_i642b:
|
||||
this->type = glsl_type::get_instance(GLSL_TYPE_BOOL,
|
||||
op0->type->vector_elements, 1);
|
||||
this->type = glsl_simple_type(GLSL_TYPE_BOOL, op0->type->vector_elements, 1);
|
||||
break;
|
||||
|
||||
case ir_unop_f2d:
|
||||
@@ -336,8 +326,7 @@ ir_expression::ir_expression(int op, ir_rvalue *op0)
|
||||
case ir_unop_u2d:
|
||||
case ir_unop_i642d:
|
||||
case ir_unop_u642d:
|
||||
this->type = glsl_type::get_instance(GLSL_TYPE_DOUBLE,
|
||||
op0->type->vector_elements, 1);
|
||||
this->type = glsl_simple_type(GLSL_TYPE_DOUBLE, op0->type->vector_elements, 1);
|
||||
break;
|
||||
|
||||
case ir_unop_i2u:
|
||||
@@ -346,8 +335,7 @@ ir_expression::ir_expression(int op, ir_rvalue *op0)
|
||||
case ir_unop_bitcast_f2u:
|
||||
case ir_unop_i642u:
|
||||
case ir_unop_u642u:
|
||||
this->type = glsl_type::get_instance(GLSL_TYPE_UINT,
|
||||
op0->type->vector_elements, 1);
|
||||
this->type = glsl_simple_type(GLSL_TYPE_UINT, op0->type->vector_elements, 1);
|
||||
break;
|
||||
|
||||
case ir_unop_i2i64:
|
||||
@@ -356,8 +344,7 @@ ir_expression::ir_expression(int op, ir_rvalue *op0)
|
||||
case ir_unop_f2i64:
|
||||
case ir_unop_d2i64:
|
||||
case ir_unop_u642i64:
|
||||
this->type = glsl_type::get_instance(GLSL_TYPE_INT64,
|
||||
op0->type->vector_elements, 1);
|
||||
this->type = glsl_simple_type(GLSL_TYPE_INT64, op0->type->vector_elements, 1);
|
||||
break;
|
||||
|
||||
case ir_unop_i2u64:
|
||||
@@ -365,8 +352,7 @@ ir_expression::ir_expression(int op, ir_rvalue *op0)
|
||||
case ir_unop_f2u64:
|
||||
case ir_unop_d2u64:
|
||||
case ir_unop_i642u64:
|
||||
this->type = glsl_type::get_instance(GLSL_TYPE_UINT64,
|
||||
op0->type->vector_elements, 1);
|
||||
this->type = glsl_simple_type(GLSL_TYPE_UINT64, op0->type->vector_elements, 1);
|
||||
break;
|
||||
|
||||
case ir_unop_unpack_double_2x32:
|
||||
@@ -423,8 +409,7 @@ ir_expression::ir_expression(int op, ir_rvalue *op0)
|
||||
this->type = op0->type;
|
||||
break;
|
||||
case ir_unop_frexp_exp:
|
||||
this->type = glsl_type::get_instance(GLSL_TYPE_INT,
|
||||
op0->type->vector_elements, 1);
|
||||
this->type = glsl_simple_type(GLSL_TYPE_INT, op0->type->vector_elements, 1);
|
||||
break;
|
||||
|
||||
case ir_unop_get_buffer_size:
|
||||
@@ -435,17 +420,14 @@ ir_expression::ir_expression(int op, ir_rvalue *op0)
|
||||
|
||||
case ir_unop_bitcast_i642d:
|
||||
case ir_unop_bitcast_u642d:
|
||||
this->type = glsl_type::get_instance(GLSL_TYPE_DOUBLE,
|
||||
op0->type->vector_elements, 1);
|
||||
this->type = glsl_simple_type(GLSL_TYPE_DOUBLE, op0->type->vector_elements, 1);
|
||||
break;
|
||||
|
||||
case ir_unop_bitcast_d2i64:
|
||||
this->type = glsl_type::get_instance(GLSL_TYPE_INT64,
|
||||
op0->type->vector_elements, 1);
|
||||
this->type = glsl_simple_type(GLSL_TYPE_INT64, op0->type->vector_elements, 1);
|
||||
break;
|
||||
case ir_unop_bitcast_d2u64:
|
||||
this->type = glsl_type::get_instance(GLSL_TYPE_UINT64,
|
||||
op0->type->vector_elements, 1);
|
||||
this->type = glsl_simple_type(GLSL_TYPE_UINT64, op0->type->vector_elements, 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -486,13 +468,13 @@ ir_expression::ir_expression(int op, ir_rvalue *op0, ir_rvalue *op1)
|
||||
case ir_binop_div:
|
||||
case ir_binop_mod:
|
||||
case ir_binop_atan2:
|
||||
if (op0->type->is_scalar()) {
|
||||
if (glsl_type_is_scalar(op0->type)) {
|
||||
this->type = op1->type;
|
||||
} else if (op1->type->is_scalar()) {
|
||||
} else if (glsl_type_is_scalar(op1->type)) {
|
||||
this->type = op0->type;
|
||||
} else {
|
||||
if (this->operation == ir_binop_mul) {
|
||||
this->type = glsl_type::get_mul_type(op0->type, op1->type);
|
||||
this->type = glsl_get_mul_type(op0->type, op1->type);
|
||||
} else {
|
||||
assert(op0->type == op1->type);
|
||||
this->type = op0->type;
|
||||
@@ -506,11 +488,11 @@ ir_expression::ir_expression(int op, ir_rvalue *op0, ir_rvalue *op1)
|
||||
case ir_binop_bit_and:
|
||||
case ir_binop_bit_xor:
|
||||
case ir_binop_bit_or:
|
||||
assert(!op0->type->is_matrix());
|
||||
assert(!op1->type->is_matrix());
|
||||
if (op0->type->is_scalar()) {
|
||||
assert(!glsl_type_is_matrix(op0->type));
|
||||
assert(!glsl_type_is_matrix(op1->type));
|
||||
if (glsl_type_is_scalar(op0->type)) {
|
||||
this->type = op1->type;
|
||||
} else if (op1->type->is_scalar()) {
|
||||
} else if (glsl_type_is_scalar(op1->type)) {
|
||||
this->type = op0->type;
|
||||
} else {
|
||||
assert(op0->type->vector_elements == op1->type->vector_elements);
|
||||
@@ -523,12 +505,11 @@ ir_expression::ir_expression(int op, ir_rvalue *op0, ir_rvalue *op1)
|
||||
case ir_binop_gequal:
|
||||
case ir_binop_less:
|
||||
assert(op0->type == op1->type);
|
||||
this->type = glsl_type::get_instance(GLSL_TYPE_BOOL,
|
||||
op0->type->vector_elements, 1);
|
||||
this->type = glsl_simple_type(GLSL_TYPE_BOOL, op0->type->vector_elements, 1);
|
||||
break;
|
||||
|
||||
case ir_binop_dot:
|
||||
this->type = op0->type->get_base_type();
|
||||
this->type = glsl_get_base_glsl_type(op0->type);
|
||||
break;
|
||||
|
||||
case ir_binop_imul_high:
|
||||
@@ -577,12 +558,12 @@ ir_expression::ir_expression(int op, ir_rvalue *op0, ir_rvalue *op1)
|
||||
unreachable("Invalid base type.");
|
||||
}
|
||||
|
||||
this->type = glsl_type::get_instance(base, op0->type->vector_elements, 1);
|
||||
this->type = glsl_simple_type(base, op0->type->vector_elements, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
case ir_binop_vector_extract:
|
||||
this->type = op0->type->get_scalar_type();
|
||||
this->type = glsl_get_scalar_type(op0->type);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -718,7 +699,7 @@ ir_constant::ir_constant(float16_t f16, unsigned vector_elements)
|
||||
{
|
||||
this->const_elements = NULL;
|
||||
assert(vector_elements <= 4);
|
||||
this->type = glsl_type::get_instance(GLSL_TYPE_FLOAT16, vector_elements, 1);
|
||||
this->type = glsl_simple_type(GLSL_TYPE_FLOAT16, vector_elements, 1);
|
||||
for (unsigned i = 0; i < vector_elements; i++) {
|
||||
this->value.f16[i] = f16.bits;
|
||||
}
|
||||
@@ -732,7 +713,7 @@ ir_constant::ir_constant(float f, unsigned vector_elements)
|
||||
{
|
||||
this->const_elements = NULL;
|
||||
assert(vector_elements <= 4);
|
||||
this->type = glsl_type::get_instance(GLSL_TYPE_FLOAT, vector_elements, 1);
|
||||
this->type = glsl_simple_type(GLSL_TYPE_FLOAT, vector_elements, 1);
|
||||
for (unsigned i = 0; i < vector_elements; i++) {
|
||||
this->value.f[i] = f;
|
||||
}
|
||||
@@ -746,7 +727,7 @@ ir_constant::ir_constant(double d, unsigned vector_elements)
|
||||
{
|
||||
this->const_elements = NULL;
|
||||
assert(vector_elements <= 4);
|
||||
this->type = glsl_type::get_instance(GLSL_TYPE_DOUBLE, vector_elements, 1);
|
||||
this->type = glsl_simple_type(GLSL_TYPE_DOUBLE, vector_elements, 1);
|
||||
for (unsigned i = 0; i < vector_elements; i++) {
|
||||
this->value.d[i] = d;
|
||||
}
|
||||
@@ -760,7 +741,7 @@ ir_constant::ir_constant(int16_t i16, unsigned vector_elements)
|
||||
{
|
||||
this->const_elements = NULL;
|
||||
assert(vector_elements <= 4);
|
||||
this->type = glsl_type::get_instance(GLSL_TYPE_INT16, vector_elements, 1);
|
||||
this->type = glsl_simple_type(GLSL_TYPE_INT16, vector_elements, 1);
|
||||
for (unsigned i = 0; i < vector_elements; i++) {
|
||||
this->value.i16[i] = i16;
|
||||
}
|
||||
@@ -774,7 +755,7 @@ ir_constant::ir_constant(uint16_t u16, unsigned vector_elements)
|
||||
{
|
||||
this->const_elements = NULL;
|
||||
assert(vector_elements <= 4);
|
||||
this->type = glsl_type::get_instance(GLSL_TYPE_UINT16, vector_elements, 1);
|
||||
this->type = glsl_simple_type(GLSL_TYPE_UINT16, vector_elements, 1);
|
||||
for (unsigned i = 0; i < vector_elements; i++) {
|
||||
this->value.u16[i] = u16;
|
||||
}
|
||||
@@ -788,7 +769,7 @@ ir_constant::ir_constant(unsigned int u, unsigned vector_elements)
|
||||
{
|
||||
this->const_elements = NULL;
|
||||
assert(vector_elements <= 4);
|
||||
this->type = glsl_type::get_instance(GLSL_TYPE_UINT, vector_elements, 1);
|
||||
this->type = glsl_simple_type(GLSL_TYPE_UINT, vector_elements, 1);
|
||||
for (unsigned i = 0; i < vector_elements; i++) {
|
||||
this->value.u[i] = u;
|
||||
}
|
||||
@@ -802,7 +783,7 @@ ir_constant::ir_constant(int integer, unsigned vector_elements)
|
||||
{
|
||||
this->const_elements = NULL;
|
||||
assert(vector_elements <= 4);
|
||||
this->type = glsl_type::get_instance(GLSL_TYPE_INT, vector_elements, 1);
|
||||
this->type = glsl_simple_type(GLSL_TYPE_INT, vector_elements, 1);
|
||||
for (unsigned i = 0; i < vector_elements; i++) {
|
||||
this->value.i[i] = integer;
|
||||
}
|
||||
@@ -816,7 +797,7 @@ ir_constant::ir_constant(uint64_t u64, unsigned vector_elements)
|
||||
{
|
||||
this->const_elements = NULL;
|
||||
assert(vector_elements <= 4);
|
||||
this->type = glsl_type::get_instance(GLSL_TYPE_UINT64, vector_elements, 1);
|
||||
this->type = glsl_simple_type(GLSL_TYPE_UINT64, vector_elements, 1);
|
||||
for (unsigned i = 0; i < vector_elements; i++) {
|
||||
this->value.u64[i] = u64;
|
||||
}
|
||||
@@ -830,7 +811,7 @@ ir_constant::ir_constant(int64_t int64, unsigned vector_elements)
|
||||
{
|
||||
this->const_elements = NULL;
|
||||
assert(vector_elements <= 4);
|
||||
this->type = glsl_type::get_instance(GLSL_TYPE_INT64, vector_elements, 1);
|
||||
this->type = glsl_simple_type(GLSL_TYPE_INT64, vector_elements, 1);
|
||||
for (unsigned i = 0; i < vector_elements; i++) {
|
||||
this->value.i64[i] = int64;
|
||||
}
|
||||
@@ -844,7 +825,7 @@ ir_constant::ir_constant(bool b, unsigned vector_elements)
|
||||
{
|
||||
this->const_elements = NULL;
|
||||
assert(vector_elements <= 4);
|
||||
this->type = glsl_type::get_instance(GLSL_TYPE_BOOL, vector_elements, 1);
|
||||
this->type = glsl_simple_type(GLSL_TYPE_BOOL, vector_elements, 1);
|
||||
for (unsigned i = 0; i < vector_elements; i++) {
|
||||
this->value.b[i] = b;
|
||||
}
|
||||
@@ -857,7 +838,7 @@ ir_constant::ir_constant(const ir_constant *c, unsigned i)
|
||||
: ir_rvalue(ir_type_constant)
|
||||
{
|
||||
this->const_elements = NULL;
|
||||
this->type = c->type->get_base_type();
|
||||
this->type = glsl_get_base_glsl_type(c->type);
|
||||
|
||||
/* Section 5.11 (Out-of-Bounds Accesses) of the GLSL 4.60 spec says:
|
||||
*
|
||||
@@ -892,15 +873,15 @@ ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list)
|
||||
this->const_elements = NULL;
|
||||
this->type = type;
|
||||
|
||||
assert(type->is_scalar() || type->is_vector() || type->is_matrix()
|
||||
|| type->is_struct() || type->is_array());
|
||||
assert(glsl_type_is_scalar(type) || glsl_type_is_vector(type) || glsl_type_is_matrix(type)
|
||||
|| glsl_type_is_struct(type) || glsl_type_is_array(type));
|
||||
|
||||
/* If the constant is a record, the types of each of the entries in
|
||||
* value_list must be a 1-for-1 match with the structure components. Each
|
||||
* entry must also be a constant. Just move the nodes from the value_list
|
||||
* to the list in the ir_constant.
|
||||
*/
|
||||
if (type->is_array() || type->is_struct()) {
|
||||
if (glsl_type_is_array(type) || glsl_type_is_struct(type)) {
|
||||
this->const_elements = ralloc_array(this, ir_constant *, type->length);
|
||||
unsigned i = 0;
|
||||
foreach_in_list(ir_constant, value, value_list) {
|
||||
@@ -922,8 +903,8 @@ ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list)
|
||||
* the components. For matrices, the scalar fills the components of the
|
||||
* diagonal while the rest is filled with 0.
|
||||
*/
|
||||
if (value->type->is_scalar() && value->next->is_tail_sentinel()) {
|
||||
if (type->is_matrix()) {
|
||||
if (glsl_type_is_scalar(value->type) && value->next->is_tail_sentinel()) {
|
||||
if (glsl_type_is_matrix(type)) {
|
||||
/* Matrix - fill diagonal (rest is already set to 0) */
|
||||
for (unsigned i = 0; i < type->matrix_columns; i++) {
|
||||
switch (type->base_type) {
|
||||
@@ -948,33 +929,33 @@ ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list)
|
||||
switch (type->base_type) {
|
||||
case GLSL_TYPE_UINT16:
|
||||
case GLSL_TYPE_INT16:
|
||||
for (unsigned i = 0; i < type->components(); i++)
|
||||
for (unsigned i = 0; i < glsl_get_components(type); i++)
|
||||
this->value.u16[i] = value->value.u16[0];
|
||||
break;
|
||||
case GLSL_TYPE_UINT:
|
||||
case GLSL_TYPE_INT:
|
||||
for (unsigned i = 0; i < type->components(); i++)
|
||||
for (unsigned i = 0; i < glsl_get_components(type); i++)
|
||||
this->value.u[i] = value->value.u[0];
|
||||
break;
|
||||
case GLSL_TYPE_FLOAT:
|
||||
for (unsigned i = 0; i < type->components(); i++)
|
||||
for (unsigned i = 0; i < glsl_get_components(type); i++)
|
||||
this->value.f[i] = value->value.f[0];
|
||||
break;
|
||||
case GLSL_TYPE_FLOAT16:
|
||||
for (unsigned i = 0; i < type->components(); i++)
|
||||
for (unsigned i = 0; i < glsl_get_components(type); i++)
|
||||
this->value.f16[i] = value->value.f16[0];
|
||||
break;
|
||||
case GLSL_TYPE_DOUBLE:
|
||||
for (unsigned i = 0; i < type->components(); i++)
|
||||
for (unsigned i = 0; i < glsl_get_components(type); i++)
|
||||
this->value.d[i] = value->value.d[0];
|
||||
break;
|
||||
case GLSL_TYPE_UINT64:
|
||||
case GLSL_TYPE_INT64:
|
||||
for (unsigned i = 0; i < type->components(); i++)
|
||||
for (unsigned i = 0; i < glsl_get_components(type); i++)
|
||||
this->value.u64[i] = value->value.u64[0];
|
||||
break;
|
||||
case GLSL_TYPE_BOOL:
|
||||
for (unsigned i = 0; i < type->components(); i++)
|
||||
for (unsigned i = 0; i < glsl_get_components(type); i++)
|
||||
this->value.b[i] = value->value.b[0];
|
||||
break;
|
||||
case GLSL_TYPE_SAMPLER:
|
||||
@@ -989,7 +970,7 @@ ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list)
|
||||
return;
|
||||
}
|
||||
|
||||
if (type->is_matrix() && value->type->is_matrix()) {
|
||||
if (glsl_type_is_matrix(type) && glsl_type_is_matrix(value->type)) {
|
||||
assert(value->next->is_tail_sentinel());
|
||||
|
||||
/* From section 5.4.2 of the GLSL 1.20 spec:
|
||||
@@ -1022,7 +1003,7 @@ ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list)
|
||||
assert(value->as_constant() != NULL);
|
||||
assert(!value->is_tail_sentinel());
|
||||
|
||||
for (unsigned j = 0; j < value->type->components(); j++) {
|
||||
for (unsigned j = 0; j < glsl_get_components(value->type); j++) {
|
||||
switch (type->base_type) {
|
||||
case GLSL_TYPE_UINT16:
|
||||
this->value.u16[i] = value->get_uint16_component(j);
|
||||
@@ -1061,11 +1042,11 @@ ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list)
|
||||
}
|
||||
|
||||
i++;
|
||||
if (i >= type->components())
|
||||
if (i >= glsl_get_components(type))
|
||||
break;
|
||||
}
|
||||
|
||||
if (i >= type->components())
|
||||
if (i >= glsl_get_components(type))
|
||||
break; /* avoid downcasting a list sentinel */
|
||||
value = (ir_constant *) value->next;
|
||||
}
|
||||
@@ -1074,21 +1055,21 @@ ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list)
|
||||
ir_constant *
|
||||
ir_constant::zero(void *mem_ctx, const glsl_type *type)
|
||||
{
|
||||
assert(type->is_scalar() || type->is_vector() || type->is_matrix()
|
||||
|| type->is_struct() || type->is_array());
|
||||
assert(glsl_type_is_scalar(type) || glsl_type_is_vector(type) || glsl_type_is_matrix(type)
|
||||
|| glsl_type_is_struct(type) || glsl_type_is_array(type));
|
||||
|
||||
ir_constant *c = new(mem_ctx) ir_constant;
|
||||
c->type = type;
|
||||
memset(&c->value, 0, sizeof(c->value));
|
||||
|
||||
if (type->is_array()) {
|
||||
if (glsl_type_is_array(type)) {
|
||||
c->const_elements = ralloc_array(c, ir_constant *, type->length);
|
||||
|
||||
for (unsigned i = 0; i < type->length; i++)
|
||||
c->const_elements[i] = ir_constant::zero(c, type->fields.array);
|
||||
}
|
||||
|
||||
if (type->is_struct()) {
|
||||
if (glsl_type_is_struct(type)) {
|
||||
c->const_elements = ralloc_array(c, ir_constant *, type->length);
|
||||
|
||||
for (unsigned i = 0; i < type->length; i++) {
|
||||
@@ -1337,7 +1318,7 @@ ir_constant::get_uint64_component(unsigned i) const
|
||||
ir_constant *
|
||||
ir_constant::get_array_element(unsigned i) const
|
||||
{
|
||||
assert(this->type->is_array());
|
||||
assert(glsl_type_is_array(this->type));
|
||||
|
||||
/* From page 35 (page 41 of the PDF) of the GLSL 1.20 spec:
|
||||
*
|
||||
@@ -1360,7 +1341,7 @@ ir_constant::get_array_element(unsigned i) const
|
||||
ir_constant *
|
||||
ir_constant::get_record_field(int idx)
|
||||
{
|
||||
assert(this->type->is_struct());
|
||||
assert(glsl_type_is_struct(this->type));
|
||||
assert(idx >= 0 && (unsigned) idx < this->type->length);
|
||||
|
||||
return const_elements[idx];
|
||||
@@ -1382,8 +1363,8 @@ ir_constant::copy_offset(ir_constant *src, int offset)
|
||||
case GLSL_TYPE_UINT64:
|
||||
case GLSL_TYPE_INT64:
|
||||
case GLSL_TYPE_BOOL: {
|
||||
unsigned int size = src->type->components();
|
||||
assert (size <= this->type->components() - offset);
|
||||
unsigned int size = glsl_get_components(src->type);
|
||||
assert (size <= glsl_get_components(this->type) - offset);
|
||||
for (unsigned int i=0; i<size; i++) {
|
||||
switch (this->type->base_type) {
|
||||
case GLSL_TYPE_UINT16:
|
||||
@@ -1443,9 +1424,9 @@ ir_constant::copy_offset(ir_constant *src, int offset)
|
||||
void
|
||||
ir_constant::copy_masked_offset(ir_constant *src, int offset, unsigned int mask)
|
||||
{
|
||||
assert (!type->is_array() && !type->is_struct());
|
||||
assert (!glsl_type_is_array(type) && !glsl_type_is_struct(type));
|
||||
|
||||
if (!type->is_vector() && !type->is_matrix()) {
|
||||
if (!glsl_type_is_vector(type) && !glsl_type_is_matrix(type)) {
|
||||
offset = 0;
|
||||
mask = 1;
|
||||
}
|
||||
@@ -1500,7 +1481,7 @@ ir_constant::has_value(const ir_constant *c) const
|
||||
if (this->type != c->type)
|
||||
return false;
|
||||
|
||||
if (this->type->is_array() || this->type->is_struct()) {
|
||||
if (glsl_type_is_array(this->type) || glsl_type_is_struct(this->type)) {
|
||||
for (unsigned i = 0; i < this->type->length; i++) {
|
||||
if (!this->const_elements[i]->has_value(c->const_elements[i]))
|
||||
return false;
|
||||
@@ -1508,7 +1489,7 @@ ir_constant::has_value(const ir_constant *c) const
|
||||
return true;
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < this->type->components(); i++) {
|
||||
for (unsigned i = 0; i < glsl_get_components(this->type); i++) {
|
||||
switch (this->type->base_type) {
|
||||
case GLSL_TYPE_UINT16:
|
||||
if (this->value.u16[i] != c->value.u16[i])
|
||||
@@ -1566,11 +1547,11 @@ ir_constant::has_value(const ir_constant *c) const
|
||||
bool
|
||||
ir_constant::is_value(float f, int i) const
|
||||
{
|
||||
if (!this->type->is_scalar() && !this->type->is_vector())
|
||||
if (!glsl_type_is_scalar(this->type) && !glsl_type_is_vector(this->type))
|
||||
return false;
|
||||
|
||||
/* Only accept boolean values for 0/1. */
|
||||
if (int(bool(i)) != i && this->type->is_boolean())
|
||||
if (int(bool(i)) != i && glsl_type_is_boolean(this->type))
|
||||
return false;
|
||||
|
||||
for (unsigned c = 0; c < this->type->vector_elements; c++) {
|
||||
@@ -1651,7 +1632,7 @@ ir_constant::is_negative_one() const
|
||||
bool
|
||||
ir_constant::is_uint16_constant() const
|
||||
{
|
||||
if (!type->is_integer_32())
|
||||
if (!glsl_type_is_integer_32(type))
|
||||
return false;
|
||||
|
||||
return value.u[0] < (1 << 16);
|
||||
@@ -1702,12 +1683,12 @@ ir_dereference_array::set_array(ir_rvalue *value)
|
||||
|
||||
const glsl_type *const vt = this->array->type;
|
||||
|
||||
if (vt->is_array()) {
|
||||
if (glsl_type_is_array(vt)) {
|
||||
type = vt->fields.array;
|
||||
} else if (vt->is_matrix()) {
|
||||
type = vt->column_type();
|
||||
} else if (vt->is_vector()) {
|
||||
type = vt->get_base_type();
|
||||
} else if (glsl_type_is_matrix(vt)) {
|
||||
type = glsl_get_column_type(vt);
|
||||
} else if (glsl_type_is_vector(vt)) {
|
||||
type = glsl_get_base_glsl_type(vt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1719,8 +1700,8 @@ ir_dereference_record::ir_dereference_record(ir_rvalue *value,
|
||||
assert(value != NULL);
|
||||
|
||||
this->record = value;
|
||||
this->type = this->record->type->field_type(field);
|
||||
this->field_idx = this->record->type->field_index(field);
|
||||
this->type = glsl_get_field_type(this->record->type, field);
|
||||
this->field_idx = glsl_get_field_index(this->record->type, field);
|
||||
}
|
||||
|
||||
|
||||
@@ -1731,8 +1712,8 @@ ir_dereference_record::ir_dereference_record(ir_variable *var,
|
||||
void *ctx = ralloc_parent(var);
|
||||
|
||||
this->record = new(ctx) ir_dereference_variable(var);
|
||||
this->type = this->record->type->field_type(field);
|
||||
this->field_idx = this->record->type->field_index(field);
|
||||
this->type = glsl_get_field_type(this->record->type, field);
|
||||
this->field_idx = glsl_get_field_index(this->record->type, field);
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -1756,7 +1737,7 @@ ir_dereference::is_lvalue(const struct _mesa_glsl_parse_state *state) const
|
||||
* "out" and "inout" function parameters."
|
||||
*/
|
||||
if ((!state || state->has_bindless()) &&
|
||||
(this->type->contains_sampler() || this->type->contains_image()))
|
||||
(glsl_contains_sampler(this->type) || glsl_type_contains_image(this->type)))
|
||||
return true;
|
||||
|
||||
/* From section 4.1.7 of the GLSL 4.40 spec:
|
||||
@@ -1765,7 +1746,7 @@ ir_dereference::is_lvalue(const struct _mesa_glsl_parse_state *state) const
|
||||
* be used as out or inout function parameters, nor can they be
|
||||
* assigned into."
|
||||
*/
|
||||
if (this->type->contains_opaque())
|
||||
if (glsl_contains_opaque(this->type))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@@ -1805,7 +1786,7 @@ ir_texture::set_sampler(ir_dereference *sampler, const glsl_type *type)
|
||||
glsl_struct_field(&glsl_type_builtin_int, "code"),
|
||||
glsl_struct_field(type, "texel"),
|
||||
};
|
||||
this->type = glsl_type::get_struct_instance(fields, 2, "struct");
|
||||
this->type = glsl_struct_type(fields, 2, "struct", false /* packed */);
|
||||
} else
|
||||
this->type = type;
|
||||
|
||||
@@ -1814,10 +1795,10 @@ ir_texture::set_sampler(ir_dereference *sampler, const glsl_type *type)
|
||||
assert(type->base_type == GLSL_TYPE_INT);
|
||||
} else if (this->op == ir_lod) {
|
||||
assert(type->vector_elements == 2);
|
||||
assert(type->is_float());
|
||||
assert(glsl_type_is_float(type));
|
||||
} else if (this->op == ir_samples_identical) {
|
||||
assert(type == &glsl_type_builtin_bool);
|
||||
assert(sampler->type->is_sampler());
|
||||
assert(glsl_type_is_sampler(sampler->type));
|
||||
assert(sampler->type->sampler_dimensionality == GLSL_SAMPLER_DIM_MS);
|
||||
} else {
|
||||
assert(sampler->type->sampled_type == (int) type->base_type);
|
||||
@@ -1868,7 +1849,7 @@ ir_swizzle::init_mask(const unsigned *comp, unsigned count)
|
||||
* (i.e., float, int, unsigned, or bool) of the vector being swizzled,
|
||||
* generate the type of the resulting value.
|
||||
*/
|
||||
type = glsl_type::get_instance(val->type->base_type, mask.num_components, 1);
|
||||
type = glsl_simple_type(val->type->base_type, mask.num_components, 1);
|
||||
}
|
||||
|
||||
ir_swizzle::ir_swizzle(ir_rvalue *val, unsigned x, unsigned y, unsigned z,
|
||||
@@ -1889,8 +1870,7 @@ ir_swizzle::ir_swizzle(ir_rvalue *val, const unsigned *comp,
|
||||
ir_swizzle::ir_swizzle(ir_rvalue *val, ir_swizzle_mask mask)
|
||||
: ir_rvalue(ir_type_swizzle), val(val), mask(mask)
|
||||
{
|
||||
this->type = glsl_type::get_instance(val->type->base_type,
|
||||
mask.num_components, 1);
|
||||
this->type = glsl_simple_type(val->type->base_type, mask.num_components, 1);
|
||||
}
|
||||
|
||||
#define X 1
|
||||
@@ -2077,10 +2057,10 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name,
|
||||
this->interface_type = NULL;
|
||||
|
||||
if (type != NULL) {
|
||||
if (type->is_interface())
|
||||
if (glsl_type_is_interface(type))
|
||||
this->init_interface_type(type);
|
||||
else if (type->without_array()->is_interface())
|
||||
this->init_interface_type(type->without_array());
|
||||
else if (glsl_type_is_interface(glsl_without_array(type)))
|
||||
this->init_interface_type(glsl_without_array(type));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2257,7 +2237,7 @@ steal_memory(ir_instruction *ir, void *new_ctx)
|
||||
* visitor, so steal their values by hand.
|
||||
*/
|
||||
if (constant != NULL &&
|
||||
(constant->type->is_array() || constant->type->is_struct())) {
|
||||
(glsl_type_is_array(constant->type) || glsl_type_is_struct(constant->type))) {
|
||||
for (unsigned int i = 0; i < constant->type->length; i++) {
|
||||
steal_memory(constant->const_elements[i], ir);
|
||||
}
|
||||
|
||||
@@ -453,7 +453,7 @@ public:
|
||||
*/
|
||||
inline bool is_interface_instance() const
|
||||
{
|
||||
return this->type->without_array() == this->interface_type;
|
||||
return glsl_without_array(this->type) == this->interface_type;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -461,7 +461,7 @@ public:
|
||||
*/
|
||||
inline bool contains_bindless() const
|
||||
{
|
||||
if (!this->type->contains_sampler() && !this->type->contains_image())
|
||||
if (!glsl_contains_sampler(this->type) && !glsl_type_contains_image(this->type))
|
||||
return false;
|
||||
|
||||
return this->data.bindless || this->data.mode != ir_var_uniform;
|
||||
@@ -531,7 +531,7 @@ public:
|
||||
|
||||
enum glsl_interface_packing get_interface_type_packing() const
|
||||
{
|
||||
return this->interface_type->get_interface_packing();
|
||||
return glsl_get_ifc_packing(this->interface_type);
|
||||
}
|
||||
/**
|
||||
* Get the max_ifc_array_access pointer
|
||||
@@ -585,8 +585,8 @@ public:
|
||||
inline bool is_interpolation_flat() const
|
||||
{
|
||||
return this->data.interpolation == INTERP_MODE_FLAT ||
|
||||
this->type->contains_integer() ||
|
||||
this->type->contains_double();
|
||||
glsl_contains_integer(this->type) ||
|
||||
glsl_contains_double(this->type);
|
||||
}
|
||||
|
||||
inline bool is_name_ralloced() const
|
||||
|
||||
@@ -56,14 +56,14 @@ ir_array_refcount_visitor::~ir_array_refcount_visitor()
|
||||
ir_array_refcount_entry::ir_array_refcount_entry(ir_variable *var)
|
||||
: var(var), is_referenced(false)
|
||||
{
|
||||
num_bits = MAX2(1, var->type->arrays_of_arrays_size());
|
||||
num_bits = MAX2(1, glsl_get_aoa_size(var->type));
|
||||
bits = new BITSET_WORD[BITSET_WORDS(num_bits)];
|
||||
memset(bits, 0, BITSET_WORDS(num_bits) * sizeof(bits[0]));
|
||||
|
||||
/* Count the "depth" of the arrays-of-arrays. */
|
||||
array_depth = 0;
|
||||
for (const glsl_type *type = var->type;
|
||||
type->is_array();
|
||||
glsl_type_is_array(type);
|
||||
type = type->fields.array) {
|
||||
array_depth++;
|
||||
}
|
||||
@@ -116,7 +116,7 @@ ir_array_refcount_visitor::visit_enter(ir_dereference_array *ir)
|
||||
/* It could also be a vector or a matrix. Individual elements of vectors
|
||||
* are natrices are not tracked, so bail.
|
||||
*/
|
||||
if (!ir->array->type->is_array())
|
||||
if (!glsl_type_is_array(ir->array->type))
|
||||
return visit_continue;
|
||||
|
||||
/* If this array dereference is a child of an array dereference that was
|
||||
@@ -139,13 +139,13 @@ ir_array_refcount_visitor::visit_enter(ir_dereference_array *ir)
|
||||
ir_dereference_array *const deref = rv->as_dereference_array();
|
||||
|
||||
assert(deref != NULL);
|
||||
assert(deref->array->type->is_array());
|
||||
assert(glsl_type_is_array(deref->array->type));
|
||||
|
||||
ir_rvalue *const array = deref->array;
|
||||
const ir_constant *const idx = deref->array_index->as_constant();
|
||||
array_deref_range *const dr = get_array_deref();
|
||||
|
||||
dr->size = array->type->array_size();
|
||||
dr->size = glsl_array_size(array->type);
|
||||
|
||||
if (idx != NULL) {
|
||||
dr->index = idx->get_int_component(0);
|
||||
@@ -153,7 +153,7 @@ ir_array_refcount_visitor::visit_enter(ir_dereference_array *ir)
|
||||
/* An unsized array can occur at the end of an SSBO. We can't track
|
||||
* accesses to such an array, so bail.
|
||||
*/
|
||||
if (array->type->array_size() == 0)
|
||||
if (glsl_array_size(array->type) == 0)
|
||||
return visit_continue;
|
||||
|
||||
dr->index = dr->size;
|
||||
|
||||
@@ -313,7 +313,7 @@ ir_builder_print_visitor::visit_leave(ir_function_signature *ir)
|
||||
void
|
||||
ir_builder_print_visitor::print_without_declaration(const ir_constant *ir)
|
||||
{
|
||||
if (ir->type->is_scalar()) {
|
||||
if (glsl_type_is_scalar(ir->type)) {
|
||||
switch (ir->type->base_type) {
|
||||
case GLSL_TYPE_UINT:
|
||||
print_without_indent("body.constant(%uu)", ir->value.u[0]);
|
||||
|
||||
@@ -44,10 +44,10 @@
|
||||
static float
|
||||
dot_f(ir_constant *op0, ir_constant *op1)
|
||||
{
|
||||
assert(op0->type->is_float() && op1->type->is_float());
|
||||
assert(glsl_type_is_float(op0->type) && glsl_type_is_float(op1->type));
|
||||
|
||||
float result = 0;
|
||||
for (unsigned c = 0; c < op0->type->components(); c++)
|
||||
for (unsigned c = 0; c < glsl_get_components(op0->type); c++)
|
||||
result += op0->value.f[c] * op1->value.f[c];
|
||||
|
||||
return result;
|
||||
@@ -56,10 +56,10 @@ dot_f(ir_constant *op0, ir_constant *op1)
|
||||
static double
|
||||
dot_d(ir_constant *op0, ir_constant *op1)
|
||||
{
|
||||
assert(op0->type->is_double() && op1->type->is_double());
|
||||
assert(glsl_type_is_double(op0->type) && glsl_type_is_double(op1->type));
|
||||
|
||||
double result = 0;
|
||||
for (unsigned c = 0; c < op0->type->components(); c++)
|
||||
for (unsigned c = 0; c < glsl_get_components(op0->type); c++)
|
||||
result += op0->value.d[c] * op1->value.d[c];
|
||||
|
||||
return result;
|
||||
@@ -492,8 +492,8 @@ constant_referenced(const ir_dereference *deref,
|
||||
ir_constant *const index_c =
|
||||
da->array_index->constant_expression_value(variable_context);
|
||||
|
||||
if (!index_c || !index_c->type->is_scalar() ||
|
||||
!index_c->type->is_integer_32())
|
||||
if (!index_c || !glsl_type_is_scalar(index_c->type) ||
|
||||
!glsl_type_is_integer_32(index_c->type))
|
||||
break;
|
||||
|
||||
const int index = index_c->type->base_type == GLSL_TYPE_INT ?
|
||||
@@ -511,13 +511,13 @@ constant_referenced(const ir_dereference *deref,
|
||||
break;
|
||||
|
||||
const glsl_type *const vt = da->array->type;
|
||||
if (vt->is_array()) {
|
||||
if (glsl_type_is_array(vt)) {
|
||||
store = substore->get_array_element(index);
|
||||
offset = 0;
|
||||
} else if (vt->is_matrix()) {
|
||||
} else if (glsl_type_is_matrix(vt)) {
|
||||
store = substore;
|
||||
offset = index * vt->vector_elements;
|
||||
} else if (vt->is_vector()) {
|
||||
} else if (glsl_type_is_vector(vt)) {
|
||||
store = substore;
|
||||
offset = suboffset + index;
|
||||
}
|
||||
@@ -569,7 +569,7 @@ constant_referenced(const ir_dereference *deref,
|
||||
ir_constant *
|
||||
ir_rvalue::constant_expression_value(void *, struct hash_table *)
|
||||
{
|
||||
assert(this->type->is_error());
|
||||
assert(glsl_type_is_error(this->type));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -691,7 +691,7 @@ ir_expression::constant_expression_value(void *mem_ctx,
|
||||
{
|
||||
assert(mem_ctx);
|
||||
|
||||
if (this->type->is_error())
|
||||
if (glsl_type_is_error(this->type))
|
||||
return NULL;
|
||||
|
||||
const glsl_type *return_type = this->type;
|
||||
@@ -712,11 +712,12 @@ ir_expression::constant_expression_value(void *mem_ctx,
|
||||
switch (op[operand]->type->base_type) {
|
||||
case GLSL_TYPE_FLOAT16: {
|
||||
const struct glsl_type *float_type =
|
||||
glsl_type::get_instance(GLSL_TYPE_FLOAT,
|
||||
op[operand]->type->vector_elements,
|
||||
op[operand]->type->matrix_columns,
|
||||
op[operand]->type->explicit_stride,
|
||||
op[operand]->type->interface_row_major);
|
||||
glsl_simple_explicit_type(GLSL_TYPE_FLOAT,
|
||||
op[operand]->type->vector_elements,
|
||||
op[operand]->type->matrix_columns,
|
||||
op[operand]->type->explicit_stride,
|
||||
op[operand]->type->interface_row_major,
|
||||
0 /* explicit_alignment */);
|
||||
|
||||
ir_constant_data f;
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(f.f); i++)
|
||||
@@ -727,11 +728,12 @@ ir_expression::constant_expression_value(void *mem_ctx,
|
||||
}
|
||||
case GLSL_TYPE_INT16: {
|
||||
const struct glsl_type *int_type =
|
||||
glsl_type::get_instance(GLSL_TYPE_INT,
|
||||
op[operand]->type->vector_elements,
|
||||
op[operand]->type->matrix_columns,
|
||||
op[operand]->type->explicit_stride,
|
||||
op[operand]->type->interface_row_major);
|
||||
glsl_simple_explicit_type(GLSL_TYPE_INT,
|
||||
op[operand]->type->vector_elements,
|
||||
op[operand]->type->matrix_columns,
|
||||
op[operand]->type->explicit_stride,
|
||||
op[operand]->type->interface_row_major,
|
||||
0 /* explicit_alignment */);
|
||||
|
||||
ir_constant_data d;
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(d.i); i++)
|
||||
@@ -742,11 +744,12 @@ ir_expression::constant_expression_value(void *mem_ctx,
|
||||
}
|
||||
case GLSL_TYPE_UINT16: {
|
||||
const struct glsl_type *uint_type =
|
||||
glsl_type::get_instance(GLSL_TYPE_UINT,
|
||||
op[operand]->type->vector_elements,
|
||||
op[operand]->type->matrix_columns,
|
||||
op[operand]->type->explicit_stride,
|
||||
op[operand]->type->interface_row_major);
|
||||
glsl_simple_explicit_type(GLSL_TYPE_UINT,
|
||||
op[operand]->type->vector_elements,
|
||||
op[operand]->type->matrix_columns,
|
||||
op[operand]->type->explicit_stride,
|
||||
op[operand]->type->interface_row_major,
|
||||
0 /* explicit_alignment */);
|
||||
|
||||
ir_constant_data d;
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(d.u); i++)
|
||||
@@ -763,25 +766,28 @@ ir_expression::constant_expression_value(void *mem_ctx,
|
||||
|
||||
switch (return_type->base_type) {
|
||||
case GLSL_TYPE_FLOAT16:
|
||||
return_type = glsl_type::get_instance(GLSL_TYPE_FLOAT,
|
||||
return_type->vector_elements,
|
||||
return_type->matrix_columns,
|
||||
return_type->explicit_stride,
|
||||
return_type->interface_row_major);
|
||||
return_type = glsl_simple_explicit_type(GLSL_TYPE_FLOAT,
|
||||
return_type->vector_elements,
|
||||
return_type->matrix_columns,
|
||||
return_type->explicit_stride,
|
||||
return_type->interface_row_major,
|
||||
0 /* explicit_alignment */);
|
||||
break;
|
||||
case GLSL_TYPE_INT16:
|
||||
return_type = glsl_type::get_instance(GLSL_TYPE_INT,
|
||||
return_type->vector_elements,
|
||||
return_type->matrix_columns,
|
||||
return_type->explicit_stride,
|
||||
return_type->interface_row_major);
|
||||
return_type = glsl_simple_explicit_type(GLSL_TYPE_INT,
|
||||
return_type->vector_elements,
|
||||
return_type->matrix_columns,
|
||||
return_type->explicit_stride,
|
||||
return_type->interface_row_major,
|
||||
0 /* explicit_alignment */);
|
||||
break;
|
||||
case GLSL_TYPE_UINT16:
|
||||
return_type = glsl_type::get_instance(GLSL_TYPE_UINT,
|
||||
return_type->vector_elements,
|
||||
return_type->matrix_columns,
|
||||
return_type->explicit_stride,
|
||||
return_type->interface_row_major);
|
||||
return_type = glsl_simple_explicit_type(GLSL_TYPE_UINT,
|
||||
return_type->vector_elements,
|
||||
return_type->matrix_columns,
|
||||
return_type->explicit_stride,
|
||||
return_type->interface_row_major,
|
||||
0 /* explicit_alignment */);
|
||||
break;
|
||||
default:
|
||||
/* nothing to do */
|
||||
@@ -805,8 +811,8 @@ ir_expression::constant_expression_value(void *mem_ctx,
|
||||
break;
|
||||
}
|
||||
|
||||
bool op0_scalar = op[0]->type->is_scalar();
|
||||
bool op1_scalar = op[1] != NULL && op[1]->type->is_scalar();
|
||||
bool op0_scalar = glsl_type_is_scalar(op[0]->type);
|
||||
bool op1_scalar = op[1] != NULL && glsl_type_is_scalar(op[1]->type);
|
||||
|
||||
/* When iterating over a vector or matrix's components, we want to increase
|
||||
* the loop counter. However, for scalars, we want to stay at 0.
|
||||
@@ -815,14 +821,14 @@ ir_expression::constant_expression_value(void *mem_ctx,
|
||||
unsigned c1_inc = op1_scalar ? 0 : 1;
|
||||
unsigned components;
|
||||
if (op1_scalar || !op[1]) {
|
||||
components = op[0]->type->components();
|
||||
components = glsl_get_components(op[0]->type);
|
||||
} else {
|
||||
components = op[1]->type->components();
|
||||
components = glsl_get_components(op[1]->type);
|
||||
}
|
||||
|
||||
/* Handle array operations here, rather than below. */
|
||||
if (op[0]->type->is_array()) {
|
||||
assert(op[1] != NULL && op[1]->type->is_array());
|
||||
if (glsl_type_is_array(op[0]->type)) {
|
||||
assert(op[1] != NULL && glsl_type_is_array(op[1]->type));
|
||||
switch (this->operation) {
|
||||
case ir_binop_all_equal:
|
||||
return new(mem_ctx) ir_constant(op[0]->has_value(op[1]));
|
||||
@@ -948,12 +954,12 @@ ir_dereference_array::constant_expression_value(void *mem_ctx,
|
||||
ir_constant *idx = this->array_index->constant_expression_value(mem_ctx, variable_context);
|
||||
|
||||
if ((array != NULL) && (idx != NULL)) {
|
||||
if (array->type->is_matrix()) {
|
||||
if (glsl_type_is_matrix(array->type)) {
|
||||
/* Array access of a matrix results in a vector.
|
||||
*/
|
||||
const unsigned column = idx->value.u[0];
|
||||
|
||||
const glsl_type *const column_type = array->type->column_type();
|
||||
const glsl_type *const column_type = glsl_get_column_type(array->type);
|
||||
|
||||
/* Section 5.11 (Out-of-Bounds Accesses) of the GLSL 4.60 spec says:
|
||||
*
|
||||
@@ -999,11 +1005,11 @@ ir_dereference_array::constant_expression_value(void *mem_ctx,
|
||||
}
|
||||
|
||||
return new(mem_ctx) ir_constant(column_type, &data);
|
||||
} else if (array->type->is_vector()) {
|
||||
} else if (glsl_type_is_vector(array->type)) {
|
||||
const unsigned component = idx->value.u[0];
|
||||
|
||||
return new(mem_ctx) ir_constant(array, component);
|
||||
} else if (array->type->is_array()) {
|
||||
} else if (glsl_type_is_array(array->type)) {
|
||||
const unsigned index = idx->value.u[0];
|
||||
return array->get_array_element(index)->clone(mem_ctx, NULL);
|
||||
}
|
||||
@@ -1129,7 +1135,7 @@ bool ir_function_signature::constant_expression_evaluate_expression_list(void *m
|
||||
ir_constant *cond =
|
||||
iif->condition->constant_expression_value(mem_ctx,
|
||||
variable_context);
|
||||
if (!cond || !cond->type->is_boolean())
|
||||
if (!cond || !glsl_type_is_boolean(cond->type))
|
||||
return false;
|
||||
|
||||
exec_list &branch = cond->get_bool_component(0) ? iif->then_instructions : iif->else_instructions;
|
||||
|
||||
@@ -57,8 +57,8 @@ ir_constant::equals(const ir_instruction *ir, enum ir_node_type) const
|
||||
if (type != other->type)
|
||||
return false;
|
||||
|
||||
for (unsigned i = 0; i < type->components(); i++) {
|
||||
if (type->is_double()) {
|
||||
for (unsigned i = 0; i < glsl_get_components(type); i++) {
|
||||
if (glsl_type_is_double(type)) {
|
||||
if (value.d[i] != other->value.d[i])
|
||||
return false;
|
||||
} else {
|
||||
|
||||
@@ -99,7 +99,7 @@ real_types = (float_type, double_type)
|
||||
# This is used by most operations.
|
||||
constant_template_common = mako.template.Template("""\
|
||||
case ${op.get_enum_name()}:
|
||||
for (unsigned c = 0; c < op[0]->type->components(); c++) {
|
||||
for (unsigned c = 0; c < glsl_get_components(op[0]->type); c++) {
|
||||
switch (op[0]->type->base_type) {
|
||||
% for dst_type, src_types in op.signatures():
|
||||
case ${src_types[0].glsl_type}:
|
||||
@@ -173,7 +173,7 @@ constant_template_vector_scalar_mixed = mako.template.Template("""\
|
||||
constant_template_mul = mako.template.Template("""\
|
||||
case ${op.get_enum_name()}:
|
||||
/* Check for equal types, or unequal types involving scalars */
|
||||
if ((op[0]->type == op[1]->type && !op[0]->type->is_matrix())
|
||||
if ((op[0]->type == op[1]->type && !glsl_type_is_matrix(op[0]->type))
|
||||
|| op0_scalar || op1_scalar) {
|
||||
for (unsigned c = 0, c0 = 0, c1 = 0;
|
||||
c < components;
|
||||
@@ -190,7 +190,7 @@ constant_template_mul = mako.template.Template("""\
|
||||
}
|
||||
}
|
||||
} else {
|
||||
assert(op[0]->type->is_matrix() || op[1]->type->is_matrix());
|
||||
assert(glsl_type_is_matrix(op[0]->type) || glsl_type_is_matrix(op[1]->type));
|
||||
|
||||
/* Multiply an N-by-M matrix with an M-by-P matrix. Since either
|
||||
* matrix can be a GLSL vector, either N or P can be 1.
|
||||
@@ -201,14 +201,14 @@ constant_template_mul = mako.template.Template("""\
|
||||
* For mat*vec, the vector is treated as a column vector. Since
|
||||
* matrix_columns is 1 for vectors, this just works.
|
||||
*/
|
||||
const unsigned n = op[0]->type->is_vector()
|
||||
const unsigned n = glsl_type_is_vector(op[0]->type)
|
||||
? 1 : op[0]->type->vector_elements;
|
||||
const unsigned m = op[1]->type->vector_elements;
|
||||
const unsigned p = op[1]->type->matrix_columns;
|
||||
for (unsigned j = 0; j < p; j++) {
|
||||
for (unsigned i = 0; i < n; i++) {
|
||||
for (unsigned k = 0; k < m; k++) {
|
||||
if (op[0]->type->is_double())
|
||||
if (glsl_type_is_double(op[0]->type))
|
||||
data.d[i+n*j] += op[0]->value.d[i+n*k]*op[1]->value.d[k+m*j];
|
||||
else
|
||||
data.f[i+n*j] += op[0]->value.f[i+n*k]*op[1]->value.f[k+m*j];
|
||||
@@ -304,11 +304,11 @@ constant_template_vector = mako.template.Template("""\
|
||||
# This template is for ir_triop_lrp.
|
||||
constant_template_lrp = mako.template.Template("""\
|
||||
case ${op.get_enum_name()}: {
|
||||
assert(op[0]->type->is_float() || op[0]->type->is_double());
|
||||
assert(op[1]->type->is_float() || op[1]->type->is_double());
|
||||
assert(op[2]->type->is_float() || op[2]->type->is_double());
|
||||
assert(glsl_type_is_float(op[0]->type) || glsl_type_is_double(op[0]->type));
|
||||
assert(glsl_type_is_float(op[1]->type) || glsl_type_is_double(op[1]->type));
|
||||
assert(glsl_type_is_float(op[2]->type) || glsl_type_is_double(op[2]->type));
|
||||
|
||||
unsigned c2_inc = op[2]->type->is_scalar() ? 0 : 1;
|
||||
unsigned c2_inc = glsl_type_is_scalar(op[2]->type) ? 0 : 1;
|
||||
for (unsigned c = 0, c2 = 0; c < components; c2 += c2_inc, c++) {
|
||||
switch (return_type->base_type) {
|
||||
% for dst_type, src_types in op.signatures():
|
||||
|
||||
@@ -150,13 +150,13 @@ get_parameter_match_type(const ir_variable *param,
|
||||
if (from_type == to_type)
|
||||
return PARAMETER_EXACT_MATCH;
|
||||
|
||||
if (to_type->is_double()) {
|
||||
if (from_type->is_float())
|
||||
if (glsl_type_is_double(to_type)) {
|
||||
if (glsl_type_is_float(from_type))
|
||||
return PARAMETER_FLOAT_TO_DOUBLE;
|
||||
return PARAMETER_INT_TO_DOUBLE;
|
||||
}
|
||||
|
||||
if (to_type->is_float())
|
||||
if (glsl_type_is_float(to_type))
|
||||
return PARAMETER_INT_TO_FLOAT;
|
||||
|
||||
/* int -> uint and any other oddball conversions */
|
||||
|
||||
@@ -49,11 +49,11 @@ ir_instruction::fprint(FILE *f) const
|
||||
static void
|
||||
glsl_print_type(FILE *f, const glsl_type *t)
|
||||
{
|
||||
if (t->is_array()) {
|
||||
if (glsl_type_is_array(t)) {
|
||||
fprintf(f, "(array ");
|
||||
glsl_print_type(f, t->fields.array);
|
||||
fprintf(f, " %u)", t->length);
|
||||
} else if (t->is_struct() && !is_gl_identifier(glsl_get_type_name(t))) {
|
||||
} else if (glsl_type_is_struct(t) && !is_gl_identifier(glsl_get_type_name(t))) {
|
||||
fprintf(f, "%s@%p", glsl_get_type_name(t), (void *) t);
|
||||
} else {
|
||||
fprintf(f, "%s", glsl_get_type_name(t));
|
||||
@@ -500,17 +500,17 @@ void ir_print_visitor::visit(ir_constant *ir)
|
||||
glsl_print_type(f, ir->type);
|
||||
fprintf(f, " (");
|
||||
|
||||
if (ir->type->is_array()) {
|
||||
if (glsl_type_is_array(ir->type)) {
|
||||
for (unsigned i = 0; i < ir->type->length; i++)
|
||||
ir->get_array_element(i)->accept(this);
|
||||
} else if (ir->type->is_struct()) {
|
||||
} else if (glsl_type_is_struct(ir->type)) {
|
||||
for (unsigned i = 0; i < ir->type->length; i++) {
|
||||
fprintf(f, "(%s ", ir->type->fields.structure[i].name);
|
||||
ir->get_record_field(i)->accept(this);
|
||||
fprintf(f, ")");
|
||||
}
|
||||
} else {
|
||||
for (unsigned i = 0; i < ir->type->components(); i++) {
|
||||
for (unsigned i = 0; i < glsl_get_components(ir->type); i++) {
|
||||
if (i != 0)
|
||||
fprintf(f, " ");
|
||||
switch (ir->type->base_type) {
|
||||
|
||||
@@ -145,7 +145,7 @@ ir_reader::read_type(s_expression *expr)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return glsl_type::get_array_instance(base_type, s_size->value());
|
||||
return glsl_array_type(base_type, s_size->value(), 0);
|
||||
}
|
||||
|
||||
s_symbol *type_sym = SX_AS_SYMBOL(expr);
|
||||
@@ -638,7 +638,7 @@ ir_reader::read_assignment(s_expression *expr)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (mask == 0 && (lhs->type->is_vector() || lhs->type->is_scalar())) {
|
||||
if (mask == 0 && (glsl_type_is_vector(lhs->type) || glsl_type_is_scalar(lhs->type))) {
|
||||
ir_read_error(expr, "non-zero write mask required.");
|
||||
return NULL;
|
||||
}
|
||||
@@ -806,7 +806,7 @@ ir_reader::read_constant(s_expression *expr)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (type->is_array()) {
|
||||
if (glsl_type_is_array(type)) {
|
||||
unsigned elements_supplied = 0;
|
||||
exec_list elements;
|
||||
foreach_in_list(s_expression, elt, &values->subexpressions) {
|
||||
@@ -835,7 +835,7 @@ ir_reader::read_constant(s_expression *expr)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (type->is_float()) {
|
||||
if (glsl_type_is_float(type)) {
|
||||
s_number *value = SX_AS_NUMBER(expr);
|
||||
if (value == NULL) {
|
||||
ir_read_error(values, "expected numbers");
|
||||
@@ -869,9 +869,9 @@ ir_reader::read_constant(s_expression *expr)
|
||||
}
|
||||
++k;
|
||||
}
|
||||
if (k != type->components()) {
|
||||
if (k != glsl_get_components(type)) {
|
||||
ir_read_error(values, "expected %u constant values, found %u",
|
||||
type->components(), k);
|
||||
glsl_get_components(type), k);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1031,7 +1031,7 @@ ir_reader::read_texture(s_expression *expr)
|
||||
}
|
||||
|
||||
if (is_sparse) {
|
||||
const glsl_type *texel = type->field_type("texel");
|
||||
const glsl_type *texel = glsl_get_field_type(type, "texel");
|
||||
if (texel == &glsl_type_builtin_error) {
|
||||
ir_read_error(NULL, "invalid type for sparse texture");
|
||||
return NULL;
|
||||
|
||||
+159
-159
@@ -102,7 +102,7 @@ ir_validate::visit(ir_dereference_variable *ir)
|
||||
/* Compare types without arrays, because one side can be sized and
|
||||
* the other unsized.
|
||||
*/
|
||||
if (ir->var->type->without_array() != ir->type->without_array()) {
|
||||
if (glsl_without_array(ir->var->type) != glsl_without_array(ir->type)) {
|
||||
printf("ir_dereference_variable type is not equal to variable type: ");
|
||||
ir->print();
|
||||
printf("\n");
|
||||
@@ -124,8 +124,8 @@ ir_validate::visit(ir_dereference_variable *ir)
|
||||
ir_visitor_status
|
||||
ir_validate::visit_enter(class ir_dereference_array *ir)
|
||||
{
|
||||
if (!ir->array->type->is_array() && !ir->array->type->is_matrix() &&
|
||||
!ir->array->type->is_vector()) {
|
||||
if (!glsl_type_is_array(ir->array->type) && !glsl_type_is_matrix(ir->array->type) &&
|
||||
!glsl_type_is_vector(ir->array->type)) {
|
||||
printf("ir_dereference_array @ %p does not specify an array, a vector "
|
||||
"or a matrix\n",
|
||||
(void *) ir);
|
||||
@@ -134,7 +134,7 @@ ir_validate::visit_enter(class ir_dereference_array *ir)
|
||||
abort();
|
||||
}
|
||||
|
||||
if (ir->array->type->is_array()) {
|
||||
if (glsl_type_is_array(ir->array->type)) {
|
||||
if (ir->array->type->fields.array != ir->type) {
|
||||
printf("ir_dereference_array type is not equal to the array "
|
||||
"element type: ");
|
||||
@@ -149,13 +149,13 @@ ir_validate::visit_enter(class ir_dereference_array *ir)
|
||||
abort();
|
||||
}
|
||||
|
||||
if (!ir->array_index->type->is_scalar()) {
|
||||
if (!glsl_type_is_scalar(ir->array_index->type)) {
|
||||
printf("ir_dereference_array @ %p does not have scalar index: %s\n",
|
||||
(void *) ir, glsl_get_type_name(ir->array_index->type));
|
||||
abort();
|
||||
}
|
||||
|
||||
if (!ir->array_index->type->is_integer_16_32()) {
|
||||
if (!glsl_type_is_integer_16_32(ir->array_index->type)) {
|
||||
printf("ir_dereference_array @ %p does not have integer index: %s\n",
|
||||
(void *) ir, glsl_get_type_name(ir->array_index->type));
|
||||
abort();
|
||||
@@ -167,7 +167,7 @@ ir_validate::visit_enter(class ir_dereference_array *ir)
|
||||
ir_visitor_status
|
||||
ir_validate::visit_enter(class ir_dereference_record *ir)
|
||||
{
|
||||
if (!ir->record->type->is_struct() && !ir->record->type->is_interface()) {
|
||||
if (!glsl_type_is_struct(ir->record->type) && !glsl_type_is_interface(ir->record->type)) {
|
||||
printf("ir_dereference_record @ %p does not specify a record\n",
|
||||
(void *) ir);
|
||||
ir->print();
|
||||
@@ -311,8 +311,8 @@ ir_validate::visit_leave(ir_expression *ir)
|
||||
assert(ir->operands[0]->type == ir->type);
|
||||
break;
|
||||
case ir_unop_logic_not:
|
||||
assert(ir->type->is_boolean());
|
||||
assert(ir->operands[0]->type->is_boolean());
|
||||
assert(glsl_type_is_boolean(ir->type));
|
||||
assert(glsl_type_is_boolean(ir->operands[0]->type));
|
||||
break;
|
||||
|
||||
case ir_unop_neg:
|
||||
@@ -321,15 +321,15 @@ ir_validate::visit_leave(ir_expression *ir)
|
||||
|
||||
case ir_unop_abs:
|
||||
case ir_unop_sign:
|
||||
assert(ir->operands[0]->type->is_int_16_32_64() ||
|
||||
ir->operands[0]->type->is_float_16_32_64());
|
||||
assert(glsl_type_is_int_16_32_64(ir->operands[0]->type) ||
|
||||
glsl_type_is_float_16_32_64(ir->operands[0]->type));
|
||||
assert(ir->type == ir->operands[0]->type);
|
||||
break;
|
||||
|
||||
case ir_unop_rcp:
|
||||
case ir_unop_rsq:
|
||||
case ir_unop_sqrt:
|
||||
assert(ir->type->is_float_16_32_64());
|
||||
assert(glsl_type_is_float_16_32_64(ir->type));
|
||||
assert(ir->type == ir->operands[0]->type);
|
||||
break;
|
||||
|
||||
@@ -338,58 +338,58 @@ ir_validate::visit_leave(ir_expression *ir)
|
||||
case ir_unop_exp2:
|
||||
case ir_unop_log2:
|
||||
case ir_unop_saturate:
|
||||
assert(ir->operands[0]->type->is_float_16_32());
|
||||
assert(glsl_type_is_float_16_32(ir->operands[0]->type));
|
||||
assert(ir->type == ir->operands[0]->type);
|
||||
break;
|
||||
|
||||
case ir_unop_f2i:
|
||||
assert(ir->operands[0]->type->is_float_16_32());
|
||||
assert(ir->type->is_int_16_32());
|
||||
assert(glsl_type_is_float_16_32(ir->operands[0]->type));
|
||||
assert(glsl_type_is_int_16_32(ir->type));
|
||||
break;
|
||||
case ir_unop_f2u:
|
||||
assert(ir->operands[0]->type->is_float_16_32());
|
||||
assert(ir->type->is_uint_16_32());
|
||||
assert(glsl_type_is_float_16_32(ir->operands[0]->type));
|
||||
assert(glsl_type_is_uint_16_32(ir->type));
|
||||
break;
|
||||
case ir_unop_i2f:
|
||||
assert(ir->operands[0]->type->is_int_16_32());
|
||||
assert(ir->type->is_float_16_32());
|
||||
assert(glsl_type_is_int_16_32(ir->operands[0]->type));
|
||||
assert(glsl_type_is_float_16_32(ir->type));
|
||||
break;
|
||||
case ir_unop_f2b:
|
||||
assert(ir->operands[0]->type->is_float_16_32());
|
||||
assert(ir->type->is_boolean());
|
||||
assert(glsl_type_is_float_16_32(ir->operands[0]->type));
|
||||
assert(glsl_type_is_boolean(ir->type));
|
||||
break;
|
||||
case ir_unop_f162b:
|
||||
assert(ir->operands[0]->type->base_type ==
|
||||
GLSL_TYPE_FLOAT16);
|
||||
assert(ir->type->is_boolean());
|
||||
assert(glsl_type_is_boolean(ir->type));
|
||||
break;
|
||||
case ir_unop_b2f:
|
||||
assert(ir->operands[0]->type->is_boolean());
|
||||
assert(ir->type->is_float_16_32());
|
||||
assert(glsl_type_is_boolean(ir->operands[0]->type));
|
||||
assert(glsl_type_is_float_16_32(ir->type));
|
||||
break;
|
||||
case ir_unop_b2f16:
|
||||
assert(ir->operands[0]->type->is_boolean());
|
||||
assert(glsl_type_is_boolean(ir->operands[0]->type));
|
||||
assert(ir->type->base_type == GLSL_TYPE_FLOAT16);
|
||||
break;
|
||||
case ir_unop_i2b:
|
||||
assert(ir->operands[0]->type->is_int_16_32());
|
||||
assert(ir->type->is_boolean());
|
||||
assert(glsl_type_is_int_16_32(ir->operands[0]->type));
|
||||
assert(glsl_type_is_boolean(ir->type));
|
||||
break;
|
||||
case ir_unop_b2i:
|
||||
assert(ir->operands[0]->type->is_boolean());
|
||||
assert(ir->type->is_int_16_32());
|
||||
assert(glsl_type_is_boolean(ir->operands[0]->type));
|
||||
assert(glsl_type_is_int_16_32(ir->type));
|
||||
break;
|
||||
case ir_unop_u2f:
|
||||
assert(ir->operands[0]->type->is_uint_16_32());
|
||||
assert(ir->type->is_float_16_32());
|
||||
assert(glsl_type_is_uint_16_32(ir->operands[0]->type));
|
||||
assert(glsl_type_is_float_16_32(ir->type));
|
||||
break;
|
||||
case ir_unop_i2u:
|
||||
assert(ir->operands[0]->type->is_int_16_32());
|
||||
assert(ir->type->is_uint_16_32());
|
||||
assert(glsl_type_is_int_16_32(ir->operands[0]->type));
|
||||
assert(glsl_type_is_uint_16_32(ir->type));
|
||||
break;
|
||||
case ir_unop_u2i:
|
||||
assert(ir->operands[0]->type->is_uint_16_32());
|
||||
assert(ir->type->is_int_16_32());
|
||||
assert(glsl_type_is_uint_16_32(ir->operands[0]->type));
|
||||
assert(glsl_type_is_int_16_32(ir->type));
|
||||
break;
|
||||
case ir_unop_bitcast_i2f:
|
||||
assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT);
|
||||
@@ -410,90 +410,90 @@ ir_validate::visit_leave(ir_expression *ir)
|
||||
|
||||
case ir_unop_bitcast_u642d:
|
||||
assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT64);
|
||||
assert(ir->type->is_double());
|
||||
assert(glsl_type_is_double(ir->type));
|
||||
break;
|
||||
case ir_unop_bitcast_i642d:
|
||||
assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT64);
|
||||
assert(ir->type->is_double());
|
||||
assert(glsl_type_is_double(ir->type));
|
||||
break;
|
||||
case ir_unop_bitcast_d2u64:
|
||||
assert(ir->operands[0]->type->is_double());
|
||||
assert(glsl_type_is_double(ir->operands[0]->type));
|
||||
assert(ir->type->base_type == GLSL_TYPE_UINT64);
|
||||
break;
|
||||
case ir_unop_bitcast_d2i64:
|
||||
assert(ir->operands[0]->type->is_double());
|
||||
assert(glsl_type_is_double(ir->operands[0]->type));
|
||||
assert(ir->type->base_type == GLSL_TYPE_INT64);
|
||||
break;
|
||||
case ir_unop_i642i:
|
||||
assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT64);
|
||||
assert(ir->type->is_int_16_32());
|
||||
assert(glsl_type_is_int_16_32(ir->type));
|
||||
break;
|
||||
case ir_unop_u642i:
|
||||
assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT64);
|
||||
assert(ir->type->is_int_16_32());
|
||||
assert(glsl_type_is_int_16_32(ir->type));
|
||||
break;
|
||||
case ir_unop_i642u:
|
||||
assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT64);
|
||||
assert(ir->type->is_uint_16_32());
|
||||
assert(glsl_type_is_uint_16_32(ir->type));
|
||||
break;
|
||||
case ir_unop_u642u:
|
||||
assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT64);
|
||||
assert(ir->type->is_uint_16_32());
|
||||
assert(glsl_type_is_uint_16_32(ir->type));
|
||||
break;
|
||||
case ir_unop_i642b:
|
||||
assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT64);
|
||||
assert(ir->type->is_boolean());
|
||||
assert(glsl_type_is_boolean(ir->type));
|
||||
break;
|
||||
case ir_unop_i642f:
|
||||
assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT64);
|
||||
assert(ir->type->is_float());
|
||||
assert(glsl_type_is_float(ir->type));
|
||||
break;
|
||||
case ir_unop_u642f:
|
||||
assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT64);
|
||||
assert(ir->type->is_float());
|
||||
assert(glsl_type_is_float(ir->type));
|
||||
break;
|
||||
case ir_unop_i642d:
|
||||
assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT64);
|
||||
assert(ir->type->is_double());
|
||||
assert(glsl_type_is_double(ir->type));
|
||||
break;
|
||||
case ir_unop_u642d:
|
||||
assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT64);
|
||||
assert(ir->type->is_double());
|
||||
assert(glsl_type_is_double(ir->type));
|
||||
break;
|
||||
case ir_unop_i2i64:
|
||||
assert(ir->operands[0]->type->is_int_16_32());
|
||||
assert(glsl_type_is_int_16_32(ir->operands[0]->type));
|
||||
assert(ir->type->base_type == GLSL_TYPE_INT64);
|
||||
break;
|
||||
case ir_unop_u2i64:
|
||||
assert(ir->operands[0]->type->is_uint_16_32());
|
||||
assert(glsl_type_is_uint_16_32(ir->operands[0]->type));
|
||||
assert(ir->type->base_type == GLSL_TYPE_INT64);
|
||||
break;
|
||||
case ir_unop_b2i64:
|
||||
assert(ir->operands[0]->type->is_boolean());
|
||||
assert(glsl_type_is_boolean(ir->operands[0]->type));
|
||||
assert(ir->type->base_type == GLSL_TYPE_INT64);
|
||||
break;
|
||||
case ir_unop_f2i64:
|
||||
assert(ir->operands[0]->type->is_float());
|
||||
assert(glsl_type_is_float(ir->operands[0]->type));
|
||||
assert(ir->type->base_type == GLSL_TYPE_INT64);
|
||||
break;
|
||||
case ir_unop_d2i64:
|
||||
assert(ir->operands[0]->type->is_double());
|
||||
assert(glsl_type_is_double(ir->operands[0]->type));
|
||||
assert(ir->type->base_type == GLSL_TYPE_INT64);
|
||||
break;
|
||||
case ir_unop_i2u64:
|
||||
assert(ir->operands[0]->type->is_int_16_32());
|
||||
assert(glsl_type_is_int_16_32(ir->operands[0]->type));
|
||||
assert(ir->type->base_type == GLSL_TYPE_UINT64);
|
||||
break;
|
||||
case ir_unop_u2u64:
|
||||
assert(ir->operands[0]->type->is_uint_16_32());
|
||||
assert(glsl_type_is_uint_16_32(ir->operands[0]->type));
|
||||
assert(ir->type->base_type == GLSL_TYPE_UINT64);
|
||||
break;
|
||||
case ir_unop_f2u64:
|
||||
assert(ir->operands[0]->type->is_float());
|
||||
assert(glsl_type_is_float(ir->operands[0]->type));
|
||||
assert(ir->type->base_type == GLSL_TYPE_UINT64);
|
||||
break;
|
||||
case ir_unop_d2u64:
|
||||
assert(ir->operands[0]->type->is_double());
|
||||
assert(glsl_type_is_double(ir->operands[0]->type));
|
||||
assert(ir->type->base_type == GLSL_TYPE_UINT64);
|
||||
break;
|
||||
case ir_unop_u642i64:
|
||||
@@ -509,7 +509,7 @@ ir_validate::visit_leave(ir_expression *ir)
|
||||
case ir_unop_ceil:
|
||||
case ir_unop_floor:
|
||||
case ir_unop_fract:
|
||||
assert(ir->operands[0]->type->is_float_16_32_64());
|
||||
assert(glsl_type_is_float_16_32_64(ir->operands[0]->type));
|
||||
assert(ir->operands[0]->type == ir->type);
|
||||
break;
|
||||
case ir_unop_sin:
|
||||
@@ -520,7 +520,7 @@ ir_validate::visit_leave(ir_expression *ir)
|
||||
case ir_unop_dFdy:
|
||||
case ir_unop_dFdy_coarse:
|
||||
case ir_unop_dFdy_fine:
|
||||
assert(ir->operands[0]->type->is_float_16_32());
|
||||
assert(glsl_type_is_float_16_32(ir->operands[0]->type));
|
||||
assert(ir->operands[0]->type == ir->type);
|
||||
break;
|
||||
|
||||
@@ -553,12 +553,12 @@ ir_validate::visit_leave(ir_expression *ir)
|
||||
break;
|
||||
|
||||
case ir_unop_pack_sampler_2x32:
|
||||
assert(ir->type->is_sampler());
|
||||
assert(glsl_type_is_sampler(ir->type));
|
||||
assert(ir->operands[0]->type == &glsl_type_builtin_uvec2);
|
||||
break;
|
||||
|
||||
case ir_unop_pack_image_2x32:
|
||||
assert(ir->type->is_image());
|
||||
assert(glsl_type_is_image(ir->type));
|
||||
assert(ir->operands[0]->type == &glsl_type_builtin_uvec2);
|
||||
break;
|
||||
|
||||
@@ -592,35 +592,35 @@ ir_validate::visit_leave(ir_expression *ir)
|
||||
|
||||
case ir_unop_unpack_sampler_2x32:
|
||||
assert(ir->type == &glsl_type_builtin_uvec2);
|
||||
assert(ir->operands[0]->type->is_sampler());
|
||||
assert(glsl_type_is_sampler(ir->operands[0]->type));
|
||||
break;
|
||||
|
||||
case ir_unop_unpack_image_2x32:
|
||||
assert(ir->type == &glsl_type_builtin_uvec2);
|
||||
assert(ir->operands[0]->type->is_image());
|
||||
assert(glsl_type_is_image(ir->operands[0]->type));
|
||||
break;
|
||||
|
||||
case ir_unop_bitfield_reverse:
|
||||
assert(ir->operands[0]->type == ir->type);
|
||||
assert(ir->type->is_integer_32());
|
||||
assert(glsl_type_is_integer_32(ir->type));
|
||||
break;
|
||||
|
||||
case ir_unop_bit_count:
|
||||
case ir_unop_find_msb:
|
||||
case ir_unop_find_lsb:
|
||||
assert(ir->operands[0]->type->vector_elements == ir->type->vector_elements);
|
||||
assert(ir->operands[0]->type->is_integer_16_32());
|
||||
assert(ir->type->is_int_16_32());
|
||||
assert(glsl_type_is_integer_16_32(ir->operands[0]->type));
|
||||
assert(glsl_type_is_int_16_32(ir->type));
|
||||
break;
|
||||
|
||||
case ir_unop_clz:
|
||||
assert(ir->operands[0]->type == ir->type);
|
||||
assert(ir->type->is_uint_16_32());
|
||||
assert(glsl_type_is_uint_16_32(ir->type));
|
||||
break;
|
||||
|
||||
case ir_unop_interpolate_at_centroid:
|
||||
assert(ir->operands[0]->type == ir->type);
|
||||
assert(ir->operands[0]->type->is_float_16_32());
|
||||
assert(glsl_type_is_float_16_32(ir->operands[0]->type));
|
||||
break;
|
||||
|
||||
case ir_unop_get_buffer_size:
|
||||
@@ -630,40 +630,40 @@ ir_validate::visit_leave(ir_expression *ir)
|
||||
|
||||
case ir_unop_ssbo_unsized_array_length:
|
||||
assert(ir->type == &glsl_type_builtin_int);
|
||||
assert(ir->operands[0]->type->is_array());
|
||||
assert(ir->operands[0]->type->is_unsized_array());
|
||||
assert(glsl_type_is_array(ir->operands[0]->type));
|
||||
assert(glsl_type_is_unsized_array(ir->operands[0]->type));
|
||||
break;
|
||||
|
||||
case ir_unop_implicitly_sized_array_length:
|
||||
assert(ir->type == &glsl_type_builtin_int);
|
||||
assert(ir->operands[0]->type->is_array());
|
||||
assert(glsl_type_is_array(ir->operands[0]->type));
|
||||
break;
|
||||
|
||||
case ir_unop_d2f:
|
||||
assert(ir->operands[0]->type->is_double());
|
||||
assert(ir->type->is_float());
|
||||
assert(glsl_type_is_double(ir->operands[0]->type));
|
||||
assert(glsl_type_is_float(ir->type));
|
||||
break;
|
||||
case ir_unop_f2d:
|
||||
assert(ir->operands[0]->type->is_float());
|
||||
assert(ir->type->is_double());
|
||||
assert(glsl_type_is_float(ir->operands[0]->type));
|
||||
assert(glsl_type_is_double(ir->type));
|
||||
break;
|
||||
case ir_unop_f162f:
|
||||
assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT16);
|
||||
assert(ir->type->is_float());
|
||||
assert(glsl_type_is_float(ir->type));
|
||||
break;
|
||||
case ir_unop_f2f16:
|
||||
case ir_unop_f2fmp:
|
||||
assert(ir->operands[0]->type->is_float());
|
||||
assert(glsl_type_is_float(ir->operands[0]->type));
|
||||
assert(ir->type->base_type == GLSL_TYPE_FLOAT16);
|
||||
break;
|
||||
case ir_unop_i2i:
|
||||
assert(ir->operands[0]->type->is_int_16_32());
|
||||
assert(ir->type->is_int_16_32());
|
||||
assert(glsl_type_is_int_16_32(ir->operands[0]->type));
|
||||
assert(glsl_type_is_int_16_32(ir->type));
|
||||
assert(ir->type->base_type != ir->operands[0]->type->base_type);
|
||||
break;
|
||||
case ir_unop_u2u:
|
||||
assert(ir->operands[0]->type->is_uint_16_32());
|
||||
assert(ir->type->is_uint_16_32());
|
||||
assert(glsl_type_is_uint_16_32(ir->operands[0]->type));
|
||||
assert(glsl_type_is_uint_16_32(ir->type));
|
||||
assert(ir->type->base_type != ir->operands[0]->type->base_type);
|
||||
break;
|
||||
case ir_unop_i2imp:
|
||||
@@ -675,31 +675,31 @@ ir_validate::visit_leave(ir_expression *ir)
|
||||
assert(ir->type->base_type == GLSL_TYPE_UINT16);
|
||||
break;
|
||||
case ir_unop_d2i:
|
||||
assert(ir->operands[0]->type->is_double());
|
||||
assert(ir->type->is_int_16_32());
|
||||
assert(glsl_type_is_double(ir->operands[0]->type));
|
||||
assert(glsl_type_is_int_16_32(ir->type));
|
||||
break;
|
||||
case ir_unop_i2d:
|
||||
assert(ir->operands[0]->type->is_int_16_32());
|
||||
assert(ir->type->is_double());
|
||||
assert(glsl_type_is_int_16_32(ir->operands[0]->type));
|
||||
assert(glsl_type_is_double(ir->type));
|
||||
break;
|
||||
case ir_unop_d2u:
|
||||
assert(ir->operands[0]->type->is_double());
|
||||
assert(ir->type->is_uint_16_32());
|
||||
assert(glsl_type_is_double(ir->operands[0]->type));
|
||||
assert(glsl_type_is_uint_16_32(ir->type));
|
||||
break;
|
||||
case ir_unop_u2d:
|
||||
assert(ir->operands[0]->type->is_uint_16_32());
|
||||
assert(ir->type->is_double());
|
||||
assert(glsl_type_is_uint_16_32(ir->operands[0]->type));
|
||||
assert(glsl_type_is_double(ir->type));
|
||||
break;
|
||||
case ir_unop_d2b:
|
||||
assert(ir->operands[0]->type->is_double());
|
||||
assert(ir->type->is_boolean());
|
||||
assert(glsl_type_is_double(ir->operands[0]->type));
|
||||
assert(glsl_type_is_boolean(ir->type));
|
||||
break;
|
||||
|
||||
case ir_unop_frexp_sig:
|
||||
assert(ir->operands[0]->type->is_float_32_64());
|
||||
assert(glsl_type_is_float_32_64(ir->operands[0]->type));
|
||||
break;
|
||||
case ir_unop_frexp_exp:
|
||||
assert(ir->operands[0]->type->is_float_32_64());
|
||||
assert(glsl_type_is_float_32_64(ir->operands[0]->type));
|
||||
assert(ir->type->base_type == GLSL_TYPE_INT);
|
||||
break;
|
||||
case ir_unop_subroutine_to_int:
|
||||
@@ -708,7 +708,7 @@ ir_validate::visit_leave(ir_expression *ir)
|
||||
break;
|
||||
|
||||
case ir_unop_atan:
|
||||
assert(ir->operands[0]->type->is_float_16_32_64());
|
||||
assert(glsl_type_is_float_16_32_64(ir->operands[0]->type));
|
||||
assert(ir->type == ir->operands[0]->type);
|
||||
break;
|
||||
|
||||
@@ -726,20 +726,20 @@ ir_validate::visit_leave(ir_expression *ir)
|
||||
if (ir->operation == ir_binop_mul &&
|
||||
(ir->type->base_type == GLSL_TYPE_UINT64 ||
|
||||
ir->type->base_type == GLSL_TYPE_INT64) &&
|
||||
(ir->operands[0]->type->is_int_16_32()||
|
||||
ir->operands[1]->type->is_int_16_32()||
|
||||
ir->operands[0]->type->is_uint_16_32() ||
|
||||
ir->operands[1]->type->is_uint_16_32())) {
|
||||
(glsl_type_is_int_16_32(ir->operands[0]->type)||
|
||||
glsl_type_is_int_16_32(ir->operands[1]->type)||
|
||||
glsl_type_is_uint_16_32(ir->operands[0]->type) ||
|
||||
glsl_type_is_uint_16_32(ir->operands[1]->type))) {
|
||||
assert(ir->operands[0]->type == ir->operands[1]->type);
|
||||
break;
|
||||
}
|
||||
|
||||
if (ir->operands[0]->type->is_scalar())
|
||||
if (glsl_type_is_scalar(ir->operands[0]->type))
|
||||
assert(ir->operands[1]->type == ir->type);
|
||||
else if (ir->operands[1]->type->is_scalar())
|
||||
else if (glsl_type_is_scalar(ir->operands[1]->type))
|
||||
assert(ir->operands[0]->type == ir->type);
|
||||
else if (ir->operands[0]->type->is_vector() &&
|
||||
ir->operands[1]->type->is_vector()) {
|
||||
else if (glsl_type_is_vector(ir->operands[0]->type) &&
|
||||
glsl_type_is_vector(ir->operands[1]->type)) {
|
||||
assert(ir->operands[0]->type == ir->operands[1]->type);
|
||||
assert(ir->operands[0]->type == ir->type);
|
||||
}
|
||||
@@ -747,10 +747,10 @@ ir_validate::visit_leave(ir_expression *ir)
|
||||
|
||||
case ir_binop_abs_sub:
|
||||
assert(ir->operands[0]->type == ir->operands[1]->type);
|
||||
assert(ir->operands[0]->type->is_integer_16_32_64());
|
||||
assert(glsl_type_is_integer_16_32_64(ir->operands[0]->type));
|
||||
assert(ir->operands[0]->type->vector_elements ==
|
||||
ir->type->vector_elements);
|
||||
assert(ir->type->is_uint_16_32_64());
|
||||
assert(glsl_type_is_uint_16_32_64(ir->type));
|
||||
break;
|
||||
|
||||
case ir_binop_add_sat:
|
||||
@@ -759,14 +759,14 @@ ir_validate::visit_leave(ir_expression *ir)
|
||||
case ir_binop_avg_round:
|
||||
assert(ir->type == ir->operands[0]->type);
|
||||
assert(ir->type == ir->operands[1]->type);
|
||||
assert(ir->type->is_integer_16_32_64());
|
||||
assert(glsl_type_is_integer_16_32_64(ir->type));
|
||||
break;
|
||||
|
||||
case ir_binop_mul_32x16:
|
||||
case ir_binop_imul_high:
|
||||
assert(ir->type == ir->operands[0]->type);
|
||||
assert(ir->type == ir->operands[1]->type);
|
||||
assert(ir->type->is_integer_32());
|
||||
assert(glsl_type_is_integer_32(ir->type));
|
||||
break;
|
||||
|
||||
case ir_binop_carry:
|
||||
@@ -785,10 +785,10 @@ ir_validate::visit_leave(ir_expression *ir)
|
||||
* comparison on scalar or vector types and return a boolean scalar or
|
||||
* vector type of the same size.
|
||||
*/
|
||||
assert(ir->type->is_boolean());
|
||||
assert(glsl_type_is_boolean(ir->type));
|
||||
assert(ir->operands[0]->type == ir->operands[1]->type);
|
||||
assert(ir->operands[0]->type->is_vector()
|
||||
|| ir->operands[0]->type->is_scalar());
|
||||
assert(glsl_type_is_vector(ir->operands[0]->type)
|
||||
|| glsl_type_is_scalar(ir->operands[0]->type));
|
||||
assert(ir->operands[0]->type->vector_elements
|
||||
== ir->type->vector_elements);
|
||||
break;
|
||||
@@ -804,15 +804,15 @@ ir_validate::visit_leave(ir_expression *ir)
|
||||
|
||||
case ir_binop_lshift:
|
||||
case ir_binop_rshift:
|
||||
assert(ir->operands[0]->type->is_integer_16_32_64() &&
|
||||
ir->operands[1]->type->is_integer_16_32_64());
|
||||
if (ir->operands[0]->type->is_scalar()) {
|
||||
assert(ir->operands[1]->type->is_scalar());
|
||||
assert(glsl_type_is_integer_16_32_64(ir->operands[0]->type) &&
|
||||
glsl_type_is_integer_16_32_64(ir->operands[1]->type));
|
||||
if (glsl_type_is_scalar(ir->operands[0]->type)) {
|
||||
assert(glsl_type_is_scalar(ir->operands[1]->type));
|
||||
}
|
||||
if (ir->operands[0]->type->is_vector() &&
|
||||
ir->operands[1]->type->is_vector()) {
|
||||
assert(ir->operands[0]->type->components() ==
|
||||
ir->operands[1]->type->components());
|
||||
if (glsl_type_is_vector(ir->operands[0]->type) &&
|
||||
glsl_type_is_vector(ir->operands[1]->type)) {
|
||||
assert(glsl_get_components(ir->operands[0]->type) ==
|
||||
glsl_get_components(ir->operands[1]->type));
|
||||
}
|
||||
assert(ir->type == ir->operands[0]->type);
|
||||
break;
|
||||
@@ -822,9 +822,9 @@ ir_validate::visit_leave(ir_expression *ir)
|
||||
case ir_binop_bit_or:
|
||||
assert(ir->operands[0]->type->base_type ==
|
||||
ir->operands[1]->type->base_type);
|
||||
assert(ir->type->is_integer_16_32_64());
|
||||
if (ir->operands[0]->type->is_vector() &&
|
||||
ir->operands[1]->type->is_vector()) {
|
||||
assert(glsl_type_is_integer_16_32_64(ir->type));
|
||||
if (glsl_type_is_vector(ir->operands[0]->type) &&
|
||||
glsl_type_is_vector(ir->operands[1]->type)) {
|
||||
assert(ir->operands[0]->type->vector_elements ==
|
||||
ir->operands[1]->type->vector_elements);
|
||||
}
|
||||
@@ -833,63 +833,63 @@ ir_validate::visit_leave(ir_expression *ir)
|
||||
case ir_binop_logic_and:
|
||||
case ir_binop_logic_xor:
|
||||
case ir_binop_logic_or:
|
||||
assert(ir->type->is_boolean());
|
||||
assert(ir->operands[0]->type->is_boolean());
|
||||
assert(ir->operands[1]->type->is_boolean());
|
||||
assert(glsl_type_is_boolean(ir->type));
|
||||
assert(glsl_type_is_boolean(ir->operands[0]->type));
|
||||
assert(glsl_type_is_boolean(ir->operands[1]->type));
|
||||
break;
|
||||
|
||||
case ir_binop_dot:
|
||||
assert(ir->type == &glsl_type_builtin_float ||
|
||||
ir->type == &glsl_type_builtin_double ||
|
||||
ir->type == &glsl_type_builtin_float16_t);
|
||||
assert(ir->operands[0]->type->is_float_16_32_64());
|
||||
assert(ir->operands[0]->type->is_vector());
|
||||
assert(glsl_type_is_float_16_32_64(ir->operands[0]->type));
|
||||
assert(glsl_type_is_vector(ir->operands[0]->type));
|
||||
assert(ir->operands[0]->type == ir->operands[1]->type);
|
||||
break;
|
||||
|
||||
case ir_binop_ldexp:
|
||||
assert(ir->operands[0]->type == ir->type);
|
||||
assert(ir->operands[0]->type->is_float_32_64());
|
||||
assert(glsl_type_is_float_32_64(ir->operands[0]->type));
|
||||
assert(ir->operands[1]->type->base_type == GLSL_TYPE_INT);
|
||||
assert(ir->operands[0]->type->components() ==
|
||||
ir->operands[1]->type->components());
|
||||
assert(glsl_get_components(ir->operands[0]->type) ==
|
||||
glsl_get_components(ir->operands[1]->type));
|
||||
break;
|
||||
|
||||
case ir_binop_vector_extract:
|
||||
assert(ir->operands[0]->type->is_vector());
|
||||
assert(ir->operands[1]->type->is_scalar()
|
||||
&& ir->operands[1]->type->is_integer_16_32());
|
||||
assert(glsl_type_is_vector(ir->operands[0]->type));
|
||||
assert(glsl_type_is_scalar(ir->operands[1]->type)
|
||||
&& glsl_type_is_integer_16_32(ir->operands[1]->type));
|
||||
break;
|
||||
|
||||
case ir_binop_interpolate_at_offset:
|
||||
assert(ir->operands[0]->type == ir->type);
|
||||
assert(ir->operands[0]->type->is_float_16_32());
|
||||
assert(ir->operands[1]->type->components() == 2);
|
||||
assert(ir->operands[1]->type->is_float_16_32());
|
||||
assert(glsl_type_is_float_16_32(ir->operands[0]->type));
|
||||
assert(glsl_get_components(ir->operands[1]->type) == 2);
|
||||
assert(glsl_type_is_float_16_32(ir->operands[1]->type));
|
||||
break;
|
||||
|
||||
case ir_binop_interpolate_at_sample:
|
||||
assert(ir->operands[0]->type == ir->type);
|
||||
assert(ir->operands[0]->type->is_float_16_32());
|
||||
assert(glsl_type_is_float_16_32(ir->operands[0]->type));
|
||||
assert(ir->operands[1]->type == &glsl_type_builtin_int ||
|
||||
ir->operands[1]->type == &glsl_type_builtin_int16_t);
|
||||
break;
|
||||
|
||||
case ir_binop_atan2:
|
||||
assert(ir->operands[0]->type->is_float_16_32_64());
|
||||
assert(glsl_type_is_float_16_32_64(ir->operands[0]->type));
|
||||
assert(ir->operands[1]->type == ir->operands[0]->type);
|
||||
assert(ir->type == ir->operands[0]->type);
|
||||
break;
|
||||
|
||||
case ir_triop_fma:
|
||||
assert(ir->type->is_float_16_32_64());
|
||||
assert(glsl_type_is_float_16_32_64(ir->type));
|
||||
assert(ir->type == ir->operands[0]->type);
|
||||
assert(ir->type == ir->operands[1]->type);
|
||||
assert(ir->type == ir->operands[2]->type);
|
||||
break;
|
||||
|
||||
case ir_triop_lrp:
|
||||
assert(ir->operands[0]->type->is_float_16_32_64());
|
||||
assert(glsl_type_is_float_16_32_64(ir->operands[0]->type));
|
||||
assert(ir->operands[0]->type == ir->operands[1]->type);
|
||||
assert(ir->operands[2]->type == ir->operands[0]->type ||
|
||||
ir->operands[2]->type == &glsl_type_builtin_float ||
|
||||
@@ -898,30 +898,30 @@ ir_validate::visit_leave(ir_expression *ir)
|
||||
break;
|
||||
|
||||
case ir_triop_csel:
|
||||
assert(ir->operands[0]->type->is_boolean());
|
||||
assert(glsl_type_is_boolean(ir->operands[0]->type));
|
||||
assert(ir->type->vector_elements == ir->operands[0]->type->vector_elements);
|
||||
assert(ir->type == ir->operands[1]->type);
|
||||
assert(ir->type == ir->operands[2]->type);
|
||||
break;
|
||||
|
||||
case ir_triop_bitfield_extract:
|
||||
assert(ir->type->is_integer_16_32());
|
||||
assert(glsl_type_is_integer_16_32(ir->type));
|
||||
assert(ir->operands[0]->type == ir->type);
|
||||
assert(ir->operands[1]->type == ir->type);
|
||||
assert(ir->operands[2]->type == ir->type);
|
||||
break;
|
||||
|
||||
case ir_triop_vector_insert:
|
||||
assert(ir->operands[0]->type->is_vector());
|
||||
assert(ir->operands[1]->type->is_scalar());
|
||||
assert(glsl_type_is_vector(ir->operands[0]->type));
|
||||
assert(glsl_type_is_scalar(ir->operands[1]->type));
|
||||
assert(ir->operands[0]->type->base_type == ir->operands[1]->type->base_type);
|
||||
assert(ir->operands[2]->type->is_scalar()
|
||||
&& ir->operands[2]->type->is_integer_16_32());
|
||||
assert(glsl_type_is_scalar(ir->operands[2]->type)
|
||||
&& glsl_type_is_integer_16_32(ir->operands[2]->type));
|
||||
assert(ir->type == ir->operands[0]->type);
|
||||
break;
|
||||
|
||||
case ir_quadop_bitfield_insert:
|
||||
assert(ir->type->is_integer_16_32());
|
||||
assert(glsl_type_is_integer_16_32(ir->type));
|
||||
assert(ir->operands[0]->type == ir->type);
|
||||
assert(ir->operands[1]->type == ir->type);
|
||||
assert(ir->operands[2]->type == ir->type);
|
||||
@@ -938,37 +938,37 @@ ir_validate::visit_leave(ir_expression *ir)
|
||||
*/
|
||||
switch (ir->type->vector_elements) {
|
||||
case 1:
|
||||
assert(ir->operands[0]->type->is_scalar());
|
||||
assert(glsl_type_is_scalar(ir->operands[0]->type));
|
||||
assert(ir->operands[0]->type->base_type == ir->type->base_type);
|
||||
assert(ir->operands[1] == NULL);
|
||||
assert(ir->operands[2] == NULL);
|
||||
assert(ir->operands[3] == NULL);
|
||||
break;
|
||||
case 2:
|
||||
assert(ir->operands[0]->type->is_scalar());
|
||||
assert(glsl_type_is_scalar(ir->operands[0]->type));
|
||||
assert(ir->operands[0]->type->base_type == ir->type->base_type);
|
||||
assert(ir->operands[1]->type->is_scalar());
|
||||
assert(glsl_type_is_scalar(ir->operands[1]->type));
|
||||
assert(ir->operands[1]->type->base_type == ir->type->base_type);
|
||||
assert(ir->operands[2] == NULL);
|
||||
assert(ir->operands[3] == NULL);
|
||||
break;
|
||||
case 3:
|
||||
assert(ir->operands[0]->type->is_scalar());
|
||||
assert(glsl_type_is_scalar(ir->operands[0]->type));
|
||||
assert(ir->operands[0]->type->base_type == ir->type->base_type);
|
||||
assert(ir->operands[1]->type->is_scalar());
|
||||
assert(glsl_type_is_scalar(ir->operands[1]->type));
|
||||
assert(ir->operands[1]->type->base_type == ir->type->base_type);
|
||||
assert(ir->operands[2]->type->is_scalar());
|
||||
assert(glsl_type_is_scalar(ir->operands[2]->type));
|
||||
assert(ir->operands[2]->type->base_type == ir->type->base_type);
|
||||
assert(ir->operands[3] == NULL);
|
||||
break;
|
||||
case 4:
|
||||
assert(ir->operands[0]->type->is_scalar());
|
||||
assert(glsl_type_is_scalar(ir->operands[0]->type));
|
||||
assert(ir->operands[0]->type->base_type == ir->type->base_type);
|
||||
assert(ir->operands[1]->type->is_scalar());
|
||||
assert(glsl_type_is_scalar(ir->operands[1]->type));
|
||||
assert(ir->operands[1]->type->base_type == ir->type->base_type);
|
||||
assert(ir->operands[2]->type->is_scalar());
|
||||
assert(glsl_type_is_scalar(ir->operands[2]->type));
|
||||
assert(ir->operands[2]->type->base_type == ir->type->base_type);
|
||||
assert(ir->operands[3]->type->is_scalar());
|
||||
assert(glsl_type_is_scalar(ir->operands[3]->type));
|
||||
assert(ir->operands[3]->type->base_type == ir->type->base_type);
|
||||
break;
|
||||
default:
|
||||
@@ -1017,7 +1017,7 @@ ir_validate::visit(ir_variable *ir)
|
||||
* bounds. There was once an error in AST-to-HIR conversion that set this
|
||||
* to be out of bounds.
|
||||
*/
|
||||
if (ir->type->array_size() > 0) {
|
||||
if (glsl_array_size(ir->type) > 0) {
|
||||
if (ir->data.max_array_access >= (int)ir->type->length) {
|
||||
printf("ir_variable has maximum access out of bounds (%d vs %d)\n",
|
||||
ir->data.max_array_access, ir->type->length - 1);
|
||||
@@ -1034,7 +1034,7 @@ ir_validate::visit(ir_variable *ir)
|
||||
const glsl_struct_field *fields =
|
||||
ir->get_interface_type()->fields.structure;
|
||||
for (unsigned i = 0; i < ir->get_interface_type()->length; i++) {
|
||||
if (fields[i].type->array_size() > 0 &&
|
||||
if (glsl_array_size(fields[i].type) > 0 &&
|
||||
!fields[i].implicit_sized_array) {
|
||||
const int *const max_ifc_array_access =
|
||||
ir->get_max_ifc_array_access();
|
||||
@@ -1074,10 +1074,10 @@ ir_visitor_status
|
||||
ir_validate::visit_enter(ir_assignment *ir)
|
||||
{
|
||||
const ir_dereference *const lhs = ir->lhs;
|
||||
if (lhs->type->is_scalar() || lhs->type->is_vector()) {
|
||||
if (glsl_type_is_scalar(lhs->type) || glsl_type_is_vector(lhs->type)) {
|
||||
if (ir->write_mask == 0) {
|
||||
printf("Assignment LHS is %s, but write mask is 0:\n",
|
||||
lhs->type->is_scalar() ? "scalar" : "vector");
|
||||
glsl_type_is_scalar(lhs->type) ? "scalar" : "vector");
|
||||
ir->print();
|
||||
abort();
|
||||
}
|
||||
|
||||
@@ -202,9 +202,9 @@ public:
|
||||
formal_param_node = formal_param_node->get_next();
|
||||
actual_param_node = actual_param_node->get_next();
|
||||
|
||||
if (formal_param->type->is_array()) {
|
||||
if (glsl_type_is_array(formal_param->type)) {
|
||||
ir_dereference_variable *deref = actual_param->as_dereference_variable();
|
||||
if (deref && deref->var && deref->var->type->is_array()) {
|
||||
if (deref && deref->var && glsl_type_is_array(deref->var->type)) {
|
||||
deref->var->data.max_array_access =
|
||||
MAX2(formal_param->data.max_array_access,
|
||||
deref->var->data.max_array_access);
|
||||
@@ -232,7 +232,7 @@ public:
|
||||
linked->symbols->add_variable(var);
|
||||
linked->ir->push_head(var);
|
||||
} else {
|
||||
if (var->type->is_array()) {
|
||||
if (glsl_type_is_array(var->type)) {
|
||||
/* It is possible to have a global array declared in multiple
|
||||
* shaders without a size. The array is implicitly sized by
|
||||
* the maximal access to it in *any* shader. Because of this,
|
||||
|
||||
@@ -121,7 +121,7 @@ intrastage_match(ir_variable *a,
|
||||
bool interface_type_match =
|
||||
(prog->IsES ?
|
||||
a->get_interface_type() == b->get_interface_type() :
|
||||
a->get_interface_type()->compare_no_precision(b->get_interface_type()));
|
||||
glsl_type_compare_no_precision(a->get_interface_type(), b->get_interface_type()));
|
||||
|
||||
/* Types must match. */
|
||||
if (!interface_type_match) {
|
||||
@@ -153,12 +153,12 @@ intrastage_match(ir_variable *a,
|
||||
|
||||
bool type_match = (match_precision ?
|
||||
a->type == b->type :
|
||||
a->type->compare_no_precision(b->type));
|
||||
glsl_type_compare_no_precision(a->type, b->type));
|
||||
|
||||
/* If a block is an array then it must match across the shader.
|
||||
* Unsized arrays are also processed and matched agaist sized arrays.
|
||||
*/
|
||||
if (!type_match && (b->type->is_array() || a->type->is_array()) &&
|
||||
if (!type_match && (glsl_type_is_array(b->type) || glsl_type_is_array(a->type)) &&
|
||||
(b->is_interface_instance() || a->is_interface_instance()) &&
|
||||
!validate_intrastage_arrays(prog, b, a, match_precision))
|
||||
return false;
|
||||
@@ -209,9 +209,9 @@ interstage_match(struct gl_shader_program *prog, ir_variable *producer,
|
||||
* making sure the types are equal.
|
||||
*/
|
||||
if ((consumer->is_interface_instance() &&
|
||||
consumer_instance_type->is_array()) ||
|
||||
glsl_type_is_array(consumer_instance_type)) ||
|
||||
(producer->is_interface_instance() &&
|
||||
producer->type->is_array())) {
|
||||
glsl_type_is_array(producer->type))) {
|
||||
if (consumer_instance_type != producer->type)
|
||||
return false;
|
||||
}
|
||||
@@ -261,7 +261,7 @@ public:
|
||||
} else {
|
||||
const struct hash_entry *entry =
|
||||
_mesa_hash_table_search(ht,
|
||||
glsl_get_type_name(var->get_interface_type()->without_array()));
|
||||
glsl_get_type_name(glsl_without_array(var->get_interface_type())));
|
||||
return entry ? (ir_variable *) entry->data : NULL;
|
||||
}
|
||||
}
|
||||
@@ -283,7 +283,7 @@ public:
|
||||
_mesa_hash_table_insert(ht, ralloc_strdup(mem_ctx, location_str), var);
|
||||
} else {
|
||||
_mesa_hash_table_insert(ht,
|
||||
glsl_get_type_name(var->get_interface_type()->without_array()), var);
|
||||
glsl_get_type_name(glsl_without_array(var->get_interface_type())), var);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -248,7 +248,7 @@ public:
|
||||
virtual ir_visitor_status visit_leave(ir_dereference_array *ir)
|
||||
{
|
||||
const glsl_type *const vt = ir->array->type;
|
||||
if (vt->is_array())
|
||||
if (glsl_type_is_array(vt))
|
||||
ir->type = vt->fields.array;
|
||||
return visit_continue;
|
||||
}
|
||||
@@ -285,7 +285,7 @@ public:
|
||||
|
||||
virtual ir_visitor_status visit(ir_variable *var)
|
||||
{
|
||||
if (!var->type->is_array() || var->data.mode != ir_var_shader_in ||
|
||||
if (!glsl_type_is_array(var->type) || var->data.mode != ir_var_shader_in ||
|
||||
var->data.patch)
|
||||
return visit_continue;
|
||||
|
||||
@@ -316,8 +316,8 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
var->type = glsl_type::get_array_instance(var->type->fields.array,
|
||||
this->num_vertices);
|
||||
var->type = glsl_array_type(var->type->fields.array,
|
||||
this->num_vertices, 0);
|
||||
var->data.max_array_access = this->num_vertices - 1;
|
||||
|
||||
return visit_continue;
|
||||
@@ -346,9 +346,9 @@ public:
|
||||
ir_expression *expr = (*rvalue)->as_expression();
|
||||
if (expr) {
|
||||
if (expr->operation == ir_unop_implicitly_sized_array_length) {
|
||||
assert(!expr->operands[0]->type->is_unsized_array());
|
||||
assert(!glsl_type_is_unsized_array(expr->operands[0]->type));
|
||||
ir_constant *constant = new(expr)
|
||||
ir_constant(expr->operands[0]->type->array_size());
|
||||
ir_constant(glsl_array_size(expr->operands[0]->type));
|
||||
if (constant) {
|
||||
*rvalue = constant;
|
||||
}
|
||||
@@ -770,14 +770,14 @@ validate_intrastage_arrays(struct gl_shader_program *prog,
|
||||
* In addition, set the type of the linked variable to the
|
||||
* explicitly sized array.
|
||||
*/
|
||||
if (var->type->is_array() && existing->type->is_array()) {
|
||||
if (glsl_type_is_array(var->type) && glsl_type_is_array(existing->type)) {
|
||||
const glsl_type *no_array_var = var->type->fields.array;
|
||||
const glsl_type *no_array_existing = existing->type->fields.array;
|
||||
bool type_matches;
|
||||
|
||||
type_matches = (match_precision ?
|
||||
no_array_var == no_array_existing :
|
||||
no_array_var->compare_no_precision(no_array_existing));
|
||||
glsl_type_compare_no_precision(no_array_var, no_array_existing));
|
||||
|
||||
if (type_matches &&
|
||||
((var->type->length == 0)|| (existing->type->length == 0))) {
|
||||
@@ -829,7 +829,7 @@ cross_validate_globals(const struct gl_constants *consts,
|
||||
continue;
|
||||
|
||||
/* don't cross validate subroutine uniforms */
|
||||
if (var->type->contains_subroutine())
|
||||
if (glsl_contains_subroutine(var->type))
|
||||
continue;
|
||||
|
||||
/* Don't cross validate interface instances. These are only relevant
|
||||
@@ -923,7 +923,7 @@ cross_validate_globals(const struct gl_constants *consts,
|
||||
existing->data.explicit_binding = true;
|
||||
}
|
||||
|
||||
if (var->type->contains_atomic() &&
|
||||
if (glsl_contains_atomic(var->type) &&
|
||||
var->data.offset != existing->data.offset) {
|
||||
linker_error(prog, "offset specifications for %s "
|
||||
"`%s' have differing values\n",
|
||||
@@ -1348,8 +1348,8 @@ public:
|
||||
var->data.from_ssbo_unsized_array,
|
||||
&implicit_sized_array);
|
||||
var->data.implicit_sized_array = implicit_sized_array;
|
||||
type_without_array = var->type->without_array();
|
||||
if (var->type->is_interface()) {
|
||||
type_without_array = glsl_without_array(var->type);
|
||||
if (glsl_type_is_interface(var->type)) {
|
||||
if (interface_contains_unsized_arrays(var->type)) {
|
||||
const glsl_type *new_type =
|
||||
resize_interface_members(var->type,
|
||||
@@ -1358,7 +1358,7 @@ public:
|
||||
var->type = new_type;
|
||||
var->change_interface_type(new_type);
|
||||
}
|
||||
} else if (type_without_array->is_interface()) {
|
||||
} else if (glsl_type_is_interface(type_without_array)) {
|
||||
if (interface_contains_unsized_arrays(type_without_array)) {
|
||||
const glsl_type *new_type =
|
||||
resize_interface_members(type_without_array,
|
||||
@@ -1383,7 +1383,7 @@ public:
|
||||
_mesa_hash_table_insert(this->unnamed_interfaces, ifc_type,
|
||||
interface_vars);
|
||||
}
|
||||
unsigned index = ifc_type->field_index(var->name);
|
||||
unsigned index = glsl_get_field_index(ifc_type, var->name);
|
||||
assert(index < ifc_type->length);
|
||||
assert(interface_vars[index] == NULL);
|
||||
interface_vars[index] = var;
|
||||
@@ -1411,9 +1411,9 @@ private:
|
||||
static void fixup_type(const glsl_type **type, unsigned max_array_access,
|
||||
bool from_ssbo_unsized_array, bool *implicit_sized)
|
||||
{
|
||||
if (!from_ssbo_unsized_array && (*type)->is_unsized_array()) {
|
||||
*type = glsl_type::get_array_instance((*type)->fields.array,
|
||||
max_array_access + 1);
|
||||
if (!from_ssbo_unsized_array && glsl_type_is_unsized_array(*type)) {
|
||||
*type = glsl_array_type((*type)->fields.array,
|
||||
max_array_access + 1, 0);
|
||||
*implicit_sized = true;
|
||||
assert(*type != NULL);
|
||||
}
|
||||
@@ -1424,13 +1424,12 @@ private:
|
||||
const glsl_type *new_interface_type)
|
||||
{
|
||||
const glsl_type *element_type = type->fields.array;
|
||||
if (element_type->is_array()) {
|
||||
if (glsl_type_is_array(element_type)) {
|
||||
const glsl_type *new_array_type =
|
||||
update_interface_members_array(element_type, new_interface_type);
|
||||
return glsl_type::get_array_instance(new_array_type, type->length);
|
||||
return glsl_array_type(new_array_type, type->length, 0);
|
||||
} else {
|
||||
return glsl_type::get_array_instance(new_interface_type,
|
||||
type->length);
|
||||
return glsl_array_type(new_interface_type, type->length, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1442,7 +1441,7 @@ private:
|
||||
{
|
||||
for (unsigned i = 0; i < type->length; i++) {
|
||||
const glsl_type *elem_type = type->fields.structure[i].type;
|
||||
if (elem_type->is_unsized_array())
|
||||
if (glsl_type_is_unsized_array(elem_type))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -1479,8 +1478,8 @@ private:
|
||||
(glsl_interface_packing) type->interface_packing;
|
||||
bool row_major = (bool) type->interface_row_major;
|
||||
const glsl_type *new_ifc_type =
|
||||
glsl_type::get_interface_instance(fields, num_fields,
|
||||
packing, row_major, glsl_get_type_name(type));
|
||||
glsl_interface_type(fields, num_fields,
|
||||
packing, row_major, glsl_get_type_name(type));
|
||||
delete [] fields;
|
||||
return new_ifc_type;
|
||||
}
|
||||
@@ -1510,8 +1509,8 @@ private:
|
||||
(glsl_interface_packing) ifc_type->interface_packing;
|
||||
bool row_major = (bool) ifc_type->interface_row_major;
|
||||
const glsl_type *new_ifc_type =
|
||||
glsl_type::get_interface_instance(fields, num_fields, packing,
|
||||
row_major, glsl_get_type_name(ifc_type));
|
||||
glsl_interface_type(fields, num_fields, packing,
|
||||
row_major, glsl_get_type_name(ifc_type));
|
||||
delete [] fields;
|
||||
for (unsigned i = 0; i < num_fields; i++) {
|
||||
if (interface_vars[i] != NULL)
|
||||
@@ -2457,7 +2456,7 @@ static int
|
||||
reserve_explicit_locations(struct gl_shader_program *prog,
|
||||
string_to_uint_map *map, ir_variable *var)
|
||||
{
|
||||
unsigned slots = var->type->uniform_locations();
|
||||
unsigned slots = glsl_type_uniform_locations(var->type);
|
||||
unsigned max_loc = var->data.location + slots - 1;
|
||||
unsigned return_value = slots;
|
||||
|
||||
@@ -2523,7 +2522,7 @@ reserve_subroutine_explicit_locations(struct gl_shader_program *prog,
|
||||
struct gl_program *p,
|
||||
ir_variable *var)
|
||||
{
|
||||
unsigned slots = var->type->uniform_locations();
|
||||
unsigned slots = glsl_type_uniform_locations(var->type);
|
||||
unsigned max_loc = var->data.location + slots - 1;
|
||||
|
||||
/* Resize remap table if locations do not fit in the current one. */
|
||||
@@ -2608,7 +2607,7 @@ check_explicit_uniform_locations(const struct gl_extensions *exts,
|
||||
|
||||
if (var->data.explicit_location) {
|
||||
bool ret = false;
|
||||
if (var->type->without_array()->is_subroutine())
|
||||
if (glsl_type_is_subroutine(glsl_without_array(var->type)))
|
||||
ret = reserve_subroutine_explicit_locations(prog, p, var);
|
||||
else {
|
||||
int slots = reserve_explicit_locations(prog, uniform_map,
|
||||
@@ -2782,14 +2781,14 @@ public:
|
||||
* We have no way to handle this in NIR or the glsl to nir pass
|
||||
* currently so let the GLSL IR lowering handle it.
|
||||
*/
|
||||
if (param->type->contains_opaque()) {
|
||||
if (glsl_contains_opaque(param->type)) {
|
||||
unsupported = true;
|
||||
return visit_stop;
|
||||
}
|
||||
}
|
||||
|
||||
if (!glsl_type_is_vector_or_scalar(ir->return_type) &&
|
||||
!ir->return_type->is_void()) {
|
||||
!glsl_type_is_void(ir->return_type)) {
|
||||
unsupported = true;
|
||||
return visit_stop;
|
||||
}
|
||||
|
||||
@@ -102,11 +102,11 @@ lower_instructions(exec_list *instructions,bool have_gpu_shader5)
|
||||
void
|
||||
lower_instructions_visitor::double_dot_to_fma(ir_expression *ir)
|
||||
{
|
||||
ir_variable *temp = new(ir) ir_variable(ir->operands[0]->type->get_base_type(), "dot_res",
|
||||
ir_variable *temp = new(ir) ir_variable(glsl_get_base_glsl_type(ir->operands[0]->type), "dot_res",
|
||||
ir_var_temporary);
|
||||
this->base_ir->insert_before(temp);
|
||||
|
||||
int nc = ir->operands[0]->type->components();
|
||||
int nc = glsl_get_components(ir->operands[0]->type);
|
||||
for (int i = nc - 1; i >= 1; i--) {
|
||||
ir_assignment *assig;
|
||||
if (i == (nc - 1)) {
|
||||
@@ -168,13 +168,13 @@ lower_instructions_visitor::find_lsb_to_float_cast(ir_expression *ir)
|
||||
ir_constant *c23 = new(ir) ir_constant(int(23), elements);
|
||||
ir_constant *c7F = new(ir) ir_constant(int(0x7F), elements);
|
||||
ir_variable *temp =
|
||||
new(ir) ir_variable(glsl_type::ivec(elements), "temp", ir_var_temporary);
|
||||
new(ir) ir_variable(glsl_ivec_type(elements), "temp", ir_var_temporary);
|
||||
ir_variable *lsb_only =
|
||||
new(ir) ir_variable(glsl_type::uvec(elements), "lsb_only", ir_var_temporary);
|
||||
new(ir) ir_variable(glsl_uvec_type(elements), "lsb_only", ir_var_temporary);
|
||||
ir_variable *as_float =
|
||||
new(ir) ir_variable(glsl_type::vec(elements), "as_float", ir_var_temporary);
|
||||
new(ir) ir_variable(glsl_vec_type(elements), "as_float", ir_var_temporary);
|
||||
ir_variable *lsb =
|
||||
new(ir) ir_variable(glsl_type::ivec(elements), "lsb", ir_var_temporary);
|
||||
new(ir) ir_variable(glsl_ivec_type(elements), "lsb", ir_var_temporary);
|
||||
|
||||
ir_instruction &i = *base_ir;
|
||||
|
||||
@@ -251,11 +251,11 @@ lower_instructions_visitor::find_msb_to_float_cast(ir_expression *ir)
|
||||
ir_constant *c000000FF = new(ir) ir_constant(0x000000FFu, elements);
|
||||
ir_constant *cFFFFFF00 = new(ir) ir_constant(0xFFFFFF00u, elements);
|
||||
ir_variable *temp =
|
||||
new(ir) ir_variable(glsl_type::uvec(elements), "temp", ir_var_temporary);
|
||||
new(ir) ir_variable(glsl_uvec_type(elements), "temp", ir_var_temporary);
|
||||
ir_variable *as_float =
|
||||
new(ir) ir_variable(glsl_type::vec(elements), "as_float", ir_var_temporary);
|
||||
new(ir) ir_variable(glsl_vec_type(elements), "as_float", ir_var_temporary);
|
||||
ir_variable *msb =
|
||||
new(ir) ir_variable(glsl_type::ivec(elements), "msb", ir_var_temporary);
|
||||
new(ir) ir_variable(glsl_ivec_type(elements), "msb", ir_var_temporary);
|
||||
|
||||
ir_instruction &i = *base_ir;
|
||||
|
||||
@@ -283,7 +283,7 @@ lower_instructions_visitor::find_msb_to_float_cast(ir_expression *ir)
|
||||
* logical-not can be achieved in two instructions.
|
||||
*/
|
||||
ir_variable *as_int =
|
||||
new(ir) ir_variable(glsl_type::ivec(elements), "as_int", ir_var_temporary);
|
||||
new(ir) ir_variable(glsl_ivec_type(elements), "as_int", ir_var_temporary);
|
||||
ir_constant *c31 = new(ir) ir_constant(int(31), elements);
|
||||
|
||||
i.insert_before(as_int);
|
||||
@@ -372,25 +372,25 @@ lower_instructions_visitor::imul_high_to_mul(ir_expression *ir)
|
||||
*/
|
||||
const unsigned elements = ir->operands[0]->type->vector_elements;
|
||||
ir_variable *src1 =
|
||||
new(ir) ir_variable(glsl_type::uvec(elements), "src1", ir_var_temporary);
|
||||
new(ir) ir_variable(glsl_uvec_type(elements), "src1", ir_var_temporary);
|
||||
ir_variable *src1h =
|
||||
new(ir) ir_variable(glsl_type::uvec(elements), "src1h", ir_var_temporary);
|
||||
new(ir) ir_variable(glsl_uvec_type(elements), "src1h", ir_var_temporary);
|
||||
ir_variable *src1l =
|
||||
new(ir) ir_variable(glsl_type::uvec(elements), "src1l", ir_var_temporary);
|
||||
new(ir) ir_variable(glsl_uvec_type(elements), "src1l", ir_var_temporary);
|
||||
ir_variable *src2 =
|
||||
new(ir) ir_variable(glsl_type::uvec(elements), "src2", ir_var_temporary);
|
||||
new(ir) ir_variable(glsl_uvec_type(elements), "src2", ir_var_temporary);
|
||||
ir_variable *src2h =
|
||||
new(ir) ir_variable(glsl_type::uvec(elements), "src2h", ir_var_temporary);
|
||||
new(ir) ir_variable(glsl_uvec_type(elements), "src2h", ir_var_temporary);
|
||||
ir_variable *src2l =
|
||||
new(ir) ir_variable(glsl_type::uvec(elements), "src2l", ir_var_temporary);
|
||||
new(ir) ir_variable(glsl_uvec_type(elements), "src2l", ir_var_temporary);
|
||||
ir_variable *t1 =
|
||||
new(ir) ir_variable(glsl_type::uvec(elements), "t1", ir_var_temporary);
|
||||
new(ir) ir_variable(glsl_uvec_type(elements), "t1", ir_var_temporary);
|
||||
ir_variable *t2 =
|
||||
new(ir) ir_variable(glsl_type::uvec(elements), "t2", ir_var_temporary);
|
||||
new(ir) ir_variable(glsl_uvec_type(elements), "t2", ir_var_temporary);
|
||||
ir_variable *lo =
|
||||
new(ir) ir_variable(glsl_type::uvec(elements), "lo", ir_var_temporary);
|
||||
new(ir) ir_variable(glsl_uvec_type(elements), "lo", ir_var_temporary);
|
||||
ir_variable *hi =
|
||||
new(ir) ir_variable(glsl_type::uvec(elements), "hi", ir_var_temporary);
|
||||
new(ir) ir_variable(glsl_uvec_type(elements), "hi", ir_var_temporary);
|
||||
ir_variable *different_signs = NULL;
|
||||
ir_constant *c0000FFFF = new(ir) ir_constant(0x0000FFFFu, elements);
|
||||
ir_constant *c16 = new(ir) ir_constant(16u, elements);
|
||||
@@ -411,9 +411,9 @@ lower_instructions_visitor::imul_high_to_mul(ir_expression *ir)
|
||||
assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT);
|
||||
|
||||
ir_variable *itmp1 =
|
||||
new(ir) ir_variable(glsl_type::ivec(elements), "itmp1", ir_var_temporary);
|
||||
new(ir) ir_variable(glsl_ivec_type(elements), "itmp1", ir_var_temporary);
|
||||
ir_variable *itmp2 =
|
||||
new(ir) ir_variable(glsl_type::ivec(elements), "itmp2", ir_var_temporary);
|
||||
new(ir) ir_variable(glsl_ivec_type(elements), "itmp2", ir_var_temporary);
|
||||
ir_constant *c0 = new(ir) ir_constant(int(0), elements);
|
||||
|
||||
i.insert_before(itmp1);
|
||||
@@ -422,7 +422,7 @@ lower_instructions_visitor::imul_high_to_mul(ir_expression *ir)
|
||||
i.insert_before(assign(itmp2, ir->operands[1]));
|
||||
|
||||
different_signs =
|
||||
new(ir) ir_variable(glsl_type::bvec(elements), "different_signs",
|
||||
new(ir) ir_variable(glsl_bvec_type(elements), "different_signs",
|
||||
ir_var_temporary);
|
||||
|
||||
i.insert_before(different_signs);
|
||||
@@ -474,7 +474,7 @@ lower_instructions_visitor::imul_high_to_mul(ir_expression *ir)
|
||||
* -1, not -0! Recall -x == ~x + 1.
|
||||
*/
|
||||
ir_variable *neg_hi =
|
||||
new(ir) ir_variable(glsl_type::ivec(elements), "neg_hi", ir_var_temporary);
|
||||
new(ir) ir_variable(glsl_ivec_type(elements), "neg_hi", ir_var_temporary);
|
||||
ir_constant *c1 = new(ir) ir_constant(1u, elements);
|
||||
|
||||
i.insert_before(neg_hi);
|
||||
@@ -494,11 +494,11 @@ lower_instructions_visitor::visit_leave(ir_expression *ir)
|
||||
{
|
||||
switch (ir->operation) {
|
||||
case ir_binop_dot:
|
||||
if (ir->operands[0]->type->is_double())
|
||||
if (glsl_type_is_double(ir->operands[0]->type))
|
||||
double_dot_to_fma(ir);
|
||||
break;
|
||||
case ir_triop_lrp:
|
||||
if (ir->operands[0]->type->is_double())
|
||||
if (glsl_type_is_double(ir->operands[0]->type))
|
||||
double_lrp(ir);
|
||||
break;
|
||||
|
||||
|
||||
@@ -225,7 +225,7 @@ struct function_record
|
||||
ir_variable* get_return_value()
|
||||
{
|
||||
if(!this->return_value) {
|
||||
assert(!this->signature->return_type->is_void());
|
||||
assert(!glsl_type_is_void(this->signature->return_type));
|
||||
return_value = new(this->signature) ir_variable(this->signature->return_type, "return_value", ir_var_temporary);
|
||||
this->signature->body.push_head(this->return_value);
|
||||
}
|
||||
@@ -305,7 +305,7 @@ struct ir_lower_jumps_visitor : public ir_control_flow_visitor {
|
||||
void insert_lowered_return(ir_return *ir)
|
||||
{
|
||||
ir_variable* return_flag = this->function.get_return_flag();
|
||||
if(!this->function.signature->return_type->is_void()) {
|
||||
if(!glsl_type_is_void(this->function.signature->return_type)) {
|
||||
ir_variable* return_value = this->function.get_return_value();
|
||||
ir->insert_before(
|
||||
new(ir) ir_assignment(
|
||||
@@ -515,7 +515,7 @@ retry: /* we get here if we put code after the if inside a branch */
|
||||
else if(jump_strengths[0] == strength_break)
|
||||
ir->insert_after(new(ir) ir_loop_jump(ir_loop_jump::jump_break));
|
||||
/* FINISHME: unify returns with identical expressions */
|
||||
else if(jump_strengths[0] == strength_return && this->function.signature->return_type->is_void())
|
||||
else if(jump_strengths[0] == strength_return && glsl_type_is_void(this->function.signature->return_type))
|
||||
ir->insert_after(new(ir) ir_return(NULL));
|
||||
else
|
||||
unify = false;
|
||||
@@ -846,7 +846,7 @@ lower_continue:
|
||||
/* In case the loop is embedded inside an if add a new return to
|
||||
* the return flag then branch and let a future pass tidy it up.
|
||||
*/
|
||||
if (this->function.signature->return_type->is_void())
|
||||
if (glsl_type_is_void(this->function.signature->return_type))
|
||||
return_if->then_instructions.push_tail(new(ir) ir_return(NULL));
|
||||
else {
|
||||
assert(this->function.return_value);
|
||||
@@ -895,7 +895,7 @@ lower_continue:
|
||||
* If the body ended in a return of void, eliminate it because
|
||||
* it is redundant.
|
||||
*/
|
||||
if (ir->return_type->is_void() &&
|
||||
if (glsl_type_is_void(ir->return_type) &&
|
||||
get_jump_strength((ir_instruction *) ir->body.get_tail())) {
|
||||
ir_jump *jump = (ir_jump *) ir->body.get_tail();
|
||||
assert (jump->ir_type == ir_type_return);
|
||||
|
||||
@@ -77,7 +77,7 @@ mat_op_to_vec_predicate(ir_instruction *ir)
|
||||
return false;
|
||||
|
||||
for (i = 0; i < expr->num_operands; i++) {
|
||||
if (expr->operands[i]->type->is_matrix())
|
||||
if (glsl_type_is_matrix(expr->operands[i]->type))
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ ir_mat_op_to_vec_visitor::get_column(ir_dereference *val, int row)
|
||||
{
|
||||
val = val->clone(mem_ctx, NULL);
|
||||
|
||||
if (val->type->is_matrix()) {
|
||||
if (glsl_type_is_matrix(val->type)) {
|
||||
val = new(mem_ctx) ir_dereference_array(val,
|
||||
new(mem_ctx) ir_constant(row));
|
||||
}
|
||||
@@ -254,7 +254,7 @@ ir_mat_op_to_vec_visitor::do_equal_mat_mat(ir_dereference *result,
|
||||
*/
|
||||
const unsigned columns = a->type->matrix_columns;
|
||||
const glsl_type *const bvec_type =
|
||||
glsl_type::get_instance(GLSL_TYPE_BOOL, columns, 1);
|
||||
glsl_simple_type(GLSL_TYPE_BOOL, columns, 1);
|
||||
|
||||
ir_variable *const tmp_bvec =
|
||||
new(this->mem_ctx) ir_variable(bvec_type, "mat_cmp_bvec",
|
||||
@@ -295,7 +295,7 @@ static bool
|
||||
has_matrix_operand(const ir_expression *expr, unsigned &columns)
|
||||
{
|
||||
for (unsigned i = 0; i < expr->num_operands; i++) {
|
||||
if (expr->operands[i]->type->is_matrix()) {
|
||||
if (glsl_type_is_matrix(expr->operands[i]->type)) {
|
||||
columns = expr->operands[i]->type->matrix_columns;
|
||||
return true;
|
||||
}
|
||||
@@ -403,21 +403,21 @@ ir_mat_op_to_vec_visitor::visit_leave(ir_assignment *orig_assign)
|
||||
break;
|
||||
}
|
||||
case ir_binop_mul:
|
||||
if (op[0]->type->is_matrix()) {
|
||||
if (op[1]->type->is_matrix()) {
|
||||
if (glsl_type_is_matrix(op[0]->type)) {
|
||||
if (glsl_type_is_matrix(op[1]->type)) {
|
||||
do_mul_mat_mat(result, op[0], op[1]);
|
||||
} else if (op[1]->type->is_vector()) {
|
||||
} else if (glsl_type_is_vector(op[1]->type)) {
|
||||
do_mul_mat_vec(result, op[0], op[1]);
|
||||
} else {
|
||||
assert(op[1]->type->is_scalar());
|
||||
assert(glsl_type_is_scalar(op[1]->type));
|
||||
do_mul_mat_scalar(result, op[0], op[1]);
|
||||
}
|
||||
} else {
|
||||
assert(op[1]->type->is_matrix());
|
||||
if (op[0]->type->is_vector()) {
|
||||
assert(glsl_type_is_matrix(op[1]->type));
|
||||
if (glsl_type_is_vector(op[0]->type)) {
|
||||
do_mul_vec_mat(result, op[0], op[1]);
|
||||
} else {
|
||||
assert(op[0]->type->is_scalar());
|
||||
assert(glsl_type_is_scalar(op[0]->type));
|
||||
do_mul_mat_scalar(result, op[1], op[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ can_lower_type(const struct gl_shader_compiler_options *options,
|
||||
* boolean types so that it will do comparisons as 16-bit.
|
||||
*/
|
||||
|
||||
switch (type->without_array()->base_type) {
|
||||
switch (glsl_without_array(type)->base_type) {
|
||||
/* TODO: should we do anything for these two with regard to Int16 vs FP16
|
||||
* support?
|
||||
*/
|
||||
@@ -421,7 +421,7 @@ handle_call(ir_call *ir, const struct set *lowerable_rvalues)
|
||||
ir_variable *resource = param->variable_referenced();
|
||||
|
||||
assert(ir->callee->return_precision == GLSL_PRECISION_HIGH);
|
||||
assert(resource->type->without_array()->is_image());
|
||||
assert(glsl_type_is_image(glsl_without_array(resource->type)));
|
||||
|
||||
/* GLSL ES 3.20 requires that images have a precision modifier, but if
|
||||
* you set one, it doesn't do anything, because all intrinsics are
|
||||
@@ -464,7 +464,7 @@ handle_call(ir_call *ir, const struct set *lowerable_rvalues)
|
||||
* We should lower the type of the return value if the sampler type
|
||||
* uses lower precision. The function parameters don't matter.
|
||||
*/
|
||||
if (var && var->type->without_array()->is_sampler()) {
|
||||
if (var && glsl_type_is_sampler(glsl_without_array(var->type))) {
|
||||
/* textureGatherOffsets always takes a highp array of constants. As
|
||||
* per the discussion https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16547#note_1393704
|
||||
* trying to lower the precision results in segfault later on
|
||||
@@ -612,10 +612,10 @@ find_lowerable_rvalues(const struct gl_shader_compiler_options *options,
|
||||
static const glsl_type *
|
||||
convert_type(bool up, const glsl_type *type)
|
||||
{
|
||||
if (type->is_array()) {
|
||||
return glsl_type::get_array_instance(convert_type(up, type->fields.array),
|
||||
type->array_size(),
|
||||
type->explicit_stride);
|
||||
if (glsl_type_is_array(type)) {
|
||||
return glsl_array_type(convert_type(up, type->fields.array),
|
||||
glsl_array_size(type),
|
||||
type->explicit_stride);
|
||||
}
|
||||
|
||||
glsl_base_type new_base_type;
|
||||
@@ -652,11 +652,12 @@ convert_type(bool up, const glsl_type *type)
|
||||
}
|
||||
}
|
||||
|
||||
return glsl_type::get_instance(new_base_type,
|
||||
type->vector_elements,
|
||||
type->matrix_columns,
|
||||
type->explicit_stride,
|
||||
type->interface_row_major);
|
||||
return glsl_simple_explicit_type(new_base_type,
|
||||
type->vector_elements,
|
||||
type->matrix_columns,
|
||||
type->explicit_stride,
|
||||
type->interface_row_major,
|
||||
0 /* explicit_alignment */);
|
||||
}
|
||||
|
||||
static const glsl_type *
|
||||
@@ -716,9 +717,9 @@ lower_precision_visitor::handle_rvalue(ir_rvalue **rvalue)
|
||||
return;
|
||||
|
||||
if (ir->as_dereference()) {
|
||||
if (!ir->type->is_boolean())
|
||||
if (!glsl_type_is_boolean(ir->type))
|
||||
*rvalue = convert_precision(false, ir);
|
||||
} else if (ir->type->is_32bit()) {
|
||||
} else if (glsl_type_is_32bit(ir->type)) {
|
||||
ir->type = lower_glsl_type(ir->type);
|
||||
|
||||
ir_constant *const_ir = ir->as_constant();
|
||||
@@ -975,8 +976,8 @@ public:
|
||||
static void
|
||||
lower_constant(ir_constant *ir)
|
||||
{
|
||||
if (ir->type->is_array()) {
|
||||
for (int i = 0; i < ir->type->array_size(); i++)
|
||||
if (glsl_type_is_array(ir->type)) {
|
||||
for (int i = 0; i < glsl_array_size(ir->type); i++)
|
||||
lower_constant(ir->get_array_element(i));
|
||||
|
||||
ir->type = lower_glsl_type(ir->type);
|
||||
@@ -1011,8 +1012,8 @@ lower_variables_visitor::visit(ir_variable *var)
|
||||
(var->data.mode != ir_var_uniform ||
|
||||
var->is_in_buffer_block() ||
|
||||
!(options->LowerPrecisionFloat16Uniforms &&
|
||||
var->type->without_array()->base_type == GLSL_TYPE_FLOAT))) ||
|
||||
!var->type->without_array()->is_32bit() ||
|
||||
glsl_without_array(var->type)->base_type == GLSL_TYPE_FLOAT))) ||
|
||||
!glsl_type_is_32bit(glsl_without_array(var->type)) ||
|
||||
(var->data.precision != GLSL_PRECISION_MEDIUM &&
|
||||
var->data.precision != GLSL_PRECISION_LOW) ||
|
||||
!can_lower_type(options, var->type))
|
||||
@@ -1046,7 +1047,7 @@ lower_variables_visitor::visit(ir_variable *var)
|
||||
void
|
||||
lower_variables_visitor::fix_types_in_deref_chain(ir_dereference *ir)
|
||||
{
|
||||
assert(ir->type->without_array()->is_32bit());
|
||||
assert(glsl_type_is_32bit(glsl_without_array(ir->type)));
|
||||
assert(_mesa_set_search(lower_vars, ir->variable_referenced()));
|
||||
|
||||
/* Fix the type in the dereference node. */
|
||||
@@ -1056,7 +1057,7 @@ lower_variables_visitor::fix_types_in_deref_chain(ir_dereference *ir)
|
||||
for (ir_dereference_array *deref_array = ir->as_dereference_array();
|
||||
deref_array;
|
||||
deref_array = deref_array->array->as_dereference_array()) {
|
||||
assert(deref_array->array->type->without_array()->is_32bit());
|
||||
assert(glsl_type_is_32bit(glsl_without_array(deref_array->array->type)));
|
||||
deref_array->array->type = lower_glsl_type(deref_array->array->type);
|
||||
}
|
||||
}
|
||||
@@ -1068,7 +1069,7 @@ lower_variables_visitor::convert_split_assignment(ir_dereference *lhs,
|
||||
{
|
||||
void *mem_ctx = ralloc_parent(lhs);
|
||||
|
||||
if (lhs->type->is_array()) {
|
||||
if (glsl_type_is_array(lhs->type)) {
|
||||
for (unsigned i = 0; i < lhs->type->length; i++) {
|
||||
ir_dereference *l, *r;
|
||||
|
||||
@@ -1081,12 +1082,12 @@ lower_variables_visitor::convert_split_assignment(ir_dereference *lhs,
|
||||
return;
|
||||
}
|
||||
|
||||
assert(lhs->type->is_16bit() || lhs->type->is_32bit());
|
||||
assert(rhs->type->is_16bit() || rhs->type->is_32bit());
|
||||
assert(lhs->type->is_16bit() != rhs->type->is_16bit());
|
||||
assert(glsl_type_is_16bit(lhs->type) || glsl_type_is_32bit(lhs->type));
|
||||
assert(glsl_type_is_16bit(rhs->type) || glsl_type_is_32bit(rhs->type));
|
||||
assert(glsl_type_is_16bit(lhs->type) != glsl_type_is_16bit(rhs->type));
|
||||
|
||||
ir_assignment *assign =
|
||||
new(mem_ctx) ir_assignment(lhs, convert_precision(lhs->type->is_32bit(), rhs));
|
||||
new(mem_ctx) ir_assignment(lhs, convert_precision(glsl_type_is_32bit(lhs->type), rhs));
|
||||
|
||||
if (insert_before)
|
||||
base_ir->insert_before(assign);
|
||||
@@ -1104,17 +1105,17 @@ lower_variables_visitor::visit_enter(ir_assignment *ir)
|
||||
ir_constant *rhs_const = ir->rhs->as_constant();
|
||||
|
||||
/* Legalize array assignments between lowered and non-lowered variables. */
|
||||
if (lhs->type->is_array() &&
|
||||
if (glsl_type_is_array(lhs->type) &&
|
||||
(rhs_var || rhs_const) &&
|
||||
(!rhs_var ||
|
||||
(var &&
|
||||
var->type->without_array()->is_16bit() !=
|
||||
rhs_var->type->without_array()->is_16bit())) &&
|
||||
glsl_type_is_16bit(glsl_without_array(var->type)) !=
|
||||
glsl_type_is_16bit(glsl_without_array(rhs_var->type)))) &&
|
||||
(!rhs_const ||
|
||||
(var &&
|
||||
var->type->without_array()->is_16bit() &&
|
||||
rhs_const->type->without_array()->is_32bit()))) {
|
||||
assert(ir->rhs->type->is_array());
|
||||
glsl_type_is_16bit(glsl_without_array(var->type)) &&
|
||||
glsl_type_is_32bit(glsl_without_array(rhs_const->type))))) {
|
||||
assert(glsl_type_is_array(ir->rhs->type));
|
||||
|
||||
/* Fix array assignments from lowered to non-lowered. */
|
||||
if (rhs_var && _mesa_set_search(lower_vars, rhs_var)) {
|
||||
@@ -1128,7 +1129,7 @@ lower_variables_visitor::visit_enter(ir_assignment *ir)
|
||||
/* Fix array assignments from non-lowered to lowered. */
|
||||
if (var &&
|
||||
_mesa_set_search(lower_vars, var) &&
|
||||
ir->rhs->type->without_array()->is_32bit()) {
|
||||
glsl_type_is_32bit(glsl_without_array(ir->rhs->type))) {
|
||||
fix_types_in_deref_chain(lhs);
|
||||
/* Convert to 16 bits for LHS. */
|
||||
convert_split_assignment(lhs, ir->rhs, true);
|
||||
@@ -1141,17 +1142,17 @@ lower_variables_visitor::visit_enter(ir_assignment *ir)
|
||||
if (var &&
|
||||
_mesa_set_search(lower_vars, var)) {
|
||||
/* Fix the LHS type. */
|
||||
if (lhs->type->without_array()->is_32bit())
|
||||
if (glsl_type_is_32bit(glsl_without_array(lhs->type)))
|
||||
fix_types_in_deref_chain(lhs);
|
||||
|
||||
/* Fix the RHS type if it's a lowered variable. */
|
||||
if (rhs_var &&
|
||||
_mesa_set_search(lower_vars, rhs_var) &&
|
||||
rhs_deref->type->without_array()->is_32bit())
|
||||
glsl_type_is_32bit(glsl_without_array(rhs_deref->type)))
|
||||
fix_types_in_deref_chain(rhs_deref);
|
||||
|
||||
/* Fix the RHS type if it's a non-array expression. */
|
||||
if (ir->rhs->type->is_32bit()) {
|
||||
if (glsl_type_is_32bit(ir->rhs->type)) {
|
||||
ir_expression *expr = ir->rhs->as_expression();
|
||||
|
||||
/* Convert the RHS to the LHS type. */
|
||||
@@ -1159,7 +1160,7 @@ lower_variables_visitor::visit_enter(ir_assignment *ir)
|
||||
(expr->operation == ir_unop_f162f ||
|
||||
expr->operation == ir_unop_i2i ||
|
||||
expr->operation == ir_unop_u2u) &&
|
||||
expr->operands[0]->type->is_16bit()) {
|
||||
glsl_type_is_16bit(expr->operands[0]->type)) {
|
||||
/* If there is an "up" conversion, just remove it.
|
||||
* This is optional. We could as well execute the else statement and
|
||||
* let NIR eliminate the up+down conversions.
|
||||
@@ -1187,7 +1188,7 @@ lower_variables_visitor::visit_enter(ir_return *ir)
|
||||
/* Fix the type of the return value. */
|
||||
if (var &&
|
||||
_mesa_set_search(lower_vars, var) &&
|
||||
deref->type->without_array()->is_32bit()) {
|
||||
glsl_type_is_32bit(glsl_without_array(deref->type))) {
|
||||
/* Create a 32-bit temporary variable. */
|
||||
ir_variable *new_var =
|
||||
new(mem_ctx) ir_variable(deref->type, "lowerp", ir_var_temporary);
|
||||
@@ -1225,8 +1226,8 @@ void lower_variables_visitor::handle_rvalue(ir_rvalue **rvalue)
|
||||
expr->operation == ir_unop_f2f16 ||
|
||||
expr->operation == ir_unop_i2i ||
|
||||
expr->operation == ir_unop_u2u) &&
|
||||
expr->type->without_array()->is_16bit() &&
|
||||
expr_op0_deref->type->without_array()->is_32bit() &&
|
||||
glsl_type_is_16bit(glsl_without_array(expr->type)) &&
|
||||
glsl_type_is_32bit(glsl_without_array(expr_op0_deref->type)) &&
|
||||
expr_op0_deref->variable_referenced() &&
|
||||
_mesa_set_search(lower_vars, expr_op0_deref->variable_referenced())) {
|
||||
fix_types_in_deref_chain(expr_op0_deref);
|
||||
@@ -1244,7 +1245,7 @@ void lower_variables_visitor::handle_rvalue(ir_rvalue **rvalue)
|
||||
/* var can be NULL if we are dereferencing ir_constant. */
|
||||
if (var &&
|
||||
_mesa_set_search(lower_vars, var) &&
|
||||
deref->type->without_array()->is_32bit()) {
|
||||
glsl_type_is_32bit(glsl_without_array(deref->type))) {
|
||||
void *mem_ctx = ralloc_parent(ir);
|
||||
|
||||
/* Create a 32-bit temporary variable. */
|
||||
@@ -1283,7 +1284,7 @@ lower_variables_visitor::visit_enter(ir_call *ir)
|
||||
/* var can be NULL if we are dereferencing ir_constant. */
|
||||
if (var &&
|
||||
_mesa_set_search(lower_vars, var) &&
|
||||
param->type->without_array()->is_32bit()) {
|
||||
glsl_type_is_32bit(glsl_without_array(param->type))) {
|
||||
fix_types_in_deref_chain(param_deref);
|
||||
|
||||
/* Create a 32-bit temporary variable for the parameter. */
|
||||
@@ -1316,7 +1317,7 @@ lower_variables_visitor::visit_enter(ir_call *ir)
|
||||
|
||||
if (ret_var &&
|
||||
_mesa_set_search(lower_vars, ret_var) &&
|
||||
ret_deref->type->without_array()->is_32bit()) {
|
||||
glsl_type_is_32bit(glsl_without_array(ret_deref->type))) {
|
||||
/* Create a 32-bit temporary variable. */
|
||||
ir_variable *new_var =
|
||||
new(mem_ctx) ir_variable(ir->callee->return_type, "lowerp",
|
||||
|
||||
@@ -93,7 +93,7 @@ lower_subroutine_visitor::visit_leave(ir_call *ir)
|
||||
bool is_compat = false;
|
||||
|
||||
for (int i = 0; i < fn->num_subroutine_types; i++) {
|
||||
if (ir->sub_var->type->without_array() == fn->subroutine_types[i]) {
|
||||
if (glsl_without_array(ir->sub_var->type) == fn->subroutine_types[i]) {
|
||||
is_compat = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ vector_deref_visitor::visit_enter(ir_assignment *ir)
|
||||
return ir_rvalue_enter_visitor::visit_enter(ir);
|
||||
|
||||
ir_dereference_array *const deref = (ir_dereference_array *) ir->lhs;
|
||||
if (!deref->array->type->is_vector())
|
||||
if (!glsl_type_is_vector(deref->array->type))
|
||||
return ir_rvalue_enter_visitor::visit_enter(ir);
|
||||
|
||||
/* SSBOs and shared variables are backed by memory and may be accessed by
|
||||
@@ -172,7 +172,7 @@ vector_deref_visitor::handle_rvalue(ir_rvalue **rv)
|
||||
return;
|
||||
|
||||
ir_dereference_array *const deref = (ir_dereference_array *) *rv;
|
||||
if (!deref->array->type->is_vector())
|
||||
if (!glsl_type_is_vector(deref->array->type))
|
||||
return;
|
||||
|
||||
/* Back-ends need to be able to handle derefs on vectors for SSBOs, UBOs,
|
||||
|
||||
@@ -106,7 +106,7 @@ is_valid_vec_const(ir_constant *ir)
|
||||
if (ir == NULL)
|
||||
return false;
|
||||
|
||||
if (!ir->type->is_scalar() && !ir->type->is_vector())
|
||||
if (!glsl_type_is_scalar(ir->type) && !glsl_type_is_vector(ir->type))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@@ -115,7 +115,7 @@ is_valid_vec_const(ir_constant *ir)
|
||||
static inline bool
|
||||
is_less_than_one(ir_constant *ir)
|
||||
{
|
||||
assert(ir->type->is_float());
|
||||
assert(glsl_type_is_float(ir->type));
|
||||
|
||||
if (!is_valid_vec_const(ir))
|
||||
return false;
|
||||
@@ -132,7 +132,7 @@ is_less_than_one(ir_constant *ir)
|
||||
static inline bool
|
||||
is_greater_than_zero(ir_constant *ir)
|
||||
{
|
||||
assert(ir->type->is_float());
|
||||
assert(glsl_type_is_float(ir->type));
|
||||
|
||||
if (!is_valid_vec_const(ir))
|
||||
return false;
|
||||
@@ -149,7 +149,7 @@ is_greater_than_zero(ir_constant *ir)
|
||||
static void
|
||||
update_type(ir_expression *ir)
|
||||
{
|
||||
if (ir->operands[0]->type->is_vector())
|
||||
if (glsl_type_is_vector(ir->operands[0]->type))
|
||||
ir->type = ir->operands[0]->type;
|
||||
else
|
||||
ir->type = ir->operands[1]->type;
|
||||
@@ -188,10 +188,10 @@ ir_algebraic_visitor::reassociate_constant(ir_expression *ir1, int const_index,
|
||||
return false;
|
||||
|
||||
/* Don't want to even think about matrices. */
|
||||
if (ir1->operands[0]->type->is_matrix() ||
|
||||
ir1->operands[1]->type->is_matrix() ||
|
||||
ir2->operands[0]->type->is_matrix() ||
|
||||
ir2->operands[1]->type->is_matrix())
|
||||
if (glsl_type_is_matrix(ir1->operands[0]->type) ||
|
||||
glsl_type_is_matrix(ir1->operands[1]->type) ||
|
||||
glsl_type_is_matrix(ir2->operands[0]->type) ||
|
||||
glsl_type_is_matrix(ir2->operands[1]->type))
|
||||
return false;
|
||||
|
||||
void *mem_ctx = ralloc_parent(ir2);
|
||||
@@ -234,7 +234,7 @@ ir_rvalue *
|
||||
ir_algebraic_visitor::swizzle_if_required(ir_expression *expr,
|
||||
ir_rvalue *operand)
|
||||
{
|
||||
if (expr->type->is_vector() && operand->type->is_scalar()) {
|
||||
if (glsl_type_is_vector(expr->type) && glsl_type_is_scalar(operand->type)) {
|
||||
return new(mem_ctx) ir_swizzle(operand, 0, 0, 0, 0,
|
||||
expr->type->vector_elements);
|
||||
} else
|
||||
@@ -248,13 +248,13 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
|
||||
ir_expression *op_expr[4] = {NULL, NULL, NULL, NULL};
|
||||
|
||||
if (ir->operation == ir_binop_mul &&
|
||||
ir->operands[0]->type->is_matrix() &&
|
||||
ir->operands[1]->type->is_vector()) {
|
||||
glsl_type_is_matrix(ir->operands[0]->type) &&
|
||||
glsl_type_is_vector(ir->operands[1]->type)) {
|
||||
ir_expression *matrix_mul = ir->operands[0]->as_expression();
|
||||
|
||||
if (matrix_mul && matrix_mul->operation == ir_binop_mul &&
|
||||
matrix_mul->operands[0]->type->is_matrix() &&
|
||||
matrix_mul->operands[1]->type->is_matrix()) {
|
||||
glsl_type_is_matrix(matrix_mul->operands[0]->type) &&
|
||||
glsl_type_is_matrix(matrix_mul->operands[1]->type)) {
|
||||
|
||||
return mul(matrix_mul->operands[0],
|
||||
mul(matrix_mul->operands[1], ir->operands[1]));
|
||||
@@ -263,7 +263,7 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
|
||||
|
||||
assert(ir->num_operands <= 4);
|
||||
for (unsigned i = 0; i < ir->num_operands; i++) {
|
||||
if (ir->operands[i]->type->is_matrix())
|
||||
if (glsl_type_is_matrix(ir->operands[i]->type))
|
||||
return ir;
|
||||
|
||||
op_const[i] =
|
||||
@@ -298,7 +298,7 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
|
||||
|
||||
case ir_binop_min:
|
||||
case ir_binop_max:
|
||||
if (!ir->type->is_float())
|
||||
if (!glsl_type_is_float(ir->type))
|
||||
break;
|
||||
|
||||
/* Replace min(max) operations and its commutative combinations with
|
||||
|
||||
@@ -140,7 +140,7 @@ do_dead_code(exec_list *instructions)
|
||||
}
|
||||
}
|
||||
|
||||
if (entry->var->type->is_subroutine())
|
||||
if (glsl_type_is_subroutine(entry->var->type))
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ public:
|
||||
{
|
||||
foreach_in_list_safe(assignment_entry, entry, this->assignments) {
|
||||
if (entry->lhs == var) {
|
||||
if (var->type->is_scalar() || var->type->is_vector()) {
|
||||
if (glsl_type_is_scalar(var->type) || glsl_type_is_vector(var->type)) {
|
||||
if (debug)
|
||||
printf("used %s (0x%01x - 0x%01x)\n", entry->lhs->name,
|
||||
entry->unused, used & 0xf);
|
||||
@@ -199,8 +199,8 @@ process_assignment(linear_ctx *lin_ctx, ir_assignment *ir, exec_list *assignment
|
||||
/* If it's a vector type, we can do per-channel elimination of
|
||||
* use of the RHS.
|
||||
*/
|
||||
if (deref_var && (deref_var->var->type->is_scalar() ||
|
||||
deref_var->var->type->is_vector())) {
|
||||
if (deref_var && (glsl_type_is_scalar(deref_var->var->type) ||
|
||||
glsl_type_is_vector(deref_var->var->type))) {
|
||||
|
||||
if (debug)
|
||||
printf("looking for %s.0x%01x to remove\n", var->name,
|
||||
|
||||
@@ -70,8 +70,8 @@ ir_visitor_status
|
||||
matrix_flipper::visit_enter(ir_expression *ir)
|
||||
{
|
||||
if (ir->operation != ir_binop_mul ||
|
||||
!ir->operands[0]->type->is_matrix() ||
|
||||
!ir->operands[1]->type->is_vector())
|
||||
!glsl_type_is_matrix(ir->operands[0]->type) ||
|
||||
!glsl_type_is_vector(ir->operands[1]->type))
|
||||
return visit_continue;
|
||||
|
||||
ir_variable *mat_var = ir->operands[0]->variable_referenced();
|
||||
|
||||
@@ -143,7 +143,7 @@ should_replace_variable(ir_variable *sig_param, ir_rvalue *param,
|
||||
/* Some places in glsl_to_nir() expect images to always be copied to a temp
|
||||
* first.
|
||||
*/
|
||||
if (sig_param->type->without_array()->is_image() && !param->is_dereference())
|
||||
if (glsl_type_is_image(glsl_without_array(sig_param->type)) && !param->is_dereference())
|
||||
return false;
|
||||
|
||||
/* SSBO and shared vars might be passed to a built-in such as an atomic
|
||||
@@ -163,7 +163,7 @@ should_replace_variable(ir_variable *sig_param, ir_rvalue *param,
|
||||
* the location information, which an assignment of an opaque
|
||||
* variable wouldn't.
|
||||
*/
|
||||
return sig_param->type->contains_opaque();
|
||||
return glsl_contains_opaque(sig_param->type);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -98,9 +98,9 @@ compare_components(ir_constant *a, ir_constant *b)
|
||||
|
||||
assert(a->type->base_type == b->type->base_type);
|
||||
|
||||
unsigned a_inc = a->type->is_scalar() ? 0 : 1;
|
||||
unsigned b_inc = b->type->is_scalar() ? 0 : 1;
|
||||
unsigned components = MAX2(a->type->components(), b->type->components());
|
||||
unsigned a_inc = glsl_type_is_scalar(a->type) ? 0 : 1;
|
||||
unsigned b_inc = glsl_type_is_scalar(b->type) ? 0 : 1;
|
||||
unsigned components = MAX2(glsl_get_components(a->type), glsl_get_components(b->type));
|
||||
|
||||
bool foundless = false;
|
||||
bool foundgreater = false;
|
||||
@@ -197,7 +197,7 @@ combine_constant(bool ismin, ir_constant *a, ir_constant *b)
|
||||
{
|
||||
void *mem_ctx = ralloc_parent(a);
|
||||
ir_constant *c = a->clone(mem_ctx, NULL);
|
||||
for (unsigned i = 0; i < c->type->components(); i++) {
|
||||
for (unsigned i = 0; i < glsl_get_components(c->type); i++) {
|
||||
switch (c->type->base_type) {
|
||||
case GLSL_TYPE_UINT16:
|
||||
if ((ismin && b->value.u16[i] < c->value.u16[i]) ||
|
||||
@@ -490,7 +490,7 @@ ir_minmax_visitor::prune_expression(ir_expression *expr, minmax_range baserange)
|
||||
static ir_rvalue *
|
||||
swizzle_if_required(ir_expression *expr, ir_rvalue *rval)
|
||||
{
|
||||
if (expr->type->is_vector() && rval->type->is_scalar()) {
|
||||
if (glsl_type_is_vector(expr->type) && glsl_type_is_scalar(rval->type)) {
|
||||
return swizzle(rval, SWIZZLE_XXXX, expr->type->vector_elements);
|
||||
} else {
|
||||
return rval;
|
||||
|
||||
@@ -233,9 +233,9 @@ is_reduction(ir_instruction *ir, void *data)
|
||||
* constant fold once split up. Handling matrices will need some more
|
||||
* work.
|
||||
*/
|
||||
if (expr->type->is_matrix() ||
|
||||
expr->operands[0]->type->is_matrix() ||
|
||||
(expr->operands[1] && expr->operands[1]->type->is_matrix())) {
|
||||
if (glsl_type_is_matrix(expr->type) ||
|
||||
glsl_type_is_matrix(expr->operands[0]->type) ||
|
||||
(expr->operands[1] && glsl_type_is_matrix(expr->operands[1]->type))) {
|
||||
ird->is_reduction = false;
|
||||
return;
|
||||
}
|
||||
@@ -288,10 +288,10 @@ update_types(ir_instruction *ir, void *)
|
||||
return;
|
||||
|
||||
const glsl_type *const new_type =
|
||||
glsl_type::get_instance(expr->type->base_type,
|
||||
MAX2(expr->operands[0]->type->vector_elements,
|
||||
expr->operands[1]->type->vector_elements),
|
||||
1);
|
||||
glsl_simple_type(expr->type->base_type,
|
||||
MAX2(expr->operands[0]->type->vector_elements,
|
||||
expr->operands[1]->type->vector_elements),
|
||||
1);
|
||||
assert(new_type != &glsl_type_builtin_error);
|
||||
expr->type = new_type;
|
||||
}
|
||||
|
||||
@@ -379,7 +379,7 @@ tree_grafting_basic_block(ir_instruction *bb_first,
|
||||
* any image layout qualifiers (including the image format) are set,
|
||||
* since we must not lose those.
|
||||
*/
|
||||
if (lhs_var->type->is_sampler() || lhs_var->type->is_image())
|
||||
if (glsl_type_is_sampler(lhs_var->type) || glsl_type_is_image(lhs_var->type))
|
||||
continue;
|
||||
|
||||
ir_variable_refcount_entry *entry = info->refs->get_variable_entry(lhs_var);
|
||||
|
||||
@@ -480,7 +480,7 @@ write_uniforms(struct blob *metadata, struct gl_shader_program *prog)
|
||||
for (unsigned i = 0; i < prog->data->NumUniformStorage; i++) {
|
||||
if (has_uniform_storage(prog, i)) {
|
||||
unsigned vec_size =
|
||||
prog->data->UniformStorage[i].type->component_slots() *
|
||||
glsl_get_component_slots(prog->data->UniformStorage[i].type) *
|
||||
MAX2(prog->data->UniformStorage[i].array_elements, 1);
|
||||
unsigned slot =
|
||||
prog->data->UniformStorage[i].storage -
|
||||
@@ -550,7 +550,7 @@ read_uniforms(struct blob_reader *metadata, struct gl_shader_program *prog)
|
||||
for (unsigned i = 0; i < prog->data->NumUniformStorage; i++) {
|
||||
if (has_uniform_storage(prog, i)) {
|
||||
unsigned vec_size =
|
||||
prog->data->UniformStorage[i].type->component_slots() *
|
||||
glsl_get_component_slots(prog->data->UniformStorage[i].type) *
|
||||
MAX2(prog->data->UniformStorage[i].array_elements, 1);
|
||||
unsigned slot =
|
||||
prog->data->UniformStorage[i].storage -
|
||||
|
||||
@@ -102,13 +102,13 @@ array_refcount_test::SetUp()
|
||||
|
||||
/* The type of vec4 x[3][4][5]; */
|
||||
const glsl_type *const array_5_of_vec4 =
|
||||
glsl_type::get_array_instance(&glsl_type_builtin_vec4, 5);
|
||||
glsl_array_type(&glsl_type_builtin_vec4, 5, 0);
|
||||
const glsl_type *const array_4_of_array_5_of_vec4 =
|
||||
glsl_type::get_array_instance(array_5_of_vec4, 4);
|
||||
glsl_array_type(array_5_of_vec4, 4, 0);
|
||||
array_3_of_array_4_of_array_5_of_vec4 =
|
||||
glsl_type::get_array_instance(array_4_of_array_5_of_vec4, 3);
|
||||
glsl_array_type(array_4_of_array_5_of_vec4, 3, 0);
|
||||
|
||||
array_3_of_int = glsl_type::get_array_instance(&glsl_type_builtin_int, 3);
|
||||
array_3_of_int = glsl_array_type(&glsl_type_builtin_int, 3, 0);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -255,7 +255,7 @@ TEST_F(array_refcount_test, ir_array_refcount_entry_initial_state_for_array)
|
||||
new(mem_ctx) ir_variable(array_3_of_array_4_of_array_5_of_vec4,
|
||||
"a",
|
||||
ir_var_auto);
|
||||
const unsigned total_elements = var->type->arrays_of_arrays_size();
|
||||
const unsigned total_elements = glsl_get_aoa_size(var->type);
|
||||
|
||||
ir_array_refcount_entry entry(var);
|
||||
|
||||
@@ -274,7 +274,7 @@ TEST_F(array_refcount_test, mark_array_elements_referenced_simple)
|
||||
new(mem_ctx) ir_variable(array_3_of_array_4_of_array_5_of_vec4,
|
||||
"a",
|
||||
ir_var_auto);
|
||||
const unsigned total_elements = var->type->arrays_of_arrays_size();
|
||||
const unsigned total_elements = glsl_get_aoa_size(var->type);
|
||||
|
||||
ir_array_refcount_entry entry(var);
|
||||
|
||||
@@ -486,7 +486,7 @@ TEST_F(array_refcount_test, do_not_process_array_inside_structure)
|
||||
};
|
||||
|
||||
const glsl_type *const record_of_array_3_of_int =
|
||||
glsl_type::get_struct_instance(fields, ARRAY_SIZE(fields), "S");
|
||||
glsl_struct_type(fields, ARRAY_SIZE(fields), "S", false /* packed */);
|
||||
|
||||
ir_variable *var_a = new(mem_ctx) ir_variable(&glsl_type_builtin_int,
|
||||
"a",
|
||||
@@ -541,7 +541,7 @@ TEST_F(array_refcount_test, visit_simple_indexing)
|
||||
|
||||
const unsigned accessed_element = 0 + (1 * 5) + (2 * 4 * 5);
|
||||
ir_array_refcount_entry *entry_b = v.get_variable_entry(var_b);
|
||||
const unsigned total_elements = var_b->type->arrays_of_arrays_size();
|
||||
const unsigned total_elements = glsl_get_aoa_size(var_b->type);
|
||||
|
||||
for (unsigned i = 0; i < total_elements; i++)
|
||||
EXPECT_EQ(i == accessed_element, entry_b->is_linearized_index_referenced(i)) <<
|
||||
@@ -636,7 +636,7 @@ TEST_F(array_refcount_test, visit_array_indexing_an_array)
|
||||
|
||||
ir_array_refcount_entry *const entry_c = v.get_variable_entry(var_c);
|
||||
|
||||
for (int i = 0; i < var_c->type->array_size(); i++) {
|
||||
for (int i = 0; i < glsl_array_size(var_c->type); i++) {
|
||||
EXPECT_EQ(true, entry_c->is_linearized_index_referenced(i)) <<
|
||||
"array c, i = " << i;
|
||||
}
|
||||
@@ -647,10 +647,10 @@ TEST_F(array_refcount_test, visit_array_indexing_an_array)
|
||||
TEST_F(array_refcount_test, visit_array_indexing_with_itself)
|
||||
{
|
||||
const glsl_type *const array_2_of_array_3_of_int =
|
||||
glsl_type::get_array_instance(array_3_of_int, 2);
|
||||
glsl_array_type(array_3_of_int, 2, 0);
|
||||
|
||||
const glsl_type *const array_2_of_array_2_of_array_3_of_int =
|
||||
glsl_type::get_array_instance(array_2_of_array_3_of_int, 2);
|
||||
glsl_array_type(array_2_of_array_3_of_int, 2, 0);
|
||||
|
||||
ir_variable *var_a = new(mem_ctx) ir_variable(&glsl_type_builtin_int,
|
||||
"a",
|
||||
|
||||
@@ -327,7 +327,7 @@ TEST_F(geometry_builtin, inputs_have_explicit_location)
|
||||
EXPECT_FALSE(var->data.explicit_location);
|
||||
EXPECT_EQ(-1, var->data.location);
|
||||
|
||||
ASSERT_TRUE(var->type->is_array());
|
||||
ASSERT_TRUE(glsl_type_is_array(var->type));
|
||||
|
||||
const glsl_type *const instance_type = var->type->fields.array;
|
||||
|
||||
|
||||
@@ -48,15 +48,15 @@ TEST_F(ir_variable_constructor, interface)
|
||||
void *mem_ctx = ralloc_context(NULL);
|
||||
|
||||
static const glsl_struct_field f[] = {
|
||||
glsl_struct_field(glsl_type::vec(4), "v")
|
||||
glsl_struct_field(glsl_vec_type(4), "v")
|
||||
};
|
||||
|
||||
const glsl_type *const iface =
|
||||
glsl_type::get_interface_instance(f,
|
||||
ARRAY_SIZE(f),
|
||||
GLSL_INTERFACE_PACKING_STD140,
|
||||
false,
|
||||
"simple_interface");
|
||||
glsl_interface_type(f,
|
||||
ARRAY_SIZE(f),
|
||||
GLSL_INTERFACE_PACKING_STD140,
|
||||
false,
|
||||
"simple_interface");
|
||||
|
||||
static const char name[] = "named_instance";
|
||||
|
||||
@@ -76,18 +76,17 @@ TEST_F(ir_variable_constructor, interface_array)
|
||||
void *mem_ctx = ralloc_context(NULL);
|
||||
|
||||
static const glsl_struct_field f[] = {
|
||||
glsl_struct_field(glsl_type::vec(4), "v")
|
||||
glsl_struct_field(glsl_vec_type(4), "v")
|
||||
};
|
||||
|
||||
const glsl_type *const iface =
|
||||
glsl_type::get_interface_instance(f,
|
||||
ARRAY_SIZE(f),
|
||||
GLSL_INTERFACE_PACKING_STD140,
|
||||
false,
|
||||
"simple_interface");
|
||||
glsl_interface_type(f,
|
||||
ARRAY_SIZE(f),
|
||||
GLSL_INTERFACE_PACKING_STD140,
|
||||
false,
|
||||
"simple_interface");
|
||||
|
||||
const glsl_type *const interface_array =
|
||||
glsl_type::get_array_instance(iface, 2);
|
||||
const glsl_type *const interface_array = glsl_array_type(iface, 2, 0);
|
||||
|
||||
static const char name[] = "array_instance";
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ TEST(sampler_types, TYPE) \
|
||||
EXPECT_EQ(DATA_TYPE, type->sampled_type); \
|
||||
ARR; \
|
||||
SHAD; \
|
||||
EXPECT_EQ(COMPS, type->coordinate_components()); \
|
||||
EXPECT_EQ(COMPS, glsl_get_sampler_coordinate_components(type)); \
|
||||
}
|
||||
|
||||
T( sampler1D, GLSL_SAMPLER_DIM_1D, GLSL_TYPE_FLOAT, NONARRAY, COLOR, 1)
|
||||
|
||||
Reference in New Issue
Block a user