opengl: Don't assert if vs_flip_loc == -1.
authorRyan C. Gordon <icculus@icculus.org>
Wed, 14 Oct 2020 16:43:03 -0400
changeset 1311 448b82b26acb
parent 1310 9f3b98d12a37
child 1312 f6fbe7e72735
opengl: Don't assert if vs_flip_loc == -1. This can be -1 if the GLSL compiler removed it, or if you bound a program without a vertex shader at all.
mojoshader_opengl.c
--- a/mojoshader_opengl.c	Tue Oct 13 01:23:44 2020 -0400
+++ b/mojoshader_opengl.c	Wed Oct 14 16:43:03 2020 -0400
@@ -2927,18 +2927,19 @@
     } // if
 
 #ifdef MOJOSHADER_FLIP_RENDERTARGET
-    assert(ctx->bound_program->vs_flip_loc != -1);
-
-    /* Some compilers require that vpFlip be a float value, rather than int.
-     * However, there's no real reason for it to be a float in the API, so we
-     * do a cast in here. That's not so bad, right...?
-     * -flibit
-     */
-    const int flip = renderTargetBound ? -1 : 1;
-    if (flip != ctx->bound_program->current_flip)
+    if (ctx->bound_program->vs_flip_loc != -1)
     {
-        ctx->glUniform1f(ctx->bound_program->vs_flip_loc, (float) flip);
-        ctx->bound_program->current_flip = flip;
+        /* Some compilers require that vpFlip be a float value, rather than int.
+         * However, there's no real reason for it to be a float in the API, so we
+         * do a cast in here. That's not so bad, right...?
+         * -flibit
+         */
+        const int flip = renderTargetBound ? -1 : 1;
+        if (flip != ctx->bound_program->current_flip)
+        {
+            ctx->glUniform1f(ctx->bound_program->vs_flip_loc, (float) flip);
+            ctx->bound_program->current_flip = flip;
+        } // if
     } // if
 #endif
 } // MOJOSHADER_glViewportInfo