summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--compile.bat2
-rw-r--r--src/fixes.c27
2 files changed, 28 insertions, 1 deletions
diff --git a/compile.bat b/compile.bat
index 0f88cee..c8e2d40 100644
--- a/compile.bat
+++ b/compile.bat
@@ -68,7 +68,7 @@ if "%dbg%"=="1" (
set clibs=-lmsvcrt -lvcruntime -lucrt
)
%CC% -shared -flto %ldflags% -Wl,/IMPLIB:.build/sst.lib,/Brepro,/nodefaultlib:libcmt ^
--L.build %clibs% -luser32 -ladvapi32 -lshlwapi -ltier0 -lvstdlib -o sst.dll%objs% .build/dll.res || exit /b
+-L.build %clibs% -luser32 -ladvapi32 -lshlwapi -ld3d9 -ltier0 -lvstdlib -o sst.dll%objs% .build/dll.res || exit /b
:: get rid of another useless file (can we just not create this???)
del .build\sst.lib
diff --git a/src/fixes.c b/src/fixes.c
index eeac1c3..4f40183 100644
--- a/src/fixes.c
+++ b/src/fixes.c
@@ -18,7 +18,12 @@
#include <stdlib.h>
#include <string.h>
+#ifdef _WIN32
+#include <d3d9.h>
+#endif
+
#include "con_.h"
+#include "factory.h"
#include "gametype.h"
static void chflags(const char *name, int unset, int set) {
@@ -92,6 +97,28 @@ void fixes_apply(void) {
}
}
+#ifdef _WIN32
+ // L4D2 has broken (dark) rendering on Intel iGPUs unless
+ // mat_tonemapping_occlusion_use_stencil is enabled. Supposedly Valve used
+ // to detect device IDs to enable it on, but new devices are still broken,
+ // so just blanket enable it if the primary adapter is Intel, since it
+ // doesn't seem to break anything else anyway.
+ if (GAMETYPE_MATCHES(L4D2x)) {
+ struct con_var *v = con_findvar("mat_tonemapping_occlusion_use_stencil");
+ if (!v || con_getvari(v)) goto e;
+ // considered getting d3d9 object from actual game, but it's way easier
+ // to just create another one
+ IDirect3D9 *d3d9 = Direct3DCreate9(D3D_SDK_VERSION);
+ if (!d3d9) goto e;
+ D3DADAPTER_IDENTIFIER9 ident;
+ if (IDirect3D9_GetAdapterIdentifier(d3d9, 0, 0, &ident) == D3D_OK &&
+ ident.VendorId == 0x8086) { // neat vendor id, btw!
+ con_setvari(v, 1);
+ }
+ IDirect3D9_Release(d3d9);
+e:; }
+#endif
+
// For some reason, L4D1 hides mat_monitorgamma and doesn't archive it.
// This means on every startup it's necessary to manually set non-default
// values via the menu. This change here brings it in line with pretty much