Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vulkan: Re-Create main window pipeline and added optional color correction #8053

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

SuperRonan
Copy link

@SuperRonan SuperRonan commented Oct 12, 2024

  1. API changes:
  • Added ImGui_ImplVulkan_ReCreateMainPipeline(...) to explicitly re-create the main window pipeline (when some of its properties are changed).
  • ImGui_ImplVulkan_CreatePipeline(...) does not implicitly use ImGui_ImplVulkan_InitInfo::PipelineRenderingCreateInfo, but a function parameter.
  • The main window pipeline is created only if possible during ImGui_ImplVulkan_Init(...) (if a render pass or rendering info are given), else it should be created with ImGui_ImplVulkan_ReCreateMainPipeline(...) before rendering)
  1. Concerning color correction:
  • The default behavior of imgui_impl_vulkan does not change (no color correction is applied with no overhead in the fragment shader).
  • A color correction method is decided at pipeline compile time (through a vulkan specialization constant)
  • Color correction parameters can either be set at pipeline compile time (static mode), or through push_constant (dynamic mode, default)
  • A gamma correction mode is implemented (and an extra alpha gamma correction since the blending does not necessarily happen in linear color space).
  • New color modes can easily be added in the fragment shader.

To illustrate the changes:
Without color correction (the main window pipeline is simply recreated to fit the new swapchain format):

NoColorCorrection.mp4

With color correction:

WithColorCorrection.mp4

…ction in the fragment shader

API changes:
- Added ImGui_ImplVulkan_ReCreateMainPipeline(...) to explicitly re-create the main window pipeline (when some of its properties are changed).
- ImGui_ImplVulkan_ReCreateMainPipeline(...) does not implicitly use ImGui_ImplVulkan_InitInfo::PipelineRenderingCreateInfo, but a function parameter.
- The main window pipeline is created only if possible during ImGui_ImplVulkan_Init(...) (if a render pass or rendering info are given), else it should be created with ImGui_ImplVulkan_ReCreateMainPipeline(...) before rendering)
Concerning color correction:
- The default behavior of imgui_impl_vulkan does not change (no color correction is applied).
- A color correction method is decided at pipeline compile time (through a vulkan specialization constant)
- Color correction parameters can either be set at pipeline compile time (static mode), or through push_constant (dynamic mode, default)
- A gamma correction mode is implemented (and an extra alpha gamma correction).
- New color modes can easily be added.

# Conflicts:
#	backends/imgui_impl_vulkan.cpp
@SuperRonan
Copy link
Author

See the pull request for the docking branch.

@SuperRonan
Copy link
Author

SuperRonan commented Oct 17, 2024

I see there are a number of other PR on a color correction ( #7904, #7826, #578, ...).
Here are some of my thoughts on this subject (probably biased):

  • I think the color correction should not be limited to a gamma correction, but other common corrections should be impleted too (HLG, ST2084, DCI-P3, other VkColorSpaceKHR) (although 99% of cases would be covered by a gamma correction)
  • Manual color correction in a shader is sometimes necessary (when rendering to a linear format (float or unorm) but with a non linear color space swapchain (like with HDR)).
  • I find it surprising that rendering to a RGBA8_UNORM target with sRGB color space "looks correct" without any gamma correction in the shader, but rendering to a RGBA8_SRGB witht the same color space needs an inverse gamma correction in the shader to "look correct". the ImGui color palette appears to be gamma pre-corrected)
  • Share the color correction control across all backends:
    • move ImGui_ImplVulkan_ColorCorrectionMethod and ImGui_ImplVulkan_ColorCorrectionParameters to imgui.h as ImGui_ColorCorrectionMethod and ImGui_ColorCorrectionParameters
    • Only use them in renderer backends that implemented color correction.
  • I would not put a ImGuiIO::ConfigFlags ImGuiConfigFlags_IsSRGB (Adding sRGB colors to ImGui style. #7826) as I think this behaviour should only be controlled by the renderer impl (as I did in the vulkan impl). ImGuiIO should remain agnostic to color spaces issues (plus ImGuiConfigFlags_IsSRGB does not scale with other color corrections) (plus in vulkan it does not appear to change anything)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants