<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Apr 3, 2018 at 6:21 AM, Karol Herbst <span dir="ltr"><<a href="mailto:kherbst@redhat.com" target="_blank">kherbst@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I added another source for all image_var_* intrinsics. Drivers have to be<br>
adjusted with this change.<br>
<br>
There was some discussion to add new intrinsics to handle operations on<br>
bindless images. Maybe we can continue with this here?<br>
<br>
Signed-off-by: Karol Herbst <<a href="mailto:kherbst@redhat.com">kherbst@redhat.com</a>><br>
---<br>
 src/compiler/glsl/glsl_to_nir.<wbr>cpp  | 19 +++++++++++++++++--<br>
 src/compiler/nir/nir.h             |  2 +-<br>
 src/compiler/nir/nir_<wbr>intrinsics.py | 24 ++++++++++++------------<br>
 3 files changed, 30 insertions(+), 15 deletions(-)<br>
<br>
diff --git a/src/compiler/glsl/glsl_to_<wbr>nir.cpp b/src/compiler/glsl/glsl_to_<wbr>nir.cpp<br>
index 1fc0cac4736..4e053c140c2 100644<br>
--- a/src/compiler/glsl/glsl_to_<wbr>nir.cpp<br>
+++ b/src/compiler/glsl/glsl_to_<wbr>nir.cpp<br>
@@ -894,10 +894,14 @@ nir_visitor::visit(ir_call *ir)<br>
          ir_dereference *image = (ir_dereference *)param;<br>
          const glsl_type *type =<br>
             image->type->without_array();<br>
+         bool bindless = image->variable_referenced()-><wbr>contains_bindless();<br>
<br>
          instr->variables[0] = evaluate_deref(&instr->instr, image);<br>
          param = param->get_next();<br>
<br>
+         if (bindless)<br>
+            instr->variables[0]->var-><wbr>data.bindless = true;<br>
+<br>
          /* Set the intrinsic destination. */<br>
          if (ir->return_deref) {<br>
             unsigned num_components = ir->return_deref->type-><wbr>vector_elements;<br>
@@ -909,6 +913,11 @@ nir_visitor::visit(ir_call *ir)<br>
<br>
          if (op == nir_intrinsic_image_var_size ||<br>
              op == nir_intrinsic_image_var_<wbr>samples) {<br>
+            if (bindless) {<br>
+               instr->src[0] = nir_src_for_ssa(evaluate_<wbr>rvalue(image));<br>
+            } else {<br>
+               instr->src[0] = nir_src_for_ssa(&instr_undef-><wbr>def);<br>
+            }<br>
             nir_builder_instr_insert(&b, &instr->instr);<br>
             break;<br>
          }<br>
@@ -941,15 +950,21 @@ nir_visitor::visit(ir_call *ir)<br>
             instr->src[1] = nir_src_for_ssa(&instr_undef-><wbr>def);<br>
          }<br>
<br>
+         if (bindless) {<br>
+            instr->src[2] = nir_src_for_ssa(evaluate_<wbr>rvalue(image));<br>
+         } else {<br>
+            instr->src[2] = nir_src_for_ssa(&instr_undef-><wbr>def);<br>
+         }<br>
+<br>
          /* Set the intrinsic parameters. */<br>
          if (!param->is_tail_sentinel()) {<br>
-            instr->src[2] =<br>
+            instr->src[3] =<br>
                nir_src_for_ssa(evaluate_<wbr>rvalue((ir_dereference *)param));<br>
             param = param->get_next();<br>
          }<br>
<br>
          if (!param->is_tail_sentinel()) {<br>
-            instr->src[3] =<br>
+            instr->src[4] =<br>
                nir_src_for_ssa(evaluate_<wbr>rvalue((ir_dereference *)param));<br>
             param = param->get_next();<br>
          }<br>
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h<br>
index e4d626d263e..c6081cbb61f 100644<br>
--- a/src/compiler/nir/nir.h<br>
+++ b/src/compiler/nir/nir.h<br>
@@ -1108,7 +1108,7 @@ typedef enum {<br>
<br>
 } nir_intrinsic_index_flag;<br>
<br>
-#define NIR_INTRINSIC_MAX_INPUTS 4<br>
+#define NIR_INTRINSIC_MAX_INPUTS 5<br>
<br>
 typedef struct {<br>
    const char *name;<br>
diff --git a/src/compiler/nir/nir_<wbr>intrinsics.py b/src/compiler/nir/nir_<wbr>intrinsics.py<br>
index 1bc99552cd7..d6da63ab769 100644<br>
--- a/src/compiler/nir/nir_<wbr>intrinsics.py<br>
+++ b/src/compiler/nir/nir_<wbr>intrinsics.py<br>
@@ -291,19 +291,19 @@ atomic3("atomic_counter_comp_<wbr>swap")<br>
 # argument with the value to be written, and image atomic operations take<br>
 # either one or two additional scalar arguments with the same meaning as in<br>
 # the ARB_shader_image_load_store specification.<br>
-intrinsic("image_var_load", src_comp=[4, 1], dest_comp=4, num_vars=1,<br>
+intrinsic("image_var_load", src_comp=[4, 1, 1], dest_comp=4, num_vars=1,<br>
           flags=[CAN_ELIMINATE])<br>
-intrinsic("image_var_store", src_comp=[4, 1, 4], num_vars=1)<br>
-intrinsic("image_var_atomic_<wbr>add",  src_comp=[4, 1, 1], dest_comp=1, num_vars=1)<br>
-intrinsic("image_var_atomic_<wbr>min",  src_comp=[4, 1, 1], dest_comp=1, num_vars=1)<br>
-intrinsic("image_var_atomic_<wbr>max",  src_comp=[4, 1, 1], dest_comp=1, num_vars=1)<br>
-intrinsic("image_var_atomic_<wbr>and",  src_comp=[4, 1, 1], dest_comp=1, num_vars=1)<br>
-intrinsic("image_var_atomic_<wbr>or",   src_comp=[4, 1, 1], dest_comp=1, num_vars=1)<br>
-intrinsic("image_var_atomic_<wbr>xor",  src_comp=[4, 1, 1], dest_comp=1, num_vars=1)<br>
-intrinsic("image_var_atomic_<wbr>exchange",  src_comp=[4, 1, 1], dest_comp=1, num_vars=1)<br>
-intrinsic("image_var_atomic_<wbr>comp_swap", src_comp=[4, 1, 1, 1], dest_comp=1, num_vars=1)<br>
-intrinsic("image_var_size",    dest_comp=0, num_vars=1, flags=[CAN_ELIMINATE, CAN_REORDER])<br>
-intrinsic("image_var_samples"<wbr>, dest_comp=1, num_vars=1, flags=[CAN_ELIMINATE, CAN_REORDER])<br>
+intrinsic("image_var_store", src_comp=[4, 1, 1, 4], num_vars=1)<br>
+intrinsic("image_var_atomic_<wbr>add",  src_comp=[4, 1, 1, 1], dest_comp=1, num_vars=1)<br>
+intrinsic("image_var_atomic_<wbr>min",  src_comp=[4, 1, 1, 1], dest_comp=1, num_vars=1)<br>
+intrinsic("image_var_atomic_<wbr>max",  src_comp=[4, 1, 1, 1], dest_comp=1, num_vars=1)<br>
+intrinsic("image_var_atomic_<wbr>and",  src_comp=[4, 1, 1, 1], dest_comp=1, num_vars=1)<br>
+intrinsic("image_var_atomic_<wbr>or",   src_comp=[4, 1, 1, 1], dest_comp=1, num_vars=1)<br>
+intrinsic("image_var_atomic_<wbr>xor",  src_comp=[4, 1, 1, 1], dest_comp=1, num_vars=1)<br>
+intrinsic("image_var_atomic_<wbr>exchange",  src_comp=[4, 1, 1, 1], dest_comp=1, num_vars=1)<br>
+intrinsic("image_var_atomic_<wbr>comp_swap", src_comp=[4, 1, 1, 1, 1], dest_comp=1, num_vars=1)<br>
+intrinsic("image_var_size",    src_comp=[1], dest_comp=0, num_vars=1, flags=[CAN_ELIMINATE, CAN_REORDER])<br>
+intrinsic("image_var_samples"<wbr>, src_comp=[1], dest_comp=1, num_vars=1, flags=[CAN_ELIMINATE, CAN_REORDER])<br></blockquote><div><br></div><div>I said this on IRC, but I really think we want separate intrinsics for bindless.  I really don't like them taking a handle from a source but then pulling a bunch of data from a variable.  Either use a variable or don't.  I'd rather we just add a set of bindless variants that have a handle as an additional source and some const indices for things such as format and qualifier flags (read/write-only). <br></div></div></div></div>