Add getError to effectShaderContext
authorEthan Lee <flibitijibibo@flibitijibibo.com>
Thu, 25 Jun 2020 10:35:29 -0400
changeset 1270 fb28ba997299
parent 1269 5ed167069622
child 1271 5a67d082c55f
Add getError to effectShaderContext
mojoshader_effects.c
mojoshader_effects.h
--- a/mojoshader_effects.c	Thu Jun 25 10:10:52 2020 -0400
+++ b/mojoshader_effects.c	Thu Jun 25 10:35:29 2020 -0400
@@ -686,6 +686,12 @@
             object->shader.shader = effect->ctx.compileShader(mainfn, *ptr, length,
                                                               swiz, swizcount,
                                                               smap, smapcount);
+            if (object->shader.shader == NULL)
+            {
+                // Bail ASAP, so we can get the error to the application
+                errorlist_add(errors, NULL, 0, effect->ctx.getError());
+                return;
+            } // if
             pd = effect->ctx.getParseData(object->shader.shader);
             if (pd->error_count > 0)
             {
@@ -816,6 +822,12 @@
                 object->shader.shader = effect->ctx.compileShader(mainfn, *ptr, length,
                                                                   swiz, swizcount,
                                                                   smap, smapcount);
+                if (object->shader.shader == NULL)
+                {
+                    // Bail ASAP, so we can get the error to the application
+                    errorlist_add(errors, NULL, 0, effect->ctx.getError());
+                    return;
+                } // if
                 pd = effect->ctx.getParseData(object->shader.shader);
                 if (pd->error_count > 0)
                 {
--- a/mojoshader_effects.h	Thu Jun 25 10:10:52 2020 -0400
+++ b/mojoshader_effects.h	Thu Jun 25 10:35:29 2020 -0400
@@ -506,6 +506,7 @@
     float **psf, int **psi, unsigned char **psb
 );
 typedef void (MOJOSHADERCALL * MOJOSHADER_unmapUniformBufferMemoryFunc)();
+typedef const char* (MOJOSHADERCALL * MOJOSHADER_getErrorFunc)();
 
 typedef struct MOJOSHADER_effectShaderContext
 {
@@ -518,6 +519,7 @@
     MOJOSHADER_getBoundShadersFunc getBoundShaders;
     MOJOSHADER_mapUniformBufferMemoryFunc mapUniformBufferMemory;
     MOJOSHADER_unmapUniformBufferMemoryFunc unmapUniformBufferMemory;
+    MOJOSHADER_getErrorFunc getError;
 
     /* Allocator */
     MOJOSHADER_malloc m;