forked from Misaki/GhostEngine
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:
110
Ghost.Graphics/D3D12/Descriptors.cs
Normal file
110
Ghost.Graphics/D3D12/Descriptors.cs
Normal file
@@ -0,0 +1,110 @@
|
||||
using Win32.Graphics.Direct3D12;
|
||||
|
||||
namespace Ghost.Graphics.D3D12;
|
||||
|
||||
/// <summary>
|
||||
/// Base class for D3D12 descriptor implementations.
|
||||
/// </summary>
|
||||
internal abstract class Descriptor
|
||||
{
|
||||
protected readonly uint index;
|
||||
protected readonly bool isShaderVisible;
|
||||
|
||||
protected Descriptor(uint index, bool isShaderVisible)
|
||||
{
|
||||
this.index = index;
|
||||
this.isShaderVisible = isShaderVisible;
|
||||
}
|
||||
|
||||
public bool IsValid => index != uint.MaxValue;
|
||||
public uint Index => index;
|
||||
public bool IsShaderVisible => isShaderVisible;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the CPU descriptor handle.
|
||||
/// </summary>
|
||||
public abstract CpuDescriptorHandle CpuHandle
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the GPU descriptor handle (only valid for shader-visible descriptors).
|
||||
/// </summary>
|
||||
public abstract GpuDescriptorHandle GpuHandle
|
||||
{
|
||||
get;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// D3D12 implementation of render target view (RTV) descriptor.
|
||||
/// </summary>
|
||||
internal sealed class RenderTargetDescriptor : Descriptor
|
||||
{
|
||||
private readonly CpuDescriptorHandle _cpuHandle;
|
||||
|
||||
public RenderTargetDescriptor(uint index, CpuDescriptorHandle cpuHandle)
|
||||
: base(index, false)
|
||||
{
|
||||
_cpuHandle = cpuHandle;
|
||||
}
|
||||
|
||||
public override CpuDescriptorHandle CpuHandle => _cpuHandle;
|
||||
public override GpuDescriptorHandle GpuHandle => default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// D3D12 implementation of depth stencil view (DSV) descriptor.
|
||||
/// </summary>
|
||||
internal sealed class DepthStencilDescriptor : Descriptor
|
||||
{
|
||||
private readonly CpuDescriptorHandle _cpuHandle;
|
||||
|
||||
public DepthStencilDescriptor(uint index, CpuDescriptorHandle cpuHandle)
|
||||
: base(index, false) // DSVs are not shader visible
|
||||
{
|
||||
_cpuHandle = cpuHandle;
|
||||
}
|
||||
|
||||
public override CpuDescriptorHandle CpuHandle => _cpuHandle;
|
||||
public override GpuDescriptorHandle GpuHandle => default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// D3D12 implementation of shader resource view (SRV) descriptor.
|
||||
/// </summary>
|
||||
internal sealed class ShaderResourceDescriptor : Descriptor
|
||||
{
|
||||
private readonly CpuDescriptorHandle _cpuHandle;
|
||||
private readonly GpuDescriptorHandle _gpuHandle;
|
||||
|
||||
public ShaderResourceDescriptor(uint index, CpuDescriptorHandle cpuHandle, GpuDescriptorHandle gpuHandle)
|
||||
: base(index, true)
|
||||
{
|
||||
_cpuHandle = cpuHandle;
|
||||
_gpuHandle = gpuHandle;
|
||||
}
|
||||
|
||||
public override CpuDescriptorHandle CpuHandle => _cpuHandle;
|
||||
public override GpuDescriptorHandle GpuHandle => _gpuHandle;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// D3D12 implementation of sampler descriptor.
|
||||
/// </summary>
|
||||
internal sealed class SamplerDescriptor : Descriptor
|
||||
{
|
||||
private readonly CpuDescriptorHandle _cpuHandle;
|
||||
private readonly GpuDescriptorHandle _gpuHandle;
|
||||
|
||||
public SamplerDescriptor(uint index, CpuDescriptorHandle cpuHandle, GpuDescriptorHandle gpuHandle)
|
||||
: base(index, true)
|
||||
{
|
||||
_cpuHandle = cpuHandle;
|
||||
_gpuHandle = gpuHandle;
|
||||
}
|
||||
|
||||
public override CpuDescriptorHandle CpuHandle => _cpuHandle;
|
||||
public override GpuDescriptorHandle GpuHandle => _gpuHandle;
|
||||
}
|
||||
Reference in New Issue
Block a user