forked from Misaki/GhostEngine
Refactor RenderGraph barrier/state tracking system
Major overhaul of resource barrier and state tracking in RenderGraph: - Introduce ResourceBarrierData for explicit (layout, access, sync) tracking. - Separate aliasing and transition barriers; explicit aliasing support. - Remove BufferHint; infer buffer usage from BufferUsage flags. - Update TextureAccess/BufferAccess to include usage requirements. - Improve enums (BarrierSync, BarrierAccess, BarrierLayout) for D3D12 alignment. - Update D3D12CommandBuffer to use new barrier data and error handling. - Make D3D12DescriptorHeap a class; add ReleaseSampler to IResourceDatabase. - Reset resource pools and aliasing managers each frame. - Batch and flush barriers efficiently per pass. - Update HLSL mesh shader macros to [NumThreads]. - Remove obsolete code and improve documentation. This refactor improves correctness, extensibility, and prepares for advanced features.
This commit is contained in:
@@ -168,7 +168,7 @@ internal sealed class RenderGraphResourceRegistry
|
||||
}
|
||||
}
|
||||
|
||||
public void BeginFrame()
|
||||
public void Reset()
|
||||
{
|
||||
// Return all resources to pool
|
||||
for (var i = 0; i < _resources.Count; i++)
|
||||
@@ -179,13 +179,30 @@ internal sealed class RenderGraphResourceRegistry
|
||||
_resources.Clear();
|
||||
}
|
||||
|
||||
public Identifier<RGTexture> ImportTexture(ref readonly TextureDesc desc, Handle<Texture> texture, string name)
|
||||
public Identifier<RGTexture> ImportTexture(ref readonly TextureDesc desc, Handle<Texture> texture, string name,
|
||||
Color128 clearColor, float clearDepth, byte clearStencil,
|
||||
bool clearAtFirstUse, bool discardAtLastUse)
|
||||
{
|
||||
var resource = _pool.Rent<RenderGraphResource>();
|
||||
resource.name = name;
|
||||
resource.type = RenderGraphResourceType.Texture;
|
||||
resource.index = _resources.Count;
|
||||
resource.rgTextureDesc = RGTextureDesc.FromTextureDesc(in desc);
|
||||
resource.rgTextureDesc = new RGTextureDesc
|
||||
{
|
||||
sizeMode = RGTextureSizeMode.Absolute,
|
||||
width = desc.Width,
|
||||
height = desc.Height,
|
||||
format = desc.Format,
|
||||
clearColor = clearColor,
|
||||
clearDepth = clearDepth,
|
||||
clearStencil = clearStencil,
|
||||
clearAtFirstUse = clearAtFirstUse,
|
||||
discardAtLastUse = discardAtLastUse,
|
||||
dimension = desc.Dimension,
|
||||
mipLevels = desc.MipLevels,
|
||||
slice = desc.Slice,
|
||||
usage = desc.Usage
|
||||
};
|
||||
resource.isImported = true;
|
||||
resource.backingResource = texture.AsResource();
|
||||
resource.resolvedWidth = desc.Width;
|
||||
|
||||
Reference in New Issue
Block a user