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

MG1/2 | MGS3: Add patches to extend texture buffer size #39

Merged
merged 1 commit into from
Nov 2, 2023

Conversation

emoose
Copy link
Contributor

@emoose emoose commented Nov 2, 2023

Fixes #15

Allows extending the temporary texture buffer that both MG1/2 & MGS3 seem to use, allowing larger texture files to be loaded into the game.

Seems MGS2 doesn't use this kind of temporary buffer, all the same CTexture/CBaseTexture code is there but the code around this temporary buffer stuff is missing, weird (maybe after they worked on MGS2 they added this buffer trick as an optimization during MGS3 work, but then forgot to backport it to MGS2, who knows)

MG1/2 does include the same buffer code but doubtful it can make much difference there, still added it just in case someone wants to use a 50MB intro logo or something :P

Haven't tried comparing memory usage with this yet, AFAIK it should only be allocing the main buffer once per session, so would add 128 - 16 = ~112MB extra usage, there is that weird mip count part which I'm not sure of though, maybe would increase it more.

One small worry with this is that it's kinda tying data files with HDFix, if you installed HDFix along with a larger-than-16MB texture pack, removing HDFix while keeping the texture pack files would cause crashing in the vanilla game...
Can't really see much way to get around that though, and guess users can always verify files in steam to fix it, so maybe not a huge problem.

@Lyall Lyall merged commit 5a4945e into Lyall:master Nov 2, 2023
@emoose
Copy link
Contributor Author

emoose commented Nov 7, 2023

Seems some are still reporting crashes with larger textures even with this patch enabled, while others have it working fine, guessing it could be related to the timing issues I mentioned in the launcher config thread, game might already be creating texture buffer before we had a chance to patch the size.

The "fix" of just running everything from DllMain instead of creating new thread might help with it, here's a build if anyone wants to try (replace the MGSHDFix 0.9 asi with the one here), please let me know here or on NexusMods if it stops the crashing for you:
MGSHDFix_0.9_DllMainHack.zip

Running from DllMain still isn't ideal though, looking into whether we can hook any of the imports that game calls early on instead.

E: should have a better solution using a IAT hook to load us in instead, seems to work across all the games fine for me, if anyone had crash issues with textures before please give it a try (install on top of MGSHDFix 0.9)
MGSHDFix_0.9_IATHook.zip

Code for that is at emoose@3dc37b1

@Klemci
Copy link

Klemci commented Nov 8, 2023

You fixed it !

9700F 3060XC (12gb)

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.

Texture buffer size increase from 16MiB
3 participants