From 35a15cf8d1af9e2f75bbcfb99d3ffb6ef904226f Mon Sep 17 00:00:00 2001 From: Benson Joeris Date: Tue, 7 Jan 2020 14:23:04 -0500 Subject: [PATCH] Add Unknown FrameRefType This represents a (sub)resource for which no usage info is available. It should be conservatively assumed that such a resource needs to be re-initialized before each replay (and this behaviour is reflected in `InitReq()`). Change-Id: I12235a6cb1c4b2e3e21bed8834653ec6a3aea009 --- renderdoc/core/resource_manager.cpp | 8 ++++++++ renderdoc/core/resource_manager.h | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/renderdoc/core/resource_manager.cpp b/renderdoc/core/resource_manager.cpp index ef1482f62..77674c387 100644 --- a/renderdoc/core/resource_manager.cpp +++ b/renderdoc/core/resource_manager.cpp @@ -125,6 +125,14 @@ FrameRefType ComposeFrameRefsDisjoint(FrameRefType x, FrameRefType y) return RDCMAX(x, y); } +FrameRefType ComposeFrameRefsFirstKnown(FrameRefType first, FrameRefType second) +{ + if(eFrameRef_Minimum <= first && first <= eFrameRef_Maximum) + return first; + else + return second; +} + bool IncludesRead(FrameRefType refType) { switch(refType) diff --git a/renderdoc/core/resource_manager.h b/renderdoc/core/resource_manager.h index 663600746..370d23255 100644 --- a/renderdoc/core/resource_manager.h +++ b/renderdoc/core/resource_manager.h @@ -103,6 +103,11 @@ enum FrameRefType // read could, incorrectly, be observed. This is because read-only resources // are not reset, so the write from the previous replay may still be present. eFrameRef_WriteBeforeRead = 5, + + // No reference info is available; + // This should only appear durring replay, and any (sub)resource with `Unknown` + // reference type should be conservatively reset before each replay. + eFrameRef_Unknown = 1000000000, }; bool IncludesRead(FrameRefType refType); @@ -135,6 +140,9 @@ FrameRefType ComposeFrameRefsUnordered(FrameRefType first, FrameRefType second); // frame refs of their subresources. FrameRefType ComposeFrameRefsDisjoint(FrameRefType x, FrameRefType y); +// Returns whichever of `first` or `second` is valid. +FrameRefType ComposeFrameRefsFirstKnown(FrameRefType first, FrameRefType second); + bool IsDirtyFrameRef(FrameRefType refType); // Captures the possible initialization/reset requirements for resources. @@ -200,6 +208,8 @@ enum InitPolicy // Return the initialization/reset requirements for a FrameRefType inline InitReqType InitReq(FrameRefType refType, InitPolicy policy, bool initialized) { + if(eFrameRef_Minimum > refType || refType > eFrameRef_Maximum) + return eInitReq_Copy; #define COPY_ONCE (initialized ? eInitReq_None : eInitReq_Copy) #define CLEAR_ONCE (initialized ? eInitReq_None : eInitReq_Clear) switch(policy)