From 2615f81f556b4458784cbae932d6876780ed0738 Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Sun, 10 Jan 2021 15:02:29 -0500 Subject: [PATCH] glsl: Move misc face/position variables to after main, fixes ES3 compatibility --- profiles/mojoshader_profile_glsl.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/profiles/mojoshader_profile_glsl.c b/profiles/mojoshader_profile_glsl.c index a02c9f8..d46ec79 100644 --- a/profiles/mojoshader_profile_glsl.c +++ b/profiles/mojoshader_profile_glsl.c @@ -1109,16 +1109,21 @@ void emit_GLSL_attribute(Context *ctx, RegisterType regtype, int regnum, 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;