st_src_reg *indirect,
unsigned *location);
st_src_reg canonicalize_gather_offset(st_src_reg offset);
+ bool handle_bound_deref(ir_dereference *ir);
bool try_emit_mad(ir_expression *ir,
int mul_operand);
void
glsl_to_tgsi_visitor::visit(ir_dereference_variable *ir)
{
- variable_storage *entry = find_variable_storage(ir->var);
+ variable_storage *entry;
ir_variable *var = ir->var;
bool remove_array;
+ if (handle_bound_deref(ir->as_dereference()))
+ return;
+
+ entry = find_variable_storage(ir->var);
+
if (!entry) {
switch (var->data.mode) {
case ir_var_uniform:
bool is_2D = false;
ir_variable *var = ir->variable_referenced();
+ if (handle_bound_deref(ir->as_dereference()))
+ return;
+
/* We only need the logic provided by st_glsl_storage_type_size()
* for arrays of structs. Indirect sampler and image indexing is handled
* elsewhere.
ir_variable *var = ir->record->variable_referenced();
int offset = 0;
+ if (handle_bound_deref(ir->as_dereference()))
+ return;
+
ir->record->accept(this);
assert(ir->field_idx >= 0);
return offset;
}
+
+bool
+glsl_to_tgsi_visitor::handle_bound_deref(ir_dereference *ir)
+{
+ ir_variable *var = ir->variable_referenced();
+
+ if (!var || var->data.mode != ir_var_uniform || var->data.bindless ||
+ !(ir->type->is_image() || ir->type->is_sampler()))
+ return false;
+
+ /* Convert from bound sampler/image to bindless handle. */
+ bool is_image = ir->type->is_image();
+ st_src_reg resource(is_image ? PROGRAM_IMAGE : PROGRAM_SAMPLER, 0, GLSL_TYPE_UINT);
+ uint16_t index = 0;
+ unsigned array_size = 1, base = 0;
+ st_src_reg reladdr;
+ get_deref_offsets(ir, &array_size, &base, &index, &reladdr, true);
+
+ resource.index = index;
+ if (reladdr.file != PROGRAM_UNDEFINED) {
+ resource.reladdr = ralloc(mem_ctx, st_src_reg);
+ *resource.reladdr = reladdr;
+ emit_arl(ir, sampler_reladdr, reladdr);
+ }
+
+ this->result = get_temp(glsl_type::uvec2_type);
+ st_dst_reg dst(this->result);
+ dst.writemask = WRITEMASK_XY;
+
+ glsl_to_tgsi_instruction *inst = emit_asm(
+ ir, is_image ? TGSI_OPCODE_IMG2HND : TGSI_OPCODE_SAMP2HND, dst);
+
+ inst->tex_target = ir->type->sampler_index();
+ inst->resource = resource;
+ inst->sampler_array_size = array_size;
+ inst->sampler_base = base;
+
+ return true;
+}
void
glsl_to_tgsi_visitor::visit(ir_texture *ir)
case TGSI_OPCODE_TXL2:
case TGSI_OPCODE_TG4:
case TGSI_OPCODE_LODQ:
+ case TGSI_OPCODE_SAMP2HND:
if (inst->resource.file == PROGRAM_SAMPLER) {
src[num_src] = t->samplers[inst->resource.index];
} else {
case TGSI_OPCODE_ATOMUMAX:
case TGSI_OPCODE_ATOMIMIN:
case TGSI_OPCODE_ATOMIMAX:
+ case TGSI_OPCODE_IMG2HND:
for (i = num_src - 1; i >= 0; i--)
src[i + 1] = src[i];
num_src++;