Closed mcourteaux closed 1 month ago
I haven't actually looked into it yet, but I suspect frames-in-flight to be dependent on that swapchain that gets destroyed.
@mcourteaux I have long awaited for this, but unfortunately it is still crashing with my use case:
src\bgfx.cpp (1737): BGFX Reset back-buffer swap chain:
src\bgfx.cpp (1746): BGFX 1936x1222, format: RGBA8, numBackBuffers: 2, maxFrameLatency: 0
src\bgfx.cpp (1748): BGFX [ ] MSAAx1
src\bgfx.cpp (1749): BGFX [ ] Fullscreen
src\bgfx.cpp (1750): BGFX [ ] V-sync
src\bgfx.cpp (1751): BGFX [x] Max Anisotropy
src\bgfx.cpp (1752): BGFX [ ] Capture
src\bgfx.cpp (1753): BGFX [ ] Flush After Render
src\bgfx.cpp (1754): BGFX [ ] Flip After Render
src\bgfx.cpp (1755): BGFX [ ] sRGB Back Buffer
src\bgfx.cpp (1756): BGFX [ ] Transparent Back Buffer
src\bgfx.cpp (1757): BGFX [ ] HDR10
src\bgfx.cpp (1758): BGFX [ ] Hi-DPI
src\bgfx.cpp (1759): BGFX [ ] Depth Clamp
src\bgfx.cpp (1760): BGFX [ ] Suspend
src\renderer_vk.cpp (718): BGFX ---E- Unknown, Validation, 0: Validation Error: [ VUID-VkSwapchainCreateInfoKHR-preTransform-01279 ] | MessageID = 0x987713ee | vkCreateSwapchainKHR(): pCreateInfo->preTransform is not supported, support values are:
VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR%s
. The Vulkan spec states: preTransform must be one of the bits present in the supportedTransforms member of the VkSurfaceCapabilitiesKHR structure returned by vkGetPhysicalDeviceSurfaceCapabilitiesKHR for the surface (https://vulkan.lunarg.com/doc/view/1.3.290.0/windows/1.3-extensions/vkspec.html#VUID-VkSwapchainCreateInfoKHR-preTransform-01279)
src\renderer_vk.cpp (7241): BGFX Create swapchain numSwapChainImages 2, minImageCount 2, BX_COUNTOF(m_backBufferColorImage) 10
src\renderer_vk.cpp (718): BGFX ---E- RenderPass, Validation, 0: Validation Error: [ VUID-VkRenderPassBeginInfo-pNext-02852 ] Object 0: handle = 0x3a6cbb0000000025, type = VK_OBJECT_TYPE_RENDER_PASS; Object 1: handle = 0x7c6fcb0000023302, type = VK_OBJECT_TYPE_FRAMEBUFFER; | MessageID = 0xdb2c5767 | vkCmdBeginRenderPass(): pRenderPassBegin->renderArea offset.x (0) + extent.width (1937) is greater than framebuffer width (1936). The Vulkan spec states: If the pNext chain does not contain VkDeviceGroupRenderPassBeginInfo or its deviceRenderAreaCount member is equal to 0, renderArea.offset.x + renderArea.extent.width must be less than or equal to VkFramebufferCreateInfo::width the framebuffer was created with (https://vulkan.lunarg.com/doc/view/1.3.290.0/windows/1.3-extensions/vkspec.html#VUID-VkRenderPassBeginInfo-pNext-02852)
src\renderer_vk.cpp (718): BGFX ---E- RenderPass, Validation, 0: Validation Error: [ VUID-VkRenderPassBeginInfo-pNext-02852 ] Object 0: handle = 0x3a6cbb0000000025, type = VK_OBJECT_TYPE_RENDER_PASS; Object 1: handle = 0x7c6fcb0000023302, type = VK_OBJECT_TYPE_FRAMEBUFFER; | MessageID = 0xdb2c5767 | vkCmdBeginRenderPass(): pRenderPassBegin->renderArea offset.x (0) + extent.width (1937) is greater than framebuffer width (1936). The Vulkan spec states: If the pNext chain does not contain VkDeviceGroupRenderPassBeginInfo or its deviceRenderAreaCount member is equal to 0, renderArea.offset.x + renderArea.extent.width must be less than or equal to VkFramebufferCreateInfo::width the framebuffer was created with (https://vulkan.lunarg.com/doc/view/1.3.290.0/windows/1.3-extensions/vkspec.html#VUID-VkRenderPassBeginInfo-pNext-02852)
src\renderer_vk.cpp (7121): BGFX WARN Create swapchain error: vkDeviceWaitIdle() failed: -4: VK_ERROR_DEVICE_LOST
src\renderer_vk.cpp (718): BGFX ---E- Unknown, Validation, 0: Validation Error: [ VUID-VkSwapchainCreateInfoKHR-preTransform-01279 ] | MessageID = 0x987713ee | vkCreateSwapchainKHR(): pCreateInfo->preTransform is not supported, support values are:
VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR%s
. The Vulkan spec states: preTransform must be one of the bits present in the supportedTransforms member of the VkSurfaceCapabilitiesKHR structure returned by vkGetPhysicalDeviceSurfaceCapabilitiesKHR for the surface (https://vulkan.lunarg.com/doc/view/1.3.290.0/windows/1.3-extensions/vkspec.html#VUID-VkSwapchainCreateInfoKHR-preTransform-01279)
src\renderer_vk.cpp (7241): BGFX Create swapchain numSwapChainImages 2, minImageCount 2, BX_COUNTOF(m_backBufferColorImage) 10
src\renderer_vk.cpp(8203): ASSERT VK_SUCCESS == vkresult -> vkQueueSubmit(m_queue, 1, &si, m_completedFence); VK error 0xfffffffc: VK_ERROR_DEVICE_LOST
src\renderer_vk.cpp (8203): BGFX FATAL 0x00000000: vkQueueSubmit(m_queue, 1, &si, m_completedFence); VK error 0xfffffffc: VK_ERROR_DEVICE_LOST
Looks like a missing VK capabilities bit?
I have added this missing bit:
m_sci.surface = m_surface;
m_sci.minImageCount = swapBufferCount;
m_sci.imageFormat = surfaceFormat;
m_sci.imageColorSpace = surfaceColorSpace;
m_sci.imageExtent.width = width;
m_sci.imageExtent.height = height;
m_sci.imageUsage = imageUsage;
m_sci.preTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR; // <-- Here
m_sci.compositeAlpha = compositeAlpha;
m_sci.presentMode = s_presentMode[presentModeIdx].mode;
m_sci.clipped = VK_FALSE;
result = vkCreateSwapchainKHR(device, &m_sci, allocatorCb, &m_swapChain);
But it's still crashing. Something is different though:
src\bgfx.cpp (1737): BGFX Reset back-buffer swap chain:
src\bgfx.cpp (1746): BGFX 2255x1217, format: RGBA8, numBackBuffers: 2, maxFrameLatency: 0
src\bgfx.cpp (1748): BGFX [ ] MSAAx1
src\bgfx.cpp (1749): BGFX [ ] Fullscreen
src\bgfx.cpp (1750): BGFX [ ] V-sync
src\bgfx.cpp (1751): BGFX [x] Max Anisotropy
src\bgfx.cpp (1752): BGFX [ ] Capture
src\bgfx.cpp (1753): BGFX [ ] Flush After Render
src\bgfx.cpp (1754): BGFX [ ] Flip After Render
src\bgfx.cpp (1755): BGFX [ ] sRGB Back Buffer
src\bgfx.cpp (1756): BGFX [ ] Transparent Back Buffer
src\bgfx.cpp (1757): BGFX [ ] HDR10
src\bgfx.cpp (1758): BGFX [ ] Hi-DPI
src\bgfx.cpp (1759): BGFX [ ] Depth Clamp
src\bgfx.cpp (1760): BGFX [ ] Suspend
src\renderer_vk.cpp (7121): BGFX WARN Create swapchain error: vkDeviceWaitIdle() failed: -4: VK_ERROR_DEVICE_LOST
src\renderer_vk.cpp (7242): BGFX Create swapchain numSwapChainImages 2, minImageCount 2, BX_COUNTOF(m_backBufferColorImage) 10
src\renderer_vk.cpp (718): BGFX ---E- RenderPass, Validation, 0: Validation Error: [ VUID-VkRenderPassBeginInfo-pNext-02852 ] Object 0: handle = 0x3a6cbb0000000025, type = VK_OBJECT_TYPE_RENDER_PASS; Object 1: handle = 0xbb229e000000c3ed, type = VK_OBJECT_TYPE_FRAMEBUFFER; | MessageID = 0xdb2c5767 | vkCmdBeginRenderPass(): pRenderPassBegin->renderArea offset.x (0) + extent.width (2256) is greater than framebuffer width (2254). The Vulkan spec states: If the pNext chain does not contain VkDeviceGroupRenderPassBeginInfo or its deviceRenderAreaCount member is equal to 0, renderArea.offset.x + renderArea.extent.width must be less than or equal to VkFramebufferCreateInfo::width the framebuffer was created with (https://vulkan.lunarg.com/doc/view/1.3.290.0/windows/1.3-extensions/vkspec.html#VUID-VkRenderPassBeginInfo-pNext-02852)
src\renderer_vk.cpp (718): BGFX ---E- RenderPass, Validation, 0: Validation Error: [ VUID-VkRenderPassBeginInfo-pNext-02853 ] Object 0: handle = 0x3a6cbb0000000025, type = VK_OBJECT_TYPE_RENDER_PASS; Object 1: handle = 0xbb229e000000c3ed, type = VK_OBJECT_TYPE_FRAMEBUFFER; | MessageID = 0x1bd44466 | vkCmdBeginRenderPass(): pRenderPassBegin->renderArea offset.y (0) + extent.height (1218) is greater than framebuffer height (1216). The Vulkan spec states: If the pNext chain does not contain VkDeviceGroupRenderPassBeginInfo or its deviceRenderAreaCount member is equal to 0, renderArea.offset.y + renderArea.extent.height must be less than or equal to VkFramebufferCreateInfo::height the framebuffer was created with (https://vulkan.lunarg.com/doc/view/1.3.290.0/windows/1.3-extensions/vkspec.html#VUID-VkRenderPassBeginInfo-pNext-02853)
src\renderer_vk.cpp (718): BGFX ---E- RenderPass, Validation, 0: Validation Error: [ VUID-VkRenderPassBeginInfo-pNext-02852 ] Object 0: handle = 0x3a6cbb0000000025, type = VK_OBJECT_TYPE_RENDER_PASS; Object 1: handle = 0xbb229e000000c3ed, type = VK_OBJECT_TYPE_FRAMEBUFFER; | MessageID = 0xdb2c5767 | vkCmdBeginRenderPass(): pRenderPassBegin->renderArea offset.x (0) + extent.width (2256) is greater than framebuffer width (2254). The Vulkan spec states: If the pNext chain does not contain VkDeviceGroupRenderPassBeginInfo or its deviceRenderAreaCount member is equal to 0, renderArea.offset.x + renderArea.extent.width must be less than or equal to VkFramebufferCreateInfo::width the framebuffer was created with (https://vulkan.lunarg.com/doc/view/1.3.290.0/windows/1.3-extensions/vkspec.html#VUID-VkRenderPassBeginInfo-pNext-02852)
src\renderer_vk.cpp (718): BGFX ---E- RenderPass, Validation, 0: Validation Error: [ VUID-VkRenderPassBeginInfo-pNext-02853 ] Object 0: handle = 0x3a6cbb0000000025, type = VK_OBJECT_TYPE_RENDER_PASS; Object 1: handle = 0xbb229e000000c3ed, type = VK_OBJECT_TYPE_FRAMEBUFFER; | MessageID = 0x1bd44466 | vkCmdBeginRenderPass(): pRenderPassBegin->renderArea offset.y (0) + extent.height (1218) is greater than framebuffer height (1216). The Vulkan spec states: If the pNext chain does not contain VkDeviceGroupRenderPassBeginInfo or its deviceRenderAreaCount member is equal to 0, renderArea.offset.y + renderArea.extent.height must be less than or equal to VkFramebufferCreateInfo::height the framebuffer was created with (https://vulkan.lunarg.com/doc/view/1.3.290.0/windows/1.3-extensions/vkspec.html#VUID-VkRenderPassBeginInfo-pNext-02853)
src\renderer_vk.cpp (718): BGFX ---E- RenderPass, Validation, 0: Validation Error: [ VUID-VkRenderPassBeginInfo-pNext-02852 ] Object 0: handle = 0x3a6cbb0000000025, type = VK_OBJECT_TYPE_RENDER_PASS; Object 1: handle = 0xbb229e000000c3ed, type = VK_OBJECT_TYPE_FRAMEBUFFER; | MessageID = 0xdb2c5767 | vkCmdBeginRenderPass(): pRenderPassBegin->renderArea offset.x (0) + extent.width (2255) is greater than framebuffer width (2254). The Vulkan spec states: If the pNext chain does not contain VkDeviceGroupRenderPassBeginInfo or its deviceRenderAreaCount member is equal to 0, renderArea.offset.x + renderArea.extent.width must be less than or equal to VkFramebufferCreateInfo::width the framebuffer was created with (https://vulkan.lunarg.com/doc/view/1.3.290.0/windows/1.3-extensions/vkspec.html#VUID-VkRenderPassBeginInfo-pNext-02852)
src\renderer_vk.cpp (718): BGFX ---E- RenderPass, Validation, 0: Validation Error: [ VUID-VkRenderPassBeginInfo-pNext-02853 ] Object 0: handle = 0x3a6cbb0000000025, type = VK_OBJECT_TYPE_RENDER_PASS; Object 1: handle = 0xbb229e000000c3ed, type = VK_OBJECT_TYPE_FRAMEBUFFER; | MessageID = 0x1bd44466 | vkCmdBeginRenderPass(): pRenderPassBegin->renderArea offset.y (0) + extent.height (1217) is greater than framebuffer height (1216). The Vulkan spec states: If the pNext chain does not contain VkDeviceGroupRenderPassBeginInfo or its deviceRenderAreaCount member is equal to 0, renderArea.offset.y + renderArea.extent.height must be less than or equal to VkFramebufferCreateInfo::height the framebuffer was created with (https://vulkan.lunarg.com/doc/view/1.3.290.0/windows/1.3-extensions/vkspec.html#VUID-VkRenderPassBeginInfo-pNext-02853)
src\renderer_vk.cpp(8204): ASSERT VK_SUCCESS == vkresult -> vkQueueSubmit(m_queue, 1, &si, m_completedFence); VK error 0xfffffffc: VK_ERROR_DEVICE_LOST
src\renderer_vk.cpp (8204): BGFX FATAL 0x00000000: vkQueueSubmit(m_queue, 1, &si, m_completedFence); VK error 0xfffffffc: VK_ERROR_DEVICE_LOST
I'm on Windows BTW.
This validation error:
src\renderer_vk.cpp (718): BGFX ---E- RenderPass, Validation, 0: Validation Error: [ VUID-VkRenderPassBeginInfo-pNext-02852 ] Object 0: handle = 0x3a6cbb0000000025, type = VK_OBJECT_TYPE_RENDER_PASS; Object 1: handle = 0xbb229e000000c3ed, type = VK_OBJECT_TYPE_FRAMEBUFFER; | MessageID = 0xdb2c5767 | vkCmdBeginRenderPass(): pRenderPassBegin->renderArea offset.x (0) + extent.width (2256) is greater than framebuffer width (2254). The Vulkan spec states: If the pNext chain does not contain VkDeviceGroupRenderPassBeginInfo or its deviceRenderAreaCount member is equal to 0, renderArea.offset.x + renderArea.extent.width must be less than or equal to VkFramebufferCreateInfo::width the framebuffer was created with (https://vulkan.lunarg.com/doc/view/1.3.290.0/windows/1.3-extensions/vkspec.html#VUID-VkRenderPassBeginInfo-pNext-02852)
Sounds like you didn't properly adjust bgfx::setViewRect()
accordingly? Can you double check that?
@mcourteaux I have double checked, and it is set properly.
@bkaradzic This really sounds like the issue I mentioned: there are still frames in flight which were using frames from the swapchain that got destroyed. How would we need to properly fix this?
I'm gathering clues:
However, the disadvantage of this approach is that we need to stop all rendering before creating the new swap chain. It is possible to create a new swap chain while drawing commands on an image from the old swap chain are still in-flight. You need to pass the previous swap chain to the oldSwapChain field in the VkSwapchainCreateInfoKHR struct and destroy the old swap chain as soon as you've finished using it.
oldSwapchain
stating:
Providing a valid oldSwapchain may aid in the resource reuse, and also allows the application to still present any images that are already acquired from it.
https://vulkan-tutorial.com/Drawing_a_triangle/Swap_chain_recreation#comment-5042868630
Posting in case someone is getting DEVICE_LOST on WaitIdle when recreating swapchains.
I noticed later on in the tutorial that vkDeviceWaitIdle() would sometimes fail with DEVICE_LOST before recreating the swapchain when I resized (glfw/rust with ash/ubuntu/nvidia) but work most of the time.
When I dragged the edge of the window, I would get swapchain out-of-date results every frame (even if I didn't release the mouse) and the swapchain would be recreated every frame with small incremental changes in size and then suddenly it would fail. I tried reproducing it on my windows machine (also nvidia but newer gpu) where resize failed directly (but only when releasing the mouse button). On windows, I would also get a "vkCreateSwapchainKHR: internal drawable creation failed" from the validation layers. I fixed both of the issues by reusing the old swapchain!
Previously I was creating a new one and then destroying the old afterwards. Not sure if this was the issue though. Now, I reuse the old when recreating and then destroy the old and everything works as expected.
Note that I was always calling WaitIdle before creating/destroying swapchains so I'm assuming the wait idle somehow did not wait properly? I also tried to wait on all outstanding fences before calling WaitIdle, but it did not help. Anyhow, reusing the old swapchain fixes it!
This comment seems relevant, but unfortunately, I don't really understand what the explained solution is.
needtoRefreshSwapchain
flag. What if the reasoning is wrong/outdated?@pezcode What are your thoughts on the matter?
Should we somehow flush the frames in flight, then switch out the swapchain, and spin back up?
Yes, wait for everything to finish, then do resizing/switching.
Should we somehow flush the frames in flight, then switch out the swapchain, and spin back up?
Yes, wait for everything to finish, then do resizing/switching.
What I mean is not just "wait", but also do an extra flip() to allow the last frame-in-flight corresponding to the old swapchain to be presented before we recreate the swapchain. Or am I talking nonsense? I sort of think this is wrong, because the window already IS resized. But I'm trying to figure out what's the reason for the vkDeviceWaitIdle()
to fail.
I thought the code already force-waits on a fence here: https://github.com/bkaradzic/bgfx/blob/dd4199bcb37426326e0e31419e99c10701e96c58/src/renderer_vk.cpp#L6824
So I'm not 100% sure why your fix works compared to the existing code. But I don't have a way to reproduce this, so I can't really help here.
Bikeshedding opinion ahead: vkDeviceWaitIdle()
is a massive hammer you shouldn't be using unless it's for shutting down the whole program or you don't care about performance. Fences are always the better option, although it means you need to spend a bit longer to understand the dependencies.
This code is explicitly ignoring the needtoRefreshSwapchain flag. What if the reasoning is wrong/outdated?
Feel free to try, but back when I wrote this it would happen that the swapchain was invalidated, but the new window size from reset() only made it to the renderer 2 frames later. So if you immediately recreated the swapchain, it would be with the old window size.
Previously I was creating a new one and then destroying the old afterwards. Not sure if this was the issue though. Now, I reuse the old when recreating and then destroy the old and everything works as expected.
In general this should be done for smooth resizing. Basically set the old swapchain handle here: https://github.com/bkaradzic/bgfx/blob/dd4199bcb37426326e0e31419e99c10701e96c58/src/renderer_vk.cpp#L6739 Then create the new one, and only then destroy the old one.
I tried this but kind of gave up because it made the code flow terrible to follow, and it was a minor optimization for visuals while resizing. It could be that some drivers have a fit when creating too many swapchains without reusing the old one, but it's not required by the spec. May or may not solve this issue, not sure.
Yeah I'm also unable to reproduce locally... Anyone who has this issue do you see it in examples, or only in your app?
It does crash with examples when modifying them to allow smooth resizing (rendering thread is different from the event thread).
I think I suggest adding a Resize
enum to the command buffer, and implement that among others things, because it's hard to track dependencies using hacks alone.
I was able to reproduce, but since the added vkDeviceWaitIdle()
I can't anymore. Perhaps I should try to debug this, without having the wait for idle instruction.
I was able to reproduce
In unmodified examples from repo?
Lets continue here: https://discord.com/channels/712512073522872352/1294033853102424125
I have added this missing bit:
m_sci.surface = m_surface; m_sci.minImageCount = swapBufferCount; m_sci.imageFormat = surfaceFormat; m_sci.imageColorSpace = surfaceColorSpace; m_sci.imageExtent.width = width; m_sci.imageExtent.height = height; m_sci.imageUsage = imageUsage; m_sci.preTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR; // <-- Here m_sci.compositeAlpha = compositeAlpha; m_sci.presentMode = s_presentMode[presentModeIdx].mode; m_sci.clipped = VK_FALSE; result = vkCreateSwapchainKHR(device, &m_sci, allocatorCb, &m_swapChain);
But it's still crashing. Something is different though:
src\bgfx.cpp (1737): BGFX Reset back-buffer swap chain: src\bgfx.cpp (1746): BGFX 2255x1217, format: RGBA8, numBackBuffers: 2, maxFrameLatency: 0 src\bgfx.cpp (1748): BGFX [ ] MSAAx1 src\bgfx.cpp (1749): BGFX [ ] Fullscreen src\bgfx.cpp (1750): BGFX [ ] V-sync src\bgfx.cpp (1751): BGFX [x] Max Anisotropy src\bgfx.cpp (1752): BGFX [ ] Capture src\bgfx.cpp (1753): BGFX [ ] Flush After Render src\bgfx.cpp (1754): BGFX [ ] Flip After Render src\bgfx.cpp (1755): BGFX [ ] sRGB Back Buffer src\bgfx.cpp (1756): BGFX [ ] Transparent Back Buffer src\bgfx.cpp (1757): BGFX [ ] HDR10 src\bgfx.cpp (1758): BGFX [ ] Hi-DPI src\bgfx.cpp (1759): BGFX [ ] Depth Clamp src\bgfx.cpp (1760): BGFX [ ] Suspend src\renderer_vk.cpp (7121): BGFX WARN Create swapchain error: vkDeviceWaitIdle() failed: -4: VK_ERROR_DEVICE_LOST src\renderer_vk.cpp (7242): BGFX Create swapchain numSwapChainImages 2, minImageCount 2, BX_COUNTOF(m_backBufferColorImage) 10 src\renderer_vk.cpp (718): BGFX ---E- RenderPass, Validation, 0: Validation Error: [ VUID-VkRenderPassBeginInfo-pNext-02852 ] Object 0: handle = 0x3a6cbb0000000025, type = VK_OBJECT_TYPE_RENDER_PASS; Object 1: handle = 0xbb229e000000c3ed, type = VK_OBJECT_TYPE_FRAMEBUFFER; | MessageID = 0xdb2c5767 | vkCmdBeginRenderPass(): pRenderPassBegin->renderArea offset.x (0) + extent.width (2256) is greater than framebuffer width (2254). The Vulkan spec states: If the pNext chain does not contain VkDeviceGroupRenderPassBeginInfo or its deviceRenderAreaCount member is equal to 0, renderArea.offset.x + renderArea.extent.width must be less than or equal to VkFramebufferCreateInfo::width the framebuffer was created with (https://vulkan.lunarg.com/doc/view/1.3.290.0/windows/1.3-extensions/vkspec.html#VUID-VkRenderPassBeginInfo-pNext-02852) src\renderer_vk.cpp (718): BGFX ---E- RenderPass, Validation, 0: Validation Error: [ VUID-VkRenderPassBeginInfo-pNext-02853 ] Object 0: handle = 0x3a6cbb0000000025, type = VK_OBJECT_TYPE_RENDER_PASS; Object 1: handle = 0xbb229e000000c3ed, type = VK_OBJECT_TYPE_FRAMEBUFFER; | MessageID = 0x1bd44466 | vkCmdBeginRenderPass(): pRenderPassBegin->renderArea offset.y (0) + extent.height (1218) is greater than framebuffer height (1216). The Vulkan spec states: If the pNext chain does not contain VkDeviceGroupRenderPassBeginInfo or its deviceRenderAreaCount member is equal to 0, renderArea.offset.y + renderArea.extent.height must be less than or equal to VkFramebufferCreateInfo::height the framebuffer was created with (https://vulkan.lunarg.com/doc/view/1.3.290.0/windows/1.3-extensions/vkspec.html#VUID-VkRenderPassBeginInfo-pNext-02853) src\renderer_vk.cpp (718): BGFX ---E- RenderPass, Validation, 0: Validation Error: [ VUID-VkRenderPassBeginInfo-pNext-02852 ] Object 0: handle = 0x3a6cbb0000000025, type = VK_OBJECT_TYPE_RENDER_PASS; Object 1: handle = 0xbb229e000000c3ed, type = VK_OBJECT_TYPE_FRAMEBUFFER; | MessageID = 0xdb2c5767 | vkCmdBeginRenderPass(): pRenderPassBegin->renderArea offset.x (0) + extent.width (2256) is greater than framebuffer width (2254). The Vulkan spec states: If the pNext chain does not contain VkDeviceGroupRenderPassBeginInfo or its deviceRenderAreaCount member is equal to 0, renderArea.offset.x + renderArea.extent.width must be less than or equal to VkFramebufferCreateInfo::width the framebuffer was created with (https://vulkan.lunarg.com/doc/view/1.3.290.0/windows/1.3-extensions/vkspec.html#VUID-VkRenderPassBeginInfo-pNext-02852) src\renderer_vk.cpp (718): BGFX ---E- RenderPass, Validation, 0: Validation Error: [ VUID-VkRenderPassBeginInfo-pNext-02853 ] Object 0: handle = 0x3a6cbb0000000025, type = VK_OBJECT_TYPE_RENDER_PASS; Object 1: handle = 0xbb229e000000c3ed, type = VK_OBJECT_TYPE_FRAMEBUFFER; | MessageID = 0x1bd44466 | vkCmdBeginRenderPass(): pRenderPassBegin->renderArea offset.y (0) + extent.height (1218) is greater than framebuffer height (1216). The Vulkan spec states: If the pNext chain does not contain VkDeviceGroupRenderPassBeginInfo or its deviceRenderAreaCount member is equal to 0, renderArea.offset.y + renderArea.extent.height must be less than or equal to VkFramebufferCreateInfo::height the framebuffer was created with (https://vulkan.lunarg.com/doc/view/1.3.290.0/windows/1.3-extensions/vkspec.html#VUID-VkRenderPassBeginInfo-pNext-02853) src\renderer_vk.cpp (718): BGFX ---E- RenderPass, Validation, 0: Validation Error: [ VUID-VkRenderPassBeginInfo-pNext-02852 ] Object 0: handle = 0x3a6cbb0000000025, type = VK_OBJECT_TYPE_RENDER_PASS; Object 1: handle = 0xbb229e000000c3ed, type = VK_OBJECT_TYPE_FRAMEBUFFER; | MessageID = 0xdb2c5767 | vkCmdBeginRenderPass(): pRenderPassBegin->renderArea offset.x (0) + extent.width (2255) is greater than framebuffer width (2254). The Vulkan spec states: If the pNext chain does not contain VkDeviceGroupRenderPassBeginInfo or its deviceRenderAreaCount member is equal to 0, renderArea.offset.x + renderArea.extent.width must be less than or equal to VkFramebufferCreateInfo::width the framebuffer was created with (https://vulkan.lunarg.com/doc/view/1.3.290.0/windows/1.3-extensions/vkspec.html#VUID-VkRenderPassBeginInfo-pNext-02852) src\renderer_vk.cpp (718): BGFX ---E- RenderPass, Validation, 0: Validation Error: [ VUID-VkRenderPassBeginInfo-pNext-02853 ] Object 0: handle = 0x3a6cbb0000000025, type = VK_OBJECT_TYPE_RENDER_PASS; Object 1: handle = 0xbb229e000000c3ed, type = VK_OBJECT_TYPE_FRAMEBUFFER; | MessageID = 0x1bd44466 | vkCmdBeginRenderPass(): pRenderPassBegin->renderArea offset.y (0) + extent.height (1217) is greater than framebuffer height (1216). The Vulkan spec states: If the pNext chain does not contain VkDeviceGroupRenderPassBeginInfo or its deviceRenderAreaCount member is equal to 0, renderArea.offset.y + renderArea.extent.height must be less than or equal to VkFramebufferCreateInfo::height the framebuffer was created with (https://vulkan.lunarg.com/doc/view/1.3.290.0/windows/1.3-extensions/vkspec.html#VUID-VkRenderPassBeginInfo-pNext-02853) src\renderer_vk.cpp(8204): ASSERT VK_SUCCESS == vkresult -> vkQueueSubmit(m_queue, 1, &si, m_completedFence); VK error 0xfffffffc: VK_ERROR_DEVICE_LOST src\renderer_vk.cpp (8204): BGFX FATAL 0x00000000: vkQueueSubmit(m_queue, 1, &si, m_completedFence); VK error 0xfffffffc: VK_ERROR_DEVICE_LOST
I'm on Windows BTW.
Confirmed that adding m_sci.preTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR; // <-- Here makes the validation error go away for me too for vulkan with Radeon driver.
@pgruenbacher You're stomping over data initialized here: https://github.com/bkaradzic/bgfx/blob/cc789e83a69fddfb13f6cbeb89f43aa56dcfff9d/src/renderer_vk.cpp#L6736-L6739
hm ok i'll look into what my root cause was then.
yea nvm I was just mistaken, testing with latest bgfx and this merged PR resolved it for me.
Potentially fixes #3227. At least on my machine, aggressively resizing the window no longer causes a device lost. For my setup, this change is an improvement. The idea is taken from here: https://github.com/mpv-player/mpv/issues/8360#issuecomment-1486705836