elishacloud / dxwrapper

Fixes compatibility issues with older games running on Windows 10/11 by wrapping DirectX dlls. Also allows loading custom libraries with the file extension .asi into game processes.
zlib License
1.15k stars 82 forks source link

Cannot create textures with RTX Remix #187

Closed dkollmann closed 1 year ago

dkollmann commented 1 year ago

After the commit https://github.com/elishacloud/dxwrapper/commit/f3867edb5a3de6af36f1e374d7b14c88c5afe8e6, the game can no longer create some surfaces.

HRESULT m_IDirectDrawX::CreateSurface(LPDDSURFACEDESC lpDDSurfaceDesc, LPDIRECTDRAWSURFACE7 FAR * lplpDDSurface, IUnknown FAR * pUnkOuter, DWORD DirectXVersion)
{
...
        if (lpDDSurfaceDesc2->dwFlags & DDSD_PIXELFORMAT)
        {
        ....
            if (FAILED(d3d9Object->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D9DisplayFormat, Usage, Resource, Format)))
            {
                LOG_LIMIT(100, __FUNCTION__ << " Error: non-supported pixel format! " << Usage << " " << Resource << " " << Format << " " << lpDDSurfaceDesc2->ddpfPixelFormat);
                return DDERR_INVALIDPIXELFORMAT;
            }
        }
        ...
}
  Name Value Type
  D9DisplayFormat D3DFMT_X8R8G8B8 (22) _D3DFORMAT
  Usage 1024 unsigned long
  Resource D3DRTYPE_TEXTURE (3) _D3DRESOURCETYPE
  Format D3DFMT_A8R8G8B8 (21) _D3DFORMAT
dkollmann commented 1 year ago

The logic to determine DepthStencilSurface is correct and reaches the same result as before. So I am unsure how those two are connected.

elishacloud commented 1 year ago

Weird. Could it be the ddrawParent->ClearSencilSurface(); line when releasing the surface?

dkollmann commented 1 year ago

No I already checked that.

elishacloud commented 1 year ago

Are you sure it is not related to the Pool selected?

elishacloud commented 1 year ago

Do you have an Nvidia graphics card? There is a bug with Nvidia that happens on a handful of games when you recreate the the d3d9 device too many times.

dkollmann commented 1 year ago

The problem seems to be the call of CreateD3D9Device();

dkollmann commented 1 year ago

It works when I use my code as a fallback, which is fine as a solution for that game.

if(DepthStencilSurface == D3DFMT_UNKNOWN && Config.DdrawAutoStencilFormat > 0)
{
    DepthStencilSurface = (D3DFORMAT) Config.DdrawAutoStencilFormat;
}
elishacloud commented 1 year ago

Ok, I added an DdrawOverrideStencilFormat option for this case: c8c3c382336c20777ffb70ba11c3b1bc18d9aa97