glsl: Check for SSBO variable in SSBO atomic lowering
authorJordan Justen <jordan.l.justen@intel.com>
Sat, 10 Oct 2015 00:43:53 +0000 (17:43 -0700)
committerJordan Justen <jordan.l.justen@intel.com>
Thu, 10 Dec 2015 07:50:38 +0000 (23:50 -0800)
When an atomic function is called, we need to check to see if it is
for an SSBO variable before lowering it to the SSBO specific intrinsic
function.

v2:
 * is_in_buffer_block => is_in_shader_storage_block (Iago)

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
src/glsl/lower_ubo_reference.cpp

index bbaf46160da1ce4b992763d1f802f763d2907c44..e088f4624be892b608857d098364f16d003e0d37 100644 (file)
@@ -979,6 +979,20 @@ lower_ubo_reference_visitor::lower_ssbo_atomic_intrinsic(ir_call *ir)
 ir_call *
 lower_ubo_reference_visitor::check_for_ssbo_atomic_intrinsic(ir_call *ir)
 {
+   exec_list& params = ir->actual_parameters;
+
+   if (params.length() < 2 || params.length() > 3)
+      return ir;
+
+   ir_rvalue *rvalue =
+      ((ir_instruction *) params.get_head())->as_rvalue();
+   if (!rvalue)
+      return ir;
+
+   ir_variable *var = rvalue->variable_referenced();
+   if (!var || !var->is_in_shader_storage_block())
+      return ir;
+
    const char *callee = ir->callee_name();
    if (!strcmp("__intrinsic_atomic_add", callee) ||
        !strcmp("__intrinsic_atomic_min", callee) ||