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

Raise TR2 texture limits #2405

Merged
merged 6 commits into from
Jan 28, 2025
Merged

Conversation

lahm86
Copy link
Collaborator

@lahm86 lahm86 commented Jan 28, 2025

Resolves #1795.
Resolves #1796.

Checklist

  • I have read the coding conventions
  • I have added a changelog entry about what my pull request accomplishes, or it is an internal change
  • I have added a readme entry about my new feature or OG bug fix, or it is a different change

Description

This raises the following limits:

  • Object textures (2048 => unlimited) - TR1 and TR2
  • Sprite textures (512 => unlimited) - TR1 and TR2
  • Texture pages (32 => 128) - TR2

The internal game_buf now also matches TR1 at 128 MB. Object and sprite textures are now allocated in game memory as opposed to keeping two permanent arrays at the maximum size. Texture pages are already using game memory. As an aside, there is a bit of a disjoint in the way we initially process texture pages, mainly because of injections in TR1, so I'll aim to get this behaving more commonly in a follow-up PR.

I've also separated the texture storage/handling from output.c, making split modules here instead. I'm aiming also to get texture pages moved from globals into the new texture module. The split is in its own commit, so this may be best reviewed overall per-commit.

I've tested a level with everything at the maximum and it loads fine. For regular levels, there should be no change.

This raises TR2's game_buf limit to match TR1, at 128 MB.
This moves object texture storage to use game_buf rather than the
regular heap.
This moves sprite texture storage to use game_buf rather than the
regular heap.
@lahm86 lahm86 added Feature New functionality Internal The invisible stuff TR2 TR1 labels Jan 28, 2025
@lahm86 lahm86 self-assigned this Jan 28, 2025
@lahm86 lahm86 requested review from a team as code owners January 28, 2025 15:11
@lahm86 lahm86 requested review from rr-, walkawayy and aredfan and removed request for a team January 28, 2025 15:11
Copy link

github-actions bot commented Jan 28, 2025

@aredfan
Copy link
Collaborator

aredfan commented Jan 28, 2025

Found an issue - the game crashes when I play The Deck (10) or Catacombs of the Talion (13), then use the level skip cheat.

@lahm86
Copy link
Collaborator Author

lahm86 commented Jan 28, 2025

Thanks @aredfan, fixed.

@rr- I've added an Output_UnloadBackground call when unloading a level, I think we were using the previous level's object texture in some cases, so because we're now clearing out the array this was a null. Maybe this call would be better in M_End in the stats phase? Or perhaps flushing it regardless when unloading the level is best as we don't necessarily know the GF sequences that have preceded.

src/libtrx/include/libtrx/game/output/const.h Outdated Show resolved Hide resolved
This splits the output module to keep the texture handling separate.
This removes the cap on object and sprite textures in TR1 and TR2, and
raises the TR2 page limit to 128.

Resolves LostArtefacts#1795.
Resolves LostArtefacts#1796.
@rr-
Copy link
Collaborator

rr- commented Jan 28, 2025

@rr- I've added an Output_UnloadBackground call when unloading a level, I think we were using the previous level's object texture in some cases, so because we're now clearing out the array this was a null. Maybe this call would be better in M_End in the stats phase? Or perhaps flushing it regardless when unloading the level is best as we don't necessarily know the GF sequences that have preceded.

Apologies – I missed your comment earlier. I think that normally, the module that loads the backgrounds should also be the one to unload them. The O_INV_BACKGROUND does stand out as a special case, but unloading it from Level_Unload() could unintentionally impact other types of backgrounds, like image-based ones. This might not cause noticeable issues to the player, but it does result in a bit chaotic dependencies.

Having Phase_End always handle background unloading could be a better approach, but it's not perfect either. On reflection, even the current setup is a bit shaky – phasers using backgrounds assume these will not be changed, not even by nested phasers. To deal with this, they'd need to manage changes during suspend/resume routines, likely by checking what the current background is.

With all that in mind, how do you feel about adding a function to check the background type, then unloading it only if it's INV_BACKGROUND_OBJECT during the object/texture unloading process?

This avoids the background being retained across levels potentially.
@lahm86
Copy link
Collaborator Author

lahm86 commented Jan 28, 2025

Thanks, I've added this check now. LMK if this looks OK.
@aredfan looks OK to me in-game, but would appreciate a second quick test if you get a chance.

@lahm86 lahm86 requested review from aredfan and rr- January 28, 2025 17:11
Copy link
Collaborator

@aredfan aredfan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aredfan looks OK to me in-game, but would appreciate a second quick test if you get a chance.

Of course. 👍

I can confirm all the OG levels are loading properly, LGTM.

@lahm86 lahm86 merged commit 763eae7 into LostArtefacts:develop Jan 28, 2025
8 checks passed
@lahm86 lahm86 deleted the raise-tex-limits branch January 28, 2025 17:44
@@ -11,7 +11,8 @@
- added exit fade-out effects (#2348)
- added optional dynamic lighting for gun flashes and explosions, similar to TR2+ (#2357)
- ⚠️ changed the game data to use a separate strings file for text information, removing it from the game flow file
- changed the sprite limit from 512 to 1024
- changed the sprite texture limit from 2048 to unlimited (within game's overall memory cap)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lahm86 @rr- this first TR1 changelog entry should say object texture limit I believe. I think it's wrong in develop currently.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. I can fix in the next texture PR. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New functionality Internal The invisible stuff TR1 TR2
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Feature request: raise texture page limit Feature request: raise texture info limit
4 participants