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

@@ -1,3 +1,6 @@
using System.Runtime.CompilerServices;
using Ghost.Core.Attributes;
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Ghost.Editor")]
[assembly: EngineAssembly]

View File

@@ -2,25 +2,33 @@
using Ghost.Engine.Services;
using Ghost.Graphics;
using Ghost.Graphics.Data;
using Misaki.HighPerformance.Unsafe.Buffer;
namespace Ghost.Engine;
internal class EngineCore
{
public async Task StartAsync(LaunchArgument args)
public void Start(LaunchArgument args)
{
ActivationHandler.Handle(args);
GraphicsPipeline.Initialize(GraphicsAPI.DX12);
AllocationManager.Initialize();
GraphicsPipeline.Initialize(GraphicsAPI.D3D12);
GraphicsPipeline.Start();
Logger.LogInfo("Engine started successfully.");
await Task.CompletedTask;
}
public async Task ShutDownAsync()
public void IncrementCPUFenceValue()
{
GraphicsPipeline.SignalCPUReady();
}
public void ShutDown()
{
GraphicsPipeline.SignalCPUReady();
GraphicsPipeline.Shutdown();
await Task.CompletedTask;
AllocationManager.Dispose();
}
}

View File

@@ -1,8 +1,9 @@
namespace Ghost.Engine.Services;
using Ghost.Entities;
namespace Ghost.Engine.Services;
internal static class PlayerLoopService
{
private static Timer? _timer;
private static bool _isRunning = false;
// TODO: Implement the actual time system
@@ -10,47 +11,47 @@ internal static class PlayerLoopService
public static void Start()
{
//if (_isRunning)
//{
// return;
//}
if (_isRunning)
{
return;
}
//foreach (var gameObject in SceneManager.QueryRootGameObjects())
//{
// gameObject.Start();
//}
for (var i = 0; i < World.WorldCount; i++)
{
var world = World.GetWorld(i);
//_timer ??= new Timer(FixedUpdate, null, 0, (int)(fixedDeltaTime * 1000));
//while (_isRunning)
//{
// Update();
//}
foreach (var script in world.QueryScript())
{
script.Start();
}
}
}
private static void Update()
public static void Update()
{
//foreach (var gameObject in SceneManager.QueryRootGameObjects())
//{
// gameObject.Update();
//}
for (var i = 0; i < World.WorldCount; i++)
{
var world = World.GetWorld(i);
world.SystemStorage.UpdateSystems();
//foreach (var gameObject in SceneManager.QueryRootGameObjects())
//{
// gameObject.LateUpdate();
//}
foreach (var script in world.QueryScript())
{
script.Update();
}
}
}
private static void FixedUpdate(object? state)
public static void Shutdown()
{
//foreach (var gameObject in SceneManager.QueryRootGameObjects())
//{
// gameObject.FixedUpdate();
//}
}
for (var i = 0; i < World.WorldCount; i++)
{
var world = World.GetWorld(i);
foreach (var script in world.QueryScript())
{
script.Update();
}
}
public static void Stop()
{
_isRunning = false;
}
}