mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-09-24 06:36:08 +00:00
Prepare to remove live<->replay resource id map lookups
* Resources will be given the ID to use on replay in order to match the original IDs. Any internal replay-time resources are given the same namespaced IDs as before. * We add a new per-ID query to check if something is replay-only or not.
This commit is contained in:
@@ -45,10 +45,8 @@ DOCUMENT(R"(This is an opaque identifier that uniquely locates a resource.
|
||||
|
||||
.. note::
|
||||
These IDs do not overlap ever - textures, buffers, shaders and samplers will all have unique IDs
|
||||
and do not reuse the namespace. Likewise the IDs assigned for resources during capture are not
|
||||
re-used on replay - the corresponding resources created on replay to stand-in for capture-time
|
||||
resources are given unique IDs and a mapping is stored to between the capture-time resource and
|
||||
the replay-time one.
|
||||
and do not reuse the namespace. The IDs assigned for resources during capture are also used
|
||||
during replay. Any internal/synthesised resources created during replay will have distinct IDs.
|
||||
)");
|
||||
struct ResourceId
|
||||
{
|
||||
|
||||
@@ -104,7 +104,7 @@ rdcstr DoStringise(const ResourceId &el)
|
||||
// hardcode empty/null ResourceId to both avoid special case below and fast-path a common case as
|
||||
// a string literal.
|
||||
if(num == 0)
|
||||
return PREFIX "0";
|
||||
return PREFIX "0"_lit;
|
||||
|
||||
// enough for prefix and a 64-bit value in decimal
|
||||
char str[48] = {};
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
namespace ResourceIDGen
|
||||
{
|
||||
static int64_t globalIDCounter = 1;
|
||||
static ResourceId baseReplayID;
|
||||
|
||||
ResourceId GetNewUniqueID()
|
||||
{
|
||||
@@ -38,16 +39,22 @@ ResourceId GetNewUniqueID()
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool IsReplayOnlyID(ResourceId id)
|
||||
{
|
||||
return baseReplayID < id;
|
||||
}
|
||||
|
||||
void SetReplayResourceIDs()
|
||||
{
|
||||
// separate replay IDs from live IDs by adding a value when replaying.
|
||||
// 1000000000000000000 live IDs before we overlap replay IDs gives
|
||||
// separate replay-only IDs from captured IDs by adding a value when replaying.
|
||||
// 1000000000000000000 capture-time IDs before we overlap replay IDs gives
|
||||
// almost 32 years generating 100000 IDs per frame at 10000 FPS.
|
||||
|
||||
// only add this value once (since we're not |'ing on a bit)
|
||||
if(globalIDCounter < 1000000000000000000LL)
|
||||
globalIDCounter =
|
||||
RDCMAX(int64_t(globalIDCounter), int64_t(globalIDCounter + 1000000000000000000LL));
|
||||
baseReplayID = GetNewUniqueID();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -296,6 +296,7 @@ inline bool MarkReferenced(std::unordered_map<ResourceId, FrameRefType> &refs, R
|
||||
namespace ResourceIDGen
|
||||
{
|
||||
ResourceId GetNewUniqueID();
|
||||
bool IsReplayOnlyID(ResourceId id);
|
||||
void SetReplayResourceIDs();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user