mach icon indicating copy to clipboard operation
mach copied to clipboard

Resizing a window on Windows / D3D12 using sysgpu fails

Open hordurj opened this issue 1 year ago • 2 comments

Re-creating the swap chain fails when resizing a window.

thread 27560 panic: api error
.\mach\src\sysgpu\d3d12.zig:1381:13: 0xe26772 in init (core-sysgpu-triangle.exe.obj)
            return error.CreateSwapChainFailed;
            ^
.\mach\src\sysgpu\d3d12.zig:504:9: 0xe27f75 in createSwapChain (core-sysgpu-triangle.exe.obj)
        return SwapChain.init(device, surface, desc);
        ^
.\mach\src\core\platform\glfw\Core.zig:572:82: 0x11395e7 in appUpdateThreadTick__anon_155243 (core-sysgpu-triangle.exe.obj)
            self.swap_chain = self.gpu_device.createSwapChain(self.surface, &self.swap_chain_desc);

hordurj avatar Jun 20 '24 21:06 hordurj

The HRESULT returned from CreateSwapChainForHwnd is E_ACCESSDENIED (0x80070005).

I have confirmed the deinit is called on the previous swap chain. I haven't seen anything obvious causing this. Maybe there still is some unfinished work on the GPU that needs to be completed.

I am thinking of trying ResizeBuffers and seeing how that behaves.

hordurj avatar Jun 21 '24 23:06 hordurj

I can see from the debug layer that the reason the new swap chain cannot be created is because someone is still holding a reference to the old swap chain. If I do an extra release on the swap chain the resize works.

hordurj avatar Jun 22 '24 21:06 hordurj