Skip to content

Commit c72d0b2

Browse files
committed
Backends: Vulkan: SwapChainImageUsage assume VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT which is added automatically. (#8946, #8110, #8111, #8686)
Merge bad3c14 which was accidentally only pushed to docking. No important side effect.
1 parent e612536 commit c72d0b2

File tree

5 files changed

+9
-13
lines changed

5 files changed

+9
-13
lines changed

backends/imgui_impl_vulkan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1634,7 +1634,7 @@ void ImGui_ImplVulkanH_CreateWindowSwapChain(VkPhysicalDevice physical_device, V
16341634
info.imageFormat = wd->SurfaceFormat.format;
16351635
info.imageColorSpace = wd->SurfaceFormat.colorSpace;
16361636
info.imageArrayLayers = 1;
1637-
info.imageUsage = (image_usage != 0) ? image_usage : VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
1637+
info.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | image_usage;
16381638
info.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE; // Assume that graphics family == present family
16391639
info.preTransform = (cap.supportedTransforms & VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR) ? VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR : cap.currentTransform;
16401640
info.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;

examples/example_glfw_vulkan/main.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ static VkDescriptorPool g_DescriptorPool = VK_NULL_HANDLE;
5454
static ImGui_ImplVulkanH_Window g_MainWindowData;
5555
static uint32_t g_MinImageCount = 2;
5656
static bool g_SwapChainRebuild = false;
57-
static VkImageUsageFlags g_SwapChainImageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
5857

5958
static void glfw_error_callback(int error, const char* description)
6059
{
@@ -240,7 +239,7 @@ static void SetupVulkanWindow(ImGui_ImplVulkanH_Window* wd, VkSurfaceKHR surface
240239

241240
// Create SwapChain, RenderPass, Framebuffer, etc.
242241
IM_ASSERT(g_MinImageCount >= 2);
243-
ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, wd, g_QueueFamily, g_Allocator, width, height, g_MinImageCount, g_SwapChainImageUsage);
242+
ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, wd, g_QueueFamily, g_Allocator, width, height, g_MinImageCount, 0);
244243
}
245244

246245
static void CleanupVulkan()
@@ -457,7 +456,7 @@ int main(int, char**)
457456
if (fb_width > 0 && fb_height > 0 && (g_SwapChainRebuild || g_MainWindowData.Width != fb_width || g_MainWindowData.Height != fb_height))
458457
{
459458
ImGui_ImplVulkan_SetMinImageCount(g_MinImageCount);
460-
ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, wd, g_QueueFamily, g_Allocator, fb_width, fb_height, g_MinImageCount, g_SwapChainImageUsage);
459+
ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, wd, g_QueueFamily, g_Allocator, fb_width, fb_height, g_MinImageCount, 0);
461460
g_MainWindowData.FrameIndex = 0;
462461
g_SwapChainRebuild = false;
463462
}

examples/example_sdl2_vulkan/main.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ static VkDescriptorPool g_DescriptorPool = VK_NULL_HANDLE;
4949
static ImGui_ImplVulkanH_Window g_MainWindowData;
5050
static uint32_t g_MinImageCount = 2;
5151
static bool g_SwapChainRebuild = false;
52-
static VkImageUsageFlags g_SwapChainImageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
5352

5453
static void check_vk_result(VkResult err)
5554
{
@@ -231,7 +230,7 @@ static void SetupVulkanWindow(ImGui_ImplVulkanH_Window* wd, VkSurfaceKHR surface
231230

232231
// Create SwapChain, RenderPass, Framebuffer, etc.
233232
IM_ASSERT(g_MinImageCount >= 2);
234-
ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, wd, g_QueueFamily, g_Allocator, width, height, g_MinImageCount, g_SwapChainImageUsage);
233+
ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, wd, g_QueueFamily, g_Allocator, width, height, g_MinImageCount, 0);
235234
}
236235

237236
static void CleanupVulkan()
@@ -477,7 +476,7 @@ int main(int, char**)
477476
if (fb_width > 0 && fb_height > 0 && (g_SwapChainRebuild || g_MainWindowData.Width != fb_width || g_MainWindowData.Height != fb_height))
478477
{
479478
ImGui_ImplVulkan_SetMinImageCount(g_MinImageCount);
480-
ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, wd, g_QueueFamily, g_Allocator, fb_width, fb_height, g_MinImageCount, g_SwapChainImageUsage);
479+
ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, wd, g_QueueFamily, g_Allocator, fb_width, fb_height, g_MinImageCount, 0);
481480
g_MainWindowData.FrameIndex = 0;
482481
g_SwapChainRebuild = false;
483482
}

examples/example_sdl3_vulkan/main.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ static VkDescriptorPool g_DescriptorPool = VK_NULL_HANDLE;
5151
static ImGui_ImplVulkanH_Window g_MainWindowData;
5252
static uint32_t g_MinImageCount = 2;
5353
static bool g_SwapChainRebuild = false;
54-
static VkImageUsageFlags g_SwapChainImageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
5554

5655
static void check_vk_result(VkResult err)
5756
{
@@ -233,7 +232,7 @@ static void SetupVulkanWindow(ImGui_ImplVulkanH_Window* wd, VkSurfaceKHR surface
233232

234233
// Create SwapChain, RenderPass, Framebuffer, etc.
235234
IM_ASSERT(g_MinImageCount >= 2);
236-
ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, wd, g_QueueFamily, g_Allocator, width, height, g_MinImageCount, g_SwapChainImageUsage);
235+
ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, wd, g_QueueFamily, g_Allocator, width, height, g_MinImageCount, 0);
237236
}
238237

239238
static void CleanupVulkan()
@@ -479,7 +478,7 @@ int main(int, char**)
479478
if (fb_width > 0 && fb_height > 0 && (g_SwapChainRebuild || g_MainWindowData.Width != fb_width || g_MainWindowData.Height != fb_height))
480479
{
481480
ImGui_ImplVulkan_SetMinImageCount(g_MinImageCount);
482-
ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, wd, g_QueueFamily, g_Allocator, fb_width, fb_height, g_MinImageCount, g_SwapChainImageUsage);
481+
ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, wd, g_QueueFamily, g_Allocator, fb_width, fb_height, g_MinImageCount, 0);
483482
g_MainWindowData.FrameIndex = 0;
484483
g_SwapChainRebuild = false;
485484
}

examples/example_win32_vulkan/main.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ static VkDescriptorPool g_DescriptorPool = VK_NULL_HANDLE;
4747
static ImGui_ImplVulkanH_Window g_MainWindowData;
4848
static uint32_t g_MinImageCount = 2;
4949
static bool g_SwapChainRebuild = false;
50-
static VkImageUsageFlags g_SwapChainImageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
5150

5251
static void check_vk_result(VkResult err)
5352
{
@@ -229,7 +228,7 @@ static void SetupVulkanWindow(ImGui_ImplVulkanH_Window* wd, VkSurfaceKHR surface
229228

230229
// Create SwapChain, RenderPass, Framebuffer, etc.
231230
IM_ASSERT(g_MinImageCount >= 2);
232-
ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, wd, g_QueueFamily, g_Allocator, width, height, g_MinImageCount, g_SwapChainImageUsage);
231+
ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, wd, g_QueueFamily, g_Allocator, width, height, g_MinImageCount, 0);
233232
}
234233

235234
static void CleanupVulkan()
@@ -550,7 +549,7 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
550549
if (fb_width > 0 && fb_height > 0 && (g_SwapChainRebuild || g_MainWindowData.Width != fb_width || g_MainWindowData.Height != fb_height))
551550
{
552551
ImGui_ImplVulkan_SetMinImageCount(g_MinImageCount);
553-
ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, &g_MainWindowData, g_QueueFamily, g_Allocator, fb_width, fb_height, g_MinImageCount, g_SwapChainImageUsage);
552+
ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, &g_MainWindowData, g_QueueFamily, g_Allocator, fb_width, fb_height, g_MinImageCount, 0);
554553
g_MainWindowData.FrameIndex = 0;
555554
g_SwapChainRebuild = false;
556555
}

0 commit comments

Comments
 (0)