Refactor resource management and enforce code formatting

Refactored `D3D12ResourceAllocator` to improve maintainability,
introducing new descriptor creation methods, utility functions,
and enhanced resource handling. Added thread safety and proper
disposal logic. Updated `.editorconfig` to enforce consistent
`using` directive sorting and increased max line length.

Revised `BufferUsage` enum in `Common.cs` to include new flags
and reorganized existing ones. Refactored `RenderTargetDesc`
conversion to an instance method. Adjusted `MeshRenderPass`
for consistency and added a parameter to `Execute`.

Minor formatting updates in `ShaderCode.hlsl` and cleanup of
unused directives in `D3D12Utility.cs`. Overall, these changes
enhance readability, maintainability, and functionality.
This commit is contained in:
2025-11-03 22:11:31 +09:00
parent a8d7cd8828
commit 017153aa02
11 changed files with 350 additions and 244 deletions

View File

@@ -14,8 +14,8 @@ namespace Ghost.Graphics.RenderPasses;
internal unsafe class MeshRenderPass : IRenderPass
{
private Handle<Mesh> _mesh;
private Handle<Material> _material;
private Identifier<Shader> _shader;
private Handle<Material> _material;
private Handle<Texture>[]? _textures;
// Texture file paths for this demo
@@ -67,7 +67,7 @@ internal unsafe class MeshRenderPass : IRenderPass
public void Execute(ref readonly RenderingContext ctx)
{
ctx.RenderMesh(_mesh, _material);
ctx.RenderMesh(_mesh, _material, "Forward");
}
public void Cleanup(IResourceDatabase resourceDatabase)

View File

@@ -75,15 +75,15 @@ float4 PSMain(PixelInput input) : SV_TARGET
Texture2D tex2 = ResourceDescriptorHeap[_TextureIndex2];
Texture2D tex3 = ResourceDescriptorHeap[_TextureIndex3];
Texture2D tex4 = ResourceDescriptorHeap[_TextureIndex4];
// Sample the textures
float4 color1 = tex1.Sample(_MainSampler, input.uv.xy);
float4 color2 = tex2.Sample(_MainSampler, input.uv.xy);
float4 color3 = tex3.Sample(_MainSampler, input.uv.xy);
float4 color4 = tex4.Sample(_MainSampler, input.uv.xy);
// Blend all textures together (simple average)
float4 blendedColor = (color1 + color2 + color3 + color4) * 0.25f;
return blendedColor * _Color;
}
}