Commit Graph

12 Commits

Author SHA1 Message Date
Sam Pavlovic
2e40e76235 Ambient Occlusion Optimizations (#4099)
* Use Hilbert Index instead of Blue Noise for GTAO, same as the original paper, allows us to have better quality with less work, GTAOPasses::DenoiseSpatial does two pixels for one thread

* Force Float16 for GTAO, good speedups on modern GPUs, default behaviour from reference implementation, do explicit casts to supress warnings

* More accurate MSAAUtils::GetSampleIndex  https://files.facepunch.com/sampavlovic/1b2611b1/image.psd.png

* adjustments

* reduce blending for non-edge pixels to preserve more details instead of using the raw amount at edges

* Early out here, no good way to have a non uniform size dispatch yet, should still keep 2x spatial speedup

* Remove unused comment

* update shaders
2026-04-15 15:42:04 +00:00
Lorenz Junglas
233e2bc313 Add debug name for bloom command list (#4508) 2026-04-09 10:31:50 -07:00
Layla
bbb66e3250 dont use OnDirty, MakeDirty and OnPropertyDirty (#4415) 2026-04-01 07:42:56 +01:00
Lorenz Junglas
2228e4cc4a Vulkan validation error fixes (#4357)
* Added explicit StopCurrentRenderPass() before all transfer ops

vkCmdCopyImage / vkCmdPipelineBarrier / vkCmdBlitImage / vkCmdResolveImage cannot be called inside a render pass and would report VUID-vkCmdXXX-renderpass validation errors

* Only bind RenderTargets when we actually have any

Prevents loading defaults which can cause validation errors

* Add missing state transitions for DoF and Bloom

So they don't interrupt the renderpass with an implicit transition via StopCurrentRenderPass.

* SetupForDraw() early return when render area is 0

Avoid VUID-VkRenderingInfo-None-08994 - Zero-extent render
Happened when minimizing / resizing

* Set correct mip level when binding and transitioning render targets

Could cause  VUID-VkImageMemoryBarrier-oldLayout-01197 for render targets

And VUID-vkCmdDraw-None-09600 when rendering cube maps
2026-03-25 09:33:47 +01: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
Sam Pavlovic
410f18ace9 SSR Optimizations (#4244)
* Start moving SSR to bindless

* Classify pass stub

* Separable bilateral upscale, 0.3ms > 0.08ms, not happy with it still

* start classify and intersect indirect

* Commandlist support for UAV barriers and clearing a texture and gpubuffer

* Simplify this, move classify to it's own shader

* All indirect

* ResourceState.IndirectArgument missing from ResourceStateToVulkanFlags switch

* Fix indirect, all works

* classify doesnt get skybox

* Add Clear method to CommandList for clearing render target colors

* bilateral upscale indirect too

* Cleanup

* Simplify bilateral upscale, With RADIUS=1, separable saves only 3 taps (6 vs 9), but costs 3 barriers + shared memory + atomics — the synchronization overhead far exceeds 3 extra texture loads of doing it with a normal X Y loop

* Dotnet format, increase roughness threshold (we can afford it 😘 ) and dont need to discard these buffers on disable

* compile shaders

* this shouldnt be a property

* Add FillGPUBuffer method for efficient buffer filling using native GPU commands
2026-03-09 03:38:04 +01:00
Lorenz Junglas
747720b309 Fix GTAO depth dispatch size and add missing UAV barriers (#4027)
- Dispatch depth prefilter at half resolution (each thread writes 2x2).
  - Fixes out of bounds reads/writes
  - and reduces unnecessary work.
- Add UAV barriers between compute passes
2026-02-11 11:13:41 +01:00
ryleigh
f229eef8f2 Fix incorrect property summaries (#4014) 2026-02-07 00:29:38 -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
Alex Guthrie
2a235be3f8 Fix AgX (#3574)
Fix AgX tinting by adjusting math, use AgX punchy look
https://files.facepunch.com/alexguthrie/1b0911b1/fixed_agx.png
2025-12-09 03:02:11 +00:00
Sam Pavlovic
920e3760bc Bunch of SSR fixes (#3481)
* Fix SSR not reprojecting correctly and drifting on downsample, reference original code and backport some of the stuff from motion vectors too, major cleanup

* Logic for RenderTarget.GetTemporary probably shouldn't ceil, causes a lot of drifting in SSR even though the logic is correct, can see downsampling up to 10 and still remaining sharp

https://files.facepunch.com/sampavlovic/1b2511b1/sbox-dev_dB9j5ipUTA.mp4

* Barriers are very strict on Intel ARC, make them explicit for SSAO and SSR, while at it make this logic for SSR simpler

For reference this is how it could appear on Intel ARC B580

https://files.facepunch.com/sampavlovic/1b2511b1/sbox-dev_UjkEGVD4k4.mp4

* CommandList.ResourceBarrierTransition for Textures/RenderTargets

* Fix Reflections_GetHitPositionReprojection while being aware of Motion::Get for future Motion Vector API, deal with temporal stability better

https://files.facepunch.com/sampavlovic/1b2811b1/sbox-dev_He8gAbtPau.mp4

* Build shader

* Format
2025-11-28 14:35:05 -03: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