How To Directx9 Device Creation with Multiple Thread Support

  • Konuyu açan Konuyu açan luigina
  • Açılış Tarihi Açılış Tarihi
  • Yanıt Yanıt 0
  • Gösterim Gösterim 283

luigina

Üye
Üye
Mesaj
22
Beğeni
47
Puan
660
Ticaret Puanı
0
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.


C++:
Genişlet Daralt Kopyala
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;
}
 
Geri
Üst