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] Implement monotonic state block tokens #4111

Merged
merged 1 commit into from
Jul 9, 2024

Conversation

WinterSnowfall
Copy link
Contributor

@WinterSnowfall WinterSnowfall commented Jul 7, 2024

Would need feedback from @AlpyneDreams .

The idea is to get rid of reinterpret casts and stick with what native does, namely a monotonically increasing counter that is passed back as the token whenever new state blocks are created. Tests have shown there's no token reuse, not even between device resets.

I also don't think we should worry about the address space being exhausted, because I did some quick math and if let's say a game creates 8 state blocks per frame @ 60 fps, it will take about 100+ days to overflow a DWORD. That's "let's not worry about it" territory in my book... but I can in theory implement a check to see if a token is already taken before allocating it.

@WinterSnowfall
Copy link
Contributor Author

I've tested ~140 d3d8 games with this PR and everything checks out. I've only seen one obscure game (FireStarter), at times, passing a state block token to apply a previously deleted state block, which is why I added the validations. Native drivers on Windows XP don't do any validations and would outright crash in this situation.

@WinterSnowfall WinterSnowfall marked this pull request as ready for review July 9, 2024 11:08
src/d3d8/d3d8_device.cpp Outdated Show resolved Hide resolved
src/d3d8/d3d8_device.cpp Outdated Show resolved Hide resolved
src/d3d8/d3d8_device.h Outdated Show resolved Hide resolved
src/d3d8/d3d8_device.cpp Outdated Show resolved Hide resolved
src/d3d8/d3d8_device.cpp Outdated Show resolved Hide resolved
@WinterSnowfall WinterSnowfall force-pushed the d3d8-tokens branch 5 times, most recently from e1a3e66 to 623a8f4 Compare July 9, 2024 16:24
@WinterSnowfall
Copy link
Contributor Author

Finalized now, hopefully. Thanks for all the nudging in the right directions.

@AlpyneDreams
Copy link
Contributor

Looks good to me. I don't have permission to merge so one of the maintainers will have to do that.

@doitsujin doitsujin merged commit ff137da into doitsujin:master Jul 9, 2024
4 checks passed
@WinterSnowfall WinterSnowfall deleted the d3d8-tokens branch July 9, 2024 22:57
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