summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMichael Smith <mikesmiffy128@gmail.com>2022-04-25 00:19:26 +0100
committerMichael Smith <mikesmiffy128@gmail.com>2022-04-25 02:05:41 +0100
commit384f441ad171ed9878a1aec8d44e3857edcb0d6f (patch)
tree6112e4abf244b2a5e68886537e0ccd111c3ecabc
parent0a4b1acc10f0e5b9ff62f34d1261909189486cbb (diff)
Fix dark L4D2 rendering on Intel integrated GPUs
Thanks Aciidz for helping test this.
-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