From c54fb916353b47c854379a921c6310e3fde1896f Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Wed, 19 Apr 2017 15:57:56 +0200 Subject: st/glsl_to_tgsi: add support for bindless samplers Signed-off-by: Samuel Pitoiset --- src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 01cfc589c4..a79acc427c 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -289,6 +289,7 @@ public: st_dst_reg dst[2]; st_src_reg src[4]; st_src_reg resource; /**< sampler or buffer register */ + st_src_reg sampler; st_src_reg *tex_offsets; /** Pointer to the ir source this tree came from for debugging */ @@ -4137,6 +4138,7 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir) unsigned sampler_array_size = 1, sampler_base = 0; uint16_t sampler_index = 0; bool is_cube_array = false, is_cube_shadow = false; + ir_variable *var; unsigned i; /* if we are a cube array sampler or a cube shadow */ @@ -4400,9 +4402,17 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir) if (ir->shadow_comparator) inst->tex_shadow = GL_TRUE; - inst->resource.index = sampler_index; - inst->sampler_array_size = sampler_array_size; - inst->sampler_base = sampler_base; + var = ir->sampler->variable_referenced(); + if (var->data.bindless) { + ir->sampler->accept(this); + inst->sampler = this->result; + inst->sampler.swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, + SWIZZLE_X, SWIZZLE_Y); + } else { + inst->resource.index = sampler_index; + inst->sampler_array_size = sampler_array_size; + inst->sampler_base = sampler_base; + } if (reladdr.file != PROGRAM_UNDEFINED) { inst->resource.reladdr = ralloc(mem_ctx, st_src_reg); @@ -5815,7 +5825,12 @@ compile_tgsi_instruction(struct st_translate *t, case TGSI_OPCODE_TXL2: case TGSI_OPCODE_TG4: case TGSI_OPCODE_LODQ: - src[num_src] = t->samplers[inst->resource.index]; + if (inst->sampler.file == PROGRAM_UNIFORM || + inst->sampler.file == PROGRAM_TEMPORARY) { + src[num_src] = translate_src(t, &inst->sampler); + } else { + src[num_src] = t->samplers[inst->resource.index]; + } assert(src[num_src].File != TGSI_FILE_NULL); if (inst->resource.reladdr) src[num_src] = -- cgit v1.2.3