diff options
author | Bas Nieuwenhuizen <[email protected]> | 2019-01-23 22:50:33 +0100 |
---|---|---|
committer | Bas Nieuwenhuizen <[email protected]> | 2019-02-06 22:35:54 +0100 |
commit | dbdb44d5756cb98e15c40d0abf9efd4a7f250895 (patch) | |
tree | adba795580e84112985be09849bc80dd6cdf11a5 | |
parent | 3c24fc64c7a4e564d84843fab7db25963d574d99 (diff) |
amd/common: Fix stores to derefs with unknown variable.
Fixes: a2b5cc3c399 "radv: enable variable pointers"
Reviewed-by: Samuel Pitoiset <[email protected]>
-rw-r--r-- | src/amd/common/ac_nir_to_llvm.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c index 6ba0ee74f11..3a830591a24 100644 --- a/src/amd/common/ac_nir_to_llvm.c +++ b/src/amd/common/ac_nir_to_llvm.c @@ -2006,18 +2006,23 @@ static void visit_store_var(struct ac_nir_context *ctx, nir_intrinsic_instr *instr) { - nir_variable *var = nir_deref_instr_get_variable(nir_instr_as_deref(instr->src[0].ssa->parent_instr)); + nir_deref_instr *deref = nir_instr_as_deref(instr->src[0].ssa->parent_instr); + nir_variable *var = nir_deref_instr_get_variable(deref); LLVMValueRef temp_ptr, value; - int idx = var->data.driver_location; - unsigned comp = var->data.location_frac; + int idx = 0; + unsigned comp = 0; LLVMValueRef src = ac_to_float(&ctx->ac, get_src(ctx, instr->src[1])); int writemask = instr->const_index[0]; LLVMValueRef indir_index; unsigned const_index; - get_deref_offset(ctx, nir_instr_as_deref(instr->src[0].ssa->parent_instr), false, - NULL, NULL, &const_index, &indir_index); + if (var) { + get_deref_offset(ctx, deref, false, + NULL, NULL, &const_index, &indir_index); + idx = var->data.driver_location; + comp = var->data.location_frac; + } if (ac_get_elem_bits(&ctx->ac, LLVMTypeOf(src)) == 64) { @@ -2030,7 +2035,7 @@ visit_store_var(struct ac_nir_context *ctx, writemask = writemask << comp; - switch (var->data.mode) { + switch (deref->mode) { case nir_var_shader_out: if (ctx->stage == MESA_SHADER_TESS_CTRL) { @@ -2039,8 +2044,8 @@ visit_store_var(struct ac_nir_context *ctx, unsigned const_index = 0; const bool is_patch = var->data.patch; - get_deref_offset(ctx, nir_instr_as_deref(instr->src[0].ssa->parent_instr), - false, NULL, is_patch ? NULL : &vertex_index, + get_deref_offset(ctx, deref, false, NULL, + is_patch ? NULL : &vertex_index, &const_index, &indir_index); ctx->abi->store_tcs_outputs(ctx->abi, var, |