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:
@@ -225,29 +225,6 @@ public struct RGTextureDesc : IEquatable<RGTextureDesc>
|
||||
usage = TextureUsage.DepthStencil | TextureUsage.ShaderResource
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an RGTextureDesc from an RHI TextureDesc (for imported textures).
|
||||
/// </summary>
|
||||
public static RGTextureDesc FromTextureDesc(in TextureDesc desc)
|
||||
{
|
||||
return new RGTextureDesc
|
||||
{
|
||||
sizeMode = RGTextureSizeMode.Absolute,
|
||||
width = desc.Width,
|
||||
height = desc.Height,
|
||||
format = desc.Format,
|
||||
clearColor = default,
|
||||
clearDepth = 1.0f,
|
||||
clearStencil = 0,
|
||||
clearAtFirstUse = false,
|
||||
discardAtLastUse = false,
|
||||
dimension = desc.Dimension,
|
||||
mipLevels = desc.MipLevels,
|
||||
slice = desc.Slice,
|
||||
usage = desc.Usage
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -342,131 +319,37 @@ public static class RGResourceExtensions
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hints for how a buffer will be used in a pass.
|
||||
/// Used to determine correct resource state transitions.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum BufferHint
|
||||
{
|
||||
/// <summary>
|
||||
/// No special usage - buffer will be used as shader resource (SRV) or UAV based on AccessFlags.
|
||||
/// </summary>
|
||||
None = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Buffer will be used as indirect argument buffer (ExecuteIndirect).
|
||||
/// Requires ResourceState.IndirectArgument.
|
||||
/// </summary>
|
||||
IndirectArgument = 1 << 0,
|
||||
}
|
||||
|
||||
internal readonly struct TextureAccess
|
||||
{
|
||||
public readonly Identifier<RGTexture> id;
|
||||
public readonly AccessFlags accessFlags;
|
||||
public readonly ResourceBarrierData usage;
|
||||
|
||||
public TextureAccess(Identifier<RGTexture> id, AccessFlags accessFlags)
|
||||
public TextureAccess(Identifier<RGTexture> id, AccessFlags accessFlags, ResourceBarrierData usage)
|
||||
{
|
||||
this.id = id;
|
||||
this.accessFlags = accessFlags;
|
||||
this.usage = usage;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tracks buffer access information including usage hints.
|
||||
/// Tracks buffer access information.
|
||||
/// </summary>
|
||||
internal readonly struct BufferAccess
|
||||
{
|
||||
public readonly Identifier<RGBuffer> id;
|
||||
public readonly AccessFlags accessFlags;
|
||||
public readonly BufferHint hint;
|
||||
public readonly ResourceBarrierData usage;
|
||||
|
||||
public BufferAccess(Identifier<RGBuffer> id, AccessFlags accessFlags, BufferHint hint = BufferHint.None)
|
||||
public BufferAccess(Identifier<RGBuffer> id, AccessFlags accessFlags, ResourceBarrierData usage)
|
||||
{
|
||||
this.id = id;
|
||||
this.accessFlags = accessFlags;
|
||||
this.hint = hint;
|
||||
this.usage = usage;
|
||||
}
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// Descriptor for creating a texture resource.
|
||||
///// </summary>
|
||||
//public readonly struct TextureDescriptor : IEquatable<TextureDescriptor>
|
||||
//{
|
||||
// public readonly int width;
|
||||
// public readonly int height;
|
||||
// public readonly TextureFormat format;
|
||||
// public readonly string name;
|
||||
|
||||
// public TextureDescriptor(int width, int height, TextureFormat format, string name)
|
||||
// {
|
||||
// this.width = width;
|
||||
// this.height = height;
|
||||
// this.format = format;
|
||||
// this.name = name;
|
||||
// }
|
||||
|
||||
// public readonly bool Equals(TextureDescriptor other)
|
||||
// {
|
||||
// return width == other.width &&
|
||||
// height == other.height &&
|
||||
// format == other.format &&
|
||||
// name == other.name;
|
||||
// }
|
||||
|
||||
// public override readonly bool Equals(object? obj) => obj is TextureDescriptor other && Equals(other);
|
||||
// public override readonly int GetHashCode() => HashCode.Combine(width, height, format, name);
|
||||
|
||||
// public static bool operator ==(TextureDescriptor left, TextureDescriptor right)
|
||||
// {
|
||||
// return left.Equals(right);
|
||||
// }
|
||||
|
||||
// public static bool operator !=(TextureDescriptor left, TextureDescriptor right)
|
||||
// {
|
||||
// return !(left == right);
|
||||
// }
|
||||
//}
|
||||
|
||||
//public readonly struct BufferDescriptor : IEquatable<BufferDescriptor>
|
||||
//{
|
||||
// public readonly uint sizeInBytes;
|
||||
// public readonly uint stride;
|
||||
// public readonly BufferUsage usage;
|
||||
// public readonly string name;
|
||||
|
||||
// public BufferDescriptor(uint sizeInBytes, uint stride, BufferUsage usage, string name)
|
||||
// {
|
||||
// this.sizeInBytes = sizeInBytes;
|
||||
// this.stride = stride;
|
||||
// this.usage = usage;
|
||||
// this.name = name;
|
||||
// }
|
||||
|
||||
// public readonly bool Equals(BufferDescriptor other)
|
||||
// {
|
||||
// return sizeInBytes == other.sizeInBytes &&
|
||||
// stride == other.stride &&
|
||||
// usage == other.usage &&
|
||||
// name == other.name;
|
||||
// }
|
||||
|
||||
// public override readonly bool Equals(object? obj) => obj is BufferDescriptor other && Equals(other);
|
||||
// public override readonly int GetHashCode() => HashCode.Combine(sizeInBytes, name);
|
||||
|
||||
// public static bool operator ==(BufferDescriptor left, BufferDescriptor right)
|
||||
// {
|
||||
// return left.Equals(right);
|
||||
// }
|
||||
|
||||
// public static bool operator !=(BufferDescriptor left, BufferDescriptor right)
|
||||
// {
|
||||
// return !(left == right);
|
||||
// }
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Base interface for pass data that can be stored in the blackboard.
|
||||
/// </summary>
|
||||
@@ -497,4 +380,4 @@ internal struct DepthStencilInfo
|
||||
public AttachmentStoreOp storeOp;
|
||||
public float clearDepth;
|
||||
public byte clearStencil;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user