From 8419621176502f906aac80601eecfcdce5324ff4 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Tue, 12 Jun 2018 22:24:00 +0200 Subject: [PATCH] mesa/glspirv: Validate that compute shaders are not linked with other stages 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 --- src/mesa/main/glspirv.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/mesa/main/glspirv.c b/src/mesa/main/glspirv.c index 73878d90365..21a1beb8453 100644 --- a/src/mesa/main/glspirv.c +++ b/src/mesa/main/glspirv.c @@ -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 * -- 2.30.2