glsl: Move misc face/position variables to after main, fixes ES3 compatibility
authorEthan Lee <flibitijibibo@flibitijibibo.com>
Sun, 10 Jan 2021 15:02:29 -0500
changeset 1320 f9036699b53a
parent 1319 cb1194078e48
child 1321 02f2aafb103c
glsl: Move misc face/position variables to after main, fixes ES3 compatibility
profiles/mojoshader_profile_glsl.c
--- a/profiles/mojoshader_profile_glsl.c	Thu Dec 31 15:56:57 2020 -0500
+++ b/profiles/mojoshader_profile_glsl.c	Sun Jan 10 15:02:29 2021 -0500
@@ -1109,16 +1109,21 @@
             const MiscTypeType mt = (MiscTypeType) regnum;
             if (mt == MISCTYPE_TYPE_FACE)
             {
-                push_output(ctx, &ctx->globals);
+                push_output(ctx, &ctx->mainline_intro);
+                ctx->indent++;
                 output_line(ctx, "float %s = gl_FrontFacing ? 1.0 : -1.0;", var);
                 pop_output(ctx);
                 return;
             } // if
             else if (mt == MISCTYPE_TYPE_POSITION)
             {
-                // TODO: For half-pixel offset compensation, floor() this value!
                 push_output(ctx, &ctx->globals);
                 output_line(ctx, "uniform vec2 vposFlip;");
+                pop_output(ctx);
+
+                // TODO: For half-pixel offset compensation, floor() this value!
+                push_output(ctx, &ctx->mainline_intro);
+                ctx->indent++;
                 output_line(ctx, "vec4 %s = vec4(gl_FragCoord.x, (gl_FragCoord.y * vposFlip.x) + vposFlip.y, gl_FragCoord.z, gl_FragCoord.w);", var);
                 pop_output(ctx);
                 return;