From 1467ba0d8f1e38caab44470c8b6a8a7e37f0818f Mon Sep 17 00:00:00 2001
From: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Date: Thu, 16 May 2024 12:45:20 -0400
Subject: [PATCH] run: retry failed CORE|COMPAT compiles with ES contexts

sometimes shaders are passed which don't specify a context type,
and these should be retried to ensure that they actually cannot be
compiled
---
 run.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/run.c b/run.c
index a91a8af..4b82a3b 100644
--- a/run.c
+++ b/run.c
@@ -739,6 +739,7 @@ main(int argc, char **argv)
 
         #pragma omp for schedule(dynamic)
         for (int i = 0; i < shader_test_length; i++) {
+            bool retry_ES = false;
             current_shader_name = shader_test[i].filename;
             current_shader_names[omp_get_thread_num()] = current_shader_name;
 
@@ -773,6 +774,7 @@ main(int argc, char **argv)
                 continue;
             }
 
+retry:
             if (current_type != type) {
                 EGLContext ctx;
 
@@ -835,6 +837,13 @@ main(int argc, char **argv)
                         else
                             glGetShaderInfoLog(s, 4096, &length, log);
 
+                        if (!retry_ES) {
+                            if (type == TYPE_CORE || type == TYPE_COMPAT) {
+                                retry_ES = true;
+                                type = TYPE_ES;
+                                goto retry;
+                            }
+                        }
                         fprintf(stderr, "ERROR: %s failed to compile:\n%s\n",
                                 current_shader_name, log);
                     }
-- 
GitLab