mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-11-03 22:51:06 +01:00 
			
		
		
		
	Backends: Vulkan: Add override for the subpass to reference during VkPipeline creation. (#3579)
This allows for binding the pipeline/sending draw commands (via `ImGui_ImplVulkan_RenderDrawData`) against any subpass, rather than being restricted to only the first subpass. Without this, attempting to bind the pipeline against a subpass other than the first one results in validation layer errors and, at worst, some drivers failing if the subpass attachments differ.
This commit is contained in:
		
				
					committed by
					
						
						ocornut
					
				
			
			
				
	
			
			
			
						parent
						
							61825c7735
						
					
				
				
					commit
					6a0e85c561
				
			@@ -22,6 +22,7 @@
 | 
			
		||||
 | 
			
		||||
// CHANGELOG
 | 
			
		||||
// (minor and older changes stripped away, please see git history for details)
 | 
			
		||||
//  2020-11-11: Vulkan: Added support for specifying which subpass to reference during VkPipeline creation.
 | 
			
		||||
//  2020-09-07: Vulkan: Added VkPipeline parameter to ImGui_ImplVulkan_RenderDrawData (default to one passed to ImGui_ImplVulkan_Init).
 | 
			
		||||
//  2020-05-04: Vulkan: Fixed crash if initial frame has no vertices.
 | 
			
		||||
//  2020-04-26: Vulkan: Fixed edge case where render callbacks wouldn't be called if the ImDrawData didn't have vertices.
 | 
			
		||||
@@ -81,6 +82,7 @@ static VkDescriptorSetLayout    g_DescriptorSetLayout = VK_NULL_HANDLE;
 | 
			
		||||
static VkPipelineLayout         g_PipelineLayout = VK_NULL_HANDLE;
 | 
			
		||||
static VkDescriptorSet          g_DescriptorSet = VK_NULL_HANDLE;
 | 
			
		||||
static VkPipeline               g_Pipeline = VK_NULL_HANDLE;
 | 
			
		||||
static uint32_t                 g_Subpass = 0;
 | 
			
		||||
static VkShaderModule           g_ShaderModuleVert;
 | 
			
		||||
static VkShaderModule           g_ShaderModuleFrag;
 | 
			
		||||
 | 
			
		||||
@@ -675,7 +677,7 @@ static void ImGui_ImplVulkan_CreatePipelineLayout(VkDevice device, const VkAlloc
 | 
			
		||||
    check_vk_result(err);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void ImGui_ImplVulkan_CreatePipeline(VkDevice device, const VkAllocationCallbacks* allocator, VkPipelineCache pipelineCache, VkRenderPass renderPass, VkSampleCountFlagBits MSAASamples, VkPipeline* pipeline)
 | 
			
		||||
static void ImGui_ImplVulkan_CreatePipeline(VkDevice device, const VkAllocationCallbacks* allocator, VkPipelineCache pipelineCache, VkRenderPass renderPass, VkSampleCountFlagBits MSAASamples, VkPipeline* pipeline, uint32_t subpass)
 | 
			
		||||
{
 | 
			
		||||
    ImGui_ImplVulkan_CreateShaderModules(device, allocator);
 | 
			
		||||
 | 
			
		||||
@@ -775,6 +777,7 @@ static void ImGui_ImplVulkan_CreatePipeline(VkDevice device, const VkAllocationC
 | 
			
		||||
    info.pDynamicState = &dynamic_state;
 | 
			
		||||
    info.layout = g_PipelineLayout;
 | 
			
		||||
    info.renderPass = renderPass;
 | 
			
		||||
    info.subpass = subpass;
 | 
			
		||||
    VkResult err = vkCreateGraphicsPipelines(device, pipelineCache, 1, &info, allocator, pipeline);
 | 
			
		||||
    check_vk_result(err);
 | 
			
		||||
}
 | 
			
		||||
@@ -846,7 +849,7 @@ bool ImGui_ImplVulkan_CreateDeviceObjects()
 | 
			
		||||
        check_vk_result(err);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ImGui_ImplVulkan_CreatePipeline(v->Device, v->Allocator, v->PipelineCache, g_RenderPass, v->MSAASamples, &g_Pipeline);
 | 
			
		||||
    ImGui_ImplVulkan_CreatePipeline(v->Device, v->Allocator, v->PipelineCache, g_RenderPass, v->MSAASamples, &g_Pipeline, g_Subpass);
 | 
			
		||||
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
@@ -901,6 +904,8 @@ bool    ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info, VkRenderPass rend
 | 
			
		||||
 | 
			
		||||
    g_VulkanInitInfo = *info;
 | 
			
		||||
    g_RenderPass = render_pass;
 | 
			
		||||
    g_Subpass = info->Subpass;
 | 
			
		||||
 | 
			
		||||
    ImGui_ImplVulkan_CreateDeviceObjects();
 | 
			
		||||
 | 
			
		||||
    return true;
 | 
			
		||||
@@ -1193,7 +1198,7 @@ void ImGui_ImplVulkanH_CreateWindowSwapChain(VkPhysicalDevice physical_device, V
 | 
			
		||||
 | 
			
		||||
        // We do not create a pipeline by default as this is also used by examples' main.cpp,
 | 
			
		||||
        // but secondary viewport in multi-viewport mode may want to create one with:
 | 
			
		||||
        //ImGui_ImplVulkan_CreatePipeline(device, allocator, VK_NULL_HANDLE, wd->RenderPass, VK_SAMPLE_COUNT_1_BIT, &wd->Pipeline);
 | 
			
		||||
        //ImGui_ImplVulkan_CreatePipeline(device, allocator, VK_NULL_HANDLE, wd->RenderPass, VK_SAMPLE_COUNT_1_BIT, &wd->Pipeline, g_Subpass);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Create The Image Views
 | 
			
		||||
 
 | 
			
		||||
@@ -35,6 +35,7 @@ struct ImGui_ImplVulkan_InitInfo
 | 
			
		||||
    VkQueue             Queue;
 | 
			
		||||
    VkPipelineCache     PipelineCache;
 | 
			
		||||
    VkDescriptorPool    DescriptorPool;
 | 
			
		||||
    uint32_t            Subpass;
 | 
			
		||||
    uint32_t            MinImageCount;          // >= 2
 | 
			
		||||
    uint32_t            ImageCount;             // >= MinImageCount
 | 
			
		||||
    VkSampleCountFlagBits        MSAASamples;   // >= VK_SAMPLE_COUNT_1_BIT
 | 
			
		||||
 
 | 
			
		||||
@@ -74,6 +74,7 @@ Other Changes:
 | 
			
		||||
- Backends: OpenGL3: Use glGetString(GL_VERSION) query instead of glGetIntegerv(GL_MAJOR_VERSION, ...)
 | 
			
		||||
  when the later returns zero (e.g. Desktop GL 2.x). (#3530) [@xndcn]
 | 
			
		||||
- Backends: OpenGL3: Backup and restore GL_PRIMITIVE_RESTART state. (#3544) [@Xipiryon]
 | 
			
		||||
- Backends: Vulkan: Added support for specifying which subpass to reference during VkPipeline creation. (@3579) [@bdero]
 | 
			
		||||
- Backends: OSX: Fix keypad-enter key not working on MacOS. (#3554) [@rokups, @lfnoise]
 | 
			
		||||
- Examples: Apple+Metal: Consolidated/simplified to get closer to other examples. (#3543) [@warrenm]
 | 
			
		||||
- Docs: Split examples/README.txt into docs/BACKENDS.md and docs/EXAMPLES.md improved them.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user