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

[d3d8] Use D3DPOOL_SCRATCH in CreateImageSurface #206

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

WinterSnowfall
Copy link

@WinterSnowfall WinterSnowfall commented Mar 5, 2024

Fixes #89 and fixes points (1.) and (2.) from #205.

Some games expect us to successfully create image surfaces for them even when they supply unsupported formats like P8 or R8G8B8. This only works with D3DPOOL_SCRATCH according to spec, and it's also what dxvk validates inside of CreateOffscreenPlainSurfaceEx().

We don't actually need to fully support them in order for the above games to work properly at least. #182 will still need P8 support, since it uses that on CreateTexture().

The only problem is we don't currently handle D3DPOOL_SCRATCH at all in CopyRects(), so this has the potential to explode and break more than it fixes. We should merge this change only after sorting out that bit ideally.

@WinterSnowfall WinterSnowfall force-pushed the d8vk-crimgsurf branch 2 times, most recently from c6abbbf to f56756e Compare March 5, 2024 23:16
@WinterSnowfall
Copy link
Author

WinterSnowfall commented Mar 5, 2024

I've sweetened it a bit by using D3DPOOL_SCRATCH only in case of unsupported surface formats (when CreateImageSurface would typically fail without this PR). We should still consider handling D3DPOOL_SCRATCH in CopyRects, but it's far less likely anything will blow up now.

Edit: Apparently, according to spec, CreateImageSurface() should use D3DPOOL_SYSTEMMEM, but I doubt this actually happens in practice. Modern drivers also don't support any of the above mentioned formats and yet most of the problematic games work fine on native d3d8. All things considered, it is perhaps a generally good idea to keep using D3DPOOL_SYSTEMMEM for the formats we do support, since some games might rely on this particularity.

Edit 2: I've confirmed CreateImageSurface() never fails on native Nvidia (thanks to @K0bin), so my initial assumptions were correct.

@WinterSnowfall WinterSnowfall force-pushed the d8vk-crimgsurf branch 2 times, most recently from a155d14 to aee1d3c Compare March 10, 2024 10:23
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.

Hidden And Dangerous - crashes after the ESRB notice is shown
1 participant