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
Enable float pixel format on windows for HDR and/or WCG #1907
Comments
Thanks for this! Is there any reason this hasn't been opened as a PR and included in GLFW? |
I can have a look on how to make a PR out of it. It probably needs rebasing to master. Also half-float buffer works only on Windows at the moment as I understand it. There might need to be some error handling when trying to use GLFW_FLOAT_PIXEL_TYPE on other OS:es/windowing systems. I'm also a but unsure about if there are any rules when creating new defines. I simply set a value that wasn't used. However, this code has been used successfully on both Nvidia GPUs, Intel GPUs, and hybrid versions between those. It probably works on AMD too but hasn't been tested. Windows is handling the static HDR meta data but it's possible to override with Nvidias API for example. |
OK, yea I was just testing it yesterday. I'm on AMD. It worked, but strangely, I could only get a BGRA buffer. I thought to add some code to check the bit shifts, but they were actually all BGRA. |
I'd like to get fp16 and other extended formats on macOS as well ~ grepping around in the code I think float pixel formats haven't been implemented since this issue was posted? Just want to double check that I haven't overlooked something. |
That's technically incorrect. When using an sRGB render target, 1.0f is the user defined preferred white point when targeting an HDR display (that behaves like LDR content, and that 1.0f is usually far off from 80 nits on any modern display). But when using scRGB render target, 1.0f is reduced to 80 nits, and you have to query the native system APIs to get the preferred brightness of "reference white" as a multiplier just in order to get LDR content to show as expected again. So you can't just switch the default behavior and expect applications to "just work".
Forget about that part for now. That's the least of your concerns. Not to mention that most displays ignore this information anyway, as it can be trivially reconstructed from the image content. Plus you are clashing with Windows here, which has already opted to take control, and has (for very good reasons) stated towards to the display that it will produce content which exactly fits the native capabilities of the display. More important is the part where you query the effective color gamut and brightness range. Everything in that range is safe to use, and will behave somewhat as expected. This is what the final applications tone mapping needs to yield. Everything outside that range is subject to "smart optimizations" the display vendor may have applied. Do not go this route, you will encounter highly unexpected effects such as the display randomly adjusting the brightness, deviating from the previously absolute scale, just in order to still fit the highlights into it's own range. If you do this, you will face displays (thanks for nothing, BenQ) trying to do the tone mapping in your stead, and the result will suck as you are no longer in the expected color space. You won't notice this specific issue if your reference system is a 10bit wide gamut display with a color profile, in that case Windows had already taken care of properly clipping. But you will notice issues on many HDR10 displays. TLDR: Make sure the content is clipped to the displays capabilities, or UB occurs. |
This feature request enables to switch from WGL_TYPE_RGBA_ARB to WGL_TYPE_RGBA_FLOAT_ARB (On Windows 10) in order to use higher color bit depths than 10 as well as HDR rendering in non-exclusive mode. This also enables wide color gamut rendering (WCG). Usage for the patch located at the end of this issue:
Values in the range 0.0f - 1.0f will be in low-dynamic-range while values above 1.0f are in high-dynamic range. The color space is Windows' scRGB where 1.0f corresponds to a brightness of 80 nits, 12.5f corresponds to 1000 nits on a linear scale. More info here: https://docs.microsoft.com/en-us/windows/win32/direct3darticles/high-dynamic-range
For sending color space and HDR metadata to the display, each vendor's API must be used. More info from Nvidia here:
Patch:
The text was updated successfully, but these errors were encountered: