feat(render): per-frame render requests & thread safety

Refactor RenderSystem to store render requests per-frame within FrameResource, improving encapsulation and resource management. Update render loop and AddRenderRequest to use the new structure, ensuring proper disposal and clearing of requests to prevent memory leaks. Remove the old global renderRequests array and update Dispose logic accordingly.

Add spin lock-based thread safety to D3D12ResourceDatabase for AddResource/AddAllocation, and introduce EnterParallelRead/ExitParallelRead methods for explicit locking.

Enhance RenderExtractionSystem and Material to support transparent render lists and a MaterialRenderType property, preparing for advanced rendering features. Includes minor code cleanups and comment improvements.
This commit is contained in:
2026-03-24 16:46:30 +09:00
parent d44ec0be31
commit 92e3d33361
8 changed files with 128 additions and 70 deletions

View File

@@ -93,8 +93,9 @@ public class RenderExtractionSystem : ISystem
var rtSize = new uint2(rtResult.Value.TextureDescription.Width, rtResult.Value.TextureDescription.Height);
var aspectScreen = (float)rtSize.x / rtSize.y;
var renderList = new RenderList(1, 64, Allocator.Temp);
var shadowCasterRenderList = new RenderList(1, 64, Allocator.Temp);
var renderList = new RenderList(1, 64, Allocator.FreeList);
var transparentRenderList = new RenderList(1, 64, Allocator.FreeList);
var shadowCasterRenderList = new RenderList(1, 64, Allocator.FreeList);
// TODO: This chould be done in parallel jobs.
foreach (var chunk in meshQuery.GetChunkIterator())
@@ -213,7 +214,7 @@ public class RenderExtractionSystem : ISystem
depthTarget = camRef.depthTarget,
opaqueRenderList = renderList,
shadowCasterRenderList = shadowCasterRenderList,
transparentRenderList = default,
transparentRenderList = default, // TODO: Classify transparent objects into a separate render list and render via oit.
renderFunc = camRef.renderFunc,
view = new RenderView
{