-
-
Notifications
You must be signed in to change notification settings - Fork 11.4k
Description
Version/Branch of Dear ImGui:
Version: v1.92.6 WIP, Branch: docking
Back-ends:
imgui_impl_glfw.cpp + imgui_impl_vulkan.cpp
Compiler, OS:
MSVC 14.44.35207, Windows 11 Enterprise 10.0.26200 Build 26200
Full config/build information:
Version: v1.92.6 WIP
Branch: docking
Back-ends: imgui_impl_glfw.cpp + imgui_impl_vulkan.cpp
Compiler: MSVC 14.44.35207
Operating System: Windows 11 Enterprise 10.0.26200 Build 26200
Details:
Using dynamic rendering and MSAA > 1 sample doesn't work
Multi-sampling works fine for main viewport (ImGui_ImplVulkan_InitInfo::PipelineInfoMain::MSAASamples), since rendering info is controlled by the host app. This allows creating multi-sample color target and resolving to swapchain image. However, when using multi-sampling for additional viewports (ImGui_ImplVulkan_InitInfo::PipelineInfoForViewports::MSAASamples), gives the following validation error:
Vulkan: ERROR: Validation Error: [ VUID-vkCmdDrawIndexed-multisampledRenderToSingleSampled-07285 ] Object 0: handle = 0x139a1095dd0, type = VK_OBJECT_TYPE_COMMAND_BUFFER; Object 1: handle = 0xf9a524000000009e, type = VK_OBJECT_TYPE_PIPELINE; | MessageID = 0xf4b969ec | vkCmdDrawIndexed(): Color attachment (0) sample count (VK_SAMPLE_COUNT_1_BIT) must match corresponding VkPipelineMultisampleStateCreateInfo sample count (VK_SAMPLE_COUNT_4_BIT).
The Vulkan spec states: If the bound pipeline was created without a VkAttachmentSampleCountInfoAMD or VkAttachmentSampleCountInfoNV structure, and the multisampledRenderToSingleSampled feature is not enabled, and the current render pass instance was begun with vkCmdBeginRendering with a VkRenderingInfo::colorAttachmentCount parameter greater than 0, then each element of the VkRenderingInfo::pColorAttachments array with a imageView not equal to VK_NULL_HANDLE must have been created with a sample count equal to the value of rasterizationSamples for the bound graphics pipeline (https://vulkan.lunarg.com/doc/view/1.4.304.1/windows/antora/spec/latest/chapters/drawing.html#VUID-vkCmdDrawIndexed-multisampledRenderToSingleSampled-07285)
That is because we don't have separate multi-sample color attachment. I think what needs to happen is the following:
- When using dynamic rendering and MSAASamples != VK_SAMPLE_COUNT_1_BIT
- Create/resize MSAA back buffer image/image view
- When rendering and if using MSAA
- Insert barriers to transition both MSAA and resolve back buffers
- Use MSAA back buffer view as color attachment and back buffer as resolve image view
Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code:
Typical ImGui_ImplVulkan_InitInfo configuration:
auto colorFormat = VK_FORMAT_R8G8B8A8_UNORM;
VkPipelineRenderingCreateInfo pipelineInfo{
.sType = VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO,
.colorAttachmentCount = 1,
.pColorAttachmentFormats = &colorFormat,
};
auto samples = VK_SAMPLE_COUNT_4_BIT;
ImGui_ImplVulkan_InitInfo info{
.ApiVersion = VK_API_VERSION_1_3,
...
.PipelineInfoMain = {
.MSAASamples = samples,
.PipelineRenderingCreateInfo = pipelineInfo,
},
.PipelineInfoForViewports = {
.MSAASamples = samples,
.PipelineRenderingCreateInfo = pipelineInfo,
},
.UseDynamicRendering = true,
...
};