@@ -31,6 +31,8 @@ import Data.Word
31
31
( Word32 )
32
32
import Foreign.Marshal.Alloc
33
33
( alloca )
34
+ import Foreign.Marshal.Utils
35
+ ( fromBool )
34
36
import Foreign.Ptr
35
37
( FunPtr , Ptr , freeHaskellFunPtr , nullPtr )
36
38
import Foreign.Storable
@@ -70,19 +72,21 @@ Cpp.using "namespace ImGui"
70
72
71
73
data InitInfo =
72
74
InitInfo
73
- { instance' :: ! Vulkan. Instance
74
- , physicalDevice :: ! Vulkan. PhysicalDevice
75
- , device :: ! Vulkan. Device
76
- , queueFamily :: ! Word32
77
- , queue :: ! Vulkan. Queue
78
- , pipelineCache :: ! Vulkan. PipelineCache
79
- , descriptorPool :: ! Vulkan. DescriptorPool
80
- , subpass :: ! Word32
81
- , minImageCount :: ! Word32
82
- , imageCount :: ! Word32
83
- , msaaSamples :: ! Vulkan. SampleCountFlagBits
84
- , mbAllocator :: Maybe Vulkan. AllocationCallbacks
85
- , checkResult :: Vulkan. Result -> IO ()
75
+ { instance' :: ! Vulkan. Instance
76
+ , physicalDevice :: ! Vulkan. PhysicalDevice
77
+ , device :: ! Vulkan. Device
78
+ , queueFamily :: ! Word32
79
+ , queue :: ! Vulkan. Queue
80
+ , pipelineCache :: ! Vulkan. PipelineCache
81
+ , descriptorPool :: ! Vulkan. DescriptorPool
82
+ , subpass :: ! Word32
83
+ , minImageCount :: ! Word32
84
+ , imageCount :: ! Word32
85
+ , msaaSamples :: ! Vulkan. SampleCountFlagBits
86
+ , colorAttachmentFormat :: ! (Maybe Vulkan. Format )
87
+ , useDynamicRendering :: ! Bool
88
+ , mbAllocator :: Maybe Vulkan. AllocationCallbacks
89
+ , checkResult :: Vulkan. Result -> IO ()
86
90
}
87
91
88
92
-- | Wraps @ImGui_ImplVulkan_Init@ and @ImGui_ImplVulkan_Shutdown@.
@@ -112,6 +116,10 @@ vulkanInit ( InitInfo {..} ) renderPass = do
112
116
withCallbacks f = case mbAllocator of
113
117
Nothing -> f nullPtr
114
118
Just callbacks -> alloca ( \ ptr -> poke ptr callbacks *> f ptr )
119
+ useDynamicRendering' :: Cpp. CBool
120
+ useDynamicRendering' = fromBool useDynamicRendering
121
+ colorAttachmentFormat' :: Vulkan. Format
122
+ colorAttachmentFormat' = fromMaybe Vulkan. FORMAT_UNDEFINED colorAttachmentFormat
115
123
liftIO do
116
124
checkResultFunPtr <- $ ( C. mkFunPtr [t | Vulkan.Result -> IO () |] ) checkResult
117
125
initResult <- withCallbacks \ callbacksPtr ->
@@ -134,8 +142,8 @@ vulkanInit ( InitInfo {..} ) renderPass = do
134
142
initInfo.MSAASamples = $(VkSampleCountFlagBits msaaSamples);
135
143
initInfo.Allocator = $(VkAllocationCallbacks* callbacksPtr);
136
144
initInfo.CheckVkResultFn = $( void (*checkResultFunPtr)(VkResult) );
137
- initInfo.UseDynamicRendering = false ;
138
- // TODO: initInfo.ColorAttachmentFormat
145
+ initInfo.UseDynamicRendering = $(bool useDynamicRendering') ;
146
+ initInfo.ColorAttachmentFormat = $(VkFormat colorAttachmentFormat');
139
147
return ImGui_ImplVulkan_Init(&initInfo, $(VkRenderPass renderPass) );
140
148
}|]
141
149
pure ( checkResultFunPtr, initResult /= 0 )
0 commit comments