Add a little utility function so that code can get IDs from real objects

This commit is contained in:
baldurk
2015-09-17 19:29:34 +02:00
parent a6626ab31b
commit a00688a86a
4 changed files with 21 additions and 12 deletions
+1 -1
View File
@@ -1134,7 +1134,7 @@ WrappedResourceType ResourceManager<WrappedResourceType, RealResourceType, Recor
SCOPED_LOCK(m_Lock);
if(real == (RealResourceType)RecordType::NullResource)
return (RealResourceType)RecordType::NullResource;
return (WrappedResourceType)RecordType::NullResource;
if(real != (RealResourceType)RecordType::NullResource && !HasWrapper(real))
{
+9 -5
View File
@@ -24,18 +24,22 @@
#include "vk_info.h"
template<typename realtype>
static ResourceId GetIDFromReal(realtype real)
{
return ((WrappedVkNonDispRes *)VKMGR()->GetWrapper(RealVkRes(real.handle)))->id;
}
void VulkanCreationInfo::Pipeline::Init(const VkGraphicsPipelineCreateInfo* pCreateInfo)
{
flags = pCreateInfo->flags;
// need to figure out which states are valid to be NULL
RDCASSERT(0 && "GetResID won't work here - these are unwrapped");
// VkPipelineShaderStageCreateInfo
RDCEraseEl(shaders);
for(uint32_t i=0; i < pCreateInfo->stageCount; i++)
shaders[ pCreateInfo->pStages[i].stage ] = GetResID(pCreateInfo->pStages[i].shader);
shaders[ pCreateInfo->pStages[i].stage ] = GetIDFromReal(pCreateInfo->pStages[i].shader);
if(pCreateInfo->pVertexInputState)
{
@@ -156,7 +160,7 @@ void VulkanCreationInfo::Framebuffer::Init(const VkFramebufferCreateInfo* pCreat
attachments.resize(pCreateInfo->attachmentCount);
for(uint32_t i=0; i < pCreateInfo->attachmentCount; i++)
attachments[i].view = GetResID(pCreateInfo->pAttachments[i].view);
attachments[i].view = GetIDFromReal(pCreateInfo->pAttachments[i].view);
}
void VulkanCreationInfo::DescSetLayout::Init(const VkDescriptorSetLayoutCreateInfo* pCreateInfo)
@@ -173,7 +177,7 @@ void VulkanCreationInfo::DescSetLayout::Init(const VkDescriptorSetLayoutCreateIn
bindings[i].immutableSampler = new ResourceId[bindings[i].arraySize];
for(uint32_t s=0; s < bindings[i].arraySize; s++)
bindings[i].immutableSampler[s] = GetResID(pCreateInfo->pBinding[i].pImmutableSamplers[s]);
bindings[i].immutableSampler[s] = GetIDFromReal(pCreateInfo->pBinding[i].pImmutableSamplers[s]);
}
}
}
+10 -6
View File
@@ -29,6 +29,12 @@
#include "serialise/string_utils.h"
template<typename realtype>
static ResourceId GetIDFromReal(realtype real)
{
return ((WrappedVkNonDispRes *)VKMGR()->GetWrapper(RealVkRes(real.handle)))->id;
}
// VKTODOMED should share this between shader and C++ - need #include support in glslang
struct displayuniforms
{
@@ -1313,20 +1319,18 @@ void VulkanReplay::SavePipelineState()
create_array_uninit(dst.bindings[b].elems, layoutBind.arraySize);
for(uint32_t a=0; a < layoutBind.arraySize; a++)
{
RDCASSERT(0 && "GetResID won't work here - these are unwrapped");
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(GetResID(info->sampler));
dst.bindings[b].elems[a].sampler = rm->GetOriginalID(GetIDFromReal(info->sampler));
// only one of these is ever set
if(info->imageView != VK_NULL_HANDLE)
dst.bindings[b].elems[a].view = rm->GetOriginalID(GetResID(info->imageView));
dst.bindings[b].elems[a].view = rm->GetOriginalID(GetIDFromReal(info->imageView));
if(info->bufferView != VK_NULL_HANDLE)
dst.bindings[b].elems[a].view = rm->GetOriginalID(GetResID(info->bufferView));
dst.bindings[b].elems[a].view = rm->GetOriginalID(GetIDFromReal(info->bufferView));
if(info->attachmentView != VK_NULL_HANDLE)
dst.bindings[b].elems[a].view = rm->GetOriginalID(GetResID(info->attachmentView));
dst.bindings[b].elems[a].view = rm->GetOriginalID(GetIDFromReal(info->attachmentView));
}
}
}
+1
View File
@@ -55,6 +55,7 @@ struct RealVkRes
RealVkRes(uint64_t nondisp) : handle(nondisp) {}
bool operator ==(const RealVkRes o) const { return handle == o.handle; }
bool operator !=(const RealVkRes o) const { return handle != o.handle; }
bool operator < (const RealVkRes o) const { return handle < o.handle; }
uint64_t handle;