<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Apr 12, 2018 at 7:36 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"><span class="">On Tue, Apr 10, 2018 at 5:10 PM, Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>> wrote:<br>
> On Tue, Apr 10, 2018 at 8:05 AM, Karol Herbst <<a href="mailto:kherbst@redhat.com">kherbst@redhat.com</a>> wrote:<br>
>><br>
>> 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<br>
>> 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 =<br>
>> ir->sampler->variable_<wbr>referenced()->contains_<wbr>bindless();<br>
><br>
><br>
> What happens if I have a uniform struct containing both a regular sampler<br>
> and a bindless sampler? I think this should be possible.<br>
><br>
<br>
</span>well currently mesa just fails to compile, but even if it would I<br>
don't see a way how we know with a ir_dereference if we reference a<br>
bindless or bound sampler.<br>
<br>
The glsl_type doesn't tell us either and maybe it makes sense to add a<br>
is_bindless method to glsl_type so that we can use it in places like<br>
here? ir->sampler->type gives me the sampler type, but lacks the<br>
information if it is bindless or not. Any thoughts?<br><div class="HOEnZb"><div class="h5"></div></div></blockquote><div><br></div><div>That seems like it's probably reasonable. I'm not sure if we really want different types. Another option would be to handle it as a layout qualifier on the structure type fields. I'm not sure which is better.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">
>><br>
>> +<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>
>> */<br>
>> nir_tex_src_sampler_offset, /* < dynamically uniform indirect offset<br>
>> */<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<br>
>> *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>
>> --<br>
>> 2.14.3<br>
>><br>
><br>
</div></div></blockquote></div><br></div></div>