mojoshader.c
changeset 1225 50b8dd7e0b1a
parent 1224 21cd84f1aa0a
child 1254 422f68756c9f
equal deleted inserted replaced
1224:21cd84f1aa0a 1225:50b8dd7e0b1a
   317 #undef DEFINE_PROFILE
   317 #undef DEFINE_PROFILE
   318 
   318 
   319 // This is for profiles that extend other profiles...
   319 // This is for profiles that extend other profiles...
   320 static const struct { const char *from; const char *to; } profileMap[] =
   320 static const struct { const char *from; const char *to; } profileMap[] =
   321 {
   321 {
       
   322     { MOJOSHADER_PROFILE_GLSPIRV, MOJOSHADER_PROFILE_SPIRV },
   322     { MOJOSHADER_PROFILE_GLSLES, MOJOSHADER_PROFILE_GLSL },
   323     { MOJOSHADER_PROFILE_GLSLES, MOJOSHADER_PROFILE_GLSL },
   323     { MOJOSHADER_PROFILE_GLSL120, MOJOSHADER_PROFILE_GLSL },
   324     { MOJOSHADER_PROFILE_GLSL120, MOJOSHADER_PROFILE_GLSL },
   324     { MOJOSHADER_PROFILE_NV2, MOJOSHADER_PROFILE_ARB1 },
   325     { MOJOSHADER_PROFILE_NV2, MOJOSHADER_PROFILE_ARB1 },
   325     { MOJOSHADER_PROFILE_NV3, MOJOSHADER_PROFILE_ARB1 },
   326     { MOJOSHADER_PROFILE_NV3, MOJOSHADER_PROFILE_ARB1 },
   326     { MOJOSHADER_PROFILE_NV4, MOJOSHADER_PROFILE_ARB1 },
   327     { MOJOSHADER_PROFILE_NV4, MOJOSHADER_PROFILE_ARB1 },
  3457         retval->symbols = ctx->ctab.symbols;
  3458         retval->symbols = ctx->ctab.symbols;
  3458         retval->preshader = ctx->preshader;
  3459         retval->preshader = ctx->preshader;
  3459         retval->mainfn = ctx->mainfn;
  3460         retval->mainfn = ctx->mainfn;
  3460 
  3461 
  3461 #if SUPPORT_PROFILE_SPIRV
  3462 #if SUPPORT_PROFILE_SPIRV
  3462         if (strcmp(retval->profile, "spirv") == 0)
  3463         if (strcmp(retval->profile, MOJOSHADER_PROFILE_SPIRV) == 0
       
  3464          || strcmp(retval->profile, MOJOSHADER_PROFILE_GLSPIRV) == 0)
  3463         {
  3465         {
  3464             size_t i, max;
  3466             size_t i, max;
  3465             int binary_size = retval->output_len - sizeof(SpirvPatchTable);
  3467             int binary_size = retval->output_len - sizeof(SpirvPatchTable);
  3466             uint32 *binary = (uint32 *) retval->output;
  3468             uint32 *binary = (uint32 *) retval->output;
  3467             SpirvPatchTable *table = (SpirvPatchTable *) &retval->output[binary_size];
  3469             SpirvPatchTable *table = (SpirvPatchTable *) &retval->output[binary_size];
  3476                 SpirvPatchEntry entry = table->samplers[i];
  3478                 SpirvPatchEntry entry = table->samplers[i];
  3477                 if (entry.offset)
  3479                 if (entry.offset)
  3478                     binary[entry.offset] = entry.location;
  3480                     binary[entry.offset] = entry.location;
  3479             } // for
  3481             } // for
  3480         } // if
  3482         } // if
  3481 #endif
  3483 #endif // SUPPORT_PROFILE_SPIRV
  3482 
  3484 
  3483         // we don't own these now, retval does.
  3485         // we don't own these now, retval does.
  3484         ctx->ctab.symbols = NULL;
  3486         ctx->ctab.symbols = NULL;
  3485         ctx->preshader = NULL;
  3487         ctx->preshader = NULL;
  3486         ctx->ctab.symbol_count = 0;
  3488         ctx->ctab.symbol_count = 0;
  3862     PROFILE_SHADER_MODEL(MOJOSHADER_PROFILE_NV2, 2);
  3864     PROFILE_SHADER_MODEL(MOJOSHADER_PROFILE_NV2, 2);
  3863     PROFILE_SHADER_MODEL(MOJOSHADER_PROFILE_NV3, 2);
  3865     PROFILE_SHADER_MODEL(MOJOSHADER_PROFILE_NV3, 2);
  3864     PROFILE_SHADER_MODEL(MOJOSHADER_PROFILE_NV4, 3);
  3866     PROFILE_SHADER_MODEL(MOJOSHADER_PROFILE_NV4, 3);
  3865     PROFILE_SHADER_MODEL(MOJOSHADER_PROFILE_METAL, 3);
  3867     PROFILE_SHADER_MODEL(MOJOSHADER_PROFILE_METAL, 3);
  3866     PROFILE_SHADER_MODEL(MOJOSHADER_PROFILE_SPIRV, 3);
  3868     PROFILE_SHADER_MODEL(MOJOSHADER_PROFILE_SPIRV, 3);
       
  3869     PROFILE_SHADER_MODEL(MOJOSHADER_PROFILE_GLSPIRV, 3);
  3867     #undef PROFILE_SHADER_MODEL
  3870     #undef PROFILE_SHADER_MODEL
  3868     return -1;  // unknown profile?
  3871     return -1;  // unknown profile?
  3869 } // MOJOSHADER_maxShaderModel
  3872 } // MOJOSHADER_maxShaderModel
  3870 
  3873 
  3871 
  3874