Skip to content

Commit aded438

Browse files
authored
Bump upstream to v1.90.9 (#207)
* Bump upstream to v1.90.9 and fix parser * Fix font and dynamic rendering breakage in vulkan backend
1 parent 31557b0 commit aded438

File tree

9 files changed

+155
-85
lines changed

9 files changed

+155
-85
lines changed

ChangeLog.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog for dear-imgui
22

3+
## [2.3.0]
4+
5+
- `imgui` updated to [1.90.9].
6+
* Breaking: `sdlRendererRenderDrawData` now required `Renderer` arg.
7+
* Breaking: ImplVulkan removed command buffer for `ImGui_ImplVulkan_CreateFontsTexture`.
8+
* Breaking: ImplVulkan removed command for `ImGui_ImplVulkan_DestroyFontUploadObjects`.
9+
+ Added `ImGui_ImplVulkan_DestroyFontsTexture`, but it shouldn't be needed as it is called from impl internals.
10+
* Breaking: ImplVulkan moved RenderPass into InitInfo structure.
11+
+ Breaking: Haskell API is now using `Either RenderPass RenderingPipelineCreateInfo` to switch between RP/dynamic rendering.
12+
313
## [2.2.1]
414

515
- Added `DearImGui.SDL.Renderer` backend and `sdlrenderer` example.
@@ -125,7 +135,9 @@ Initial Hackage release based on [1.83].
125135
[2.1.3]: https://github.com/haskell-game/dear-imgui.hs/tree/v2.1.3
126136
[2.2.0]: https://github.com/haskell-game/dear-imgui.hs/tree/v2.2.0
127137
[2.2.1]: https://github.com/haskell-game/dear-imgui.hs/tree/v2.2.1
138+
[2.3.0]: https://github.com/haskell-game/dear-imgui.hs/tree/v2.3.0
128139

140+
[1.90.9]: https://github.com/ocornut/imgui/releases/tag/v1.90.9
129141
[1.89.9]: https://github.com/ocornut/imgui/releases/tag/v1.89.9
130142
[1.87]: https://github.com/ocornut/imgui/releases/tag/v1.87
131143
[1.86]: https://github.com/ocornut/imgui/releases/tag/v1.86

dear-imgui.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cabal-version: 3.0
22

33
name: dear-imgui
4-
version: 2.2.1
4+
version: 2.3.0
55
author: Oliver Charles
66
77
license: BSD-3-Clause

examples/sdl/Renderer.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ mainLoop renderer = do
109109
SDL.rendererDrawColor renderer $= V4 0 0 0 255
110110
SDL.clear renderer
111111
render
112-
sdlRendererRenderDrawData =<< getDrawData
112+
sdlRendererRenderDrawData renderer =<< getDrawData
113113
SDL.present renderer
114114

115115
go refs

examples/vulkan/Main.hs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -391,16 +391,15 @@ app = do
391391
, device
392392
, queueFamily
393393
, queue
394-
, pipelineCache = Vulkan.NULL_HANDLE
395-
, descriptorPool = imGuiDescriptorPool
396-
, subpass = 0
394+
, pipelineCache = Vulkan.NULL_HANDLE
395+
, descriptorPool = imGuiDescriptorPool
396+
, subpass = 0
397397
, minImageCount
398398
, imageCount
399-
, msaaSamples = Vulkan.SAMPLE_COUNT_1_BIT
400-
, mbAllocator = Nothing
401-
, useDynamicRendering = False
402-
, colorAttachmentFormat = Nothing
403-
, checkResult = \case { Vulkan.SUCCESS -> pure (); e -> throw $ Vulkan.VulkanException e }
399+
, msaaSamples = Vulkan.SAMPLE_COUNT_1_BIT
400+
, mbAllocator = Nothing
401+
, rendering = Left imGuiRenderPass
402+
, checkResult = \case { Vulkan.SUCCESS -> pure (); e -> throw $ Vulkan.VulkanException e }
404403
}
405404

406405
logDebug "Initialising ImGui SDL2 for Vulkan"
@@ -409,7 +408,7 @@ app = do
409408
( const ImGui.SDL.sdl2Shutdown )
410409

411410
logDebug "Initialising ImGui for Vulkan"
412-
ImGui.Vulkan.withVulkan initInfo imGuiRenderPass \ _ -> do
411+
ImGui.Vulkan.withVulkan initInfo \ _ -> do
413412

414413
logDebug "Running one-shot commands to upload ImGui textures"
415414
logDebug "Creating fence"
@@ -421,7 +420,9 @@ app = do
421420

422421
logDebug "Recording one-shot commands"
423422
beginCommandBuffer oneshotCommandBuffer
424-
_ <- ImGui.Vulkan.vulkanCreateFontsTexture oneshotCommandBuffer
423+
424+
logDebug "ImGui preparing fonts texture"
425+
_ <- ImGui.Vulkan.vulkanCreateFontsTexture
425426

426427
logDebug "Uploading texture"
427428
let textureSubresource = Vulkan.ImageSubresourceRange
@@ -497,8 +498,6 @@ app = do
497498
waitForFences device ( WaitAll [ fence ] )
498499

499500
logDebug "Finished uploading font objects"
500-
logDebug "Cleaning up one-shot commands"
501-
ImGui.Vulkan.vulkanDestroyFontUploadObjects
502501
traverse_ ResourceT.release [ fenceKey, oneshotCommandBufferKey, stageKey ]
503502

504503
logDebug "Adding imgui texture"

generator/DearImGui/Generator/Parser.hs

Lines changed: 56 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ import Data.Bits
2727
import Data.Char
2828
( isSpace, toLower )
2929
import Data.Either
30-
( partitionEithers )
30+
( rights )
3131
import Data.Functor
3232
( ($>) )
3333
import Data.Int
3434
( Int64 )
3535
import Data.Maybe
3636
( catMaybes, fromMaybe )
3737
import Foreign.C.Types
38-
( CInt )
38+
( CChar, CInt, CShort, CLLong, CUChar, CUShort, CUInt, CULLong )
3939

4040
-- template-haskell
4141
import qualified Language.Haskell.TH as TH
@@ -44,7 +44,7 @@ import qualified Language.Haskell.TH as TH
4444
-- megaparsec
4545
import Text.Megaparsec
4646
( MonadParsec(..), ShowErrorComponent(..)
47-
, (<?>), anySingle, customFailure, single
47+
, (<?>), anySingle, choice, customFailure, single
4848
)
4949

5050
-- parser-combinators
@@ -126,13 +126,24 @@ headers = do
126126
_ <- skipManyTill anySingle ( namedSection "Dear ImGui end-user API functions" )
127127

128128
_ <- skipManyTill anySingle ( namedSection "Flags & Enumerations" )
129-
( _defines, basicEnums ) <- partitionEithers <$>
129+
130+
basicEnums <- rights <$>
131+
manyTill
132+
( ( Left <$> try ignoreDefine )
133+
<|> ( Left <$> try cppConditional )
134+
<|> ( Right <$> enumeration enumNamesAndTypes )
135+
)
136+
( namedSection "Tables API flags and structures (ImGuiTableFlags, ImGuiTableColumnFlags, ImGuiTableRowFlags, ImGuiTableBgTarget, ImGuiTableSortSpecs, ImGuiTableColumnSortSpecs)" )
137+
138+
tableEnums <- rights <$>
130139
manyTill
131140
( ( Left <$> try ignoreDefine )
132141
<|> ( Left <$> try cppConditional )
133142
<|> ( Right <$> enumeration enumNamesAndTypes )
134143
)
135-
( namedSection "Helpers: Memory allocations macros, ImVector<>" )
144+
( try $ many comment >> keyword "struct" >> identifier)
145+
146+
_ <- skipManyTill anySingle ( namedSection "Helpers: Memory allocations macros, ImVector<>" )
136147

137148
_ <- skipManyTill anySingle ( namedSection "ImGuiStyle" )
138149

@@ -158,7 +169,7 @@ headers = do
158169

159170
let
160171
enums :: [ Enumeration () ]
161-
enums = basicEnums <> drawingEnums <> fontEnums
172+
enums = basicEnums <> tableEnums <> drawingEnums <> fontEnums
162173
pure ( Headers { enums } )
163174

164175
--------------------------------------------------------------------------------
@@ -169,6 +180,15 @@ forwardDeclarations
169180
=> m ( HashMap Text Comment, HashMap Text ( TH.Name, Comment ) )
170181
forwardDeclarations = do
171182
_ <- many comment
183+
_scalars <- many do
184+
try $ keyword "typedef"
185+
signed <- try (keyword "signed" $> True) <|> (keyword "unsigned" $> False)
186+
width <- try (keyword "int") <|> try (keyword "char") <|> try (keyword "short") <|> try (keyword "int") <|> (keyword "long" >> keyword "long")
187+
typeName <- identifier
188+
reservedSymbol ';'
189+
doc <- comment
190+
pure (typeName, (signed, width, doc))
191+
_ <- many comment
172192
structs <- many do
173193
keyword "struct"
174194
structName <- identifier
@@ -177,6 +197,9 @@ forwardDeclarations = do
177197
pure ( structName, doc )
178198
_ <- many comment
179199
enums <- many do
200+
_ <- try do
201+
_ <- many comment
202+
cppConditional <|> pure ()
180203
keyword "enum"
181204
enumName <- identifier
182205
symbol ":"
@@ -197,7 +220,23 @@ forwardDeclarations = do
197220
pure ( HashMap.fromList structs, HashMap.fromList (enums <> typedefs) )
198221

199222
cTypeName :: MonadParsec e [Tok] m => m TH.Name
200-
cTypeName = keyword "int" $> ''CInt
223+
cTypeName =
224+
choice
225+
[ try $ (keyword "char") $> ''CChar
226+
, try $ (keyword "signed" >> keyword "int") $> ''CInt
227+
, try $ (keyword "unsigned" >> keyword "int") $> ''CUInt
228+
, try $ (keyword "unsigned" >> keyword "char") $> ''CUChar
229+
, try $ (identifier' "ImS8") $> ''CChar
230+
, try $ (identifier' "ImU8") $> ''CUChar
231+
, try $ (identifier' "ImS16") $> ''CShort
232+
, try $ (identifier' "ImU16") $> ''CUShort
233+
, try $ (identifier' "ImS32") $> ''CInt
234+
, try $ (identifier' "ImU32") $> ''CUInt
235+
, try $ (identifier' "ImS64") $> ''CLLong
236+
, try $ (identifier' "ImU64") $> ''CULLong
237+
, keyword "int" $> ''CInt
238+
]
239+
<?> "cTypeName"
201240

202241
--------------------------------------------------------------------------------
203242
-- Parsing enumerations.
@@ -211,6 +250,7 @@ data EnumState = EnumState
211250

212251
enumeration :: MonadParsec CustomParseError [Tok] m => HashMap Text ( TH.Name, Comment ) -> m ( Enumeration () )
213252
enumeration enumNamesAndTypes = do
253+
void $ many (try $ comment >> cppConditional)
214254
inlineDocs <- try do
215255
inlineDocs <- many comment
216256
keyword "enum"
@@ -331,13 +371,20 @@ comment = CommentText <$>
331371
<?> "comment"
332372

333373
keyword :: MonadParsec e [ Tok ] m => Text -> m ()
334-
keyword kw = token ( \ case { Keyword kw' | kw == kw' -> Just (); _ -> Nothing } ) mempty
374+
keyword = void . keyword'
375+
376+
keyword' :: MonadParsec e [ Tok ] m => Text -> m Text
377+
keyword' kw = token ( \ case { Keyword kw' | kw == kw' -> Just kw; _ -> Nothing } ) mempty
335378
<?> ( Text.unpack kw <> " (keyword)" )
336379

337380
identifier :: MonadParsec e [ Tok ] m => m Text
338381
identifier = token ( \ case { Identifier i -> Just i; _ -> Nothing } ) mempty
339382
<?> "identifier"
340383

384+
identifier' :: MonadParsec e [ Tok ] m => Text -> m Text
385+
identifier' ident = token ( \ case { Identifier i | i == ident -> Just ident; _ -> Nothing } ) mempty
386+
<?> ( Text.unpack ident <> " (identifier)" )
387+
341388
{-
342389
prefixedIdentifier :: MonadParsec e [ Tok ] m => Text -> m Text
343390
prefixedIdentifier prefix =
@@ -452,7 +499,7 @@ cppDirective f = token ( \case { BeginCPP a -> f a; _ -> Nothing } ) mempty
452499

453500
cppConditional :: MonadParsec e [Tok] m => m ()
454501
cppConditional = do
455-
void $ cppDirective ( \case { "ifdef" -> Just True; "ifndef" -> Just False; _ -> Nothing } )
502+
void $ cppDirective ( \case { "if" -> Just True; "ifdef" -> Just True; "ifndef" -> Just False; _ -> Nothing } )
456503
-- assumes no nesting
457504
void $ skipManyTill anySingle ( cppDirective ( \case { "endif" -> Just (); _ -> Nothing } ) )
458505
void $ skipManyTill anySingle ( single EndCPPLine )

imgui

Submodule imgui updated 100 files

src/DearImGui/SDL/Renderer.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,6 @@ sdlRendererNewFrame = liftIO do
6969
[C.exp| void { ImGui_ImplSDLRenderer2_NewFrame(); } |]
7070

7171
-- | Wraps @ImGui_ImplSDLRenderer2_RenderDrawData@.
72-
sdlRendererRenderDrawData :: MonadIO m => DrawData -> m ()
73-
sdlRendererRenderDrawData (DrawData ptr) = liftIO do
74-
[C.exp| void { ImGui_ImplSDLRenderer2_RenderDrawData((ImDrawData*) $( void* ptr )) } |]
72+
sdlRendererRenderDrawData :: MonadIO m => Renderer -> DrawData -> m ()
73+
sdlRendererRenderDrawData (Renderer renderPtr) (DrawData ptr) = liftIO do
74+
[C.exp| void { ImGui_ImplSDLRenderer2_RenderDrawData((ImDrawData*) $( void* ptr ), (SDL_Renderer*) $( void* renderPtr )) } |]

0 commit comments

Comments
 (0)