Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on systems older than Windows 10 Build 20348 #33

Closed
shaggie76 opened this issue Feb 23, 2022 · 3 comments
Closed

Crash on systems older than Windows 10 Build 20348 #33

shaggie76 opened this issue Feb 23, 2022 · 3 comments
Assignees
Labels
bug Something isn't working compatibility Compatibility with some platforms next release To be done as soon as possible

Comments

@shaggie76
Copy link

We upgraded D3D12MA and immediately started seeing an uptick in a crash in the wild. From what we can tell MemoryBlock::Init is blindly using GetDevice4() which may not be available in earlier versions of Windows 10 and code like this will GPF:

#ifdef __ID3D12Device4_INTERFACE_DEFINED__
    HRESULT hr = m_Allocator->GetDevice4()->CreateHeap1(&heapDesc, pProtectedSession, D3D12MA_IID_PPV_ARGS(&m_Heap));
#else
    D3D12MA_ASSERT(pProtectedSession == NULL);
    HRESULT hr = m_Allocator->GetDevice()->CreateHeap(&heapDesc, D3D12MA_IID_PPV_ARGS(&m_Heap));
#endif
@shaggie76
Copy link
Author

I made several changes to work around this

MemoryBlock::Init

#ifdef __ID3D12Device4_INTERFACE_DEFINED__
    D3D12MA_ASSERT(pProtectedSession == NULL || m_Allocator->GetDevice4());
    HRESULT hr = m_Allocator->GetDevice4() ? 
        m_Allocator->GetDevice4()->CreateHeap1(&heapDesc, pProtectedSession, D3D12MA_IID_PPV_ARGS(&m_Heap)) :
        m_Allocator->GetDevice()->CreateHeap(&heapDesc, D3D12MA_IID_PPV_ARGS(&m_Heap));
#else

AllocatorPimpl::AllocateCommittedResource

#ifdef __ID3D12Device4_INTERFACE_DEFINED__
    D3D12MA_ASSERT(committedAllocParams.m_ProtectedSession == NULL || m_Device4);

    HRESULT hr = m_Device4 ? 
    m_Device4->CreateCommittedResource1(
        &committedAllocParams.m_HeapProperties,
        committedAllocParams.m_HeapFlags & ~RESOURCE_CLASS_HEAP_FLAGS,
        pResourceDesc, InitialResourceState,
        pOptimizedClearValue, committedAllocParams.m_ProtectedSession, D3D12MA_IID_PPV_ARGS(&res)) :
    m_Device->CreateCommittedResource(
        &committedAllocParams.m_HeapProperties,
        committedAllocParams.m_HeapFlags & ~RESOURCE_CLASS_HEAP_FLAGS, 
        pResourceDesc, InitialResourceState,
        pOptimizedClearValue, D3D12MA_IID_PPV_ARGS(&res));
#else

AllocatorPimpl::AllocateHeap

#ifdef __ID3D12Device4_INTERFACE_DEFINED__
    D3D12MA_ASSERT(committedAllocParams.m_ProtectedSession == NULL || m_Device4);
    HRESULT hr = m_Device4 ? 
        m_Device4->CreateHeap1(&heapDesc, committedAllocParams.m_ProtectedSession, D3D12MA_IID_PPV_ARGS(&heap)) :
        m_Device->CreateHeap(&heapDesc, D3D12MA_IID_PPV_ARGS(&heap));
#else

I don't have a system impacted but I faked it by commenting out m_Device->QueryInterface(D3D12MA_IID_PPV_ARGS(&m_Device4));

@shaggie76
Copy link
Author

Best I can tell these are all Windows 10 version 1607 systems

@adam-sawicki-a adam-sawicki-a self-assigned this Feb 24, 2022
@adam-sawicki-a adam-sawicki-a added bug Something isn't working compatibility Compatibility with some platforms next release To be done as soon as possible labels Feb 24, 2022
@adam-sawicki-a
Copy link
Collaborator

Thank you for reporting this bug. I confirm that this situation was not handled properly. I made some fixes in hope they will work in your case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compatibility Compatibility with some platforms next release To be done as soon as possible
Projects
None yet
Development

No branches or pull requests

2 participants