[Mesa-dev] [RFC PATCH 32/65] st/glsl_to_tgsi: add support for bindless samplers
Samuel Pitoiset
samuel.pitoiset at gmail.com
Fri May 19 16:52:37 UTC 2017
Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index ef6597e083..5734d0e456 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -306,6 +306,7 @@ public:
unsigned tex_offset_num_offset:3;
unsigned dead_mask:4; /**< Used in dead code elimination */
unsigned buffer_access:3; /**< buffer access type */
+ unsigned bindless:1; /**< bindless sampler/image */
const struct tgsi_opcode_info *info;
};
@@ -4154,6 +4155,7 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir)
const glsl_type *sampler_type = ir->sampler->type;
unsigned sampler_array_size = 1, sampler_base = 0;
bool is_cube_array = false, is_cube_shadow = false;
+ ir_variable *var = ir->sampler->variable_referenced();
unsigned i;
/* if we are a cube array sampler or a cube shadow */
@@ -4386,7 +4388,7 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir)
st_src_reg sampler(PROGRAM_SAMPLER, 0, GLSL_TYPE_UINT);
get_deref_offsets(ir->sampler, &sampler_array_size, &sampler_base,
- (uint16_t *)&sampler.index, &reladdr, true);
+ (uint16_t *)&sampler.index, &reladdr, !var->is_bindless());
if (reladdr.file != PROGRAM_UNDEFINED) {
sampler.reladdr = ralloc(mem_ctx, st_src_reg);
@@ -4423,9 +4425,17 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir)
if (ir->shadow_comparator)
inst->tex_shadow = GL_TRUE;
- inst->resource = sampler;
- inst->sampler_array_size = sampler_array_size;
- inst->sampler_base = sampler_base;
+ if (var->is_bindless()) {
+ ir->sampler->accept(this);
+ inst->resource = this->result;
+ inst->resource.swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y,
+ SWIZZLE_X, SWIZZLE_Y);
+ inst->bindless = 1;
+ } else {
+ inst->resource = sampler;
+ inst->sampler_array_size = sampler_array_size;
+ inst->sampler_base = sampler_base;
+ }
if (ir->offset) {
if (!inst->tex_offsets)
@@ -5856,7 +5866,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->resource.file == PROGRAM_SAMPLER) {
+ src[num_src] = t->samplers[inst->resource.index];
+ } else {
+ /* Bindless samplers. */
+ src[num_src] = translate_src(t, &inst->resource);
+ }
assert(src[num_src].File != TGSI_FILE_NULL);
if (inst->resource.reladdr)
src[num_src] =
@@ -5873,7 +5888,7 @@ compile_tgsi_instruction(struct st_translate *t,
tex_target,
st_translate_texture_type(inst->tex_type),
texoffsets, inst->tex_offset_num_offset,
- src, num_src, 0);
+ src, num_src, inst->bindless);
return;
case TGSI_OPCODE_RESQ:
--
2.13.0
More information about the mesa-dev
mailing list