Jump to content

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
  • Nitro Booster
4 hours ago, Luigina said:

It fixes application freeze / crash when creating a thread on application create.

 

19 minutes ago, HFWhite said:

will this really improve performance?

 

  • Nitro Booster
35 minutes ago, HFWhite said:

I mean yeah, I saw that but.. will it really?

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

  • Active Member

Is a good post, aswell did months ago that too cause on the 3rd app created is lagging and is not getting max fps and is going kinda 20-25 fps feels crazy.

  • Metin2 Dev 1
  • Honorable Member
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

992404397646696589.png
Former C++ Developer at Gameloft on DML
Join my Discord: Distraught Labs

  • Nitro Booster
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

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • 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.