From 62ab376abbf5b57a98c7613bcfafb0ba71f73650 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 17 May 2016 16:13:05 -0400 Subject: [PATCH] Metal: Cleaned up output a little bit. --- mojoshader.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/mojoshader.c b/mojoshader.c index 933023e3..ef185f52 100644 --- a/mojoshader.c +++ b/mojoshader.c @@ -4482,10 +4482,6 @@ static void emit_METAL_start(Context *ctx, const char *profilestr) ctx->mainfn = StrDup(ctx, "FragmentShader"); } // if - push_output(ctx, &ctx->globals); - output_line(ctx, "using namespace metal;"); - pop_output(ctx); - set_output(ctx, &ctx->mainline); ctx->indent++; } // emit_METAL_start @@ -4551,9 +4547,12 @@ static void output_METAL_uniform_array(Context *ctx, const RegisterType regtype, static void emit_METAL_finalize(Context *ctx) { // throw some blank lines around to make source more readable. - push_output(ctx, &ctx->globals); - output_blank_line(ctx); - pop_output(ctx); + if (ctx->globals) // don't add a blank line if the section is empty. + { + push_output(ctx, &ctx->globals); + output_blank_line(ctx); + pop_output(ctx); + } // if // If we had a relative addressing of REG_TYPE_INPUT, we need to build // an array for it at the start of main(). GLSL doesn't let you specify @@ -4576,6 +4575,8 @@ static void emit_METAL_finalize(Context *ctx) INC_METAL_HEADER(texture); #undef INC_METAL_HEADER output_blank_line(ctx); + output_line(ctx, "using namespace metal;"); + output_blank_line(ctx); pop_output(ctx); // Fill in the shader's mainline function signature.