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

Karol Herbst kherbst at redhat.com
Tue Apr 3 13:43:42 UTC 2018


On Tue, Apr 3, 2018 at 3:21 PM, 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=+;

small type here, should have been "num_srcs++" instead.

>
>     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 */
>     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
>


More information about the mesa-dev mailing list