Hello
After the loss of the d3d11 path in my engine i am currently reimplementing all the features.Right now im facing some issues when resizing my buffers which i never encountered before. The code im using for resize events (on WM_SIZE) is:
void GxDeviceD3D11::onResize(uint32 w, uint32 h) {
if (!mIsInitialized) {
return;
}
mTargetHeight = h;
mTargetWidth = w;
mViewport.Height = static_cast<float>(mTargetHeight);
mViewport.Width = static_cast<float>(mTargetWidth);
mContext->OMSetRenderTargets(0, nullptr, nullptr);
mMainRenderTargetView->Release();
mMainDepthBufferView->Release();
assert(SUCCEEDED(mSwapChain->ResizeBuffers(0, 0, 0, DXGI_FORMAT_UNKNOWN, 0)));
ID3D11Texture2D* backBuffer = nullptr;
assert(SUCCEEDED(mSwapChain->GetBuffer(0, IID_PPV_ARGS(&backBuffer))));
assert(SUCCEEDED(mDevice->CreateRenderTargetView(backBuffer, nullptr, &mMainRenderTargetView)));
backBuffer->Release();
mDepthBufferDesc.Height = mTargetHeight;
mDepthBufferDesc.Width = mTargetWidth;
mMainDepthTexture->Release();
assert(SUCCEEDED(mDevice->CreateTexture2D(&mDepthBufferDesc, nullptr, &mMainDepthTexture)));
memset(&mDepthViewDesc, 0, sizeof(mDepthViewDesc));
mDepthViewDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
mDepthViewDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DMS;
assert(SUCCEEDED(mDevice->CreateDepthStencilView(mMainDepthTexture, &mDepthViewDesc, &mMainDepthBufferView)));
mContext->OMSetRenderTargets(1, &mMainRenderTargetView, mMainDepthBufferView);
mContext->RSSetViewports(1, &mViewport);
}
And the error i get:
D3D11 ERROR: ID3D11Device::RemoveDevice: Device removal has been triggered for the following reason (E_OUTOFMEMORY: The application tried to use more adapter memory than the Device can simultaneously accommodate. As a result, the TDR (Timeout Detection and Recovery) mechanism has been triggered. The current Device Context was executing commands when exhaustion occurred. The application needs to make less aggressive use of the display memory, perhaps by leveraging ClearState to ensure large Resources do not stay bound to the pipeline, or by leveraging information, such as DXGI_ADAPTER_DESC::DedicatedVideoMemory.). [ EXECUTION ERROR #378: DEVICE_REMOVAL_PROCESS_AT_FAULT]
Neither is the windows size very big nor are the values wrong.
If i comment out the ResizeBuffers and let the depth buffer its old size everything works fine, but as soon as im using ResizeBuffers and resize the window (when i let go of the window) it first halts for a while and then prints the error. If i only resize it a little it freezes for a second or two and then continues, but if i resize it more it freezes longer until i get the error message stated above. What could be the reason for that?
Greetings
Plerion