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

[Graphics] Dx11: Fix ResizeBuffer when swap chain is under flip model and changing format #1814

Merged
merged 1 commit into from
Sep 22, 2023

Conversation

Eideren
Copy link
Collaborator

@Eideren Eideren commented Sep 21, 2023

PR Details

Why this issue occurred:

Flip model supports 3 different formats, none of them are sRGB.
The asset view swaps between gamma and linear rendering depending on the asset, so non-sRGB and sRGB format.
When the swap chain is initialized, the logic stripped out the sRGB specifier from the format provided, so it never could crash then.
But when the view changes size or format, ResizeBuffer is called, if the format requested is sRGB it won't be stripped out, so it'll silently crash the application.

What this PR does:

Ensures that the format, when creating and on resize, is not only non-sRGB but also supported by flip model.

This seems a bit weird for me though, should we not require the callers to provide a format that is compatible with the flip model if they do enable it, instead of silently fixing the format for them ? I can understand doing so if there are no difference in visuals but that seems unlikely ? Maybe you could chime in @azeno ?

Related Issue

Fixes #1770
Related to PR #1594

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My change requires a change to the documentation.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@Eideren Eideren requested a review from azeno September 21, 2023 18:05
@Eideren
Copy link
Collaborator Author

Eideren commented Sep 21, 2023

And a big thanks to @Perksey for helping me out with this issue

@azeno
Copy link
Collaborator

azeno commented Sep 22, 2023

I don’t really understand why the asset view would change the render target format based on the asset? This doesn’t sound right. But your PR looks good to me. Especially that it now throws if the format is not supported under the flip model. Removing the auto switch entirely would for sure also be an option, just hard to say what implications that could have on existing apps.

@Eideren
Copy link
Collaborator Author

Eideren commented Sep 22, 2023

Thanks a bunch for getting back to me so fast and looking through this @azeno, really appreciate it !
Right, I'll leave throwing when we have a case where we can see a discrepancy between expected color and the displayed one then.

Windows - Simple (Tests) fails, looking at the history it has been randomly failing off and on for a while now, even on the same method so unlikely to be caused by this. I'll take a look into that after merging.

@Eideren Eideren merged commit 9124336 into stride3d:master Sep 22, 2023
@Eideren Eideren deleted the flip_fix branch September 22, 2023 11:18
@Ethereal77
Copy link
Contributor

I don’t really understand why the asset view would change the render target format based on the asset?

I think the asset view does that in order to properly show the preview of some assets that must be shown as they are (without gamma conversion), like normal maps or heightmaps (which must be linear), and maybe others also.

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.

Skybox texture asset preview cause game studio crash
3 participants