From: Marek Olšák <[email protected]>

the instruction knows the target
---
 src/gallium/drivers/radeonsi/si_shader.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index b170eb9..83d1d9f 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -3232,37 +3232,37 @@ static LLVMValueRef force_dcc_off(struct 
si_shader_context *ctx,
        }
 }
 
 /**
  * Load the resource descriptor for \p image.
  */
 static void
 image_fetch_rsrc(
        struct lp_build_tgsi_context *bld_base,
        const struct tgsi_full_src_register *image,
-       bool dcc_off,
+       bool dcc_off, unsigned target,
        LLVMValueRef *rsrc)
 {
        struct si_shader_context *ctx = si_shader_context(bld_base);
        LLVMValueRef rsrc_ptr = LLVMGetParam(ctx->main_fn,
                                             SI_PARAM_IMAGES);
        LLVMValueRef index, tmp;
 
        assert(image->Register.File == TGSI_FILE_IMAGE);
 
        if (!image->Register.Indirect) {
                const struct tgsi_shader_info *info = bld_base->info;
 
                index = LLVMConstInt(ctx->i32, image->Register.Index, 0);
 
                if (info->images_writemask & (1 << image->Register.Index) &&
-                   !(info->images_buffers & (1 << image->Register.Index)))
+                   target != TGSI_TEXTURE_BUFFER)
                        dcc_off = true;
        } else {
                /* From the GL_ARB_shader_image_load_store extension spec:
                 *
                 *    If a shader performs an image load, store, or atomic
                 *    operation using an image variable declared as an array,
                 *    and if the index used to select an individual element is
                 *    negative or greater than or equal to the size of the
                 *    array, the results of the operation are undefined but may
                 *    not lead to termination.
@@ -3415,21 +3415,21 @@ static void load_fetch_args(
                rsrc = shader_buffer_fetch_rsrc(ctx, &inst->Src[0]);
 
                tmp = lp_build_emit_fetch(bld_base, inst, 1, 0);
                offset = LLVMBuildBitCast(builder, tmp, 
bld_base->uint_bld.elem_type, "");
 
                buffer_append_args(ctx, emit_data, rsrc, 
bld_base->uint_bld.zero,
                                   offset, false);
        } else if (inst->Src[0].Register.File == TGSI_FILE_IMAGE) {
                LLVMValueRef coords;
 
-               image_fetch_rsrc(bld_base, &inst->Src[0], false, &rsrc);
+               image_fetch_rsrc(bld_base, &inst->Src[0], false, target, &rsrc);
                coords = image_fetch_coords(bld_base, inst, 1);
 
                if (target == TGSI_TEXTURE_BUFFER) {
                        rsrc = extract_rsrc_top_half(ctx, rsrc);
                        buffer_append_args(ctx, emit_data, rsrc, coords,
                                        bld_base->uint_bld.zero, false);
                } else {
                        emit_data->args[0] = coords;
                        emit_data->args[1] = rsrc;
                        emit_data->args[2] = lp_build_const_int32(gallivm, 15); 
/* dmask */
@@ -3626,28 +3626,29 @@ static void store_fetch_args(
 
                buffer_append_args(ctx, emit_data, rsrc, 
bld_base->uint_bld.zero,
                                   offset, false);
        } else if (inst->Dst[0].Register.File == TGSI_FILE_IMAGE) {
                unsigned target = inst->Memory.Texture;
                LLVMValueRef coords;
 
                coords = image_fetch_coords(bld_base, inst, 0);
 
                if (target == TGSI_TEXTURE_BUFFER) {
-                       image_fetch_rsrc(bld_base, &memory, false, &rsrc);
+                       image_fetch_rsrc(bld_base, &memory, false, target, 
&rsrc);
 
                        rsrc = extract_rsrc_top_half(ctx, rsrc);
                        buffer_append_args(ctx, emit_data, rsrc, coords,
                                        bld_base->uint_bld.zero, false);
                } else {
                        emit_data->args[1] = coords;
-                       image_fetch_rsrc(bld_base, &memory, true, 
&emit_data->args[2]);
+                       image_fetch_rsrc(bld_base, &memory, true, target,
+                                        &emit_data->args[2]);
                        emit_data->args[3] = lp_build_const_int32(gallivm, 15); 
/* dmask */
                        emit_data->arg_count = 4;
 
                        image_append_args(ctx, emit_data, target, false);
                }
        }
 }
 
 static void store_emit_buffer(
                struct si_shader_context *ctx,
@@ -3827,21 +3828,21 @@ static void atomic_fetch_args(
                tmp = lp_build_emit_fetch(bld_base, inst, 1, 0);
                offset = LLVMBuildBitCast(builder, tmp, 
bld_base->uint_bld.elem_type, "");
 
                buffer_append_args(ctx, emit_data, rsrc, 
bld_base->uint_bld.zero,
                                   offset, true);
        } else if (inst->Src[0].Register.File == TGSI_FILE_IMAGE) {
                unsigned target = inst->Memory.Texture;
                LLVMValueRef coords;
 
                image_fetch_rsrc(bld_base, &inst->Src[0],
-                                target != TGSI_TEXTURE_BUFFER, &rsrc);
+                                target != TGSI_TEXTURE_BUFFER, target, &rsrc);
                coords = image_fetch_coords(bld_base, inst, 1);
 
                if (target == TGSI_TEXTURE_BUFFER) {
                        rsrc = extract_rsrc_top_half(ctx, rsrc);
                        buffer_append_args(ctx, emit_data, rsrc, coords,
                                           bld_base->uint_bld.zero, true);
                } else {
                        emit_data->args[emit_data->arg_count++] = coords;
                        emit_data->args[emit_data->arg_count++] = rsrc;
 
@@ -3970,25 +3971,27 @@ static void resq_fetch_args(
        struct gallivm_state *gallivm = bld_base->base.gallivm;
        const struct tgsi_full_instruction *inst = emit_data->inst;
        const struct tgsi_full_src_register *reg = &inst->Src[0];
 
        emit_data->dst_type = ctx->v4i32;
 
        if (reg->Register.File == TGSI_FILE_BUFFER) {
                emit_data->args[0] = shader_buffer_fetch_rsrc(ctx, reg);
                emit_data->arg_count = 1;
        } else if (inst->Memory.Texture == TGSI_TEXTURE_BUFFER) {
-               image_fetch_rsrc(bld_base, reg, false, &emit_data->args[0]);
+               image_fetch_rsrc(bld_base, reg, false, inst->Memory.Texture,
+                                &emit_data->args[0]);
                emit_data->arg_count = 1;
        } else {
                emit_data->args[0] = bld_base->uint_bld.zero; /* mip level */
-               image_fetch_rsrc(bld_base, reg, false, &emit_data->args[1]);
+               image_fetch_rsrc(bld_base, reg, false, inst->Memory.Texture,
+                                &emit_data->args[1]);
                emit_data->args[2] = lp_build_const_int32(gallivm, 15); /* 
dmask */
                emit_data->args[3] = bld_base->uint_bld.zero; /* unorm */
                emit_data->args[4] = bld_base->uint_bld.zero; /* r128 */
                emit_data->args[5] = tgsi_is_array_image(inst->Memory.Texture) ?
                        bld_base->uint_bld.one : bld_base->uint_bld.zero; /* da 
*/
                emit_data->args[6] = bld_base->uint_bld.zero; /* glc */
                emit_data->args[7] = bld_base->uint_bld.zero; /* slc */
                emit_data->args[8] = bld_base->uint_bld.zero; /* tfe */
                emit_data->args[9] = bld_base->uint_bld.zero; /* lwe */
                emit_data->arg_count = 10;
-- 
2.7.4

_______________________________________________
mesa-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to