mesa/glspirv: Validate that compute shaders are not linked with other stages
authorNeil Roberts <nroberts@igalia.com>
Tue, 12 Jun 2018 20:24:00 +0000 (22:24 +0200)
committerAlejandro Piñeiro <apinheiro@igalia.com>
Fri, 12 Jul 2019 21:42:42 +0000 (23:42 +0200)
The test is based on link_shaders().

For example, it allows the following test (when run on SPIR-V mode) to
pass:
   spec/arb_compute_shader/linker/mix_compute_and_non_compute.shader_test

Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
src/mesa/main/glspirv.c

index 73878d903657b0b4c5f786569c032f92d77fc1af..21a1beb84536dc302217bab943685667ef718168 100644 (file)
@@ -203,6 +203,16 @@ _mesa_spirv_link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
          }
       }
    }
+
+   /* Compute shaders have additional restrictions. */
+   if ((prog->data->linked_stages & (1 << MESA_SHADER_COMPUTE)) &&
+       (prog->data->linked_stages & ~(1 << MESA_SHADER_COMPUTE))) {
+      ralloc_asprintf_append(&prog->data->InfoLog,
+                             "Compute shaders may not be linked with any other "
+                             "type of shader\n");
+      prog->data->LinkStatus = LINKING_FAILURE;
+      return;
+   }
 }
 
 nir_shader *