diff --git a/meson.build b/meson.build index 9383111..b11ce11 100644 --- a/meson.build +++ b/meson.build @@ -118,7 +118,7 @@ dependencies += [ vma, vkbootstrap, glm, - imgui, + # imgui, sdl2, fastgltf, simdjson, diff --git a/vk_engine.cpp b/vk_engine.cpp index c60fef7..8924d40 100644 --- a/vk_engine.cpp +++ b/vk_engine.cpp @@ -35,7 +35,6 @@ void VulkanEngine::init() init_sync_structures(); init_descriptors(); init_pipelines(); - _gui.init_imgui(VulkanEngine::Get()); init_default_data(); //everything went fine @@ -169,9 +168,6 @@ void VulkanEngine::draw() // ZED: ? vkutil::transition_image(t.cmd, _swapchainImages[t.swapchainImageIndex], VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); - // ZED: end drawing the things - _gui.draw_imgui(_swapchainExtent, t.cmd, _swapchainImageViews[t.swapchainImageIndex]); - // ZED: finalize image and commit command buffer vkutil::transition_image(t.cmd, _swapchainImages[t.swapchainImageIndex], VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR); @@ -260,7 +256,6 @@ void VulkanEngine::run() continue; } - _gui.render_imgui(backgroundEffects, ¤tBackgroundEffect); draw(); } } diff --git a/vk_gui.cpp b/vk_gui.cpp index 86e4bd3..08cd0bb 100644 --- a/vk_gui.cpp +++ b/vk_gui.cpp @@ -2,9 +2,6 @@ #include "vk_initializers.h" #include #include -#include -#include -#include #include "vk_engine.h" struct SDL_Window* VkGUI::init_window(VkExtent2D windowExtent) @@ -22,104 +19,6 @@ struct SDL_Window* VkGUI::init_window(VkExtent2D windowExtent) window_flags); } -void VkGUI::init_imgui(VulkanEngine& engine) -{ - // 1. create descriptor pool for IMGUI - // the size of the pool is very oversize, but it's copied from imgui demo - // itself. - VkDescriptorPoolSize pool_sizes[] = { - { VK_DESCRIPTOR_TYPE_SAMPLER, 1000 }, - { VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1000 }, - { VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, 1000 }, - { VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 1000 }, - { VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, 1000 }, - { VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, 1000 }, - { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1000 }, - { VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1000 }, - { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 1000 }, - { VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, 1000 }, - { VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1000 } - }; - - VkDescriptorPoolCreateInfo pool_info{ - .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO, - .flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, - .maxSets = 1000, - .poolSizeCount = (uint32_t)std::size(pool_sizes), - .pPoolSizes = pool_sizes, - }; - - VkDescriptorPool imguiPool; - VK_CHECK(vkCreateDescriptorPool(engine._device, &pool_info, nullptr, &imguiPool)); - - // 2: initialize the imgui library - ImGui::CreateContext(); - - ImGui_ImplSDL2_InitForVulkan(engine._window); - - ImGui_ImplVulkan_InitInfo init_info{ - .Instance = engine._instance, - .PhysicalDevice = engine._chosenGPU, - .Device = engine._device, - .Queue = engine._graphicsQueue, - .DescriptorPool = imguiPool, - .MinImageCount = 3, - .ImageCount = 3, - .MSAASamples = VK_SAMPLE_COUNT_1_BIT, - .UseDynamicRendering = true, - .PipelineRenderingCreateInfo = { - .sType = VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO, - .colorAttachmentCount = 1, - .pColorAttachmentFormats = &engine._swapchainImageFormat, - }, - }; - - ImGui_ImplVulkan_Init(&init_info); - ImGui_ImplVulkan_CreateFontsTexture(); - - engine._mainDeletionQueue.push_function([=,this]() { - ImGui_ImplVulkan_Shutdown(); - vkDestroyDescriptorPool(engine._device, imguiPool, nullptr); - }); -} - -void VkGUI::draw_imgui(VkExtent2D& swapchainExtent, VkCommandBuffer cmd, VkImageView targetImageView) -{ - VkRenderingAttachmentInfo colorAttachment = vkinit::attachment_info(targetImageView, nullptr, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); - - VkRenderingInfo renderInfo = vkinit::rendering_info(swapchainExtent, &colorAttachment, nullptr); - - vkCmdBeginRendering(cmd, &renderInfo); - - ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), cmd); - - vkCmdEndRendering(cmd); -} - -void VkGUI::render_imgui(std::vector& backgroundEffects, int* currentBackgroundEffect) -{ - ImGui_ImplVulkan_NewFrame(); - ImGui_ImplSDL2_NewFrame(); - - ImGui::NewFrame(); - - if (ImGui::Begin("background")) { - - ComputeEffect& selected = backgroundEffects[*currentBackgroundEffect]; - - ImGui::Text("Selected effect: %s", selected.name); - - ImGui::SliderInt("Effect Index", currentBackgroundEffect,0, backgroundEffects.size() - 1); - - ImGui::InputFloat4("data1",(float*)& selected.data.data1); - ImGui::InputFloat4("data2",(float*)& selected.data.data2); - ImGui::InputFloat4("data3",(float*)& selected.data.data3); - ImGui::InputFloat4("data4",(float*)& selected.data.data4); - } - ImGui::End(); - - ImGui::Render(); -} void VkGUI::destroy(struct SDL_Window* _window) { @@ -145,7 +44,5 @@ void VkGUI::poll_event() { stop_rendering = false; } } - - ImGui_ImplSDL2_ProcessEvent(&event); } } diff --git a/vk_gui.h b/vk_gui.h index 8890504..aa25f6c 100644 --- a/vk_gui.h +++ b/vk_gui.h @@ -9,9 +9,6 @@ class VkGUI { bool stop_rendering = false; struct SDL_Window* init_window(VkExtent2D windowExtent); - void init_imgui(VulkanEngine& engine); - void draw_imgui(VkExtent2D& swapchainExtent, VkCommandBuffer cmd, VkImageView targetImageView); - void render_imgui(std::vector& backgroundEffects, int* currentBackgroundEffect); void destroy(struct SDL_Window* _window); void poll_event();