diff options
author | Jason Ekstrand <[email protected]> | 2015-05-06 12:35:30 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2015-08-31 16:58:20 -0700 |
commit | 9da6d808bec836c413e308caa7b36d74429ecf8d (patch) | |
tree | 3f845c4951d39d8899a6d5b270ebf728c3ac9300 | |
parent | 1feeee9cf476010f72cb973480f67de0764e6a90 (diff) |
nir/spirv: Make vtn_ssa_value handle constants as well as ssa values
-rw-r--r-- | src/glsl/nir/spirv_to_nir.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/glsl/nir/spirv_to_nir.c b/src/glsl/nir/spirv_to_nir.c index 0177be04537..03ef4c45dd1 100644 --- a/src/glsl/nir/spirv_to_nir.c +++ b/src/glsl/nir/spirv_to_nir.c @@ -31,7 +31,26 @@ nir_ssa_def * vtn_ssa_value(struct vtn_builder *b, uint32_t value_id) { - return vtn_value(b, value_id, vtn_value_type_ssa)->ssa; + struct vtn_value *val = vtn_untyped_value(b, value_id); + switch (val->value_type) { + case vtn_value_type_constant: { + assert(glsl_type_is_vector_or_scalar(val->type)); + unsigned num_components = glsl_get_vector_elements(val->type); + nir_load_const_instr *load = + nir_load_const_instr_create(b->shader, num_components); + + for (unsigned i = 0; i < num_components; i++) + load->value.u[0] = val->constant->value.u[0]; + + nir_builder_instr_insert(&b->nb, &load->instr); + return &load->def; + } + + case vtn_value_type_ssa: + return val->ssa; + default: + unreachable("Invalid type for an SSA value"); + } } static char * |