diff --git a/CMakeLists.txt b/CMakeLists.txt index 1582b949..5a541cb6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -251,8 +251,8 @@ FetchContent_Declare(libktx EXCLUDE_FROM_ALL SYSTEM URL https://github.co FetchContent_Declare(implot EXCLUDE_FROM_ALL SYSTEM URL https://github.com/epezent/implot/archive/3da8bd34299965d3b0ab124df743fe3e076fa222.zip URL_HASH SHA256=e9b439a94aa6f09fcf12ed9c2cd784efe5e99e96242122aa683e690b29f7a59f) file(GLOB IMGUI_PATCHES CONFIGURE_DEPENDS patches/imgui/*) -FetchContent_Declare(imgui EXCLUDE_FROM_ALL SYSTEM URL https://github.com/ocornut/imgui/archive/refs/tags/v1.92.7.tar.gz - URL_HASH SHA256=b21b14ce1ef6dd4d85fa54f68f8449a9be94f3b453aba7fe4ea2a9764e43a5ef +FetchContent_Declare(imgui EXCLUDE_FROM_ALL SYSTEM URL https://github.com/ocornut/imgui/archive/refs/tags/v1.92.8.tar.gz + URL_HASH SHA256=fecb33d33930e12ff53a34064e9d3a06c8f7c3e04408f14cd36c80e3faac863b PATCH_COMMAND ${CMAKE_CURRENT_LIST_DIR}/patches/apply.sh ${IMGUI_PATCHES} ) FetchContent_Declare(uni-algo EXCLUDE_FROM_ALL SYSTEM URL https://github.com/uni-algo/uni-algo/archive/v1.2.0.tar.gz diff --git a/client/render/imgui_impl.cpp b/client/render/imgui_impl.cpp index ccca6c21..3de08a1b 100644 --- a/client/render/imgui_impl.cpp +++ b/client/render/imgui_impl.cpp @@ -183,7 +183,7 @@ static float distance_to_window(ImGuiWindow * window, ImVec2 position) static const std::array layout_bindings = { vk::DescriptorSetLayoutBinding{ .binding = 0, - .descriptorType = vk::DescriptorType::eCombinedImageSampler, + .descriptorType = vk::DescriptorType::eSampledImage, .descriptorCount = 1, .stageFlags = vk::ShaderStageFlagBits::eFragment, }}; @@ -1170,12 +1170,12 @@ imgui_context::~imgui_context() ImGui::DestroyContext(context); } -ImTextureID imgui_textures::load_texture(const std::string & filename, vk::raii::Sampler && sampler) +ImTextureID imgui_textures::load_texture(const std::string & filename) { - return load_texture(utils::mapped_file{filename}, std::move(sampler), filename); + return load_texture(utils::mapped_file{filename}, filename); } -ImTextureID imgui_textures::load_texture(const std::span & bytes, vk::raii::Sampler && sampler, const std::string & name) +ImTextureID imgui_textures::load_texture(const std::span & bytes, const std::string & name) { bool srgb = true; @@ -1188,7 +1188,6 @@ ImTextureID imgui_textures::load_texture(const std::span & byte std::shared_ptr ds = descriptor_pool.allocate(); vk::DescriptorImageInfo image_info{ - .sampler = *sampler, .imageView = *image->image_view, .imageLayout = vk::ImageLayout::eShaderReadOnlyOptimal, }; @@ -1196,7 +1195,7 @@ ImTextureID imgui_textures::load_texture(const std::span & byte vk::WriteDescriptorSet ds_write{ .dstSet = **ds, .descriptorCount = 1, - .descriptorType = vk::DescriptorType::eCombinedImageSampler, + .descriptorType = vk::DescriptorType::eSampledImage, .pImageInfo = &image_info}; device.updateDescriptorSets(ds_write, nullptr); @@ -1206,7 +1205,6 @@ ImTextureID imgui_textures::load_texture(const std::span & byte textures.emplace( id, texture_data{ - .sampler = std::move(sampler), .image = image, .descriptor_set = std::move(ds), }); @@ -1214,43 +1212,6 @@ ImTextureID imgui_textures::load_texture(const std::span & byte return id; } -ImTextureID imgui_textures::load_texture(const std::span & bytes, const std::string & name) -{ - return load_texture( - bytes, - vk::raii::Sampler{ - device, - vk::SamplerCreateInfo{ - .magFilter = vk::Filter::eLinear, - .minFilter = vk::Filter::eLinear, - .mipmapMode = vk::SamplerMipmapMode::eLinear, - .addressModeU = vk::SamplerAddressMode::eClampToEdge, - .addressModeV = vk::SamplerAddressMode::eClampToEdge, - .addressModeW = vk::SamplerAddressMode::eClampToEdge, - .borderColor = vk::BorderColor::eFloatTransparentBlack, - }, - }, - name); -} - -ImTextureID imgui_textures::load_texture(const std::string & filename) -{ - return load_texture( - filename, - vk::raii::Sampler{ - device, - vk::SamplerCreateInfo{ - .magFilter = vk::Filter::eLinear, - .minFilter = vk::Filter::eLinear, - .mipmapMode = vk::SamplerMipmapMode::eLinear, - .addressModeU = vk::SamplerAddressMode::eClampToEdge, - .addressModeV = vk::SamplerAddressMode::eClampToEdge, - .addressModeW = vk::SamplerAddressMode::eClampToEdge, - .borderColor = vk::BorderColor::eFloatTransparentBlack, - }, - }); -} - void imgui_textures::free_texture(ImTextureID texture) { textures.erase(texture); diff --git a/client/render/imgui_impl.h b/client/render/imgui_impl.h index 03f0a6b1..d91c95e3 100644 --- a/client/render/imgui_impl.h +++ b/client/render/imgui_impl.h @@ -43,7 +43,6 @@ class imgui_textures { struct texture_data { - vk::raii::Sampler sampler; std::shared_ptr image; std::shared_ptr descriptor_set; }; @@ -70,9 +69,7 @@ public: thread_safe & queue, std::shared_ptr image_cache = {}); ~imgui_textures(); - ImTextureID load_texture(const std::string & filename, vk::raii::Sampler && sampler); ImTextureID load_texture(const std::string & filename); - ImTextureID load_texture(const std::span & bytes, vk::raii::Sampler && sampler, const std::string & name = ""); ImTextureID load_texture(const std::span & bytes, const std::string & name = ""); void free_texture(ImTextureID); }; diff --git a/patches/imgui/0001-Change-ImGui-ButtonBehavior-default-flags-when-using.patch b/patches/imgui/0001-Change-ImGui-ButtonBehavior-default-flags-when-using.patch index ca3eab7e..0cfe31ec 100644 --- a/patches/imgui/0001-Change-ImGui-ButtonBehavior-default-flags-when-using.patch +++ b/patches/imgui/0001-Change-ImGui-ButtonBehavior-default-flags-when-using.patch @@ -1,4 +1,4 @@ -From 226a83f9700f711f61217cce5c348a6a2b9a9908 Mon Sep 17 00:00:00 2001 +From 27bc503672721dad26deae568c7938b3998fb16a Mon Sep 17 00:00:00 2001 From: Guillaume Meunier Date: Wed, 16 Oct 2024 20:51:52 +0200 Subject: [PATCH 1/2] Change ImGui::ButtonBehavior default flags when using @@ -12,10 +12,10 @@ Subject: [PATCH 1/2] Change ImGui::ButtonBehavior default flags when using 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/imgui.cpp b/imgui.cpp -index 80720224a..7ab41be89 100644 +index 2edb22be2..e7eb77038 100644 --- a/imgui.cpp +++ b/imgui.cpp -@@ -10400,7 +10400,7 @@ static const char* GetInputSourceName(ImGuiInputSource source) +@@ -10470,7 +10470,7 @@ static const char* GetInputSourceName(ImGuiInputSource source) } static const char* GetMouseSourceName(ImGuiMouseSource source) { @@ -25,10 +25,10 @@ index 80720224a..7ab41be89 100644 if (source < 0 || source >= ImGuiMouseSource_COUNT) return "Unknown"; diff --git a/imgui.h b/imgui.h -index 11e0ff8e7..cae851232 100644 +index 9fdce397d..66a58e1f0 100644 --- a/imgui.h +++ b/imgui.h -@@ -1984,6 +1984,8 @@ enum ImGuiMouseSource : int +@@ -1987,6 +1987,8 @@ enum ImGuiMouseSource : int ImGuiMouseSource_Mouse = 0, // Input is coming from an actual mouse. ImGuiMouseSource_TouchScreen, // Input is coming from a touch screen (no hovering prior to initial press, less precise initial press aiming, dual-axis wheeling possible). ImGuiMouseSource_Pen, // Input is coming from a pressure/magnetic pen (often used in conjunction with high-sampling rates). @@ -38,10 +38,10 @@ index 11e0ff8e7..cae851232 100644 }; diff --git a/imgui_demo.cpp b/imgui_demo.cpp -index cd95de76b..b6989294b 100644 +index 7d882f803..35fdd31c9 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp -@@ -7849,6 +7849,11 @@ static void DemoWindowInputs() +@@ -7925,6 +7925,11 @@ static void DemoWindowInputs() ImGui::Text("Mouse clicked count:"); for (int i = 0; i < IM_COUNTOF(io.MouseDown); i++) if (io.MouseClickedCount[i] > 0) { ImGui::SameLine(); ImGui::Text("b%d: %d", i, io.MouseClickedCount[i]); } @@ -54,10 +54,10 @@ index cd95de76b..b6989294b 100644 // displaying the data for old/new backends. // User code should never have to go through such hoops! diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp -index 23f139c5c..0eb1947a3 100644 +index ea792f9e8..3caee9aad 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp -@@ -557,7 +557,12 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool +@@ -559,7 +559,12 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool // Default behavior requires click + release inside bounding box if ((flags & ImGuiButtonFlags_PressedOnMask_) == 0) diff --git a/patches/imgui/0002-Add-ImGuiWindowFlags_NoFocusOnClick-flag.patch b/patches/imgui/0002-Add-ImGuiWindowFlags_NoFocusOnClick-flag.patch index abc560fd..32dc754c 100644 --- a/patches/imgui/0002-Add-ImGuiWindowFlags_NoFocusOnClick-flag.patch +++ b/patches/imgui/0002-Add-ImGuiWindowFlags_NoFocusOnClick-flag.patch @@ -1,4 +1,4 @@ -From e5614d9ebd5a68c9ff1e76be9348c073d0a3aa2b Mon Sep 17 00:00:00 2001 +From 8de8beaafd19092491959493ac00c87418c61349 Mon Sep 17 00:00:00 2001 From: Guillaume Meunier Date: Tue, 22 Oct 2024 15:09:14 +0200 Subject: [PATCH 2/2] Add ImGuiWindowFlags_NoFocusOnClick flag @@ -9,10 +9,10 @@ Subject: [PATCH 2/2] Add ImGuiWindowFlags_NoFocusOnClick flag 2 files changed, 4 insertions(+) diff --git a/imgui.cpp b/imgui.cpp -index 7ab41be89..def02c2a8 100644 +index e7eb77038..95f4cbeac 100644 --- a/imgui.cpp +++ b/imgui.cpp -@@ -5326,6 +5326,9 @@ void ImGui::UpdateMouseMovingWindowEndFrame() +@@ -5362,6 +5362,9 @@ void ImGui::UpdateMouseMovingWindowEndFrame() // Handle the edge case of a popup being closed while clicking in its empty space. // If we try to focus it, FocusWindow() > ClosePopupsOverWindow() will accidentally close any parent popups because they are not linked together any more. ImGuiWindow* hovered_root = hovered_window ? hovered_window->RootWindow : NULL; @@ -23,10 +23,10 @@ index 7ab41be89..def02c2a8 100644 if (hovered_window != NULL && !is_closed_popup) diff --git a/imgui.h b/imgui.h -index cae851232..fe887a1b2 100644 +index 66a58e1f0..3d41c6b15 100644 --- a/imgui.h +++ b/imgui.h -@@ -1185,6 +1185,7 @@ enum ImGuiWindowFlags_ +@@ -1186,6 +1186,7 @@ enum ImGuiWindowFlags_ ImGuiWindowFlags_NoNavInputs = 1 << 16, // No keyboard/gamepad navigation within the window ImGuiWindowFlags_NoNavFocus = 1 << 17, // No focusing toward this window with keyboard/gamepad navigation (e.g. skipped by Ctrl+Tab) ImGuiWindowFlags_UnsavedDocument = 1 << 18, // Display a dot next to the title. When used in a tab/docking context, tab is selected when clicking the X + closure is not assumed (will wait for user to stop submitting the tab). Otherwise closure is assumed when pressing the X, so if you keep submitting the tab may reappear at end of tab bar.