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

Fix resource leak and prevent pure device creation #175

Merged
merged 3 commits into from
Sep 11, 2024

Conversation

elishacloud
Copy link
Contributor

This fixes a resource leak that happens in GetTexture() because we query for the interface after getting the texture and never release the extra reference that creates.

Also, this prevents the game from creating a pure device. d3d8to9 won't work with a pure device because it requires many Get functions that won't work if a game creates a pure device.

@WinterSnowfall
Copy link
Contributor

d3d8to9 won't work with a pure device because it requires many Get functions that won't work if a game creates a pure device.

Has it been a problem so far? AFAIK a lot of games will request D3DCREATE_PUREDEVICE in order to signal they need HWVP only, so getting rid of it entirely may also come with some performance implications.

@elishacloud
Copy link
Contributor Author

Has it been a problem so far? AFAIK a lot of games will request D3DCREATE_PUREDEVICE in order to signal they need HWVP only, so getting rid of it entirely may also come with some performance implications.

You can search for GetDesc in the code and see the number of functions that would fail. Even simple functions like CopyRects() and UpdateTexture() will fail with d3d8to9 in a pure device.

Maybe pure devices are more common in Direct3D9 games than in Direct3D8 or maybe these are the reason for a number of games that already fail or have issues with d3d8to9 that hasn't been investigated yet. I know several.

Either way if a game uses a pure device it is unlikely to work right with d3d8to9.

@WinterSnowfall
Copy link
Contributor

WinterSnowfall commented Sep 11, 2024

You can search for GetDesc in the code

Not all Get* functions are actually disabled, rather only the ones affecting state, if docs are to be believed. See here.

@Polymega
Copy link

Maybe pure devices are more common in Direct3D9 games than in Direct3D8 or maybe these are the reason for a number of games that already fail or have issues with d3d8to9 that hasn't been investigated yet. I know several.

Wonder if this would fix Silent Hill 3's unique DX8 shaders? Right now, all advanced beauty shaders made by SH3 don't render at all when using d3d8to9.

@elishacloud
Copy link
Contributor Author

Not all Get* functions are actually disabled, rather only the ones affecting state, if docs are to be believed. See here.

Ok, I removed the code that prevents pure device creation.

@elishacloud
Copy link
Contributor Author

Ok, good call. I fixed it to release the base texture in each block.

@crosire crosire merged commit ac41b09 into crosire:main Sep 11, 2024
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.

4 participants