mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-08-01 00:08:05 -04:00
* Add Texture Pool section to shadow debug https://files.facepunch.com/lolleko/2026/April/13_16-21-UsedRook.png Shows of orphaned textures (in flight stat keeps growing. * Return shadow map to pool when light is destroyed https://files.facepunch.com/lolleko/2026/April/13_16-24-ClutteredCooter.png * Use Queue instead of Stack for shadow texture pool eviction We want FIFO semantics instead of LIFO. Stack (LIFO) buried old textures under newer ones, potentially preventing disposal * Remove unused OnLightRemoved callback
29 lines
1.3 KiB
C#
29 lines
1.3 KiB
C#
using NativeEngine;
|
|
using System.Collections.Concurrent;
|
|
|
|
namespace Sandbox.Rendering;
|
|
|
|
/// <summary>
|
|
/// Stupid class for native to call, instances a shadowmapper per lightbinner
|
|
/// </summary>
|
|
internal static class ShadowMapperCallbacks
|
|
{
|
|
/// <summary>
|
|
/// Each pooled lightbinner gets a shadowmapper, use the lightbinner ptr as a handle.. probably fine
|
|
/// There's only gonna be a handful of these
|
|
/// </summary>
|
|
static ConcurrentDictionary<IntPtr, ShadowMapper> ShadowMappers = [];
|
|
|
|
static ShadowMapper Get( IntPtr pLightMapper ) => ShadowMappers.GetOrAdd( pLightMapper, _ => new() );
|
|
|
|
internal static void InitForView( IntPtr handle, ISceneView sceneView ) => Get( handle ).InitForView( sceneView );
|
|
internal static void SetShaderAttributes( IntPtr handle, CRenderAttributes renderAttr )
|
|
{
|
|
Get( handle ).SetShaderAttributes( new RenderAttributes( renderAttr ) );
|
|
}
|
|
|
|
internal static void UploadToGPU( IntPtr handle ) => Get( handle ).UploadToGPU();
|
|
internal static uint FindOrCreateShadowMaps( IntPtr handle, SceneLight sceneObject, ISceneView view, float flScreenSize ) => Get( handle ).FindOrCreateShadowMaps( sceneObject, view, flScreenSize );
|
|
internal static int DoDirectionalLight( IntPtr handle, SceneLight sceneObject, ISceneView view ) => Get( handle ).DoDirectionalLight( sceneObject, view );
|
|
}
|