From a88c5c400862fd6a8a6a6ce63c9838c1e5e4260d Mon Sep 17 00:00:00 2001 From: baldurk Date: Tue, 25 Sep 2018 12:05:40 +0100 Subject: [PATCH] Use VkBaseInStructure, official version of VkGenericStruct --- renderdoc/driver/vulkan/vk_common.cpp | 22 +++++++++---------- renderdoc/driver/vulkan/vk_common.h | 21 ++++++------------ renderdoc/driver/vulkan/vk_serialise.cpp | 6 ++--- .../driver/vulkan/wrappers/vk_cmd_funcs.cpp | 8 +++---- .../driver/vulkan/wrappers/vk_misc_funcs.cpp | 4 ++-- .../driver/vulkan/wrappers/vk_queue_funcs.cpp | 8 +++---- .../vulkan/wrappers/vk_resource_funcs.cpp | 16 +++++++------- .../driver/vulkan/wrappers/vk_sync_funcs.cpp | 8 +++---- .../driver/vulkan/wrappers/vk_wsi_funcs.cpp | 2 +- 9 files changed, 44 insertions(+), 51 deletions(-) diff --git a/renderdoc/driver/vulkan/vk_common.cpp b/renderdoc/driver/vulkan/vk_common.cpp index 1166eae1b..1b7e5f6f6 100644 --- a/renderdoc/driver/vulkan/vk_common.cpp +++ b/renderdoc/driver/vulkan/vk_common.cpp @@ -284,8 +284,8 @@ bool VkInitParams::IsSupportedVersion(uint64_t ver) // lets us just copy across a struct unmodified into some temporary memory and // append it onto a pNext chain we're building template -void CopyNextChainedStruct(byte *&tempMem, const VkGenericStruct *nextInput, - VkGenericStruct *&nextChainTail) +void CopyNextChainedStruct(byte *&tempMem, const VkBaseInStructure *nextInput, + VkBaseInStructure *&nextChainTail) { const VkStruct *instruct = (const VkStruct *)nextInput; VkStruct *outstruct = (VkStruct *)tempMem; @@ -299,15 +299,15 @@ void CopyNextChainedStruct(byte *&tempMem, const VkGenericStruct *nextInput, outstruct->pNext = NULL; // append this onto the chain - nextChainTail->pNext = (const VkGenericStruct *)outstruct; - nextChainTail = (VkGenericStruct *)outstruct; + nextChainTail->pNext = (const VkBaseInStructure *)outstruct; + nextChainTail = (VkBaseInStructure *)outstruct; } // this is similar to the above function, but for use after we've modified a struct locally // e.g. to unwrap some members or patch flags, etc. template void AppendModifiedChainedStruct(byte *&tempMem, VkStruct *outputStruct, - VkGenericStruct *&nextChainTail) + VkBaseInStructure *&nextChainTail) { tempMem = (byte *)(outputStruct + 1); @@ -315,13 +315,13 @@ void AppendModifiedChainedStruct(byte *&tempMem, VkStruct *outputStruct, outputStruct->pNext = NULL; // append this onto the chain - nextChainTail->pNext = (const VkGenericStruct *)outputStruct; - nextChainTail = (VkGenericStruct *)outputStruct; + nextChainTail->pNext = (const VkBaseInStructure *)outputStruct; + nextChainTail = (VkBaseInStructure *)outputStruct; } size_t GetNextPatchSize(const void *pNext) { - const VkGenericStruct *next = (const VkGenericStruct *)pNext; + const VkBaseInStructure *next = (const VkBaseInStructure *)pNext; size_t memSize = 0; while(next) @@ -472,7 +472,7 @@ size_t GetNextPatchSize(const void *pNext) } void UnwrapNextChain(CaptureState state, const char *structName, byte *&tempMem, - VkGenericStruct *infoStruct) + VkBaseInStructure *infoStruct) { // during capture, this walks the pNext chain and either copies structs that can be passed // straight through, or copies and modifies any with vulkan objects that need to be unwrapped. @@ -482,8 +482,8 @@ void UnwrapNextChain(CaptureState state, const char *structName, byte *&tempMem, // serialised and available for future use and for user inspection, but isn't replayed when not // necesary. - VkGenericStruct *nextChainTail = infoStruct; - const VkGenericStruct *nextInput = (const VkGenericStruct *)infoStruct->pNext; + VkBaseInStructure *nextChainTail = infoStruct; + const VkBaseInStructure *nextInput = (const VkBaseInStructure *)infoStruct->pNext; // start with an empty chain. Every call to AppendModifiedChainedStruct / CopyNextChainedStruct // pushes on a new entry, but if there's only one entry in the list and it's one we want to skip, diff --git a/renderdoc/driver/vulkan/vk_common.h b/renderdoc/driver/vulkan/vk_common.h index 84de52d85..d5b5be068 100644 --- a/renderdoc/driver/vulkan/vk_common.h +++ b/renderdoc/driver/vulkan/vk_common.h @@ -217,14 +217,7 @@ enum VkCheckExt_Max, }; -// structure for casting to easily iterate and template specialising Serialise -struct VkGenericStruct -{ - VkStructureType sType; - const VkGenericStruct *pNext; -}; - -DECLARE_REFLECTION_STRUCT(VkGenericStruct); +DECLARE_REFLECTION_STRUCT(VkBaseInStructure); // we cast to this type when serialising as a placeholder indicating that // the given flags field doesn't have any bits defined @@ -235,15 +228,15 @@ enum VkFlagWithNoBits size_t GetNextPatchSize(const void *next); void UnwrapNextChain(CaptureState state, const char *structName, byte *&tempMem, - VkGenericStruct *infoStruct); + VkBaseInStructure *infoStruct); template -const VkGenericStruct *FindNextStruct(const VkStruct *haystack, VkStructureType needle) +const VkBaseInStructure *FindNextStruct(const VkStruct *haystack, VkStructureType needle) { if(!haystack) return NULL; - const VkGenericStruct *next = (const VkGenericStruct *)haystack->pNext; + const VkBaseInStructure *next = (const VkBaseInStructure *)haystack->pNext; while(next) { if(next->sType == needle) @@ -256,19 +249,19 @@ const VkGenericStruct *FindNextStruct(const VkStruct *haystack, VkStructureType } template -VkGenericStruct *FindNextStruct(VkStruct *haystack, VkStructureType needle) +VkBaseInStructure *FindNextStruct(VkStruct *haystack, VkStructureType needle) { if(!haystack) return NULL; - VkGenericStruct *next = (VkGenericStruct *)haystack->pNext; + VkBaseInStructure *next = (VkBaseInStructure *)haystack->pNext; while(next) { if(next->sType == needle) return next; // assume non-const pNext in the original struct - next = (VkGenericStruct *)next->pNext; + next = (VkBaseInStructure *)next->pNext; } return NULL; diff --git a/renderdoc/driver/vulkan/vk_serialise.cpp b/renderdoc/driver/vulkan/vk_serialise.cpp index 187e8c5c5..619a7385f 100644 --- a/renderdoc/driver/vulkan/vk_serialise.cpp +++ b/renderdoc/driver/vulkan/vk_serialise.cpp @@ -333,7 +333,7 @@ static void SerialiseNext(SerialiserType &ser, VkStructureType &sType, const voi } // walk the pNext chain, skipping any structs we don't care about serialising. - VkGenericStruct *next = (VkGenericStruct *)pNext; + VkBaseInStructure *next = (VkBaseInStructure *)pNext; while(next) { @@ -348,7 +348,7 @@ static void SerialiseNext(SerialiserType &ser, VkStructureType &sType, const voi } // walk to the next item if we didn't serialise the current one - next = (VkGenericStruct *)next->pNext; + next = (VkBaseInStructure *)next->pNext; } // if we got here, either pNext was NULL (common) or we skipped the whole chain. Serialise a @@ -372,7 +372,7 @@ static inline void DeserialiseNext(const void *pNext) return; // walk the chain, deserialising from the tail back - const VkGenericStruct *gen = (const VkGenericStruct *)pNext; + const VkBaseInStructure *gen = (const VkBaseInStructure *)pNext; DeserialiseNext(gen->pNext); delete gen; } diff --git a/renderdoc/driver/vulkan/wrappers/vk_cmd_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_cmd_funcs.cpp index 7b5eac2d5..e8de3c52e 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_cmd_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_cmd_funcs.cpp @@ -633,7 +633,7 @@ bool WrappedVulkan::Serialise_vkBeginCommandBuffer(SerialiserType &ser, VkComman byte *tempMem = GetTempMemory(GetNextPatchSize(unwrappedBeginInfo.pNext)); UnwrapNextChain(m_State, "VkCommandBufferBeginInfo", tempMem, - (VkGenericStruct *)&unwrappedBeginInfo); + (VkBaseInStructure *)&unwrappedBeginInfo); if(IsActiveReplaying(m_State)) { @@ -823,7 +823,7 @@ VkResult WrappedVulkan::vkBeginCommandBuffer(VkCommandBuffer commandBuffer, byte *tempMem = GetTempMemory(GetNextPatchSize(beginInfo.pNext)); - UnwrapNextChain(m_State, "VkCommandBufferBeginInfo", tempMem, (VkGenericStruct *)&beginInfo); + UnwrapNextChain(m_State, "VkCommandBufferBeginInfo", tempMem, (VkBaseInStructure *)&beginInfo); VkResult ret; SERIALISE_TIME_CALL( @@ -1050,7 +1050,7 @@ bool WrappedVulkan::Serialise_vkCmdBeginRenderPass(SerialiserType &ser, VkComman byte *tempMem = GetTempMemory(GetNextPatchSize(unwrappedInfo.pNext)); - UnwrapNextChain(m_State, "VkRenderPassBeginInfo", tempMem, (VkGenericStruct *)&unwrappedInfo); + UnwrapNextChain(m_State, "VkRenderPassBeginInfo", tempMem, (VkBaseInStructure *)&unwrappedInfo); m_LastCmdBufferID = GetResourceManager()->GetOriginalID(GetResID(commandBuffer)); @@ -1129,7 +1129,7 @@ void WrappedVulkan::vkCmdBeginRenderPass(VkCommandBuffer commandBuffer, byte *tempMem = GetTempMemory(GetNextPatchSize(unwrappedInfo.pNext)); - UnwrapNextChain(m_State, "VkRenderPassBeginInfo", tempMem, (VkGenericStruct *)&unwrappedInfo); + UnwrapNextChain(m_State, "VkRenderPassBeginInfo", tempMem, (VkBaseInStructure *)&unwrappedInfo); SERIALISE_TIME_CALL( ObjDisp(commandBuffer)->CmdBeginRenderPass(Unwrap(commandBuffer), &unwrappedInfo, contents)); diff --git a/renderdoc/driver/vulkan/wrappers/vk_misc_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_misc_funcs.cpp index 5ead3991f..abb8af365 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_misc_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_misc_funcs.cpp @@ -425,7 +425,7 @@ bool WrappedVulkan::Serialise_vkCreateSampler(SerialiserType &ser, VkDevice devi byte *tempMem = GetTempMemory(GetNextPatchSize(patched.pNext)); - UnwrapNextChain(m_State, "VkSamplerCreateInfo", tempMem, (VkGenericStruct *)&patched); + UnwrapNextChain(m_State, "VkSamplerCreateInfo", tempMem, (VkBaseInStructure *)&patched); VkResult ret = ObjDisp(device)->CreateSampler(Unwrap(device), &patched, NULL, &samp); @@ -472,7 +472,7 @@ VkResult WrappedVulkan::vkCreateSampler(VkDevice device, const VkSamplerCreateIn byte *tempMem = GetTempMemory(GetNextPatchSize(info.pNext)); - UnwrapNextChain(m_State, "VkSamplerCreateInfo", tempMem, (VkGenericStruct *)&info); + UnwrapNextChain(m_State, "VkSamplerCreateInfo", tempMem, (VkBaseInStructure *)&info); VkResult ret; SERIALISE_TIME_CALL( diff --git a/renderdoc/driver/vulkan/wrappers/vk_queue_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_queue_funcs.cpp index c5c9b6eb5..63a774aa6 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_queue_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_queue_funcs.cpp @@ -230,7 +230,7 @@ bool WrappedVulkan::Serialise_vkQueueSubmit(SerialiserType &ser, VkQueue queue, tempMem += unwrapped.commandBufferCount * sizeof(VkCommandBuffer); - UnwrapNextChain(m_State, "VkSubmitInfo", tempMem, (VkGenericStruct *)&unwrapped); + UnwrapNextChain(m_State, "VkSubmitInfo", tempMem, (VkBaseInStructure *)&unwrapped); ObjDisp(queue)->QueueSubmit(Unwrap(queue), 1, &unwrapped, VK_NULL_HANDLE); @@ -398,7 +398,7 @@ bool WrappedVulkan::Serialise_vkQueueSubmit(SerialiserType &ser, VkQueue queue, byte *tempMem = GetTempMemory(GetNextPatchSize(rerecordedSubmit.pNext)); - UnwrapNextChain(m_State, "VkSubmitInfo", tempMem, (VkGenericStruct *)&rerecordedSubmit); + UnwrapNextChain(m_State, "VkSubmitInfo", tempMem, (VkBaseInStructure *)&rerecordedSubmit); rerecordedSubmit.commandBufferCount = (uint32_t)rerecordedCmds.size(); rerecordedSubmit.pCommandBuffers = &rerecordedCmds[0]; @@ -548,7 +548,7 @@ VkResult WrappedVulkan::vkQueueSubmit(VkQueue queue, uint32_t submitCount, for(uint32_t o = 0; o < unwrappedSubmits[i].signalSemaphoreCount; o++) unwrappedSignalSems[o] = Unwrap(pSubmits[i].pSignalSemaphores[o]); - UnwrapNextChain(m_State, "VkSubmitInfo", memory, (VkGenericStruct *)&unwrappedSubmits[i]); + UnwrapNextChain(m_State, "VkSubmitInfo", memory, (VkBaseInStructure *)&unwrappedSubmits[i]); } VkResult ret; @@ -924,7 +924,7 @@ VkResult WrappedVulkan::vkQueueBindSparse(VkQueue queue, uint32_t bindInfoCount, RDCASSERT(pBindInfo[i].sType == VK_STRUCTURE_TYPE_BIND_SPARSE_INFO && pBindInfo[i].pNext == NULL); unwrapped[i] = pBindInfo[i]; - UnwrapNextChain(m_State, "VkBindSparseInfo", next, (VkGenericStruct *)&unwrapped[i]); + UnwrapNextChain(m_State, "VkBindSparseInfo", next, (VkBaseInStructure *)&unwrapped[i]); // unwrap the signal semaphores into a new array VkSemaphore *signal = (VkSemaphore *)next; diff --git a/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp index a443d1900..66377de1e 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp @@ -174,7 +174,7 @@ VkBindImageMemoryInfo *WrappedVulkan::UnwrapInfos(const VkBindImageMemoryInfo *i for(uint32_t i = 0; i < count; i++) { - UnwrapNextChain(m_State, "VkBindImageMemoryInfo", tempMem, (VkGenericStruct *)&ret[i]); + UnwrapNextChain(m_State, "VkBindImageMemoryInfo", tempMem, (VkBaseInStructure *)&ret[i]); ret[i].image = Unwrap(ret[i].image); ret[i].memory = Unwrap(ret[i].memory); } @@ -262,7 +262,7 @@ bool WrappedVulkan::Serialise_vkAllocateMemory(SerialiserType &ser, VkDevice dev byte *tempMem = GetTempMemory(GetNextPatchSize(patched.pNext)); - UnwrapNextChain(m_State, "VkMemoryAllocateInfo", tempMem, (VkGenericStruct *)&patched); + UnwrapNextChain(m_State, "VkMemoryAllocateInfo", tempMem, (VkBaseInStructure *)&patched); VkResult ret = ObjDisp(device)->AllocateMemory(Unwrap(device), &patched, NULL, &mem); @@ -385,7 +385,7 @@ VkResult WrappedVulkan::vkAllocateMemory(VkDevice device, const VkMemoryAllocate byte *tempMem = GetTempMemory(GetNextPatchSize(unwrapped.pNext)); - UnwrapNextChain(m_State, "VkMemoryAllocateInfo", tempMem, (VkGenericStruct *)&unwrapped); + UnwrapNextChain(m_State, "VkMemoryAllocateInfo", tempMem, (VkBaseInStructure *)&unwrapped); VkResult ret; SERIALISE_TIME_CALL( @@ -1021,7 +1021,7 @@ bool WrappedVulkan::Serialise_vkCreateBuffer(SerialiserType &ser, VkDevice devic byte *tempMem = GetTempMemory(GetNextPatchSize(patched.pNext)); - UnwrapNextChain(m_State, "VkBufferCreateInfo", tempMem, (VkGenericStruct *)&patched); + UnwrapNextChain(m_State, "VkBufferCreateInfo", tempMem, (VkBaseInStructure *)&patched); VkResult ret = ObjDisp(device)->CreateBuffer(Unwrap(device), &patched, NULL, &buf); @@ -1064,7 +1064,7 @@ VkResult WrappedVulkan::vkCreateBuffer(VkDevice device, const VkBufferCreateInfo byte *tempMem = GetTempMemory(GetNextPatchSize(adjusted_info.pNext)); - UnwrapNextChain(m_State, "VkBufferCreateInfo", tempMem, (VkGenericStruct *)&adjusted_info); + UnwrapNextChain(m_State, "VkBufferCreateInfo", tempMem, (VkBaseInStructure *)&adjusted_info); VkResult ret; SERIALISE_TIME_CALL( @@ -1302,7 +1302,7 @@ bool WrappedVulkan::Serialise_vkCreateImage(SerialiserType &ser, VkDevice device byte *tempMem = GetTempMemory(GetNextPatchSize(patched.pNext)); - UnwrapNextChain(m_State, "VkImageCreateInfo", tempMem, (VkGenericStruct *)&patched); + UnwrapNextChain(m_State, "VkImageCreateInfo", tempMem, (VkBaseInStructure *)&patched); VkResult ret = ObjDisp(device)->CreateImage(Unwrap(device), &patched, NULL, &img); @@ -1420,7 +1420,7 @@ VkResult WrappedVulkan::vkCreateImage(VkDevice device, const VkImageCreateInfo * byte *tempMem = GetTempMemory(GetNextPatchSize(createInfo_adjusted.pNext)); - UnwrapNextChain(m_State, "VkImageCreateInfo", tempMem, (VkGenericStruct *)&createInfo_adjusted); + UnwrapNextChain(m_State, "VkImageCreateInfo", tempMem, (VkBaseInStructure *)&createInfo_adjusted); VkResult ret; SERIALISE_TIME_CALL( @@ -1451,7 +1451,7 @@ VkResult WrappedVulkan::vkCreateImage(VkDevice device, const VkImageCreateInfo * bool isExternal = false; - const VkGenericStruct *next = (const VkGenericStruct *)pCreateInfo->pNext; + const VkBaseInStructure *next = (const VkBaseInStructure *)pCreateInfo->pNext; // search for external memory image create info struct in pNext chain while(next) diff --git a/renderdoc/driver/vulkan/wrappers/vk_sync_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_sync_funcs.cpp index 0376c12d0..631c2aa2b 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_sync_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_sync_funcs.cpp @@ -115,7 +115,7 @@ bool WrappedVulkan::Serialise_vkCreateFence(SerialiserType &ser, VkDevice device byte *tempMem = GetTempMemory(GetNextPatchSize(patched.pNext)); - UnwrapNextChain(m_State, "VkFenceCreateInfo", tempMem, (VkGenericStruct *)&patched); + UnwrapNextChain(m_State, "VkFenceCreateInfo", tempMem, (VkBaseInStructure *)&patched); VkResult ret = ObjDisp(device)->CreateFence(Unwrap(device), &patched, NULL, &fence); @@ -144,7 +144,7 @@ VkResult WrappedVulkan::vkCreateFence(VkDevice device, const VkFenceCreateInfo * byte *tempMem = GetTempMemory(GetNextPatchSize(info.pNext)); - UnwrapNextChain(m_State, "VkFenceCreateInfo", tempMem, (VkGenericStruct *)&info); + UnwrapNextChain(m_State, "VkFenceCreateInfo", tempMem, (VkBaseInStructure *)&info); VkResult ret; SERIALISE_TIME_CALL(ret = ObjDisp(device)->CreateFence(Unwrap(device), &info, pAllocator, pFence)); @@ -523,7 +523,7 @@ bool WrappedVulkan::Serialise_vkCreateSemaphore(SerialiserType &ser, VkDevice de byte *tempMem = GetTempMemory(GetNextPatchSize(patched.pNext)); - UnwrapNextChain(m_State, "VkSemaphoreCreateInfo", tempMem, (VkGenericStruct *)&patched); + UnwrapNextChain(m_State, "VkSemaphoreCreateInfo", tempMem, (VkBaseInStructure *)&patched); VkResult ret = ObjDisp(device)->CreateSemaphore(Unwrap(device), &patched, NULL, &sem); @@ -573,7 +573,7 @@ VkResult WrappedVulkan::vkCreateSemaphore(VkDevice device, const VkSemaphoreCrea byte *tempMem = GetTempMemory(GetNextPatchSize(info.pNext)); - UnwrapNextChain(m_State, "VkSemaphoreCreateInfo", tempMem, (VkGenericStruct *)&info); + UnwrapNextChain(m_State, "VkSemaphoreCreateInfo", tempMem, (VkBaseInStructure *)&info); VkResult ret; SERIALISE_TIME_CALL( diff --git a/renderdoc/driver/vulkan/wrappers/vk_wsi_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_wsi_funcs.cpp index 0e7c19889..9352cbe28 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_wsi_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_wsi_funcs.cpp @@ -646,7 +646,7 @@ VkResult WrappedVulkan::vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR unwrappedInfo.pWaitSemaphores = unwrappedInfo.waitSemaphoreCount ? &unwrappedSems[0] : NULL; // Don't support any extensions for present info - const VkGenericStruct *next = (const VkGenericStruct *)pPresentInfo->pNext; + const VkBaseInStructure *next = (const VkBaseInStructure *)pPresentInfo->pNext; while(next) { // allowed (and ignored) pNext structs