diff options
author | Samuel Pitoiset <[email protected]> | 2018-10-29 16:31:07 +0100 |
---|---|---|
committer | Samuel Pitoiset <[email protected]> | 2019-01-14 17:59:51 +0100 |
commit | 929df7afafb546d8af538085ff165cc62fdcb813 (patch) | |
tree | 27631e757621ded9a3425590c6c25b4941d00de7 | |
parent | af2a85df743ed7b59b03aba96071cef12fce41c3 (diff) |
ac/nir: set cache policy when loading/storing buffer images
This was missing.
Signed-off-by: Samuel Pitoiset <[email protected]>
Reviewed-by: Bas Nieuwenhuizen <[email protected]>
-rw-r--r-- | src/amd/common/ac_nir_to_llvm.c | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c index 78e803330c0..62ee9259836 100644 --- a/src/amd/common/ac_nir_to_llvm.c +++ b/src/amd/common/ac_nir_to_llvm.c @@ -2355,9 +2355,12 @@ static LLVMValueRef visit_image_load(struct ac_nir_context *ctx, LLVMValueRef res; const nir_variable *var = get_image_variable(instr); const struct glsl_type *type = var->type; + struct ac_image_args args = {}; type = glsl_without_array(type); + args.cache_policy = get_cache_policy(ctx, var->data.image.access, false); + const enum glsl_sampler_dim dim = glsl_get_sampler_dim(type); if (dim == GLSL_SAMPLER_DIM_BUF) { unsigned mask = nir_ssa_def_components_read(&instr->dest.ssa); @@ -2368,16 +2371,16 @@ static LLVMValueRef visit_image_load(struct ac_nir_context *ctx, vindex = LLVMBuildExtractElement(ctx->ac.builder, get_src(ctx, instr->src[1]), ctx->ac.i32_0, ""); - /* TODO: set "glc" and "can_speculate" when OpenGL needs it. */ + /* TODO: set "can_speculate" when OpenGL needs it. */ res = ac_build_buffer_load_format(&ctx->ac, rsrc, vindex, ctx->ac.i32_0, num_channels, - false, false); + !!(args.cache_policy & ac_glc), + false); res = ac_build_expand_to_vec4(&ctx->ac, res, num_channels); res = ac_trim_vector(&ctx->ac, res, instr->dest.ssa.num_components); res = ac_to_integer(&ctx->ac, res); } else { - struct ac_image_args args = {}; args.opcode = ac_image_load; get_image_coords(ctx, instr, &args); args.resource = get_image_descriptor(ctx, instr, AC_DESC_IMAGE, false); @@ -2385,8 +2388,6 @@ static LLVMValueRef visit_image_load(struct ac_nir_context *ctx, glsl_sampler_type_is_array(type)); args.dmask = 15; args.attributes = AC_FUNC_ATTR_READONLY; - args.cache_policy = - get_cache_policy(ctx, var->data.image.access, false); res = ac_build_image_opcode(&ctx->ac, &args); } @@ -2400,10 +2401,9 @@ static void visit_image_store(struct ac_nir_context *ctx, const nir_variable *var = get_image_variable(instr); const struct glsl_type *type = glsl_without_array(var->type); const enum glsl_sampler_dim dim = glsl_get_sampler_dim(type); - LLVMValueRef glc = ctx->ac.i1false; - bool force_glc = ctx->ac.chip_class == SI; - if (force_glc) - glc = ctx->ac.i1true; + struct ac_image_args args = {}; + + args.cache_policy = get_cache_policy(ctx, var->data.image.access, true); if (dim == GLSL_SAMPLER_DIM_BUF) { char name[48]; @@ -2427,14 +2427,13 @@ static void visit_image_store(struct ac_nir_context *ctx, if (HAVE_LLVM >= 0x800) { params[4] = ctx->ac.i32_0; /* soffset */ - params[5] = glc ? ctx->ac.i32_1 : ctx->ac.i32_0; + params[5] = (args.cache_policy & ac_glc) ? ctx->ac.i32_1 : ctx->ac.i32_0; } else { - params[4] = glc; /* glc */ + params[4] = LLVMConstInt(ctx->ac.i1, !!(args.cache_policy & ac_glc), 0); params[5] = ctx->ac.i1false; /* slc */ } ac_build_intrinsic(&ctx->ac, name, ctx->ac.voidt, params, 6, 0); } else { - struct ac_image_args args = {}; args.opcode = ac_image_store; args.data[0] = ac_to_float(&ctx->ac, get_src(ctx, instr->src[3])); get_image_coords(ctx, instr, &args); @@ -2442,8 +2441,6 @@ static void visit_image_store(struct ac_nir_context *ctx, args.dim = get_ac_image_dim(&ctx->ac, glsl_get_sampler_dim(type), glsl_sampler_type_is_array(type)); args.dmask = 15; - args.cache_policy = - get_cache_policy(ctx, var->data.image.access, true); ac_build_image_opcode(&ctx->ac, &args); } |