mojoshader.c
changeset 1158 94bbbdd9a344
parent 1157 d7282ef4110f
child 1159 d4f97945e2f5
equal deleted inserted replaced
1157:d7282ef4110f 1158:94bbbdd9a344
  4480             ctx->mainfn = StrDup(ctx, "VertexShader");
  4480             ctx->mainfn = StrDup(ctx, "VertexShader");
  4481         else if (shader_is_pixel(ctx))
  4481         else if (shader_is_pixel(ctx))
  4482             ctx->mainfn = StrDup(ctx, "FragmentShader");
  4482             ctx->mainfn = StrDup(ctx, "FragmentShader");
  4483     } // if
  4483     } // if
  4484 
  4484 
  4485     push_output(ctx, &ctx->globals);
       
  4486     output_line(ctx, "using namespace metal;");
       
  4487     pop_output(ctx);
       
  4488 
       
  4489     set_output(ctx, &ctx->mainline);
  4485     set_output(ctx, &ctx->mainline);
  4490     ctx->indent++;
  4486     ctx->indent++;
  4491 } // emit_METAL_start
  4487 } // emit_METAL_start
  4492 
  4488 
  4493 static void emit_METAL_RET(Context *ctx);
  4489 static void emit_METAL_RET(Context *ctx);
  4549 } // output_METAL_uniform_array
  4545 } // output_METAL_uniform_array
  4550 
  4546 
  4551 static void emit_METAL_finalize(Context *ctx)
  4547 static void emit_METAL_finalize(Context *ctx)
  4552 {
  4548 {
  4553     // throw some blank lines around to make source more readable.
  4549     // throw some blank lines around to make source more readable.
  4554     push_output(ctx, &ctx->globals);
  4550     if (ctx->globals)  // don't add a blank line if the section is empty.
  4555     output_blank_line(ctx);
  4551     {
  4556     pop_output(ctx);
  4552         push_output(ctx, &ctx->globals);
       
  4553         output_blank_line(ctx);
       
  4554         pop_output(ctx);
       
  4555     } // if
  4557 
  4556 
  4558     // If we had a relative addressing of REG_TYPE_INPUT, we need to build
  4557     // If we had a relative addressing of REG_TYPE_INPUT, we need to build
  4559     //  an array for it at the start of main(). GLSL doesn't let you specify
  4558     //  an array for it at the start of main(). GLSL doesn't let you specify
  4560     //  arrays of attributes.
  4559     //  arrays of attributes.
  4561     //float4 blah_array[BIGGEST_ARRAY];
  4560     //float4 blah_array[BIGGEST_ARRAY];
  4573     INC_METAL_HEADER(relational);
  4572     INC_METAL_HEADER(relational);
  4574     INC_METAL_HEADER(geometric);
  4573     INC_METAL_HEADER(geometric);
  4575     INC_METAL_HEADER(graphics);
  4574     INC_METAL_HEADER(graphics);
  4576     INC_METAL_HEADER(texture);
  4575     INC_METAL_HEADER(texture);
  4577     #undef INC_METAL_HEADER
  4576     #undef INC_METAL_HEADER
       
  4577     output_blank_line(ctx);
       
  4578     output_line(ctx, "using namespace metal;");
  4578     output_blank_line(ctx);
  4579     output_blank_line(ctx);
  4579     pop_output(ctx);
  4580     pop_output(ctx);
  4580 
  4581 
  4581     // Fill in the shader's mainline function signature.
  4582     // Fill in the shader's mainline function signature.
  4582     push_output(ctx, &ctx->mainline_intro);
  4583     push_output(ctx, &ctx->mainline_intro);