forked from Misaki/GhostEngine
Added a new `ConstPtr<T>` struct for type-safe pointers. Added a new `ICommandBuffer` interface for resource copying. Added a new `IRenderPass` interface to define render passes. Added a new `IResource` interface for GPU resources. Added a new `IResourceAllocator` interface for resource management. Added a new `ISwapChainPanelNative` struct for native interactions. Added a new `D3D12Utility` class for Direct3D 12 utilities. Added a new package reference for `Vortice.Win32.Graphics.D3D12MemoryAllocator`. Changed project file to allow unsafe code blocks. Changed `Result` struct methods to improve clarity. Changed error handling in `ProjectService` and `AssetDatabase` to use `Result.Failure()`. Changed `launchSettings.json` to enable native debugging. Changed rendering logic in `ScenePage.xaml.cs` to use `IRenderer`. Changed `IGraphicsDevice` interface to include renderer properties. Changed `IRenderView` to `IRenderer` and updated its methods. Changed `Mesh` class to use the new `IResource` interface for buffers. Changed `GraphicsAPI` enum to include a `None` value. Changed various aspects of the `GraphicsPipeline` class for new architecture. Removed the old `DX12RenderView` class and replaced it with `DX12Renderer`. Removed unnecessary code in the `ResourceView` class.
37 lines
863 B
C#
37 lines
863 B
C#
using Ghost.Graphics.Contracts;
|
|
using System.Runtime.CompilerServices;
|
|
using Vortice.Direct3D12;
|
|
|
|
namespace Ghost.Graphics.DX12;
|
|
|
|
public unsafe class DX12Resource : IResource
|
|
{
|
|
private readonly ID3D12Resource _nativeResource;
|
|
|
|
internal ID3D12Resource NativeResource => _nativeResource;
|
|
|
|
public ulong GPUAddress => _nativeResource.GPUVirtualAddress;
|
|
|
|
public string Name
|
|
{
|
|
get => _nativeResource.Name;
|
|
set => _nativeResource.Name = value;
|
|
}
|
|
|
|
public DX12Resource(ID3D12Resource nativeResource)
|
|
{
|
|
_nativeResource = nativeResource;
|
|
}
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public void SetData<T>(Span<T> data)
|
|
where T : unmanaged
|
|
{
|
|
_nativeResource.WriteToSubresource(0, data, 0, 0);
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
_nativeResource.Dispose();
|
|
}
|
|
} |