Skip to content

Ability to set the color space for ImGui away from UNORM (to SRGB or others) in Vulkan #8271

@BenMcAvoy

Description

@BenMcAvoy

Version/Branch of Dear ImGui:

Version 1.91.0, Branch: docking (master/docking/etc.)

Back-ends:

imgui_impl_glfw.cpp + imgui_impl_vulkan.cpp

Compiler, OS:

Linux + Clang

Full config/build information:

Dear ImGui 1.91.0 (19100)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=201703
define: __linux__
define: __GNUC__=14
define: IMGUI_HAS_VIEWPORT
define: IMGUI_HAS_DOCK
--------------------------------
io.BackendPlatformName: imgui_impl_glfw
io.BackendRendererName: imgui_impl_vulkan
io.ConfigFlags: 0x00000000
io.ConfigViewportsNoDecoration
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x00001C0E
 HasMouseCursors
 HasSetMousePos
 PlatformHasViewports
 HasMouseHoveredViewport
 RendererHasVtxOffset
 RendererHasViewports
--------------------------------
io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 512,64
io.DisplaySize: 1338.00,924.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:

My Issue/Question:

I cannot seem to figure out how to switch the surface format from UNORM to SRGB or some other format when using Vulkan in ImGui. This means that all my colours for ImGui appear washed out and exploring issues and examples has not made it clearer unfortunately. Thanks so much for any help!

Screenshots/Video:

Surface is in VK_FORMAT_B8G8R8A8_SRGB
image

Surface is VK_FORMAT_B8G8R8A8_UNORM
image

Minimal, Complete and Verifiable Example code:

// If you were to want to use SRGB in your application like so:
// It seems undocumented how to switch colour spaces if it is possible
VkSurfaceFormatKHR App::ChooseSwapSurfaceFormat(
    const std::vector<VkSurfaceFormatKHR> &availableFormats) {
  for (const auto &availableFormat : availableFormats) {
    if (availableFormat.format == VK_FORMAT_B8G8R8A8_SRGB &&
        availableFormat.colorSpace == VK_COLOR_SPACE_SRGB_NONLINEAR_KHR) {
      return availableFormat;
    }
  }

  return availableFormats[0];
}

I have explored other issues but they do not seem to have any solutions apart from modifying the backend files, I would like not to resort to this, or is there simply no other way in the current API. Any help is greatly appreciated!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions