Skip to content

Commit

Permalink
HLSL: Fix non-main entrypoints failing to compile
Browse files Browse the repository at this point in the history
  • Loading branch information
thatcosmonaut committed Nov 25, 2024
1 parent 373383c commit 836db4f
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/SDL_shadercross.c
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,7 @@ static SPIRVTranspileContext *SDL_ShaderCross_INTERNAL_TranspileFromSPIRV(
spvc_compiler_options_set_uint(options, SPVC_COMPILER_OPTION_HLSL_SHADER_MODEL, shadermodel);
spvc_compiler_options_set_uint(options, SPVC_COMPILER_OPTION_HLSL_NONWRITABLE_UAV_TEXTURE_AS_SRV, 1);
spvc_compiler_options_set_uint(options, SPVC_COMPILER_OPTION_HLSL_FLATTEN_MATRIX_VERTEX_INPUT_SEMANTICS, 1);
spvc_compiler_options_set_bool(options, SPVC_COMPILER_OPTION_HLSL_USE_ENTRY_POINT_NAME, true);
}

SpvExecutionModel executionModel;
Expand Down Expand Up @@ -1591,11 +1592,15 @@ static SPIRVTranspileContext *SDL_ShaderCross_INTERNAL_TranspileFromSPIRV(
return NULL;
}

/* Determine the "cleansed" entrypoint name (e.g. main -> main0 on MSL) */
cleansed_entrypoint = spvc_compiler_get_cleansed_entry_point_name(
compiler,
entrypoint,
spvc_compiler_get_execution_model(compiler));
if (backend == SPVC_BACKEND_MSL) {
// Metal doesn't allow a "main" entrypoint, so determine the "cleansed" entrypoint name (e.g. main -> main0 on MSL)
cleansed_entrypoint = spvc_compiler_get_cleansed_entry_point_name(
compiler,
entrypoint,
spvc_compiler_get_execution_model(compiler));
} else {
cleansed_entrypoint = entrypoint;
}

transpileContext = SDL_malloc(sizeof(SPIRVTranspileContext));
transpileContext->context = context;
Expand Down

0 comments on commit 836db4f

Please sign in to comment.