Remove these useless variables
This commit is contained in:
@@ -7,33 +7,30 @@
|
||||
#include <memory>
|
||||
|
||||
namespace gui {
|
||||
static VkAllocationCallbacks* g_Allocator = NULL;
|
||||
static VkInstance g_Instance = VK_NULL_HANDLE;
|
||||
static VkPhysicalDevice g_PhysicalDevice = VK_NULL_HANDLE;
|
||||
static VkDevice g_Device = VK_NULL_HANDLE;
|
||||
static uint32_t g_QueueFamily = (uint32_t)-1;
|
||||
static VkQueue g_Queue = VK_NULL_HANDLE;
|
||||
static VkPipelineCache g_PipelineCache = VK_NULL_HANDLE;
|
||||
static VkDescriptorPool g_DescriptorPool = VK_NULL_HANDLE;
|
||||
static VkAllocationCallbacks* g_Allocator = NULL;
|
||||
static VkInstance g_Instance = VK_NULL_HANDLE;
|
||||
static VkPhysicalDevice g_PhysicalDevice = VK_NULL_HANDLE;
|
||||
static VkDevice g_Device = VK_NULL_HANDLE;
|
||||
static uint32_t g_QueueFamily = (uint32_t)-1;
|
||||
static VkQueue g_Queue = VK_NULL_HANDLE;
|
||||
static VkPipelineCache g_PipelineCache = VK_NULL_HANDLE;
|
||||
static VkDescriptorPool g_DescriptorPool = VK_NULL_HANDLE;
|
||||
|
||||
static ImGui_ImplVulkanH_Window g_MainWindowData;
|
||||
static uint32_t g_MinImageCount = 2;
|
||||
static ImGui_ImplVulkanH_Window g_MainWindowData;
|
||||
static uint32_t g_MinImageCount = 2;
|
||||
|
||||
inline std::shared_ptr<Vulkan::WSI> g_Wsi;
|
||||
|
||||
static void CheckVkResult(VkResult err) {
|
||||
if (err == VK_SUCCESS)
|
||||
return;
|
||||
|
||||
if (err < VK_SUCCESS)
|
||||
panic("[vulkan] VkResult = {}", (int) err);
|
||||
|
||||
warn("[vulkan] VkResult = {}", (int) err);
|
||||
}
|
||||
static void CheckVkResult(VkResult err) {
|
||||
if (err == VK_SUCCESS)
|
||||
return;
|
||||
|
||||
if (err < VK_SUCCESS)
|
||||
panic("[vulkan] VkResult = {}", (int) err);
|
||||
|
||||
warn("[vulkan] VkResult = {}", (int) err);
|
||||
}
|
||||
|
||||
inline void Initialize(const std::shared_ptr<Vulkan::WSI>& wsi, SDL_Window* nativeWindow) {
|
||||
VkResult err;
|
||||
g_Wsi = wsi;
|
||||
// Setup Dear ImGui context
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
@@ -46,16 +43,16 @@ namespace gui {
|
||||
ImGui::StyleColorsDark();
|
||||
//ImGui::StyleColorsClassic();
|
||||
|
||||
g_Instance = wsi->get_context().get_instance();
|
||||
g_PhysicalDevice = wsi->get_device().get_physical_device();
|
||||
g_Device = wsi->get_device().get_device();
|
||||
g_QueueFamily = wsi->get_context().get_queue_info().family_indices[Vulkan::QUEUE_INDEX_GRAPHICS];
|
||||
g_Queue = wsi->get_context().get_queue_info().queues[Vulkan::QUEUE_INDEX_GRAPHICS];
|
||||
g_PipelineCache = nullptr;
|
||||
g_DescriptorPool = nullptr;
|
||||
g_Allocator = nullptr;
|
||||
g_MinImageCount = 2;
|
||||
|
||||
g_Instance = wsi->get_context().get_instance();
|
||||
g_PhysicalDevice = wsi->get_device().get_physical_device();
|
||||
g_Device = wsi->get_device().get_device();
|
||||
g_QueueFamily = wsi->get_context().get_queue_info().family_indices[Vulkan::QUEUE_INDEX_GRAPHICS];
|
||||
g_Queue = wsi->get_context().get_queue_info().queues[Vulkan::QUEUE_INDEX_GRAPHICS];
|
||||
g_PipelineCache = nullptr;
|
||||
g_DescriptorPool = nullptr;
|
||||
g_Allocator = nullptr;
|
||||
g_MinImageCount = 2;
|
||||
|
||||
|
||||
// Create Descriptor Pool
|
||||
{
|
||||
@@ -119,41 +116,41 @@ namespace gui {
|
||||
info.pDependencies = &dependency;
|
||||
err = vkCreateRenderPass(g_Device, &info, g_Allocator, &renderPass);
|
||||
CheckVkResult(err);
|
||||
}
|
||||
// Setup Platform/Renderer backends
|
||||
ImGui_ImplSDL3_InitForVulkan(nativeWindow);
|
||||
ImGui_ImplVulkan_InitInfo init_info = {};
|
||||
init_info.Instance = g_Instance;
|
||||
init_info.PhysicalDevice = g_PhysicalDevice;
|
||||
init_info.Device = g_Device;
|
||||
init_info.QueueFamily = g_QueueFamily;
|
||||
init_info.Queue = g_Queue;
|
||||
init_info.PipelineCache = g_PipelineCache;
|
||||
init_info.DescriptorPool = g_DescriptorPool;
|
||||
init_info.Allocator = g_Allocator;
|
||||
}
|
||||
// Setup Platform/Renderer backends
|
||||
ImGui_ImplSDL3_InitForVulkan(nativeWindow);
|
||||
ImGui_ImplVulkan_InitInfo init_info = {};
|
||||
init_info.Instance = g_Instance;
|
||||
init_info.PhysicalDevice = g_PhysicalDevice;
|
||||
init_info.Device = g_Device;
|
||||
init_info.QueueFamily = g_QueueFamily;
|
||||
init_info.Queue = g_Queue;
|
||||
init_info.PipelineCache = g_PipelineCache;
|
||||
init_info.DescriptorPool = g_DescriptorPool;
|
||||
init_info.Allocator = g_Allocator;
|
||||
init_info.MinImageCount = g_MinImageCount;
|
||||
init_info.ImageCount = 2;
|
||||
init_info.CheckVkResultFn = CheckVkResult;
|
||||
init_info.CheckVkResultFn = CheckVkResult;
|
||||
init_info.RenderPass = renderPass;
|
||||
init_info.ApiVersion = VK_API_VERSION_1_3;
|
||||
|
||||
ImGui_ImplVulkan_LoadFunctions(VK_API_VERSION_1_3, [](const char *function_name, void *vulkan_instance) {
|
||||
return vkGetInstanceProcAddr((reinterpret_cast<VkInstance>(vulkan_instance)), function_name);
|
||||
}, g_Instance);
|
||||
|
||||
if(!ImGui_ImplVulkan_Init(&init_info))
|
||||
panic("Failed to initialize ImGui!");
|
||||
}
|
||||
|
||||
inline void StartFrame() {
|
||||
ImGui_ImplVulkan_NewFrame();
|
||||
ImGui_ImplSDL3_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
}
|
||||
if(!ImGui_ImplVulkan_Init(&init_info))
|
||||
panic("Failed to initialize ImGui!");
|
||||
}
|
||||
|
||||
inline void Cleanup() {
|
||||
ImGui_ImplVulkan_Shutdown();
|
||||
ImGui_ImplSDL3_Shutdown();
|
||||
ImGui::DestroyContext();
|
||||
}
|
||||
inline void StartFrame() {
|
||||
ImGui_ImplVulkan_NewFrame();
|
||||
ImGui_ImplSDL3_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
}
|
||||
|
||||
inline void Cleanup() {
|
||||
ImGui_ImplVulkan_Shutdown();
|
||||
ImGui_ImplSDL3_Shutdown();
|
||||
ImGui::DestroyContext();
|
||||
}
|
||||
}
|
||||
@@ -19,10 +19,9 @@ struct NativeWindow {
|
||||
~NativeWindow() {
|
||||
SDL_DestroyWindow(window);
|
||||
}
|
||||
void setTitle(const std::string& v) { title = v; }
|
||||
|
||||
SDL_Window* getHandle() { return window; }
|
||||
private:
|
||||
SDL_Window* window;
|
||||
std::string title;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user