Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.8.2
-
None
Description
I know, I have to attach minimal example, but the explanations below is quite clear.
Create own ID3D11Device *d3dDevice and ID3D11DeviceContext *d3dContext by using D3D11CreateDevice(), where the first parameter pAdapter is valid IDXGIAdapter pointer from IDXGIFactory1::EnumAdapters()
Now, import the device and context:
QRhiD3D11NativeHandles nativeHandles;
nativeHandles.dev = d3dDevice;
nativeHandles.context = d3dContext;
QRhi::Implementation m_curImpl= QRhi::D3D11;
QRhiD3D11InitParams initParams;
initParams.enableDebugLayer = true;
QRhi * rhi = QRhi::create(m_curImpl,&initParams,{},&nativeHandles);
rhi is a valid pointer.
Later, in QWindow::resizeEvent() we have : QRhiSwapChain:createOrResize() and the actual call is QD3D11SwapChain::createOrResize()
Since this is the first call, the member QD3D11SwapChain::swapChain is null and the code takes the true branch in "if (!swapChain) " qrhid3d11.cpp, line 5172.
At line 5179 we have: QRhiD3D::outputDesc1ForWindow(m_window, rhiD->activeAdapter, &hdrOutputDesc)
Note that rhiD->activeAapter is null.
Then we have call to output6ForWindow(w, adapter, &out6) and ACCESS VIOLATION at qrhid3dhepers.cpp line 20: for (UINT i = 0; adapter->EnumOutputs(i, &output) != DXGI_ERROR_NOT_FOUND; ++i)
"adapter" variable is null.
If we don't import device and context and allow QRhi::create to create its own,
output6ForWindow() is called with a valid IDXGIAdapter pointer for adapter parameter.
According to my debug, the crash is because when importing device and context, QRhiD3D11::create() does not set any value to QRhiD3D11::activeAdapter member.
QRhiD3D11:QRhiD3D11() correctly initializes importedDeviceAndContext member to true.
Then qrhid3d.cpp Line 243: if (!importedDeviceAndContext)
In the false branch (we importing device and context) I don't see any activeAdapter assignment it remains null.
The true branch correctly sets the activeAdapter member.
Attachments
Gerrit Reviews
For Gerrit Dashboard: QTBUG-135112 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
634388,1 | rhi: d3d11: Fix not setting activeAdapter when importing | 6.8 | qt/qtbase | Status: NEW | 0 | 0 |