void nir_lower_bitmap(nir_shader *shader, const nir_lower_bitmap_options *options);
bool nir_lower_atomics(nir_shader *shader,
- const struct gl_shader_program *shader_program);
+ const struct gl_shader_program *shader_program,
+ bool use_binding_as_idx);
bool nir_lower_atomics_to_ssbo(nir_shader *shader, unsigned ssbo_offset);
bool nir_lower_to_source_mods(nir_shader *shader);
static bool
lower_instr(nir_intrinsic_instr *instr,
const struct gl_shader_program *shader_program,
- nir_shader *shader)
+ nir_shader *shader, bool use_binding_as_idx)
{
nir_intrinsic_op op;
switch (instr->intrinsic) {
void *mem_ctx = ralloc_parent(instr);
unsigned uniform_loc = instr->variables[0]->var->data.location;
+ unsigned idx = use_binding_as_idx ?
+ instr->variables[0]->var->data.binding :
+ shader_program->data->UniformStorage[uniform_loc].opaque[shader->info.stage].index;
+
nir_intrinsic_instr *new_instr = nir_intrinsic_instr_create(mem_ctx, op);
- nir_intrinsic_set_base(new_instr,
- shader_program->data->UniformStorage[uniform_loc].opaque[shader->info.stage].index);
+ nir_intrinsic_set_base(new_instr, idx);
nir_load_const_instr *offset_const =
nir_load_const_instr_create(mem_ctx, 1, 32);
bool
nir_lower_atomics(nir_shader *shader,
- const struct gl_shader_program *shader_program)
+ const struct gl_shader_program *shader_program,
+ bool use_binding_as_idx)
{
bool progress = false;
nir_foreach_instr_safe(instr, block) {
if (instr->type == nir_instr_type_intrinsic)
progress |= lower_instr(nir_instr_as_intrinsic(instr),
- shader_program, shader);
+ shader_program, shader,
+ use_binding_as_idx);
}
}
brw_shader_gather_info(prog->nir, prog);
NIR_PASS_V(prog->nir, nir_lower_samplers, shProg);
- NIR_PASS_V(prog->nir, nir_lower_atomics, shProg);
+ NIR_PASS_V(prog->nir, nir_lower_atomics, shProg, false);
NIR_PASS_V(prog->nir, nir_lower_atomics_to_ssbo,
prog->nir->info.num_abos);
st_set_prog_affected_state_flags(prog);
NIR_PASS_V(nir, st_nir_lower_builtin);
- NIR_PASS_V(nir, nir_lower_atomics, shader_program);
+ NIR_PASS_V(nir, nir_lower_atomics, shader_program, true);
if (st->ctx->_Shader->Flags & GLSL_DUMP) {
_mesa_log("\n");