SDL_gpu_shadercross: Fix warnings

From 5ed76b73612b970baa39c262c8bdb97e8c83ca9a Mon Sep 17 00:00:00 2001
From: cosmonaut <[EMAIL REDACTED]>
Date: Fri, 25 Oct 2024 10:05:03 -0700
Subject: [PATCH] Fix warnings

---
 include/SDL_gpu_shadercross.h | 12 ++++++------
 src/SDL_gpu_shadercross.c     |  9 +++++----
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/include/SDL_gpu_shadercross.h b/include/SDL_gpu_shadercross.h
index e34d2ba..a0eb9b6 100644
--- a/include/SDL_gpu_shadercross.h
+++ b/include/SDL_gpu_shadercross.h
@@ -74,7 +74,7 @@ extern SDL_DECLSPEC SDL_GPUShaderFormat SDLCALL SDL_ShaderCross_GetSPIRVShaderFo
  *
  * \param bytecode the SPIRV bytecode.
  * \param bytecodeSize the length of the SPIRV bytecode.
- * \param entrypoint the entry point function name for the shader.
+ * \param entrypoint the entry point function name for the shader in UTF-8.
  * \param shaderStage the shader stage to transpile the shader with.
  */
 extern SDL_DECLSPEC void * SDLCALL SDL_ShaderCross_TranspileMSLFromSPIRV(
@@ -90,7 +90,7 @@ extern SDL_DECLSPEC void * SDLCALL SDL_ShaderCross_TranspileMSLFromSPIRV(
  *
  * \param bytecode the SPIRV bytecode.
  * \param bytecodeSize the length of the SPIRV bytecode.
- * \param entrypoint the entry point function name for the shader.
+ * \param entrypoint the entry point function name for the shader in UTF-8.
  * \param shaderStage the shader stage to transpile the shader with.
  * \param size filled in with the bytecode buffer size.
  */
@@ -108,7 +108,7 @@ extern SDL_DECLSPEC void * SDLCALL SDL_ShaderCross_CompileDXBCFromSPIRV(
  *
  * \param bytecode the SPIRV bytecode.
  * \param bytecodeSize the length of the SPIRV bytecode.
- * \param entrypoint the entry point function name for the shader.
+ * \param entrypoint the entry point function name for the shader in UTF-8.
  * \param shaderStage the shader stage to transpile the shader with.
  * \param size filled in with the bytecode buffer size.
  */
@@ -160,7 +160,7 @@ extern SDL_DECLSPEC SDL_GPUShaderFormat SDLCALL SDL_ShaderCross_GetHLSLShaderFor
  * You must SDL_free the returned buffer once you are done with it.
  *
  * \param hlslSource the HLSL source code for the shader.
- * \param entrypoint the entry point function name for the shader.
+ * \param entrypoint the entry point function name for the shader in UTF-8.
  * \param shaderProfile the shader profile to compile the shader with.
  * \param size filled in with the bytecode buffer size.
  * \returns an SDL_malloc'd buffer containing DXBC bytecode.
@@ -179,7 +179,7 @@ extern SDL_DECLSPEC void * SDLCALL SDL_ShaderCross_CompileDXBCFromHLSL(
  * You must SDL_free the returned buffer once you are done with it.
  *
  * \param hlslSource the HLSL source code for the shader.
- * \param entrypoint the entry point function name for the shader.
+ * \param entrypoint the entry point function name for the shader in UTF-8.
  * \param shaderProfile the shader profile to compile the shader with.
  * \param size filled in with the bytecode buffer size.
  * \returns an SDL_malloc'd buffer containing DXIL bytecode.
@@ -198,7 +198,7 @@ extern SDL_DECLSPEC void * SDLCALL SDL_ShaderCross_CompileDXILFromHLSL(
  * You must SDL_free the returned buffer once you are done with it.
  *
  * \param hlslSource the HLSL source code for the shader.
- * \param entrypoint the entry point function name for the shader.
+ * \param entrypoint the entry point function name for the shader in UTF-8.
  * \param shaderProfile the shader profile to compile the shader with.
  * \param size filled in with the bytecode buffer size.
  * \returns an SDL_malloc'd buffer containing SPIRV bytecode.
diff --git a/src/SDL_gpu_shadercross.c b/src/SDL_gpu_shadercross.c
index e454c85..c93672e 100644
--- a/src/SDL_gpu_shadercross.c
+++ b/src/SDL_gpu_shadercross.c
@@ -99,7 +99,7 @@ typedef enum DXC_OUT_KIND
     DXC_OUT_TIME_TRACE = 13,
     DXC_OUT_LAST = DXC_OUT_TIME_TRACE,
     DXC_OUT_NUM_ENUMS,
-    DXC_OUT_FORCE_DWORD = 0xFFFFFFFF
+    // DXC_OUT_FORCE_DWORD = 0xFFFFFFFF
 } DXC_OUT_KIND;
 
 #define DXC_CP_UTF8  65001
@@ -296,9 +296,11 @@ static void *SDL_ShaderCross_INTERNAL_CompileUsingDXC(
     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);
     LPCWSTR args[] = {
         (LPCWSTR)L"-E",
-        (LPCWSTR)L"main", /* FIXME: convert entry point to UTF-16 */
+        (LPCWSTR)entryPointUtf16,
         NULL,
         NULL,
         NULL,
@@ -1016,7 +1018,6 @@ static void *SDL_ShaderCross_INTERNAL_CreateShaderFromSPIRV(
     const void *originalCreateInfo,
     bool isCompute)
 {
-    const SDL_GPUShaderCreateInfo *createInfo;
     SDL_GPUShaderFormat format;
     void *compiledResult;
 
@@ -1041,7 +1042,7 @@ static void *SDL_ShaderCross_INTERNAL_CreateShaderFromSPIRV(
 
     void *translatedCreateInfo = SDL_ShaderCross_INTERNAL_TranslateFromSPIRV(
         format,
-        createInfo,
+        originalCreateInfo,
         isCompute);
 
     if (isCompute) {