[Mesa-dev] [PATCH 12/24] radeonsi: set readnone on reads from read-only memory
Constantine Kharlamov
Hi-Angel at yandex.ru
Fri Mar 10 22:03:14 UTC 2017
On 26.02.2017 02:58, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> ---
> src/amd/common/ac_llvm_build.c | 11 +++++++++--
> src/amd/common/ac_llvm_build.h | 3 ++-
> src/gallium/drivers/radeonsi/si_shader.c | 20 ++++++++++----------
> 3 files changed, 21 insertions(+), 13 deletions(-)
>
> diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c
> index 42965b6..f0ab9cb 100644
> --- a/src/amd/common/ac_llvm_build.c
> +++ b/src/amd/common/ac_llvm_build.c
> @@ -612,21 +612,22 @@ ac_build_tbuffer_store_dwords(struct ac_llvm_context *ctx,
>
> LLVMValueRef
> ac_build_buffer_load(struct ac_llvm_context *ctx,
> LLVMValueRef rsrc,
> int num_channels,
> LLVMValueRef vindex,
> LLVMValueRef voffset,
> LLVMValueRef soffset,
> unsigned inst_offset,
> unsigned glc,
> - unsigned slc)
> + unsigned slc,
> + bool readonly_memory)
> {
> unsigned func = CLAMP(num_channels, 1, 3) - 1;
>
> if (HAVE_LLVM >= 0x309) {
> LLVMValueRef args[] = {
> LLVMBuildBitCast(ctx->builder, rsrc, ctx->v4i32, ""),
> vindex ? vindex : LLVMConstInt(ctx->i32, 0, 0),
> LLVMConstInt(ctx->i32, inst_offset, 0),
> LLVMConstInt(ctx->i1, glc, 0),
> LLVMConstInt(ctx->i1, slc, 0)
> @@ -644,21 +645,27 @@ ac_build_buffer_load(struct ac_llvm_context *ctx,
>
> if (soffset) {
> args[2] = LLVMBuildAdd(ctx->builder, args[2], soffset,
> "");
> }
>
> snprintf(name, sizeof(name), "llvm.amdgcn.buffer.load.%s",
> type_names[func]);
>
> return ac_emit_llvm_intrinsic(ctx, name, types[func], args,
> - ARRAY_SIZE(args), AC_FUNC_ATTR_READONLY);
> + ARRAY_SIZE(args),
> + /* READNONE means writes can't
> + * affect it, while READONLY means
> + * that writes can affect it. */
> + readonly_memory ?
> + AC_FUNC_ATTR_READNONE :
> + AC_FUNC_ATTR_READONLY);
You probably swapped the arguments, i.e. when "readonly_memory == true",
you're passing AC_FUNC_ATTR_READNONE instead of AC_FUNC_ATTR_READONLY.
More information about the mesa-dev
mailing list