mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-03-07 03:20:28 +01:00
r600/sfn: Use glsl_type C helpers
In one case, just used glsl_without_array instead of checking if its an array to decide to use. Using that helper with a non-array type just returns the type. Reviewed-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:
parent
55cde229d5
commit
2cbc318193
4 changed files with 28 additions and 28 deletions
|
|
@ -443,7 +443,7 @@ r600_nir_lower_atomics(nir_shader *shader)
|
|||
std::map<unsigned, nir_variable *> sorted_var;
|
||||
|
||||
nir_foreach_variable_with_modes_safe(var, shader, nir_var_uniform) {
|
||||
if (var->type->contains_atomic()) {
|
||||
if (glsl_contains_atomic(var->type)) {
|
||||
sorted_var[(var->data.binding << 16) | var->data.offset] = var;
|
||||
exec_node_remove(&var->node);
|
||||
}
|
||||
|
|
@ -451,7 +451,7 @@ r600_nir_lower_atomics(nir_shader *shader)
|
|||
|
||||
for (auto& [dummy, var] : sorted_var) {
|
||||
auto iindex = binding_offset.find(var->data.binding);
|
||||
unsigned offset_update = var->type->atomic_size() / 4; /* ATOMIC_COUNTER_SIZE */
|
||||
unsigned offset_update = glsl_atomic_size(var->type) / 4; /* ATOMIC_COUNTER_SIZE */
|
||||
if (iindex == binding_offset.end()) {
|
||||
var->data.index = 0;
|
||||
binding_offset[var->data.binding] = offset_update;
|
||||
|
|
|
|||
|
|
@ -391,7 +391,7 @@ nir_def *
|
|||
LowerSplit64BitVar::split_load_deref_array(nir_intrinsic_instr *intr, nir_src& index)
|
||||
{
|
||||
auto old_var = nir_intrinsic_get_var(intr, 0);
|
||||
unsigned old_components = old_var->type->without_array()->components();
|
||||
unsigned old_components = glsl_get_components(glsl_without_array(old_var->type));
|
||||
|
||||
assert(old_components > 2 && old_components <= 4);
|
||||
|
||||
|
|
@ -416,7 +416,7 @@ LowerSplit64BitVar::split_store_deref_array(nir_intrinsic_instr *intr,
|
|||
nir_deref_instr *deref)
|
||||
{
|
||||
auto old_var = nir_intrinsic_get_var(intr, 0);
|
||||
unsigned old_components = old_var->type->without_array()->components();
|
||||
unsigned old_components = glsl_get_components(glsl_without_array(old_var->type));
|
||||
|
||||
assert(old_components > 2 && old_components <= 4);
|
||||
|
||||
|
|
@ -453,7 +453,7 @@ LowerSplit64BitVar::split_store_deref_var(nir_intrinsic_instr *intr,
|
|||
UNUSED nir_deref_instr *deref)
|
||||
{
|
||||
auto old_var = nir_intrinsic_get_var(intr, 0);
|
||||
unsigned old_components = old_var->type->without_array()->components();
|
||||
unsigned old_components = glsl_get_components(glsl_without_array(old_var->type));
|
||||
|
||||
assert(old_components > 2 && old_components <= 4);
|
||||
|
||||
|
|
@ -481,7 +481,7 @@ LowerSplit64BitVar::split_load_deref_var(nir_intrinsic_instr *intr)
|
|||
{
|
||||
auto old_var = nir_intrinsic_get_var(intr, 0);
|
||||
auto vars = get_var_pair(old_var);
|
||||
unsigned old_components = old_var->type->components();
|
||||
unsigned old_components = glsl_get_components(old_var->type);
|
||||
|
||||
nir_deref_instr *deref1 = nir_build_deref_var(b, vars.first);
|
||||
auto *load1 = nir_load_deref(b, deref1);
|
||||
|
|
@ -499,18 +499,18 @@ LowerSplit64BitVar::get_var_pair(nir_variable *old_var)
|
|||
{
|
||||
auto split_vars = m_varmap.find(old_var->data.driver_location);
|
||||
|
||||
assert(old_var->type->without_array()->components() > 2);
|
||||
assert(glsl_get_components(glsl_without_array(old_var->type)) > 2);
|
||||
|
||||
if (split_vars == m_varmap.end()) {
|
||||
auto var1 = nir_variable_clone(old_var, b->shader);
|
||||
auto var2 = nir_variable_clone(old_var, b->shader);
|
||||
|
||||
var1->type = glsl_dvec_type(2);
|
||||
var2->type = glsl_dvec_type(old_var->type->without_array()->components() - 2);
|
||||
var2->type = glsl_dvec_type(glsl_get_components(glsl_without_array(old_var->type)) - 2);
|
||||
|
||||
if (old_var->type->is_array()) {
|
||||
var1->type = glsl_array_type(var1->type, old_var->type->array_size(), 0);
|
||||
var2->type = glsl_array_type(var2->type, old_var->type->array_size(), 0);
|
||||
if (glsl_type_is_array(old_var->type)) {
|
||||
var1->type = glsl_array_type(var1->type, glsl_array_size(old_var->type), 0);
|
||||
var2->type = glsl_array_type(var2->type, glsl_array_size(old_var->type), 0);
|
||||
}
|
||||
|
||||
if (old_var->data.mode == nir_var_shader_in ||
|
||||
|
|
@ -838,9 +838,9 @@ Lower64BitToVec2::filter(const nir_instr *instr) const
|
|||
if (nir_src_bit_size(intr->src[1]) == 64)
|
||||
return true;
|
||||
auto var = nir_intrinsic_get_var(intr, 0);
|
||||
if (var->type->without_array()->bit_size() == 64)
|
||||
if (glsl_get_bit_size(glsl_without_array(var->type)) == 64)
|
||||
return true;
|
||||
return (var->type->without_array()->components() != intr->num_components);
|
||||
return (glsl_get_components(glsl_without_array(var->type)) != intr->num_components);
|
||||
}
|
||||
case nir_intrinsic_store_global:
|
||||
return nir_src_bit_size(intr->src[0]) == 64;
|
||||
|
|
@ -951,15 +951,15 @@ Lower64BitToVec2::load_deref_64_to_vec2(nir_intrinsic_instr *intr)
|
|||
{
|
||||
auto deref = nir_instr_as_deref(intr->src[0].ssa->parent_instr);
|
||||
auto var = nir_intrinsic_get_var(intr, 0);
|
||||
unsigned components = var->type->without_array()->components();
|
||||
if (var->type->without_array()->bit_size() == 64) {
|
||||
unsigned components = glsl_get_components(glsl_without_array(var->type));
|
||||
if (glsl_get_bit_size(glsl_without_array(var->type)) == 64) {
|
||||
components *= 2;
|
||||
if (deref->deref_type == nir_deref_type_var) {
|
||||
var->type = glsl_vec_type(components);
|
||||
} else if (deref->deref_type == nir_deref_type_array) {
|
||||
|
||||
var->type =
|
||||
glsl_array_type(glsl_vec_type(components), var->type->array_size(), 0);
|
||||
glsl_array_type(glsl_vec_type(components), glsl_array_size(var->type), 0);
|
||||
|
||||
} else {
|
||||
nir_print_shader(b->shader, stderr);
|
||||
|
|
@ -970,7 +970,7 @@ Lower64BitToVec2::load_deref_64_to_vec2(nir_intrinsic_instr *intr)
|
|||
if (deref->deref_type == nir_deref_type_array) {
|
||||
auto deref_array = nir_instr_as_deref(deref->parent.ssa->parent_instr);
|
||||
deref_array->type = var->type;
|
||||
deref->type = deref_array->type->without_array();
|
||||
deref->type = glsl_without_array(deref_array->type);
|
||||
}
|
||||
|
||||
intr->num_components = components;
|
||||
|
|
@ -985,15 +985,15 @@ Lower64BitToVec2::store_64_to_vec2(nir_intrinsic_instr *intr)
|
|||
auto deref = nir_instr_as_deref(intr->src[0].ssa->parent_instr);
|
||||
auto var = nir_intrinsic_get_var(intr, 0);
|
||||
|
||||
unsigned components = var->type->without_array()->components();
|
||||
unsigned components = glsl_get_components(glsl_without_array(var->type));
|
||||
unsigned wrmask = nir_intrinsic_write_mask(intr);
|
||||
if (var->type->without_array()->bit_size() == 64) {
|
||||
if (glsl_get_bit_size(glsl_without_array(var->type)) == 64) {
|
||||
components *= 2;
|
||||
if (deref->deref_type == nir_deref_type_var) {
|
||||
var->type = glsl_vec_type(components);
|
||||
} else if (deref->deref_type == nir_deref_type_array) {
|
||||
var->type =
|
||||
glsl_array_type(glsl_vec_type(components), var->type->array_size(), 0);
|
||||
glsl_array_type(glsl_vec_type(components), glsl_array_size(var->type), 0);
|
||||
} else {
|
||||
nir_print_shader(b->shader, stderr);
|
||||
assert(0 && "Only lowring of var and array derefs supported\n");
|
||||
|
|
@ -1003,7 +1003,7 @@ Lower64BitToVec2::store_64_to_vec2(nir_intrinsic_instr *intr)
|
|||
if (deref->deref_type == nir_deref_type_array) {
|
||||
auto deref_array = nir_instr_as_deref(deref->parent.ssa->parent_instr);
|
||||
deref_array->type = var->type;
|
||||
deref->type = deref_array->type->without_array();
|
||||
deref->type = glsl_without_array(deref_array->type);
|
||||
}
|
||||
intr->num_components = components;
|
||||
nir_intrinsic_set_write_mask(intr, wrmask == 1 ? 3 : 0xf);
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ r600_nir_lower_int_tg4(nir_shader *shader)
|
|||
|
||||
nir_foreach_uniform_variable(var, shader)
|
||||
{
|
||||
if (var->type->is_sampler()) {
|
||||
if (glsl_type_is_sampler(var->type)) {
|
||||
if (glsl_base_type_is_integer(var->type->sampled_type)) {
|
||||
need_lowering = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -581,11 +581,11 @@ Shader::scan_shader(const nir_function *func)
|
|||
bool
|
||||
Shader::scan_uniforms(nir_variable *uniform)
|
||||
{
|
||||
if (uniform->type->contains_atomic()) {
|
||||
int natomics = uniform->type->atomic_size() / 4; /* ATOMIC_COUNTER_SIZE */
|
||||
if (glsl_contains_atomic(uniform->type)) {
|
||||
int natomics = glsl_atomic_size(uniform->type) / 4; /* ATOMIC_COUNTER_SIZE */
|
||||
m_nhwatomic += natomics;
|
||||
|
||||
if (uniform->type->is_array())
|
||||
if (glsl_type_is_array(uniform->type))
|
||||
m_indirect_files |= 1 << TGSI_FILE_HW_ATOMIC;
|
||||
|
||||
m_flags.set(sh_uses_atomics);
|
||||
|
|
@ -610,10 +610,10 @@ Shader::scan_uniforms(nir_variable *uniform)
|
|||
m_atomics.push_back(atom);
|
||||
}
|
||||
|
||||
auto type = uniform->type->is_array() ? uniform->type->without_array() : uniform->type;
|
||||
if (type->is_image() || uniform->data.mode == nir_var_mem_ssbo) {
|
||||
auto type = glsl_without_array(uniform->type);
|
||||
if (glsl_type_is_image(type) || uniform->data.mode == nir_var_mem_ssbo) {
|
||||
m_flags.set(sh_uses_images);
|
||||
if (uniform->type->is_array() && !(uniform->data.mode == nir_var_mem_ssbo))
|
||||
if (glsl_type_is_array(uniform->type) && !(uniform->data.mode == nir_var_mem_ssbo))
|
||||
m_indirect_files |= 1 << TGSI_FILE_IMAGE;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue