feat(d3d12): unify resource mgmt & add pooling system

Refactored D3D12 resource and command management with a new D3D12Object<T> base class for unified lifetime and naming of COM objects. Introduced pooled command buffer and resource management in D3D12GraphicsEngine and ResourceManager, using frame-based return queues for safe reuse. Updated RenderSystem to use pooled command buffers and render requests, and to properly dispose of per-frame resources. Changed frame synchronization and resource release logic to use ulong fence/frame values for improved robustness. Refactored swap chain to DXGISwapChain and improved error handling and code clarity. Removed renderer management from IGraphicsEngine. Changed ResourceDesc, TextureDesc, and BufferDesc to record structs with equality and hashing for pooling.

BREAKING CHANGE: Renderer management APIs removed from IGraphicsEngine. Frame and resource synchronization now use ulong instead of uint. Resource pooling and command buffer pooling are now required for correct usage.
This commit is contained in:
2026-03-23 20:48:08 +09:00
parent 2b3bf21a74
commit d44ec0be31
22 changed files with 623 additions and 440 deletions

View File

@@ -627,7 +627,7 @@ public struct BarrierDesc
}
}
public struct ResourceDesc
public record struct ResourceDesc
{
[StructLayout(LayoutKind.Explicit)]
internal struct resource_union
@@ -638,7 +638,7 @@ public struct ResourceDesc
public BufferDesc bufferDescription;
}
internal resource_union _desc;
private resource_union _desc;
public ResourceType Type
{
@@ -682,6 +682,31 @@ public struct ResourceDesc
TextureDescription = desc
};
}
public bool Equals(ResourceDesc other)
{
if (Type != other.Type)
{
return false;
}
return Type switch
{
ResourceType.Texture => TextureDescription.Equals(other.TextureDescription),
ResourceType.Buffer => BufferDescription.Equals(other.BufferDescription),
_ => throw new InvalidOperationException($"Unknown resource type: {Type}")
};
}
public override int GetHashCode()
{
return Type switch
{
ResourceType.Texture => HashCode.Combine(Type, TextureDescription),
ResourceType.Buffer => HashCode.Combine(Type, BufferDescription),
_ => throw new InvalidOperationException($"Unknown resource type: {Type}")
};
}
}
/// <summary>
@@ -831,7 +856,7 @@ public struct RenderTargetDesc
/// <summary>
/// Texture description
/// </summary>
public struct TextureDesc
public record struct TextureDesc
{
/// <summary>
/// Width of the texture
@@ -939,7 +964,7 @@ public record struct SamplerDesc
}
}
public struct BufferDesc
public record struct BufferDesc
{
public ulong Size
{