Refactor graphics architecture and resource management

Added DescriptorAllocator.cs to manage descriptor allocations for Direct3D 12.
Added Texture2D.cs to handle 2D textures and GPU resource creation.
Added DescriptorAllocatorExample.cs to demonstrate the new descriptor allocator interface.

Changed project files to reference Misaki.HighPerformance.LowLevel instead of Misaki.HighPerformance.Unsafe.
Changed _renderView type from IRenderer? to Renderer? in ScenePage.xaml.cs.
Changed EngineCore.cs to remove explicit graphics API specification during initialization.
Changed Logger.cs to enhance the Assert method with a DoesNotReturnIf attribute.
Changed resource types in Mesh.cs from IResource to GraphicsResource.

Removed multiple interfaces including ICommandBuffer, IDebugLayer, IGraphicsDevice, IPipelineResource, IRenderPass, IRenderer, IResource, and IResourceAllocator to simplify the graphics architecture.
Removed D3D12DebugLayer class from DebugLayer.cs to streamline the debug layer implementation.

Updated CommandList.cs and D3D12CommandBuffer.cs to implement a new command list structure for Direct3D 12.
Updated Material.cs to improve handling of constant buffers and textures.
Updated Shader.cs to include new structures for texture and property information.
Updated GraphicsPipeline.cs to support the new graphics device and resource management system.
Updated UnitTestAppWindow.xaml.cs to reflect changes in the renderer type and ensure proper resource management.
Updated BindlessMeshRenderPass.cs and MeshRenderPass.cs to implement modern rendering techniques, including bindless textures and improved shader management.
Updated CBufferCache.cs to align with the new resource management system and improve memory handling.
This commit is contained in:
2025-07-12 01:20:04 +09:00
parent eed1b9d3d0
commit 1284bb17de
38 changed files with 2831 additions and 517 deletions

View File

@@ -1,14 +0,0 @@
using Ghost.Graphics.Data;
using Win32.Graphics.Direct3D12;
namespace Ghost.Graphics.Contracts;
public interface ICommandBuffer
{
// TODO: They should be internal, maybe an interface ICommandBufferInternal?
public void BarrierTransition(IResource resource, ResourceStates beforeState, ResourceStates afterState);
public void SetGraphicsRootConstantBufferView(uint slot, ulong gpuAddress);
public void DrawMesh(Mesh mesh, Material material);
public void CopyResource(IResource dstResource, uint dstOffset, IResource srcResource, uint srcOffset, uint size);
}

View File

@@ -1,5 +0,0 @@
namespace Ghost.Graphics.Contracts;
internal interface IDebugLayer : IDisposable
{
}

View File

@@ -1,20 +0,0 @@
using Ghost.Graphics.Data;
namespace Ghost.Graphics.Contracts;
internal interface IGraphicsDevice : IDisposable
{
public static abstract GraphicsAPI TargetAPI
{
get;
}
public ReadOnlySpan<IRenderer> Renderers
{
get;
}
public IRenderer CreateRenderer(in SwapChainPresenter swapChainSurface);
public void RemoveRenderer(IRenderer renderer);
public void InitializePendingRenderers();
}

View File

@@ -1,5 +0,0 @@
namespace Ghost.Graphics.Contracts;
internal interface IPipelineResource : IDisposable
{
}

View File

@@ -1,7 +1,9 @@
namespace Ghost.Graphics.Contracts;
using Ghost.Graphics.D3D12;
namespace Ghost.Graphics.Contracts;
internal interface IRenderPass : IDisposable
{
void Initialize(ICommandBuffer cmb);
void Execute(ICommandBuffer cmb);
void Initialize(CommandList cmd);
void Execute(CommandList cmd);
}

View File

@@ -1,39 +0,0 @@
namespace Ghost.Graphics.Contracts;
/// <summary>
/// Defines the contract for a render view in the graphics pipeline.
/// </summary>
internal interface IRenderer : IDisposable
{
public ReadOnlySpan<IRenderPass> RenderPasses
{
get;
}
/// <summary>
/// Requests a resize of the render view.
/// </summary>
/// <param name="width">The new width of the render view.</param>
/// <param name="height">The new height of the render view.</param>
/// <remarks>This only submits a resize request without executing it. May overwrite last request if next request issued before next frame.</remarks>
public void RequestResize(uint width, uint height);
/// <summary>
/// Executes any pending resize operations for the current context.
/// </summary>
public void ExecutePendingResize();
public void Initialize();
/// <summary>
/// Renders the current content to the output target.
/// </summary>
public void Render();
/// <summary>
/// Waits for the next frame to be ready for rendering.
/// </summary>
public void WaitNextFrame();
/// <summary>
/// Waits for the render view to become idle, ensuring all previous commands have been executed and resources are ready for the next frame.
/// </summary>
public void WaitIdle();
}

View File

@@ -1,38 +0,0 @@
using Misaki.HighPerformance.LowLevel.Collections;
namespace Ghost.Graphics.Contracts;
public unsafe interface IResource : IDisposable
{
public ulong GPUAddress
{
get;
}
public string Name
{
get;
set;
}
public bool TempResource
{
get;
}
public void SetData<T>(Span<T> data)
where T : unmanaged;
public void SetData<T>(T* data, uint length)
where T : unmanaged;
public void SetData(void* data, uint size);
public UnsafeArray<T> ReadData<T>(Allocator allocator)
where T : unmanaged;
public void ReadData<T>(T* ppData, uint* size)
where T : unmanaged;
public void ReadData(void* ppData, uint* size);
}

View File

@@ -1,11 +0,0 @@
using Win32.Graphics.Direct3D12;
namespace Ghost.Graphics.Contracts;
internal unsafe interface IResourceAllocator : IDisposable
{
public IResource CreateUploadBuffer(uint sizeInBytes, bool tempResource = false, ResourceFlags flags = ResourceFlags.None);
public IResource CreateCopyDestinationBuffer(uint sizeInBytes, bool tempResource = false, ResourceFlags flags = ResourceFlags.None);
public void ReleaseTempResource();
}