Jump to content

How To Directx9 Device Creation with Multiple Thread Support


Recommended Posts

  • Nitro Booster

Hi everyone,

With this change you can handle multiple threads on device creating on Directx9 update. It fixes application freeze / crash when creating a thread on application create.

 

GrpDetector.cpp

// Before

if (m_kD3DCaps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT)
{
    if (m_kD3DCaps.DevCaps & D3DDEVCAPS_PUREDEVICE)
    {
        dwD3DBehavior = D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_PUREDEVICE;

        if (pfnConfirmDevice(m_kD3DCaps, dwD3DBehavior, eD3DFmtPixel))
            isFormatConfirmed = TRUE;
    }

    if (FALSE == isFormatConfirmed)
    {
        dwD3DBehavior = D3DCREATE_HARDWARE_VERTEXPROCESSING;

        if (pfnConfirmDevice(m_kD3DCaps, dwD3DBehavior, eD3DFmtPixel))
            isFormatConfirmed = TRUE;
    }

    if (FALSE == isFormatConfirmed)
    {
        dwD3DBehavior = D3DCREATE_MIXED_VERTEXPROCESSING;

        if (pfnConfirmDevice(m_kD3DCaps, dwD3DBehavior, eD3DFmtPixel))
            isFormatConfirmed = TRUE;
    }
}

// Confirm the device/format for SW vertex processing
if (FALSE == isFormatConfirmed)
{
    dwD3DBehavior = D3DCREATE_SOFTWARE_VERTEXPROCESSING;

    if (pfnConfirmDevice(m_kD3DCaps, dwD3DBehavior, eD3DFmtPixel))
        isFormatConfirmed = TRUE;
}

// After

if (m_kD3DCaps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT)
{
    if (m_kD3DCaps.DevCaps & D3DDEVCAPS_PUREDEVICE)
    {
        dwD3DBehavior = D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_PUREDEVICE | D3DCREATE_MULTITHREADED;

        if (pfnConfirmDevice(m_kD3DCaps, dwD3DBehavior, eD3DFmtPixel))
            isFormatConfirmed = TRUE;
    }

    if (FALSE == isFormatConfirmed)
    {
        dwD3DBehavior = D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED;

        if (pfnConfirmDevice(m_kD3DCaps, dwD3DBehavior, eD3DFmtPixel))
            isFormatConfirmed = TRUE;
    }

    if (FALSE == isFormatConfirmed)
    {
        dwD3DBehavior = D3DCREATE_MIXED_VERTEXPROCESSING | D3DCREATE_MULTITHREADED;

        if (pfnConfirmDevice(m_kD3DCaps, dwD3DBehavior, eD3DFmtPixel))
            isFormatConfirmed = TRUE;
    }
}

// Confirm the device/format for SW vertex processing
if (FALSE == isFormatConfirmed)
{
    dwD3DBehavior = D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED;

    if (pfnConfirmDevice(m_kD3DCaps, dwD3DBehavior, eD3DFmtPixel))
        isFormatConfirmed = TRUE;
}

 

  • Think 1
  • muscle 1
  • Love 1
Link to comment
Share on other sites

  • Honorable Member
Posted (edited)
On 5/15/2024 at 9:43 PM, HFWhite said:

will this really improve performance?

No, it just adds a global mutex, so may decreases it.

On 5/15/2024 at 10:50 PM, Luigina said:

You can try, create a thread on app create with dx9. App will crash or freeze sometimes when opening the client.

You did something really wrong if it fixes your crashes.

Edited by Distraught
  • Good 3
Link to comment
Share on other sites

  • Nitro Booster
Posted (edited)
6 hours ago, Distraught said:

You did something really wrong if it fixes your crashes.


I didn't wrong thing, i was creating load thread for some cheat algorithm & load some resources when app creating. After dx9 update this problem occured, i changed thread to async to fix it. It was ok but after some research on microsoft website i did it and revert to thread, issue solved. So it worked on me. To make sure of this, I did the same on the mainline, the same problem was occurring, with this flag I made sure that it was solved there as well.

There is a other ways too ofc. Like create thread after all create processes done

Edited by Luigina
Link to comment
Share on other sites

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.