Missed that.

Reviewed-by: Samuel Pitoiset <samuel.pitoi...@gmail.com>

On 09/29/2017 02:25 PM, Marek Olšák wrote:
From: Marek Olšák <marek.ol...@amd.com>

We emitted instructions loading the bindless handle after the memory
instruction.

Cc: 17.1 17.2 <mesa-sta...@lists.freedesktop.org>
---
  src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 18 ++++++++++++++----
  1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 2d62213..b2345b8 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -3618,20 +3618,26 @@ glsl_to_tgsi_visitor::visit_image_intrinsic(ir_call *ir)
st_dst_reg dst = undef_dst;
     if (ir->return_deref) {
        ir->return_deref->accept(this);
        dst = st_dst_reg(this->result);
        dst.writemask = (1 << ir->return_deref->type->vector_elements) - 1;
     }
glsl_to_tgsi_instruction *inst; + st_src_reg bindless;
+   if (imgvar->contains_bindless()) {
+      img->accept(this);
+      bindless = this->result;
+   }
+
     if (ir->callee->intrinsic_id == ir_intrinsic_image_size) {
        dst.writemask = WRITEMASK_XYZ;
        inst = emit_asm(ir, TGSI_OPCODE_RESQ, dst);
     } else if (ir->callee->intrinsic_id == ir_intrinsic_image_samples) {
        st_src_reg res = get_temp(glsl_type::ivec4_type);
        st_dst_reg dstres = st_dst_reg(res);
        dstres.writemask = WRITEMASK_W;
        inst = emit_asm(ir, TGSI_OPCODE_RESQ, dstres);
        res.swizzle = SWIZZLE_WWWW;
        emit_asm(ir, TGSI_OPCODE_MOV, dst, res);
@@ -3715,22 +3721,21 @@ glsl_to_tgsi_visitor::visit_image_intrinsic(ir_call *ir)
           assert(!"Unexpected intrinsic");
           return;
        }
inst = emit_asm(ir, opcode, dst, coord, arg1, arg2);
        if (opcode == TGSI_OPCODE_STORE)
           inst->dst[0].writemask = WRITEMASK_XYZW;
     }
if (imgvar->contains_bindless()) {
-      img->accept(this);
-      inst->resource = this->result;
+      inst->resource = bindless;
        inst->resource.swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y,
                                               SWIZZLE_X, SWIZZLE_Y);
     } else {
        inst->resource = image;
        inst->sampler_array_size = sampler_array_size;
        inst->sampler_base = sampler_base;
     }
inst->tex_target = type->sampler_index();
     inst->image_format = st_mesa_format_to_pipe_format(st_context(ctx),
@@ -4238,20 +4243,26 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir)
     get_deref_offsets(ir->sampler, &sampler_array_size, &sampler_base,
                       &index, &reladdr, !var->contains_bindless());
sampler.index = index;
     if (reladdr.file != PROGRAM_UNDEFINED) {
        sampler.reladdr = ralloc(mem_ctx, st_src_reg);
        *sampler.reladdr = reladdr;
        emit_arl(ir, sampler_reladdr, reladdr);
     }
+ st_src_reg bindless;
+   if (var->contains_bindless()) {
+      ir->sampler->accept(this);
+      bindless = this->result;
+   }
+
     if (opcode == TGSI_OPCODE_TXD)
        inst = emit_asm(ir, opcode, result_dst, coord, dx, dy);
     else if (opcode == TGSI_OPCODE_TXQ) {
        if (ir->op == ir_query_levels) {
           /* the level is stored in W */
           inst = emit_asm(ir, opcode, st_dst_reg(levels_src), lod_info);
           result_dst.writemask = WRITEMASK_X;
           levels_src.swizzle = SWIZZLE_WWWW;
           emit_asm(ir, TGSI_OPCODE_MOV, result_dst, levels_src);
        } else
@@ -4268,22 +4279,21 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir)
        } else {
           inst = emit_asm(ir, opcode, result_dst, coord, component);
        }
     } else
        inst = emit_asm(ir, opcode, result_dst, coord);
if (ir->shadow_comparator)
        inst->tex_shadow = GL_TRUE;
if (var->contains_bindless()) {
-      ir->sampler->accept(this);
-      inst->resource = this->result;
+      inst->resource = bindless;
        inst->resource.swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y,
                                               SWIZZLE_X, SWIZZLE_Y);
     } else {
        inst->resource = sampler;
        inst->sampler_array_size = sampler_array_size;
        inst->sampler_base = sampler_base;
     }
if (ir->offset) {
        if (!inst->tex_offsets)

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to