forked from Misaki/GhostEngine
Refactor RenderGraph barrier/state tracking system
Major overhaul of resource barrier and state tracking in RenderGraph: - Introduce ResourceBarrierData for explicit (layout, access, sync) tracking. - Separate aliasing and transition barriers; explicit aliasing support. - Remove BufferHint; infer buffer usage from BufferUsage flags. - Update TextureAccess/BufferAccess to include usage requirements. - Improve enums (BarrierSync, BarrierAccess, BarrierLayout) for D3D12 alignment. - Update D3D12CommandBuffer to use new barrier data and error handling. - Make D3D12DescriptorHeap a class; add ReleaseSampler to IResourceDatabase. - Reset resource pools and aliasing managers each frame. - Batch and flush barriers efficiently per pass. - Update HLSL mesh shader macros to [NumThreads]. - Remove obsolete code and improve documentation. This refactor improves correctness, extensibility, and prepares for advanced features.
This commit is contained in:
@@ -233,7 +233,7 @@ internal class MeshRenderPass : IRenderPass
|
||||
throw new InvalidOperationException("Failed to get material reference.");
|
||||
}
|
||||
|
||||
ref readonly var matRef = ref meshResult.Value;
|
||||
ref var matRef = ref meshResult.Value;
|
||||
var matProps = new ShaderProperties_MyShader_Standard
|
||||
{
|
||||
color = new float4(1.0f, 1.0f, 1.0f, 1.0f),
|
||||
@@ -271,7 +271,6 @@ internal class MeshRenderPass : IRenderPass
|
||||
});
|
||||
}
|
||||
|
||||
// FIX: We can not upload the blit material properties during a native render pass.
|
||||
using (var builder = graph.AddUnsafeRenderPass<BlitPassData>("Blit Pass", out var passData))
|
||||
{
|
||||
passData.source = renderTarget;
|
||||
@@ -281,7 +280,7 @@ internal class MeshRenderPass : IRenderPass
|
||||
|
||||
builder.UseTexture(passData.source, AccessFlags.Read);
|
||||
builder.UseTexture(passData.destination, AccessFlags.WriteAll);
|
||||
|
||||
|
||||
builder.SetRenderFunc<BlitPassData>(static (data, ctx) =>
|
||||
{
|
||||
var r = ctx.ResourceDatabase.GetMaterialReference(data.blitMaterial);
|
||||
@@ -290,7 +289,7 @@ internal class MeshRenderPass : IRenderPass
|
||||
return;
|
||||
}
|
||||
|
||||
ref readonly var matRef = ref r.Value;
|
||||
ref var matRef = ref r.Value;
|
||||
var blitProps = new ShaderProperties_Hidden_Blit
|
||||
{
|
||||
mainTex = ctx.ResourceDatabase.GetBindlessIndex(ctx.GetActualResource(data.source.AsResource())),
|
||||
@@ -311,9 +310,12 @@ internal class MeshRenderPass : IRenderPass
|
||||
|
||||
public void Cleanup(IResourceDatabase resourceDatabase)
|
||||
{
|
||||
resourceDatabase.ReleaseMaterial(_blitMaterial);
|
||||
|
||||
resourceDatabase.ReleaseMaterial(_material);
|
||||
resourceDatabase.ReleaseShader(_shader);
|
||||
resourceDatabase.ReleaseMesh(_mesh);
|
||||
resourceDatabase.ReleaseSampler(_sampler);
|
||||
|
||||
if (_textures != null)
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ struct PixelInput
|
||||
float4 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
[MESH_SHADER_THREADS(3)] // 3 threads per triangle
|
||||
[NumThreads(3, 1, 1)] // 3 threads per triangle
|
||||
[OUTPUT_TRIANGLE_TOPOLOGY]
|
||||
void MSMain(
|
||||
uint3 groupThreadID : SV_GroupThreadID,
|
||||
|
||||
Reference in New Issue
Block a user