From 6fa39fbbcb88a8284e0e30f44b69812622946f07 Mon Sep 17 00:00:00 2001 From: Benson Joeris Date: Fri, 1 Feb 2019 11:37:57 -0500 Subject: [PATCH] Add `InitReqType` to classify `FrameRefType` by init/reset requirements. The accumulated `FrameRefType` of the accesses to a resource within a frame determines how the resource needs to be initialized. The possibilities are: * `None`: The initial value of the resource is never used within the frame, either because it is never read, or because it is only read after being cleared * `InitOnce`: The resource needs to be initialized before replaying the frame for the first time, but does not ever need to be reset; this occurs when a resource is read within the frame, but not written within the frame. * `Reset`: The resource needs to be reset each time before replaying the frame. This occurs when the resource is read and later written within the frame. --- renderdoc/core/resource_manager.h | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/renderdoc/core/resource_manager.h b/renderdoc/core/resource_manager.h index 25d7e161f..08c769548 100644 --- a/renderdoc/core/resource_manager.h +++ b/renderdoc/core/resource_manager.h @@ -114,6 +114,39 @@ FrameRefType ComposeFrameRefsUnordered(FrameRefType first, FrameRefType second); bool IsDirtyFrameRef(FrameRefType refType); +// Captures the possible initialization/reset requirements for resources. +// These requirements are entirely determined by the resource's FrameRefType, +// but this type improves the readability of the code that checks +// init/reset requirements. +enum InitReqType +{ + // Initial contents of the resource are not used, and need not be initialized. + // Corresponds to `None`, `Write` or `Clear` ref types. + eInitReq_None, + + // Initial contents of the resource are read, but not overwritten; + // the resource needs to be initialized before the first replay, but need not + // be reset before subsequent replays. + // Corresponds to `Read` ref type. + eInitReq_InitOnce, + + // Initial contents of the resource are read, and later overwritten; + // the resource needs to be reset before each replay. + // Corresponds to `ReadBeforeWrite` ref type. + eInitReq_Reset, +}; + +// Return the initialization/reset requirements for a FrameRefType +inline InitReqType InitReq(FrameRefType refType) +{ + switch(refType) + { + case eFrameRef_Read: return eInitReq_InitOnce; + case eFrameRef_ReadBeforeWrite: return eInitReq_Reset; + default: return eInitReq_None; + } +} + // handle marking a resource referenced for read or write and storing RAW access etc. bool MarkReferenced(std::map &refs, ResourceId id, FrameRefType refType);