Skip to content

Comments

Fix sRGB backbuffers on the SDL_GPU and D3D11 backends#240

Merged
flibitijibibo merged 6 commits intoFNA-XNA:masterfrom
kg:srgbswapchain
May 31, 2025
Merged

Fix sRGB backbuffers on the SDL_GPU and D3D11 backends#240
flibitijibibo merged 6 commits intoFNA-XNA:masterfrom
kg:srgbswapchain

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

}
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