From 7ba885fddd8814f54aef467f04c4c6532624e150 Mon Sep 17 00:00:00 2001 From: baldurk Date: Sat, 19 Sep 2015 16:13:33 +0200 Subject: [PATCH] Use parent object when wrapping to fetch dispatch table * The created object's dispatch table pointer is only valid after it gets back to the loader - after our layer has run. So at create time it's invalid, we just look to the parent which has the same value. --- renderdoc/driver/vulkan/vk_common.h | 1 - renderdoc/driver/vulkan/vk_core.cpp | 173 +++++++++++++------------- renderdoc/driver/vulkan/vk_core.h | 26 ++-- renderdoc/driver/vulkan/vk_debug.cpp | 56 ++++----- renderdoc/driver/vulkan/vk_manager.h | 6 +- renderdoc/driver/vulkan/vk_replay.cpp | 18 +-- 6 files changed, 141 insertions(+), 139 deletions(-) diff --git a/renderdoc/driver/vulkan/vk_common.h b/renderdoc/driver/vulkan/vk_common.h index 5b2d17f15..4be80c390 100644 --- a/renderdoc/driver/vulkan/vk_common.h +++ b/renderdoc/driver/vulkan/vk_common.h @@ -154,7 +154,6 @@ enum VulkanChunkType CREATE_FRAMEBUFFER, CREATE_RENDERPASS, CREATE_DESCRIPTOR_POOL, - CREATE_DESCRIPTOR_SET, CREATE_DESCRIPTOR_SET_LAYOUT, CREATE_BUFFER, CREATE_BUFFER_VIEW, diff --git a/renderdoc/driver/vulkan/vk_core.cpp b/renderdoc/driver/vulkan/vk_core.cpp index d6623363e..17a761130 100644 --- a/renderdoc/driver/vulkan/vk_core.cpp +++ b/renderdoc/driver/vulkan/vk_core.cpp @@ -66,7 +66,6 @@ const char *VkChunkNames[] = "vkCreateFramebuffer", "vkCreateRenderPass", "vkCreateDescriptorPool", - "vkCreateDescriptorSet", "vkCreateDescriptorSetLayout", "vkCreateBuffer", "vkCreateBufferView", @@ -257,11 +256,9 @@ void WrappedVulkan::Initialise(VkInitParams ¶ms) VkInstance inst = {0}; - // GSFTODO: Fix this - // VkResult ret = m_Real.vkCreateInstance(&instinfo, &inst); VkResult ret = dummyInstanceTable->CreateInstance(&instinfo, &inst); - GetResourceManager()->WrapResource(inst); + GetResourceManager()->WrapResource(inst, inst); GetResourceManager()->AddLiveResource(params.InstanceID, inst); SAFE_DELETE_ARRAY(layerscstr); @@ -465,7 +462,7 @@ VkResult WrappedVulkan::vkCreateInstance( VkResult ret = get_dispatch_table(renderdoc_instance_table_map, *pInstance)->CreateInstance(pCreateInfo, &inst); - GetResourceManager()->WrapResource(inst); + GetResourceManager()->WrapResource(inst, inst); if(ret != VK_SUCCESS) return ret; @@ -559,7 +556,7 @@ bool WrappedVulkan::Serialise_vkEnumeratePhysicalDevices( SAFE_DELETE_ARRAY(devices); - GetResourceManager()->WrapResource(pd); + GetResourceManager()->WrapResource(inst, pd); GetResourceManager()->AddLiveResource(physId, pd); } @@ -606,7 +603,7 @@ VkResult WrappedVulkan::vkEnumeratePhysicalDevices( } else { - GetResourceManager()->WrapResource(devices[i]); + GetResourceManager()->WrapResource(instance, devices[i]); if(m_State >= WRITING) { @@ -711,7 +708,7 @@ bool WrappedVulkan::Serialise_vkCreateDevice( VkResult ret = ObjDisp(*pDevice)->CreateDevice(Unwrap(physicalDevice), &createInfo, &device); - GetResourceManager()->WrapResource(device); + GetResourceManager()->WrapResource(device, device); GetResourceManager()->AddLiveResource(devId, device); found = false; @@ -720,11 +717,6 @@ bool WrappedVulkan::Serialise_vkCreateDevice( { if(m_PhysicalReplayData[i].phys == physicalDevice) { - // VKTODOHIGH super ultra mega hyper hack of great justice - // GSFTODO hack - //void PopulateDeviceHooks(VkDevice d, VkInstance i); - //PopulateDeviceHooks(device, m_PhysicalReplayData[i].inst); - // fill out replay functions. Maybe this should be somewhere else. // VKTODOLOW this won't work with multiple devices - will need a replay device table for each { @@ -868,7 +860,7 @@ VkResult WrappedVulkan::vkCreateDevice( if(ret == VK_SUCCESS) { - ResourceId id = GetResourceManager()->WrapResource(*pDevice); + ResourceId id = GetResourceManager()->WrapResource(*pDevice, *pDevice); found = false; @@ -890,14 +882,14 @@ VkResult WrappedVulkan::vkCreateDevice( vkr = ObjDisp(*pDevice)->CreateCommandPool(Unwrap(*pDevice), &poolInfo, &m_PhysicalReplayData[i].cmdpool); RDCASSERT(vkr == VK_SUCCESS); - GetResourceManager()->WrapResource(m_PhysicalReplayData[i].cmdpool); + GetResourceManager()->WrapResource(Unwrap(*pDevice), m_PhysicalReplayData[i].cmdpool); VkCmdBufferCreateInfo cmdInfo = { VK_STRUCTURE_TYPE_CMD_BUFFER_CREATE_INFO, NULL, Unwrap(m_PhysicalReplayData[i].cmdpool), VK_CMD_BUFFER_LEVEL_PRIMARY, 0 }; vkr = ObjDisp(*pDevice)->CreateCommandBuffer(Unwrap(*pDevice), &cmdInfo, &m_PhysicalReplayData[i].cmd); RDCASSERT(vkr == VK_SUCCESS); found = true; - GetResourceManager()->WrapResource(m_PhysicalReplayData[i].cmd); + GetResourceManager()->WrapResource(Unwrap(*pDevice), m_PhysicalReplayData[i].cmd); // VKTODOHIGH hack, need to properly handle multiple devices etc and // not have this 'current swap chain device' thing. @@ -1151,7 +1143,7 @@ bool WrappedVulkan::Serialise_vkGetDeviceQueue( VkQueue queue; VkResult ret = ObjDisp(device)->GetDeviceQueue(Unwrap(device), nodeIdx, idx, &queue); - GetResourceManager()->WrapResource(queue); + GetResourceManager()->WrapResource(Unwrap(device), queue); GetResourceManager()->AddLiveResource(queueId, queue); } @@ -1177,7 +1169,7 @@ VkResult WrappedVulkan::vkGetDeviceQueue( } else { - ResourceId id = GetResourceManager()->WrapResource(*pQueue); + ResourceId id = GetResourceManager()->WrapResource(Unwrap(device), *pQueue); if(m_State >= WRITING) { @@ -1622,7 +1614,7 @@ bool WrappedVulkan::Serialise_vkAllocMemory( } else { - ResourceId live = GetResourceManager()->WrapResource(mem); + ResourceId live = GetResourceManager()->WrapResource(Unwrap(device), mem); GetResourceManager()->AddLiveResource(id, mem); m_MemoryInfo[live].size = info.allocationSize; @@ -1641,7 +1633,7 @@ VkResult WrappedVulkan::vkAllocMemory( if(ret == VK_SUCCESS) { - ResourceId id = GetResourceManager()->WrapResource(*pMem); + ResourceId id = GetResourceManager()->WrapResource(Unwrap(device), *pMem); if(m_State >= WRITING) { @@ -1969,7 +1961,7 @@ bool WrappedVulkan::Serialise_vkCreateBuffer( } else { - ResourceId live = GetResourceManager()->WrapResource(buf); + ResourceId live = GetResourceManager()->WrapResource(Unwrap(device), buf); GetResourceManager()->AddLiveResource(id, buf); } } @@ -1986,7 +1978,7 @@ VkResult WrappedVulkan::vkCreateBuffer( if(ret == VK_SUCCESS) { - ResourceId id = GetResourceManager()->WrapResource(*pBuffer); + ResourceId id = GetResourceManager()->WrapResource(Unwrap(device), *pBuffer); if(m_State >= WRITING) { @@ -2033,7 +2025,7 @@ bool WrappedVulkan::Serialise_vkCreateBufferView( } else { - ResourceId live = GetResourceManager()->WrapResource(view); + ResourceId live = GetResourceManager()->WrapResource(Unwrap(device), view); GetResourceManager()->AddLiveResource(id, view); } } @@ -2052,7 +2044,7 @@ VkResult WrappedVulkan::vkCreateBufferView( if(ret == VK_SUCCESS) { - ResourceId id = GetResourceManager()->WrapResource(*pView); + ResourceId id = GetResourceManager()->WrapResource(Unwrap(device), *pView); if(m_State >= WRITING) { @@ -2100,7 +2092,7 @@ bool WrappedVulkan::Serialise_vkCreateImage( } else { - ResourceId live = GetResourceManager()->WrapResource(img); + ResourceId live = GetResourceManager()->WrapResource(Unwrap(device), img); GetResourceManager()->AddLiveResource(id, img); m_ImageInfo[live].type = info.imageType; @@ -2142,7 +2134,7 @@ VkResult WrappedVulkan::vkCreateImage( if(ret == VK_SUCCESS) { - ResourceId id = GetResourceManager()->WrapResource(*pImage); + ResourceId id = GetResourceManager()->WrapResource(Unwrap(device), *pImage); if(m_State >= WRITING) { @@ -2216,7 +2208,7 @@ bool WrappedVulkan::Serialise_vkCreateImageView( } else { - ResourceId live = GetResourceManager()->WrapResource(view); + ResourceId live = GetResourceManager()->WrapResource(Unwrap(device), view); GetResourceManager()->AddLiveResource(id, view); } } @@ -2235,7 +2227,7 @@ VkResult WrappedVulkan::vkCreateImageView( if(ret == VK_SUCCESS) { - ResourceId id = GetResourceManager()->WrapResource(*pView); + ResourceId id = GetResourceManager()->WrapResource(Unwrap(device), *pView); if(m_State >= WRITING) { @@ -2283,7 +2275,7 @@ bool WrappedVulkan::Serialise_vkCreateAttachmentView( } else { - ResourceId live = GetResourceManager()->WrapResource(view); + ResourceId live = GetResourceManager()->WrapResource(Unwrap(device), view); GetResourceManager()->AddLiveResource(id, view); } } @@ -2302,7 +2294,7 @@ VkResult WrappedVulkan::vkCreateAttachmentView( if(ret == VK_SUCCESS) { - ResourceId id = GetResourceManager()->WrapResource(*pView); + ResourceId id = GetResourceManager()->WrapResource(Unwrap(device), *pView); if(m_State >= WRITING) { @@ -2352,7 +2344,7 @@ bool WrappedVulkan::Serialise_vkCreateShaderModule( } else { - ResourceId live = GetResourceManager()->WrapResource(sh); + ResourceId live = GetResourceManager()->WrapResource(Unwrap(device), sh); GetResourceManager()->AddLiveResource(id, sh); } } @@ -2369,7 +2361,7 @@ VkResult WrappedVulkan::vkCreateShaderModule( if(ret == VK_SUCCESS) { - ResourceId id = GetResourceManager()->WrapResource(*pShaderModule); + ResourceId id = GetResourceManager()->WrapResource(Unwrap(device), *pShaderModule); if(m_State >= WRITING) { @@ -2416,7 +2408,7 @@ bool WrappedVulkan::Serialise_vkCreateShader( } else { - ResourceId live = GetResourceManager()->WrapResource(sh); + ResourceId live = GetResourceManager()->WrapResource(Unwrap(device), sh); GetResourceManager()->AddLiveResource(id, sh); } } @@ -2435,7 +2427,7 @@ VkResult WrappedVulkan::vkCreateShader( if(ret == VK_SUCCESS) { - ResourceId id = GetResourceManager()->WrapResource(*pShader); + ResourceId id = GetResourceManager()->WrapResource(Unwrap(device), *pShader); if(m_State >= WRITING) { @@ -2487,7 +2479,7 @@ bool WrappedVulkan::Serialise_vkCreatePipelineCache( } else { - ResourceId live = GetResourceManager()->WrapResource(cache); + ResourceId live = GetResourceManager()->WrapResource(Unwrap(device), cache); GetResourceManager()->AddLiveResource(id, cache); } } @@ -2504,7 +2496,7 @@ VkResult WrappedVulkan::vkCreatePipelineCache( if(ret == VK_SUCCESS) { - ResourceId id = GetResourceManager()->WrapResource(*pPipelineCache); + ResourceId id = GetResourceManager()->WrapResource(Unwrap(device), *pPipelineCache); if(m_State >= WRITING) { @@ -2559,7 +2551,7 @@ bool WrappedVulkan::Serialise_vkCreateGraphicsPipelines( } else { - ResourceId live = GetResourceManager()->WrapResource(pipe); + ResourceId live = GetResourceManager()->WrapResource(Unwrap(device), pipe); GetResourceManager()->AddLiveResource(id, pipe); } } @@ -2580,10 +2572,10 @@ VkResult WrappedVulkan::vkCreateGraphicsPipelines( for(uint32_t i=0; i < count; i++) { VkPipelineShaderStageCreateInfo *unwrappedStages = new VkPipelineShaderStageCreateInfo[pCreateInfos[i].stageCount]; - for(uint32_t j=0; j < pCreateInfos[j].stageCount; j++) + for(uint32_t j=0; j < pCreateInfos[i].stageCount; j++) { - unwrappedStages[i] = unwrappedInfos[i].pStages[j]; - unwrappedStages[i].shader = Unwrap(unwrappedStages[i].shader); + unwrappedStages[j] = pCreateInfos[i].pStages[j]; + unwrappedStages[j].shader = Unwrap(unwrappedStages[j].shader); } unwrappedInfos[i] = pCreateInfos[i]; @@ -2603,7 +2595,7 @@ VkResult WrappedVulkan::vkCreateGraphicsPipelines( { for(uint32_t i=0; i < count; i++) { - ResourceId id = GetResourceManager()->WrapResource(pPipelines[i]); + ResourceId id = GetResourceManager()->WrapResource(Unwrap(device), pPipelines[i]); if(m_State >= WRITING) { @@ -2660,7 +2652,7 @@ bool WrappedVulkan::Serialise_vkCreateDescriptorPool( device = GetResourceManager()->GetLiveHandle(devId); - VkResult ret = ObjDisp(device)->CreateDescriptorPool(device, pooluse, maxs, &info, &pool); + VkResult ret = ObjDisp(device)->CreateDescriptorPool(Unwrap(device), pooluse, maxs, &info, &pool); if(ret != VK_SUCCESS) { @@ -2668,7 +2660,7 @@ bool WrappedVulkan::Serialise_vkCreateDescriptorPool( } else { - ResourceId live = GetResourceManager()->WrapResource(pool); + ResourceId live = GetResourceManager()->WrapResource(Unwrap(device), pool); GetResourceManager()->AddLiveResource(id, pool); } } @@ -2687,7 +2679,7 @@ VkResult WrappedVulkan::vkCreateDescriptorPool( if(ret == VK_SUCCESS) { - ResourceId id = GetResourceManager()->WrapResource(*pDescriptorPool); + ResourceId id = GetResourceManager()->WrapResource(Unwrap(device), *pDescriptorPool); if(m_State >= WRITING) { @@ -2739,7 +2731,7 @@ bool WrappedVulkan::Serialise_vkCreateDescriptorSetLayout( } else { - ResourceId live = GetResourceManager()->WrapResource(layout); + ResourceId live = GetResourceManager()->WrapResource(Unwrap(device), layout); GetResourceManager()->AddLiveResource(id, layout); } } @@ -2778,7 +2770,7 @@ VkResult WrappedVulkan::vkCreateDescriptorSetLayout( if(ret == VK_SUCCESS) { - ResourceId id = GetResourceManager()->WrapResource(*pSetLayout); + ResourceId id = GetResourceManager()->WrapResource(Unwrap(device), *pSetLayout); if(m_State >= WRITING) { @@ -2826,7 +2818,7 @@ bool WrappedVulkan::Serialise_vkCreatePipelineLayout( } else { - ResourceId live = GetResourceManager()->WrapResource(layout); + ResourceId live = GetResourceManager()->WrapResource(Unwrap(device), layout); GetResourceManager()->AddLiveResource(id, layout); } } @@ -2854,7 +2846,7 @@ VkResult WrappedVulkan::vkCreatePipelineLayout( if(ret == VK_SUCCESS) { - ResourceId id = GetResourceManager()->WrapResource(*pPipelineLayout); + ResourceId id = GetResourceManager()->WrapResource(Unwrap(device), *pPipelineLayout); if(m_State >= WRITING) { @@ -2903,7 +2895,7 @@ bool WrappedVulkan::Serialise_vkCreateSampler( } else { - ResourceId live = GetResourceManager()->WrapResource(samp); + ResourceId live = GetResourceManager()->WrapResource(Unwrap(device), samp); GetResourceManager()->AddLiveResource(id, samp); } } @@ -2920,7 +2912,7 @@ VkResult WrappedVulkan::vkCreateSampler( if(ret == VK_SUCCESS) { - ResourceId id = GetResourceManager()->WrapResource(*pSampler); + ResourceId id = GetResourceManager()->WrapResource(Unwrap(device), *pSampler); if(m_State >= WRITING) { @@ -2967,7 +2959,7 @@ bool WrappedVulkan::Serialise_vkCreateSemaphore( } else { - ResourceId live = GetResourceManager()->WrapResource(sem); + ResourceId live = GetResourceManager()->WrapResource(Unwrap(device), sem); GetResourceManager()->AddLiveResource(id, sem); } } @@ -2984,7 +2976,7 @@ VkResult WrappedVulkan::vkCreateSemaphore( if(ret == VK_SUCCESS) { - ResourceId id = GetResourceManager()->WrapResource(*pSemaphore); + ResourceId id = GetResourceManager()->WrapResource(Unwrap(device), *pSemaphore); if(m_State >= WRITING) { @@ -3034,7 +3026,7 @@ bool WrappedVulkan::Serialise_vkCreateFramebuffer( } else { - ResourceId live = GetResourceManager()->WrapResource(fb); + ResourceId live = GetResourceManager()->WrapResource(Unwrap(device), fb); GetResourceManager()->AddLiveResource(id, fb); } } @@ -3066,7 +3058,7 @@ VkResult WrappedVulkan::vkCreateFramebuffer( if(ret == VK_SUCCESS) { - ResourceId id = GetResourceManager()->WrapResource(*pFramebuffer); + ResourceId id = GetResourceManager()->WrapResource(Unwrap(device), *pFramebuffer); if(m_State >= WRITING) { @@ -3118,7 +3110,7 @@ bool WrappedVulkan::Serialise_vkCreateRenderPass( } else { - ResourceId live = GetResourceManager()->WrapResource(rp); + ResourceId live = GetResourceManager()->WrapResource(Unwrap(device), rp); GetResourceManager()->AddLiveResource(id, rp); } } @@ -3135,7 +3127,7 @@ VkResult WrappedVulkan::vkCreateRenderPass( if(ret == VK_SUCCESS) { - ResourceId id = GetResourceManager()->WrapResource(*pRenderPass); + ResourceId id = GetResourceManager()->WrapResource(Unwrap(device), *pRenderPass); if(m_State >= WRITING) { @@ -3187,7 +3179,7 @@ bool WrappedVulkan::Serialise_vkCreateDynamicViewportState( } else { - ResourceId live = GetResourceManager()->WrapResource(state); + ResourceId live = GetResourceManager()->WrapResource(Unwrap(device), state); GetResourceManager()->AddLiveResource(id, state); } } @@ -3204,7 +3196,7 @@ VkResult WrappedVulkan::vkCreateDynamicViewportState( if(ret == VK_SUCCESS) { - ResourceId id = GetResourceManager()->WrapResource(*pState); + ResourceId id = GetResourceManager()->WrapResource(Unwrap(device), *pState); if(m_State >= WRITING) { @@ -3254,7 +3246,7 @@ bool WrappedVulkan::Serialise_vkCreateDynamicRasterState( } else { - ResourceId live = GetResourceManager()->WrapResource(state); + ResourceId live = GetResourceManager()->WrapResource(Unwrap(device), state); GetResourceManager()->AddLiveResource(id, state); } } @@ -3271,7 +3263,7 @@ VkResult WrappedVulkan::vkCreateDynamicRasterState( if(ret == VK_SUCCESS) { - ResourceId id = GetResourceManager()->WrapResource(*pState); + ResourceId id = GetResourceManager()->WrapResource(Unwrap(device), *pState); if(m_State >= WRITING) { @@ -3321,7 +3313,7 @@ bool WrappedVulkan::Serialise_vkCreateDynamicColorBlendState( } else { - ResourceId live = GetResourceManager()->WrapResource(state); + ResourceId live = GetResourceManager()->WrapResource(Unwrap(device), state); GetResourceManager()->AddLiveResource(id, state); } } @@ -3338,7 +3330,7 @@ VkResult WrappedVulkan::vkCreateDynamicColorBlendState( if(ret == VK_SUCCESS) { - ResourceId id = GetResourceManager()->WrapResource(*pState); + ResourceId id = GetResourceManager()->WrapResource(Unwrap(device), *pState); if(m_State >= WRITING) { @@ -3388,7 +3380,7 @@ bool WrappedVulkan::Serialise_vkCreateDynamicDepthStencilState( } else { - ResourceId live = GetResourceManager()->WrapResource(state); + ResourceId live = GetResourceManager()->WrapResource(Unwrap(device), state); GetResourceManager()->AddLiveResource(id, state); } } @@ -3405,7 +3397,7 @@ VkResult WrappedVulkan::vkCreateDynamicDepthStencilState( if(ret == VK_SUCCESS) { - ResourceId id = GetResourceManager()->WrapResource(*pState); + ResourceId id = GetResourceManager()->WrapResource(Unwrap(device), *pState); if(m_State >= WRITING) { @@ -3454,7 +3446,7 @@ bool WrappedVulkan::Serialise_vkCreateCommandPool( } else { - ResourceId live = GetResourceManager()->WrapResource(pool); + ResourceId live = GetResourceManager()->WrapResource(Unwrap(device), pool); GetResourceManager()->AddLiveResource(id, pool); } } @@ -3471,7 +3463,7 @@ VkResult WrappedVulkan::vkCreateCommandPool( if(ret == VK_SUCCESS) { - ResourceId id = GetResourceManager()->WrapResource(*pCmdPool); + ResourceId id = GetResourceManager()->WrapResource(Unwrap(device), *pCmdPool); if(m_State >= WRITING) { @@ -3519,7 +3511,7 @@ VkResult WrappedVulkan::vkCreateCommandBuffer( if(ret == VK_SUCCESS) { - ResourceId id = GetResourceManager()->WrapResource(*pCmdBuffer); + ResourceId id = GetResourceManager()->WrapResource(Unwrap(device), *pCmdBuffer); if(m_State >= WRITING) { @@ -3568,7 +3560,7 @@ bool WrappedVulkan::Serialise_vkAllocDescriptorSets( VkDescriptorSetLayout layout = GetResourceManager()->GetLiveHandle(layoutId); uint32_t cnt = 0; - VkResult ret = ObjDisp(device)->AllocDescriptorSets(device, descriptorPool, usage, 1, &layout, &descset, &cnt); + VkResult ret = ObjDisp(device)->AllocDescriptorSets(Unwrap(device), descriptorPool, usage, 1, &layout, &descset, &cnt); if(ret != VK_SUCCESS) { @@ -3576,7 +3568,7 @@ bool WrappedVulkan::Serialise_vkAllocDescriptorSets( } else { - ResourceId live = GetResourceManager()->WrapResource(descset); + ResourceId live = GetResourceManager()->WrapResource(Unwrap(device), descset); GetResourceManager()->AddLiveResource(id, descset); // this is stored in the resource record on capture, we need to be able to look to up @@ -3597,7 +3589,15 @@ VkResult WrappedVulkan::vkAllocDescriptorSets( VkDescriptorSet* pDescriptorSets, uint32_t* pCount) { - VkResult ret = ObjDisp(device)->AllocDescriptorSets(Unwrap(device), Unwrap(descriptorPool), setUsage, count, pSetLayouts, pDescriptorSets, pCount); + // VKTODOLOW this should be a persistent per-thread array that resizes up + // to a high water mark, so we don't have to allocate + VkDescriptorSetLayout *unwrapped = new VkDescriptorSetLayout[count]; + for(uint32_t i=0; i < count; i++) + unwrapped[i] = Unwrap(pSetLayouts[i]); + + VkResult ret = ObjDisp(device)->AllocDescriptorSets(Unwrap(device), Unwrap(descriptorPool), setUsage, count, unwrapped, pDescriptorSets, pCount); + + SAFE_DELETE_ARRAY(unwrapped); RDCASSERT(pCount == NULL || *pCount == count); // VKTODOMED: find out what *pCount < count means @@ -3605,7 +3605,7 @@ VkResult WrappedVulkan::vkAllocDescriptorSets( { for(uint32_t i=0; i < count; i++) { - ResourceId id = GetResourceManager()->WrapResource(pDescriptorSets[i]); + ResourceId id = GetResourceManager()->WrapResource(Unwrap(device), pDescriptorSets[i]); if(m_State >= WRITING) { @@ -3952,7 +3952,7 @@ bool WrappedVulkan::Serialise_vkBeginCommandBuffer( } else { - GetResourceManager()->WrapResource(cmd); + GetResourceManager()->WrapResource(Unwrap(device), cmd); } m_PartialReplayData.resultPartialCmdBuffer = cmd; @@ -3982,7 +3982,7 @@ bool WrappedVulkan::Serialise_vkBeginCommandBuffer( } else { - ResourceId live = GetResourceManager()->WrapResource(cmd); + ResourceId live = GetResourceManager()->WrapResource(Unwrap(device), cmd); GetResourceManager()->AddLiveResource(bakeId, cmd); } @@ -4163,7 +4163,7 @@ bool WrappedVulkan::Serialise_vkResetCommandBuffer(VkCmdBuffer cmdBuffer, VkCmdB } else { - ResourceId live = GetResourceManager()->WrapResource(cmd); + ResourceId live = GetResourceManager()->WrapResource(Unwrap(device), cmd); GetResourceManager()->AddLiveResource(bakeId, cmd); } @@ -6750,7 +6750,7 @@ VkResult WrappedVulkan::vkGetSwapChainInfoWSI( } else { - ResourceId id = GetResourceManager()->WrapResource(images[i].image); + ResourceId id = GetResourceManager()->WrapResource(Unwrap(device), images[i].image); if(m_State >= WRITING) { @@ -6864,7 +6864,7 @@ bool WrappedVulkan::Serialise_vkCreateSwapChainWSI( VkResult vkr = ObjDisp(device)->CreateImage(Unwrap(device), &imInfo, &im); RDCASSERT(vkr == VK_SUCCESS); - ResourceId liveId = GetResourceManager()->WrapResource(im); + ResourceId liveId = GetResourceManager()->WrapResource(Unwrap(device), im); VkMemoryRequirements mrq = {0}; @@ -6879,7 +6879,7 @@ bool WrappedVulkan::Serialise_vkCreateSwapChainWSI( vkr = ObjDisp(device)->AllocMemory(Unwrap(device), &allocInfo, &mem); RDCASSERT(vkr == VK_SUCCESS); - GetResourceManager()->WrapResource(mem); + GetResourceManager()->WrapResource(Unwrap(device), mem); vkr = ObjDisp(device)->BindImageMemory(Unwrap(device), Unwrap(im), Unwrap(mem), 0); RDCASSERT(vkr == VK_SUCCESS); @@ -6923,7 +6923,7 @@ VkResult WrappedVulkan::vkCreateSwapChainWSI( if(ret == VK_SUCCESS) { - ResourceId id = GetResourceManager()->WrapResource(*pSwapChain); + ResourceId id = GetResourceManager()->WrapResource(Unwrap(device), *pSwapChain); if(m_State >= WRITING) { @@ -6982,7 +6982,7 @@ VkResult WrappedVulkan::vkCreateSwapChainWSI( vkr = vt->CreateRenderPass(Unwrap(device), &rpinfo, &swapInfo.rp); RDCASSERT(vkr == VK_SUCCESS); - GetResourceManager()->WrapResource(swapInfo.rp); + GetResourceManager()->WrapResource(Unwrap(device), swapInfo.rp); } { @@ -6997,7 +6997,7 @@ VkResult WrappedVulkan::vkCreateSwapChainWSI( vkr = vt->CreateDynamicViewportState(Unwrap(device), &vpInfo, &swapInfo.vp); RDCASSERT(vkr == VK_SUCCESS); - GetResourceManager()->WrapResource(swapInfo.vp); + GetResourceManager()->WrapResource(Unwrap(device), swapInfo.vp); } // serialise out the swap chain images @@ -7052,7 +7052,7 @@ VkResult WrappedVulkan::vkCreateSwapChainWSI( vkr = vt->CreateAttachmentView(Unwrap(device), &info, &swapImInfo.view); RDCASSERT(vkr == VK_SUCCESS); - GetResourceManager()->WrapResource(swapImInfo.view); + GetResourceManager()->WrapResource(Unwrap(device), swapImInfo.view); VkAttachmentBindInfo attBind = { swapImInfo.view, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL }; @@ -7066,7 +7066,7 @@ VkResult WrappedVulkan::vkCreateSwapChainWSI( vkr = vt->CreateFramebuffer(Unwrap(device), &fbinfo, &swapImInfo.fb); RDCASSERT(vkr == VK_SUCCESS); - GetResourceManager()->WrapResource(swapImInfo.fb); + GetResourceManager()->WrapResource(Unwrap(device), swapImInfo.fb); } } @@ -7652,7 +7652,7 @@ bool WrappedVulkan::Prepare_InitialState(WrappedVkRes *res) vkr = ObjDisp(d)->AllocMemory(Unwrap(d), &allocInfo, &mem); RDCASSERT(vkr == VK_SUCCESS); - GetResourceManager()->WrapResource(mem); + GetResourceManager()->WrapResource(Unwrap(d), mem); VkCmdBufferBeginInfo beginInfo = { VK_STRUCTURE_TYPE_CMD_BUFFER_BEGIN_INFO, NULL, VK_CMD_BUFFER_OPTIMIZE_SMALL_BATCH_BIT | VK_CMD_BUFFER_OPTIMIZE_ONE_TIME_SUBMIT_BIT }; @@ -7824,7 +7824,7 @@ bool WrappedVulkan::Serialise_InitialState(WrappedVkRes *res) vkr = ObjDisp(d)->AllocMemory(Unwrap(d), &allocInfo, &mem); RDCASSERT(vkr == VK_SUCCESS); - GetResourceManager()->WrapResource(mem); + GetResourceManager()->WrapResource(Unwrap(d), mem); VkBufferCreateInfo bufInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, NULL, @@ -7837,7 +7837,7 @@ bool WrappedVulkan::Serialise_InitialState(WrappedVkRes *res) vkr = ObjDisp(d)->CreateBuffer(Unwrap(d), &bufInfo, &buf); RDCASSERT(vkr == VK_SUCCESS); - GetResourceManager()->WrapResource(buf); + GetResourceManager()->WrapResource(Unwrap(d), buf); vkr = ObjDisp(d)->BindBufferMemory(Unwrap(d), Unwrap(buf), Unwrap(mem), 0); RDCASSERT(vkr == VK_SUCCESS); @@ -8040,9 +8040,6 @@ void WrappedVulkan::ProcessChunk(uint64_t offset, VulkanChunkType context) case CREATE_DESCRIPTOR_POOL: Serialise_vkCreateDescriptorPool(VK_NULL_HANDLE, VK_DESCRIPTOR_POOL_USAGE_MAX_ENUM, 0, NULL, NULL); break; - case CREATE_DESCRIPTOR_SET: - Serialise_vkAllocDescriptorSets(VK_NULL_HANDLE, VK_NULL_HANDLE, VK_DESCRIPTOR_SET_USAGE_MAX_ENUM, 0, NULL, NULL, NULL); - break; case CREATE_DESCRIPTOR_SET_LAYOUT: Serialise_vkCreateDescriptorSetLayout(VK_NULL_HANDLE, NULL, NULL); break; diff --git a/renderdoc/driver/vulkan/vk_core.h b/renderdoc/driver/vulkan/vk_core.h index 0a42247b3..a230b0f49 100644 --- a/renderdoc/driver/vulkan/vk_core.h +++ b/renderdoc/driver/vulkan/vk_core.h @@ -54,14 +54,14 @@ extern VkLayerInstanceDispatchTable *dummyInstanceTable; extern device_table_map renderdoc_device_table_map; extern instance_table_map renderdoc_instance_table_map; -template -void SetDispatchTable(bool writing, wrappedtype *wrapped) +template +void SetDispatchTable(bool writing, parenttype parent, wrappedtype *wrapped) { if(writing) { wrapped->table = wrappedtype::UseInstanceDispatchTable - ? (uintptr_t)get_dispatch_table(renderdoc_instance_table_map, (void *)wrapped->real.handle) - : (uintptr_t)get_dispatch_table(renderdoc_device_table_map, (void *)wrapped->real.handle); + ? (uintptr_t)get_dispatch_table(renderdoc_instance_table_map, (void *)parent) + : (uintptr_t)get_dispatch_table(renderdoc_device_table_map, (void *)parent); } else { @@ -71,12 +71,18 @@ void SetDispatchTable(bool writing, wrappedtype *wrapped) } } -template inline void SetTableIfDispatchable(bool writing, wrappedtype *obj) {} -template<> inline void SetTableIfDispatchable(bool writing, WrappedVkInstance *obj) { SetDispatchTable(writing, obj); } -template<> inline void SetTableIfDispatchable(bool writing, WrappedVkPhysicalDevice *obj) { SetDispatchTable(writing, obj); } -template<> inline void SetTableIfDispatchable(bool writing, WrappedVkDevice *obj) { SetDispatchTable(writing, obj); } -template<> inline void SetTableIfDispatchable(bool writing, WrappedVkQueue *obj) { SetDispatchTable(writing, obj); } -template<> inline void SetTableIfDispatchable(bool writing, WrappedVkCmdBuffer *obj) { SetDispatchTable(writing, obj); } +template +inline void SetTableIfDispatchable(bool writing, parenttype parent, wrappedtype *obj) {} +template<> inline void SetTableIfDispatchable(bool writing, VkInstance parent, WrappedVkInstance *obj) +{ SetDispatchTable(writing, parent, obj); } +template<> inline void SetTableIfDispatchable(bool writing, VkInstance parent, WrappedVkPhysicalDevice *obj) +{ SetDispatchTable(writing, parent, obj); } +template<> inline void SetTableIfDispatchable(bool writing, VkDevice parent, WrappedVkDevice *obj) +{ SetDispatchTable(writing, parent, obj); } +template<> inline void SetTableIfDispatchable(bool writing, VkDevice parent, WrappedVkQueue *obj) +{ SetDispatchTable(writing, parent, obj); } +template<> inline void SetTableIfDispatchable(bool writing, VkDevice parent, WrappedVkCmdBuffer *obj) +{ SetDispatchTable(writing, parent, obj); } using std::vector; using std::list; diff --git a/renderdoc/driver/vulkan/vk_debug.cpp b/renderdoc/driver/vulkan/vk_debug.cpp index 1d04d690d..ca39ceab0 100644 --- a/renderdoc/driver/vulkan/vk_debug.cpp +++ b/renderdoc/driver/vulkan/vk_debug.cpp @@ -92,7 +92,7 @@ void VulkanDebugManager::UBO::Create(WrappedVulkan *driver, VkDevice dev, VkDevi VkResult vkr = vt->CreateBuffer(Unwrap(dev), &bufInfo, &buf); RDCASSERT(vkr == VK_SUCCESS); - VKMGR()->WrapResource(buf); + VKMGR()->WrapResource(Unwrap(dev), buf); VkMemoryRequirements mrq; vkr = vt->GetBufferMemoryRequirements(Unwrap(dev), Unwrap(buf), &mrq); @@ -107,7 +107,7 @@ void VulkanDebugManager::UBO::Create(WrappedVulkan *driver, VkDevice dev, VkDevi vkr = vt->AllocMemory(Unwrap(dev), &allocInfo, &mem); RDCASSERT(vkr == VK_SUCCESS); - VKMGR()->WrapResource(mem); + VKMGR()->WrapResource(Unwrap(dev), mem); vkr = vt->BindBufferMemory(Unwrap(dev), Unwrap(buf), Unwrap(mem), 0); RDCASSERT(vkr == VK_SUCCESS); @@ -121,7 +121,7 @@ void VulkanDebugManager::UBO::Create(WrappedVulkan *driver, VkDevice dev, VkDevi vkr = vt->CreateBufferView(Unwrap(dev), &bufviewInfo, &view); RDCASSERT(vkr == VK_SUCCESS); - VKMGR()->WrapResource(view); + VKMGR()->WrapResource(Unwrap(dev), view); } void VulkanDebugManager::UBO::Destroy(const VkLayerDispatchTable *vt, VkDevice dev) @@ -224,7 +224,7 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev, VkIm vkr = vt->CreateSampler(Unwrap(dev), &sampInfo, &m_LinearSampler); RDCASSERT(vkr == VK_SUCCESS); - VKMGR()->WrapResource(m_LinearSampler); + VKMGR()->WrapResource(Unwrap(dev), m_LinearSampler); sampInfo.minFilter = VK_TEX_FILTER_NEAREST; sampInfo.magFilter = VK_TEX_FILTER_NEAREST; @@ -233,14 +233,14 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev, VkIm vkr = vt->CreateSampler(Unwrap(dev), &sampInfo, &m_PointSampler); RDCASSERT(vkr == VK_SUCCESS); - VKMGR()->WrapResource(m_PointSampler); + VKMGR()->WrapResource(Unwrap(dev), m_PointSampler); VkPipelineCacheCreateInfo cacheInfo = { VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO, NULL, 0, NULL, 0 }; vkr = vt->CreatePipelineCache(Unwrap(dev), &cacheInfo, &m_PipelineCache); RDCASSERT(vkr == VK_SUCCESS); - VKMGR()->WrapResource(m_PipelineCache); + VKMGR()->WrapResource(Unwrap(dev), m_PipelineCache); { // VKTODOLOW not sure if these stage flags VK_SHADER_STAGE_... work yet? @@ -256,7 +256,7 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev, VkIm vkr = vt->CreateDescriptorSetLayout(Unwrap(dev), &descsetLayoutInfo, &m_CheckerboardDescSetLayout); RDCASSERT(vkr == VK_SUCCESS); - VKMGR()->WrapResource(m_CheckerboardDescSetLayout); + VKMGR()->WrapResource(Unwrap(dev), m_CheckerboardDescSetLayout); } { @@ -273,7 +273,7 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev, VkIm vkr = vt->CreateDescriptorSetLayout(Unwrap(dev), &descsetLayoutInfo, &m_TexDisplayDescSetLayout); RDCASSERT(vkr == VK_SUCCESS); - VKMGR()->WrapResource(m_TexDisplayDescSetLayout); + VKMGR()->WrapResource(Unwrap(dev), m_TexDisplayDescSetLayout); } { @@ -292,7 +292,7 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev, VkIm vkr = vt->CreateDescriptorSetLayout(Unwrap(dev), &descsetLayoutInfo, &m_TextDescSetLayout); RDCASSERT(vkr == VK_SUCCESS); - VKMGR()->WrapResource(m_TextDescSetLayout); + VKMGR()->WrapResource(Unwrap(dev), m_TextDescSetLayout); } VkPipelineLayoutCreateInfo pipeLayoutInfo = { @@ -304,21 +304,21 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev, VkIm vkr = vt->CreatePipelineLayout(Unwrap(dev), &pipeLayoutInfo, &m_TexDisplayPipeLayout); RDCASSERT(vkr == VK_SUCCESS); - VKMGR()->WrapResource(m_TexDisplayPipeLayout); + VKMGR()->WrapResource(Unwrap(dev), m_TexDisplayPipeLayout); pipeLayoutInfo.pSetLayouts = UnwrapPtr(m_CheckerboardDescSetLayout); vkr = vt->CreatePipelineLayout(Unwrap(dev), &pipeLayoutInfo, &m_CheckerboardPipeLayout); RDCASSERT(vkr == VK_SUCCESS); - VKMGR()->WrapResource(m_CheckerboardPipeLayout); + VKMGR()->WrapResource(Unwrap(dev), m_CheckerboardPipeLayout); pipeLayoutInfo.pSetLayouts = UnwrapPtr(m_TextDescSetLayout); vkr = vt->CreatePipelineLayout(Unwrap(dev), &pipeLayoutInfo, &m_TextPipeLayout); RDCASSERT(vkr == VK_SUCCESS); - VKMGR()->WrapResource(m_TextPipeLayout); + VKMGR()->WrapResource(Unwrap(dev), m_TextPipeLayout); VkDescriptorTypeCount descPoolTypes[] = { { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1024, }, @@ -333,26 +333,26 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev, VkIm vkr = vt->CreateDescriptorPool(Unwrap(dev), VK_DESCRIPTOR_POOL_USAGE_ONE_SHOT, 3, &descpoolInfo, &m_DescriptorPool); RDCASSERT(vkr == VK_SUCCESS); - VKMGR()->WrapResource(m_DescriptorPool); + VKMGR()->WrapResource(Unwrap(dev), m_DescriptorPool); uint32_t count; vkr = vt->AllocDescriptorSets(Unwrap(dev), Unwrap(m_DescriptorPool), VK_DESCRIPTOR_SET_USAGE_STATIC, 1, UnwrapPtr(m_CheckerboardDescSetLayout), &m_CheckerboardDescSet, &count); RDCASSERT(vkr == VK_SUCCESS); - VKMGR()->WrapResource(m_CheckerboardDescSet); + VKMGR()->WrapResource(Unwrap(dev), m_CheckerboardDescSet); vkr = vt->AllocDescriptorSets(Unwrap(dev), Unwrap(m_DescriptorPool), VK_DESCRIPTOR_SET_USAGE_STATIC, 1, UnwrapPtr(m_TexDisplayDescSetLayout), &m_TexDisplayDescSet, &count); RDCASSERT(vkr == VK_SUCCESS); - VKMGR()->WrapResource(m_TexDisplayDescSet); + VKMGR()->WrapResource(Unwrap(dev), m_TexDisplayDescSet); vkr = vt->AllocDescriptorSets(Unwrap(dev), Unwrap(m_DescriptorPool), VK_DESCRIPTOR_SET_USAGE_STATIC, 1, UnwrapPtr(m_TextDescSetLayout), &m_TextDescSet, &count); RDCASSERT(vkr == VK_SUCCESS); - VKMGR()->WrapResource(m_TextDescSet); + VKMGR()->WrapResource(Unwrap(dev), m_TextDescSet); m_CheckerboardUBO.Create(driver, dev, 128); m_TexDisplayUBO.Create(driver, dev, 128); @@ -373,7 +373,7 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev, VkIm vkr = vt->CreateDynamicRasterState(Unwrap(dev), &rsInfo, &m_DynamicRSState); RDCASSERT(vkr == VK_SUCCESS); - VKMGR()->WrapResource(m_DynamicRSState); + VKMGR()->WrapResource(Unwrap(dev), m_DynamicRSState); VkDynamicColorBlendStateCreateInfo cbInfo = { VK_STRUCTURE_TYPE_DYNAMIC_COLOR_BLEND_STATE_CREATE_INFO, NULL, @@ -383,7 +383,7 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev, VkIm vkr = vt->CreateDynamicColorBlendState(Unwrap(dev), &cbInfo, &m_DynamicCBStateWhite); RDCASSERT(vkr == VK_SUCCESS); - VKMGR()->WrapResource(m_DynamicCBStateWhite); + VKMGR()->WrapResource(Unwrap(dev), m_DynamicCBStateWhite); VkDynamicDepthStencilStateCreateInfo dsInfo = { VK_STRUCTURE_TYPE_DYNAMIC_DEPTH_STENCIL_STATE_CREATE_INFO, NULL, @@ -393,7 +393,7 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev, VkIm vkr = vt->CreateDynamicDepthStencilState(Unwrap(dev), &dsInfo, &m_DynamicDSStateDisabled); RDCASSERT(vkr == VK_SUCCESS); - VKMGR()->WrapResource(m_DynamicDSStateDisabled); + VKMGR()->WrapResource(Unwrap(dev), m_DynamicDSStateDisabled); string shaderSources[] = { GetEmbeddedResource(blitvs_spv), @@ -425,7 +425,7 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev, VkIm vkr = vt->CreateShaderModule(Unwrap(dev), &modinfo, &module[i]); RDCASSERT(vkr == VK_SUCCESS); - VKMGR()->WrapResource(module[i]); + VKMGR()->WrapResource(Unwrap(dev), module[i]); VkShaderCreateInfo shadinfo = { VK_STRUCTURE_TYPE_SHADER_CREATE_INFO, NULL, @@ -435,7 +435,7 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev, VkIm vkr = vt->CreateShader(Unwrap(dev), &shadinfo, &shader[i]); RDCASSERT(vkr == VK_SUCCESS); - VKMGR()->WrapResource(shader[i]); + VKMGR()->WrapResource(Unwrap(dev), shader[i]); } VkPipelineShaderStageCreateInfo stages[2] = { @@ -508,7 +508,7 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev, VkIm vkr = vt->CreateGraphicsPipelines(Unwrap(dev), Unwrap(m_PipelineCache), 1, &pipeInfo, &m_CheckerboardPipeline); RDCASSERT(vkr == VK_SUCCESS); - VKMGR()->WrapResource(m_CheckerboardPipeline); + VKMGR()->WrapResource(Unwrap(dev), m_CheckerboardPipeline); stages[0].shader = Unwrap(shader[BLITVS]); stages[1].shader = Unwrap(shader[TEXDISPLAYFS]); @@ -518,7 +518,7 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev, VkIm vkr = vt->CreateGraphicsPipelines(Unwrap(dev), Unwrap(m_PipelineCache), 1, &pipeInfo, &m_TexDisplayPipeline); RDCASSERT(vkr == VK_SUCCESS); - VKMGR()->WrapResource(m_TexDisplayPipeline); + VKMGR()->WrapResource(Unwrap(dev), m_TexDisplayPipeline); attState.blendEnable = true; attState.srcBlendColor = VK_BLEND_SRC_ALPHA; @@ -527,7 +527,7 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev, VkIm vkr = vt->CreateGraphicsPipelines(Unwrap(dev), Unwrap(m_PipelineCache), 1, &pipeInfo, &m_TexDisplayBlendPipeline); RDCASSERT(vkr == VK_SUCCESS); - VKMGR()->WrapResource(m_TexDisplayBlendPipeline); + VKMGR()->WrapResource(Unwrap(dev), m_TexDisplayBlendPipeline); ia.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; @@ -539,7 +539,7 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev, VkIm vkr = vt->CreateGraphicsPipelines(Unwrap(dev), Unwrap(m_PipelineCache), 1, &pipeInfo, &m_TextPipeline); RDCASSERT(vkr == VK_SUCCESS); - VKMGR()->WrapResource(m_TextPipeline); + VKMGR()->WrapResource(Unwrap(dev), m_TextPipeline); for(size_t i=0; i < ARRAY_COUNT(module); i++) { @@ -599,7 +599,7 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev, VkIm vkr = vt->CreateImage(Unwrap(dev), &imInfo, &m_TextAtlas); RDCASSERT(vkr == VK_SUCCESS); - VKMGR()->WrapResource(m_TextAtlas); + VKMGR()->WrapResource(Unwrap(dev), m_TextAtlas); VkMemoryRequirements mrq; vkr = vt->GetImageMemoryRequirements(Unwrap(dev), Unwrap(m_TextAtlas), &mrq); @@ -618,7 +618,7 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev, VkIm vkr = vt->AllocMemory(Unwrap(dev), &allocInfo, &m_TextAtlasMem); RDCASSERT(vkr == VK_SUCCESS); - VKMGR()->WrapResource(m_TextAtlasMem); + VKMGR()->WrapResource(Unwrap(dev), m_TextAtlasMem); vkr = vt->BindImageMemory(Unwrap(dev), Unwrap(m_TextAtlas), Unwrap(m_TextAtlasMem), 0); RDCASSERT(vkr == VK_SUCCESS); @@ -636,7 +636,7 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev, VkIm vkr = vt->CreateImageView(Unwrap(dev), &viewInfo, &m_TextAtlasView); RDCASSERT(vkr == VK_SUCCESS); - VKMGR()->WrapResource(m_TextAtlasView); + VKMGR()->WrapResource(Unwrap(dev), m_TextAtlasView); // need to transition image into valid state, then upload VkCmdBuffer cmd = driver->GetCmd(); diff --git a/renderdoc/driver/vulkan/vk_manager.h b/renderdoc/driver/vulkan/vk_manager.h index 9656d614d..c54345abc 100644 --- a/renderdoc/driver/vulkan/vk_manager.h +++ b/renderdoc/driver/vulkan/vk_manager.h @@ -104,15 +104,15 @@ class VulkanResourceManager : public ResourceManagerid; } - template - ResourceId WrapResource(realtype &obj) + template + ResourceId WrapResource(parenttype parentObj, realtype &obj) { RDCASSERT(obj != VK_NULL_HANDLE); ResourceId id = ResourceIDGen::GetNewUniqueID(); typename UnwrapHelper::Outer *wrapped = new typename UnwrapHelper::Outer(obj, id); - SetTableIfDispatchable(m_State >= WRITING, wrapped); + SetTableIfDispatchable(m_State >= WRITING, parentObj, wrapped); AddCurrentResource(id, wrapped); diff --git a/renderdoc/driver/vulkan/vk_replay.cpp b/renderdoc/driver/vulkan/vk_replay.cpp index 02f56c56a..d14896b62 100644 --- a/renderdoc/driver/vulkan/vk_replay.cpp +++ b/renderdoc/driver/vulkan/vk_replay.cpp @@ -245,7 +245,7 @@ void VulkanReplay::OutputWindow::Create(WrappedVulkan *driver, VkDevice device, vkr = vt->CreateSwapChainWSI(Unwrap(device), &swapInfo, &swap); RDCASSERT(vkr == VK_SUCCESS); - VKMGR()->WrapResource(swap); + VKMGR()->WrapResource(Unwrap(device), swap); if(old != VK_NULL_HANDLE) vt->DestroySwapChainWSI(Unwrap(device), Unwrap(old)); @@ -263,7 +263,7 @@ void VulkanReplay::OutputWindow::Create(WrappedVulkan *driver, VkDevice device, for(size_t i=0; i < numImgs; i++) { colimg[i] = imgs[i].image; - VKMGR()->WrapResource(colimg[i]); + VKMGR()->WrapResource(Unwrap(device), colimg[i]); coltrans[i].image = Unwrap(colimg[i]); coltrans[i].oldLayout = coltrans[i].newLayout = VK_IMAGE_LAYOUT_UNDEFINED; } @@ -314,7 +314,7 @@ void VulkanReplay::OutputWindow::Create(WrappedVulkan *driver, VkDevice device, vkr = vt->CreateRenderPass(Unwrap(device), &rpinfo, &renderpass); RDCASSERT(vkr == VK_SUCCESS); - VKMGR()->WrapResource(renderpass); + VKMGR()->WrapResource(Unwrap(device), renderpass); } { @@ -329,7 +329,7 @@ void VulkanReplay::OutputWindow::Create(WrappedVulkan *driver, VkDevice device, VkResult vkr = vt->CreateDynamicViewportState(Unwrap(device), &vpInfo, &fullVP); RDCASSERT(vkr == VK_SUCCESS); - VKMGR()->WrapResource(fullVP); + VKMGR()->WrapResource(Unwrap(device), fullVP); } { @@ -346,7 +346,7 @@ void VulkanReplay::OutputWindow::Create(WrappedVulkan *driver, VkDevice device, VkResult vkr = vt->CreateImage(Unwrap(device), &imInfo, &bb); RDCASSERT(vkr == VK_SUCCESS); - VKMGR()->WrapResource(bb); + VKMGR()->WrapResource(Unwrap(device), bb); VkMemoryRequirements mrq = {0}; @@ -361,7 +361,7 @@ void VulkanReplay::OutputWindow::Create(WrappedVulkan *driver, VkDevice device, vkr = vt->AllocMemory(Unwrap(device), &allocInfo, &bbmem); RDCASSERT(vkr == VK_SUCCESS); - VKMGR()->WrapResource(bbmem); + VKMGR()->WrapResource(Unwrap(device), bbmem); vkr = vt->BindImageMemory(Unwrap(device), Unwrap(bb), Unwrap(bbmem), 0); RDCASSERT(vkr == VK_SUCCESS); @@ -379,7 +379,7 @@ void VulkanReplay::OutputWindow::Create(WrappedVulkan *driver, VkDevice device, vkr = vt->CreateAttachmentView(Unwrap(device), &info, &bbview); RDCASSERT(vkr == VK_SUCCESS); - VKMGR()->WrapResource(bbview); + VKMGR()->WrapResource(Unwrap(device), bbview); VkAttachmentBindInfo attBind = { Unwrap(bbview), VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL }; @@ -393,7 +393,7 @@ void VulkanReplay::OutputWindow::Create(WrappedVulkan *driver, VkDevice device, vkr = vt->CreateFramebuffer(Unwrap(device), &fbinfo, &fb); RDCASSERT(vkr == VK_SUCCESS); - VKMGR()->WrapResource(fb); + VKMGR()->WrapResource(Unwrap(device), fb); } if(dsimg != VK_NULL_HANDLE) @@ -406,7 +406,7 @@ void VulkanReplay::OutputWindow::Create(WrappedVulkan *driver, VkDevice device, vkr = vt->CreateAttachmentView(Unwrap(device), &info, &dsview); RDCASSERT(vkr == VK_SUCCESS); - VKMGR()->WrapResource(dsview); + VKMGR()->WrapResource(Unwrap(device), dsview); } }