mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-04 09:00:44 +00:00
Make ResourceId::id member private, add ResourceId::Null()
This commit is contained in:
@@ -53,7 +53,9 @@ struct ToStr
|
||||
{
|
||||
// super inefficient to convert to qstr then std::string then back to qstr
|
||||
// but this is just a temporary measure
|
||||
return QString::number(el.id).toStdString();
|
||||
uint64_t num = 0;
|
||||
memcpy(&num, &el, sizeof(num));
|
||||
return QString::number(num).toStdString();
|
||||
}
|
||||
|
||||
static std::string Get(const ReplayStatus &el)
|
||||
|
||||
@@ -117,19 +117,33 @@ typedef void *(RENDERDOC_CC *pRENDERDOC_AllocArrayMem)(uint64_t sz);
|
||||
|
||||
#include "basic_types.h"
|
||||
|
||||
#ifdef RENDERDOC_EXPORTS
|
||||
struct ResourceId;
|
||||
|
||||
namespace ResourceIDGen
|
||||
{
|
||||
// the only function allowed access to ResourceId internals, for allocating a new ID
|
||||
ResourceId GetNewUniqueID();
|
||||
};
|
||||
#endif
|
||||
|
||||
// We give every resource a globally unique ID so that we can differentiate
|
||||
// between two textures allocated in the same memory (after the first is freed)
|
||||
//
|
||||
// it's a struct around a uint64_t to aid in template selection
|
||||
struct ResourceId
|
||||
{
|
||||
uint64_t id;
|
||||
|
||||
ResourceId() : id() {}
|
||||
ResourceId(uint64_t val, bool) { id = val; }
|
||||
inline static ResourceId Null() { return ResourceId(); }
|
||||
bool operator==(const ResourceId u) const { return id == u.id; }
|
||||
bool operator!=(const ResourceId u) const { return id != u.id; }
|
||||
bool operator<(const ResourceId u) const { return id < u.id; }
|
||||
private:
|
||||
uint64_t id;
|
||||
|
||||
#ifdef RENDERDOC_EXPORTS
|
||||
friend ResourceId ResourceIDGen::GetNewUniqueID();
|
||||
#endif
|
||||
};
|
||||
|
||||
#include "capture_options.h"
|
||||
|
||||
@@ -31,7 +31,9 @@ static volatile int64_t globalIDCounter = 1;
|
||||
|
||||
ResourceId GetNewUniqueID()
|
||||
{
|
||||
return ResourceId(Atomic::Inc64(&globalIDCounter), true);
|
||||
ResourceId ret;
|
||||
ret.id = Atomic::Inc64(&globalIDCounter);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void SetReplayResourceIDs()
|
||||
|
||||
@@ -41,7 +41,9 @@ string ToStrHelper<false, ResourceId>::Get(const ResourceId &el)
|
||||
{
|
||||
char tostrBuf[256] = {0};
|
||||
|
||||
StringFormat::snprintf(tostrBuf, 255, "ResID_%llu", el.id);
|
||||
RDCCOMPILE_ASSERT(sizeof(el) == sizeof(uint64_t), "ResourceId is no longer 1:1 with uint64_t");
|
||||
|
||||
StringFormat::snprintf(tostrBuf, 255, "ResID_%llu", (uint64_t &)el);
|
||||
|
||||
return tostrBuf;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user