From d02570aaf035e206affc1bcea39d54018d552735 Mon Sep 17 00:00:00 2001
From: cosmonaut <[EMAIL REDACTED]>
Date: Sun, 27 Oct 2024 21:34:19 -0700
Subject: [PATCH] Fix entrypoint encoding
---
src/SDL_gpu_shadercross.c | 7 ++++++-
src/cli.c | 4 ++++
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/SDL_gpu_shadercross.c b/src/SDL_gpu_shadercross.c
index b0dad80..86c3112 100644
--- a/src/SDL_gpu_shadercross.c
+++ b/src/SDL_gpu_shadercross.c
@@ -292,12 +292,17 @@ static void *SDL_ShaderCross_INTERNAL_CompileUsingDXC(
bool spirv,
size_t *size) // filled in with number of bytes of returned buffer
{
+ if (SDL_strstr(shaderProfile, "5_0")) {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s", "Cannot use Shader Model 5 with DXC!");
+ return NULL;
+ }
+
DxcBuffer source;
IDxcResult *dxcResult;
IDxcBlob *blob;
IDxcBlobUtf8 *errors;
size_t entryPointLength = SDL_utf8strlen(entrypoint) + 1;
- const char *entryPointUtf16 = SDL_iconv_string("UTF-16", "UTF-8", entrypoint, entryPointLength);
+ wchar_t *entryPointUtf16 = (wchar_t *)SDL_iconv_string("WCHAR_T", "UTF-8", entrypoint, entryPointLength);
LPCWSTR args[] = {
(LPCWSTR)L"-E",
(LPCWSTR)entryPointUtf16,
diff --git a/src/cli.c b/src/cli.c
index 51210f2..33a4dd2 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -391,6 +391,10 @@ int main(int argc, char *argv[])
entrypointName,
profileName,
&bytecodeSize);
+ if (spirv == NULL) {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s", "Failed to compile SPIR-V!");
+ return 1;
+ }
char *buffer = SDL_ShaderCross_TranspileMSLFromSPIRV(
spirv,
bytecodeSize,