[Mesa-dev] [PATCH 2/4] nir: add support for bindless_texture samplers

Jason Ekstrand jason at jlekstrand.net
Wed Apr 4 14:53:23 UTC 2018


On Wed, Apr 4, 2018 at 3:18 AM, Karol Herbst <kherbst at redhat.com> wrote:

> On Wed, Apr 4, 2018 at 2:16 AM, Jason Ekstrand <jason at jlekstrand.net>
> wrote:
> > On Tue, Apr 3, 2018 at 6:21 AM, Karol Herbst <kherbst at redhat.com> wrote:
> >>
> >> Signed-off-by: Karol Herbst <kherbst at redhat.com>
> >> ---
> >>  src/compiler/glsl/glsl_to_nir.cpp | 17 +++++++++++++++--
> >>  src/compiler/nir/nir.h            |  1 +
> >>  src/compiler/nir/nir_print.c      |  3 +++
> >>  3 files changed, 19 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/src/compiler/glsl/glsl_to_nir.cpp
> >> b/src/compiler/glsl/glsl_to_nir.cpp
> >> index dbb58d82e8f..8e2d96a2361 100644
> >> --- a/src/compiler/glsl/glsl_to_nir.cpp
> >> +++ b/src/compiler/glsl/glsl_to_nir.cpp
> >> @@ -1971,6 +1971,8 @@ nir_visitor::visit(ir_texture *ir)
> >>  {
> >>     unsigned num_srcs;
> >>     nir_texop op;
> >> +   bool bindless =
> >> ir->sampler->variable_referenced()->contains_bindless();
> >> +
> >>     switch (ir->op) {
> >>     case ir_tex:
> >>        op = nir_texop_tex;
> >> @@ -2044,6 +2046,8 @@ nir_visitor::visit(ir_texture *ir)
> >>        num_srcs++;
> >>     if (ir->offset != NULL)
> >>        num_srcs++;
> >> +   if (bindless)
> >> +      num_srcs=+;
> >>
> >>     nir_tex_instr *instr = nir_tex_instr_create(this->shader,
> num_srcs);
> >>
> >> @@ -2069,10 +2073,19 @@ nir_visitor::visit(ir_texture *ir)
> >>        unreachable("not reached");
> >>     }
> >>
> >> -   instr->texture = evaluate_deref(&instr->instr, ir->sampler);
> >> -
> >>     unsigned src_number = 0;
> >>
> >> +   /* for bindless we use the handle src */
> >> +   if (bindless) {
> >> +      instr->texture = NULL;
> >> +      instr->src[src_number].src =
> >> +         nir_src_for_ssa(evaluate_rvalue(ir->sampler));
> >> +      instr->src[src_number].src_type = nir_tex_src_handle;
> >> +      src_number++;
> >> +   } else {
> >> +      instr->texture = evaluate_deref(&instr->instr, ir->sampler);
> >> +   }
> >> +
> >>     if (ir->coordinate != NULL) {
> >>        instr->coord_components = ir->coordinate->type->vector_elements;
> >>        instr->src[src_number].src =
> >> diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
> >> index f33049d7134..e4d626d263e 100644
> >> --- a/src/compiler/nir/nir.h
> >> +++ b/src/compiler/nir/nir.h
> >> @@ -1218,6 +1218,7 @@ typedef enum {
> >>     nir_tex_src_texture_offset, /* < dynamically uniform indirect offset
> >> */
> >>     nir_tex_src_sampler_offset, /* < dynamically uniform indirect offset
> >> */
> >>     nir_tex_src_plane,          /* < selects plane for planar textures
> */
> >> +   nir_tex_src_handle,         /* < handle for bindless samples */
> >
> >
> > Do we want to have separate texture and sampler handles?  We don't care
> for
> > GL but I kind-of think we will for Vulkan.
> >
>
> Don't know. Never looked into vulkan yet. I could rename it to
> sample_handle for now and we can add the texture handle later for
> vulkan?
>

Sure.  Or we can just add both now and add nir_print support for both and
then we have them.  It's just an enum.  It's not like it costs us much.


> >>
> >>     nir_num_tex_src_types
> >>  } nir_tex_src_type;
> >>
> >> diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c
> >> index 21f13097651..c9431555f2f 100644
> >> --- a/src/compiler/nir/nir_print.c
> >> +++ b/src/compiler/nir/nir_print.c
> >> @@ -778,6 +778,9 @@ print_tex_instr(nir_tex_instr *instr, print_state
> >> *state)
> >>        case nir_tex_src_plane:
> >>           fprintf(fp, "(plane)");
> >>           break;
> >> +      case nir_tex_src_handle:
> >> +         fprintf(fp, "(handle)");
> >> +         break;
> >>
> >>        default:
> >>           unreachable("Invalid texture source type");
> >> --
> >> 2.14.3
> >>
> >> _______________________________________________
> >> mesa-dev mailing list
> >> mesa-dev at lists.freedesktop.org
> >> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180404/69037833/attachment.html>


More information about the mesa-dev mailing list