-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e4c929e
commit ad25bde
Showing
4 changed files
with
85 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include "imgui.hpp" | ||
|
||
#include <imgui_impl_vulkan.h> | ||
|
||
#include "common/debug/error.hpp" | ||
#include "graphics/vulkan/context.hpp" | ||
#include "graphics/vulkan/physical_device.hpp" | ||
#include "graphics/vulkan/util/constants.hpp" | ||
#include "graphics/vulkan/util/vk_call.hpp" | ||
#include "init/dear_imgui_vulkan.hpp" | ||
|
||
namespace gravel::vk { | ||
|
||
void init_imgui(ImGuiData& data, VkRenderPass render_pass, const uint32 swapchain_images) | ||
{ | ||
const auto graphics_queue_family_index = | ||
get_queue_family_indices(get_gpu(), get_surface()).graphics_family.value(); | ||
|
||
ImGui_ImplVulkan_InitInfo info {}; | ||
info.Instance = get_instance(); | ||
info.PhysicalDevice = get_gpu(); | ||
info.Device = get_device(); | ||
info.QueueFamily = graphics_queue_family_index; | ||
info.Queue = get_graphics_queue(); | ||
info.PipelineCache = data.pipeline_cache.get(); | ||
info.DescriptorPool = data.descriptor_pool.get(); | ||
info.Subpass = 0; | ||
info.MinImageCount = kMaxFramesInFlight; | ||
info.ImageCount = swapchain_images; | ||
info.MSAASamples = VK_SAMPLE_COUNT_1_BIT; | ||
info.Allocator = nullptr; | ||
info.CheckVkResultFn = [](const VkResult result) { | ||
GRAVEL_VK_CALL(result, "[VK] ImGui Vulkan backend error"); | ||
}; | ||
|
||
if (!ImGui_ImplVulkan_Init(&info, render_pass)) { | ||
throw Error {"[VK] Could not initialize ImGui Vulkan backend"}; | ||
} | ||
|
||
DearImGuiVulkan::recreate_font_textures(); | ||
} | ||
|
||
} // namespace gravel::vk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#pragma once | ||
|
||
#include <array> // size | ||
|
||
#include <vulkan/vulkan.h> | ||
|
||
#include "common/primitives.hpp" | ||
#include "graphics/vulkan/pipeline/descriptor_pool.hpp" | ||
#include "graphics/vulkan/pipeline/pipeline_cache.hpp" | ||
|
||
namespace gravel::vk { | ||
|
||
inline constexpr VkDescriptorPoolSize kImGuiDescriptorPoolSizes[] = { | ||
{VK_DESCRIPTOR_TYPE_SAMPLER, 8}, | ||
{VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 32}, | ||
{VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, 8}, | ||
{VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 8}, | ||
{VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, 8}, | ||
{VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, 8}, | ||
{VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 32}, | ||
{VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 8}, | ||
{VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 8}, | ||
{VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, 8}, | ||
{VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 8}, | ||
}; | ||
|
||
struct ImGuiData final { | ||
PipelineCache pipeline_cache {create_pipeline_cache()}; | ||
DescriptorPool descriptor_pool {1'000, | ||
kImGuiDescriptorPoolSizes, | ||
std::size(kImGuiDescriptorPoolSizes), | ||
VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT}; | ||
}; | ||
|
||
/// Initializes the ImGui Vulkan backend. | ||
void init_imgui(ImGuiData& data, VkRenderPass render_pass, uint32 swapchain_images); | ||
|
||
} // namespace gravel::vk |