mirror of
https://github.com/narzoul/DDrawCompat
synced 2024-12-30 08:55:36 +01:00
Use igd9trinity32.dll when ForceD3D9On12=off
This commit is contained in:
parent
837f7da035
commit
45d755cb41
@ -124,8 +124,8 @@ namespace D3dDdi
|
||||
auto& repo = getRepo();
|
||||
SurfaceRepository::Surface tex;
|
||||
SurfaceRepository::Surface rt;
|
||||
repo.getTempSurface(tex, 1, 1, D3DDDIFMT_X8R8G8B8, DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY);
|
||||
repo.getTempSurface(rt, 1, 1, D3DDDIFMT_X8R8G8B8, DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY);
|
||||
repo.getTempSurface(tex, 1, 1, D3DDDIFMT_R5G6B5, DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY);
|
||||
repo.getTempSurface(rt, 1, 1, D3DDDIFMT_R5G6B5, DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY);
|
||||
|
||||
if (tex.resource && rt.resource)
|
||||
{
|
||||
@ -134,7 +134,8 @@ namespace D3dDdi
|
||||
tex.surface->Lock(tex.surface, nullptr, &desc, DDLOCK_DISCARDCONTENTS | DDLOCK_WAIT, nullptr);
|
||||
if (desc.lpSurface)
|
||||
{
|
||||
static_cast<DWORD*>(desc.lpSurface)[0] = 0xFF;
|
||||
const WORD testColor = static_cast<WORD>(getFormatInfo(D3DDDIFMT_R5G6B5).pixelFormat.dwGBitMask);
|
||||
static_cast<WORD*>(desc.lpSurface)[0] = testColor;
|
||||
tex.surface->Unlock(tex.surface, nullptr);
|
||||
|
||||
m_shaderBlitter.colorKeyTestBlt(*rt.resource, *tex.resource);
|
||||
@ -144,7 +145,7 @@ namespace D3dDdi
|
||||
rt.surface->Lock(rt.surface, nullptr, &desc, DDLOCK_READONLY | DDLOCK_WAIT, nullptr);
|
||||
if (desc.lpSurface)
|
||||
{
|
||||
method = 0xFF == static_cast<DWORD*>(desc.lpSurface)[0]
|
||||
method = testColor == static_cast<WORD*>(desc.lpSurface)[0]
|
||||
? Config::Settings::ColorKeyMethod::ALPHATEST
|
||||
: Config::Settings::ColorKeyMethod::NATIVE;
|
||||
rt.surface->Unlock(rt.surface, nullptr);
|
||||
|
@ -100,10 +100,7 @@ namespace D3dDdi
|
||||
const UINT UNINITIALIZED_STATE = 0xBAADBAAD;
|
||||
|
||||
m_device.getOrigVtable().pfnSetDepthStencil(m_device, &m_current.depthStencil);
|
||||
m_device.getOrigVtable().pfnSetPixelShader(m_device, nullptr);
|
||||
m_device.getOrigVtable().pfnSetRenderTarget(m_device, &m_current.renderTarget);
|
||||
m_device.getOrigVtable().pfnSetVertexShaderDecl(m_device, nullptr);
|
||||
m_device.getOrigVtable().pfnSetVertexShaderFunc(m_device, nullptr);
|
||||
m_device.getOrigVtable().pfnSetViewport(m_device, &m_current.viewport);
|
||||
m_device.getOrigVtable().pfnUpdateWInfo(m_device, &m_current.wInfo);
|
||||
m_device.getOrigVtable().pfnSetZRange(m_device, &m_current.zRange);
|
||||
@ -836,7 +833,10 @@ namespace D3dDdi
|
||||
}
|
||||
|
||||
m_device.flushPrimitives();
|
||||
origSetShaderFunc(m_device, shader);
|
||||
if (shader)
|
||||
{
|
||||
origSetShaderFunc(m_device, shader);
|
||||
}
|
||||
currentShader = shader;
|
||||
return true;
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <atomic>
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
|
||||
#include <Windows.h>
|
||||
@ -234,6 +235,30 @@ namespace
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!Config::forceD3D9On12.get() &&
|
||||
KMTQAITYPE_UMDRIVERNAME == pData->Type &&
|
||||
KMTUMDVERSION_DX9 == static_cast<D3DKMT_UMDFILENAMEINFO*>(pData->pPrivateDriverData)->Version)
|
||||
{
|
||||
D3DKMT_UMDFILENAMEINFO fn = {};
|
||||
fn.Version = KMTUMDVERSION_DX12;
|
||||
D3DKMT_QUERYADAPTERINFO data = *pData;
|
||||
data.pPrivateDriverData = &fn;
|
||||
data.PrivateDriverDataSize = sizeof(fn);
|
||||
if (SUCCEEDED(D3DKMTQueryAdapterInfo(&data)))
|
||||
{
|
||||
std::filesystem::path path(fn.UmdFileName);
|
||||
path.replace_filename("igd9trinity32.dll");
|
||||
HMODULE mod = LoadLibraryExW(path.native().c_str(), nullptr, LOAD_LIBRARY_AS_DATAFILE);
|
||||
if (mod)
|
||||
{
|
||||
FreeLibrary(mod);
|
||||
memcpy(static_cast<D3DKMT_UMDFILENAMEINFO*>(pData->pPrivateDriverData)->UmdFileName,
|
||||
path.wstring().c_str(), (path.native().length() + 1) * 2);
|
||||
LOG_ONCE("Replacing D3D9On12 with igd9trinity32.dll");
|
||||
return LOG_RESULT(S_OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
return LOG_RESULT(result);
|
||||
}
|
||||
|
||||
|
@ -257,7 +257,8 @@ namespace D3dDdi
|
||||
LOWORD(filter) | (srgbRead ? D3DTEXF_SRGBREAD : 0));
|
||||
if (flags & BLT_COLORKEYTEST)
|
||||
{
|
||||
state.setTempTextureStageState({ 0, D3DDDITSS_TEXTURECOLORKEYVAL, 0xFF });
|
||||
const DWORD testColor = getFormatInfo(D3DDDIFMT_R5G6B5).pixelFormat.dwGBitMask;
|
||||
state.setTempTextureStageState({ 0, D3DDDITSS_TEXTURECOLORKEYVAL, testColor });
|
||||
}
|
||||
|
||||
state.setTempStreamSourceUm({ 0, sizeof(Vertex) }, m_vertices.data());
|
||||
|
@ -319,7 +319,7 @@ namespace
|
||||
g_frontBuffer->SetClipper(g_frontBuffer, g_clipper);
|
||||
g_surfaceDesc = desc;
|
||||
|
||||
if (0 != (desc.ddsCaps.dwCaps & DDSCAPS_FLIP))
|
||||
if (g_isExclusiveFullscreen && 0 != (desc.ddsCaps.dwCaps & DDSCAPS_FLIP))
|
||||
{
|
||||
g_frontBuffer->Flip(g_frontBuffer, getLastSurface(), DDFLIP_WAIT);
|
||||
D3dDdi::KernelModeThunks::waitForVsyncCounter(D3dDdi::KernelModeThunks::getVsyncCounter() + 1);
|
||||
@ -408,7 +408,7 @@ namespace
|
||||
{
|
||||
updatePresentationWindow();
|
||||
*g_deviceWindowPtr = g_presentationWindow;
|
||||
g_frontBuffer->Flip(g_frontBuffer, getBackBuffer(), DDFLIP_WAIT);
|
||||
g_frontBuffer->Flip(g_frontBuffer, g_isExclusiveFullscreen ? getBackBuffer() : nullptr, DDFLIP_WAIT);
|
||||
*g_deviceWindowPtr = g_deviceWindow;
|
||||
}
|
||||
g_presentEndVsyncCount = D3dDdi::KernelModeThunks::getVsyncCounter() + 1;
|
||||
@ -522,7 +522,7 @@ namespace DDraw
|
||||
desc.dwSize = sizeof(desc);
|
||||
desc.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
|
||||
desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
|
||||
desc.dwBackBufferCount = 2;
|
||||
desc.dwBackBufferCount = g_isExclusiveFullscreen ? 2 : 1;
|
||||
|
||||
auto prevIsFullscreen = g_isFullscreen;
|
||||
g_isFullscreen = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user