Refactor and enhance resource management and rendering

Updated multiple components to improve encapsulation, maintainability, and performance. Key changes include:

- Upgraded package dependencies in project files.
- Refactored `Mesh` and `RenderingContext` to use properties and added support for per-object constant buffers.
- Improved resource management in `D3D12CommandBuffer`, `D3D12CommandQueue`, and `D3D12ResourceAllocator` with better encapsulation and disposal handling.
- Added validation for constant buffer sizes in `D3D12PipelineLibrary`.
- Simplified `MeshBuilder` methods to accept allocators and removed hardcoded values.
- Enhanced debugging with `GPUResourceLeakException` and resource tracking updates.
- Updated shaders and rendering logic for testing, including hardcoded triangle rendering.
- Removed redundant base classes and interfaces for cleaner code structure.
This commit is contained in:
2025-11-26 01:48:24 +09:00
parent dfe786a2aa
commit 0720444c2c
40 changed files with 1008 additions and 903 deletions

View File

@@ -18,7 +18,9 @@ internal struct CBufferCache : IResourceReleasable
public readonly Handle<GraphicsBuffer> GpuResource => _gpuResource;
public readonly uint AlignedSize => _alignedSize;
public unsafe CBufferCache(Handle<GraphicsBuffer> buffer, uint bufferSize)
public readonly bool IsCreated => _gpuResource.IsValid && _cpuData.IsCreated;
public CBufferCache(Handle<GraphicsBuffer> buffer, uint bufferSize)
{
_alignedSize = (bufferSize + 255u) & ~255u;
@@ -65,6 +67,11 @@ public struct Material : IResourceReleasable, IHandleType
var pass = database.GetShaderPass(shader.GetPassKey(i));
var cbufferInfo = pass.CBuffer;
if (cbufferInfo.SizeInBytes == 0)
{
continue;
}
var desc = new BufferDesc
{
Size = cbufferInfo.SizeInBytes,
@@ -91,7 +98,7 @@ public struct Material : IResourceReleasable, IHandleType
public ref struct MaterialAccessor
{
private ref Material _materialData;
private Shader _shader;
private readonly Shader _shader;
private readonly IResourceDatabase _resourceDatabase;