From: Jason Ekstrand Date: Wed, 23 Dec 2015 19:10:58 +0000 (-0800) Subject: nir/spirv: Handle derefs in vtn_ssa_value X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6219a69589a78efd8a40832d5f71ffe42eda9f67;p=mesa.git nir/spirv: Handle derefs in vtn_ssa_value This is kind of a hack, but it makes vtn_ssa_value insert a load if the value requested is actually a deref. This shouldn't happen normally but, thanks to the impedence mismatch of the NIR function parameter model vs. the SPIR-V model, this can happen for function arguments. --- diff --git a/src/glsl/nir/spirv_to_nir.c b/src/glsl/nir/spirv_to_nir.c index 1afa7eba5a9..dc165252c25 100644 --- a/src/glsl/nir/spirv_to_nir.c +++ b/src/glsl/nir/spirv_to_nir.c @@ -109,6 +109,10 @@ vtn_const_ssa_value(struct vtn_builder *b, nir_constant *constant, return val; } +static struct vtn_ssa_value * +vtn_variable_load(struct vtn_builder *b, nir_deref_var *src, + struct vtn_type *src_type); + struct vtn_ssa_value * vtn_ssa_value(struct vtn_builder *b, uint32_t value_id) { @@ -119,6 +123,11 @@ vtn_ssa_value(struct vtn_builder *b, uint32_t value_id) case vtn_value_type_ssa: return val->ssa; + + case vtn_value_type_deref: + /* This is needed for function parameters */ + return vtn_variable_load(b, val->deref, val->deref_type); + default: unreachable("Invalid type for an SSA value"); }