glsl_get_length(type));
}
- assert(glsl_type_is_struct(type));
+ assert(glsl_type_is_struct_or_ifc(type));
LLVMTypeRef member_types[glsl_get_length(type)];
mark_16bit_fs_input(ctx, glsl_get_array_element(type), location + i * stride);
}
} else {
- assert(glsl_type_is_struct(type));
+ assert(glsl_type_is_struct_or_ifc(type));
for (unsigned i = 0; i < glsl_get_length(type); i++) {
mark_16bit_fs_input(ctx, glsl_get_struct_field(type, i), location);
location += glsl_count_attribute_slots(glsl_get_struct_field(type, i), false);
{
const struct glsl_type *t_without_array = glsl_without_array(type);
- if (glsl_type_is_struct(type)) {
+ if (glsl_type_is_struct_or_ifc(type)) {
for (unsigned int i = 0; i < glsl_get_length(type); i++) {
const struct glsl_type *field_type = glsl_get_struct_field(type, i);
set_uniform_initializer(data, field_type, val->elements[i]);
return;
}
- if (glsl_type_is_struct(t_without_array) ||
+ if (glsl_type_is_struct_or_ifc(t_without_array) ||
(glsl_type_is_array(type) &&
glsl_type_is_array(glsl_get_array_element(type)))) {
const struct glsl_type *element_type = glsl_get_array_element(type);
entry->array_size = glsl_get_length(type);
entry->children = build_type_tree_for_type(glsl_get_array_element(type));
entry->children->parent = entry;
- } else if (glsl_type_is_struct(type)) {
+ } else if (glsl_type_is_struct_or_ifc(type)) {
struct type_tree_entry *last = NULL;
for (unsigned i = 0; i < glsl_get_length(type); i++) {
* composite type or an array where each element occupies more than one
* location than we need to recursively process it.
*/
- if (glsl_type_is_struct(type) ||
+ if (glsl_type_is_struct_or_ifc(type) ||
(glsl_type_is_array(type) &&
(glsl_type_is_array(glsl_get_array_element(type)) ||
- glsl_type_is_struct(glsl_get_array_element(type))))) {
+ glsl_type_is_struct_or_ifc(glsl_get_array_element(type))))) {
int location_count = 0;
struct type_tree_entry *old_type = state->current_type;
for (unsigned i = 0; i < glsl_get_length(type); i++) {
const struct glsl_type *field_type;
- if (glsl_type_is_struct(type))
+ if (glsl_type_is_struct_or_ifc(type))
field_type = glsl_get_struct_field(type, i);
else
field_type = glsl_get_array_element(type);
location += entries;
location_count += entries;
- if (glsl_type_is_struct(type))
+ if (glsl_type_is_struct_or_ifc(type))
state->current_type = state->current_type->next_sibling;
}
location_offset += child_outputs;
dest_offset += component_slots;
}
- } else if (glsl_type_is_struct(type)) {
+ } else if (glsl_type_is_struct_or_ifc(type)) {
unsigned length = glsl_get_length(type);
for (unsigned i = 0; i < length; i++) {
const struct glsl_type *child_type = glsl_get_struct_field(type, i);
nir_build_deref_struct(nir_builder *build, nir_deref_instr *parent,
unsigned index)
{
- assert(glsl_type_is_struct(parent->type));
+ assert(glsl_type_is_struct_or_ifc(parent->type));
nir_deref_instr *deref =
nir_deref_instr_create(build->shader, nir_deref_type_struct);
}
case nir_deref_type_struct:
- assert(glsl_type_is_struct(parent->type));
+ assert(glsl_type_is_struct_or_ifc(parent->type));
assert(glsl_get_length(parent->type) ==
glsl_get_length(leader_parent->type));
glsl_type_size_align_func size_align,
unsigned field_idx)
{
- assert(glsl_type_is_struct(struct_type));
+ assert(glsl_type_is_struct_or_ifc(struct_type));
unsigned offset = 0;
for (unsigned i = 0; i <= field_idx; i++) {
unsigned elem_size, elem_align;
glsl_type_get_sampler_count(glsl_without_array(type)));
}
- if (glsl_type_is_struct(type)) {
+ if (glsl_type_is_struct_or_ifc(type)) {
unsigned count = 0;
for (int i = 0; i < glsl_get_length(type); i++)
count += glsl_type_get_sampler_count(glsl_get_struct_field(type, i));
glsl_type_get_image_count(glsl_without_array(type)));
}
- if (glsl_type_is_struct(type)) {
+ if (glsl_type_is_struct_or_ifc(type)) {
unsigned count = 0;
for (int i = 0; i < glsl_get_length(type); i++)
count += glsl_type_get_image_count(glsl_get_struct_field(type, i));
const struct glsl_type *child_type = glsl_get_array_element(type);
for (unsigned i = 0; i < length; i++)
add_var_xfb_outputs(xfb, var, buffer, location, offset, child_type);
- } else if (glsl_type_is_struct(type)) {
+ } else if (glsl_type_is_struct_or_ifc(type)) {
unsigned length = glsl_get_length(type);
for (unsigned i = 0; i < length; i++) {
const struct glsl_type *child_type = glsl_get_struct_field(type, i);
add_var_xfb_outputs(xfb, var, var->data.xfb_buffer,
&location, &offset, var->type);
} else if (is_array_block) {
- assert(glsl_type_is_struct(var->interface_type));
+ assert(glsl_type_is_struct_or_ifc(var->interface_type));
unsigned aoa_size = glsl_get_aoa_size(var->type);
const struct glsl_type *itype = var->interface_type;
if (glsl_type_is_array(out_var->type) ||
glsl_type_is_dual_slot(out_var->type) ||
glsl_type_is_matrix(out_var->type) ||
- glsl_type_is_struct(out_var->type))
+ glsl_type_is_struct_or_ifc(out_var->type))
return false;
/* Limit this pass to scalars for now to keep things simple. Most varyings
nir_store_deref(b, nir_build_deref_array(b, deref, nir_imm_int(b, i)),
&load->def, ~0);
}
- } else if (glsl_type_is_struct(deref->type)) {
+ } else if (glsl_type_is_struct_or_ifc(deref->type)) {
unsigned len = glsl_get_length(deref->type);
for (unsigned i = 0; i < len; i++) {
build_constant_load(b, nir_build_deref_struct(b, deref, i),
* TODO: Add support for struct splitting.
*/
if ((!glsl_type_is_array(type) && !glsl_type_is_matrix(type))||
- glsl_type_is_struct(glsl_without_array(type)))
+ glsl_type_is_struct_or_ifc(glsl_without_array(type)))
continue;
/* Skip builtins */
/* Skip types we cannot split */
if (glsl_type_is_matrix(glsl_without_array(var->type)) ||
- glsl_type_is_struct(glsl_without_array(var->type)))
+ glsl_type_is_struct_or_ifc(glsl_without_array(var->type)))
continue;
switch (intr->intrinsic) {
switch (deref->deref_type) {
case nir_deref_type_struct:
- assert(glsl_type_is_struct(parent->type));
+ assert(glsl_type_is_struct_or_ifc(parent->type));
assert(deref->strct.index < glsl_get_length(parent->type));
if (parent->children[deref->strct.index] == NULL) {
assert(glsl_get_explicit_stride(type) == 0);
return glsl_array_type(elem, glsl_get_length(type), 0);
} else {
- assert(glsl_type_is_struct(type));
+ assert(glsl_type_is_struct_or_ifc(type));
assert(index < glsl_get_length(type));
return glsl_get_struct_field(type, index);
}
assert(dst->type == src->type);
if (glsl_type_is_vector_or_scalar(src->type)) {
nir_copy_deref(b, dst, src);
- } else if (glsl_type_is_struct(src->type)) {
+ } else if (glsl_type_is_struct_or_ifc(src->type)) {
for (unsigned i = 0; i < glsl_get_length(src->type); i++) {
split_deref_copy_instr(b, nir_build_deref_struct(b, dst, i),
nir_build_deref_struct(b, src, i));
};
const struct glsl_type *struct_type = glsl_without_array(type);
- if (glsl_type_is_struct(struct_type)) {
+ if (glsl_type_is_struct_or_ifc(struct_type)) {
field->num_fields = glsl_get_length(struct_type),
field->fields = ralloc_array(state->mem_ctx, struct field,
field->num_fields);
* pull all of the variables we plan to split off of the list
*/
nir_foreach_variable_safe(var, vars) {
- if (!glsl_type_is_struct(glsl_without_array(var->type)))
+ if (!glsl_type_is_struct_or_ifc(glsl_without_array(var->type)))
continue;
exec_node_remove(&var->node);
continue;
assert(i > 0);
- assert(glsl_type_is_struct(path.path[i - 1]->type));
+ assert(glsl_type_is_struct_or_ifc(path.path[i - 1]->type));
assert(path.path[i - 1]->type ==
glsl_without_array(tail_field->type));
switch (instr->deref_type) {
case nir_deref_type_struct:
- validate_assert(state, glsl_type_is_struct(parent->type));
+ validate_assert(state, glsl_type_is_struct_or_ifc(parent->type));
validate_assert(state,
instr->strct.index < glsl_get_length(parent->type));
validate_assert(state, instr->type ==
if (var->num_members > 0) {
const struct glsl_type *without_array = glsl_without_array(var->type);
- validate_assert(state, glsl_type_is_struct(without_array));
+ validate_assert(state, glsl_type_is_struct_or_ifc(without_array));
validate_assert(state, var->num_members == glsl_get_length(without_array));
validate_assert(state, var->members != NULL);
}
}
bool
-glsl_type_is_struct(const struct glsl_type *type)
+glsl_type_is_struct_or_ifc(const struct glsl_type *type)
{
return type->is_struct() || type->is_interface();
}
bool glsl_type_is_array(const struct glsl_type *type);
bool glsl_type_is_array_of_arrays(const struct glsl_type *type);
bool glsl_type_is_array_or_matrix(const struct glsl_type *type);
-bool glsl_type_is_struct(const struct glsl_type *type);
+bool glsl_type_is_struct_or_ifc(const struct glsl_type *type);
bool glsl_type_is_sampler(const struct glsl_type *type);
bool glsl_type_is_image(const struct glsl_type *type);
bool glsl_type_is_dual_slot(const struct glsl_type *type);
break;
case SpvOpIAddCarry:
- vtn_assert(glsl_type_is_struct(val->ssa->type));
+ vtn_assert(glsl_type_is_struct_or_ifc(val->ssa->type));
val->ssa->elems[0]->def = nir_iadd(&b->nb, src[0], src[1]);
val->ssa->elems[1]->def = nir_uadd_carry(&b->nb, src[0], src[1]);
break;
case SpvOpISubBorrow:
- vtn_assert(glsl_type_is_struct(val->ssa->type));
+ vtn_assert(glsl_type_is_struct_or_ifc(val->ssa->type));
val->ssa->elems[0]->def = nir_isub(&b->nb, src[0], src[1]);
val->ssa->elems[1]->def = nir_usub_borrow(&b->nb, src[0], src[1]);
break;
case SpvOpUMulExtended: {
- vtn_assert(glsl_type_is_struct(val->ssa->type));
+ vtn_assert(glsl_type_is_struct_or_ifc(val->ssa->type));
nir_ssa_def *umul = nir_umul_2x32_64(&b->nb, src[0], src[1]);
val->ssa->elems[0]->def = nir_unpack_64_2x32_split_x(&b->nb, umul);
val->ssa->elems[1]->def = nir_unpack_64_2x32_split_y(&b->nb, umul);
}
case SpvOpSMulExtended: {
- vtn_assert(glsl_type_is_struct(val->ssa->type));
+ vtn_assert(glsl_type_is_struct_or_ifc(val->ssa->type));
nir_ssa_def *smul = nir_imul_2x32_64(&b->nb, src[0], src[1]);
val->ssa->elems[0]->def = nir_unpack_64_2x32_split_x(&b->nb, smul);
val->ssa->elems[1]->def = nir_unpack_64_2x32_split_y(&b->nb, smul);
case GLSLstd450ModfStruct: {
nir_ssa_def *sign = nir_fsign(nb, src[0]);
nir_ssa_def *abs = nir_fabs(nb, src[0]);
- vtn_assert(glsl_type_is_struct(val->ssa->type));
+ vtn_assert(glsl_type_is_struct_or_ifc(val->ssa->type));
val->ssa->elems[0]->def = nir_fmul(nb, sign, nir_ffract(nb, abs));
val->ssa->elems[1]->def = nir_fmul(nb, sign, nir_ffloor(nb, abs));
return;
}
case GLSLstd450FrexpStruct: {
- vtn_assert(glsl_type_is_struct(val->ssa->type));
+ vtn_assert(glsl_type_is_struct_or_ifc(val->ssa->type));
if (src[0]->bit_size == 64)
val->ssa->elems[0]->def = build_frexp64(nb, src[0],
&val->ssa->elems[1]->def);
nir_ssa_def *desc_array_index)
{
if (!desc_array_index) {
- vtn_assert(glsl_type_is_struct(var->type->type));
+ vtn_assert(glsl_type_is_struct_or_ifc(var->type->type));
desc_array_index = nir_imm_int(&b->nb, 0);
}
}
for (; idx < deref_chain->length; idx++) {
- if (glsl_type_is_struct(type->type)) {
+ if (glsl_type_is_struct_or_ifc(type->type)) {
vtn_assert(deref_chain->link[idx].mode == vtn_access_mode_literal);
unsigned field = deref_chain->link[idx].id;
tail = nir_build_deref_struct(&b->nb, tail, field);
_vtn_local_load_store(b, load, child, inout->elems[i]);
}
} else {
- vtn_assert(glsl_type_is_struct(deref->type));
+ vtn_assert(glsl_type_is_struct_or_ifc(deref->type));
unsigned elems = glsl_get_length(deref->type);
for (unsigned i = 0; i < elems; i++) {
nir_deref_instr *child = nir_build_deref_struct(&b->nb, deref, i);
var->patch = false;
vtn_foreach_decoration(b, val, var_is_patch_cb, &var->patch);
if (glsl_type_is_array(var->type->type) &&
- glsl_type_is_struct(without_array->type)) {
+ glsl_type_is_struct_or_ifc(without_array->type)) {
vtn_foreach_decoration(b, vtn_value(b, without_array->id,
vtn_value_type_type),
var_is_patch_cb, &var->patch);
* type is a composite type or an array where each element occupies
* more than one slot than we need to recursively process it.
*/
- if (glsl_type_is_struct(type)) {
+ if (glsl_type_is_struct_or_ifc(type)) {
unsigned location_count = 0;
for (unsigned i = 0; i < glsl_get_length(type); i++) {
const struct glsl_type *element_type = glsl_get_array_element(type);
if (glsl_type_is_array(element_type) ||
- glsl_type_is_struct(element_type)) {
+ glsl_type_is_struct_or_ifc(element_type)) {
unsigned element_count = count_uniform_storage_slots(element_type);
return element_count * glsl_get_length(type);
}
*/
unsigned comps;
- if (glsl_type_is_struct(type)) {
+ if (glsl_type_is_struct_or_ifc(type)) {
comps = 4;
} else {
comps = glsl_get_vector_elements(type);
const struct glsl_type *type = glsl_without_array(var->type);
for (unsigned int i = 0; i < var->num_state_slots; i++) {
unsigned comps;
- if (glsl_type_is_struct(type)) {
+ if (glsl_type_is_struct_or_ifc(type)) {
/* Builtin struct require specical handling for now we just
* make all members vec4. See st_nir_lower_builtin.
*/