Enhance graphics engine and code organization

Added `InternalsVisibleTo` attribute for "Ghost.Graphics" and "Ghost.Editor" in `AssemblyInfo.cs`.
Added a new `EngineAssemblyAttribute` in `EngineAssemblyAttribute.cs`.
Added a reference to `Misaki.HighPerformance.Unsafe` in `Ghost.Core.csproj`.
Added a new `Bounds` struct to represent axis-aligned bounding boxes in `Bounds.cs`.
Added new `Color32` and `Color128` structs for color representation in `Color.cs`.

Changed the namespace from `Ghost.Editor.Controls` to `Ghost.Editor.Core.Controls` in multiple files.
Changed the implicit conversion operator in `ConstPtr<T>` to use a more descriptive parameter name in `ConstPtr.cs`.
Changed the `Mesh` class to use `Color128` instead of `Color32` for color representation.

Enhanced the `TypeCache` class to load types from assemblies marked with `EngineAssemblyAttribute`.
Enhanced the `ProjectService` class to improve the `GetAllProjectAsync` method by filtering out bad projects.
Enhanced the `GraphicsPipeline` class to support both DX12 and D3D12 graphics APIs.
Enhanced the `Shader` class to include methods for compiling HLSL shaders and managing root signatures.
Enhanced the `MeshRenderPass` class to utilize the new shader compilation methods.

Refactored the `AppStateMachine` class to use private fields instead of static fields for state management.
Refactored the `ComponentDataView` class to use the new namespace and improve organization.
Refactored project references in `Ghost.Graphics.csproj` to include new dependencies and remove outdated ones.

Made various adjustments to ensure consistency and improve code quality across multiple files.
This commit is contained in:
2025-07-02 21:30:10 +09:00
parent 300ae7251b
commit 5ae4128baf
66 changed files with 2100 additions and 1632 deletions

View File

@@ -0,0 +1,42 @@
using Ghost.Core;
using Ghost.Graphics.Contracts;
using Ghost.Graphics.Data;
using Win32.Graphics.Direct3D;
using Win32.Graphics.Direct3D12;
namespace Ghost.Graphics.D3D12;
internal unsafe class D3D12CommandBuffer : ICommandBuffer
{
private readonly ConstPtr<ID3D12GraphicsCommandList10> _commandList;
internal ConstPtr<ID3D12GraphicsCommandList10> CommandList => _commandList;
public D3D12CommandBuffer(ID3D12GraphicsCommandList10* commandList)
{
_commandList = commandList;
}
public void DrawMesh(Mesh mesh)
{
_commandList.Ptr->IASetPrimitiveTopology(PrimitiveTopology.TriangleList);
_commandList.Ptr->IASetVertexBuffers(0, 1, mesh.VertexBufferView);
_commandList.Ptr->IASetIndexBuffer(mesh.IndexBufferView);
_commandList.Ptr->DrawIndexedInstanced(mesh.IndexCount, 1, 0, 0, 0);
}
public void CopyResource(IResource dstResource, uint dstOffset, IResource srcResource, uint srcOffset, uint size)
{
var dstDXResource = (D3D12Resource)dstResource;
var srcDXResource = (D3D12Resource)srcResource;
_commandList.Ptr->CopyBufferRegion(dstDXResource.NativeResource, dstOffset, srcDXResource.NativeResource, srcOffset, size);
}
public void BarrierTransition(IResource resource, ResourceStates beforeState, ResourceStates afterState)
{
var dxResource = (D3D12Resource)resource;
_commandList.Ptr->ResourceBarrierTransition(dxResource.NativeResource.Ptr, beforeState, afterState);
}
}