Remove forced initial states for resources

* This was used for two things:
  - UAVs on D3D11, which we can just mark dirty at creation as we do
   with things on D3D12/Vulkan where we know we'll always want initial
   states.
  - Texture views/Texture buffers on GL, where we check if the texture
   was referenced and force initial states for the underlying data
   store. This requires a bit more work but can still be achieved by a
   GL-specific force-inclusion pass on the frame references.
This commit is contained in:
baldurk
2019-05-14 11:27:54 +01:00
parent ada97bf7bd
commit 0fd6b0c546
13 changed files with 34 additions and 97 deletions
-47
View File
@@ -569,7 +569,6 @@ protected:
virtual bool ResourceTypeRelease(WrappedResourceType res) = 0;
virtual bool Force_InitialState(WrappedResourceType res, bool prepare) = 0;
virtual bool AllowDeletedResource_InitialState() { return false; }
virtual bool Need_InitialStateChunk(WrappedResourceType res) = 0;
virtual bool Prepare_InitialState(WrappedResourceType res) = 0;
@@ -1052,22 +1051,6 @@ void ResourceManager<Configuration>::PrepareInitialContents()
}
RDCDEBUG("Prepared %u dirty resources", prepared);
prepared = 0;
for(auto it = m_CurrentResourceMap.begin(); it != m_CurrentResourceMap.end(); ++it)
{
if(it->second == (WrappedResourceType)RecordType::NullResource)
continue;
if(Force_InitialState(it->second, true))
{
prepared++;
Prepare_InitialState(it->second);
}
}
RDCDEBUG("Force-prepared %u dirty resources", prepared);
}
template <typename Configuration>
@@ -1160,36 +1143,6 @@ void ResourceManager<Configuration>::InsertInitialContentsChunks(WriteSerialiser
}
RDCDEBUG("Serialised %u resources, skipped %u unreferenced", dirty, skipped);
dirty = 0;
for(auto it = m_CurrentResourceMap.begin(); it != m_CurrentResourceMap.end(); ++it)
{
if(it->second == (WrappedResourceType)RecordType::NullResource)
continue;
if(Force_InitialState(it->second, false))
{
dirty++;
auto preparedChunk = m_InitialChunks.find(it->first);
if(preparedChunk != m_InitialChunks.end())
{
preparedChunk->second->Write(ser);
m_InitialChunks.erase(preparedChunk);
}
else
{
uint64_t size = GetSize_InitialState(it->first, it->second);
SCOPED_SERIALISE_CHUNK(SystemChunk::InitialContents, size);
Serialise_InitialState(ser, it->first, it->second);
}
}
}
RDCDEBUG("Force-serialised %u dirty resources", dirty);
}
template <typename Configuration>
@@ -1016,6 +1016,14 @@ HRESULT WrappedID3D11Device::CreateUnorderedAccessView(ID3D11Resource *pResource
record->AddParent(parent);
record->AddChunk(chunk);
// if this UAV has a hidden counter, immediately mark it as dirty so we force initial
// contents to fetch its counter
if(pDesc->ViewDimension == D3D11_UAV_DIMENSION_BUFFER &&
(pDesc->Buffer.Flags & (D3D11_BUFFER_UAV_FLAG_COUNTER | D3D11_BUFFER_UAV_FLAG_APPEND)) != 0)
{
GetResourceManager()->MarkDirtyResource(id);
}
}
else
{
-5
View File
@@ -72,11 +72,6 @@ bool D3D11ResourceManager::ResourceTypeRelease(ID3D11DeviceChild *res)
return true;
}
bool D3D11ResourceManager::Force_InitialState(ID3D11DeviceChild *res, bool prepare)
{
return IdentifyTypeByPtr(res) == Resource_UnorderedAccessView;
}
bool D3D11ResourceManager::Need_InitialStateChunk(ID3D11DeviceChild *res)
{
return IdentifyTypeByPtr(res) != Resource_Buffer;
-1
View File
@@ -259,7 +259,6 @@ private:
bool ResourceTypeRelease(ID3D11DeviceChild *res);
bool Force_InitialState(ID3D11DeviceChild *res, bool prepare);
bool Need_InitialStateChunk(ID3D11DeviceChild *res);
bool Prepare_InitialState(ID3D11DeviceChild *res);
uint64_t GetSize_InitialState(ResourceId id, ID3D11DeviceChild *res);
@@ -30,11 +30,6 @@
#include "d3d12_manager.h"
#include "d3d12_resources.h"
bool D3D12ResourceManager::Force_InitialState(ID3D12DeviceChild *res, bool prepare)
{
return false;
}
bool D3D12ResourceManager::Need_InitialStateChunk(ID3D12DeviceChild *res)
{
return true;
-1
View File
@@ -713,7 +713,6 @@ private:
bool ResourceTypeRelease(ID3D12DeviceChild *res);
bool Force_InitialState(ID3D12DeviceChild *res, bool prepare);
bool Need_InitialStateChunk(ID3D12DeviceChild *res);
bool Prepare_InitialState(ID3D12DeviceChild *res);
uint64_t GetSize_InitialState(ResourceId id, ID3D12DeviceChild *res);
-5
View File
@@ -45,11 +45,6 @@ bool D3D8ResourceManager::ResourceTypeRelease(IUnknown *res)
return true;
}
bool D3D8ResourceManager::Force_InitialState(IUnknown *res, bool prepare)
{
return false;
}
bool D3D8ResourceManager::Need_InitialStateChunk(IUnknown *res)
{
return true;
-1
View File
@@ -74,7 +74,6 @@ private:
bool ResourceTypeRelease(IUnknown *res);
bool Force_InitialState(IUnknown *res, bool prepare);
bool Need_InitialStateChunk(IUnknown *res);
bool Prepare_InitialState(IUnknown *res);
uint64_t GetSize_InitialState(ResourceId id, IUnknown *res);
+4
View File
@@ -1999,6 +1999,10 @@ bool WrappedOpenGL::EndFrameCapture(void *dev, void *wnd)
SERIALISE_ELEMENT(fbo);
}
RDCDEBUG("Forcing inclusion of views");
GetResourceManager()->Force_ReferenceViews();
RDCDEBUG("Inserting Resource Serialisers");
GetResourceManager()->InsertReferencedChunks(ser);
+20 -25
View File
@@ -1020,42 +1020,37 @@ void GLResourceManager::PrepareTextureInitialContents(ResourceId liveid, Resourc
SetInitialContents(origid, initContents);
}
bool GLResourceManager::Force_InitialState(GLResource res, bool prepare)
void GLResourceManager::Force_ReferenceViews()
{
if(res.Namespace != eResBuffer && res.Namespace != eResTexture)
return false;
// don't need to force anything if we're already including all resources
if(RenderDoc::Inst().GetCaptureOptions().refAllResources)
return false;
return;
GLResourceRecord *record = GetResourceRecord(res);
// if we have some viewers, check to see if they were referenced but we weren't, and force our own
// initial state inclusion.
if(record && !record->viewTextures.empty())
for(auto recordit = m_ResourceRecords.begin(); recordit != m_ResourceRecords.end(); ++recordit)
{
// need to prepare all such resources, just in case for the worst case.
if(prepare)
return true;
GLResourceRecord *record = recordit->second;
// if this data resource was referenced already, just skip
if(m_FrameReferencedResources.find(record->GetResourceID()) != m_FrameReferencedResources.end())
return false;
// see if any of our viewers were referenced
for(auto it = record->viewTextures.begin(); it != record->viewTextures.end(); ++it)
// if this resource has some viewers, check to see if they were referenced by the frame but we
// weren't, and force our own reference as well so that our initial states are included
if(record && !record->viewTextures.empty())
{
// if so, return true to force our inclusion, for the benefit of the view
if(m_FrameReferencedResources.find(*it) != m_FrameReferencedResources.end())
// if this data resource was referenced already, just skip
if(m_FrameReferencedResources.find(record->GetResourceID()) != m_FrameReferencedResources.end())
continue;
// see if any of our viewers were referenced
for(auto it = record->viewTextures.begin(); it != record->viewTextures.end(); ++it)
{
RDCDEBUG("Forcing inclusion of %llu for %llu", record->GetResourceID(), *it);
return true;
// if so, return true to force our inclusion, for the benefit of the view
if(m_FrameReferencedResources.find(*it) != m_FrameReferencedResources.end())
{
RDCDEBUG("Forcing inclusion of %llu for %llu", record->GetResourceID(), *it);
MarkResourceFrameReferenced(record->GetResourceID(), eFrameRef_ReadBeforeWrite);
break;
}
}
}
}
return false;
}
uint64_t GLResourceManager::GetSize_InitialState(ResourceId resid, GLResource res)
+2 -1
View File
@@ -243,6 +243,8 @@ public:
void MarkVAOReferenced(GLResource res, FrameRefType ref, bool allowFake0 = false);
void MarkFBOReferenced(GLResource res, FrameRefType ref);
void Force_ReferenceViews();
template <typename SerialiserType>
bool Serialise_InitialState(SerialiserType &ser, ResourceId resid, GLResource res);
@@ -256,7 +258,6 @@ public:
private:
bool ResourceTypeRelease(GLResource res);
bool Force_InitialState(GLResource res, bool prepare);
bool Need_InitialStateChunk(GLResource res);
bool Prepare_InitialState(GLResource res);
uint64_t GetSize_InitialState(ResourceId resid, GLResource res);
-5
View File
@@ -723,11 +723,6 @@ MemRefs *VulkanResourceManager::FindMemRefs(ResourceId mem)
return NULL;
}
bool VulkanResourceManager::Force_InitialState(WrappedVkRes *res, bool prepare)
{
return false;
}
bool VulkanResourceManager::Need_InitialStateChunk(WrappedVkRes *res)
{
return true;
-1
View File
@@ -435,7 +435,6 @@ public:
private:
bool ResourceTypeRelease(WrappedVkRes *res);
bool Force_InitialState(WrappedVkRes *res, bool prepare);
bool AllowDeletedResource_InitialState() { return true; }
bool Need_InitialStateChunk(WrappedVkRes *res);
bool Prepare_InitialState(WrappedVkRes *res);