void ResizeSurface()
        {
            Math.Rectangle newBounds = surface.Bounds;
            SurfaceSize   = newBounds.Size;
            SurfaceBounds = newBounds;

            deviceContext.OutputMerger.ResetTargets();
            swapChain.ResizeBuffers(0, (int)newBounds.Width, (int)newBounds.Height, DXGI.Format.R8G8B8A8_UNorm, DXGI.SwapChainFlags.None);
            deviceContext.Rasterizer.SetViewport(0, 0, newBounds.Width, newBounds.Height);

            viewMatrix  = Matrix.Transpose(Matrix.Scaling(2f / newBounds.Width, -2f / newBounds.Height, 1));
            viewMatrix *= Matrix.Transpose(Matrix.Translation(-newBounds.Width / 2f, -newBounds.Height / 2f, 0));
            UpdateMatrixBuffer();

            depthStencilView?.Dispose();
            depthStencilBuffer?.Dispose();
            surfaceTarget?.Dispose();
            surfaceView?.Dispose();
            surfaceTexture?.Dispose();

            depthStencilBuffer = device.CreateDepthStencilBuffer((int)newBounds.Width, (int)newBounds.Height, sampleDescription, out depthStencilView);
            surfaceTexture     = device.CreateSurface((int)newBounds.Width, (int)newBounds.Height, sampleDescription, out surfaceTarget);
            deviceContext.OutputMerger.SetTargets(depthStencilView, surfaceTarget);
            surfaceView = new D3D11.ShaderResourceView(device, surfaceTexture);
        }