From 62ac0ee804027d1a1fa9864e03428ced7bd8510a Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Fri, 5 Dec 2014 14:46:24 -0800 Subject: [PATCH] nir/tex_instr: Rename the indirect source type and add an array size In particular, we rename nir_tex_src_sampler_index to _sampler_offset and add a sampler_array_size field to nir_tex_instr. This way we can pass the size of sampler arrays through to backends even after removing the variable information and, with it, the type. Reviewed-by: Connor Abbott --- src/glsl/nir/nir.c | 4 ++++ src/glsl/nir/nir.h | 11 ++++++++++- src/glsl/nir/nir_print.c | 4 ++-- src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 2 +- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c index e9035d449c3..b15440b0855 100644 --- a/src/glsl/nir/nir.c +++ b/src/glsl/nir/nir.c @@ -467,6 +467,10 @@ nir_tex_instr_create(void *mem_ctx, unsigned num_srcs) instr->has_predicate = false; src_init(&instr->predicate); + instr->sampler_index = 0; + instr->sampler_array_size = 0; + instr->sampler = NULL; + return instr; } diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h index ecd174a88ad..fe1f9a8682e 100644 --- a/src/glsl/nir/nir.h +++ b/src/glsl/nir/nir.h @@ -793,7 +793,7 @@ typedef enum { nir_tex_src_ms_index, /* MSAA sample index */ nir_tex_src_ddx, nir_tex_src_ddy, - nir_tex_src_sampler_index, /* < dynamically uniform indirect index */ + nir_tex_src_sampler_offset, /* < dynamically uniform indirect offset */ nir_num_texinput_types } nir_texinput_type; @@ -838,7 +838,16 @@ typedef struct { /* gather component selector */ unsigned component : 2; + /** The sampler index + * + * If this texture instruction has a nir_tex_src_sampler_offset source, + * then the sampler index is given by sampler_index + sampler_offset. + */ unsigned sampler_index; + + /** The size of the sampler array or 0 if it's not an array */ + unsigned sampler_array_size; + nir_deref_var *sampler; /* if this is NULL, use sampler_index instead */ } nir_tex_instr; diff --git a/src/glsl/nir/nir_print.c b/src/glsl/nir/nir_print.c index 68d0b6d1117..22a2a1d6557 100644 --- a/src/glsl/nir/nir_print.c +++ b/src/glsl/nir/nir_print.c @@ -464,8 +464,8 @@ print_tex_instr(nir_tex_instr *instr, print_var_state *state, FILE *fp) case nir_tex_src_ddy: fprintf(fp, "(ddy)"); break; - case nir_tex_src_sampler_index: - fprintf(fp, "(sampler_index)"); + case nir_tex_src_sampler_offset: + fprintf(fp, "(sampler_offset)"); break; default: diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp index a5360754648..1fe9fefe526 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp @@ -1662,7 +1662,7 @@ fs_visitor::nir_emit_texture(nir_tex_instr *instr) break; case nir_tex_src_projector: unreachable("should be lowered"); - case nir_tex_src_sampler_index: + case nir_tex_src_sampler_offset: unreachable("not yet supported"); default: unreachable("unknown texture source"); -- 2.30.2