ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
61.05k stars 10.29k forks source link

SDL3+SDL_Renderer no longer renders content correctly #7343

Closed JoeyLiang-0 closed 8 months ago

JoeyLiang-0 commented 8 months ago

Version/Branch of Dear ImGui:

Version 1.90.3, sync to latest (659fb41d...), Branch: master

Back-ends:

imgui_impl_sdl3.cpp + imgui_impl_sdlrenderer3.cpp

Compiler, OS:

Windows 11, Visual Studio 2022

Full config/build information:

Dear ImGui 1.90.4 WIP (19032)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=199711
define: _WIN32
define: _WIN64
define: _MSC_VER=1939
define: _MSVC_LANG=201402
--------------------------------
io.BackendPlatformName: imgui_impl_sdl3
io.BackendRendererName: imgui_impl_sdlrenderer3
io.ConfigFlags: 0x00000003
 NavEnableKeyboard
 NavEnableGamepad
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x0000000E
 HasMouseCursors
 HasSetMousePos
 RendererHasVtxOffset
--------------------------------
io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 512,64
io.DisplaySize: 1280.00,720.00
io.DisplayFramebufferScale: 1.00,1.00
--------------------------------
style.WindowPadding: 8.00,8.00
style.WindowBorderSize: 1.00
style.FramePadding: 4.00,3.00
style.FrameRounding: 0.00
style.FrameBorderSize: 0.00
style.ItemSpacing: 8.00,4.00
style.ItemInnerSpacing: 4.00,4.00

Details:

Recently updated SDL and found the sdl3+sdlRenderer3 no longer works correctly. I use the latest ImGUI code with sdl3+sdlRenderer3 example to narrow down the issue is due to recent SDL update. From SDL main branch, rendering with 4ba6aeee9d6fe224aaf8b7a682647891991969a6 is still correct, but since 54c2ba6afd776d0d0c8f2bc438ad34d49a9cd87c the rendering is messed up. Please refer to the attached screenshots for the good/bad comparison.

git log

...
commit 54c2ba6afd776d0d0c8f2bc438ad34d49a9cd87c                                                                                                                                            
Author: Sam Lantinga <slouken@libsdl.org>                                                                                                                                                  
Date:   Wed Feb 21 09:03:03 2024 -0800                                                                                                                                                     

    Added the Chrome HDR tonemap operator                                                                                                                                                  

    Also added support for the SDL_PIXELFORMAT_XBGR2101010 pixel format to the D3D12, D3D11, and Metal renderers.                                                                          

commit 4ba6aeee9d6fe224aaf8b7a682647891991969a6                                                                                                                                            
Author: Sam Lantinga <slouken@libsdl.org>                                                                                                                                                  
Date:   Mon Feb 19 08:45:02 2024 -0800                                                                                                                                                     

    A second take on HDR support with an SDR white point and HDR headroom                                                                                                                  

    This better reflects how HDR content is actually used, e.g. most content is in the SDR range, with specular highlights and bright details beyond the SDR range, in the HDR headroom.   

    This more closely matches how HDR is handled on Apple platforms, as EDR.     

Screenshots/Video:

image

Minimal, Complete and Verifiable Example code:

(https://github.com/ocornut/imgui/tree/master/examples/example_sdl3_sdlrenderer3)

ocornut commented 8 months ago

I can't understand how the commit description (https://github.com/libsdl-org/SDL/commit/54c2ba6afd776d0d0c8f2bc438ad34d49a9cd87c) would relate/affect your backend.

You may want to see which underlying backend your SDL_Renderer is using, see if changing it fixes something etc.

JoeyLiang-0 commented 8 months ago

DirectX12 is used under the SDL_Renderer3. If I revert just src/render/direct3d12/* from commit 54c2ba6a to 4ba6aeee, everything backs to normal. At 64c2ba6a where SDL_Renderer3 has issue, both example_win32_directx12 and exaple_sdl3_opengl3 render content correctly.

ocornut commented 8 months ago

Given the expected contents of that commit I would say it seems like a bug in SDL3 wip branch.

JoeyLiang-0 commented 8 months ago

Thanks for your comments, and the great project too! I will follow this issue on SDL side when getting some free time.

joey-cyt commented 8 months ago

@ocornut You are right. Today, I sync-ed to the latest SDL source code, and kept ImGui code the same (659fb41...), the example_sdl3_sdlrenderer3 renders content correctly again! Thank you very much,

ocornut commented 8 months ago

Great to hear, closing this :)