mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-06 01:50:38 +00:00
Move ResourceId tracking to common location for all drivers to share
This commit is contained in:
@@ -25,6 +25,21 @@
|
||||
|
||||
#include "resource_manager.h"
|
||||
|
||||
namespace ResourceIDGen
|
||||
{
|
||||
static volatile int64_t globalIDCounter = 1;
|
||||
|
||||
ResourceId GetNewUniqueID()
|
||||
{
|
||||
return ResourceId(Atomic::Inc64(&globalIDCounter), true);
|
||||
}
|
||||
|
||||
void SetReplayResourceIDs()
|
||||
{
|
||||
globalIDCounter = RDCMAX(uint64_t(globalIDCounter), uint64_t(globalIDCounter|0x1000000000000000ULL));
|
||||
}
|
||||
};
|
||||
|
||||
void ResourceRecord::MarkResourceFrameReferenced(ResourceId id, FrameRefType refType)
|
||||
{
|
||||
ResourceManager<void*,ResourceRecord>::MarkReferenced(m_FrameRefs, id, refType);
|
||||
|
||||
@@ -55,6 +55,12 @@ enum FrameRefType
|
||||
eFrameRef_ReadBeforeWrite,
|
||||
};
|
||||
|
||||
namespace ResourceIDGen
|
||||
{
|
||||
ResourceId GetNewUniqueID();
|
||||
void SetReplayResourceIDs();
|
||||
};
|
||||
|
||||
class ResourceRecordHandler
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -127,7 +127,7 @@ WrappedID3D11DeviceContext::WrappedID3D11DeviceContext(WrappedID3D11Device* real
|
||||
}
|
||||
|
||||
// create a temporary and grab its resource ID
|
||||
m_ResourceID = TrackedResource().GetResourceID();
|
||||
m_ResourceID = ResourceIDGen::GetNewUniqueID();
|
||||
|
||||
m_ContextRecord = NULL;
|
||||
|
||||
|
||||
@@ -310,7 +310,7 @@ WrappedID3D11Device::WrappedID3D11Device(ID3D11Device* realDevice, D3D11InitPara
|
||||
m_pSerialiser = NULL;
|
||||
m_pDebugSerialiser = NULL;
|
||||
|
||||
TrackedResource::SetReplayResourceIDs();
|
||||
ResourceIDGen::SetReplayResourceIDs();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -330,7 +330,7 @@ WrappedID3D11Device::WrappedID3D11Device(ID3D11Device* realDevice, D3D11InitPara
|
||||
m_pSerialiser->SetChunkNameLookup(&GetChunkName);
|
||||
|
||||
// create a temporary and grab its resource ID
|
||||
m_ResourceID = TrackedResource().GetResourceID();
|
||||
m_ResourceID = ResourceIDGen::GetNewUniqueID();
|
||||
|
||||
m_DeviceRecord = NULL;
|
||||
|
||||
|
||||
@@ -56,8 +56,6 @@ WRAPPED_POOL_INST(WrappedID3D11RasterizerState1);
|
||||
WRAPPED_POOL_INST(WrappedID3D11BlendState1);
|
||||
#endif
|
||||
|
||||
volatile LONGLONG TrackedResource::globalIDCounter = 1;
|
||||
|
||||
map<ResourceId,WrappedID3D11Texture1D::TextureEntry> WrappedTexture<ID3D11Texture1D, D3D11_TEXTURE1D_DESC>::m_TextureList;
|
||||
map<ResourceId,WrappedID3D11Texture2D::TextureEntry> WrappedTexture<ID3D11Texture2D, D3D11_TEXTURE2D_DESC>::m_TextureList;
|
||||
map<ResourceId,WrappedID3D11Texture3D::TextureEntry> WrappedTexture<ID3D11Texture3D, D3D11_TEXTURE3D_DESC>::m_TextureList;
|
||||
|
||||
@@ -95,28 +95,15 @@ class TrackedResource
|
||||
public:
|
||||
TrackedResource()
|
||||
{
|
||||
m_ID = GetNewUniqueID();
|
||||
m_ID = ResourceIDGen::GetNewUniqueID();
|
||||
}
|
||||
|
||||
ResourceId GetResourceID() { return m_ID; }
|
||||
|
||||
static void SetReplayResourceIDs()
|
||||
{
|
||||
globalIDCounter = RDCMAX(uint64_t(globalIDCounter), uint64_t(globalIDCounter|0x1000000000000000ULL));
|
||||
}
|
||||
|
||||
private:
|
||||
TrackedResource(const TrackedResource &);
|
||||
TrackedResource &operator =(const TrackedResource &);
|
||||
|
||||
ResourceId GetNewUniqueID()
|
||||
{
|
||||
uint64_t newID = (uint64_t)InterlockedIncrement64(&globalIDCounter);
|
||||
|
||||
return ResourceId(newID, true); // bool to make explicit
|
||||
}
|
||||
|
||||
static volatile LONGLONG globalIDCounter;
|
||||
ResourceId m_ID;
|
||||
};
|
||||
|
||||
|
||||
@@ -28,21 +28,6 @@
|
||||
#include "gl_common.h"
|
||||
#include "gl_driver.h"
|
||||
|
||||
namespace TrackedResource
|
||||
{
|
||||
static volatile int64_t globalIDCounter = 0;
|
||||
|
||||
ResourceId GetNewUniqueID()
|
||||
{
|
||||
return ResourceId(Atomic::Inc64(&globalIDCounter), true);
|
||||
}
|
||||
|
||||
void SetReplayResourceIDs()
|
||||
{
|
||||
globalIDCounter = RDCMAX(uint64_t(globalIDCounter), uint64_t(globalIDCounter|0x1000000000000000ULL));
|
||||
}
|
||||
};
|
||||
|
||||
bool ExtensionSupported[ExtensionSupported_Count];
|
||||
bool VendorCheck[VendorCheck_Count];
|
||||
|
||||
|
||||
@@ -777,7 +777,7 @@ WrappedOpenGL::WrappedOpenGL(const char *logfile, const GLHookSet &funcs)
|
||||
{
|
||||
m_DeviceRecord = m_ContextRecord = NULL;
|
||||
|
||||
TrackedResource::SetReplayResourceIDs();
|
||||
ResourceIDGen::SetReplayResourceIDs();
|
||||
|
||||
InitSPIRVCompiler();
|
||||
RenderDoc::Inst().RegisterShutdownFunction(&ShutdownSPIRVCompiler);
|
||||
|
||||
@@ -107,7 +107,7 @@ class GLResourceManager : public ResourceManager<GLResource, GLResourceRecord>
|
||||
|
||||
ResourceId RegisterResource(GLResource res)
|
||||
{
|
||||
ResourceId id = TrackedResource::GetNewUniqueID();
|
||||
ResourceId id = ResourceIDGen::GetNewUniqueID();
|
||||
m_CurrentResourceIds[res] = id;
|
||||
AddCurrentResource(id, res);
|
||||
return id;
|
||||
|
||||
@@ -211,9 +211,3 @@ struct GLResourceRecord : public ResourceRecord
|
||||
private:
|
||||
byte *ShadowPtr[2];
|
||||
};
|
||||
|
||||
namespace TrackedResource
|
||||
{
|
||||
ResourceId GetNewUniqueID();
|
||||
void SetReplayResourceIDs();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user