Since the backing storage for these is shared we cannot ensure that
the value won't change by writes from other threads. Normally SSBO
accesses are not guaranteed to be syncronized with other threads,
except when memoryBarrier is used. So, we might be able to optimize
some SSBO accesses, but for now we always take the safe path and emit
the SSBO access.
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
if (!deref->var->type->is_vector() && !deref->var->type->is_scalar())
return;
+ /* We can't do copy propagation on buffer variables, since the underlying
+ * memory storage is shared across multiple threads we can't be sure that
+ * the variable value isn't modified between this assignment and the next
+ * instruction where its value is read.
+ */
+ if (deref->var->data.mode == ir_var_shader_storage)
+ return;
+
entry = new(this->mem_ctx) acp_entry(deref->var, ir->write_mask, constant);
this->acp->push_tail(entry);
}