On Tue, Apr 10, 2018 at 8:05 AM, Karol Herbst <kher...@redhat.com> wrote:
> v2: add both texture and sampler handles > > Signed-off-by: Karol Herbst <kher...@redhat.com> > --- > src/compiler/glsl/glsl_to_nir.cpp | 17 +++++++++++++++-- > src/compiler/nir/nir.h | 2 ++ > src/compiler/nir/nir_print.c | 6 ++++++ > 3 files changed, 23 insertions(+), 2 deletions(-) > > diff --git a/src/compiler/glsl/glsl_to_nir.cpp > b/src/compiler/glsl/glsl_to_nir.cpp > index dbb58d82e8f..9f233637306 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(); > What happens if I have a uniform struct containing both a regular sampler and a bindless sampler? I think this should be possible. > + > 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 texture 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_texture_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..e395352f89c 100644 > --- a/src/compiler/nir/nir.h > +++ b/src/compiler/nir/nir.h > @@ -1218,6 +1218,8 @@ 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_texture_handle, /* < handle for bindless texture */ > + nir_tex_src_sampler_handle, /* < handle for bindless sampler */ > 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..52f20b1eb10 100644 > --- a/src/compiler/nir/nir_print.c > +++ b/src/compiler/nir/nir_print.c > @@ -778,6 +778,12 @@ print_tex_instr(nir_tex_instr *instr, print_state > *state) > case nir_tex_src_plane: > fprintf(fp, "(plane)"); > break; > + case nir_tex_src_texture_handle: > + fprintf(fp, "(texture_handle)"); > + break; > + case nir_tex_src_sampler_handle: > + fprintf(fp, "(sampler_handle)"); > + break; > > default: > unreachable("Invalid texture source type"); > -- > 2.14.3 > >
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev