<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Apr 10, 2018 at 8:05 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">v2: add both texture and sampler handles<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 | 17 +++++++++++++++--<br>
src/compiler/nir/nir.h | 2 ++<br>
src/compiler/nir/nir_print.c | 6 ++++++<br>
3 files changed, 23 insertions(+), 2 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 dbb58d82e8f..9f233637306 100644<br>
--- a/src/compiler/glsl/glsl_to_<wbr>nir.cpp<br>
+++ b/src/compiler/glsl/glsl_to_<wbr>nir.cpp<br>
@@ -1971,6 +1971,8 @@ nir_visitor::visit(ir_texture *ir)<br>
{<br>
unsigned num_srcs;<br>
nir_texop op;<br>
+ bool bindless = ir->sampler->variable_<wbr>referenced()->contains_<wbr>bindless();<br></blockquote><div><br></div><div>What happens if I have a uniform struct containing both a regular sampler and a bindless sampler? I think this should be possible.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
switch (ir->op) {<br>
case ir_tex:<br>
op = nir_texop_tex;<br>
@@ -2044,6 +2046,8 @@ nir_visitor::visit(ir_texture *ir)<br>
num_srcs++;<br>
if (ir->offset != NULL)<br>
num_srcs++;<br>
+ if (bindless)<br>
+ num_srcs++;<br>
<br>
nir_tex_instr *instr = nir_tex_instr_create(this-><wbr>shader, num_srcs);<br>
<br>
@@ -2069,10 +2073,19 @@ nir_visitor::visit(ir_texture *ir)<br>
unreachable("not reached");<br>
}<br>
<br>
- instr->texture = evaluate_deref(&instr->instr, ir->sampler);<br>
-<br>
unsigned src_number = 0;<br>
<br>
+ /* for bindless we use the texture handle src */<br>
+ if (bindless) {<br>
+ instr->texture = NULL;<br>
+ instr->src[src_number].src =<br>
+ nir_src_for_ssa(evaluate_<wbr>rvalue(ir->sampler));<br>
+ instr->src[src_number].src_<wbr>type = nir_tex_src_texture_handle;<br>
+ src_number++;<br>
+ } else {<br>
+ instr->texture = evaluate_deref(&instr->instr, ir->sampler);<br>
+ }<br>
+<br>
if (ir->coordinate != NULL) {<br>
instr->coord_components = ir->coordinate->type->vector_<wbr>elements;<br>
instr->src[src_number].src =<br>
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h<br>
index f33049d7134..e395352f89c 100644<br>
--- a/src/compiler/nir/nir.h<br>
+++ b/src/compiler/nir/nir.h<br>
@@ -1218,6 +1218,8 @@ typedef enum {<br>
nir_tex_src_texture_offset, /* < dynamically uniform indirect offset */<br>
nir_tex_src_sampler_offset, /* < dynamically uniform indirect offset */<br>
nir_tex_src_plane, /* < selects plane for planar textures */<br>
+ nir_tex_src_texture_handle, /* < handle for bindless texture */<br>
+ nir_tex_src_sampler_handle, /* < handle for bindless sampler */<br>
nir_num_tex_src_types<br>
} nir_tex_src_type;<br>
<br>
diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c<br>
index 21f13097651..52f20b1eb10 100644<br>
--- a/src/compiler/nir/nir_print.c<br>
+++ b/src/compiler/nir/nir_print.c<br>
@@ -778,6 +778,12 @@ print_tex_instr(nir_tex_instr *instr, print_state *state)<br>
case nir_tex_src_plane:<br>
fprintf(fp, "(plane)");<br>
break;<br>
+ case nir_tex_src_texture_handle:<br>
+ fprintf(fp, "(texture_handle)");<br>
+ break;<br>
+ case nir_tex_src_sampler_handle:<br>
+ fprintf(fp, "(sampler_handle)");<br>
+ break;<br>
<br>
default:<br>
unreachable("Invalid texture source type");<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.14.3<br>
<br>
</font></span></blockquote></div><br></div></div>