tgstation / rust-g

Rust based libraries for tgstation
MIT License
28 stars 100 forks source link

IconForge - Building spritesheets at the speed of light #160

Closed itsmeow closed 6 months ago

itsmeow commented 10 months ago

Adds IconForge, a new module for building asset spritesheets.

It's over 10x faster than BYOND in some cases. This module just takes a JSON input and spits out a spritesheet to a path, so it's up to the DM side to actually use it correctly, but I've tested it with a branch on Bee: https://github.com/itsmeowForks/BeeStation-Hornet/tree/asset-rustg

It is quite fast. image

I've also added a panic handler to the core rustg module, since this module is.. prone to panicing Not anymore, but it was useful in testing. This should also help diagnose crashes from within rust-g without needing to take minidumps.

In the future I want to add a more advanced caching system to this, but as it is, it's already just a faster replacement for the existing spritesheet generation code in DM, and people are interested, so here it is. The way the JSON input is designed allows you to precisely determine if anything has changed, since it only supports DMI+icon_states and not any BYOND /icons. You can basically just hash everything and compare to get better caching.

Also adds a caching validation tool. This hashes all DMIs within the sprites object and compares them to a previous one provided by DM. It also provides the hashes as the result of the generate() function when prompted. It is up to DM to do the rest, rustg only provides a fast method for comparing the hashes with parallelism.

Cache validation check doesn't cost too much: image

itsmeow commented 10 months ago

Also please be nice, this is my first Rust project ever. I know the code is kinda messy.

itsmeow commented 10 months ago

DNM until https://github.com/spacestation13/dmi-rust/pull/20

itsmeow commented 10 months ago

If you need proof of this thing's pure efficiency, here's a graph comparison on the DM side. image

itsmeow commented 10 months ago

Dependency merged. Finishing up caching stuff. It's a bit of a mess, honestly. I wish this module wasn't so opinionated, but that is why it's optional.

itsmeow commented 10 months ago

This PR is now feature complete.

itsmeow commented 10 months ago

This is only failing build because rust added a new lint that affects the hash module.

itsmeow commented 10 months ago

OpenDream hast mislead my blending again. 😔

itsmeow commented 10 months ago

I have a branch implementing GAGS into iconforge, although I'd prefer it to be part of another PR. Should I just push it here or wait for merge? It's just one commit atm.

optimumtact commented 7 months ago

@ZeWaka is there a reason this isn't merge yet

ZeWaka commented 7 months ago

@ZeWaka is there a reason this isn't merge yet

Waiting on me to do a final review early this week per my comment yesterday in tooling questions

ZeWaka commented 7 months ago

i would update the build fails but you are cringe and don't let me push to your branch

itsmeow commented 7 months ago

sorries

ZeWaka commented 7 months ago

https://github.com/BeeStation/BeeStation-Hornet/pull/10404 https://github.com/BeeStation/BeeStation-Hornet/pull/10615

AffectedArc07 commented 6 months ago

Cannot wait for an implementation of this, please @ me with the PR when its done.

itsmeow commented 6 months ago

Cannot wait for an implementation of this, please @ me with the PR when its done.

On TG? I've already implemented it on Bee, the PRs are mentioned above.

itsmeow commented 5 months ago

One more relevant PR if anyone was going to port btw: https://github.com/BeeStation/BeeStation-Hornet/pull/10649