op = nir_intrinsic_image_deref_samples;
break;
case ir_intrinsic_ssbo_store:
- op = nir_intrinsic_store_ssbo;
- break;
case ir_intrinsic_ssbo_load:
- op = nir_intrinsic_load_ssbo;
- break;
case ir_intrinsic_ssbo_atomic_add:
- op = ir->return_deref->type->is_integer_32_64()
- ? nir_intrinsic_ssbo_atomic_add : nir_intrinsic_ssbo_atomic_fadd;
- break;
case ir_intrinsic_ssbo_atomic_and:
- op = nir_intrinsic_ssbo_atomic_and;
- break;
case ir_intrinsic_ssbo_atomic_or:
- op = nir_intrinsic_ssbo_atomic_or;
- break;
case ir_intrinsic_ssbo_atomic_xor:
- op = nir_intrinsic_ssbo_atomic_xor;
- 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;
- else if (ir->return_deref->type == glsl_type::uint_type)
- op = nir_intrinsic_ssbo_atomic_umin;
- else if (ir->return_deref->type == glsl_type::float_type)
- op = nir_intrinsic_ssbo_atomic_fmin;
- else
- unreachable("Invalid type");
- 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;
- else if (ir->return_deref->type == glsl_type::uint_type)
- op = nir_intrinsic_ssbo_atomic_umax;
- else if (ir->return_deref->type == glsl_type::float_type)
- op = nir_intrinsic_ssbo_atomic_fmax;
- else
- unreachable("Invalid type");
- break;
case ir_intrinsic_ssbo_atomic_exchange:
- op = nir_intrinsic_ssbo_atomic_exchange;
- break;
case ir_intrinsic_ssbo_atomic_comp_swap:
- op = ir->return_deref->type->is_integer_32_64()
- ? nir_intrinsic_ssbo_atomic_comp_swap
- : nir_intrinsic_ssbo_atomic_fcomp_swap;
- break;
+ /* SSBO store/loads should only have been lowered in GLSL IR for
+ * non-nir drivers, NIR drivers make use of gl_nir_lower_buffers()
+ * instead.
+ */
+ unreachable("Invalid operation nir doesn't want lowered ssbo "
+ "store/loads");
case ir_intrinsic_shader_clock:
op = nir_intrinsic_shader_clock;
break;
nir_builder_instr_insert(&b, &instr->instr);
break;
}
- case nir_intrinsic_load_ssbo: {
- exec_node *param = ir->actual_parameters.get_head();
- ir_rvalue *block = ((ir_instruction *)param)->as_rvalue();
-
- param = param->get_next();
- ir_rvalue *offset = ((ir_instruction *)param)->as_rvalue();
-
- instr->src[0] = nir_src_for_ssa(evaluate_rvalue(block));
- instr->src[1] = nir_src_for_ssa(evaluate_rvalue(offset));
-
- const glsl_type *type = ir->return_deref->var->type;
- instr->num_components = type->vector_elements;
- intrinsic_set_std430_align(instr, type);
-
- /* Setup destination register */
- unsigned bit_size = type->is_boolean() ? 32 : glsl_get_bit_size(type);
- nir_ssa_dest_init(&instr->instr, &instr->dest,
- type->vector_elements, bit_size, NULL);
-
- /* Insert the created nir instruction now since in the case of boolean
- * result we will need to emit another instruction after it
- */
- nir_builder_instr_insert(&b, &instr->instr);
-
- /*
- * In SSBO/UBO's, a true boolean value is any non-zero value, but we
- * consider a true boolean to be ~0. Fix this up with a != 0
- * comparison.
- */
- if (type->is_boolean())
- ret = nir_i2b(&b, &instr->dest.ssa);
- break;
- }
- case nir_intrinsic_ssbo_atomic_add:
- case nir_intrinsic_ssbo_atomic_imin:
- case nir_intrinsic_ssbo_atomic_umin:
- case nir_intrinsic_ssbo_atomic_imax:
- case nir_intrinsic_ssbo_atomic_umax:
- case nir_intrinsic_ssbo_atomic_and:
- case nir_intrinsic_ssbo_atomic_or:
- case nir_intrinsic_ssbo_atomic_xor:
- case nir_intrinsic_ssbo_atomic_exchange:
- case nir_intrinsic_ssbo_atomic_comp_swap:
- case nir_intrinsic_ssbo_atomic_fadd:
- case nir_intrinsic_ssbo_atomic_fmin:
- case nir_intrinsic_ssbo_atomic_fmax:
- case nir_intrinsic_ssbo_atomic_fcomp_swap: {
- int param_count = ir->actual_parameters.length();
- assert(param_count == 3 || param_count == 4);
-
- /* Block index */
- exec_node *param = ir->actual_parameters.get_head();
- ir_instruction *inst = (ir_instruction *) param;
- instr->src[0] = nir_src_for_ssa(evaluate_rvalue(inst->as_rvalue()));
-
- /* Offset */
- param = param->get_next();
- inst = (ir_instruction *) param;
- instr->src[1] = nir_src_for_ssa(evaluate_rvalue(inst->as_rvalue()));
-
- /* data1 parameter (this is always present) */
- param = param->get_next();
- inst = (ir_instruction *) param;
- instr->src[2] = nir_src_for_ssa(evaluate_rvalue(inst->as_rvalue()));
-
- /* data2 parameter (only with atomic_comp_swap) */
- if (param_count == 4) {
- assert(op == nir_intrinsic_ssbo_atomic_comp_swap ||
- op == nir_intrinsic_ssbo_atomic_fcomp_swap);
- param = param->get_next();
- inst = (ir_instruction *) param;
- instr->src[3] = nir_src_for_ssa(evaluate_rvalue(inst->as_rvalue()));
- }
-
- /* Atomic result */
- assert(ir->return_deref);
- nir_ssa_dest_init(&instr->instr, &instr->dest,
- ir->return_deref->type->vector_elements, 32, NULL);
- nir_builder_instr_insert(&b, &instr->instr);
- break;
- }
case nir_intrinsic_load_shared: {
exec_node *param = ir->actual_parameters.get_head();
ir_rvalue *offset = ((ir_instruction *)param)->as_rvalue();
{
/* Some special cases */
switch (ir->operation) {
- case ir_binop_ubo_load: {
- nir_intrinsic_instr *load =
- nir_intrinsic_instr_create(this->shader, nir_intrinsic_load_ubo);
- unsigned bit_size = ir->type->is_boolean() ? 32 :
- glsl_get_bit_size(ir->type);
- load->num_components = ir->type->vector_elements;
- load->src[0] = nir_src_for_ssa(evaluate_rvalue(ir->operands[0]));
- load->src[1] = nir_src_for_ssa(evaluate_rvalue(ir->operands[1]));
- intrinsic_set_std430_align(load, ir->type);
- add_instr(&load->instr, ir->type->vector_elements, bit_size);
-
- /*
- * In UBO's, a true boolean value is any non-zero value, but we consider
- * a true boolean to be ~0. Fix this up with a != 0 comparison.
- */
-
- if (ir->type->is_boolean())
- this->result = nir_i2b(&b, &load->dest.ssa);
-
- return;
- }
-
case ir_unop_interpolate_at_centroid:
case ir_binop_interpolate_at_offset:
case ir_binop_interpolate_at_sample: {
return;
}
+ case ir_binop_ubo_load:
+ /* UBO loads should only have been lowered in GLSL IR for non-nir drivers,
+ * NIR drivers make use of gl_nir_lower_buffers() instead.
+ */
+ unreachable("Invalid operation nir doesn't want lowered ubo loads");
default:
break;
}