diff --git a/impl11/ddraw/DeviceResources.cpp b/impl11/ddraw/DeviceResources.cpp index b611005c..14519503 100644 --- a/impl11/ddraw/DeviceResources.cpp +++ b/impl11/ddraw/DeviceResources.cpp @@ -17,6 +17,7 @@ #include "../Debug/MainPixelShaderBpp4ColorKey20.h" #include "../Debug/VertexShader.h" #include "../Debug/PixelShaderAtest565.h" +#include "../Debug/PixelShaderAtestDiscardBlack.h" #include "../Debug/PixelShaderAtestTexture.h" #include "../Debug/PixelShaderAtestTextureNoAlpha.h" #include "../Debug/PixelShaderTexture.h" @@ -31,6 +32,7 @@ #include "../Release/MainPixelShaderBpp4ColorKey20.h" #include "../Release/VertexShader.h" #include "../Release/PixelShaderAtest565.h" +#include "../Release/PixelShaderAtestDiscardBlack.h" #include "../Release/PixelShaderAtestTexture.h" #include "../Release/PixelShaderAtestTextureNoAlpha.h" #include "../Release/PixelShaderTexture.h" @@ -618,6 +620,9 @@ HRESULT DeviceResources::LoadResources() if (FAILED(hr = this->_d3dDevice->CreatePixelShader(g_PixelShaderAtest565, sizeof(g_PixelShaderAtest565), nullptr, &_pixelShaderAtest565))) return hr; + if (FAILED(hr = this->_d3dDevice->CreatePixelShader(g_PixelShaderAtestDiscardBlack, sizeof(g_PixelShaderAtestDiscardBlack), nullptr, &_pixelShaderAtestDiscardBlack))) + return hr; + if (FAILED(hr = this->_d3dDevice->CreatePixelShader(g_PixelShaderAtestTexture, sizeof(g_PixelShaderAtestTexture), nullptr, &_pixelShaderAtestTexture))) return hr; diff --git a/impl11/ddraw/DeviceResources.h b/impl11/ddraw/DeviceResources.h index e2528791..bba03ccd 100644 --- a/impl11/ddraw/DeviceResources.h +++ b/impl11/ddraw/DeviceResources.h @@ -95,6 +95,7 @@ class DeviceResources ComPtr _inputLayout; ComPtr _pixelShaderTexture; ComPtr _pixelShaderAtest565; + ComPtr _pixelShaderAtestDiscardBlack; ComPtr _pixelShaderAtestTexture; ComPtr _pixelShaderAtestTextureNoAlpha; ComPtr _pixelShaderSolid; diff --git a/impl11/ddraw/Direct3DDevice.cpp b/impl11/ddraw/Direct3DDevice.cpp index aaca7c53..182693cc 100644 --- a/impl11/ddraw/Direct3DDevice.cpp +++ b/impl11/ddraw/Direct3DDevice.cpp @@ -507,6 +507,9 @@ void Direct3DDevice::UpdatePixelShader(ID3D11DeviceContext *context, Direct3DTex // HACK: This is a workaround because NVidia cards may return 0 alpha for 565 textures, // causing flicker and holes e.g. in the rear of the A-Wing in XWA (most visible from the side). if (texture->_surface->_pixelFormat.dwRGBAlphaBitMask == 0) pixelShader = this->_deviceResources->_pixelShaderAtest565; + // On the other hand, XvT relies on this behaviour for laser "explosions"... + // TODO: might this be a unsupported color key ssue?? + if (g_config.isXvT && texture->_surface->_pixelFormat.dwRGBAlphaBitMask == 0) pixelShader = this->_deviceResources->_pixelShaderAtestDiscardBlack; } this->_deviceResources->InitPixelShader(pixelShader); diff --git a/impl11/ddraw/config.cpp b/impl11/ddraw/config.cpp index 841ef246..f85271f4 100644 --- a/impl11/ddraw/config.cpp +++ b/impl11/ddraw/config.cpp @@ -196,7 +196,7 @@ Config::Config() bool isXWA = len >= 17 && _stricmp(name + len - 17, "xwingalliance.exe") == 0; isXWing = len >= 11 && _stricmp(name + len - 11, "xwing95.exe") == 0; isTIE = len >= 9 && _stricmp(name + len - 9, "tie95.exe") == 0; - bool isXvT = len >= 11 && _stricmp(name + len - 11, "z_xvt__.exe") == 0 && + isXvT = len >= 11 && _stricmp(name + len - 11, "z_xvt__.exe") == 0 && *(const unsigned long long *)0x523aec == 0x54534c2e31505352ull; bool isBoP = len >= 11 && _stricmp(name + len - 11, "z_xvt__.exe") == 0 && *(const unsigned long long *)0x5210bc == 0x54534c2e31505352ull; @@ -352,4 +352,4 @@ void Config::runAutopatch() VirtualProtect((void *)0x4f2a8c, 4, old, &dummy); } FlushInstructionCache(GetCurrentProcess(), NULL, 0); -} \ No newline at end of file +} diff --git a/impl11/ddraw/config.h b/impl11/ddraw/config.h index 30213fcc..dedc97aa 100644 --- a/impl11/ddraw/config.h +++ b/impl11/ddraw/config.h @@ -29,6 +29,7 @@ class Config bool XWAMode; bool isTIE; bool isXWing; + bool isXvT; float Concourse3DScale; diff --git a/impl11/ddraw/ddraw.rc b/impl11/ddraw/ddraw.rc index 06758c03..672e000f 100644 --- a/impl11/ddraw/ddraw.rc +++ b/impl11/ddraw/ddraw.rc @@ -48,8 +48,8 @@ END // 1 VERSIONINFO - FILEVERSION 1,5,8 - PRODUCTVERSION 1,5,8 + FILEVERSION 1,5,9 + PRODUCTVERSION 1,5,9 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -66,12 +66,12 @@ BEGIN BEGIN VALUE "CompanyName", "Jérémy Ansel" VALUE "FileDescription", "Direct3D 11 implementation for X-Wing series" - VALUE "FileVersion", "1.5.8" + VALUE "FileVersion", "1.5.9" VALUE "InternalName", "ddraw.dll" VALUE "LegalCopyright", "Copyright (C) Jérémy Ansel 2014, Reimar Döffinger 2015-2019" VALUE "OriginalFilename", "ddraw.dll" VALUE "ProductName", "xwa_ddraw_d3d11" - VALUE "ProductVersion", "1.5.8" + VALUE "ProductVersion", "1.5.9" END END BLOCK "VarFileInfo" diff --git a/impl11/ddraw/ddraw.vcxproj b/impl11/ddraw/ddraw.vcxproj index 518431e3..9487d855 100644 --- a/impl11/ddraw/ddraw.vcxproj +++ b/impl11/ddraw/ddraw.vcxproj @@ -14,19 +14,19 @@ {C03DE3A0-EF2A-4596-AFDE-66E4C4FD6E23} Win32Proj ddraw - 10.0.17763.0 + 10.0 DynamicLibrary true - v141 + v142 NotSet DynamicLibrary false - v141 + v142 true NotSet diff --git a/impl11/shaders/PixelShaderAtestDiscardBlack.hlsl b/impl11/shaders/PixelShaderAtestDiscardBlack.hlsl new file mode 100644 index 00000000..5acd2234 --- /dev/null +++ b/impl11/shaders/PixelShaderAtestDiscardBlack.hlsl @@ -0,0 +1,22 @@ +// Copyright (c) 2014 Jérémy Ansel +// Licensed under the MIT license. See LICENSE.txt + + +Texture2D texture0 : register(t0); +SamplerState sampler0 : register(s0); + +struct PixelShaderInput +{ + float4 pos : SV_POSITION; + float4 color : COLOR0; + float2 tex : TEXCOORD; +}; + +float4 main(PixelShaderInput input) : SV_TARGET +{ + float4 texelColor = texture0.Sample(sampler0, input.tex); + if (input.color.a == 0) discard; + if (texelColor.r == 0 && texelColor.g == 0 && texelColor.b == 0) discard; + texelColor *= input.color; + return float4(texelColor.rgb, input.color.a); +} diff --git a/impl11/shaders/shaders.vcxproj b/impl11/shaders/shaders.vcxproj index d7e56c06..6221a7fa 100644 --- a/impl11/shaders/shaders.vcxproj +++ b/impl11/shaders/shaders.vcxproj @@ -13,19 +13,19 @@ {EBD25ABF-9127-4887-9BF2-C7D3880BF68B} shaders - 10.0.17763.0 + 10.0 Application true - v141 + v142 MultiByte Application false - v141 + v142 true MultiByte @@ -113,6 +113,10 @@ Pixel Pixel + + Pixel + Pixel + Pixel Pixel diff --git a/impl11/shaders/shaders.vcxproj.filters b/impl11/shaders/shaders.vcxproj.filters index 36072e88..62bde5fc 100644 --- a/impl11/shaders/shaders.vcxproj.filters +++ b/impl11/shaders/shaders.vcxproj.filters @@ -28,5 +28,6 @@ + \ No newline at end of file diff --git a/impl11/tests/tests.vcxproj b/impl11/tests/tests.vcxproj index bf119b4d..3175a92b 100644 --- a/impl11/tests/tests.vcxproj +++ b/impl11/tests/tests.vcxproj @@ -14,19 +14,19 @@ {0F3CC45E-5B7D-49DF-88E2-044BDB7554A0} Win32Proj tests - 10.0.17763.0 + 10.0 Application true - v141 + v142 Unicode Application false - v141 + v142 true Unicode