mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-27 20:31:02 +00:00
Remove VkResource, switch to WrappedVkRes*, update all but vk_core.cpp
This commit is contained in:
@@ -1823,9 +1823,9 @@ string ToStrHelper<false, VkPresentModeWSI>::Get(const VkPresentModeWSI &el)
|
||||
#define SerialiseObject(type, name, obj) \
|
||||
{ \
|
||||
ResourceId id; \
|
||||
if(m_Mode >= WRITING) id = (obj == VK_NULL_HANDLE) ? ResourceId() : MGR()->GetID(MakeRes(obj)); \
|
||||
if(m_Mode >= WRITING) id = GetResID(obj); \
|
||||
Serialise(name, id); \
|
||||
if(m_Mode < WRITING) obj = (id == ResourceId()) ? VK_NULL_HANDLE : type(MGR()->GetLiveResource(id).handle); \
|
||||
if(m_Mode < WRITING) obj = (id == ResourceId()) ? VK_NULL_HANDLE : type(MGR()->GetLiveResource(id)->real); \
|
||||
}
|
||||
|
||||
static void SerialiseNext(Serialiser *ser, const void *&pNext)
|
||||
|
||||
@@ -1075,23 +1075,14 @@ VkResult WrappedVulkan::vkGetGlobalExtensionProperties(
|
||||
return util_GetExtensionProperties(0, NULL, pCount, pProperties);
|
||||
}
|
||||
|
||||
void WrappedVulkan::DestroyObject(VkResource res, ResourceId id)
|
||||
{
|
||||
GetResourceManager()->MarkCleanResource(id);
|
||||
VkResourceRecord *record = GetResourceManager()->GetResourceRecord(id);
|
||||
if(record)
|
||||
record->Delete(GetResourceManager());
|
||||
GetResourceManager()->UnregisterResource(res);
|
||||
|
||||
if(m_ImageInfo.find(id) != m_ImageInfo.end())
|
||||
m_ImageInfo.erase(id);
|
||||
}
|
||||
|
||||
#define DESTROY_IMPL(type, func) \
|
||||
VkResult WrappedVulkan::vk ## func(VkDevice device, type obj) \
|
||||
{ \
|
||||
DestroyObject(MakeRes(obj), GetResourceManager()->GetID(MakeRes(obj))); \
|
||||
return device_dispatch_table(device)->func(device, obj); \
|
||||
WrappedVkRes *wrapped = GetWrapped(obj);
|
||||
GetResourceManager()->MarkCleanResource(wrapped->id); \
|
||||
if(wrapped->record) wrapped->record->Delete(GetResourceManager()); \
|
||||
if(m_ImageInfo.find(wrapped->id) != m_ImageInfo.end()) m_ImageInfo.erase(wrapped->id); \
|
||||
return device_dispatch_table(device)->func(Unwrap(device), type(wrapped->real)); \
|
||||
}
|
||||
|
||||
DESTROY_IMPL(VkBuffer, DestroyBuffer)
|
||||
|
||||
@@ -436,12 +436,12 @@ public:
|
||||
VulkanReplay *GetReplay() { return &m_Replay; }
|
||||
|
||||
// replay interface
|
||||
bool Prepare_InitialState(VkResource res);
|
||||
bool Serialise_InitialState(VkResource res);
|
||||
void Create_InitialState(ResourceId id, VkResource live, bool hasData);
|
||||
void Apply_InitialState(VkResource live, VulkanResourceManager::InitialContentData initial);
|
||||
bool Prepare_InitialState(WrappedVkRes *res);
|
||||
bool Serialise_InitialState(WrappedVkRes *res);
|
||||
void Create_InitialState(ResourceId id, WrappedVkRes *live, bool hasData);
|
||||
void Apply_InitialState(WrappedVkRes *live, VulkanResourceManager::InitialContentData initial);
|
||||
|
||||
bool ReleaseResource(VkResource res);
|
||||
bool ReleaseResource(WrappedVkRes *res);
|
||||
|
||||
void Initialise(VkInitParams ¶ms);
|
||||
void ReplayLog(uint32_t frameID, uint32_t startEventID, uint32_t endEventID, ReplayLogType replayType);
|
||||
@@ -449,8 +449,6 @@ public:
|
||||
|
||||
vector<FetchFrameRecord> &GetFrameRecord() { return m_FrameRecord; }
|
||||
FetchAPIEvent GetEvent(uint32_t eventID);
|
||||
|
||||
void DestroyObject(VkResource res, ResourceId id);
|
||||
|
||||
// Device initialization
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#include "vk_info.h"
|
||||
|
||||
void VulkanCreationInfo::Pipeline::Init(VulkanResourceManager *rm, const VkGraphicsPipelineCreateInfo* pCreateInfo)
|
||||
void VulkanCreationInfo::Pipeline::Init(const VkGraphicsPipelineCreateInfo* pCreateInfo)
|
||||
{
|
||||
flags = pCreateInfo->flags;
|
||||
|
||||
@@ -33,7 +33,7 @@ void VulkanCreationInfo::Pipeline::Init(VulkanResourceManager *rm, const VkGraph
|
||||
// VkPipelineShaderStageCreateInfo
|
||||
RDCEraseEl(shaders);
|
||||
for(uint32_t i=0; i < pCreateInfo->stageCount; i++)
|
||||
shaders[ pCreateInfo->pStages[i].stage ] = rm->GetOriginalID(rm->GetID(MakeRes(pCreateInfo->pStages[i].shader)));
|
||||
shaders[ pCreateInfo->pStages[i].stage ] = GetResID(pCreateInfo->pStages[i].shader);
|
||||
|
||||
if(pCreateInfo->pVertexInputState)
|
||||
{
|
||||
@@ -110,7 +110,7 @@ void VulkanCreationInfo::Pipeline::Init(VulkanResourceManager *rm, const VkGraph
|
||||
}
|
||||
}
|
||||
|
||||
void VulkanCreationInfo::ViewportScissor::Init(VulkanResourceManager *rm, const VkDynamicViewportStateCreateInfo* pCreateInfo)
|
||||
void VulkanCreationInfo::ViewportScissor::Init(const VkDynamicViewportStateCreateInfo* pCreateInfo)
|
||||
{
|
||||
viewports.resize(pCreateInfo->viewportAndScissorCount);
|
||||
scissors.resize(pCreateInfo->viewportAndScissorCount);
|
||||
@@ -122,7 +122,7 @@ void VulkanCreationInfo::ViewportScissor::Init(VulkanResourceManager *rm, const
|
||||
}
|
||||
}
|
||||
|
||||
void VulkanCreationInfo::Raster::Init(VulkanResourceManager *rm, const VkDynamicRasterStateCreateInfo* pCreateInfo)
|
||||
void VulkanCreationInfo::Raster::Init(const VkDynamicRasterStateCreateInfo* pCreateInfo)
|
||||
{
|
||||
depthBias = pCreateInfo->depthBias;
|
||||
depthBiasClamp = pCreateInfo->depthBiasClamp;
|
||||
@@ -130,13 +130,13 @@ void VulkanCreationInfo::Raster::Init(VulkanResourceManager *rm, const VkDynamic
|
||||
lineWidth = pCreateInfo->lineWidth;
|
||||
}
|
||||
|
||||
void VulkanCreationInfo::Blend::Init(VulkanResourceManager *rm, const VkDynamicColorBlendStateCreateInfo* pCreateInfo)
|
||||
void VulkanCreationInfo::Blend::Init(const VkDynamicColorBlendStateCreateInfo* pCreateInfo)
|
||||
{
|
||||
RDCCOMPILE_ASSERT(sizeof(blendConst) == sizeof(pCreateInfo->blendConst), "blend constant size mismatch!");
|
||||
memcpy(blendConst, pCreateInfo->blendConst, sizeof(blendConst));
|
||||
}
|
||||
|
||||
void VulkanCreationInfo::DepthStencil::Init(VulkanResourceManager *rm, const VkDynamicDepthStencilStateCreateInfo* pCreateInfo)
|
||||
void VulkanCreationInfo::DepthStencil::Init(const VkDynamicDepthStencilStateCreateInfo* pCreateInfo)
|
||||
{
|
||||
minDepthBounds = pCreateInfo->minDepthBounds;
|
||||
maxDepthBounds = pCreateInfo->maxDepthBounds;
|
||||
@@ -146,7 +146,7 @@ void VulkanCreationInfo::DepthStencil::Init(VulkanResourceManager *rm, const VkD
|
||||
stencilBackRef = pCreateInfo->stencilBackRef;
|
||||
}
|
||||
|
||||
void VulkanCreationInfo::Framebuffer::Init(VulkanResourceManager *rm, const VkFramebufferCreateInfo* pCreateInfo)
|
||||
void VulkanCreationInfo::Framebuffer::Init(const VkFramebufferCreateInfo* pCreateInfo)
|
||||
{
|
||||
width = pCreateInfo->width;
|
||||
height = pCreateInfo->height;
|
||||
@@ -154,10 +154,10 @@ void VulkanCreationInfo::Framebuffer::Init(VulkanResourceManager *rm, const VkFr
|
||||
|
||||
attachments.resize(pCreateInfo->attachmentCount);
|
||||
for(uint32_t i=0; i < pCreateInfo->attachmentCount; i++)
|
||||
attachments[i].view = rm->GetOriginalID(rm->GetID(MakeRes(pCreateInfo->pAttachments[i].view)));
|
||||
attachments[i].view = GetResID(pCreateInfo->pAttachments[i].view);
|
||||
}
|
||||
|
||||
void VulkanCreationInfo::DescSetLayout::Init(VulkanResourceManager *rm, const VkDescriptorSetLayoutCreateInfo* pCreateInfo)
|
||||
void VulkanCreationInfo::DescSetLayout::Init(const VkDescriptorSetLayoutCreateInfo* pCreateInfo)
|
||||
{
|
||||
bindings.resize(pCreateInfo->count);
|
||||
for(uint32_t i=0; i < pCreateInfo->count; i++)
|
||||
@@ -171,7 +171,7 @@ void VulkanCreationInfo::DescSetLayout::Init(VulkanResourceManager *rm, const Vk
|
||||
bindings[i].immutableSampler = new ResourceId[bindings[i].arraySize];
|
||||
|
||||
for(uint32_t s=0; s < bindings[i].arraySize; s++)
|
||||
bindings[i].immutableSampler[s] = rm->GetID(MakeRes(pCreateInfo->pBinding[i].pImmutableSamplers[s]));
|
||||
bindings[i].immutableSampler[s] = GetResID(pCreateInfo->pBinding[i].pImmutableSamplers[s]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ struct VulkanCreationInfo
|
||||
{
|
||||
struct Pipeline
|
||||
{
|
||||
void Init(VulkanResourceManager *rm, const VkGraphicsPipelineCreateInfo* pCreateInfo);
|
||||
void Init(const VkGraphicsPipelineCreateInfo* pCreateInfo);
|
||||
|
||||
// VkGraphicsPipelineCreateInfo
|
||||
VkPipelineCreateFlags flags;
|
||||
@@ -113,7 +113,7 @@ struct VulkanCreationInfo
|
||||
|
||||
struct ViewportScissor
|
||||
{
|
||||
void Init(VulkanResourceManager *rm, const VkDynamicViewportStateCreateInfo* pCreateInfo);
|
||||
void Init(const VkDynamicViewportStateCreateInfo* pCreateInfo);
|
||||
|
||||
vector<VkViewport> viewports;
|
||||
vector<VkRect2D> scissors;
|
||||
@@ -122,7 +122,7 @@ struct VulkanCreationInfo
|
||||
|
||||
struct Raster
|
||||
{
|
||||
void Init(VulkanResourceManager *rm, const VkDynamicRasterStateCreateInfo* pCreateInfo);
|
||||
void Init(const VkDynamicRasterStateCreateInfo* pCreateInfo);
|
||||
|
||||
float depthBias;
|
||||
float depthBiasClamp;
|
||||
@@ -133,7 +133,7 @@ struct VulkanCreationInfo
|
||||
|
||||
struct Blend
|
||||
{
|
||||
void Init(VulkanResourceManager *rm, const VkDynamicColorBlendStateCreateInfo* pCreateInfo);
|
||||
void Init(const VkDynamicColorBlendStateCreateInfo* pCreateInfo);
|
||||
|
||||
float blendConst[4];
|
||||
};
|
||||
@@ -141,7 +141,7 @@ struct VulkanCreationInfo
|
||||
|
||||
struct DepthStencil
|
||||
{
|
||||
void Init(VulkanResourceManager *rm, const VkDynamicDepthStencilStateCreateInfo* pCreateInfo);
|
||||
void Init(const VkDynamicDepthStencilStateCreateInfo* pCreateInfo);
|
||||
|
||||
float minDepthBounds;
|
||||
float maxDepthBounds;
|
||||
@@ -154,7 +154,7 @@ struct VulkanCreationInfo
|
||||
|
||||
struct Framebuffer
|
||||
{
|
||||
void Init(VulkanResourceManager *rm, const VkFramebufferCreateInfo* pCreateInfo);
|
||||
void Init(const VkFramebufferCreateInfo* pCreateInfo);
|
||||
|
||||
struct Attachment
|
||||
{
|
||||
@@ -168,7 +168,7 @@ struct VulkanCreationInfo
|
||||
|
||||
struct DescSetLayout
|
||||
{
|
||||
void Init(VulkanResourceManager *rm, const VkDescriptorSetLayoutCreateInfo* pCreateInfo);
|
||||
void Init(const VkDescriptorSetLayoutCreateInfo* pCreateInfo);
|
||||
|
||||
void CreateBindingsArray(vector<VkDescriptorInfo*> &descBindings);
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ void VulkanResourceManager::RecordTransitions(vector< pair<ResourceId, ImageRegi
|
||||
{
|
||||
const VkImageMemoryBarrier &t = transitions[ti];
|
||||
|
||||
ResourceId id = GetID(MakeRes(t.image));
|
||||
ResourceId id = GetResID(t.image);
|
||||
|
||||
uint32_t nummips = t.subresourceRange.mipLevels;
|
||||
uint32_t numslices = t.subresourceRange.arraySize;
|
||||
@@ -239,7 +239,7 @@ void VulkanResourceManager::SerialiseImageStates(Serialiser *m_pSerialiser, map<
|
||||
t.outputMask = 0;
|
||||
t.srcQueueFamilyIndex = 0;
|
||||
t.destQueueFamilyIndex = 0;
|
||||
t.image = (VkImage)GetCurrentResource(liveid).handle;
|
||||
t.image = (VkImage)GetCurrentResource(liveid)->real;
|
||||
t.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
t.newLayout = state.state;
|
||||
t.subresourceRange = state.range;
|
||||
@@ -432,39 +432,39 @@ void VulkanResourceManager::ApplyTransitions(vector< pair<ResourceId, ImageRegio
|
||||
}
|
||||
}
|
||||
|
||||
bool VulkanResourceManager::Force_InitialState(VkResource res)
|
||||
bool VulkanResourceManager::Force_InitialState(WrappedVkRes *res)
|
||||
{
|
||||
// VKTODOMED don't want to be forcing device memory initial state, need to
|
||||
// know which objects have dirtied their bound memory.
|
||||
return (res.Namespace == eResDeviceMemory);
|
||||
return WrappedVkDeviceMemory::IsAlloc(res);
|
||||
}
|
||||
|
||||
bool VulkanResourceManager::Need_InitialStateChunk(VkResource res)
|
||||
bool VulkanResourceManager::Need_InitialStateChunk(WrappedVkRes *res)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VulkanResourceManager::Prepare_InitialState(VkResource res)
|
||||
bool VulkanResourceManager::Prepare_InitialState(WrappedVkRes *res)
|
||||
{
|
||||
return m_Core->Prepare_InitialState(res);
|
||||
}
|
||||
|
||||
bool VulkanResourceManager::Serialise_InitialState(VkResource res)
|
||||
bool VulkanResourceManager::Serialise_InitialState(WrappedVkRes *res)
|
||||
{
|
||||
return m_Core->Serialise_InitialState(res);
|
||||
}
|
||||
|
||||
void VulkanResourceManager::Create_InitialState(ResourceId id, VkResource live, bool hasData)
|
||||
void VulkanResourceManager::Create_InitialState(ResourceId id, WrappedVkRes *live, bool hasData)
|
||||
{
|
||||
return m_Core->Create_InitialState(id, live, hasData);
|
||||
}
|
||||
|
||||
void VulkanResourceManager::Apply_InitialState(VkResource live, InitialContentData initial)
|
||||
void VulkanResourceManager::Apply_InitialState(WrappedVkRes *live, InitialContentData initial)
|
||||
{
|
||||
return m_Core->Apply_InitialState(live, initial);
|
||||
}
|
||||
|
||||
bool VulkanResourceManager::ResourceTypeRelease(VkResource res)
|
||||
bool VulkanResourceManager::ResourceTypeRelease(WrappedVkRes *res)
|
||||
{
|
||||
return m_Core->ReleaseResource(res);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ using std::pair;
|
||||
|
||||
class WrappedVulkan;
|
||||
|
||||
class VulkanResourceManager : public ResourceManager<VkResource, VkResourceRecord>
|
||||
class VulkanResourceManager : public ResourceManager<WrappedVkRes*, VkResourceRecord>
|
||||
{
|
||||
public:
|
||||
VulkanResourceManager(LogState s, Serialiser *ser, WrappedVulkan *core)
|
||||
@@ -44,177 +44,10 @@ class VulkanResourceManager : public ResourceManager<VkResource, VkResourceRecor
|
||||
if(m_Inst) RDCFATAL("Multiple resource managers");
|
||||
m_Inst = this;
|
||||
}
|
||||
~VulkanResourceManager() {}
|
||||
~VulkanResourceManager() { m_Inst = NULL; }
|
||||
|
||||
static VulkanResourceManager *GetInstance() { return m_Inst; }
|
||||
|
||||
void Shutdown()
|
||||
{
|
||||
while(!m_VkResourceRecords.empty())
|
||||
{
|
||||
// VKTODOLOW we pick from the end, on the assumption that in
|
||||
// namespace order (which is resource record order), later entries
|
||||
// always have parents that are earlier.
|
||||
auto it = --(m_VkResourceRecords.end());
|
||||
ResourceId id = it->second->GetResourceID();
|
||||
it->second->Delete(this);
|
||||
|
||||
if(!m_VkResourceRecords.empty() && m_VkResourceRecords.begin()->second->GetResourceID() == id)
|
||||
m_VkResourceRecords.erase(m_VkResourceRecords.begin());
|
||||
}
|
||||
|
||||
m_CurrentResourceIds.clear();
|
||||
|
||||
while(!m_InitialContents.empty())
|
||||
{
|
||||
auto it = m_InitialContents.begin();
|
||||
ResourceTypeRelease(it->second.resource);
|
||||
Serialiser::FreeAlignedBuffer(it->second.blob);
|
||||
if(!m_InitialContents.empty())
|
||||
m_InitialContents.erase(m_InitialContents.begin());
|
||||
}
|
||||
|
||||
// have to do this here since we want to do it in reverse order
|
||||
for(auto it = m_LiveResourceMap.end(); it != m_LiveResourceMap.begin();)
|
||||
{
|
||||
// decrement it first since the initial value at .end() is invalid
|
||||
--it;
|
||||
ResourceTypeRelease(it->second);
|
||||
}
|
||||
m_LiveResourceMap.clear();
|
||||
|
||||
for(auto it = m_InframeResourceMap.end(); it != m_InframeResourceMap.begin();)
|
||||
{
|
||||
// decrement it first since the initial value at .end() is invalid
|
||||
--it;
|
||||
ResourceTypeRelease(it->second);
|
||||
}
|
||||
m_InframeResourceMap.clear();
|
||||
|
||||
RDCASSERT(m_ResourceRecords.empty());
|
||||
|
||||
m_Inst = NULL;
|
||||
}
|
||||
|
||||
inline void RemoveResourceRecord(ResourceId id)
|
||||
{
|
||||
for(auto it = m_VkResourceRecords.begin(); it != m_VkResourceRecords.end(); it++)
|
||||
{
|
||||
if(it->second->GetResourceID() == id)
|
||||
{
|
||||
m_VkResourceRecords.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ResourceManager::RemoveResourceRecord(id);
|
||||
}
|
||||
|
||||
// this should take the VkDevice associated too, for release
|
||||
ResourceId RegisterResource(VkResource res)
|
||||
{
|
||||
ResourceId id = ResourceIDGen::GetNewUniqueID();
|
||||
m_CurrentResourceIds[res] = id;
|
||||
AddCurrentResource(id, res);
|
||||
return id;
|
||||
}
|
||||
|
||||
void UnregisterResource(VkResource res)
|
||||
{
|
||||
auto it = m_CurrentResourceIds.find(res);
|
||||
if(it != m_CurrentResourceIds.end())
|
||||
{
|
||||
ReleaseCurrentResource(it->second);
|
||||
auto origit = m_OriginalIDs.find(it->second);
|
||||
if(origit != m_OriginalIDs.end())
|
||||
EraseLiveResource(origit->second);
|
||||
m_CurrentResourceIds.erase(res);
|
||||
}
|
||||
}
|
||||
|
||||
ResourceId GetID(VkResource res)
|
||||
{
|
||||
auto it = m_CurrentResourceIds.find(res);
|
||||
if(it != m_CurrentResourceIds.end())
|
||||
return it->second;
|
||||
return ResourceId();
|
||||
}
|
||||
|
||||
using ResourceManager::GetCurrentResource;
|
||||
|
||||
VkResource GetCurrentResource(VkResource obj)
|
||||
{
|
||||
return ResourceManager::GetCurrentResource(GetID(obj));
|
||||
}
|
||||
|
||||
using ResourceManager::HasCurrentResource;
|
||||
|
||||
bool HasCurrentResource(VkResource obj)
|
||||
{
|
||||
return ResourceManager::HasCurrentResource(GetID(obj));
|
||||
}
|
||||
|
||||
VkResourceRecord *AddResourceRecord(ResourceId id)
|
||||
{
|
||||
VkResourceRecord *ret = ResourceManager::AddResourceRecord(id);
|
||||
VkResource res = GetCurrentResource(id);
|
||||
|
||||
m_VkResourceRecords[res] = ret;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
VkResourceRecord *AddResourceRecord(VkResource res, ResourceId id)
|
||||
{
|
||||
VkResourceRecord *ret = ResourceManager::AddResourceRecord(id);
|
||||
m_VkResourceRecords[res] = ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
using ResourceManager::HasResourceRecord;
|
||||
|
||||
bool HasResourceRecord(VkResource res)
|
||||
{
|
||||
auto it = m_VkResourceRecords.find(res);
|
||||
if(it != m_VkResourceRecords.end())
|
||||
return true;
|
||||
|
||||
return ResourceManager::HasResourceRecord(GetID(res));
|
||||
}
|
||||
|
||||
using ResourceManager::GetResourceRecord;
|
||||
|
||||
VkResourceRecord *GetResourceRecord(VkResource res)
|
||||
{
|
||||
auto it = m_VkResourceRecords.find(res);
|
||||
if(it != m_VkResourceRecords.end())
|
||||
return it->second;
|
||||
|
||||
return ResourceManager::GetResourceRecord(GetID(res));
|
||||
}
|
||||
|
||||
using ResourceManager::MarkResourceFrameReferenced;
|
||||
|
||||
void MarkResourceFrameReferenced(VkResource res, FrameRefType refType)
|
||||
{
|
||||
if(res.handle == 0) return;
|
||||
ResourceManager::MarkResourceFrameReferenced(GetID(res), refType);
|
||||
}
|
||||
|
||||
using ResourceManager::MarkDirtyResource;
|
||||
|
||||
void MarkDirtyResource(VkResource res)
|
||||
{
|
||||
return ResourceManager::MarkDirtyResource(GetID(res));
|
||||
}
|
||||
|
||||
using ResourceManager::MarkCleanResource;
|
||||
|
||||
void MarkCleanResource(VkResource res)
|
||||
{
|
||||
return ResourceManager::MarkCleanResource(GetID(res));
|
||||
}
|
||||
|
||||
// handling memory & image transitions
|
||||
void RecordTransitions(vector< pair<ResourceId, ImageRegionState> > &trans, map<ResourceId, ImgState> &states,
|
||||
uint32_t numTransitions, const VkImageMemoryBarrier *transitions);
|
||||
@@ -225,21 +58,22 @@ class VulkanResourceManager : public ResourceManager<VkResource, VkResourceRecor
|
||||
|
||||
private:
|
||||
bool SerialisableResource(ResourceId id, VkResourceRecord *record);
|
||||
|
||||
bool ResourceTypeRelease(VkResource res);
|
||||
|
||||
bool Force_InitialState(VkResource res);
|
||||
bool Need_InitialStateChunk(VkResource res);
|
||||
bool Prepare_InitialState(VkResource res);
|
||||
bool Serialise_InitialState(VkResource res);
|
||||
void Create_InitialState(ResourceId id, VkResource live, bool hasData);
|
||||
void Apply_InitialState(VkResource live, InitialContentData initial);
|
||||
ResourceId GetID(WrappedVkRes *res)
|
||||
{
|
||||
return res ? res->id : ResourceId();
|
||||
}
|
||||
|
||||
bool ResourceTypeRelease(WrappedVkRes *res);
|
||||
|
||||
bool Force_InitialState(WrappedVkRes *res);
|
||||
bool Need_InitialStateChunk(WrappedVkRes *res);
|
||||
bool Prepare_InitialState(WrappedVkRes *res);
|
||||
bool Serialise_InitialState(WrappedVkRes *res);
|
||||
void Create_InitialState(ResourceId id, WrappedVkRes *live, bool hasData);
|
||||
void Apply_InitialState(WrappedVkRes *live, InitialContentData initial);
|
||||
|
||||
static VulkanResourceManager *m_Inst;
|
||||
|
||||
map<VkResource, VkResourceRecord*> m_VkResourceRecords;
|
||||
|
||||
map<VkResource, ResourceId> m_CurrentResourceIds;
|
||||
|
||||
WrappedVulkan *m_Core;
|
||||
};
|
||||
|
||||
@@ -1287,15 +1287,15 @@ void VulkanReplay::SavePipelineState()
|
||||
if(layoutBind.immutableSampler)
|
||||
dst.bindings[b].elems[a].sampler = layoutBind.immutableSampler[a];
|
||||
else if(info->sampler != VK_NULL_HANDLE)
|
||||
dst.bindings[b].elems[a].sampler = rm->GetOriginalID(rm->GetID(MakeRes(info->sampler)));
|
||||
dst.bindings[b].elems[a].sampler = rm->GetOriginalID(GetResID(info->sampler));
|
||||
|
||||
// only one of these is ever set
|
||||
if(info->imageView != VK_NULL_HANDLE)
|
||||
dst.bindings[b].elems[a].view = rm->GetOriginalID(rm->GetID(MakeRes(info->imageView)));
|
||||
dst.bindings[b].elems[a].view = rm->GetOriginalID(GetResID(info->imageView));
|
||||
if(info->bufferView != VK_NULL_HANDLE)
|
||||
dst.bindings[b].elems[a].view = rm->GetOriginalID(rm->GetID(MakeRes(info->bufferView)));
|
||||
dst.bindings[b].elems[a].view = rm->GetOriginalID(GetResID(info->bufferView));
|
||||
if(info->attachmentView != VK_NULL_HANDLE)
|
||||
dst.bindings[b].elems[a].view = rm->GetOriginalID(rm->GetID(MakeRes(info->attachmentView)));
|
||||
dst.bindings[b].elems[a].view = rm->GetOriginalID(GetResID(info->attachmentView));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -394,65 +394,6 @@ enum VkNamespace
|
||||
|
||||
VkNamespace IdentifyTypeByPtr(WrappedVkRes *ptr);
|
||||
|
||||
enum NullInitialiser { MakeNullResource };
|
||||
|
||||
struct VkResource
|
||||
{
|
||||
VkResource() { Namespace = eResUnknown; handle = VK_NULL_HANDLE; }
|
||||
VkResource(NullInitialiser) { Namespace = eResUnknown; handle = VK_NULL_HANDLE; }
|
||||
VkResource(VkNamespace n, uint64_t o) { Namespace = n; handle = o; }
|
||||
VkNamespace Namespace;
|
||||
uint64_t handle;
|
||||
|
||||
bool operator ==(const VkResource &o) const
|
||||
{
|
||||
return Namespace == o.Namespace && handle == o.handle;
|
||||
}
|
||||
|
||||
bool operator !=(const VkResource &o) const
|
||||
{
|
||||
return !(*this == o);
|
||||
}
|
||||
|
||||
bool operator <(const VkResource &o) const
|
||||
{
|
||||
if(Namespace != o.Namespace) return Namespace < o.Namespace;
|
||||
return handle < o.handle;
|
||||
}
|
||||
};
|
||||
|
||||
inline VkResource MakeRes(VkPhysicalDevice o) { return VkResource(eResPhysicalDevice, (uint64_t)o); }
|
||||
inline VkResource MakeRes(VkInstance o) { return VkResource(eResInstance, (uint64_t)o); }
|
||||
inline VkResource MakeRes(VkDevice o) { return VkResource(eResDevice, (uint64_t)o); }
|
||||
inline VkResource MakeRes(VkQueue o) { return VkResource(eResQueue, (uint64_t)o); }
|
||||
inline VkResource MakeRes(VkCmdBuffer o) { return VkResource(eResCmdBuffer, (uint64_t)o); }
|
||||
inline VkResource MakeRes(VkCmdPool o) { return VkResource(eResCmdPool, o.handle); }
|
||||
inline VkResource MakeRes(VkDeviceMemory o) { return VkResource(eResDeviceMemory, o.handle); }
|
||||
inline VkResource MakeRes(VkBuffer o) { return VkResource(eResBuffer, o.handle); }
|
||||
inline VkResource MakeRes(VkBufferView o) { return VkResource(eResBufferView, o.handle); }
|
||||
inline VkResource MakeRes(VkImage o) { return VkResource(eResImage, o.handle); }
|
||||
inline VkResource MakeRes(VkImageView o) { return VkResource(eResImageView, o.handle); }
|
||||
inline VkResource MakeRes(VkAttachmentView o) { return VkResource(eResAttachmentView, o.handle); }
|
||||
inline VkResource MakeRes(VkFramebuffer o) { return VkResource(eResFramebuffer, o.handle); }
|
||||
inline VkResource MakeRes(VkRenderPass o) { return VkResource(eResRenderPass, o.handle); }
|
||||
inline VkResource MakeRes(VkShader o) { return VkResource(eResShader, o.handle); }
|
||||
inline VkResource MakeRes(VkShaderModule o) { return VkResource(eResShaderModule, o.handle); }
|
||||
inline VkResource MakeRes(VkPipeline o) { return VkResource(eResPipeline, o.handle); }
|
||||
inline VkResource MakeRes(VkPipelineCache o) { return VkResource(eResPipelineCache, o.handle); }
|
||||
inline VkResource MakeRes(VkPipelineLayout o) { return VkResource(eResPipelineLayout, o.handle); }
|
||||
inline VkResource MakeRes(VkSampler o) { return VkResource(eResSampler, o.handle); }
|
||||
inline VkResource MakeRes(VkDescriptorSet o) { return VkResource(eResDescriptorSet, o.handle); }
|
||||
inline VkResource MakeRes(VkDescriptorPool o) { return VkResource(eResDescriptorPool, o.handle); }
|
||||
inline VkResource MakeRes(VkDescriptorSetLayout o) { return VkResource(eResDescriptorSetLayout, o.handle); }
|
||||
inline VkResource MakeRes(VkDynamicViewportState o) { return VkResource(eResViewportState, o.handle); }
|
||||
inline VkResource MakeRes(VkDynamicRasterState o) { return VkResource(eResRasterState, o.handle); }
|
||||
inline VkResource MakeRes(VkDynamicColorBlendState o) { return VkResource(eResColorBlendState, o.handle); }
|
||||
inline VkResource MakeRes(VkDynamicDepthStencilState o) { return VkResource(eResDepthStencilState, o.handle); }
|
||||
inline VkResource MakeRes(VkFence o) { return VkResource(eResFence, o.handle); }
|
||||
inline VkResource MakeRes(VkSemaphore o) { return VkResource(eResSemaphore, o.handle); }
|
||||
|
||||
inline VkResource MakeRes(VkSwapChainWSI o) { return VkResource(eResWSISwapChain, o.handle); }
|
||||
|
||||
#define UNTRANSITIONED_IMG_STATE ((VkImageLayout)0xffffffff)
|
||||
|
||||
struct ImageRegionState
|
||||
@@ -475,7 +416,7 @@ struct ImageRegionState
|
||||
struct VkResourceRecord : public ResourceRecord
|
||||
{
|
||||
public:
|
||||
static const NullInitialiser NullResource = MakeNullResource;
|
||||
enum { NullResource = (unsigned int)NULL };
|
||||
|
||||
VkResourceRecord(ResourceId id) :
|
||||
ResourceRecord(id, true),
|
||||
|
||||
Reference in New Issue
Block a user