Skip to content

Fix sRGB backbuffers on the SDL_GPU and D3D11 backends #240

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

Merged
merged 6 commits into from
May 31, 2025

Conversation

kg
Copy link
Contributor

@kg kg commented Mar 12, 2025

sRGB textures and render targets work but when you request a sRGB backbuffer, you don't get one right now.

On SDL_GPU we aren't flowing the sRGB flag through.

On D3D11, we changed to flip model which doesn't allow sRGB backbuffers, you have to set the colorspace on the swapchain instead.

This PR also fixes a swapchain leak triggered by enabling HDR in D3D11

@kg kg force-pushed the srgbswapchain branch from c95f743 to 4e78ac1 Compare March 12, 2025 09:52
@kg kg changed the title Fix sRGB backbuffers on the SDL_GPU backend Fix sRGB backbuffers on the SDL_GPU and D3D11 backends Mar 12, 2025
Copy link
Member

@flibitijibibo flibitijibibo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One tiny thing and one slightly less tiny but still pretty small thing - otherwise lgtm

@@ -2699,6 +2706,10 @@ static void D3D11_INTERNAL_CreateSwapChain(
{
colorSpace = DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709;
}
else if (sRGB)
{
colorSpace = DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't the else cover this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this or the other else are both the correct color space

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some more testing and it seems like they're right, but it feels like either the sRGB or non-sRGB arm should be G10 so I'm not sure what's going on.

Co-authored-by: Ethan Lee <flibitijibibo@gmail.com>
@kg
Copy link
Contributor Author

kg commented Mar 12, 2025

This isn't ready to merge yet, I just noticed that this color space code leaks a reference to the swapchain

EDIT: Fixed

EDIT 2: Sort of. I think we need to release swapchain3 instead of swapchain, because it's technically legal for queryinterface to return a separate object...

Copy link
Member

@flibitijibibo flibitijibibo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compared these changes to SDL_GPU's swapchain composition logic and it's close enough, making a couple changes then merging...

@flibitijibibo
Copy link
Member

SLR hosting is returning 502 for some reason, probably temporary - the other Linux builds are fine so this should be green when steamos.cloud is back.

@flibitijibibo flibitijibibo merged commit 66c8c13 into FNA-XNA:master May 31, 2025
9 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants