[Mesa-dev] [PATCH 1/2] radeonsi: set AC_FUNC_ATTR_READNONE for image opcodes where it was missing

Samuel Pitoiset samuel.pitoiset at gmail.com
Thu Apr 11 07:18:30 UTC 2019


Reviewed-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>

On 4/11/19 3:30 AM, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> ---
>   src/amd/common/ac_llvm_build.c                    | 1 +
>   src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c | 4 ++++
>   2 files changed, 5 insertions(+)
>
> diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c
> index a612dcefa1d..cfbca294c97 100644
> --- a/src/amd/common/ac_llvm_build.c
> +++ b/src/amd/common/ac_llvm_build.c
> @@ -3293,20 +3293,21 @@ LLVMValueRef ac_unpack_param(struct ac_llvm_context *ctx, LLVMValueRef param,
>    *   addr[sample_index] = (fmask >> (addr[sample_index] * 4)) & 0xF;
>    */
>   void ac_apply_fmask_to_sample(struct ac_llvm_context *ac, LLVMValueRef fmask,
>   			      LLVMValueRef *addr, bool is_array_tex)
>   {
>   	struct ac_image_args fmask_load = {};
>   	fmask_load.opcode = ac_image_load;
>   	fmask_load.resource = fmask;
>   	fmask_load.dmask = 0xf;
>   	fmask_load.dim = is_array_tex ? ac_image_2darray : ac_image_2d;
> +	fmask_load.attributes = AC_FUNC_ATTR_READNONE;
>   
>   	fmask_load.coords[0] = addr[0];
>   	fmask_load.coords[1] = addr[1];
>   	if (is_array_tex)
>   		fmask_load.coords[2] = addr[2];
>   
>   	LLVMValueRef fmask_value = ac_build_image_opcode(ac, &fmask_load);
>   	fmask_value = LLVMBuildExtractElement(ac->builder, fmask_value,
>   					      ac->i32_0, "");
>   
> diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
> index 727def56f65..ed67976b421 100644
> --- a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
> +++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
> @@ -1035,20 +1035,21 @@ static void resq_emit(
>   		if (inst->Memory.Texture == TGSI_TEXTURE_3D)
>   			target = TGSI_TEXTURE_2D_ARRAY;
>   		else
>   			target = inst->Memory.Texture;
>   	}
>   
>   	struct ac_image_args args = {};
>   	args.opcode = ac_image_get_resinfo;
>   	args.dim = ac_texture_dim_from_tgsi_target(ctx->screen, target);
>   	args.dmask = 0xf;
> +	args.attributes = AC_FUNC_ATTR_READNONE;
>   
>   	if (inst->Instruction.Opcode == TGSI_OPCODE_TXQ) {
>   		tex_fetch_ptrs(bld_base, emit_data, &args.resource, NULL, NULL);
>   		args.lod = lp_build_emit_fetch(bld_base, inst, 0, TGSI_CHAN_X);
>   	} else {
>   		image_fetch_rsrc(bld_base, reg, false, target, &args.resource);
>   		args.lod = ctx->i32_0;
>   	}
>   
>   	emit_data->output[emit_data->chan] =
> @@ -1265,20 +1266,21 @@ si_lower_gather4_integer(struct si_shader_context *ctx,
>   			lp_build_if(&if_ctx, &ctx->gallivm, LLVMBuildNot(builder, wa_8888, ""));
>   		}
>   
>   		/* Query the texture size. */
>   		resinfo.opcode = ac_image_get_resinfo;
>   		resinfo.dim = ac_texture_dim_from_tgsi_target(ctx->screen, target);
>   		resinfo.resource = args->resource;
>   		resinfo.sampler = args->sampler;
>   		resinfo.lod = ctx->ac.i32_0;
>   		resinfo.dmask = 0xf;
> +		resinfo.attributes = AC_FUNC_ATTR_READNONE;
>   
>   		LLVMValueRef texsize =
>   			fix_resinfo(ctx, target,
>   				    ac_build_image_opcode(&ctx->ac, &resinfo));
>   
>   		/* Compute -0.5 / size. */
>   		for (unsigned c = 0; c < 2; c++) {
>   			half_texel[c] =
>   				LLVMBuildExtractElement(builder, texsize,
>   							LLVMConstInt(ctx->i32, c, 0), "");
> @@ -1769,20 +1771,22 @@ static void si_llvm_emit_fbfetch(const struct lp_build_tgsi_action *action,
>   		fmask = ac_build_load_to_sgpr(&ctx->ac, ptr,
>   			LLVMConstInt(ctx->i32, SI_PS_IMAGE_COLORBUF0_FMASK / 2, 0));
>   
>   		ac_apply_fmask_to_sample(&ctx->ac, fmask, args.coords,
>   					 ctx->shader->key.mono.u.ps.fbfetch_layered);
>   	}
>   
>   	args.opcode = ac_image_load;
>   	args.resource = image;
>   	args.dmask = 0xf;
> +	args.attributes = AC_FUNC_ATTR_READNONE;
> +
>   	if (ctx->shader->key.mono.u.ps.fbfetch_msaa)
>   		args.dim = ctx->shader->key.mono.u.ps.fbfetch_layered ?
>   			ac_image_2darraymsaa : ac_image_2dmsaa;
>   	else if (ctx->shader->key.mono.u.ps.fbfetch_is_1D)
>   		args.dim = ctx->shader->key.mono.u.ps.fbfetch_layered ?
>   			ac_image_1darray : ac_image_1d;
>   	else
>   		args.dim = ctx->shader->key.mono.u.ps.fbfetch_layered ?
>   			ac_image_2darray : ac_image_2d;
>   


More information about the mesa-dev mailing list