From 62c954fa36a605786d3980cf417e969a9d02e02b Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Thu, 25 Jun 2020 10:35:29 -0400 Subject: [PATCH] Add getError to effectShaderContext --- mojoshader_effects.c | 12 ++++++++++++ mojoshader_effects.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/mojoshader_effects.c b/mojoshader_effects.c index 39f83fb6..f609ead8 100644 --- a/mojoshader_effects.c +++ b/mojoshader_effects.c @@ -686,6 +686,12 @@ static void readsmallobjects(const uint32 numsmallobjects, 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 @@ static void readlargeobjects(const uint32 numlargeobjects, 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) { diff --git a/mojoshader_effects.h b/mojoshader_effects.h index f5f18a94..6eb8ab56 100644 --- a/mojoshader_effects.h +++ b/mojoshader_effects.h @@ -506,6 +506,7 @@ typedef void (MOJOSHADERCALL * MOJOSHADER_mapUniformBufferMemoryFunc)( 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 @@ typedef struct MOJOSHADER_effectShaderContext MOJOSHADER_getBoundShadersFunc getBoundShaders; MOJOSHADER_mapUniformBufferMemoryFunc mapUniformBufferMemory; MOJOSHADER_unmapUniformBufferMemoryFunc unmapUniformBufferMemory; + MOJOSHADER_getErrorFunc getError; /* Allocator */ MOJOSHADER_malloc m;