mojoshader.c
changeset 1163 c73c39a59dd4
parent 1162 de0613aa8f07
child 1164 006194daea99
equal deleted inserted replaced
1162:de0613aa8f07 1163:c73c39a59dd4
  4539     // Fill in the shader's mainline function signature.
  4539     // Fill in the shader's mainline function signature.
  4540     push_output(ctx, &ctx->mainline_intro);
  4540     push_output(ctx, &ctx->mainline_intro);
  4541     output_line(ctx, "%s %s%s %s (",
  4541     output_line(ctx, "%s %s%s %s (",
  4542                 shader_is_vertex(ctx) ? "vertex" : "fragment",
  4542                 shader_is_vertex(ctx) ? "vertex" : "fragment",
  4543                 ctx->outputs ? ctx->mainfn : "void",
  4543                 ctx->outputs ? ctx->mainfn : "void",
  4544                 ctx->outputs ? "Output" : "", ctx->mainfn);
  4544                 ctx->outputs ? "_Output" : "", ctx->mainfn);
  4545     pop_output(ctx);
  4545     pop_output(ctx);
  4546 
  4546 
  4547     push_output(ctx, &ctx->mainline_arguments);
  4547     push_output(ctx, &ctx->mainline_arguments);
  4548     ctx->indent++;
  4548     ctx->indent++;
  4549 
  4549 
  4554     if (commas) commas--;
  4554     if (commas) commas--;
  4555 
  4555 
  4556     if (uniform_count > 0)
  4556     if (uniform_count > 0)
  4557     {
  4557     {
  4558         push_output(ctx, &ctx->globals);
  4558         push_output(ctx, &ctx->globals);
  4559         output_line(ctx, "struct %sUniforms", ctx->mainfn);
  4559         output_line(ctx, "struct %s_Uniforms", ctx->mainfn);
  4560         output_line(ctx, "{");
  4560         output_line(ctx, "{");
  4561         ctx->indent++;
  4561         ctx->indent++;
  4562         if (ctx->uniform_float4_count > 0)
  4562         if (ctx->uniform_float4_count > 0)
  4563             output_line(ctx, "float4 uniforms_float4[%d];", ctx->uniform_float4_count);
  4563             output_line(ctx, "float4 uniforms_float4[%d];", ctx->uniform_float4_count);
  4564         if (ctx->uniform_int4_count > 0)
  4564         if (ctx->uniform_int4_count > 0)
  4567             output_line(ctx, "bool uniforms_bool[%d];", ctx->uniform_bool_count);
  4567             output_line(ctx, "bool uniforms_bool[%d];", ctx->uniform_bool_count);
  4568         ctx->indent--;
  4568         ctx->indent--;
  4569         output_line(ctx, "};");
  4569         output_line(ctx, "};");
  4570         pop_output(ctx);
  4570         pop_output(ctx);
  4571 
  4571 
  4572         output_line(ctx, "constant %sUniforms &uniforms [[buffer(16)]]%s", ctx->mainfn, commas ? "," : "");
  4572         output_line(ctx, "constant %s_Uniforms &uniforms [[buffer(16)]]%s", ctx->mainfn, commas ? "," : "");
  4573         commas--;
  4573         commas--;
  4574     } // if
  4574     } // if
  4575 
  4575 
  4576     if (ctx->inputs)
  4576     if (ctx->inputs)
  4577     {
  4577     {
  4578         output_line(ctx, "%sInput input [[stage_in]]%s", ctx->mainfn, commas ? "," : "");
  4578         output_line(ctx, "%s_Input input [[stage_in]]%s", ctx->mainfn, commas ? "," : "");
  4579         commas--;
  4579         commas--;
  4580     } // if
  4580     } // if
  4581 
  4581 
  4582     ctx->indent--;
  4582     ctx->indent--;
  4583     output_line(ctx, ") {");
  4583     output_line(ctx, ") {");
  4584     if (ctx->outputs)
  4584     if (ctx->outputs)
  4585     {
  4585     {
  4586         ctx->indent++;
  4586         ctx->indent++;
  4587         output_line(ctx, "%sOutput output;", ctx->mainfn);
  4587         output_line(ctx, "%s_Output output;", ctx->mainfn);
  4588 
  4588 
  4589         push_output(ctx, &ctx->mainline);
  4589         push_output(ctx, &ctx->mainline);
  4590         ctx->indent++;
  4590         ctx->indent++;
  4591         output_line(ctx, "return output;");
  4591         output_line(ctx, "return output;");
  4592         pop_output(ctx);
  4592         pop_output(ctx);
  4876         if (regtype == REG_TYPE_INPUT)
  4876         if (regtype == REG_TYPE_INPUT)
  4877         {
  4877         {
  4878             push_output(ctx, &ctx->inputs);
  4878             push_output(ctx, &ctx->inputs);
  4879             if (buffer_size(ctx->inputs) == 0)
  4879             if (buffer_size(ctx->inputs) == 0)
  4880             {
  4880             {
  4881                 output_line(ctx, "struct %sInput", ctx->mainfn);
  4881                 output_line(ctx, "struct %s_Input", ctx->mainfn);
  4882                 output_line(ctx, "{");
  4882                 output_line(ctx, "{");
  4883             } // if
  4883             } // if
  4884 
  4884 
  4885             ctx->indent++;
  4885             ctx->indent++;
  4886             output_line(ctx, "float4 %s [[attribute(%d)]];", var, regnum);
  4886             output_line(ctx, "float4 %s [[attribute(%d)]];", var, regnum);
  4901         else if (regtype == REG_TYPE_OUTPUT)
  4901         else if (regtype == REG_TYPE_OUTPUT)
  4902         {
  4902         {
  4903             push_output(ctx, &ctx->outputs);
  4903             push_output(ctx, &ctx->outputs);
  4904             if (buffer_size(ctx->outputs) == 0)
  4904             if (buffer_size(ctx->outputs) == 0)
  4905             {
  4905             {
  4906                 output_line(ctx, "struct %sOutput", ctx->mainfn);
  4906                 output_line(ctx, "struct %s_Output", ctx->mainfn);
  4907                 output_line(ctx, "{");
  4907                 output_line(ctx, "{");
  4908             } // if
  4908             } // if
  4909 
  4909 
  4910             ctx->indent++;
  4910             ctx->indent++;
  4911 
  4911 
  4964         if ((regtype == REG_TYPE_COLOROUT) || (regtype == REG_TYPE_DEPTHOUT))
  4964         if ((regtype == REG_TYPE_COLOROUT) || (regtype == REG_TYPE_DEPTHOUT))
  4965         {
  4965         {
  4966             push_output(ctx, &ctx->outputs);
  4966             push_output(ctx, &ctx->outputs);
  4967             if (buffer_size(ctx->outputs) == 0)
  4967             if (buffer_size(ctx->outputs) == 0)
  4968             {
  4968             {
  4969                 output_line(ctx, "struct %sOutput", ctx->mainfn);
  4969                 output_line(ctx, "struct %s_Output", ctx->mainfn);
  4970                 output_line(ctx, "{");
  4970                 output_line(ctx, "{");
  4971             } // if
  4971             } // if
  4972             ctx->indent++;
  4972             ctx->indent++;
  4973 
  4973 
  4974             if (regtype == REG_TYPE_COLOROUT)
  4974             if (regtype == REG_TYPE_COLOROUT)
  4997         {
  4997         {
  4998             int skipreference = 0;
  4998             int skipreference = 0;
  4999             push_output(ctx, &ctx->inputs);
  4999             push_output(ctx, &ctx->inputs);
  5000             if (buffer_size(ctx->inputs) == 0)
  5000             if (buffer_size(ctx->inputs) == 0)
  5001             {
  5001             {
  5002                 output_line(ctx, "struct %sInput", ctx->mainfn);
  5002                 output_line(ctx, "struct %s_Input", ctx->mainfn);
  5003                 output_line(ctx, "{");
  5003                 output_line(ctx, "{");
  5004             } // if
  5004             } // if
  5005             ctx->indent++;
  5005             ctx->indent++;
  5006 
  5006 
  5007             if (regtype == REG_TYPE_MISCTYPE)
  5007             if (regtype == REG_TYPE_MISCTYPE)