Skip to content

Commit 0815fbc

Browse files
raquelpecesEvergreen
authored andcommitted
Graphics/SRP/RPF - [UUM 69082][URP][RG][Camera Stacking] Game view background turn yellow after enable render graph
When more than two cameras are stacked in 2D with URP and RG activate, the `clearOnFirstUse` is set to `false` for all the overlay cameras, and `true` for the Base camera. This flag is allocated in the `TextureDesc.clearBuffer` of the `TextureResource`. When the hash of the Render Graph is created, this flag was not added to the hash of the graph. So, the RG was returning the same cache hash for base camera, and overlay cameras, and it was clearing the color buffer as it was indicated in the base camera for all the overlay cameras. I have added the `clearBuffer` to the compute of the hash, and to be sure for the future also the `discardBuffer` as this is another flag in the camera stacking.
1 parent 5d23ffe commit 0815fbc

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphPass.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,13 +373,19 @@ void ComputeTextureHash(ref int hash, in ResourceHandle handle, RenderGraphResou
373373
hash = hash * 23 + desc.width;
374374
hash = hash * 23 + desc.height;
375375
}
376+
377+
// Add the clear/discard buffer flags to the hash (used in all the cases above)
378+
hash = hash * 23 + res.desc.clearBuffer.GetHashCode();
379+
hash = hash * 23 + res.desc.discardBuffer.GetHashCode();
376380
}
377381
else
378382
{
379383
var desc = resources.GetTextureResourceDesc(handle);
380384
hash = hash * 23 + (int)desc.colorFormat;
381385
hash = hash * 23 + (int)desc.dimension;
382386
hash = hash * 23 + (int)desc.msaaSamples;
387+
hash = hash * 23 + desc.clearBuffer.GetHashCode();
388+
hash = hash * 23 + desc.discardBuffer.GetHashCode();
383389
switch (desc.sizeMode)
384390
{
385391
case TextureSizeMode.Explicit:

0 commit comments

Comments
 (0)