From e06d360e2893e06001d6390525ac9f2b0f5cf28b Mon Sep 17 00:00:00 2001 From: Mars Date: Tue, 15 Oct 2024 21:53:36 -0400 Subject: [PATCH] hooooly it works --- .gitignore | 1 + src/main.cpp | 55 ++++++++++++++++++++++++++++++++++------------------ 2 files changed, 37 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index a1b519d..a0026ae 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ .direnv/ .vscode/ build/ +imgui.ini diff --git a/src/main.cpp b/src/main.cpp index 736f2a4..63755c0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -159,8 +159,9 @@ class VulkanApp { std::vector mUniformBuffersMapped; // Mapped pointers for the uniform buffers // Descriptor pool and sets - vk::UniqueDescriptorPool mDescriptorPool; // Descriptor pool - std::vector mDescriptorSets; // Descriptor sets + vk::UniqueDescriptorPool mDescriptorPool; // Descriptor pool + vk::UniqueDescriptorPool mImGuiDescriptorPool; // Descriptor pool for ImGui + std::vector mDescriptorSets; // Descriptor sets // Command buffers std::vector mCommandBuffers; // Command buffers @@ -277,25 +278,41 @@ class VulkanApp { // Initialize ImGui for GLFW and Vulkan ImGui_ImplGlfw_InitForVulkan(mWindow.get(), true); - ImGui_ImplVulkan_InitInfo initInfo = {}; - initInfo.Instance = mInstance.get(); - initInfo.PhysicalDevice = mPhysicalDevice; - initInfo.Device = mDevice.get(); - initInfo.QueueFamily = findQueueFamilies(mPhysicalDevice).graphics_family.value(); - initInfo.Queue = mGraphicsQueue; - initInfo.PipelineCache = VK_NULL_HANDLE; - initInfo.DescriptorPool = mDescriptorPool.get(); - initInfo.RenderPass = mRenderPass.get(); - initInfo.MSAASamples = static_cast(mMsaaSamples); - initInfo.Allocator = nullptr; - initInfo.MinImageCount = MAX_FRAMES_IN_FLIGHT; - initInfo.ImageCount = static_cast(mSwapChainImages.size()); - initInfo.CheckVkResultFn = nullptr; + vk::DescriptorPoolSize descriptorPoolSize = { + .type = vk::DescriptorType::eCombinedImageSampler, + .descriptorCount = 1, + }; + + vk::DescriptorPoolCreateInfo poolInfo { + .flags = vk::DescriptorPoolCreateFlagBits::eFreeDescriptorSet, + .maxSets = 1, + .poolSizeCount = 1, + .pPoolSizes = &descriptorPoolSize, + }; + + mImGuiDescriptorPool = mDevice->createDescriptorPoolUnique(poolInfo); + + ImGui_ImplVulkan_InitInfo initInfo = { + .Instance = mInstance.get(), + .PhysicalDevice = mPhysicalDevice, + .Device = mDevice.get(), + .QueueFamily = findQueueFamilies(mPhysicalDevice).graphics_family.value(), + .Queue = mGraphicsQueue, + .DescriptorPool = mImGuiDescriptorPool.get(), + .RenderPass = mRenderPass.get(), + .MinImageCount = 1, + .ImageCount = static_cast(mSwapChainImages.size()), + .MSAASamples = static_cast(mMsaaSamples), + .PipelineCache = VK_NULL_HANDLE, + .Subpass = 0, + .UseDynamicRendering = false, + .PipelineRenderingCreateInfo = {}, + .Allocator = nullptr, + .CheckVkResultFn = nullptr, + .MinAllocationSize = 0, + }; ImGui_ImplVulkan_Init(&initInfo); - - // Upload Fonts - ImGui_ImplVulkan_CreateFontsTexture(); } // Main loop