Skip to content

Conversation

@Wartori54
Copy link
Member

@Wartori54 Wartori54 commented Nov 30, 2025

As the title suggests, this PR attempts to rewrite the entirety of the good old FTL, into a more maintainable and future proof codebase, splitting code into a new class TextureContentHelper to keep file sizes small.
The main intention of this PR is to make VirtualTexture fully thread safe, and re-enginneer an implementation of FTL.

For context FTL has simply the following goal: decode the texture data from disk to a CPU buffer asynchronously, then upload to GPU memory on the main thread. This speeds up loading times and fixes some crashes on Nvidia gpus. Theres a writeup about most of the significant FTL details at the top of the VirtualTexture file diving deep into this and other topics.

As for performance, it should be on par, this PR does not have any intentional speed improvements (in fact, it may be slower due to the heavier synchronization in VirtualTexture but it should be fairly small). I have some plans and some ongoing tests to improve performance and bound memory usage even lower, but those will land in a follow up PR once ready that will build off of this one. (Runtime atlasing is still on the TODO list, I did not forget!)

Finally CI will fail, specifically the SJ TAS test since this is breaking for CollabUtils2. Luckily that mod has been updated already to be compatible and the only required extra steps for local testing are: clone the repo and dotnet build -c Release; mostly because it has not yet been released on gamebanana.
An update has been pushed to CollabUtils2 making it compatible with the changes of this PR.

@maddie480-bot maddie480-bot added the review needed This PR needs 2 approvals to be merged (bot-managed) label Nov 30, 2025
Copy link
Member

@microlith57 microlith57 left a comment

Choose a reason for hiding this comment

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

first pass, picking the low hanging fruit first! nothing here is blocking

@Wartori54
Copy link
Member Author

@microlith57 all feedback has been addressed!

@maddie480
Copy link
Member

/azp run

Copy link
Contributor

@DashingCat DashingCat left a comment

Choose a reason for hiding this comment

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

Tested on Linux and works as expected, without significant changes in loading times compared to the previous "Fast Texture Loading" implementation.

[SettingNeedsRelaunch]
[SettingInGame(false)]
[SettingIgnore] // TODO: Show as advanced setting.
public bool? FastTextureLoadingPoolUseGC { get; set; } = null;
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe FastTextureLoadingPoolUseGC should be a bool instead of a bool?, as both null and false are equivalent when using the property in Celeste.Mod.mm/Mod/Helpers/TextureContentHelper.cs.

Copy link
Member Author

Choose a reason for hiding this comment

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

The idea behind having a default third state is the ability to change what it actually defaults to if we ever need to, because if the default were to be false we would not be able to switch all the users who didn't manually disable the feature (since we could not distinguish that).
And if you look further _FastTextureLoading and ThreadedGL have been doing this for a while now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review needed This PR needs 2 approvals to be merged (bot-managed)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants