Add new interfaces and refactor rendering logic

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.
This commit is contained in:
2025-06-30 13:50:06 +09:00
parent 8fd1222780
commit 300ae7251b
27 changed files with 765 additions and 486 deletions

17
Ghost.Core/ConstPtr.cs Normal file
View File

@@ -0,0 +1,17 @@
namespace Ghost.Core;
public unsafe readonly struct ConstPtr<T>
where T : unmanaged
{
private readonly T* _ptr;
public ConstPtr(T* ptr)
{
_ptr = ptr;
}
public readonly T* Ptr => _ptr;
public static implicit operator T*(ConstPtr<T> constPtr) => constPtr._ptr;
public static implicit operator ConstPtr<T>(T* ptr) => new(ptr);
}

View File

@@ -4,6 +4,7 @@
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
</PropertyGroup>
</Project>

View File

@@ -12,17 +12,17 @@ public readonly struct Result
this.message = message;
}
public static Result OK()
public static Result Success()
{
return new Result(true);
}
public static Result Error(string? message)
public static Result Failure(string? message)
{
return new Result(false, message);
}
public void CheckSuccess()
public void EnsureSuccess()
{
if (!success)
{
@@ -47,17 +47,17 @@ public readonly struct Result<T>
this.message = message;
}
public static Result<T> OK(T data)
public static Result<T> Success(T data)
{
return new Result<T>(true, data);
}
public static Result<T> Error(string? message)
public static Result<T> Failure(string? message)
{
return new Result<T>(false, default!, message);
}
public void CheckSuccess()
public void EnsureSuccess()
{
if (!success)
{