Skip to content

Resizing Swapchain for Direct2D failing, #466

Closed Answered by amannan-123
amannan-123 asked this question in Q&A
Discussion options

You must be logged in to vote

For anyone else who might face the same issue, the issue was caused by the bulk resizing of the swapchain buffers during the resize operation. It was resolved by ensuring the swapchain is not resized multiple times simultaneously.

Here's the relevant code snippet:

private bool _resizing = false;
private void ResizeRenderTarget()
{
	if (_swapChain == null || _d2dDeviceContext == null || _resizing) return;
	_resizing = true;
	_dxgiBackBuffer?.Release();
	_renderTarget?.Release();
	_d2dDeviceContext.Target.Release();
	_d2dDeviceContext.Target = null;
	var res = _swapChain.ResizeBuffers(0, 0, 0, Format.Unknown, SwapChainFlags.None);
	if (res.Failure)
	{
		throw new InvalidOperationException("…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@amannan-123
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by amannan-123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants