4

I am reaching an exception which I do not know how to resolve/understand. It comes from D3D12CreateDevice, which I do not have source and control.

Context

I have an application with WPF (.net7) and c code which creates a D3D12 asset (window) which is injected into a XAML object (eg., rectangle) and they interoperate. The code was working fine until I updated from .net48 to .net5+ (.net7 exactly).

I did not change the code but the projects files.

I reinstalled the GPU drivers (using RTX4090), which did not solve the problem.

The D3D12 code works well with other WPF contexts, and not with others, furthermore, the interop code does not seems to be involved in that case since we are far from it; so I am really confused.

My questions:

  1. how to solve this ?
  2. should I consider .net5+ not fit for such interoperability and consider revert to .net48 ?

More details:

Exception thrown at 0x00007FF8A6EECD29 in ShutterModeler.exe: Microsoft C++ exception: Poco::NotFoundException at memory location 0x0000006DE436E670.

// Helper function for acquiring the first available hardware adapter that supports Direct3D 12.
// If no such adapter can be found, *ppAdapter will be set to nullptr.
_Use_decl_annotations_
void DX12CudaSample::GetHardwareAdapter(IDXGIFactory2* pFactory, IDXGIAdapter1** ppAdapter)
{
    ComPtr<IDXGIAdapter1> adapter;
    *ppAdapter = nullptr;

    for (UINT adapterIndex = 0; DXGI_ERROR_NOT_FOUND != pFactory->EnumAdapters1(adapterIndex, &adapter); ++adapterIndex)
    {
        DXGI_ADAPTER_DESC1 desc;
        adapter->GetDesc1(&desc);
        bool isSoftwareGPU = desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE;
        if (isSoftwareGPU)
            continue;

        auto uuidDev = _uuidof(ID3D12Device);
        auto currentAdapter = adapter.Get();
        auto status = D3D12CreateDevice(currentAdapter, D3D_FEATURE_LEVEL_11_0, uuidDev, nullptr); //this line throws
        //if (SUCCEEDED(D3D12CreateDevice(adapter.Get(), D3D_FEATURE_LEVEL_11_0, _uuidof(ID3D12Device), nullptr)))
        if(SUCCEEDED(status))
            break;
    }

    *ppAdapter = adapter.Detach();
}

It seems that the correct adapted was found:

  desc    {Description=0x0000006de437c3b0 L"NVIDIA GeForce RTX 4090" VendorId=4318 DeviceId=9860 ...} DXGI_ADAPTER_DESC1

more details:

  Description 0x0000006de437c3b0 L"NVIDIA GeForce RTX 4090"   wchar_t[128]
  VendorId 4318   unsigned int
  DeviceId    9860    unsigned int        SubSysId    375066846   unsigned int
  Revision    161 unsigned int
  DedicatedVideoMemory    25329401856 unsigned __int64
  DedicatedSystemMemory   0   unsigned __int64
  SharedSystemMemory  68674734080 unsigned __int64
  AdapterLuid {LowPart=14177306 HighPart=0 }  _LUID       Flags   0   unsigned int

and:

currentAdapter = 0x000002a4dcfd3f50

Call stack from my code to the exception:

KernelBase.dll!RaiseException() Unknown
MessageBus.dll!00007fffa447cb4d()   Unknown
MessageBus.dll!00007fffa427af4e()   Unknown
MessageBus.dll!00007fffa41fe097()   Unknown
MessageBus.dll!00007fffa4210919()   Unknown
MessageBus.dll!00007fffa420ac95()   Unknown
MessageBus.dll!00007fffa42085d0()   Unknown
MessageBus.dll!00007fffa420fe91()   Unknown
nvwgf2umx.dll!00007fff876e8da7()    Unknown
nvwgf2umx.dll!00007fff876ea202()    Unknown
nvwgf2umx.dll!00007fff876d9e64()    Unknown
nvwgf2umx.dll!00007fff878dc16b()    Unknown
nvwgf2umx.dll!00007fff87bb8a70()    Unknown
nvwgf2umx.dll!00007fff88c9725b()    Unknown
D3D12Core.dll!NDXGI::CUMDAdapter::OpenAdapter<0>(void)  Unknown
D3D12Core.dll!NDXGI::CUMDAdapter::CUMDAdapter(struct IDXCoreAdapterFactory *,struct IDXCoreAdapter *,struct _LUID)  Unknown
D3D12Core.dll!CCreateDeviceCache::LoadUMD(void) Unknown
D3D12Core.dll!CCreateDeviceCache::ResolveUMDAndVersion(class std::vector<struct SupportedVersion,class std::allocator<struct SupportedVersion> > &,class std::shared_ptr<class NDXGI::CUMDAdapter> &,unsigned __int64 *)    Unknown
D3D12Core.dll!D3D12CoreCreateDevice()   Unknown
D3D12Core.dll!D3D12ValidateAndCreateDevice()    Unknown
D3D12.dll!D3D12CreateDeviceImpl(struct IUnknown *,enum D3D_FEATURE_LEVEL,struct _GUID const &,void * *) Unknown
D3D12.dll!D3D12CreateDevice()   Unknown
D3D12CudaUpdate.dll!DX12CudaSample::GetHardwareAdapter(IDXGIFactory2 * pFactory, IDXGIAdapter1 * * ppAdapter) Line 56   C++

Sources

I can't share the exact code, because I could not find a way to reproduce the error with a smaller project, but I am using the D3D12 code from this solution:

https://github.com/mprevot/CudaD3D12Update/blob/master/DX12CudaSample.cpp

The code to get the first D3D12 adapter is the same as from MSFT:

https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-d3d12createdevice

Soleil
  • 6,404
  • 5
  • 41
  • 61

1 Answers1

1

It looks like this is a known issue with Nvidia drivers right now: https://forums.developer.nvidia.com/t/poco-notfoundexception-thrown-in-driver-version-531-18/245285

Sadly, I think the only current working solution is to roll back drivers.