nir: Make image load/store intrinsics variable-width

Instead of requiring 4 components, this allows them to potentially use
fewer.  Both the SPIR-V and GLSL paths still generate vec4 intrinsics so
drivers which assume 4 components should be safe.  However, we want to
be able to shrink them for i965.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
Jason Ekstrand
2018-08-14 14:03:05 -05:00
parent 7cdf8f9339
commit 15d39f474b
3 changed files with 11 additions and 4 deletions

View File

@@ -904,12 +904,17 @@ nir_visitor::visit(ir_call *ir)
/* Set the intrinsic destination. */
if (ir->return_deref) {
unsigned num_components = ir->return_deref->type->vector_elements;
if (instr->intrinsic == nir_intrinsic_image_deref_size)
instr->num_components = num_components;
nir_ssa_dest_init(&instr->instr, &instr->dest,
num_components, 32, NULL);
}
if (op == nir_intrinsic_image_deref_size) {
instr->num_components = instr->dest.ssa.num_components;
} else if (op == nir_intrinsic_image_deref_load ||
op == nir_intrinsic_image_deref_store) {
instr->num_components = 4;
}
if (op == nir_intrinsic_image_deref_size ||
op == nir_intrinsic_image_deref_samples) {
nir_builder_instr_insert(&b, &instr->instr);