mojoshader.c
branchtrunk
changeset 65 aa0b9bb40df7
parent 64 4f4bd3c7eef6
child 66 64c37d56e19f
equal deleted inserted replaced
64:4f4bd3c7eef6 65:aa0b9bb40df7
   670 } // get_D3D_register_string
   670 } // get_D3D_register_string
   671 
   671 
   672 
   672 
   673 static char *make_D3D_destarg_string(Context *ctx, const int idx)
   673 static char *make_D3D_destarg_string(Context *ctx, const int idx)
   674 {
   674 {
       
   675     char *retval = get_scratch_buffer(ctx);
       
   676     *retval = '\0';  // truncate string to start.
       
   677 
   675     if (idx >= STATICARRAYLEN(ctx->dest_args))
   678     if (idx >= STATICARRAYLEN(ctx->dest_args))
   676     {
   679     {
   677         fail(ctx, "Too many destination args");
   680         fail(ctx, "Too many destination args");
   678         return "";
   681         return retval;
   679     } // if
   682     } // if
   680 
   683 
   681     const DestArgInfo *arg = &ctx->dest_args[idx];
   684     const DestArgInfo *arg = &ctx->dest_args[idx];
   682 
   685 
   683     const char *result_shift_str = "";
   686     const char *result_shift_str = "";
   700                                                       arg->regnum, regnum_str,
   703                                                       arg->regnum, regnum_str,
   701                                                       sizeof (regnum_str));
   704                                                       sizeof (regnum_str));
   702     if (regtype_str == NULL)
   705     if (regtype_str == NULL)
   703     {
   706     {
   704         fail(ctx, "Unknown destination register type.");
   707         fail(ctx, "Unknown destination register type.");
   705         return "";
   708         return retval;
   706     } // if
   709     } // if
   707 
   710 
   708     char writemask_str[6];
   711     char writemask_str[6];
   709     int i = 0;
   712     int i = 0;
   710     if (arg->writemask != 0xF)  // 0xF == 1111. No explicit mask.
   713     if (arg->writemask != 0xF)  // 0xF == 1111. No explicit mask.
   717     } // if
   720     } // if
   718     writemask_str[i] = '\0';
   721     writemask_str[i] = '\0';
   719     assert(i < sizeof (writemask_str));
   722     assert(i < sizeof (writemask_str));
   720 
   723 
   721     // may turn out something like "_x2_sat_pp_centroid r0.xyzw" ...
   724     // may turn out something like "_x2_sat_pp_centroid r0.xyzw" ...
   722     char *retval = get_scratch_buffer(ctx);
       
   723     snprintf(retval, SCRATCH_BUFFER_SIZE, "%s%s%s%s %s%s%s",
   725     snprintf(retval, SCRATCH_BUFFER_SIZE, "%s%s%s%s %s%s%s",
   724              result_shift_str, sat_str, pp_str, cent_str,
   726              result_shift_str, sat_str, pp_str, cent_str,
   725              regtype_str, regnum_str, writemask_str);
   727              regtype_str, regnum_str, writemask_str);
   726     return retval;
   728     return retval;
   727 } // make_D3D_destarg_string
   729 } // make_D3D_destarg_string