mirror of
https://github.com/Facepunch/sbox-public.git
synced 2025-12-23 22:48:07 -05:00
* Stop generating solutions via -test flag add -generatesolution * Add TestAppSystem remove Application.InitUnitTest Avoids some hacks and also makes sure our tests are as close to a real AppSystem as possible. * Add shutdown unit test shuts down an re-inits the engine * Properly dispose native resources hold by managed during shutdown Should fix a bunch of crashes * Fix filesystem and networking tests * StandaloneTest does proper Game Close * Make sure package tests clean up properly * Make sure menu scene and resources are released on shutdown * Report leaked scenes on shutdown * Ensure DestroyImmediate is not used on scenes * Fix unmounting in unit tests not clearing native refs * Force destroy native resource on ResourceLib Clear
53 lines
2.0 KiB
C#
53 lines
2.0 KiB
C#
using NativeEngine;
|
|
using System.Collections.Concurrent;
|
|
|
|
namespace Sandbox.Rendering;
|
|
|
|
internal partial class RenderPipeline
|
|
{
|
|
static ConcurrentQueue<RenderPipeline> Pool = new();
|
|
static ConcurrentDictionary<IntPtr, RenderPipeline> ActivePipelines = new();
|
|
|
|
internal static void InternalAddLayersToView( ISceneView view, RenderViewport viewport, SceneViewRenderTargetHandle rtColor, SceneViewRenderTargetHandle rtDepth, RenderMultisampleType nMSAA, CRenderAttributes pipelineAttrs, RenderViewport screenSize )
|
|
{
|
|
// Grab a pooled RenderPipeline, it just needs to be a unique one per render view
|
|
if ( !Pool.TryDequeue( out var renderPipeline ) )
|
|
renderPipeline = new();
|
|
|
|
ActivePipelines.TryAdd( view.self, renderPipeline );
|
|
renderPipeline.AddLayersToView( view, viewport, rtColor, rtDepth, nMSAA, pipelineAttrs, screenSize );
|
|
}
|
|
|
|
// Invoked after native side is done adding layers
|
|
// This can be moved to AddLayersToView once the entire pipeline is in C#
|
|
internal static void InternalPipelineEnd( ISceneView view, RenderViewport viewport, SceneViewRenderTargetHandle rtColor, SceneViewRenderTargetHandle rtDepth, RenderMultisampleType nMSAA, CRenderAttributes pipelineAttrs, RenderViewport screenSize )
|
|
{
|
|
// At this point a pipeline for this view should already exist, grab it
|
|
if ( !ActivePipelines.TryGetValue( view.self, out var renderPipeline ) )
|
|
return;
|
|
|
|
renderPipeline.PipelineEnd( view, viewport, rtColor, rtDepth, nMSAA, pipelineAttrs, screenSize );
|
|
}
|
|
|
|
/// <summary>
|
|
/// Called once a view has been submitted, which means the entire render pipeline has executed and we don't need the object anymore.
|
|
/// </summary>
|
|
internal static void OnSceneViewSubmitted( ISceneView view )
|
|
{
|
|
// Try, it's okay if it doesn't have anything because it could be a non pipeline (dependent) view
|
|
if ( !ActivePipelines.TryRemove( view.self, out var renderPipeline ) )
|
|
{
|
|
return;
|
|
}
|
|
|
|
// Return to pool
|
|
Pool.Enqueue( renderPipeline );
|
|
}
|
|
|
|
internal static void ClearPool()
|
|
{
|
|
Pool.Clear();
|
|
ActivePipelines.Clear();
|
|
}
|
|
}
|