Closed TheSpydog closed 4 years ago
Quick fix for MinGW:
diff --git a/profiles/mojoshader_profile_hlsl.c b/profiles/mojoshader_profile_hlsl.c
index da8f84a..856b366 100644
--- a/profiles/mojoshader_profile_hlsl.c
+++ b/profiles/mojoshader_profile_hlsl.c
@@ -779,6 +779,7 @@ void emit_HLSL_attribute(Context *ctx, RegisterType regtype, int regnum,
const char *usage_str = NULL;
char index_str[16] = { '\0' };
char var[64];
+ char a[256];
get_HLSL_varname_in_buf(ctx, regtype, regnum, var, sizeof (var));
@@ -922,7 +923,6 @@ void emit_HLSL_attribute(Context *ctx, RegisterType regtype, int regnum,
output_line(ctx, "float4 m_%s : TEXCOORD%d;", var, index);
break;
default:
- char a[256];
snprintf(a, sizeof(a), "Invalid vertex output semantic %d", usage);
fail(ctx, a);
break;
One more quick fix for non-HLSL build configurations:
SNIP
VS2010 really doesn't like that patch. Putting mojoshader_internal.h
first seems to conflict with the windows string headers somehow.
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\string.h(105): error C2061: syntax error : identifier 'SDL_strlen'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\string.h(105): error C2059: syntax error : ')'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\string.h(105): error C2143: syntax error : missing ')' before ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\string.h(105): error C2733: second C linkage of overloaded function 'SDL_strlcpy' not allowed
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\string.h(105) : see declaration of 'SDL_strlcpy'
...etc...
Oh, must be the SDL_stblib macros... blech. This will need some kind of adjustment somewhere, since currently all non-Windows builds are broken as of the latest revision.
Figured out how to make it cooperate with VS2010!
diff --git a/mojoshader_d3d11.c b/mojoshader_d3d11.c
index b078cb3..ae3e5f7 100644
--- a/mojoshader_d3d11.c
+++ b/mojoshader_d3d11.c
@@ -7,14 +7,21 @@
* This file written by Ryan C. Gordon.
*/
+#ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN 1
+#include <windows.h> // Include this early to avoid SDL conflicts
+#endif
+
+#define __MOJOSHADER_INTERNAL__ 1
+#include "mojoshader_internal.h"
+
+#if SUPPORT_PROFILE_HLSL
+
#define D3D11_NO_HELPERS
#define CINTERFACE
#define COBJMACROS
#include <d3d11.h>
-#define __MOJOSHADER_INTERNAL__ 1
-#include "mojoshader_internal.h"
-
#ifndef WINAPI_FAMILY_WINRT
#define WINAPI_FAMILY_WINRT 0
#endif
@@ -69,7 +76,6 @@ static inline void out_of_memory(void)
// profile-specific implementations...
-#if SUPPORT_PROFILE_HLSL
#ifdef MOJOSHADER_EFFECT_SUPPORT
typedef HRESULT(WINAPI *PFN_D3DCOMPILE)(
Excellent! It just occurred to me, I wonder if we even need the #ifdef MOJOSHADER_EFFECT_SUPPORT
check since nothing in the file directly uses the effects system.
Probably not, now that I think about it - the same could be said for Metal too, aside from the MTLLibrary part.
Only two things I found in this last review:
Other than that I didn’t see anything that wasn’t already FIXME’d.
Cleaned up and pushed to upstream: https://hg.icculus.org/icculus/mojoshader/rev/0135d797e287
This emits FXC-compilable SM4 code. Not yet tested at runtime. Also included is
mojoshader_d3d11.c
which houses the D3D11 Effect API.Confirmed to compile without issue: