protonscr

[d3d9] NFS3 crashes

dxvkopen d3d9
doitsujin/dxvk#1695 · opened 2020-07-18 by K0bin · updated 2023-06-01 · 2 comments · github
KK0bin 2020-07-18 github

Need for Speed 3 crashes when starting a race.

It looks to me like the WindowProc Handler does infinite recursion.
I added some logging:

LRESULT CALLBACK D3D9WindowProc(HWND window, UINT message, WPARAM wparam, LPARAM lparam) {
    if (message == WM_NCCALCSIZE && wparam == TRUE)
      return 0;

    D3D9WindowData windowData = {};

    {
      std::lock_guard lock(g_windowProcMapMutex);

      auto it = g_windowProcMap.find(window);
      if (it != g_windowProcMap.end())
        windowData = it->second;
    }

    bool unicode = windowData.proc
      ? windowData.unicode
      : IsWindowUnicode(window);

    if (window == nullptr) {
        Logger::err("null window");
    }
    if (windowData.proc == nullptr) {
        Logger::err("null windowproc");
    }
    Logger::err(unicode ? "unicode" : "ascii");
    if (wparam == 0) {
        Logger::err("null wparam");
    }
    if (lparam == 0) {
        Logger::err("null lparam");
    }

    if (!windowData.proc || windowData.filter) {
        Logger::err("DefWindowProc");
        LRESULT res = CallCharsetFunction(
            DefWindowProcW, DefWindowProcA, unicode,
            window, message, wparam, lparam);
        Logger::err("DefWindowProc done");
        return res;
    }

    if (message == WM_DESTROY) {
        Logger::err("ResetWindowProc");
        ResetWindowProc(window);
        Logger::err("ResetWindowProc done");
    }

    Logger::err("CallWindowProc");
    LRESULT res = CallCharsetFunction(
      CallWindowProcW, CallWindowProcA, unicode,
        windowData.proc, window, message, wparam, lparam);
    Logger::err("CallWindowProc done");
    return res;
  }

Check the logs, it seems to call CallWindowProc over and over again.

Apparently the game also only displays a black screen one Wine. This may or may not be related.

Commenting out all calls to HookWindowProc and D3D9WindowMessageFilter filter(m_window); in d3d9_swapchain.cpp makes it work.

Software information

Need for Speed 3

System information

  • GPU: GTX 1070
  • Driver: 451.74.0
  • Wine version: Windows
  • DXVK version: PR 1686 + some logging (doesn't matter, it doesnt touch the crashing code)

Apitrace file(s)

Log files

BBlisto91 2022-07-26 github

Just noting here so it doesn't get lost. I wasn't able to reproduce a crash on windows with the modern patch + dxvk.
This is tested with a Nvidia 960. Both dxvk 1.7 and 1.10.2

Edit: Note to selfs. Need to figure if original issue was with modern patch or something else

WWinterSnowfall 2023-06-01 github

@K0bin I guess this is a windows specific issue, since it's fine in Wine? At least if you're referring to the latest modern patch which uses nGlide to end up in d3d9 land. It needs the dialogueMode workaround otherwise it will only render a black screen for some reason, but @Blisto91 already took care of that bit.

Nothing extracted yet.