From: Rhys Perry Date: Wed, 19 Oct 2022 17:17:29 +0000 (+0100) Subject: ac/llvm: fix mixing non-uniform/uniform sampler/texture descriptors X-Git-Tag: upstream/22.3.5~1293 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c492779924cd4798b7666b812d3a805380ef67bb;p=platform%2Fupstream%2Fmesa.git ac/llvm: fix mixing non-uniform/uniform sampler/texture descriptors Non-uniform descriptors are not loaded in NIR and instead the pointer is passed to abi->load_sampler_desc. It can be the case that only the texture or sampler uses this path. For the descriptor which doesn't use the path, we would previously pass NULL to abi->load_sampler_desc. Signed-off-by: Rhys Perry Reviewed-by: Georg Lehmann Part-of: --- diff --git a/src/amd/llvm/ac_nir_to_llvm.c b/src/amd/llvm/ac_nir_to_llvm.c index d8efa41..17cbeea 100644 --- a/src/amd/llvm/ac_nir_to_llvm.c +++ b/src/amd/llvm/ac_nir_to_llvm.c @@ -4619,11 +4619,6 @@ static void tex_fetch_ptrs(struct ac_nir_context *ctx, nir_tex_instr *instr, } } - if (*res_ptr) { - /* descriptors given through nir_tex_src_{texture,sampler}_handle */ - return; - } - enum ac_descriptor_type main_descriptor = instr->sampler_dim == GLSL_SAMPLER_DIM_BUF ? AC_DESC_BUFFER : AC_DESC_IMAGE; @@ -4642,7 +4637,7 @@ static void tex_fetch_ptrs(struct ac_nir_context *ctx, nir_tex_instr *instr, main_descriptor = AC_DESC_FMASK; } - if (texture_dynamic_handle) { + if (texture_dynamic_handle || sampler_dynamic_handle) { /* descriptor handles given through nir_tex_src_{texture,sampler}_handle */ if (instr->texture_non_uniform) texture_dynamic_handle = enter_waterfall(ctx, &wctx[0], texture_dynamic_handle, divergent); @@ -4650,15 +4645,21 @@ static void tex_fetch_ptrs(struct ac_nir_context *ctx, nir_tex_instr *instr, if (instr->sampler_non_uniform) sampler_dynamic_handle = enter_waterfall(ctx, &wctx[1], sampler_dynamic_handle, divergent); - *res_ptr = ctx->abi->load_sampler_desc(ctx->abi, 0, 0, 0, texture_dynamic_handle, - main_descriptor, false, false, true); + if (texture_dynamic_handle) + *res_ptr = ctx->abi->load_sampler_desc(ctx->abi, 0, 0, 0, texture_dynamic_handle, + main_descriptor, false, false, true); - if (samp_ptr) + if (samp_ptr && sampler_dynamic_handle) *samp_ptr = ctx->abi->load_sampler_desc(ctx->abi, 0, 0, 0, sampler_dynamic_handle, AC_DESC_SAMPLER, false, false, true); return; } + if (*res_ptr) { + /* descriptors given through nir_tex_src_{texture,sampler}_handle */ + return; + } + LLVMValueRef texture_dynamic_index = get_sampler_desc_index(ctx, texture_deref_instr, &instr->instr, false); if (!sampler_deref_instr)