-
Notifications
You must be signed in to change notification settings - Fork 8
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] Ensure all references are cleared before d3d9 device reset #172
[d3d8] Ensure all references are cleared before d3d9 device reset #172
Conversation
9992d59
to
6d54828
Compare
6d54828
to
4619f81
Compare
There still seem to be some issues around bound resources (e.g. with Scrapland Remastered at times), but I don't think there's anything left to fix on d8vk end. Remaining discrepancies may just be games doing stupid things or differences in handling between d3d8 and d3d9 (let's hope not...). Either way, this PR fixes most of the issues, but caveat emptor the saga may not be entirely over. |
As I long feared, there's a difference between how d3d8 and d3d9 handle losable resource validation on device resets, in that d3d9 counts state blocks as losable resources while d3d8 does not. This appears to be a rare case where the docs are actually on point: Here's d3d8:
And d3d9:
We'll have to disable losable counts for state blocks in d9vk via the bridge when using it with d8vk. I'll PR something separately against dxvk to address this. Edit: doitsujin#3665 |
Since there may be some time still until we rebase and all of this is merged, note to self that with the latest upstream code we still need to plop a call to SetD3D8CompatibilityMode as follows:
for everything to work properly. |
And there I was, dear reader, chasing refs again... D3DPOOL_DEFAULT resources are a problem now, since anything lingering on a device reset will cause games to crash. I managed to narrow down such an obscure case, by following it up to the temporary blit surfaces we were (in some cases) creating during CopyRects. The problem there was mainly with that extra refcount that was keeping the blit surfaces around even after surface (containing object) destruction - since we're passing everything around as a public COM, the refcount for With the extra ref it was, unfortunately, always stuck at a very constant 2 and never destroyed. An easy enough fix, but it took me quite some time to figure it out.
Nevemind on the last bit, turns out using RTs is somewhat faster (probably because they're not lockable). I've added a note so that we don't forget we need to be extra careful when messing about with object lifecycle in this area. |
fa06526
to
35110ad
Compare
I've included the bridge call to enable the D3D8 compatibility mode (which currently only affects state block tracking for device reset). Note however this will cause issues until a rebase is performed, since the necessary bridge code was added directly upstream. |
9b44e13
to
9ebed42
Compare
1af0ac2
to
640dd68
Compare
640dd68
to
4e56157
Compare
Now that we've imported the new D3D9 device reset validations we also need ensure that:
We clear all d3d8 cached references before calling d3d9 device reset
We regenerate/rebind the backbuffers and autoDS after the d3d9 device reset succeeds
We actually free state blocks on calls to DeleteStateBlock()
Otherwise some d3d8 games will livelock and crash, complaining they can't reset the device with bound resources (it was the default render target, depth stencil and state blocks that were bound from our end).
Fixes #174, fixes #175, partially addresses #59 (fixes the startup crash, as that seems to have been state block related).