mojoshader.c
changeset 1169 68e644e677fd
parent 1164 006194daea99
child 1173 4b2f745c643b
equal deleted inserted replaced
1168:ddd9304d03a8 1169:68e644e677fd
  4083     return buf;
  4083     return buf;
  4084 } // get_METAL_const_array_varname_in_buf
  4084 } // get_METAL_const_array_varname_in_buf
  4085 
  4085 
  4086 static const char *get_METAL_const_array_varname(Context *ctx, int base, int size)
  4086 static const char *get_METAL_const_array_varname(Context *ctx, int base, int size)
  4087 {
  4087 {
  4088     char buf[64];
  4088     char buf[128];
  4089     get_METAL_const_array_varname_in_buf(ctx, base, size, buf, sizeof (buf));
  4089     get_METAL_const_array_varname_in_buf(ctx, base, size, buf, sizeof (buf));
  4090     return StrDup(ctx, buf);
  4090     return StrDup(ctx, buf);
  4091 } // get_METAL_const_array_varname
  4091 } // get_METAL_const_array_varname
  4092 
  4092 
  4093 
  4093 
  4360     char rel_swizzle[4] = { '\0' };
  4360     char rel_swizzle[4] = { '\0' };
  4361     const char *rel_regtype_str = "";
  4361     const char *rel_regtype_str = "";
  4362     if (arg->relative)
  4362     if (arg->relative)
  4363     {
  4363     {
  4364         if (arg->regtype == REG_TYPE_INPUT)
  4364         if (arg->regtype == REG_TYPE_INPUT)
  4365             regtype_str=get_METAL_input_array_varname(ctx,(char*)alloca(64),64);
  4365             regtype_str=get_METAL_input_array_varname(ctx,(char*)alloca(128),128);
  4366         else
  4366         else
  4367         {
  4367         {
  4368             assert(arg->regtype == REG_TYPE_CONST);
  4368             assert(arg->regtype == REG_TYPE_CONST);
  4369             const int arrayidx = arg->relative_array->index;
  4369             const int arrayidx = arg->relative_array->index;
  4370             const int offset = arg->regnum - arrayidx;
  4370             const int offset = arg->regnum - arrayidx;
  4371             assert(offset >= 0);
  4371             assert(offset >= 0);
  4372             if (arg->relative_array->constant)
  4372             if (arg->relative_array->constant)
  4373             {
  4373             {
  4374                 const int arraysize = arg->relative_array->count;
  4374                 const int arraysize = arg->relative_array->count;
  4375                 regtype_str = get_METAL_const_array_varname_in_buf(ctx,
  4375                 regtype_str = get_METAL_const_array_varname_in_buf(ctx,
  4376                                 arrayidx, arraysize, (char *) alloca(64), 64);
  4376                                 arrayidx, arraysize, (char *) alloca(128), 128);
  4377                 if (offset != 0)
  4377                 if (offset != 0)
  4378                     snprintf(rel_offset, sizeof (rel_offset), "%d + ", offset);
  4378                     snprintf(rel_offset, sizeof (rel_offset), "%d + ", offset);
  4379             } // if
  4379             } // if
  4380             else
  4380             else
  4381             {
  4381             {
  4677 } // emit_METAL_array
  4677 } // emit_METAL_array
  4678 
  4678 
  4679 static void emit_METAL_const_array(Context *ctx, const ConstantsList *clist,
  4679 static void emit_METAL_const_array(Context *ctx, const ConstantsList *clist,
  4680                                    int base, int size)
  4680                                    int base, int size)
  4681 {
  4681 {
  4682     char varname[64];
  4682     char varname[128];
  4683     get_METAL_const_array_varname_in_buf(ctx,base,size,varname,sizeof(varname));
  4683     get_METAL_const_array_varname_in_buf(ctx,base,size,varname,sizeof(varname));
  4684 
  4684 
  4685     const char *cstr = NULL;
  4685     const char *cstr = NULL;
  4686     push_output(ctx, &ctx->globals);
  4686     push_output(ctx, &ctx->globals);
  4687     output_line(ctx, "constant float4 %s[%d] = {", varname, size);
  4687     output_line(ctx, "constant float4 %s[%d] = {", varname, size);
  4722     //  uniforms.uniforms_float4[0]. As we push one big struct, this will
  4722     //  uniforms.uniforms_float4[0]. As we push one big struct, this will
  4723     //  prevent uploading unused data.
  4723     //  prevent uploading unused data.
  4724 
  4724 
  4725     const char *utype = get_METAL_uniform_type(ctx, regtype);
  4725     const char *utype = get_METAL_uniform_type(ctx, regtype);
  4726     char varname[64];
  4726     char varname[64];
  4727     char name[64];
  4727     char name[128];
  4728     int index = 0;
  4728     int index = 0;
  4729 
  4729 
  4730     get_METAL_varname_in_buf(ctx, regtype, regnum, varname, sizeof (varname));
  4730     get_METAL_varname_in_buf(ctx, regtype, regnum, varname, sizeof (varname));
  4731 
  4731 
  4732     push_output(ctx, &ctx->mainline_top);
  4732     push_output(ctx, &ctx->mainline_top);