libsdl-org / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
9.95k stars 1.84k forks source link

Direct2D12 no longer works with ImGui's SDL3+SDL_Renderer correctly #9135

Closed JoeyLiang-0 closed 8 months ago

JoeyLiang-0 commented 8 months ago

Since the commit of: https://github.com/libsdl-org/SDL/commit/54c2ba6afd776d0d0c8f2bc438ad34d49a9cd87c ImGui's example of SDL3+SDL_Renderer3 doesn't work correctly, https://github.com/ocornut/imgui/tree/master/examples/example_sdl3_sdlrenderer3 Omar thought the cause should be on SDL side. The details of the issue: https://github.com/ocornut/imgui/issues/7343 The screenshots of correct version vs. wrong one: image

slouken commented 8 months ago

Can you find out what renderer is being used and what texture format is being used? Is this an HDR use case?

JoeyLiang-0 commented 8 months ago

Don't think HDR is used in the example project. When stepping into the rendering callstacks, it showed D3D12 renderer is used, texture format is 0x16762004.

>   example_sdl3_sdlrenderer3.exe!SDL_RenderGeometryRaw_REAL(SDL_Renderer * renderer, SDL_Texture * texture, ...
    example_sdl3_sdlrenderer3.exe!SDL_RenderGeometryRaw(SDL_Renderer * a, SDL_Texture * b, ...
    example_sdl3_sdlrenderer3.exe!ImGui_ImplSDLRenderer3_RenderDrawData(...
    example_sdl3_sdlrenderer3.exe!main(...

renderer->info
{name=0x00007ff7a5f18940 "direct3d12" flags=0x00000006 num_texture_formats=0x00000009 ...}
    name: 0x00007ff7a5f18940 "direct3d12"
    flags: 0x00000006
    num_texture_formats: 0x00000009
    texture_formats: 0x0000017ce27b60e8 {0x16362004, 0x16161804, 0x16572004, 0x1a204008, 0x32315659, 0x56555949, 0x3231564e, ...}
    max_texture_width: 0x00004000
    max_texture_height: 0x00004000

texture->format
0x16762004

Note: with the same version, example_win32_directx12 works fine (the left half of the attached screenshot)

slouken commented 8 months ago

Hmm, it's working for me here. Are you using the latest imgui and SDL code?

image
joey-cyt commented 8 months ago

Thanks, I will try to find other machine(s) to test, to see if there is other cause(s) invovled.

oscar7070 commented 8 months ago

Not working currently for me too on OpenGL & Vulkan(Tested on latest ImGui and latest SDL3) OpenGL(Broken ): Screenshot_318

DirectX(Works with no problems): Screenshot_319

And Vulkan(Broken and crashing) Screenshot_320

On Vulcan renderer crash output: Screenshot_321

joey-cyt commented 8 months ago

Today, sync-ed to the latest SDL source code, and kept ImGui code the same, the ImGui's example_sdl3_sdlrenderer3 renders content correctly again! Thanks for the great work!

slouken commented 8 months ago

Great!