I implemented this first as a separate optimization pass in GLSL IR [1], but Curro pointed out that this being pretty much a restricted form of a CSE pass it would probably make more sense to do it inside CSE (and we no longer have a CSE pass in GLSL IR).
Unlike other things we CSE in NIR, in the case of SSBO loads we need to make sure that we invalidate previous entries in the set in the presence of conflicting instructions (i.e. SSBO writes to the same block and offset) or in the presence of memory barriers. If this is accepted I intend to extend this to also cover image reads, which follow similar behavior. No regressions observed in piglit or dEQP's SSBO functional tests. [1] http://lists.freedesktop.org/archives/mesa-dev/2015-October/097718.html Iago Toral Quiroga (2): nir/cse: invalidate SSBO loads in presence of ssbo writes or memory barriers nir/instr_set: allow rewrite of SSBO loads src/glsl/nir/nir_instr_set.c | 24 ++++++-- src/glsl/nir/nir_opt_cse.c | 142 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 162 insertions(+), 4 deletions(-) -- 1.9.1 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev