uint32_t *num_resume_shaders_out,
void *mem_ctx);
+int nir_get_io_offset_src_number(const nir_intrinsic_instr *instr);
+int nir_get_io_arrayed_index_src_number(const nir_intrinsic_instr *instr);
+
nir_src *nir_get_io_offset_src(nir_intrinsic_instr *instr);
nir_src *nir_get_io_arrayed_index_src(nir_intrinsic_instr *instr);
nir_src *nir_get_shader_call_payload_src(nir_intrinsic_instr *call);
}
/**
- * Return the offset source for a load/store intrinsic.
+ * Return the offset source number for a load/store intrinsic or -1 if there's no offset.
*/
-nir_src *
-nir_get_io_offset_src(nir_intrinsic_instr *instr)
+int
+nir_get_io_offset_src_number(const nir_intrinsic_instr *instr)
{
switch (instr->intrinsic) {
case nir_intrinsic_load_input:
case nir_intrinsic_task_payload_atomic_swap:
case nir_intrinsic_global_atomic:
case nir_intrinsic_global_atomic_swap:
- return &instr->src[0];
+ return 0;
case nir_intrinsic_load_ubo:
case nir_intrinsic_load_ssbo:
case nir_intrinsic_load_input_vertex:
case nir_intrinsic_store_scratch:
case nir_intrinsic_ssbo_atomic:
case nir_intrinsic_ssbo_atomic_swap:
- return &instr->src[1];
+ return 1;
case nir_intrinsic_store_ssbo:
case nir_intrinsic_store_per_vertex_output:
case nir_intrinsic_store_per_primitive_output:
- return &instr->src[2];
+ return 2;
default:
- return NULL;
+ return -1;
}
}
/**
- * Return the vertex index source for a load/store per_vertex intrinsic.
+ * Return the offset source for a load/store intrinsic.
*/
nir_src *
-nir_get_io_arrayed_index_src(nir_intrinsic_instr *instr)
+nir_get_io_offset_src(nir_intrinsic_instr *instr)
+{
+ const int idx = nir_get_io_offset_src_number(instr);
+ return idx >= 0 ? &instr->src[idx] : NULL;
+}
+
+/**
+ * Return the vertex index source number for a load/store per_vertex intrinsic or -1 if there's no offset.
+ */
+int
+nir_get_io_arrayed_index_src_number(const nir_intrinsic_instr *instr)
{
switch (instr->intrinsic) {
case nir_intrinsic_load_per_vertex_input:
case nir_intrinsic_load_per_vertex_output:
case nir_intrinsic_load_per_primitive_output:
- return &instr->src[0];
+ return 0;
case nir_intrinsic_store_per_vertex_output:
case nir_intrinsic_store_per_primitive_output:
- return &instr->src[1];
+ return 1;
default:
- return NULL;
+ return -1;
}
}
/**
+ * Return the vertex index source for a load/store per_vertex intrinsic.
+ */
+nir_src *
+nir_get_io_arrayed_index_src(nir_intrinsic_instr *instr)
+{
+ const int idx = nir_get_io_arrayed_index_src_number(instr);
+ return idx >= 0 ? &instr->src[idx] : NULL;
+}
+
+/**
* Return the numeric constant that identify a NULL pointer for each address
* format.
*/