feat(rendergraph): skip redundant SRV barriers, add usage param
Add logic to skip generic SRV barriers for resources explicitly handled as color, depth, or random access in raster passes, preventing redundant transitions. Update RGTextureDesc to accept a TextureUsage parameter for more flexible texture descriptor creation.
This commit is contained in:
@@ -238,6 +238,41 @@ internal static class RenderGraphBarriers
|
||||
for (var j = 0; j < readList.Count; j++)
|
||||
{
|
||||
var handle = readList[j];
|
||||
|
||||
bool isExplicitlyHandled = false;
|
||||
if (pass.type == RenderPassType.Raster)
|
||||
{
|
||||
for (var c = 0; c <= pass.maxColorIndex; c++)
|
||||
{
|
||||
if (pass.colorAccess[c].id.IsValid && pass.colorAccess[c].id.Value == handle.Value)
|
||||
{
|
||||
isExplicitlyHandled = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isExplicitlyHandled && pass.depthAccess.id.IsValid && pass.depthAccess.id.Value == handle.Value)
|
||||
{
|
||||
isExplicitlyHandled = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isExplicitlyHandled)
|
||||
{
|
||||
for (var u = 0; u < pass.randomAccess.Count; u++)
|
||||
{
|
||||
if (pass.randomAccess[u].Value == handle.Value)
|
||||
{
|
||||
isExplicitlyHandled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Skip generic SRV barrier if handled specifically
|
||||
if (isExplicitlyHandled)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var targetState = GetBufferReadBarrierData(handle, pass, (RenderGraphResourceType)i, resources);
|
||||
AddTransition(handle, targetState);
|
||||
}
|
||||
|
||||
@@ -212,7 +212,8 @@ public struct RGTextureDesc : IEquatable<RGTextureDesc>
|
||||
byte clearStencil = 0,
|
||||
bool clearAtFirstUse = true,
|
||||
bool discardAtLastUse = true,
|
||||
TextureFormat format = TextureFormat.D32_Float)
|
||||
TextureFormat format = TextureFormat.D32_Float,
|
||||
TextureUsage usage = TextureUsage.DepthStencil)
|
||||
{
|
||||
return new RGTextureDesc
|
||||
{
|
||||
@@ -228,7 +229,7 @@ public struct RGTextureDesc : IEquatable<RGTextureDesc>
|
||||
dimension = TextureDimension.Texture2D,
|
||||
mipLevels = 1,
|
||||
slice = 1,
|
||||
usage = TextureUsage.DepthStencil | TextureUsage.ShaderResource
|
||||
usage = usage
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user