summaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/glsl/glsl_to_nir.cpp172
-rw-r--r--src/compiler/glsl/lower_shared_reference.cpp18
-rw-r--r--src/compiler/glsl/lower_ubo_reference.cpp18
3 files changed, 105 insertions, 103 deletions
diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp
index 01dcac4ee93..7ecbfe079a1 100644
--- a/src/compiler/glsl/glsl_to_nir.cpp
+++ b/src/compiler/glsl/glsl_to_nir.cpp
@@ -609,74 +609,75 @@ nir_visitor::visit(ir_call *ir)
{
if (ir->callee->is_intrinsic) {
nir_intrinsic_op op;
- if (strcmp(ir->callee_name(), "__intrinsic_atomic_read") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_atomic_counter_read);
+
+ switch (ir->callee->intrinsic_id) {
+ case ir_intrinsic_atomic_counter_read:
op = nir_intrinsic_atomic_counter_read_var;
- } else if (strcmp(ir->callee_name(), "__intrinsic_atomic_increment") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_atomic_counter_increment);
+ break;
+ case ir_intrinsic_atomic_counter_increment:
op = nir_intrinsic_atomic_counter_inc_var;
- } else if (strcmp(ir->callee_name(), "__intrinsic_atomic_predecrement") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_atomic_counter_predecrement);
+ break;
+ case ir_intrinsic_atomic_counter_predecrement:
op = nir_intrinsic_atomic_counter_dec_var;
- } else if (strcmp(ir->callee_name(), "__intrinsic_image_load") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_image_load);
+ break;
+ case ir_intrinsic_image_load:
op = nir_intrinsic_image_load;
- } else if (strcmp(ir->callee_name(), "__intrinsic_image_store") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_image_store);
+ break;
+ case ir_intrinsic_image_store:
op = nir_intrinsic_image_store;
- } else if (strcmp(ir->callee_name(), "__intrinsic_image_atomic_add") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_image_atomic_add);
+ break;
+ case ir_intrinsic_image_atomic_add:
op = nir_intrinsic_image_atomic_add;
- } else if (strcmp(ir->callee_name(), "__intrinsic_image_atomic_min") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_image_atomic_min);
+ break;
+ case ir_intrinsic_image_atomic_min:
op = nir_intrinsic_image_atomic_min;
- } else if (strcmp(ir->callee_name(), "__intrinsic_image_atomic_max") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_image_atomic_max);
+ break;
+ case ir_intrinsic_image_atomic_max:
op = nir_intrinsic_image_atomic_max;
- } else if (strcmp(ir->callee_name(), "__intrinsic_image_atomic_and") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_image_atomic_and);
+ break;
+ case ir_intrinsic_image_atomic_and:
op = nir_intrinsic_image_atomic_and;
- } else if (strcmp(ir->callee_name(), "__intrinsic_image_atomic_or") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_image_atomic_or);
+ break;
+ case ir_intrinsic_image_atomic_or:
op = nir_intrinsic_image_atomic_or;
- } else if (strcmp(ir->callee_name(), "__intrinsic_image_atomic_xor") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_image_atomic_xor);
+ break;
+ case ir_intrinsic_image_atomic_xor:
op = nir_intrinsic_image_atomic_xor;
- } else if (strcmp(ir->callee_name(), "__intrinsic_image_atomic_exchange") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_image_atomic_exchange);
+ break;
+ case ir_intrinsic_image_atomic_exchange:
op = nir_intrinsic_image_atomic_exchange;
- } else if (strcmp(ir->callee_name(), "__intrinsic_image_atomic_comp_swap") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_image_atomic_comp_swap);
+ break;
+ case ir_intrinsic_image_atomic_comp_swap:
op = nir_intrinsic_image_atomic_comp_swap;
- } else if (strcmp(ir->callee_name(), "__intrinsic_memory_barrier") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_memory_barrier);
+ break;
+ case ir_intrinsic_memory_barrier:
op = nir_intrinsic_memory_barrier;
- } else if (strcmp(ir->callee_name(), "__intrinsic_image_size") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_image_size);
+ break;
+ case ir_intrinsic_image_size:
op = nir_intrinsic_image_size;
- } else if (strcmp(ir->callee_name(), "__intrinsic_image_samples") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_image_samples);
+ break;
+ case ir_intrinsic_image_samples:
op = nir_intrinsic_image_samples;
- } else if (strcmp(ir->callee_name(), "__intrinsic_store_ssbo") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_ssbo_store);
+ break;
+ case ir_intrinsic_ssbo_store:
op = nir_intrinsic_store_ssbo;
- } else if (strcmp(ir->callee_name(), "__intrinsic_load_ssbo") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_ssbo_load);
+ break;
+ case ir_intrinsic_ssbo_load:
op = nir_intrinsic_load_ssbo;
- } else if (strcmp(ir->callee_name(), "__intrinsic_atomic_add_ssbo") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_ssbo_atomic_add);
+ break;
+ case ir_intrinsic_ssbo_atomic_add:
op = nir_intrinsic_ssbo_atomic_add;
- } else if (strcmp(ir->callee_name(), "__intrinsic_atomic_and_ssbo") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_ssbo_atomic_and);
+ break;
+ case ir_intrinsic_ssbo_atomic_and:
op = nir_intrinsic_ssbo_atomic_and;
- } else if (strcmp(ir->callee_name(), "__intrinsic_atomic_or_ssbo") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_ssbo_atomic_or);
+ break;
+ case ir_intrinsic_ssbo_atomic_or:
op = nir_intrinsic_ssbo_atomic_or;
- } else if (strcmp(ir->callee_name(), "__intrinsic_atomic_xor_ssbo") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_ssbo_atomic_xor);
+ break;
+ case ir_intrinsic_ssbo_atomic_xor:
op = nir_intrinsic_ssbo_atomic_xor;
- } else if (strcmp(ir->callee_name(), "__intrinsic_atomic_min_ssbo") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_ssbo_atomic_min);
+ break;
+ case ir_intrinsic_ssbo_atomic_min:
assert(ir->return_deref);
if (ir->return_deref->type == glsl_type::int_type)
op = nir_intrinsic_ssbo_atomic_imin;
@@ -684,8 +685,8 @@ nir_visitor::visit(ir_call *ir)
op = nir_intrinsic_ssbo_atomic_umin;
else
unreachable("Invalid type");
- } else if (strcmp(ir->callee_name(), "__intrinsic_atomic_max_ssbo") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_ssbo_atomic_max);
+ break;
+ case ir_intrinsic_ssbo_atomic_max:
assert(ir->return_deref);
if (ir->return_deref->type == glsl_type::int_type)
op = nir_intrinsic_ssbo_atomic_imax;
@@ -693,50 +694,50 @@ nir_visitor::visit(ir_call *ir)
op = nir_intrinsic_ssbo_atomic_umax;
else
unreachable("Invalid type");
- } else if (strcmp(ir->callee_name(), "__intrinsic_atomic_exchange_ssbo") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_ssbo_atomic_exchange);
+ break;
+ case ir_intrinsic_ssbo_atomic_exchange:
op = nir_intrinsic_ssbo_atomic_exchange;
- } else if (strcmp(ir->callee_name(), "__intrinsic_atomic_comp_swap_ssbo") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_ssbo_atomic_comp_swap);
+ break;
+ case ir_intrinsic_ssbo_atomic_comp_swap:
op = nir_intrinsic_ssbo_atomic_comp_swap;
- } else if (strcmp(ir->callee_name(), "__intrinsic_shader_clock") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_shader_clock);
+ break;
+ case ir_intrinsic_shader_clock:
op = nir_intrinsic_shader_clock;
- } else if (strcmp(ir->callee_name(), "__intrinsic_group_memory_barrier") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_group_memory_barrier);
+ break;
+ case ir_intrinsic_group_memory_barrier:
op = nir_intrinsic_group_memory_barrier;
- } else if (strcmp(ir->callee_name(), "__intrinsic_memory_barrier_atomic_counter") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_memory_barrier_atomic_counter);
+ break;
+ case ir_intrinsic_memory_barrier_atomic_counter:
op = nir_intrinsic_memory_barrier_atomic_counter;
- } else if (strcmp(ir->callee_name(), "__intrinsic_memory_barrier_buffer") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_memory_barrier_buffer);
+ break;
+ case ir_intrinsic_memory_barrier_buffer:
op = nir_intrinsic_memory_barrier_buffer;
- } else if (strcmp(ir->callee_name(), "__intrinsic_memory_barrier_image") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_memory_barrier_image);
+ break;
+ case ir_intrinsic_memory_barrier_image:
op = nir_intrinsic_memory_barrier_image;
- } else if (strcmp(ir->callee_name(), "__intrinsic_memory_barrier_shared") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_memory_barrier_shared);
+ break;
+ case ir_intrinsic_memory_barrier_shared:
op = nir_intrinsic_memory_barrier_shared;
- } else if (strcmp(ir->callee_name(), "__intrinsic_load_shared") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_shared_load);
+ break;
+ case ir_intrinsic_shared_load:
op = nir_intrinsic_load_shared;
- } else if (strcmp(ir->callee_name(), "__intrinsic_store_shared") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_shared_store);
+ break;
+ case ir_intrinsic_shared_store:
op = nir_intrinsic_store_shared;
- } else if (strcmp(ir->callee_name(), "__intrinsic_atomic_add_shared") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_shared_atomic_add);
+ break;
+ case ir_intrinsic_shared_atomic_add:
op = nir_intrinsic_shared_atomic_add;
- } else if (strcmp(ir->callee_name(), "__intrinsic_atomic_and_shared") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_shared_atomic_and);
+ break;
+ case ir_intrinsic_shared_atomic_and:
op = nir_intrinsic_shared_atomic_and;
- } else if (strcmp(ir->callee_name(), "__intrinsic_atomic_or_shared") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_shared_atomic_or);
+ break;
+ case ir_intrinsic_shared_atomic_or:
op = nir_intrinsic_shared_atomic_or;
- } else if (strcmp(ir->callee_name(), "__intrinsic_atomic_xor_shared") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_shared_atomic_xor);
+ break;
+ case ir_intrinsic_shared_atomic_xor:
op = nir_intrinsic_shared_atomic_xor;
- } else if (strcmp(ir->callee_name(), "__intrinsic_atomic_min_shared") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_shared_atomic_min);
+ break;
+ case ir_intrinsic_shared_atomic_min:
assert(ir->return_deref);
if (ir->return_deref->type == glsl_type::int_type)
op = nir_intrinsic_shared_atomic_imin;
@@ -744,8 +745,8 @@ nir_visitor::visit(ir_call *ir)
op = nir_intrinsic_shared_atomic_umin;
else
unreachable("Invalid type");
- } else if (strcmp(ir->callee_name(), "__intrinsic_atomic_max_shared") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_shared_atomic_max);
+ break;
+ case ir_intrinsic_shared_atomic_max:
assert(ir->return_deref);
if (ir->return_deref->type == glsl_type::int_type)
op = nir_intrinsic_shared_atomic_imax;
@@ -753,13 +754,14 @@ nir_visitor::visit(ir_call *ir)
op = nir_intrinsic_shared_atomic_umax;
else
unreachable("Invalid type");
- } else if (strcmp(ir->callee_name(), "__intrinsic_atomic_exchange_shared") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_shared_atomic_exchange);
+ break;
+ case ir_intrinsic_shared_atomic_exchange:
op = nir_intrinsic_shared_atomic_exchange;
- } else if (strcmp(ir->callee_name(), "__intrinsic_atomic_comp_swap_shared") == 0) {
- assert(ir->callee->intrinsic_id == ir_intrinsic_shared_atomic_comp_swap);
+ break;
+ case ir_intrinsic_shared_atomic_comp_swap:
op = nir_intrinsic_shared_atomic_comp_swap;
- } else {
+ break;
+ default:
unreachable("not reached");
}
diff --git a/src/compiler/glsl/lower_shared_reference.cpp b/src/compiler/glsl/lower_shared_reference.cpp
index 49ee3774c68..a7e738e8fc4 100644
--- a/src/compiler/glsl/lower_shared_reference.cpp
+++ b/src/compiler/glsl/lower_shared_reference.cpp
@@ -450,15 +450,15 @@ lower_shared_reference_visitor::check_for_shared_atomic_intrinsic(ir_call *ir)
if (!var || var->data.mode != ir_var_shader_shared)
return ir;
- const char *callee = ir->callee_name();
- if (!strcmp("__intrinsic_atomic_add", callee) ||
- !strcmp("__intrinsic_atomic_min", callee) ||
- !strcmp("__intrinsic_atomic_max", callee) ||
- !strcmp("__intrinsic_atomic_and", callee) ||
- !strcmp("__intrinsic_atomic_or", callee) ||
- !strcmp("__intrinsic_atomic_xor", callee) ||
- !strcmp("__intrinsic_atomic_exchange", callee) ||
- !strcmp("__intrinsic_atomic_comp_swap", callee)) {
+ const enum ir_intrinsic_id id = ir->callee->intrinsic_id;
+ if (id == ir_intrinsic_generic_atomic_add ||
+ id == ir_intrinsic_generic_atomic_min ||
+ id == ir_intrinsic_generic_atomic_max ||
+ id == ir_intrinsic_generic_atomic_and ||
+ id == ir_intrinsic_generic_atomic_or ||
+ id == ir_intrinsic_generic_atomic_xor ||
+ id == ir_intrinsic_generic_atomic_exchange ||
+ id == ir_intrinsic_generic_atomic_comp_swap) {
return lower_shared_atomic_intrinsic(ir);
}
diff --git a/src/compiler/glsl/lower_ubo_reference.cpp b/src/compiler/glsl/lower_ubo_reference.cpp
index 0e6a02d868c..276e77fbc82 100644
--- a/src/compiler/glsl/lower_ubo_reference.cpp
+++ b/src/compiler/glsl/lower_ubo_reference.cpp
@@ -1063,15 +1063,15 @@ lower_ubo_reference_visitor::check_for_ssbo_atomic_intrinsic(ir_call *ir)
if (!var || !var->is_in_shader_storage_block())
return ir;
- const char *callee = ir->callee_name();
- if (!strcmp("__intrinsic_atomic_add", callee) ||
- !strcmp("__intrinsic_atomic_min", callee) ||
- !strcmp("__intrinsic_atomic_max", callee) ||
- !strcmp("__intrinsic_atomic_and", callee) ||
- !strcmp("__intrinsic_atomic_or", callee) ||
- !strcmp("__intrinsic_atomic_xor", callee) ||
- !strcmp("__intrinsic_atomic_exchange", callee) ||
- !strcmp("__intrinsic_atomic_comp_swap", callee)) {
+ const enum ir_intrinsic_id id = ir->callee->intrinsic_id;
+ if (id == ir_intrinsic_generic_atomic_add ||
+ id == ir_intrinsic_generic_atomic_min ||
+ id == ir_intrinsic_generic_atomic_max ||
+ id == ir_intrinsic_generic_atomic_and ||
+ id == ir_intrinsic_generic_atomic_or ||
+ id == ir_intrinsic_generic_atomic_xor ||
+ id == ir_intrinsic_generic_atomic_exchange ||
+ id == ir_intrinsic_generic_atomic_comp_swap) {
return lower_ssbo_atomic_intrinsic(ir);
}