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

View File

@@ -29,7 +29,7 @@ public readonly struct ResourceHandle : IEquatable<ResourceHandle>
{
unchecked
{
return (id * 397) ^ (int)generation;
return (id * 397) ^ generation;
}
}
@@ -52,6 +52,7 @@ public readonly struct ResourceHandle : IEquatable<ResourceHandle>
public readonly struct TextureHandle : IEquatable<TextureHandle>
{
private readonly ResourceHandle _resourceHandle;
private readonly BindlessDescriptor _bindlessDescriptor;
public ResourceHandle ResourceHandle => _resourceHandle;
public static TextureHandle Invalid => new(ResourceHandle.Invalid);
@@ -59,13 +60,20 @@ public readonly struct TextureHandle : IEquatable<TextureHandle>
internal TextureHandle(ResourceHandle resourceHandle)
{
_resourceHandle = resourceHandle;
_bindlessDescriptor = BindlessDescriptor.Invalid;
}
internal TextureHandle(ResourceHandle resourceHandle, BindlessDescriptor descriptor)
{
_resourceHandle = resourceHandle;
_bindlessDescriptor = descriptor;
}
public bool IsValid => _resourceHandle.IsValid;
public bool Equals(TextureHandle other)
{
return _resourceHandle.Equals(other._resourceHandle);
return _resourceHandle.Equals(other._resourceHandle) && _bindlessDescriptor.Equals(other._bindlessDescriptor);
}
public override bool Equals(object? obj)
@@ -75,7 +83,7 @@ public readonly struct TextureHandle : IEquatable<TextureHandle>
public override int GetHashCode()
{
return _resourceHandle.GetHashCode();
return HashCode.Combine(_resourceHandle, _bindlessDescriptor);
}
public static bool operator ==(TextureHandle left, TextureHandle right)
@@ -115,7 +123,7 @@ public readonly struct BufferHandle : IEquatable<BufferHandle>
public bool Equals(BufferHandle other)
{
return _resourceHandle.Equals(other._resourceHandle);
return _resourceHandle.Equals(other._resourceHandle) && _bindlessDescriptor.Equals(other._bindlessDescriptor);
}
public override bool Equals(object? obj)
@@ -125,7 +133,7 @@ public readonly struct BufferHandle : IEquatable<BufferHandle>
public override int GetHashCode()
{
return _resourceHandle.GetHashCode();
return HashCode.Combine(_resourceHandle, _bindlessDescriptor);
}
public static bool operator ==(BufferHandle left, BufferHandle right)