-
-
Notifications
You must be signed in to change notification settings - Fork 1k
feat: Enable rendering to HDR displays on DirectX/Windows #2711
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
feat: Enable rendering to HDR displays on DirectX/Windows #2711
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
sources/engine/Stride/Graphics/ColorSpace.cs:159
- [nitpick] The enum member 'YcbcrStudioGhlgTopleftP2020' deviates from the usual gamma notation pattern; please confirm if 'Ghlg' is intentional or if it should be 'G22'.
YcbcrStudioGhlgTopleftP2020 = 18,
Would be nice to mention in the crossplatform classes like the window and presenter that this is only supported on directx, looks like you disabled edits from maintainers so I can't take care of this for you. |
Should the new type and code be guarded against some #define so that if someone builds the engine for OpenGL only, they don't appear at all? |
For crossplatform purposes, I would rather we avoid compile-time checks wherever possible to ensure we have the least amount of friction with how user build their games, I would rather we notify user of the lack of support than force them to setup a compile time branch for such a simple feature. That's what we're already doing for most missing features between graphics apis actually, so it would make sense to continue in the same direction for this one I think. |
I'll enable this, was not intentional. Thanks! |
…olor space properties.
…com/vvvv/stride into dev/tebjan/add-hdr-10bit-backbuffer # Conflicts: # sources/engine/Stride.Graphics/GraphicsPresenter.cs
It looks like I can't enable it because I am not the repo's owner. But I've added the info to the public properties. |
Thanks ! |
PR Details
This PR introduces support for rendering to High Dynamic Range (HDR) displays by enabling configuration of the swap chain's output color space and pixel format.
Key Changes:
ColorSpaceType
Enum: Added a newStride.Graphics.ColorSpaceType
enum (inColorSpace.cs
) which mirrors theDXGI_COLOR_SPACE_TYPE
values.GraphicsPresenter.SetOutputColorSpace
Method: Added a new public methodGraphicsPresenter.SetOutputColorSpace(ColorSpaceType colorSpace, PixelFormat format)
. This is the primary way for users to configure the desired output. Calling this method will:IDXGISwapChain3::SetColorSpace1
on D3D11/12) with the specified color space.PresentationParameters
now includes anOutputColorSpace
property.GameWindowRenderer
uses this property and allows settingPreferredOutputColorSpace
to trigger a presenter update.SwapChainGraphicsPresenter
applies theOutputColorSpace
when creating/recreating the swap chain.PixelFormat
andColorSpaceType
combinations are intended for specific HDR standards (scRGB, HDR10).How to Use HDR Output:
To enable HDR rendering, you need to get the
Game.GraphicsDevice.Presenter
and call the newSetOutputColorSpace
method with the appropriateColorSpaceType
andPixelFormat
. This should typically be done after the game has started and the graphics device is initialized, for example, within a game script'sStart
orUpdate
method.Common combinations include:
ColorSpaceType.RgbFullG2084NoneP2020
withPixelFormat.R10G10B10A2_UNorm
. This requires the rendering pipeline to output colors matching the PQ transfer function and Rec.2020 primaries.ColorSpaceType.RgbFullG10NoneP709
withPixelFormat.R16G16B16A16_Float
. This allows for linear rendering in a wider gamut, relying on the Windows Desktop Window Manager (DWM) for final conversion to the display.ColorSpaceType.RgbFullG22NoneP709
with an 8-bit format likePixelFormat.R8G8B8A8_UNorm_SRgb
.Example Script:
Important Considerations:
SetOutputColorSpace
call may fail if the combination is not supported. Error handling is recommended.R16G16B16A16_Float
increases memory bandwidth usage compared to standard 8-bit formats.See also Microsoft's documentation on HDR with DirectX:
Types of changes
Checklist