Refactor GPU resource management and rendering pipeline

- Introduced `Handle<T>` and `Identifier<T>` for lightweight, strongly-typed resource identifiers.
- Replaced `BitSet` with `UnsafeBitSet` for improved performance and memory safety.
- Refactored `Mesh` and `Material` into `MeshClass` and `MaterialClass` for better GPU resource handling.
- Added `D3D12ResourceDatabase` to centralize GPU resource tracking and lifecycle management.
- Updated `D3D12ShaderCompiler` to load shaders from disk and dynamically populate constant buffers and textures.
- Enhanced `ICommandBuffer` with new upload operations for buffers and textures.
- Refactored `Vertex` struct for simplified memory layout and better performance.
- Updated `MeshBuilder` and rendering logic to align with new resource and shader structures.
- Added `BindlessDescriptor` support to `TextureHandle` and `BufferHandle`.
- Removed unused classes and performed general cleanup.
- Updated unit tests and demos to reflect the new architecture.
This commit is contained in:
2025-09-19 23:20:15 +09:00
parent 6a504cefc8
commit a39f377533
39 changed files with 1669 additions and 826 deletions

88
Ghost.Core/Handle.cs Normal file
View File

@@ -0,0 +1,88 @@
namespace Ghost.Core;
public readonly struct Handle<T>
{
public readonly int id;
public readonly int generation;
public Handle(int id, int generation)
{
this.id = id;
this.generation = generation;
}
public static Handle<T> Invalid => new(-1, -1);
public readonly override int GetHashCode()
{
return id.GetHashCode();
}
public readonly override bool Equals(object? obj)
{
return obj is Handle<T> id && Equals(id);
}
public readonly bool Equals(Handle<T> other)
{
return id == other.id;
}
public readonly int CompareTo(Handle<T> other)
{
return id.CompareTo(other.id);
}
public static bool operator ==(Handle<T> a, Handle<T> b)
{
return a.Equals(b);
}
public static bool operator !=(Handle<T> a, Handle<T> b)
{
return !a.Equals(b);
}
}
public readonly struct Identifier<T>
{
public readonly int value;
public Identifier(int value)
{
this.value = value;
}
public static Identifier<T> Invalid => new(-1);
public readonly override int GetHashCode()
{
return value.GetHashCode();
}
public readonly override bool Equals(object? obj)
{
return obj is Identifier<T> id && Equals(id);
}
public readonly bool Equals(Identifier<T> other)
{
return value == other.value;
}
public readonly int CompareTo(Identifier<T> other)
{
return value.CompareTo(other.value);
}
public static bool operator ==(Identifier<T> a, Identifier<T> b)
{
return a.Equals(b);
}
public static bool operator !=(Identifier<T> a, Identifier<T> b)
{
return !a.Equals(b);
}
}