*/
NIR_INTRINSIC_DESC_TYPE = 19,
+ /**
+ * The nir_alu_type of a uniform/input/output
+ */
+ NIR_INTRINSIC_TYPE = 20,
+
NIR_INTRINSIC_NUM_INDEX_FLAGS,
} nir_intrinsic_index_flag;
INTRINSIC_IDX_ACCESSORS(align_mul, ALIGN_MUL, unsigned)
INTRINSIC_IDX_ACCESSORS(align_offset, ALIGN_OFFSET, unsigned)
INTRINSIC_IDX_ACCESSORS(desc_type, DESC_TYPE, unsigned)
+INTRINSIC_IDX_ACCESSORS(type, TYPE, nir_alu_type)
static inline void
nir_intrinsic_set_align(nir_intrinsic_instr *intrin,
ALIGN_OFFSET = "NIR_INTRINSIC_ALIGN_OFFSET"
# The vulkan descriptor type for vulkan_resource_index
DESC_TYPE = "NIR_INTRINSIC_DESC_TYPE"
+# The nir_alu_type of a uniform/input/output
+TYPE = "NIR_INTRINSIC_TYPE"
#
# Possible flags:
flags=flags)
# src[] = { offset }.
-load("uniform", 1, [BASE, RANGE], [CAN_ELIMINATE, CAN_REORDER])
+load("uniform", 1, [BASE, RANGE, TYPE], [CAN_ELIMINATE, CAN_REORDER])
# src[] = { buffer_index, offset }.
load("ubo", 2, [ACCESS, ALIGN_MUL, ALIGN_OFFSET], flags=[CAN_ELIMINATE, CAN_REORDER])
# src[] = { offset }.
-load("input", 1, [BASE, COMPONENT], [CAN_ELIMINATE, CAN_REORDER])
+load("input", 1, [BASE, COMPONENT, TYPE], [CAN_ELIMINATE, CAN_REORDER])
# src[] = { vertex, offset }.
load("per_vertex_input", 2, [BASE, COMPONENT], [CAN_ELIMINATE, CAN_REORDER])
# src[] = { barycoord, offset }.
intrinsic("store_" + name, [0] + ([1] * (num_srcs - 1)), indices=indices, flags=flags)
# src[] = { value, offset }.
-store("output", 2, [BASE, WRMASK, COMPONENT])
+store("output", 2, [BASE, WRMASK, COMPONENT, TYPE])
# src[] = { value, vertex, offset }.
store("per_vertex_output", 3, [BASE, WRMASK, COMPONENT])
# src[] = { value, block_index, offset }
static nir_intrinsic_instr *
lower_load(nir_intrinsic_instr *intrin, struct lower_io_state *state,
nir_ssa_def *vertex_index, nir_variable *var, nir_ssa_def *offset,
- unsigned component)
+ unsigned component, const struct glsl_type *type)
{
const nir_shader *nir = state->builder.shader;
nir_variable_mode mode = var->data.mode;
nir_intrinsic_set_range(load,
state->type_size(var->type, var->data.bindless));
+ if (load->intrinsic == nir_intrinsic_load_input ||
+ load->intrinsic == nir_intrinsic_load_uniform)
+ nir_intrinsic_set_type(load, nir_get_nir_type_for_glsl_type(type));
+
if (vertex_index) {
load->src[0] = nir_src_for_ssa(vertex_index);
load->src[1] = nir_src_for_ssa(offset);
static nir_intrinsic_instr *
lower_store(nir_intrinsic_instr *intrin, struct lower_io_state *state,
nir_ssa_def *vertex_index, nir_variable *var, nir_ssa_def *offset,
- unsigned component)
+ unsigned component, const struct glsl_type *type)
{
nir_variable_mode mode = var->data.mode;
if (mode == nir_var_shader_out)
nir_intrinsic_set_component(store, component);
+ if (store->intrinsic == nir_intrinsic_store_output)
+ nir_intrinsic_set_type(store, nir_get_nir_type_for_glsl_type(type));
+
nir_intrinsic_set_write_mask(store, nir_intrinsic_write_mask(intrin));
if (vertex_index)
static nir_intrinsic_instr *
lower_interpolate_at(nir_intrinsic_instr *intrin, struct lower_io_state *state,
- nir_variable *var, nir_ssa_def *offset, unsigned component)
+ nir_variable *var, nir_ssa_def *offset, unsigned component,
+ const struct glsl_type *type)
{
assert(var->data.mode == nir_var_shader_in);
/* Ignore interpolateAt() for flat variables - flat is flat. */
if (var->data.interpolation == INTERP_MODE_FLAT)
- return lower_load(intrin, state, NULL, var, offset, component);
+ return lower_load(intrin, state, NULL, var, offset, component, type);
nir_intrinsic_op bary_op;
switch (intrin->intrinsic) {
switch (intrin->intrinsic) {
case nir_intrinsic_load_deref:
replacement = lower_load(intrin, state, vertex_index, var, offset,
- component_offset);
+ component_offset, deref->type);
break;
case nir_intrinsic_store_deref:
replacement = lower_store(intrin, state, vertex_index, var, offset,
- component_offset);
+ component_offset, deref->type);
break;
case nir_intrinsic_deref_atomic_add:
case nir_intrinsic_interp_deref_at_offset:
assert(vertex_index == NULL);
replacement = lower_interpolate_at(intrin, state, var, offset,
- component_offset);
+ component_offset, deref->type);
break;
default:
[NIR_INTRINSIC_ALIGN_MUL] = "align_mul",
[NIR_INTRINSIC_ALIGN_OFFSET] = "align_offset",
[NIR_INTRINSIC_DESC_TYPE] = "desc_type",
+ [NIR_INTRINSIC_TYPE] = "type",
};
for (unsigned idx = 1; idx < NIR_INTRINSIC_NUM_INDEX_FLAGS; idx++) {
if (!info->index_map[idx])
} else if (idx == NIR_INTRINSIC_DESC_TYPE) {
VkDescriptorType desc_type = nir_intrinsic_desc_type(instr);
fprintf(fp, " desc_type=%s", vulkan_descriptor_type_name(desc_type));
+ } else if (idx == NIR_INTRINSIC_TYPE) {
+ nir_alu_type type = nir_intrinsic_type(instr);
+ unsigned size = nir_alu_type_get_type_size(type);
+ const char *name;
+ switch (nir_alu_type_get_base_type(type)) {
+ case nir_type_int: name = "int"; break;
+ case nir_type_uint: name = "uint"; break;
+ case nir_type_bool: name = "bool"; break;
+ case nir_type_float: name = "float"; break;
+ default: name = "invalid";
+ }
+ if (size)
+ fprintf(fp, " type=%s%u", name, size);
+ else
+ fprintf(fp, " type=%s", name);
} else {
unsigned off = info->index_map[idx] - 1;
assert(index_name[idx]); /* forgot to update index_name table? */