keid-ui-dearimgui 0.1.1.0 → 0.1.1.1
raw patch · 3 files changed
+22/−6 lines, 3 filesdep ~keid-corePVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
Dependency ranges changed: keid-core
API changes (from Hackage documentation)
+ Render.ImGui: allocateLoop :: Bool -> ResourceT (StageRIO st) ()
Files
- ChangeLog.md +5/−0
- keid-ui-dearimgui.cabal +2/−2
- src/Render/ImGui.hs +15/−4
ChangeLog.md view
@@ -1,5 +1,10 @@ # Changelog for keid-dearimgui +## 0.1.1.1++- Added `Vk.deviceWaitIdle` injection in `afterLoop`.+ * Should fix release/allocate race between two imgui-using stages back-to-back.+ ## 0.1.1.0 - Added `allocateWithFonts` from dear-imgui-1.3.0.
keid-ui-dearimgui.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: keid-ui-dearimgui-version: 0.1.1.0+version: 0.1.1.1 synopsis: DearImGui elements for Keid engine. category: Game Engine author: IC Rainbow@@ -94,7 +94,7 @@ , binary , bytestring , dear-imgui >=1.3.0- , keid-core+ , keid-core >=0.1.6.1 , resourcet , rio >=0.1.12.0 , rio-app
src/Render/ImGui.hs view
@@ -4,6 +4,7 @@ , allocateWithFonts , allocateWith + , allocateLoop , beforeLoop , afterLoop @@ -17,12 +18,13 @@ import RIO import Control.Monad.Trans.Resource (ReleaseKey, ResourceT, register, release)-import DearImGui.Vulkan (InitInfo(..))-import DearImGui.Vulkan qualified as ImGui import DearImGui qualified as ImGui import DearImGui.FontAtlas qualified as FontAtlas import DearImGui.GLFW (glfwNewFrame, glfwShutdown) import DearImGui.GLFW.Vulkan (glfwInitForVulkan)+import DearImGui.Vulkan (InitInfo(..))+import DearImGui.Vulkan qualified as ImGui+import Engine.Vulkan.Types (getDevice) import RIO.App (appEnv) import Vulkan.Core10 qualified as Vk import Vulkan.Exception (VulkanException(..))@@ -144,6 +146,12 @@ , Vk.DESCRIPTOR_TYPE_INPUT_ATTACHMENT ] +allocateLoop :: Bool -> ResourceT (StageRIO st) ()+allocateLoop installCallbacks = do+ lift $ beforeLoop installCallbacks+ shutdownImGui <- lift $ toIO afterLoop+ void $! register shutdownImGui+ {- | Initialize context to serve the draws in the current render loop. You will need to trigger callbacks from DearImGui.GLFW if you're opting out of them here.@@ -152,7 +160,7 @@ -} beforeLoop :: Bool -> StageRIO st () beforeLoop installCallbacks = do- logDebug "Setting up ImGui"+ logDebug "glfwInitForVulkan" window <- asks $ ghWindow . appEnv success <- glfwInitForVulkan window installCallbacks unless success do@@ -160,8 +168,11 @@ afterLoop :: StageRIO st () afterLoop = do- logDebug "Shutting down ImGui"+ logDebug "glfwShutdown"+ asks getDevice >>= Vk.deviceWaitIdle+ logDebug "glfwShutdown: Device idle" glfwShutdown+ logDebug "glfwShutdown finished" mkDrawData :: MonadIO m => m a -> m (a, ImGui.DrawData) mkDrawData action = do