Added a new `Ref<T>` struct for reference semantics. Added the `RenderGraph` system for managing rendering passes. Added the `RenderTexture` class for encapsulating GPU resources. Added `GraphicsBuffer` class for effective GPU resource management. Changed `CommandList` methods from public to internal for visibility control. Changed `IRenderPass` interface from internal to public for accessibility. Changed `GetData<T>()` in `ComponentObject.cs` to return `CompRef<T>`. Changed `GetComponent<T>()` in `EntityManager.cs` to return `CompRef<T>`. Changed `GetSingleton<T>()` in `World.cs` to use `CompRef<T>`. Changed `IQueryTypeParameter` to use `CompRef<T>` for consistency. Changed `QueryItem<T0>` and related structs to use `CompRef<T>`. Changed `Material` class to support bindless textures. Changed `Shader` class to support bindless rendering. Changed `Mesh` class to support bindless vertex and index buffer access. Updated documentation to reflect the new bindless rendering architecture.
122 lines
3.2 KiB
C#
122 lines
3.2 KiB
C#
using Win32.Graphics.Direct3D12;
|
|
|
|
namespace Ghost.Graphics.RenderGraphModule;
|
|
|
|
/// <summary>
|
|
/// Handle for render graph texture resource
|
|
/// </summary>
|
|
public readonly struct RGTextureHandle : IEquatable<RGTextureHandle>
|
|
{
|
|
internal readonly RenderGraph? _renderGraph;
|
|
internal readonly int _resourceId;
|
|
|
|
internal RGTextureHandle(int resourceId, RenderGraph renderGraph)
|
|
{
|
|
_resourceId = resourceId;
|
|
_renderGraph = renderGraph;
|
|
}
|
|
|
|
public bool IsValid => _resourceId >= 0 && _renderGraph != null;
|
|
|
|
public bool Equals(RGTextureHandle other)
|
|
{
|
|
return _resourceId == other._resourceId && ReferenceEquals(_renderGraph, other._renderGraph);
|
|
}
|
|
|
|
public override bool Equals(object? obj)
|
|
{
|
|
return obj is RGTextureHandle other && Equals(other);
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
return HashCode.Combine(_resourceId, _renderGraph);
|
|
}
|
|
|
|
public static bool operator ==(RGTextureHandle left, RGTextureHandle right)
|
|
{
|
|
return left.Equals(right);
|
|
}
|
|
|
|
public static bool operator !=(RGTextureHandle left, RGTextureHandle right)
|
|
{
|
|
return !(left == right);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Handle for render graph buffer resource
|
|
/// </summary>
|
|
public readonly struct RGBufferHandle : IEquatable<RGBufferHandle>
|
|
{
|
|
internal readonly RenderGraph? _renderGraph;
|
|
internal readonly int _resourceId;
|
|
|
|
internal RGBufferHandle(int resourceId, RenderGraph renderGraph)
|
|
{
|
|
_resourceId = resourceId;
|
|
_renderGraph = renderGraph;
|
|
}
|
|
|
|
public bool IsValid => _resourceId >= 0 && _renderGraph != null;
|
|
|
|
public bool Equals(RGBufferHandle other)
|
|
{
|
|
return _resourceId == other._resourceId && ReferenceEquals(_renderGraph, other._renderGraph);
|
|
}
|
|
|
|
public override bool Equals(object? obj)
|
|
{
|
|
return obj is RGBufferHandle other && Equals(other);
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
return HashCode.Combine(_resourceId, _renderGraph);
|
|
}
|
|
|
|
public static bool operator ==(RGBufferHandle left, RGBufferHandle right)
|
|
{
|
|
return left.Equals(right);
|
|
}
|
|
|
|
public static bool operator !=(RGBufferHandle left, RGBufferHandle right)
|
|
{
|
|
return !(left == right);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Resource access information for dependency tracking
|
|
/// </summary>
|
|
internal readonly struct ResourceAccess
|
|
{
|
|
public readonly int resourceId;
|
|
public readonly int passIndex;
|
|
public readonly ResourceAccessType accessType;
|
|
|
|
public ResourceAccess(int resourceId, ResourceAccessType accessType, int passIndex)
|
|
{
|
|
this.resourceId = resourceId;
|
|
this.accessType = accessType;
|
|
this.passIndex = passIndex;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Represents a barrier to be executed for resource state transitions
|
|
/// </summary>
|
|
internal readonly struct RenderGraphBarrier
|
|
{
|
|
public readonly int resourceId;
|
|
public readonly ResourceStates stateBefore;
|
|
public readonly ResourceStates stateAfter;
|
|
|
|
public RenderGraphBarrier(int resourceId, ResourceStates stateBefore, ResourceStates stateAfter)
|
|
{
|
|
this.resourceId = resourceId;
|
|
this.stateBefore = stateBefore;
|
|
this.stateAfter = stateAfter;
|
|
}
|
|
}
|