Remove pending-dirty operations, mark resources dirty immediately

* Now that the dirty list is only read once at the start of the frame we can
  mark resources dirty mid-frame freely and don't have to defer that. The
  internal resource manager locking prevents us from adding to the list while it
  is being modified.
This commit is contained in:
baldurk
2019-05-15 14:12:17 +01:00
parent ce92ba70d1
commit 95e63cb965
27 changed files with 134 additions and 497 deletions
-3
View File
@@ -170,10 +170,7 @@ void ResourceRecord::Delete(ResourceRecordHandler *mgr)
DeleteChunks();
if(ResID != ResourceId())
{
mgr->MarkCleanResource(ResID);
mgr->RemoveResourceRecord(ResID);
}
mgr->DestroyResourceRecord(this);
}
+1 -45
View File
@@ -199,8 +199,6 @@ class ResourceRecordHandler
{
public:
virtual void MarkDirtyResource(ResourceId id) = 0;
virtual void MarkCleanResource(ResourceId id) = 0;
virtual void MarkPendingDirty(ResourceId id) = 0;
virtual void RemoveResourceRecord(ResourceId id) = 0;
virtual void MarkResourceFrameReferenced(ResourceId id, FrameRefType refType) = 0;
virtual void DestroyResourceRecord(ResourceRecord *record) = 0;
@@ -492,14 +490,6 @@ public:
// of the frame.
inline void MarkDirtyResource(ResourceId res);
// for use when we might be mid-capture, this will get flushed to dirty state before the
// next frame but is safe to use mid-capture
void MarkPendingDirty(ResourceId res);
void FlushPendingDirty();
// this can be used when the resource is cleared or similar and it's in a known state
void MarkCleanResource(ResourceId res);
// returns if the resource has been marked as dirty
bool IsResourceDirty(ResourceId res);
@@ -603,7 +593,6 @@ protected:
// used during capture - holds resources marked as dirty, needing initial contents
set<ResourceId> m_DirtyResources;
set<ResourceId> m_PendingDirtyResources;
struct InitialContentDataOrChunk
{
@@ -717,26 +706,6 @@ void ResourceManager<Configuration>::MarkDirtyResource(ResourceId res)
m_DirtyResources.insert(res);
}
template <typename Configuration>
void ResourceManager<Configuration>::MarkPendingDirty(ResourceId res)
{
SCOPED_LOCK(m_Lock);
if(res == ResourceId())
return;
m_PendingDirtyResources.insert(res);
}
template <typename Configuration>
void ResourceManager<Configuration>::FlushPendingDirty()
{
SCOPED_LOCK(m_Lock);
m_DirtyResources.insert(m_PendingDirtyResources.begin(), m_PendingDirtyResources.end());
m_PendingDirtyResources.clear();
}
template <typename Configuration>
bool ResourceManager<Configuration>::IsResourceDirty(ResourceId res)
{
@@ -748,20 +717,6 @@ bool ResourceManager<Configuration>::IsResourceDirty(ResourceId res)
return m_DirtyResources.find(res) != m_DirtyResources.end();
}
template <typename Configuration>
void ResourceManager<Configuration>::MarkCleanResource(ResourceId res)
{
SCOPED_LOCK(m_Lock);
if(res == ResourceId())
return;
if(IsResourceDirty(res))
{
m_DirtyResources.erase(res);
}
}
template <typename Configuration>
void ResourceManager<Configuration>::SetInitialContents(ResourceId id, InitialContentData contents)
{
@@ -1431,6 +1386,7 @@ void ResourceManager<Configuration>::ReleaseCurrentResource(ResourceId id)
RDCASSERT(m_CurrentResourceMap.find(id) != m_CurrentResourceMap.end(), id);
m_CurrentResourceMap.erase(id);
m_DirtyResources.erase(id);
}
template <typename Configuration>
-11
View File
@@ -621,14 +621,6 @@ void WrappedID3D11DeviceContext::CleanupCapture()
m_ContextRecord->UnlockChunks();
m_ContextRecord->FreeParents(m_pDevice->GetResourceManager());
for(auto it = m_MissingTracks.begin(); it != m_MissingTracks.end(); ++it)
{
if(m_pDevice->GetResourceManager()->HasResourceRecord(*it))
MarkDirtyResource(*it);
}
m_MissingTracks.clear();
}
void WrappedID3D11DeviceContext::BeginFrame()
@@ -642,9 +634,6 @@ void WrappedID3D11DeviceContext::BeginFrame()
void WrappedID3D11DeviceContext::EndFrame()
{
DrainAnnotationQueue();
if(IsBackgroundCapturing(m_State))
m_pDevice->GetResourceManager()->FlushPendingDirty();
}
bool WrappedID3D11DeviceContext::IsFL11_1()
-2
View File
@@ -161,8 +161,6 @@ private:
map<ResourceId, size_t> m_MapResourceRecordAllocs;
set<ResourceId> m_MissingTracks;
ResourceId m_ResourceID;
D3D11ResourceRecord *m_ContextRecord;
@@ -379,7 +379,7 @@ void WrappedID3D11DeviceContext::UpdateSubresource1(ID3D11Resource *pDstResource
MarkResourceReferenced(GetIDForResource(pDstResource), eFrameRef_PartialWrite);
m_MissingTracks.insert(GetIDForResource(pDstResource));
MarkDirtyResource(GetIDForResource(pDstResource));
m_ContextRecord->AddChunk(scope.Get());
}
@@ -463,7 +463,7 @@ void WrappedID3D11DeviceContext::CopySubresourceRegion1(ID3D11Resource *pDstReso
Serialise_CopySubresourceRegion1(ser, pDstResource, DstSubresource, DstX, DstY, DstZ,
pSrcResource, SrcSubresource, pSrcBox, CopyFlags);
m_MissingTracks.insert(GetIDForResource(pDstResource));
MarkDirtyResource(GetIDForResource(pDstResource));
m_ContextRecord->AddChunk(scope.Get());
}
@@ -621,7 +621,7 @@ void WrappedID3D11DeviceContext::ClearView(ID3D11View *pView, const FLOAT Color[
ID3D11Resource *viewRes = NULL;
pView->GetResource(&viewRes);
m_MissingTracks.insert(GetIDForResource(viewRes));
MarkDirtyResource(GetIDForResource(viewRes));
MarkResourceReferenced(GetIDForResource(viewRes), eFrameRef_PartialWrite);
SAFE_RELEASE(viewRes);
@@ -1768,7 +1768,7 @@ void WrappedID3D11DeviceContext::DiscardResource(ID3D11Resource *pResource)
SERIALISE_ELEMENT(m_ResourceID).Named("Context").TypedAs("ID3D11DeviceContext *");
Serialise_DiscardResource(ser, pResource);
m_MissingTracks.insert(GetIDForResource(pResource));
MarkDirtyResource(GetIDForResource(pResource));
MarkResourceReferenced(GetIDForResource(pResource), eFrameRef_PartialWrite);
m_ContextRecord->AddChunk(scope.Get());
@@ -1924,7 +1924,7 @@ void WrappedID3D11DeviceContext::DiscardView(ID3D11View *pResourceView)
ID3D11Resource *viewRes = NULL;
pResourceView->GetResource(&viewRes);
m_MissingTracks.insert(GetIDForResource(viewRes));
MarkDirtyResource(GetIDForResource(viewRes));
MarkResourceReferenced(GetIDForResource(viewRes), eFrameRef_PartialWrite);
SAFE_RELEASE(viewRes);
@@ -2092,7 +2092,7 @@ void WrappedID3D11DeviceContext::DiscardView1(ID3D11View *pResourceView, const D
ID3D11Resource *viewRes = NULL;
pResourceView->GetResource(&viewRes);
m_MissingTracks.insert(GetIDForResource(viewRes));
MarkDirtyResource(GetIDForResource(viewRes));
MarkResourceReferenced(GetIDForResource(viewRes), eFrameRef_PartialWrite);
SAFE_RELEASE(viewRes);
+24 -48
View File
@@ -2274,15 +2274,9 @@ void WrappedID3D11DeviceContext::SOSetTargets(UINT NumBuffers, ID3D11Buffer *con
// to avoid having to track "possibly" dirty resources.
// Besides, it's unlikely an application will set an output then not draw to it
if(IsActiveCapturing(m_State))
{
MarkResourceReferenced(GetIDForResource(ppSOTargets[i]), eFrameRef_PartialWrite);
m_MissingTracks.insert(GetIDForResource(ppSOTargets[i]));
}
else if(IsBackgroundCapturing(m_State))
{
MarkDirtyResource(GetIDForResource(ppSOTargets[i]));
}
MarkDirtyResource(GetIDForResource(ppSOTargets[i]));
bufs[i] = UNWRAP(WrappedID3D11Buffer, ppSOTargets[i]);
}
}
@@ -3209,10 +3203,7 @@ void WrappedID3D11DeviceContext::OMSetRenderTargets(UINT NumViews,
// technically this isn't dirty until the draw call, but let's be conservative
// to avoid having to track "possibly" dirty resources.
// Besides, it's unlikely an application will set an output then not draw to it
if(IsBackgroundCapturing(m_State))
MarkDirtyResource(GetViewResourceResID(ppRenderTargetViews[i]));
else if(IsActiveCapturing(m_State))
m_MissingTracks.insert(GetViewResourceResID(ppRenderTargetViews[i]));
MarkDirtyResource(GetViewResourceResID(ppRenderTargetViews[i]));
}
RTs[i] = UNWRAP(WrappedID3D11RenderTargetView1, ppRenderTargetViews[i]);
@@ -3221,10 +3212,7 @@ void WrappedID3D11DeviceContext::OMSetRenderTargets(UINT NumViews,
if(pDepthStencilView && IsCaptureMode(m_State))
{
if(IsBackgroundCapturing(m_State))
MarkDirtyResource(GetViewResourceResID(pDepthStencilView));
else if(IsActiveCapturing(m_State))
m_MissingTracks.insert(GetViewResourceResID(pDepthStencilView));
MarkDirtyResource(GetViewResourceResID(pDepthStencilView));
}
if(IsActiveCapturing(m_State))
@@ -3605,10 +3593,7 @@ void WrappedID3D11DeviceContext::OMSetRenderTargetsAndUnorderedAccessViews(
// technically this isn't dirty until the draw call, but let's be conservative
// to avoid having to track "possibly" dirty resources.
// Besides, it's unlikely an application will set an output then not draw to it
if(IsBackgroundCapturing(m_State))
MarkDirtyResource(GetViewResourceResID(ppRenderTargetViews[i]));
else if(IsActiveCapturing(m_State))
m_MissingTracks.insert(GetViewResourceResID(ppRenderTargetViews[i]));
MarkDirtyResource(GetViewResourceResID(ppRenderTargetViews[i]));
}
RTs[i] = UNWRAP(WrappedID3D11RenderTargetView1, ppRenderTargetViews[i]);
@@ -3619,10 +3604,7 @@ void WrappedID3D11DeviceContext::OMSetRenderTargetsAndUnorderedAccessViews(
{
if(ppUnorderedAccessViews[i] && IsCaptureMode(m_State))
{
if(IsBackgroundCapturing(m_State))
MarkDirtyResource(GetViewResourceResID(ppUnorderedAccessViews[i]));
else if(IsActiveCapturing(m_State))
m_MissingTracks.insert(GetViewResourceResID(ppUnorderedAccessViews[i]));
MarkDirtyResource(GetViewResourceResID(ppUnorderedAccessViews[i]));
}
UAVs[i] = UNWRAP(WrappedID3D11UnorderedAccessView1, ppUnorderedAccessViews[i]);
@@ -3630,10 +3612,7 @@ void WrappedID3D11DeviceContext::OMSetRenderTargetsAndUnorderedAccessViews(
if(pDepthStencilView && IsCaptureMode(m_State))
{
if(IsBackgroundCapturing(m_State))
MarkDirtyResource(GetViewResourceResID(pDepthStencilView));
else if(IsActiveCapturing(m_State))
m_MissingTracks.insert(GetViewResourceResID(pDepthStencilView));
MarkDirtyResource(GetViewResourceResID(pDepthStencilView));
}
VerifyState();
@@ -4765,16 +4744,13 @@ void WrappedID3D11DeviceContext::CSSetUnorderedAccessViews(
{
if(ppUnorderedAccessViews[i] && IsCaptureMode(m_State))
{
if(IsBackgroundCapturing(m_State))
if(IsActiveCapturing(m_State))
{
MarkDirtyResource(GetViewResourceResID(ppUnorderedAccessViews[i]));
}
else if(IsActiveCapturing(m_State))
{
m_MissingTracks.insert(GetViewResourceResID(ppUnorderedAccessViews[i]));
MarkResourceReferenced(GetIDForResource(ppUnorderedAccessViews[i]), eFrameRef_Read);
MarkResourceReferenced(GetViewResourceResID(ppUnorderedAccessViews[i]), eFrameRef_Read);
}
MarkDirtyResource(GetViewResourceResID(ppUnorderedAccessViews[i]));
}
UAVs[i] = UNWRAP(WrappedID3D11UnorderedAccessView1, ppUnorderedAccessViews[i]);
@@ -5280,9 +5256,6 @@ void WrappedID3D11DeviceContext::ExecuteCommandList(ID3D11CommandList *pCommandL
cmdListRecord->AddResourceReferences(m_pDevice->GetResourceManager());
}
// still update dirty resources for subsequent captures
wrapped->MarkDirtyResources(m_MissingTracks);
{
// insert a chunk to let us know on replay that we finished the command list's
// chunks and we can restore the state
@@ -5658,7 +5631,8 @@ void WrappedID3D11DeviceContext::CopySubresourceRegion(ID3D11Resource *pDstResou
m_ContextRecord->AddChunk(scope.Get());
m_MissingTracks.insert(GetIDForResource(pDstResource));
MarkDirtyResource(GetIDForResource(pDstResource));
// assume partial update
MarkResourceReferenced(GetIDForResource(pDstResource), eFrameRef_Read);
MarkResourceReferenced(GetIDForResource(pDstResource), eFrameRef_PartialWrite);
@@ -5802,7 +5776,8 @@ void WrappedID3D11DeviceContext::CopyResource(ID3D11Resource *pDstResource,
m_ContextRecord->AddChunk(scope.Get());
m_MissingTracks.insert(GetIDForResource(pDstResource));
MarkDirtyResource(GetIDForResource(pDstResource));
MarkResourceReferenced(GetIDForResource(pDstResource), eFrameRef_PartialWrite);
MarkResourceReferenced(GetIDForResource(pSrcResource), eFrameRef_Read);
}
@@ -5957,7 +5932,7 @@ void WrappedID3D11DeviceContext::UpdateSubresource(ID3D11Resource *pDstResource,
MarkResourceReferenced(GetIDForResource(pDstResource), eFrameRef_PartialWrite);
m_MissingTracks.insert(GetIDForResource(pDstResource));
MarkDirtyResource(GetIDForResource(pDstResource));
m_ContextRecord->AddChunk(scope.Get());
}
@@ -6236,7 +6211,8 @@ void WrappedID3D11DeviceContext::CopyStructureCount(ID3D11Buffer *pDstBuffer,
m_ContextRecord->AddChunk(scope.Get());
m_MissingTracks.insert(GetIDForResource(pDstBuffer));
MarkDirtyResource(GetIDForResource(pDstBuffer));
MarkResourceReferenced(GetIDForResource(pDstBuffer), eFrameRef_Read);
MarkResourceReferenced(GetIDForResource(pDstBuffer), eFrameRef_PartialWrite);
@@ -6256,7 +6232,7 @@ void WrappedID3D11DeviceContext::CopyStructureCount(ID3D11Buffer *pDstBuffer,
record->AddParent(srcRecord);
MarkDirtyResource(GetViewResourceResID(pSrcView));
MarkDirtyResource(GetIDForResource(pDstBuffer));
}
}
@@ -6350,7 +6326,7 @@ void WrappedID3D11DeviceContext::ResolveSubresource(ID3D11Resource *pDstResource
m_ContextRecord->AddChunk(scope.Get());
m_MissingTracks.insert(GetIDForResource(pDstResource));
MarkDirtyResource(GetIDForResource(pDstResource));
MarkResourceReferenced(GetIDForResource(pDstResource), eFrameRef_Read);
MarkResourceReferenced(GetIDForResource(pDstResource), eFrameRef_PartialWrite);
MarkResourceReferenced(GetIDForResource(pSrcResource), eFrameRef_Read);
@@ -6430,7 +6406,7 @@ void WrappedID3D11DeviceContext::GenerateMips(ID3D11ShaderResourceView *pShaderR
ResourceId id = GetViewResourceResID(pShaderResourceView);
m_MissingTracks.insert(id);
MarkDirtyResource(id);
MarkResourceReferenced(id, eFrameRef_Read);
MarkResourceReferenced(id, eFrameRef_PartialWrite);
@@ -6556,7 +6532,7 @@ void WrappedID3D11DeviceContext::ClearRenderTargetView(ID3D11RenderTargetView *p
MarkResourceReferenced(GetIDForResource(pRenderTargetView), eFrameRef_Read);
}
m_MissingTracks.insert(GetViewResourceResID(pRenderTargetView));
MarkDirtyResource(GetViewResourceResID(pRenderTargetView));
m_ContextRecord->AddChunk(scope.Get());
}
@@ -6636,7 +6612,7 @@ void WrappedID3D11DeviceContext::ClearUnorderedAccessViewUint(
MarkResourceReferenced(GetIDForResource(pUnorderedAccessView), eFrameRef_Read);
}
m_MissingTracks.insert(GetViewResourceResID(pUnorderedAccessView));
MarkDirtyResource(GetViewResourceResID(pUnorderedAccessView));
m_ContextRecord->AddChunk(scope.Get());
}
@@ -6716,7 +6692,7 @@ void WrappedID3D11DeviceContext::ClearUnorderedAccessViewFloat(
MarkResourceReferenced(GetIDForResource(pUnorderedAccessView), eFrameRef_Read);
}
m_MissingTracks.insert(GetViewResourceResID(pUnorderedAccessView));
MarkDirtyResource(GetViewResourceResID(pUnorderedAccessView));
m_ContextRecord->AddChunk(scope.Get());
}
@@ -6809,7 +6785,7 @@ void WrappedID3D11DeviceContext::ClearDepthStencilView(ID3D11DepthStencilView *p
MarkResourceReferenced(GetIDForResource(pDepthStencilView), eFrameRef_Read);
}
m_MissingTracks.insert(GetViewResourceResID(pDepthStencilView));
MarkDirtyResource(GetViewResourceResID(pDepthStencilView));
m_ContextRecord->AddChunk(scope.Get());
}
@@ -7600,7 +7576,7 @@ HRESULT WrappedID3D11DeviceContext::Map(ID3D11Resource *pResource, UINT Subresou
}
else
{
m_MissingTracks.insert(GetIDForResource(pResource));
GetResourceManager()->MarkDirtyResource(GetIDForResource(pResource));
// create a chunk purely for the user's benefit
USE_SCRATCH_SERIALISER();
-2
View File
@@ -2402,8 +2402,6 @@ void WrappedID3D11Device::ReleaseResource(ID3D11DeviceChild *res)
SCOPED_LOCK(m_D3DLock);
GetResourceManager()->MarkCleanResource(idx);
if(WrappedID3D11DeviceContext::IsAlloc(res))
RemoveDeferredContext((WrappedID3D11DeviceContext *)res);
@@ -375,18 +375,10 @@ void WrappedID3D12CommandQueue::ExecuteCommandListsInternal(UINT NumCommandLists
// the submit chunk to the frame record don't have to be protected.
// Only the decision of whether we're inframe or not, and marking
// dirty.
if(capframe)
{
for(auto it = record->bakedCommands->cmdInfo->dirtied.begin();
it != record->bakedCommands->cmdInfo->dirtied.end(); ++it)
GetResourceManager()->MarkPendingDirty(*it);
}
else
{
for(auto it = record->bakedCommands->cmdInfo->dirtied.begin();
it != record->bakedCommands->cmdInfo->dirtied.end(); ++it)
GetResourceManager()->MarkDirtyResource(*it);
}
for(auto it = record->bakedCommands->cmdInfo->dirtied.begin();
it != record->bakedCommands->cmdInfo->dirtied.end(); ++it)
GetResourceManager()->MarkDirtyResource(*it);
if(capframe)
{
@@ -521,7 +513,7 @@ void WrappedID3D12CommandQueue::ExecuteCommandListsInternal(UINT NumCommandLists
// update comparison shadow for next time
memcpy(ref, res->GetMap(subres), size);
GetResourceManager()->MarkPendingDirty(res->GetResourceID());
GetResourceManager()->MarkDirtyResource(res->GetResourceID());
}
else
{
-4
View File
@@ -1855,8 +1855,6 @@ bool WrappedID3D12Device::EndFrameCapture(void *dev, void *wnd)
GetResourceManager()->FreeInitialContents();
GetResourceManager()->FlushPendingDirty();
FlushPendingDescriptorWrites();
return true;
@@ -1901,8 +1899,6 @@ bool WrappedID3D12Device::DiscardFrameCapture(void *dev, void *wnd)
GetResourceManager()->FreeInitialContents();
GetResourceManager()->FlushPendingDirty();
FlushPendingDescriptorWrites();
return true;
+4 -28
View File
@@ -764,13 +764,7 @@ HRESULT WrappedID3D12Device::CreateDescriptorHeap(const D3D12_DESCRIPTOR_HEAP_DE
record->AddChunk(scope.Get());
{
SCOPED_READLOCK(m_CapTransitionLock);
if(IsBackgroundCapturing(m_State))
GetResourceManager()->MarkDirtyResource(wrapped->GetResourceID());
else
GetResourceManager()->MarkPendingDirty(wrapped->GetResourceID());
}
GetResourceManager()->MarkDirtyResource(wrapped->GetResourceID());
}
else
{
@@ -1346,13 +1340,7 @@ HRESULT WrappedID3D12Device::CreateCommittedResource(const D3D12_HEAP_PROPERTIES
record->AddChunk(scope.Get());
{
SCOPED_READLOCK(m_CapTransitionLock);
if(IsBackgroundCapturing(m_State))
GetResourceManager()->MarkDirtyResource(wrapped->GetResourceID());
else
GetResourceManager()->MarkPendingDirty(wrapped->GetResourceID());
}
GetResourceManager()->MarkDirtyResource(wrapped->GetResourceID());
}
else
{
@@ -1616,13 +1604,7 @@ HRESULT WrappedID3D12Device::CreatePlacedResource(ID3D12Heap *pHeap, UINT64 Heap
record->AddParent(GetRecord(pHeap));
record->AddChunk(scope.Get());
{
SCOPED_READLOCK(m_CapTransitionLock);
if(IsBackgroundCapturing(m_State))
GetResourceManager()->MarkDirtyResource(wrapped->GetResourceID());
else
GetResourceManager()->MarkPendingDirty(wrapped->GetResourceID());
}
GetResourceManager()->MarkDirtyResource(wrapped->GetResourceID());
}
else
{
@@ -2338,13 +2320,7 @@ HRESULT WrappedID3D12Device::OpenSharedHandle(HANDLE NTHandle, REFIID riid, void
record->AddChunk(scope.Get());
{
SCOPED_READLOCK(m_CapTransitionLock);
if(IsBackgroundCapturing(m_State))
GetResourceManager()->MarkDirtyResource(wrapped->GetResourceID());
else
GetResourceManager()->MarkPendingDirty(wrapped->GetResourceID());
}
GetResourceManager()->MarkDirtyResource(wrapped->GetResourceID());
{
SCOPED_LOCK(m_ResourceStatesLock);
@@ -359,13 +359,7 @@ HRESULT WrappedID3D12Device::CreateCommittedResource1(
record->AddChunk(scope.Get());
{
SCOPED_READLOCK(m_CapTransitionLock);
if(IsBackgroundCapturing(m_State))
GetResourceManager()->MarkDirtyResource(wrapped->GetResourceID());
else
GetResourceManager()->MarkPendingDirty(wrapped->GetResourceID());
}
GetResourceManager()->MarkDirtyResource(wrapped->GetResourceID());
}
else
{
-10
View File
@@ -1677,8 +1677,6 @@ void WrappedOpenGL::SwapBuffers(void *windowHandle)
m_FrameCounter++; // first present becomes frame #1, this function is at the end of the frame
GetResourceManager()->FlushPendingDirty();
ContextData &ctxdata = GetCtxData();
// we only handle context-window associations here as it's too common to
@@ -2360,14 +2358,6 @@ void WrappedOpenGL::CleanupCapture()
{
CleanupResourceRecord(it->second.m_ContextDataRecord, true);
}
for(auto it = m_MissingTracks.begin(); it != m_MissingTracks.end(); ++it)
{
if(GetResourceManager()->HasResourceRecord(*it))
GetResourceManager()->MarkDirtyResource(*it);
}
m_MissingTracks.clear();
}
void WrappedOpenGL::FreeCaptureData()
-3
View File
@@ -164,8 +164,6 @@ private:
ResourceId m_ContextResourceID;
GLResourceRecord *m_ContextRecord;
set<ResourceId> m_MissingTracks;
GLResourceManager *m_ResourceManager;
SDFile *m_StructuredFile;
@@ -564,7 +562,6 @@ public:
void RegisterDebugCallback();
bool IsUnsafeDraw(uint32_t eventId) { return m_UnsafeDraws.find(eventId) != m_UnsafeDraws.end(); }
void AddMissingTrack(ResourceId id) { m_MissingTracks.insert(id); }
// replay interface
void Initialise(GLInitParams &params, uint64_t sectionVersion);
void ReplayLog(uint32_t startEventID, uint32_t endEventID, ReplayLogType replayType);
-3
View File
@@ -128,10 +128,7 @@ void GLResourceManager::SetInternalResource(GLResource res)
bool GLResourceManager::ResourceTypeRelease(GLResource res)
{
if(HasCurrentResource(res))
{
MarkCleanResource(res);
UnregisterResource(res);
}
m_Driver->QueueResourceRelease(res);
return true;
-4
View File
@@ -110,7 +110,6 @@ public:
{
++count;
ResourceId res = it->second;
MarkCleanResource(res);
if(HasResourceRecord(res))
GetResourceRecord(res)->Delete(this);
ReleaseCurrentResource(it->second);
@@ -216,9 +215,6 @@ public:
using ResourceManager::MarkDirtyResource;
void MarkDirtyResource(GLResource res) { return ResourceManager::MarkDirtyResource(GetID(res)); }
using ResourceManager::MarkCleanResource;
void MarkCleanResource(GLResource res) { return ResourceManager::MarkCleanResource(GetID(res)); }
void RegisterSync(ContextPair &ctx, GLsync sync, GLuint &name, ResourceId &id)
{
name = (GLuint)Atomic::Inc64(&m_SyncName);
+3 -2
View File
@@ -475,7 +475,6 @@ void GLRenderState::MarkReferenced(WrappedOpenGL *driver, bool initial) const
{
manager->MarkResourceFrameReferenced(Images[i].res,
initial ? eFrameRef_None : eFrameRef_ReadBeforeWrite);
driver->AddMissingTrack(manager->GetID(Images[i].res));
}
manager->MarkVAOReferenced(VAO, initial ? eFrameRef_None : eFrameRef_Read, true);
@@ -517,9 +516,11 @@ void GLRenderState::MarkReferenced(WrappedOpenGL *driver, bool initial) const
// if same FBO is bound to both targets, treat it as draw only
if(ReadFBO != DrawFBO)
manager->MarkFBOReferenced(ReadFBO, initial ? eFrameRef_None : eFrameRef_Read);
MarkDirty(driver);
}
void GLRenderState::MarkDirty(WrappedOpenGL *driver)
void GLRenderState::MarkDirty(WrappedOpenGL *driver) const
{
GLResourceManager *manager = driver->GetResourceManager();
+1 -1
View File
@@ -78,7 +78,7 @@ struct GLRenderState
void Clear();
void MarkReferenced(WrappedOpenGL *driver, bool initial) const;
void MarkDirty(WrappedOpenGL *driver);
void MarkDirty(WrappedOpenGL *driver) const;
enum
{
@@ -384,10 +384,7 @@ void WrappedOpenGL::glBindBuffer(GLenum target, GLuint buffer)
if(target == eGL_TRANSFORM_FEEDBACK_BUFFER || target == eGL_SHADER_STORAGE_BUFFER ||
target == eGL_ATOMIC_COUNTER_BUFFER)
{
if(IsBackgroundCapturing(m_State))
GetResourceManager()->MarkDirtyResource(r->GetResourceID());
else
m_MissingTracks.insert(r->GetResourceID());
GetResourceManager()->MarkDirtyResource(r->GetResourceID());
}
}
else
@@ -932,7 +929,7 @@ void WrappedOpenGL::glNamedBufferSubDataEXT(GLuint buffer, GLintptr offset, GLsi
if(IsActiveCapturing(m_State))
{
GetContextRecord()->AddChunk(chunk);
m_MissingTracks.insert(record->GetResourceID());
GetResourceManager()->MarkDirtyResource(record->GetResourceID());
GetResourceManager()->MarkResourceFrameReferenced(record->GetResourceID(),
eFrameRef_ReadBeforeWrite);
}
@@ -985,7 +982,7 @@ void WrappedOpenGL::glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr s
if(IsActiveCapturing(m_State))
{
GetContextRecord()->AddChunk(chunk);
m_MissingTracks.insert(record->GetResourceID());
GetResourceManager()->MarkDirtyResource(record->GetResourceID());
GetResourceManager()->MarkResourceFrameReferenced(record->GetResourceID(),
eFrameRef_ReadBeforeWrite);
}
@@ -1066,7 +1063,7 @@ void WrappedOpenGL::glNamedCopyBufferSubDataEXT(GLuint readBuffer, GLuint writeB
if(IsActiveCapturing(m_State))
{
GetContextRecord()->AddChunk(chunk);
m_MissingTracks.insert(writerecord->GetResourceID());
GetResourceManager()->MarkDirtyResource(writerecord->GetResourceID());
GetResourceManager()->MarkResourceFrameReferenced(writerecord->GetResourceID(),
eFrameRef_ReadBeforeWrite);
}
@@ -1127,7 +1124,7 @@ void WrappedOpenGL::glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, G
if(IsActiveCapturing(m_State))
{
GetContextRecord()->AddChunk(chunk);
m_MissingTracks.insert(writerecord->GetResourceID());
GetResourceManager()->MarkDirtyResource(writerecord->GetResourceID());
GetResourceManager()->MarkResourceFrameReferenced(writerecord->GetResourceID(),
eFrameRef_ReadBeforeWrite);
}
@@ -1257,10 +1254,7 @@ void WrappedOpenGL::glBindBufferBase(GLenum target, GLuint index, GLuint buffer)
if(r && (target == eGL_TRANSFORM_FEEDBACK_BUFFER || target == eGL_SHADER_STORAGE_BUFFER ||
target == eGL_ATOMIC_COUNTER_BUFFER))
{
if(IsActiveCapturing(m_State))
m_MissingTracks.insert(r->GetResourceID());
else
GetResourceManager()->MarkDirtyResource(BufferRes(GetCtx(), buffer));
GetResourceManager()->MarkDirtyResource(BufferRes(GetCtx(), buffer));
}
if(IsActiveCapturing(m_State))
@@ -1389,10 +1383,7 @@ void WrappedOpenGL::glBindBufferRange(GLenum target, GLuint index, GLuint buffer
if(r && (target == eGL_TRANSFORM_FEEDBACK_BUFFER || target == eGL_SHADER_STORAGE_BUFFER ||
target == eGL_ATOMIC_COUNTER_BUFFER))
{
if(IsActiveCapturing(m_State))
m_MissingTracks.insert(r->GetResourceID());
else
GetResourceManager()->MarkDirtyResource(BufferRes(GetCtx(), buffer));
GetResourceManager()->MarkDirtyResource(BufferRes(GetCtx(), buffer));
}
if(IsActiveCapturing(m_State))
@@ -1480,7 +1471,7 @@ void WrappedOpenGL::glBindBuffersBase(GLenum target, GLuint first, GLsizei count
{
ResourceId id = GetResourceManager()->GetID(BufferRes(GetCtx(), buffers[i]));
GetResourceManager()->MarkResourceFrameReferenced(id, eFrameRef_ReadBeforeWrite);
m_MissingTracks.insert(id);
GetResourceManager()->MarkDirtyResource(id);
}
}
@@ -1679,7 +1670,7 @@ void WrappedOpenGL::glBindBuffersRange(GLenum target, GLuint first, GLsizei coun
{
ResourceId id = GetResourceManager()->GetID(BufferRes(GetCtx(), buffers[i]));
GetResourceManager()->MarkResourceFrameReferenced(id, eFrameRef_ReadBeforeWrite);
m_MissingTracks.insert(id);
GetResourceManager()->MarkDirtyResource(id);
}
}
@@ -1774,20 +1765,14 @@ void WrappedOpenGL::glInvalidateBufferData(GLuint buffer)
{
GL.glInvalidateBufferData(buffer);
if(IsBackgroundCapturing(m_State))
GetResourceManager()->MarkDirtyResource(BufferRes(GetCtx(), buffer));
else
m_MissingTracks.insert(GetResourceManager()->GetID(BufferRes(GetCtx(), buffer)));
GetResourceManager()->MarkDirtyResource(BufferRes(GetCtx(), buffer));
}
void WrappedOpenGL::glInvalidateBufferSubData(GLuint buffer, GLintptr offset, GLsizeiptr length)
{
GL.glInvalidateBufferSubData(buffer, offset, length);
if(IsBackgroundCapturing(m_State))
GetResourceManager()->MarkDirtyResource(BufferRes(GetCtx(), buffer));
else
m_MissingTracks.insert(GetResourceManager()->GetID(BufferRes(GetCtx(), buffer)));
GetResourceManager()->MarkDirtyResource(BufferRes(GetCtx(), buffer));
}
#pragma endregion
@@ -2348,7 +2333,7 @@ GLboolean WrappedOpenGL::glUnmapNamedBufferEXT(GLuint buffer)
if(IsActiveCapturing(m_State))
{
m_MissingTracks.insert(record->GetResourceID());
GetResourceManager()->MarkDirtyResource(record->GetResourceID());
GetResourceManager()->MarkResourceFrameReferenced(record->GetResourceID(),
eFrameRef_ReadBeforeWrite);
}
@@ -2550,7 +2535,7 @@ void WrappedOpenGL::glFlushMappedNamedBufferRangeEXT(GLuint buffer, GLintptr off
{
if(record)
{
m_MissingTracks.insert(record->GetResourceID());
GetResourceManager()->MarkDirtyResource(record->GetResourceID());
GetResourceManager()->MarkResourceFrameReferenced(record->GetResourceID(),
eFrameRef_ReadBeforeWrite);
@@ -2836,7 +2821,6 @@ void WrappedOpenGL::glDeleteTransformFeedbacks(GLsizei n, const GLuint *ids)
GLResource res = FeedbackRes(GetCtx(), ids[i]);
if(GetResourceManager()->HasCurrentResource(res))
{
GetResourceManager()->MarkCleanResource(res);
if(GetResourceManager()->HasResourceRecord(res))
GetResourceManager()->GetResourceRecord(res)->Delete(GetResourceManager());
GetResourceManager()->UnregisterResource(res);
@@ -4742,7 +4726,6 @@ void WrappedOpenGL::glDeleteBuffers(GLsizei n, const GLuint *buffers)
record->FreeShadowStorage();
}
GetResourceManager()->MarkCleanResource(res);
if(GetResourceManager()->HasResourceRecord(res))
GetResourceManager()->GetResourceRecord(res)->Delete(GetResourceManager());
GetResourceManager()->UnregisterResource(res);
@@ -4759,7 +4742,6 @@ void WrappedOpenGL::glDeleteVertexArrays(GLsizei n, const GLuint *arrays)
GLResource res = VertexArrayRes(GetCtx(), arrays[i]);
if(GetResourceManager()->HasCurrentResource(res))
{
GetResourceManager()->MarkCleanResource(res);
if(GetResourceManager()->HasResourceRecord(res))
GetResourceManager()->GetResourceRecord(res)->Delete(GetResourceManager());
GetResourceManager()->UnregisterResource(res);
@@ -4427,7 +4427,7 @@ void WrappedOpenGL::glClearTexImage(GLuint texture, GLint level, GLenum format,
Serialise_glClearTexImage(ser, texture, level, format, type, data);
GetContextRecord()->AddChunk(scope.Get());
m_MissingTracks.insert(GetResourceManager()->GetID(TextureRes(GetCtx(), texture)));
GetResourceManager()->MarkDirtyResource(TextureRes(GetCtx(), texture));
}
else if(IsBackgroundCapturing(m_State))
{
@@ -4544,7 +4544,7 @@ void WrappedOpenGL::glClearTexSubImage(GLuint texture, GLint level, GLint xoffse
depth, format, type, data);
GetContextRecord()->AddChunk(scope.Get());
m_MissingTracks.insert(GetResourceManager()->GetID(TextureRes(GetCtx(), texture)));
GetResourceManager()->MarkDirtyResource(TextureRes(GetCtx(), texture));
}
else if(IsBackgroundCapturing(m_State))
{
@@ -191,12 +191,7 @@ void WrappedOpenGL::glNamedFramebufferTextureEXT(GLuint framebuffer, GLenum atta
if(texture != 0 && GetResourceManager()->HasResourceRecord(TextureRes(GetCtx(), texture)))
{
ResourceRecord *texrecord =
GetResourceManager()->GetResourceRecord(TextureRes(GetCtx(), texture));
if(IsBackgroundCapturing(m_State))
GetResourceManager()->MarkDirtyResource(texrecord->GetResourceID());
else
m_MissingTracks.insert(texrecord->GetResourceID());
GetResourceManager()->MarkDirtyResource(TextureRes(GetCtx(), texture));
}
if(m_HighTrafficResources.find(record->GetResourceID()) != m_HighTrafficResources.end() &&
@@ -249,12 +244,7 @@ void WrappedOpenGL::glFramebufferTexture(GLenum target, GLenum attachment, GLuin
if(texture != 0 && GetResourceManager()->HasResourceRecord(TextureRes(GetCtx(), texture)))
{
ResourceRecord *texrecord =
GetResourceManager()->GetResourceRecord(TextureRes(GetCtx(), texture));
if(IsBackgroundCapturing(m_State))
GetResourceManager()->MarkDirtyResource(texrecord->GetResourceID());
else
m_MissingTracks.insert(texrecord->GetResourceID());
GetResourceManager()->MarkDirtyResource(TextureRes(GetCtx(), texture));
}
if(m_HighTrafficResources.find(record->GetResourceID()) != m_HighTrafficResources.end() &&
@@ -335,12 +325,7 @@ void WrappedOpenGL::glNamedFramebufferTexture1DEXT(GLuint framebuffer, GLenum at
if(texture != 0 && GetResourceManager()->HasResourceRecord(TextureRes(GetCtx(), texture)))
{
ResourceRecord *texrecord =
GetResourceManager()->GetResourceRecord(TextureRes(GetCtx(), texture));
if(IsBackgroundCapturing(m_State))
GetResourceManager()->MarkDirtyResource(texrecord->GetResourceID());
else
m_MissingTracks.insert(texrecord->GetResourceID());
GetResourceManager()->MarkDirtyResource(TextureRes(GetCtx(), texture));
}
if(m_HighTrafficResources.find(record->GetResourceID()) != m_HighTrafficResources.end() &&
@@ -394,12 +379,7 @@ void WrappedOpenGL::glFramebufferTexture1D(GLenum target, GLenum attachment, GLe
if(texture != 0 && GetResourceManager()->HasResourceRecord(TextureRes(GetCtx(), texture)))
{
ResourceRecord *texrecord =
GetResourceManager()->GetResourceRecord(TextureRes(GetCtx(), texture));
if(IsBackgroundCapturing(m_State))
GetResourceManager()->MarkDirtyResource(texrecord->GetResourceID());
else
m_MissingTracks.insert(texrecord->GetResourceID());
GetResourceManager()->MarkDirtyResource(TextureRes(GetCtx(), texture));
}
if(m_HighTrafficResources.find(record->GetResourceID()) != m_HighTrafficResources.end() &&
@@ -481,12 +461,7 @@ void WrappedOpenGL::glNamedFramebufferTexture2DEXT(GLuint framebuffer, GLenum at
if(texture != 0 && GetResourceManager()->HasResourceRecord(TextureRes(GetCtx(), texture)))
{
ResourceRecord *texrecord =
GetResourceManager()->GetResourceRecord(TextureRes(GetCtx(), texture));
if(IsBackgroundCapturing(m_State))
GetResourceManager()->MarkDirtyResource(texrecord->GetResourceID());
else
m_MissingTracks.insert(texrecord->GetResourceID());
GetResourceManager()->MarkDirtyResource(TextureRes(GetCtx(), texture));
}
if(m_HighTrafficResources.find(record->GetResourceID()) != m_HighTrafficResources.end() &&
@@ -540,12 +515,7 @@ void WrappedOpenGL::glFramebufferTexture2D(GLenum target, GLenum attachment, GLe
if(texture != 0 && GetResourceManager()->HasResourceRecord(TextureRes(GetCtx(), texture)))
{
ResourceRecord *texrecord =
GetResourceManager()->GetResourceRecord(TextureRes(GetCtx(), texture));
if(IsBackgroundCapturing(m_State))
GetResourceManager()->MarkDirtyResource(texrecord->GetResourceID());
else
m_MissingTracks.insert(texrecord->GetResourceID());
GetResourceManager()->MarkDirtyResource(TextureRes(GetCtx(), texture));
}
if(m_HighTrafficResources.find(record->GetResourceID()) != m_HighTrafficResources.end() &&
@@ -651,12 +621,7 @@ void WrappedOpenGL::glFramebufferTexture2DMultisampleEXT(GLenum target, GLenum a
if(texture != 0 && GetResourceManager()->HasResourceRecord(TextureRes(GetCtx(), texture)))
{
ResourceRecord *texrecord =
GetResourceManager()->GetResourceRecord(TextureRes(GetCtx(), texture));
if(IsBackgroundCapturing(m_State))
GetResourceManager()->MarkDirtyResource(texrecord->GetResourceID());
else
m_MissingTracks.insert(texrecord->GetResourceID());
GetResourceManager()->MarkDirtyResource(TextureRes(GetCtx(), texture));
}
if(m_HighTrafficResources.find(record->GetResourceID()) != m_HighTrafficResources.end() &&
@@ -742,12 +707,7 @@ void WrappedOpenGL::glNamedFramebufferTexture3DEXT(GLuint framebuffer, GLenum at
if(texture != 0 && GetResourceManager()->HasResourceRecord(TextureRes(GetCtx(), texture)))
{
ResourceRecord *texrecord =
GetResourceManager()->GetResourceRecord(TextureRes(GetCtx(), texture));
if(IsBackgroundCapturing(m_State))
GetResourceManager()->MarkDirtyResource(texrecord->GetResourceID());
else
m_MissingTracks.insert(texrecord->GetResourceID());
GetResourceManager()->MarkDirtyResource(TextureRes(GetCtx(), texture));
}
if(m_HighTrafficResources.find(record->GetResourceID()) != m_HighTrafficResources.end() &&
@@ -803,12 +763,7 @@ void WrappedOpenGL::glFramebufferTexture3D(GLenum target, GLenum attachment, GLe
if(texture != 0 && GetResourceManager()->HasResourceRecord(TextureRes(GetCtx(), texture)))
{
ResourceRecord *texrecord =
GetResourceManager()->GetResourceRecord(TextureRes(GetCtx(), texture));
if(IsBackgroundCapturing(m_State))
GetResourceManager()->MarkDirtyResource(texrecord->GetResourceID());
else
m_MissingTracks.insert(texrecord->GetResourceID());
GetResourceManager()->MarkDirtyResource(TextureRes(GetCtx(), texture));
}
if(m_HighTrafficResources.find(record->GetResourceID()) != m_HighTrafficResources.end() &&
@@ -1021,12 +976,7 @@ void WrappedOpenGL::glNamedFramebufferTextureLayerEXT(GLuint framebuffer, GLenum
if(texture != 0 && GetResourceManager()->HasResourceRecord(TextureRes(GetCtx(), texture)))
{
ResourceRecord *texrecord =
GetResourceManager()->GetResourceRecord(TextureRes(GetCtx(), texture));
if(IsBackgroundCapturing(m_State))
GetResourceManager()->MarkDirtyResource(texrecord->GetResourceID());
else
m_MissingTracks.insert(texrecord->GetResourceID());
GetResourceManager()->MarkDirtyResource(TextureRes(GetCtx(), texture));
}
if(m_HighTrafficResources.find(record->GetResourceID()) != m_HighTrafficResources.end() &&
@@ -1080,12 +1030,7 @@ void WrappedOpenGL::glFramebufferTextureLayer(GLenum target, GLenum attachment,
if(texture != 0 && GetResourceManager()->HasResourceRecord(TextureRes(GetCtx(), texture)))
{
ResourceRecord *texrecord =
GetResourceManager()->GetResourceRecord(TextureRes(GetCtx(), texture));
if(IsBackgroundCapturing(m_State))
GetResourceManager()->MarkDirtyResource(texrecord->GetResourceID());
else
m_MissingTracks.insert(texrecord->GetResourceID());
GetResourceManager()->MarkDirtyResource(TextureRes(GetCtx(), texture));
}
if(m_HighTrafficResources.find(record->GetResourceID()) != m_HighTrafficResources.end() &&
@@ -1188,12 +1133,7 @@ void WrappedOpenGL::glFramebufferTextureMultiviewOVR(GLenum target, GLenum attac
if(texture != 0 && GetResourceManager()->HasResourceRecord(TextureRes(GetCtx(), texture)))
{
ResourceRecord *texrecord =
GetResourceManager()->GetResourceRecord(TextureRes(GetCtx(), texture));
if(IsBackgroundCapturing(m_State))
GetResourceManager()->MarkDirtyResource(texrecord->GetResourceID());
else
m_MissingTracks.insert(texrecord->GetResourceID());
GetResourceManager()->MarkDirtyResource(TextureRes(GetCtx(), texture));
}
if(m_HighTrafficResources.find(record->GetResourceID()) != m_HighTrafficResources.end() &&
@@ -1307,12 +1247,7 @@ void WrappedOpenGL::glFramebufferTextureMultisampleMultiviewOVR(GLenum target, G
if(texture != 0 && GetResourceManager()->HasResourceRecord(TextureRes(GetCtx(), texture)))
{
ResourceRecord *texrecord =
GetResourceManager()->GetResourceRecord(TextureRes(GetCtx(), texture));
if(IsBackgroundCapturing(m_State))
GetResourceManager()->MarkDirtyResource(texrecord->GetResourceID());
else
m_MissingTracks.insert(texrecord->GetResourceID());
GetResourceManager()->MarkDirtyResource(TextureRes(GetCtx(), texture));
}
if(m_HighTrafficResources.find(record->GetResourceID()) != m_HighTrafficResources.end() &&
@@ -2044,7 +1979,6 @@ void WrappedOpenGL::glDeleteFramebuffers(GLsizei n, const GLuint *framebuffers)
GLResource res = FramebufferRes(GetCtx(), framebuffers[i]);
if(GetResourceManager()->HasCurrentResource(res))
{
GetResourceManager()->MarkCleanResource(res);
if(GetResourceManager()->HasResourceRecord(res))
GetResourceManager()->GetResourceRecord(res)->Delete(GetResourceManager());
GetResourceManager()->UnregisterResource(res);
@@ -2198,7 +2132,6 @@ void WrappedOpenGL::glDeleteRenderbuffers(GLsizei n, const GLuint *renderbuffers
GLResource res = RenderbufferRes(GetCtx(), renderbuffers[i]);
if(GetResourceManager()->HasCurrentResource(res))
{
GetResourceManager()->MarkCleanResource(res);
if(GetResourceManager()->HasResourceRecord(res))
GetResourceManager()->GetResourceRecord(res)->Delete(GetResourceManager());
GetResourceManager()->UnregisterResource(res);
@@ -1266,7 +1266,6 @@ void WrappedOpenGL::glDeleteProgram(GLuint program)
GLResource res = ProgramRes(GetCtx(), program);
if(GetResourceManager()->HasCurrentResource(res))
{
GetResourceManager()->MarkCleanResource(res);
if(GetResourceManager()->HasResourceRecord(res))
GetResourceManager()->GetResourceRecord(res)->Delete(GetResourceManager());
GetResourceManager()->UnregisterResource(res);
@@ -226,7 +226,6 @@ void WrappedOpenGL::glDeleteTextures(GLsizei n, const GLuint *textures)
GLResource res = TextureRes(GetCtx(), textures[i]);
if(GetResourceManager()->HasCurrentResource(res))
{
GetResourceManager()->MarkCleanResource(res);
if(GetResourceManager()->HasResourceRecord(res))
GetResourceManager()->GetResourceRecord(res)->Delete(GetResourceManager());
GetResourceManager()->UnregisterResource(res);
@@ -748,10 +747,7 @@ void WrappedOpenGL::glTextureView(GLuint texture, GLenum target, GLuint origtext
// mark the underlying resource as dirty to avoid tracking dirty across
// aliased resources etc.
if(IsBackgroundCapturing(m_State))
GetResourceManager()->MarkDirtyResource(origrecord->GetResourceID());
else
m_MissingTracks.insert(origrecord->GetResourceID());
GetResourceManager()->MarkDirtyResource(origrecord->GetResourceID());
}
{
@@ -836,7 +832,7 @@ void WrappedOpenGL::Common_glGenerateTextureMipmapEXT(GLResourceRecord *record,
Serialise_glGenerateTextureMipmapEXT(ser, record->Resource.name, target);
GetContextRecord()->AddChunk(scope.Get());
m_MissingTracks.insert(record->GetResourceID());
GetResourceManager()->MarkDirtyResource(record->GetResourceID());
GetResourceManager()->MarkResourceFrameReferenced(record->GetResourceID(),
eFrameRef_ReadBeforeWrite);
}
@@ -891,10 +887,7 @@ void WrappedOpenGL::glInvalidateTexImage(GLuint texture, GLint level)
{
SERIALISE_TIME_CALL(GL.glInvalidateTexImage(texture, level));
if(IsBackgroundCapturing(m_State))
GetResourceManager()->MarkDirtyResource(TextureRes(GetCtx(), texture));
else
m_MissingTracks.insert(GetResourceManager()->GetID(TextureRes(GetCtx(), texture)));
GetResourceManager()->MarkDirtyResource(TextureRes(GetCtx(), texture));
}
void WrappedOpenGL::glInvalidateTexSubImage(GLuint texture, GLint level, GLint xoffset,
@@ -904,10 +897,7 @@ void WrappedOpenGL::glInvalidateTexSubImage(GLuint texture, GLint level, GLint x
SERIALISE_TIME_CALL(
GL.glInvalidateTexSubImage(texture, level, xoffset, yoffset, zoffset, width, height, depth));
if(IsBackgroundCapturing(m_State))
GetResourceManager()->MarkDirtyResource(TextureRes(GetCtx(), texture));
else
m_MissingTracks.insert(GetResourceManager()->GetID(TextureRes(GetCtx(), texture)));
GetResourceManager()->MarkDirtyResource(TextureRes(GetCtx(), texture));
}
template <typename SerialiserType>
@@ -1008,7 +998,7 @@ void WrappedOpenGL::glCopyImageSubData(GLuint srcName, GLenum srcTarget, GLint s
srcDepth);
GetContextRecord()->AddChunk(scope.Get());
m_MissingTracks.insert(dstrecord->GetResourceID());
GetResourceManager()->MarkDirtyResource(dstrecord->GetResourceID());
GetResourceManager()->MarkResourceFrameReferenced(dstrecord->GetResourceID(),
eFrameRef_CompleteWrite);
GetResourceManager()->MarkResourceFrameReferenced(srcrecord->GetResourceID(), eFrameRef_Read);
@@ -1107,7 +1097,7 @@ void WrappedOpenGL::Common_glCopyTextureSubImage1DEXT(GLResourceRecord *record,
width);
GetContextRecord()->AddChunk(scope.Get());
m_MissingTracks.insert(record->GetResourceID());
GetResourceManager()->MarkDirtyResource(record->GetResourceID());
GetResourceManager()->MarkResourceFrameReferenced(record->GetResourceID(),
eFrameRef_PartialWrite);
}
@@ -1212,7 +1202,7 @@ void WrappedOpenGL::Common_glCopyTextureSubImage2DEXT(GLResourceRecord *record,
yoffset, x, y, width, height);
GetContextRecord()->AddChunk(scope.Get());
m_MissingTracks.insert(record->GetResourceID());
GetResourceManager()->MarkDirtyResource(record->GetResourceID());
GetResourceManager()->MarkResourceFrameReferenced(record->GetResourceID(),
eFrameRef_PartialWrite);
}
@@ -1315,7 +1305,6 @@ void WrappedOpenGL::Common_glCopyTextureSubImage3DEXT(GLResourceRecord *record,
if(IsBackgroundCapturing(m_State))
{
GetResourceManager()->MarkDirtyResource(record->GetResourceID());
m_MissingTracks.insert(record->GetResourceID());
}
else if(IsActiveCapturing(m_State))
{
@@ -1325,7 +1314,7 @@ void WrappedOpenGL::Common_glCopyTextureSubImage3DEXT(GLResourceRecord *record,
yoffset, zoffset, x, y, width, height);
GetContextRecord()->AddChunk(scope.Get());
m_MissingTracks.insert(record->GetResourceID());
GetResourceManager()->MarkDirtyResource(record->GetResourceID());
GetResourceManager()->MarkResourceFrameReferenced(record->GetResourceID(),
eFrameRef_PartialWrite);
}
@@ -2251,10 +2240,7 @@ void WrappedOpenGL::Common_glTextureImage1DEXT(ResourceId texId, GLenum target,
// illegal to re-type textures
record->VerifyDataType(target);
if(IsActiveCapturing(m_State))
m_MissingTracks.insert(record->GetResourceID());
else if(fromunpackbuf)
GetResourceManager()->MarkDirtyResource(record->GetResourceID());
GetResourceManager()->MarkDirtyResource(record->GetResourceID());
}
}
@@ -2498,10 +2484,7 @@ void WrappedOpenGL::Common_glTextureImage2DEXT(ResourceId texId, GLenum target,
// illegal to re-type textures
record->VerifyDataType(target);
if(IsActiveCapturing(m_State))
m_MissingTracks.insert(record->GetResourceID());
else if(fromunpackbuf)
GetResourceManager()->MarkDirtyResource(record->GetResourceID());
GetResourceManager()->MarkDirtyResource(record->GetResourceID());
}
}
@@ -2727,10 +2710,7 @@ void WrappedOpenGL::Common_glTextureImage3DEXT(ResourceId texId, GLenum target,
// illegal to re-type textures
record->VerifyDataType(target);
if(IsActiveCapturing(m_State))
m_MissingTracks.insert(record->GetResourceID());
else if(fromunpackbuf)
GetResourceManager()->MarkDirtyResource(record->GetResourceID());
GetResourceManager()->MarkDirtyResource(record->GetResourceID());
}
}
@@ -2957,10 +2937,7 @@ void WrappedOpenGL::Common_glCompressedTextureImage1DEXT(ResourceId texId, GLenu
// illegal to re-type textures
record->VerifyDataType(target);
if(IsActiveCapturing(m_State))
m_MissingTracks.insert(record->GetResourceID());
else if(fromunpackbuf)
GetResourceManager()->MarkDirtyResource(record->GetResourceID());
GetResourceManager()->MarkDirtyResource(record->GetResourceID());
}
}
@@ -3310,10 +3287,7 @@ void WrappedOpenGL::Common_glCompressedTextureImage2DEXT(ResourceId texId, GLenu
// illegal to re-type textures
record->VerifyDataType(target);
if(IsActiveCapturing(m_State))
m_MissingTracks.insert(record->GetResourceID());
else if(fromunpackbuf)
GetResourceManager()->MarkDirtyResource(record->GetResourceID());
GetResourceManager()->MarkDirtyResource(record->GetResourceID());
}
}
@@ -3547,10 +3521,7 @@ void WrappedOpenGL::Common_glCompressedTextureImage3DEXT(ResourceId texId, GLenu
// illegal to re-type textures
record->VerifyDataType(target);
if(IsActiveCapturing(m_State))
m_MissingTracks.insert(record->GetResourceID());
else if(fromunpackbuf)
GetResourceManager()->MarkDirtyResource(record->GetResourceID());
GetResourceManager()->MarkDirtyResource(record->GetResourceID());
}
}
@@ -3725,7 +3696,7 @@ void WrappedOpenGL::Common_glCopyTextureImage1DEXT(GLResourceRecord *record, GLe
y, width, border);
GetContextRecord()->AddChunk(scope.Get());
m_MissingTracks.insert(record->GetResourceID());
GetResourceManager()->MarkDirtyResource(record->GetResourceID());
GetResourceManager()->MarkResourceFrameReferenced(record->GetResourceID(),
eFrameRef_PartialWrite);
}
@@ -3879,7 +3850,7 @@ void WrappedOpenGL::Common_glCopyTextureImage2DEXT(GLResourceRecord *record, GLe
y, width, height, border);
GetContextRecord()->AddChunk(scope.Get());
m_MissingTracks.insert(record->GetResourceID());
GetResourceManager()->MarkDirtyResource(record->GetResourceID());
GetResourceManager()->MarkResourceFrameReferenced(record->GetResourceID(),
eFrameRef_PartialWrite);
}
@@ -4836,7 +4807,7 @@ void WrappedOpenGL::Common_glTextureSubImage1DEXT(GLResourceRecord *record, GLen
if(IsActiveCapturing(m_State))
{
GetContextRecord()->AddChunk(scope.Get());
m_MissingTracks.insert(record->GetResourceID());
GetResourceManager()->MarkDirtyResource(record->GetResourceID());
GetResourceManager()->MarkResourceFrameReferenced(record->GetResourceID(),
eFrameRef_PartialWrite);
}
@@ -5049,7 +5020,7 @@ void WrappedOpenGL::Common_glTextureSubImage2DEXT(GLResourceRecord *record, GLen
if(IsActiveCapturing(m_State))
{
GetContextRecord()->AddChunk(scope.Get());
m_MissingTracks.insert(record->GetResourceID());
GetResourceManager()->MarkDirtyResource(record->GetResourceID());
GetResourceManager()->MarkResourceFrameReferenced(record->GetResourceID(),
eFrameRef_PartialWrite);
}
@@ -5270,7 +5241,7 @@ void WrappedOpenGL::Common_glTextureSubImage3DEXT(GLResourceRecord *record, GLen
if(IsActiveCapturing(m_State))
{
GetContextRecord()->AddChunk(scope.Get());
m_MissingTracks.insert(record->GetResourceID());
GetResourceManager()->MarkDirtyResource(record->GetResourceID());
GetResourceManager()->MarkResourceFrameReferenced(record->GetResourceID(),
eFrameRef_PartialWrite);
}
@@ -5472,7 +5443,7 @@ void WrappedOpenGL::Common_glCompressedTextureSubImage1DEXT(GLResourceRecord *re
if(IsActiveCapturing(m_State))
{
GetContextRecord()->AddChunk(scope.Get());
m_MissingTracks.insert(record->GetResourceID());
GetResourceManager()->MarkDirtyResource(record->GetResourceID());
GetResourceManager()->MarkResourceFrameReferenced(record->GetResourceID(),
eFrameRef_PartialWrite);
}
@@ -5686,7 +5657,7 @@ void WrappedOpenGL::Common_glCompressedTextureSubImage2DEXT(GLResourceRecord *re
if(IsActiveCapturing(m_State))
{
GetContextRecord()->AddChunk(scope.Get());
m_MissingTracks.insert(record->GetResourceID());
GetResourceManager()->MarkDirtyResource(record->GetResourceID());
GetResourceManager()->MarkResourceFrameReferenced(record->GetResourceID(),
eFrameRef_PartialWrite);
}
@@ -5906,7 +5877,7 @@ void WrappedOpenGL::Common_glCompressedTextureSubImage3DEXT(GLResourceRecord *re
if(IsActiveCapturing(m_State))
{
GetContextRecord()->AddChunk(scope.Get());
m_MissingTracks.insert(record->GetResourceID());
GetResourceManager()->MarkDirtyResource(record->GetResourceID());
GetResourceManager()->MarkResourceFrameReferenced(record->GetResourceID(),
eFrameRef_PartialWrite);
}
@@ -6082,12 +6053,12 @@ void WrappedOpenGL::Common_glTextureBufferRangeEXT(ResourceId texId, GLenum targ
if(IsActiveCapturing(m_State))
{
GetContextRecord()->AddChunk(scope.Get());
m_MissingTracks.insert(record->GetResourceID());
GetResourceManager()->MarkDirtyResource(record->GetResourceID());
GetResourceManager()->MarkResourceFrameReferenced(record->GetResourceID(), eFrameRef_Read);
if(bufid != ResourceId())
{
m_MissingTracks.insert(bufid);
GetResourceManager()->MarkDirtyResource(bufid);
GetResourceManager()->MarkResourceFrameReferenced(bufid, eFrameRef_Read);
}
}
@@ -6258,12 +6229,12 @@ void WrappedOpenGL::Common_glTextureBufferEXT(ResourceId texId, GLenum target,
if(IsActiveCapturing(m_State))
{
GetContextRecord()->AddChunk(chunk);
m_MissingTracks.insert(record->GetResourceID());
GetResourceManager()->MarkDirtyResource(record->GetResourceID());
GetResourceManager()->MarkResourceFrameReferenced(record->GetResourceID(), eFrameRef_Read);
if(bufid != ResourceId())
{
m_MissingTracks.insert(bufid);
GetResourceManager()->MarkDirtyResource(bufid);
GetResourceManager()->MarkResourceFrameReferenced(bufid, eFrameRef_Read);
}
}
+1 -7
View File
@@ -1879,8 +1879,6 @@ bool WrappedVulkan::EndFrameCapture(void *dev, void *wnd)
GetResourceManager()->FreeInitialContents();
GetResourceManager()->FlushPendingDirty();
FreeAllMemory(MemoryScope::InitialContents);
return true;
@@ -1930,8 +1928,6 @@ bool WrappedVulkan::DiscardFrameCapture(void *dev, void *wnd)
GetResourceManager()->FreeInitialContents();
GetResourceManager()->FlushPendingDirty();
FreeAllMemory(MemoryScope::InitialContents);
return true;
@@ -1940,10 +1936,8 @@ bool WrappedVulkan::DiscardFrameCapture(void *dev, void *wnd)
void WrappedVulkan::AdvanceFrame()
{
if(IsBackgroundCapturing(m_State))
{
RenderDoc::Inst().Tick();
GetResourceManager()->FlushPendingDirty();
}
m_FrameCounter++; // first present becomes frame #1, this function is at the end of the frame
}
-1
View File
@@ -326,7 +326,6 @@ public:
if(IsReplayMode(m_State))
ResourceManager::RemoveWrapper(ToTypedHandle(Unwrap(obj)));
ResourceManager::MarkCleanResource(id);
ResourceManager::ReleaseCurrentResource(id);
VkResourceRecord *record = GetRecord(obj);
if(record)
@@ -506,21 +506,11 @@ VkResult WrappedVulkan::vkAllocateDescriptorSets(VkDevice device,
record->AddParent(poolrecord);
record->AddParent(GetResourceManager()->GetResourceRecord(layoutID));
bool capframe = false;
// just always treat descriptor sets as dirty
{
SCOPED_LOCK(m_CapTransitionLock);
capframe = IsActiveCapturing(m_State);
}
// only mark descriptor set as dirty if it's not a push descriptor layout
if((layoutRecord->descInfo->layout->flags &
VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR) == 0)
{
if(capframe)
GetResourceManager()->MarkPendingDirty(id);
else
GetResourceManager()->MarkDirtyResource(id);
GetResourceManager()->MarkDirtyResource(id);
}
record->descInfo = new DescriptorSetData();
@@ -781,6 +781,11 @@ VkResult WrappedVulkan::vkQueueSubmit(VkQueue queue, uint32_t submitCount,
bool capframe = false;
bool present = false;
{
SCOPED_LOCK(m_CapTransitionLock);
capframe = IsActiveCapturing(m_State);
}
set<ResourceId> refdIDs;
VkResourceRecord *queueRecord = GetRecord(queue);
@@ -801,80 +806,32 @@ VkResult WrappedVulkan::vkQueueSubmit(VkQueue queue, uint32_t submitCount,
m_ImageLayouts);
}
// need to lock the whole section of code, not just the check on
// m_State, as we also need to make sure we don't check the state,
// start marking dirty resources then while we're doing so the
// state becomes capframe.
// the next sections where we mark resources referenced and add
// the submit chunk to the frame record don't have to be protected.
// Only the decision of whether we're inframe or not, and marking
// dirty.
for(auto it = record->bakedCommands->cmdInfo->dirtied.begin();
it != record->bakedCommands->cmdInfo->dirtied.end(); ++it)
{
SCOPED_LOCK(m_CapTransitionLock);
if(IsActiveCapturing(m_State))
if(GetResourceManager()->HasCurrentResource(*it))
GetResourceManager()->MarkDirtyResource(*it);
}
// with EXT_descriptor_indexing a binding might have been updated after
// vkCmdBindDescriptorSets, so we need to track dirtied here at the last second.
for(auto it = record->bakedCommands->cmdInfo->boundDescSets.begin();
it != record->bakedCommands->cmdInfo->boundDescSets.end(); ++it)
{
VkResourceRecord *setrecord = GetRecord(*it);
SCOPED_LOCK(setrecord->descInfo->refLock);
const std::map<ResourceId, pair<uint32_t, FrameRefType>> &frameRefs =
setrecord->descInfo->bindFrameRefs;
for(auto refit = frameRefs.begin(); refit != frameRefs.end(); ++refit)
{
for(auto it = record->bakedCommands->cmdInfo->dirtied.begin();
it != record->bakedCommands->cmdInfo->dirtied.end(); ++it)
if(refit->second.second == eFrameRef_PartialWrite ||
refit->second.second == eFrameRef_ReadBeforeWrite)
{
if(GetResourceManager()->HasCurrentResource(*it))
GetResourceManager()->MarkPendingDirty(*it);
}
// with EXT_descriptor_indexing a binding might have been updated after
// vkCmdBindDescriptorSets, so we need to track dirtied here at the last second.
for(auto it = record->bakedCommands->cmdInfo->boundDescSets.begin();
it != record->bakedCommands->cmdInfo->boundDescSets.end(); ++it)
{
VkResourceRecord *setrecord = GetRecord(*it);
SCOPED_LOCK(setrecord->descInfo->refLock);
const std::map<ResourceId, pair<uint32_t, FrameRefType>> &frameRefs =
setrecord->descInfo->bindFrameRefs;
for(auto refit = frameRefs.begin(); refit != frameRefs.end(); ++refit)
{
if(refit->second.second == eFrameRef_PartialWrite ||
refit->second.second == eFrameRef_ReadBeforeWrite)
{
if(GetResourceManager()->HasCurrentResource(refit->first))
GetResourceManager()->MarkPendingDirty(refit->first);
}
}
}
capframe = true;
}
else
{
for(auto it = record->bakedCommands->cmdInfo->dirtied.begin();
it != record->bakedCommands->cmdInfo->dirtied.end(); ++it)
{
if(GetResourceManager()->HasCurrentResource(*it))
GetResourceManager()->MarkDirtyResource(*it);
}
// with EXT_descriptor_indexing a binding might have been updated after
// vkCmdBindDescriptorSets, so we need to track dirtied here at the last second.
for(auto it = record->bakedCommands->cmdInfo->boundDescSets.begin();
it != record->bakedCommands->cmdInfo->boundDescSets.end(); ++it)
{
VkResourceRecord *setrecord = GetRecord(*it);
SCOPED_LOCK(setrecord->descInfo->refLock);
const std::map<ResourceId, pair<uint32_t, FrameRefType>> &frameRefs =
setrecord->descInfo->bindFrameRefs;
for(auto refit = frameRefs.begin(); refit != frameRefs.end(); ++refit)
{
if(refit->second.second == eFrameRef_PartialWrite ||
refit->second.second == eFrameRef_ReadBeforeWrite)
{
if(GetResourceManager()->HasCurrentResource(refit->first))
GetResourceManager()->MarkDirtyResource(refit->first);
}
}
if(GetResourceManager()->HasCurrentResource(refit->first))
GetResourceManager()->MarkDirtyResource(refit->first);
}
}
}
@@ -1030,7 +987,7 @@ VkResult WrappedVulkan::vkQueueSubmit(VkQueue queue, uint32_t submitCount,
state.mapFlushed = false;
}
GetResourceManager()->MarkPendingDirty(record->GetResourceID());
GetResourceManager()->MarkDirtyResource(record->GetResourceID());
}
else
{
@@ -917,17 +917,7 @@ VkResult WrappedVulkan::vkBindBufferMemory(VkDevice device, VkBuffer buffer, VkD
AddForcedReference(GetResID(memory), eFrameRef_ReadBeforeWrite);
// the memory is immediately dirty because we have no way of tracking writes to it
bool capframe = false;
{
SCOPED_LOCK(m_CapTransitionLock);
capframe = IsActiveCapturing(m_State);
}
if(capframe)
GetResourceManager()->MarkPendingDirty(GetResID(memory));
else
GetResourceManager()->MarkDirtyResource(GetResID(memory));
GetResourceManager()->MarkDirtyResource(GetResID(memory));
}
}
@@ -1171,18 +1161,7 @@ VkResult WrappedVulkan::vkCreateBuffer(VkDevice device, const VkBufferCreateInfo
// buffers are always bound opaquely and in arbitrary divisions, sparse residency
// only means not all the buffer needs to be bound, which is not that interesting for
// our purposes. We just need to make sure sparse buffers are dirty.
bool capframe = false;
{
SCOPED_LOCK(m_CapTransitionLock);
capframe = IsActiveCapturing(m_State);
}
if(capframe)
GetResourceManager()->MarkPendingDirty(id);
else
GetResourceManager()->MarkDirtyResource(id);
GetResourceManager()->MarkDirtyResource(id);
}
if(isSparse || isExternal)
@@ -1656,17 +1635,7 @@ VkResult WrappedVulkan::vkCreateImage(VkDevice device, const VkImageCreateInfo *
{
record->resInfo = new ResourceInfo();
bool capframe = false;
{
SCOPED_LOCK(m_CapTransitionLock);
capframe = IsActiveCapturing(m_State);
}
if(capframe)
GetResourceManager()->MarkPendingDirty(id);
else
GetResourceManager()->MarkDirtyResource(id);
GetResourceManager()->MarkDirtyResource(id);
// pre-populate memory requirements
ObjDisp(device)->GetImageMemoryRequirements(Unwrap(device), Unwrap(*pImage),
@@ -2005,17 +1974,7 @@ VkResult WrappedVulkan::vkBindBufferMemory2(VkDevice device, uint32_t bindInfoCo
AddForcedReference(GetResID(pBindInfos[i].memory), eFrameRef_ReadBeforeWrite);
// the memory is immediately dirty because we have no way of tracking writes to it
bool capframe = false;
{
SCOPED_LOCK(m_CapTransitionLock);
capframe = IsActiveCapturing(m_State);
}
if(capframe)
GetResourceManager()->MarkPendingDirty(GetResID(pBindInfos[i].memory));
else
GetResourceManager()->MarkDirtyResource(GetResID(pBindInfos[i].memory));
GetResourceManager()->MarkDirtyResource(GetResID(pBindInfos[i].memory));
}
}
}