When calculating the binding table index for non-constant sampler
array indexing it needs to add the base binding table index which is a
constant within the generated code. Often this base is zero so we can
avoid a redundant instruction in that case.
It looks like nothing in shader-db is doing non-constant sampler array
indexing so this patch doesn't make any difference but it might be
worth having anyway.
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
Acked-by: Ben Widawsky <ben@bwidawsk.net>
/* addr = ((sampler * 0x101) + base_binding_table_index) & 0xfff */
brw_MUL(p, addr, sampler_reg, brw_imm_ud(0x101));
- brw_ADD(p, addr, addr, brw_imm_ud(base_binding_table_index));
+ if (base_binding_table_index)
+ brw_ADD(p, addr, addr, brw_imm_ud(base_binding_table_index));
brw_AND(p, addr, addr, brw_imm_ud(0xfff));
brw_pop_insn_state(p);
/* addr = ((sampler * 0x101) + base_binding_table_index) & 0xfff */
brw_MUL(p, addr, sampler_reg, brw_imm_ud(0x101));
- brw_ADD(p, addr, addr, brw_imm_ud(base_binding_table_index));
+ if (base_binding_table_index)
+ brw_ADD(p, addr, addr, brw_imm_ud(base_binding_table_index));
brw_AND(p, addr, addr, brw_imm_ud(0xfff));
brw_pop_insn_state(p);