Commit Graph

10 Commits

Author SHA1 Message Date
Lorenz Junglas
4b09d3dbd9 Fix particle sprite perf regression (#4454)
* Upload SpriteBatchSceneObject buffer inside render context

* Bump particle pool size
2026-04-02 14:03:56 +02:00
Lorenz Junglas
729448dad5 Sprites: only do a single GPU upload rather than one per group. (#4435)
Previously, we would call GPUBuffer.SetData many times through a loop.
This is now replaced by a single call after all sprite groups have been processed.

This reduces GPU fencing and CPU -> GPU transfer overhead.
2026-04-01 18:53:37 +02:00
Lorenz Junglas
26eebeb1c4 Calculate sprite batch bounds in parallel (#4318)
* Calculate sprite batch bounds in parallel

* Particle sprites pass bounds so we dont have to recalculate them

* Account for pivot when calculating bounds

* Use empty bbox isntead of infinite bounds for spriteless groups
2026-03-17 15:00:28 +01:00
Carson Kompon
58622852f8 Fix SpriteRenderers sorting improperly against other renderers (like TextRenderer) (#4298)
BEFORE:
https://files.facepunch.com/CarsonKompon/2026/March/13_11-37-EllipticalMongoose.mp4
AFTER:
https://files.facepunch.com/CarsonKompon/2026/March/13_11-33-EarnestAdeliepenguin.mp4
2026-03-16 08:34:16 -04:00
Lorenz Junglas
54932b6725 (Shutdown) Leak Fixes (#4242)
* Remove unnecessary static singletons in MainMenu code

* Empty SceneWorld delete queues during shutdown

* Dresser cancel async load operation on destroy

* Use reflection to null references to static native resources on shutdown

This way we don't  have to remember doing this manually.

* Fix SoundOcclusionSystem using static lists to reference resources

* Sound System: Use weak references to refer to scenes

* Cleanup static logging listeners that kept strong refs to panels

* UISystem Cleanup, make sure all panel/stylesheet refs are released

* RenderTarget and RenderAttributes shutdown cleanup

* Rework AvatarLoader, ThumbLoader & HTTPImageLoader Cache

First try to go through ResourceLibrary.WeakIndex which might already hold the texture.

If there is no hit, go through a second cache that caches HTTP & Steam API response bytes instead of textures.
We want to cache the response bytes rather than the actual Texture, so stuff cached sits in RAM not VRAM.
Before avatars and thumbs would reside in VRAM.

* Fix rendertarget leak in CommandList.Attr.SetValue

GetDepthTarget() / GetColorTarget() return a new strong handle (ref count +1).
We need to DestroyStrongHandle()  that ref. So handles don't leak.

* Call EngineLoop.DrainFrameEndDisposables before shutdown

* NativeResourceCache now report leaks on shutdown

* Override Resource.Destroy for native resources, kill stronghandles

* Deregister SceneWorld from SceneWorld.All during destruction

* Ensure async texture loading cancels on shutdown

* SkinnedModelRender bonemergetarget deregister from target OnDisabled

* Clear shaderMaterials cache during shutdown

* Refactor Shutdown code

Mostly renaming methods from Clear() -> Shutdown()
Adding separate GlobalContext.Shutdown function (more aggressive than GlobalContext.Reset).
Clear some static input state.

* Deregister surfaces from Surface.All in OnDestroy

* RunAllStaticConstructors when loading a mount

* Advanced managed resource leak tracker enabled via `resource_leak_tracking 1`

Works by never pruning the WeakTable in NativeResourceCache.
So we can check for all resources if they are still being held on to and log a callstack.
2026-03-09 17:02:27 +01:00
ryleigh
074263fddb Add Snap To Frame option for particle sheet sequences (#3821) 2026-01-21 10:06:51 -08:00
Lorenz Junglas
12affe5ccb Reduce material creations/allocations (#3766)
* Make SpriteBatchSceneObject shaders static, so we don't create them per instance

* Avoid per frame shader/material creation in PostProcessing

* Avoid per frame shader/material creation in HudPainter

* Move a few more compute shaders into static members

* Reduce allocations in NormalizeFilename

* Reduce string allocations in Material.FromShader
2026-01-14 08:40:37 +01:00
Antoine Pilote
924bbb3fa9 Added sprite alpha cutout (#3667)
* Added AlphaCutout setting to opaque sprite

* Just store as uint and cast back to float when necessary, simpler that way

https://files.facepunch.com/antopilo/1b2311b1/sbox-dev_wEBQHQosGe.mp4

* Rename fogStrength var to packedFogAndAlpha

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Fix typo by copilot preventing from compiling

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-05 07:50:31 -08:00
Antoine Pilote
9331f2bffa Fixed opaque & non-opaque sprite sorting (#3660) 2025-12-22 16:29:31 -08:00
s&box team
71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00