Move swapchain info either under resource record or into creationinfo

This commit is contained in:
baldurk
2015-10-21 14:16:58 +02:00
parent 1f42e54145
commit 0ff8501561
6 changed files with 49 additions and 66 deletions
-30
View File
@@ -379,36 +379,6 @@ WrappedVulkan::WrappedVulkan(const char *logFilename)
WrappedVulkan::~WrappedVulkan()
{
// VKTODOLOW should only have one swapchain, since we are only handling the simple case
// of one device, etc for now.
RDCASSERT(m_SwapChainInfo.size() == 1);
for(auto it = m_SwapChainInfo.begin(); it != m_SwapChainInfo.end(); ++it)
{
for(size_t i=0; i < it->second.images.size(); i++)
{
// only in the replay app are these 'real' images to be destroyed
if(RenderDoc::Inst().IsReplayApp())
{
// go through our wrapped functions, since the resources need to be deregistered
vkDestroyImage(GetDev(), it->second.images[i].im);
vkFreeMemory(GetDev(), it->second.images[i].mem);
}
// VKTODOHIGH this device has been destroyed already - need to kill these when
// swapchain is destroyed?
//if(it->second.images[i].fb != VK_NULL_HANDLE)
//ObjDisp(GetDev())->DestroyFramebuffer(Unwrap(GetDev()), it->second.images[i].fb);
//if(it->second.images[i].view != VK_NULL_HANDLE)
//ObjDisp(GetDev())->DestroyImageView(Unwrap(GetDev()), it->second.images[i].view);
}
//if(it->second.rp != VK_NULL_HANDLE)
//ObjDisp(GetDev())->DestroyRenderPass(Unwrap(GetDev()), it->second.rp);
}
m_SwapChainInfo.clear();
// VKTODOLOW shutdown order is really up in the air
for(size_t i=0; i < m_PhysicalReplayData.size(); i++)
{
-19
View File
@@ -343,24 +343,6 @@ private:
bool InPartialRange() { return m_CmdBufferInfo[m_PartialReplayData.partialParent].curEventID <= m_LastEventID - m_PartialReplayData.baseEvent; }
VkCmdBuffer PartialCmdBuf() { return m_PartialReplayData.resultPartialCmdBuffer; }
struct SwapInfo
{
VkFormat format;
VkExtent2D extent;
int arraySize;
VkRenderPass rp;
struct SwapImage
{
VkDeviceMemory mem;
VkImage im;
VkImageView view;
VkFramebuffer fb;
};
vector<SwapImage> images;
};
// this info is stored in the record on capture, but we
// need it on replay too
@@ -377,7 +359,6 @@ private:
map<ResourceId, MemState> m_MemoryInfo;
map<ResourceId, ImgState> m_ImageInfo;
map<ResourceId, CmdBufferInfo> m_CmdBufferInfo;
map<ResourceId, SwapInfo> m_SwapChainInfo;
// READING only
map<ResourceId, ResourceId> m_BufferMemBinds;
+3 -2
View File
@@ -187,8 +187,6 @@ struct VulkanCreationInfo
ResourceId image;
};
map<ResourceId, ImageView> m_ImageView;
map<ResourceId, DescSetLayout> m_DescSetLayout;
struct ShaderModule
{
@@ -209,4 +207,7 @@ struct VulkanCreationInfo
ShaderBindpointMapping mapping;
};
map<ResourceId, Shader> m_Shader;
map<ResourceId, SwapchainInfo> m_SwapChain;
map<ResourceId, DescSetLayout> m_DescSetLayout;
};
+1
View File
@@ -486,4 +486,5 @@ VkResourceRecord::~VkResourceRecord()
descBindings.clear();
SAFE_DELETE(layout);
SAFE_DELETE(swapInfo);
}
+22 -1
View File
@@ -549,6 +549,24 @@ inline bool operator <(const VkDescriptorSet a, const VkDescriptorSet b)
return a.handle < b.handle;
}
struct SwapchainInfo
{
VkFormat format;
VkExtent2D extent;
int arraySize;
VkRenderPass rp;
struct SwapImage
{
VkImage im;
VkImageView view;
VkFramebuffer fb;
};
vector<SwapImage> images;
};
struct DescSetLayout;
struct VkResourceRecord : public ResourceRecord
@@ -561,7 +579,8 @@ struct VkResourceRecord : public ResourceRecord
bakedCommands(NULL),
pool(NULL),
memory(NULL),
layout(NULL)
layout(NULL),
swapInfo(NULL)
{
}
@@ -631,6 +650,8 @@ struct VkResourceRecord : public ResourceRecord
WrappedVkRes *Resource;
SwapchainInfo *swapInfo;
// a list of resources that are made dirty by submitting this command buffer
set<ResourceId> dirtied;
@@ -90,8 +90,8 @@ bool WrappedVulkan::Serialise_vkGetSwapchainImagesKHR(
if(m_State == READING)
{
// VKTODOLOW what if num images is less than on capture?
RDCASSERT(idx < m_SwapChainInfo[swapId].images.size());
GetResourceManager()->AddLiveResource(id, m_SwapChainInfo[swapId].images[idx].im);
RDCASSERT(idx < m_CreationInfo.m_SwapChain[swapId].images.size());
GetResourceManager()->AddLiveResource(id, m_CreationInfo.m_SwapChain[swapId].images[idx].im);
}
return true;
@@ -210,14 +210,16 @@ bool WrappedVulkan::Serialise_vkCreateSwapchainKHR(
SERIALISE_ELEMENT(uint32_t, numSwapImages, numIms);
m_SwapChainInfo[id].format = info.imageFormat;
m_SwapChainInfo[id].extent = info.imageExtent;
m_SwapChainInfo[id].arraySize = info.imageArraySize;
m_SwapChainInfo[id].images.resize(numSwapImages);
if(m_State == READING)
{
SwapchainInfo &swapinfo = m_CreationInfo.m_SwapChain[id];
swapinfo.format = info.imageFormat;
swapinfo.extent = info.imageExtent;
swapinfo.arraySize = info.imageArraySize;
swapinfo.images.resize(numSwapImages);
device = GetResourceManager()->GetLiveHandle<VkDevice>(devId);
const VkImageCreateInfo imInfo = {
@@ -272,8 +274,7 @@ bool WrappedVulkan::Serialise_vkCreateSwapchainKHR(
// image live ID will be assigned separately in Serialise_vkGetSwapChainInfoWSI
// memory doesn't have a live ID
m_SwapChainInfo[id].images[i].mem = mem;
m_SwapChainInfo[id].images[i].im = im;
swapinfo.images[i].im = im;
// fill out image info so we track resource state transitions
m_ImageInfo[liveId].type = VK_IMAGE_TYPE_2D;
@@ -339,7 +340,12 @@ VkResult WrappedVulkan::vkCreateSwapchainKHR(
m_SwapPhysDevice = (int)i;
}
SwapInfo &swapInfo = m_SwapChainInfo[id];
record->swapInfo = new SwapchainInfo();
SwapchainInfo &swapInfo = *record->swapInfo;
swapInfo.format = pCreateInfo->imageFormat;
swapInfo.extent = pCreateInfo->imageExtent;
swapInfo.arraySize = pCreateInfo->imageArraySize;
VkResult vkr = VK_SUCCESS;
@@ -385,6 +391,8 @@ VkResult WrappedVulkan::vkCreateSwapchainKHR(
uint32_t numSwapImages;
VkResult ret = vt->GetSwapchainImagesKHR(Unwrap(device), Unwrap(*pSwapChain), &numSwapImages, NULL);
RDCASSERT(ret == VK_SUCCESS);
swapInfo.images.resize(numSwapImages);
VkImage* images = new VkImage[numSwapImages];
@@ -394,10 +402,9 @@ VkResult WrappedVulkan::vkCreateSwapchainKHR(
for(uint32_t i=0; i < numSwapImages; i++)
{
SwapInfo::SwapImage &swapImInfo = swapInfo.images[i];
SwapchainInfo::SwapImage &swapImInfo = swapInfo.images[i];
// memory doesn't exist for genuine WSI created images
swapImInfo.mem = VK_NULL_HANDLE;
swapImInfo.im = images[i];
ResourceId imid = GetResID(images[i]);
@@ -481,8 +488,10 @@ VkResult WrappedVulkan::vkQueuePresentKHR(
RDCASSERT(pPresentInfo->pNext == NULL);
ResourceId swapid = GetResID(pPresentInfo->swapchains[0]);
VkResourceRecord *swaprecord = GetRecord(pPresentInfo->swapchains[0]);
RDCASSERT(swaprecord->swapInfo);
const SwapInfo &swapInfo = m_SwapChainInfo[swapid];
const SwapchainInfo &swapInfo = *swaprecord->swapInfo;
VkImage backbuffer = swapInfo.images[pPresentInfo->imageIndices[0]].im;