diff --git a/renderdoc/driver/vulkan/imgrefs_tests.cpp b/renderdoc/driver/vulkan/imgrefs_tests.cpp index 54165f1cb..79fa31dc6 100644 --- a/renderdoc/driver/vulkan/imgrefs_tests.cpp +++ b/renderdoc/driver/vulkan/imgrefs_tests.cpp @@ -31,7 +31,6 @@ #include "vk_resources.h" #include -#include TEST_CASE("Test ImgRefs type", "[imgrefs]") { @@ -89,7 +88,7 @@ TEST_CASE("Test ImgRefs type", "[imgrefs]") ImgRefs imgRefs(ImageInfo(VK_FORMAT_D16_UNORM_S8_UINT, {100, 100, 1}, 11, 17, 1)); ImageRange range; imgRefs.Update(range, eFrameRef_Read); - std::vector expected = {eFrameRef_Read}; + rdcarray expected = {eFrameRef_Read}; CHECK(imgRefs.rangeRefs == expected); }; SECTION("update split aspect") @@ -98,7 +97,7 @@ TEST_CASE("Test ImgRefs type", "[imgrefs]") ImageRange range; range.aspectMask = VK_IMAGE_ASPECT_STENCIL_BIT; imgRefs.Update(range, eFrameRef_Read); - std::vector expected = {eFrameRef_None, eFrameRef_Read}; + rdcarray expected = {eFrameRef_None, eFrameRef_Read}; CHECK(imgRefs.rangeRefs == expected); }; SECTION("update split levels") @@ -108,10 +107,10 @@ TEST_CASE("Test ImgRefs type", "[imgrefs]") range.baseMipLevel = 1; range.levelCount = 3; imgRefs.Update(range, eFrameRef_Read); - std::vector expected = {eFrameRef_None, eFrameRef_Read, eFrameRef_Read, - eFrameRef_Read, eFrameRef_None, eFrameRef_None, - eFrameRef_None, eFrameRef_None, eFrameRef_None, - eFrameRef_None, eFrameRef_None}; + rdcarray expected = {eFrameRef_None, eFrameRef_Read, eFrameRef_Read, + eFrameRef_Read, eFrameRef_None, eFrameRef_None, + eFrameRef_None, eFrameRef_None, eFrameRef_None, + eFrameRef_None, eFrameRef_None}; CHECK(imgRefs.rangeRefs == expected); }; SECTION("update split layers") @@ -120,7 +119,7 @@ TEST_CASE("Test ImgRefs type", "[imgrefs]") ImageRange range; range.baseArrayLayer = 7; imgRefs.Update(range, eFrameRef_Read); - std::vector expected = { + rdcarray expected = { eFrameRef_None, eFrameRef_None, eFrameRef_None, eFrameRef_None, eFrameRef_None, eFrameRef_None, eFrameRef_None, eFrameRef_Read, eFrameRef_Read, eFrameRef_Read, eFrameRef_Read, eFrameRef_Read, eFrameRef_Read, eFrameRef_Read, eFrameRef_Read, @@ -137,7 +136,7 @@ TEST_CASE("Test ImgRefs type", "[imgrefs]") range1.baseMipLevel = 5; range1.levelCount = 2; imgRefs.Update(range1, eFrameRef_PartialWrite); - std::vector expected = { + rdcarray expected = { // VK_IMAGE_ASPECT_DEPTH_BIT eFrameRef_None, eFrameRef_None, eFrameRef_None, eFrameRef_None, eFrameRef_None, eFrameRef_PartialWrite, eFrameRef_PartialWrite, eFrameRef_None, eFrameRef_None, @@ -161,7 +160,7 @@ TEST_CASE("Test ImgRefs type", "[imgrefs]") range1.baseMipLevel = 2; range1.levelCount = 3; imgRefs.Update(range1, eFrameRef_PartialWrite); - std::vector expected = { + rdcarray expected = { // (Depth, level 0) eFrameRef_None, eFrameRef_Read, eFrameRef_Read, eFrameRef_None, eFrameRef_None, // (Depth, level 1) @@ -203,7 +202,7 @@ TEST_CASE("Test ImgRefs type", "[imgrefs]") ImageRange range; range.layerCount = 1; imgRefs.Update(range, eFrameRef_Read); - std::vector expected = {eFrameRef_Read}; + rdcarray expected = {eFrameRef_Read}; CHECK(imgRefs.rangeRefs == expected); } SECTION("update 3D image 3D view") @@ -213,7 +212,7 @@ TEST_CASE("Test ImgRefs type", "[imgrefs]") range.layerCount = 1; range.viewType = VK_IMAGE_VIEW_TYPE_3D; imgRefs.Update(range, eFrameRef_Read); - std::vector expected = {eFrameRef_Read}; + rdcarray expected = {eFrameRef_Read}; CHECK(imgRefs.rangeRefs == expected); } SECTION("update 3D image 2D view") @@ -223,8 +222,8 @@ TEST_CASE("Test ImgRefs type", "[imgrefs]") range.layerCount = 1; range.viewType = VK_IMAGE_VIEW_TYPE_2D; imgRefs.Update(range, eFrameRef_Read); - std::vector expected = {eFrameRef_Read, eFrameRef_None, eFrameRef_None, - eFrameRef_None, eFrameRef_None}; + rdcarray expected = {eFrameRef_Read, eFrameRef_None, eFrameRef_None, + eFrameRef_None, eFrameRef_None}; CHECK(imgRefs.rangeRefs == expected); } SECTION("update 3D image 2D array view") @@ -235,8 +234,8 @@ TEST_CASE("Test ImgRefs type", "[imgrefs]") range.layerCount = 2; range.viewType = VK_IMAGE_VIEW_TYPE_2D_ARRAY; imgRefs.Update(range, eFrameRef_Read); - std::vector expected = {eFrameRef_None, eFrameRef_Read, eFrameRef_Read, - eFrameRef_None, eFrameRef_None}; + rdcarray expected = {eFrameRef_None, eFrameRef_Read, eFrameRef_Read, + eFrameRef_None, eFrameRef_None}; CHECK(imgRefs.rangeRefs == expected); } SECTION("update 3D image 2D array view full") @@ -245,7 +244,7 @@ TEST_CASE("Test ImgRefs type", "[imgrefs]") ImageRange range; range.viewType = VK_IMAGE_VIEW_TYPE_2D_ARRAY; imgRefs.Update(range, eFrameRef_Read); - std::vector expected = {eFrameRef_Read}; + rdcarray expected = {eFrameRef_Read}; CHECK(imgRefs.rangeRefs == expected); } SECTION("update 3D image 3D view full") @@ -254,7 +253,7 @@ TEST_CASE("Test ImgRefs type", "[imgrefs]") ImageRange range; range.viewType = VK_IMAGE_VIEW_TYPE_3D; imgRefs.Update(range, eFrameRef_Read); - std::vector expected = {eFrameRef_Read}; + rdcarray expected = {eFrameRef_Read}; CHECK(imgRefs.rangeRefs == expected); } }; diff --git a/renderdoc/driver/vulkan/vk_apple.cpp b/renderdoc/driver/vulkan/vk_apple.cpp index 0158b481c..3eb35d50d 100644 --- a/renderdoc/driver/vulkan/vk_apple.cpp +++ b/renderdoc/driver/vulkan/vk_apple.cpp @@ -177,7 +177,7 @@ void *LoadVulkanLibrary() } // if not, we fall back to our embedded libvulkan and also force use of our embedded ICD. - std::string libpath; + rdcstr libpath; FileIO::GetLibraryFilename(libpath); libpath = get_dirname(libpath) + "/../plugins/MoltenVK/"; diff --git a/renderdoc/driver/vulkan/vk_bindless_feedback.cpp b/renderdoc/driver/vulkan/vk_bindless_feedback.cpp index e7edb8bfa..a4d4c343f 100644 --- a/renderdoc/driver/vulkan/vk_bindless_feedback.cpp +++ b/renderdoc/driver/vulkan/vk_bindless_feedback.cpp @@ -227,7 +227,7 @@ void AnnotateShader(const SPIRVPatchData &patchData, const char *entryName, // functions we need to patch, with the indices of which parameters have bindings coming along // with - std::map> functionPatchQueue; + std::map> functionPatchQueue; // start with the entry point, with no parameters to patch functionPatchQueue[entryID] = {}; @@ -236,7 +236,7 @@ void AnnotateShader(const SPIRVPatchData &patchData, const char *entryName, while(!functionPatchQueue.empty()) { rdcspv::Id funcId; - std::vector patchArgIndices; + rdcarray patchArgIndices; { auto it = functionPatchQueue.begin(); @@ -286,7 +286,7 @@ void AnnotateShader(const SPIRVPatchData &patchData, const char *entryName, ++it; // onto the OpFunctionParameters. First allocate IDs for all our new function parameters - std::vector patchedParamIDs; + rdcarray patchedParamIDs; for(size_t i = 0; i < patchArgIndices.size(); i++) patchedParamIDs.push_back(editor.MakeId()); @@ -342,8 +342,8 @@ void AnnotateShader(const SPIRVPatchData &patchData, const char *entryName, // check if any of the variables being passed are ones we care about. Accumulate the added // parameters - std::vector funccall; - std::vector patchArgs; + rdcarray funccall; + rdcarray patchArgs; // examine each argument to see if it's one we care about for(size_t i = 0; i < call.arguments.size(); i++) @@ -364,7 +364,7 @@ void AnnotateShader(const SPIRVPatchData &patchData, const char *entryName, { // prepend all the existing words for(size_t i = 1; i < it.size(); i++) - funccall.insert(funccall.begin() + i - 1, it.word(i)); + funccall.insert(i - 1, it.word(i)); rdcspv::Iter oldCall = it; @@ -556,7 +556,7 @@ void VulkanReplay::FetchShaderFeedback(uint32_t eventId) std::map offsetMap; { - const std::vector &descSetLayoutIds = + const rdcarray &descSetLayoutIds = creationInfo.m_PipelineLayout[pipeInfo.layout].descSetLayouts; rdcspv::Binding key; @@ -659,7 +659,7 @@ void VulkanReplay::FetchShaderFeedback(uint32_t eventId) // create pipeline layout with new descriptor set layouts { - const std::vector &push = + const rdcarray &push = creationInfo.m_PipelineLayout[pipeInfo.layout].pushRanges; VkPipelineLayoutCreateInfo pipeLayoutInfo = { diff --git a/renderdoc/driver/vulkan/vk_common.cpp b/renderdoc/driver/vulkan/vk_common.cpp index c60cf1ddf..8a8a5979f 100644 --- a/renderdoc/driver/vulkan/vk_common.cpp +++ b/renderdoc/driver/vulkan/vk_common.cpp @@ -29,7 +29,7 @@ WrappedVulkan *VkMarkerRegion::vk = NULL; -VkMarkerRegion::VkMarkerRegion(VkCommandBuffer cmd, const std::string &marker) +VkMarkerRegion::VkMarkerRegion(VkCommandBuffer cmd, const rdcstr &marker) { if(cmd == VK_NULL_HANDLE) return; @@ -38,7 +38,7 @@ VkMarkerRegion::VkMarkerRegion(VkCommandBuffer cmd, const std::string &marker) Begin(marker, cmd); } -VkMarkerRegion::VkMarkerRegion(VkQueue q, const std::string &marker) +VkMarkerRegion::VkMarkerRegion(VkQueue q, const rdcstr &marker) { if(q == VK_NULL_HANDLE) { @@ -60,7 +60,7 @@ VkMarkerRegion::~VkMarkerRegion() End(cmdbuf); } -void VkMarkerRegion::Begin(const std::string &marker, VkCommandBuffer cmd) +void VkMarkerRegion::Begin(const rdcstr &marker, VkCommandBuffer cmd) { if(cmd == VK_NULL_HANDLE) return; @@ -75,7 +75,7 @@ void VkMarkerRegion::Begin(const std::string &marker, VkCommandBuffer cmd) ObjDisp(cmd)->CmdBeginDebugUtilsLabelEXT(Unwrap(cmd), &label); } -void VkMarkerRegion::Set(const std::string &marker, VkCommandBuffer cmd) +void VkMarkerRegion::Set(const rdcstr &marker, VkCommandBuffer cmd) { if(cmd == VK_NULL_HANDLE) return; @@ -102,7 +102,7 @@ void VkMarkerRegion::End(VkCommandBuffer cmd) ObjDisp(cmd)->CmdEndDebugUtilsLabelEXT(Unwrap(cmd)); } -void VkMarkerRegion::Begin(const std::string &marker, VkQueue q) +void VkMarkerRegion::Begin(const rdcstr &marker, VkQueue q) { if(q == VK_NULL_HANDLE) { @@ -122,7 +122,7 @@ void VkMarkerRegion::Begin(const std::string &marker, VkQueue q) ObjDisp(q)->QueueBeginDebugUtilsLabelEXT(Unwrap(q), &label); } -void VkMarkerRegion::Set(const std::string &marker, VkQueue q) +void VkMarkerRegion::Set(const rdcstr &marker, VkQueue q) { if(q == VK_NULL_HANDLE) { diff --git a/renderdoc/driver/vulkan/vk_common.h b/renderdoc/driver/vulkan/vk_common.h index 2759e69db..99c7658e0 100644 --- a/renderdoc/driver/vulkan/vk_common.h +++ b/renderdoc/driver/vulkan/vk_common.h @@ -153,17 +153,17 @@ DECLARE_REFLECTION_STRUCT(VkPackedVersion); // If VK_EXT_debug_marker isn't supported, will silently do nothing struct VkMarkerRegion { - VkMarkerRegion(VkCommandBuffer cmd, const std::string &marker); - VkMarkerRegion(VkQueue q, const std::string &marker); - VkMarkerRegion(const std::string &marker) : VkMarkerRegion(VkQueue(VK_NULL_HANDLE), marker) {} + VkMarkerRegion(VkCommandBuffer cmd, const rdcstr &marker); + VkMarkerRegion(VkQueue q, const rdcstr &marker); + VkMarkerRegion(const rdcstr &marker) : VkMarkerRegion(VkQueue(VK_NULL_HANDLE), marker) {} ~VkMarkerRegion(); - static void Begin(const std::string &marker, VkCommandBuffer cmd); - static void Set(const std::string &marker, VkCommandBuffer cmd); + static void Begin(const rdcstr &marker, VkCommandBuffer cmd); + static void Set(const rdcstr &marker, VkCommandBuffer cmd); static void End(VkCommandBuffer cmd); - static void Begin(const std::string &marker, VkQueue q = VK_NULL_HANDLE); - static void Set(const std::string &marker, VkQueue q = VK_NULL_HANDLE); + static void Begin(const rdcstr &marker, VkQueue q = VK_NULL_HANDLE); + static void Set(const rdcstr &marker, VkQueue q = VK_NULL_HANDLE); static void End(VkQueue q = VK_NULL_HANDLE); VkCommandBuffer cmdbuf = VK_NULL_HANDLE; diff --git a/renderdoc/driver/vulkan/vk_core.cpp b/renderdoc/driver/vulkan/vk_core.cpp index a5238620f..3bc2bcec4 100644 --- a/renderdoc/driver/vulkan/vk_core.cpp +++ b/renderdoc/driver/vulkan/vk_core.cpp @@ -23,6 +23,7 @@ ******************************************************************************/ #include "vk_core.h" +#include #include #include "driver/ihv/amd/amd_rgp.h" #include "driver/shaders/spirv/spirv_compile.h" @@ -42,10 +43,10 @@ uint64_t VkInitParams::GetSerialiseSize() ret += AppName.size() + EngineName.size(); - for(const std::string &s : Layers) + for(const rdcstr &s : Layers) ret += 8 + s.size(); - for(const std::string &s : Extensions) + for(const rdcstr &s : Extensions) ret += 8 + s.size(); return (uint64_t)ret; @@ -237,14 +238,7 @@ VkCommandBuffer WrappedVulkan::GetNextCmd() void WrappedVulkan::RemovePendingCommandBuffer(VkCommandBuffer cmd) { - for(auto it = m_InternalCmds.pendingcmds.begin(); it != m_InternalCmds.pendingcmds.end(); ++it) - { - if(*it == cmd) - { - m_InternalCmds.pendingcmds.erase(it); - break; - } - } + m_InternalCmds.pendingcmds.removeOne(cmd); } void WrappedVulkan::AddPendingCommandBuffer(VkCommandBuffer cmd) @@ -259,7 +253,7 @@ void WrappedVulkan::SubmitCmds(VkSemaphore *unwrappedWaitSemaphores, if(m_InternalCmds.pendingcmds.empty()) return; - std::vector cmds = m_InternalCmds.pendingcmds; + rdcarray cmds = m_InternalCmds.pendingcmds; for(size_t i = 0; i < cmds.size(); i++) cmds[i] = Unwrap(cmds[i]); @@ -288,9 +282,7 @@ void WrappedVulkan::SubmitCmds(VkSemaphore *unwrappedWaitSemaphores, FlushQ(); #endif - m_InternalCmds.submittedcmds.insert(m_InternalCmds.submittedcmds.end(), - m_InternalCmds.pendingcmds.begin(), - m_InternalCmds.pendingcmds.end()); + m_InternalCmds.submittedcmds.append(m_InternalCmds.pendingcmds); m_InternalCmds.pendingcmds.clear(); } @@ -327,9 +319,7 @@ void WrappedVulkan::SubmitSemaphores() // no actual submission, just mark them as 'done with' so they will be // recycled on next flush - m_InternalCmds.submittedsems.insert(m_InternalCmds.submittedsems.end(), - m_InternalCmds.pendingsems.begin(), - m_InternalCmds.pendingsems.end()); + m_InternalCmds.submittedsems.append(m_InternalCmds.pendingsems); m_InternalCmds.pendingsems.clear(); } @@ -359,11 +349,15 @@ void WrappedVulkan::FlushQ() if(!m_InternalCmds.submittedcmds.empty()) { - m_InternalCmds.freecmds.insert(m_InternalCmds.freecmds.end(), - m_InternalCmds.submittedcmds.begin(), - m_InternalCmds.submittedcmds.end()); + m_InternalCmds.freecmds.append(m_InternalCmds.submittedcmds); m_InternalCmds.submittedcmds.clear(); } + + if(!m_InternalCmds.submittedsems.empty()) + { + m_InternalCmds.freesems.append(m_InternalCmds.submittedsems); + m_InternalCmds.submittedsems.clear(); + } } VkCommandBuffer WrappedVulkan::GetExtQueueCmd(uint32_t queueFamilyIdx) @@ -1133,8 +1127,8 @@ bool WrappedVulkan::IsSupportedExtension(const char *extName) return false; } -void WrappedVulkan::FilterToSupportedExtensions(std::vector &exts, - std::vector &filtered) +void WrappedVulkan::FilterToSupportedExtensions(rdcarray &exts, + rdcarray &filtered) { // now we can step through both lists with two pointers, // instead of doing an O(N*M) lookup searching through each @@ -1184,7 +1178,7 @@ VkResult WrappedVulkan::FilterDeviceExtensionProperties(VkPhysicalDevice physDev if(vkr != VK_SUCCESS) return vkr; - std::vector exts(numExts); + rdcarray exts(numExts); vkr = ObjDisp(physDev)->EnumerateDeviceExtensionProperties(Unwrap(physDev), pLayerName, &numExts, &exts[0]); @@ -1196,7 +1190,7 @@ VkResult WrappedVulkan::FilterDeviceExtensionProperties(VkPhysicalDevice physDev // sort the reported extensions std::sort(exts.begin(), exts.end()); - std::vector filtered; + rdcarray filtered; filtered.reserve(exts.size()); FilterToSupportedExtensions(exts, filtered); @@ -1205,9 +1199,8 @@ VkResult WrappedVulkan::FilterDeviceExtensionProperties(VkPhysicalDevice physDev InstanceDeviceInfo *instDevInfo = GetRecord(m_Instance)->instDevInfo; // extensions with conditional support - for(auto it = filtered.begin(); it != filtered.end();) - { - if(!strcmp(it->extensionName, VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME)) + filtered.removeIf([instDevInfo, physDev](const VkExtensionProperties &ext) { + if(!strcmp(ext.extensionName, VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME)) { // require GPDP2 if(instDevInfo->ext_KHR_get_physical_device_properties2) @@ -1220,9 +1213,8 @@ VkResult WrappedVulkan::FilterDeviceExtensionProperties(VkPhysicalDevice physDev if(fragmentDensityFeatures.fragmentDensityMapNonSubsampledImages) { - // supported - ++it; - continue; + // supported, don't remove + return false; } else { @@ -1234,11 +1226,10 @@ VkResult WrappedVulkan::FilterDeviceExtensionProperties(VkPhysicalDevice physDev } // if it wasn't supported, remove the extension - it = filtered.erase(it); - continue; + return true; } - if(!strcmp(it->extensionName, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME)) + if(!strcmp(ext.extensionName, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME)) { // require GPDP2 if(instDevInfo->ext_KHR_get_physical_device_properties2) @@ -1251,9 +1242,8 @@ VkResult WrappedVulkan::FilterDeviceExtensionProperties(VkPhysicalDevice physDev if(bufaddr.bufferDeviceAddressCaptureReplay) { - // supported - ++it; - continue; + // supported, don't remove + return false; } else { @@ -1264,11 +1254,10 @@ VkResult WrappedVulkan::FilterDeviceExtensionProperties(VkPhysicalDevice physDev } // if it wasn't supported, remove the extension - it = filtered.erase(it); - continue; + return true; } - if(!strcmp(it->extensionName, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME)) + if(!strcmp(ext.extensionName, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME)) { // require GPDP2 if(instDevInfo->ext_KHR_get_physical_device_properties2) @@ -1281,9 +1270,8 @@ VkResult WrappedVulkan::FilterDeviceExtensionProperties(VkPhysicalDevice physDev if(bufaddr.bufferDeviceAddressCaptureReplay) { - // supported - ++it; - continue; + // supported, don't remove + return false; } else { @@ -1294,18 +1282,17 @@ VkResult WrappedVulkan::FilterDeviceExtensionProperties(VkPhysicalDevice physDev } // if it wasn't supported, remove the extension - it = filtered.erase(it); - continue; + return true; } - ++it; - } + // not an extension with conditional support, don't remove + return false; + }); // now we can add extensions that we provide ourselves (note this isn't sorted, but we // don't have to sort the results, the sorting was just so we could filter optimally). - filtered.insert( - filtered.end(), &renderdocProvidedDeviceExtensions[0], - &renderdocProvidedDeviceExtensions[0] + ARRAY_COUNT(renderdocProvidedDeviceExtensions)); + filtered.append(&renderdocProvidedDeviceExtensions[0], + ARRAY_COUNT(renderdocProvidedDeviceExtensions)); } return FillPropertyCountAndList(&filtered[0], (uint32_t)filtered.size(), pPropertyCount, @@ -1325,7 +1312,7 @@ VkResult WrappedVulkan::FilterInstanceExtensionProperties( if(vkr != VK_SUCCESS) return vkr; - std::vector exts(numExts); + rdcarray exts(numExts); vkr = pChain->CallDown(pLayerName, &numExts, &exts[0]); if(vkr != VK_SUCCESS) @@ -1336,7 +1323,7 @@ VkResult WrappedVulkan::FilterInstanceExtensionProperties( // sort the reported extensions std::sort(exts.begin(), exts.end()); - std::vector filtered; + rdcarray filtered; filtered.reserve(exts.size()); FilterToSupportedExtensions(exts, filtered); @@ -1345,9 +1332,8 @@ VkResult WrappedVulkan::FilterInstanceExtensionProperties( { // now we can add extensions that we provide ourselves (note this isn't sorted, but we // don't have to sort the results, the sorting was just so we could filter optimally). - filtered.insert( - filtered.end(), &renderdocProvidedInstanceExtensions[0], - &renderdocProvidedInstanceExtensions[0] + ARRAY_COUNT(renderdocProvidedInstanceExtensions)); + filtered.append(&renderdocProvidedInstanceExtensions[0], + ARRAY_COUNT(renderdocProvidedInstanceExtensions)); } return FillPropertyCountAndList(&filtered[0], (uint32_t)filtered.size(), pPropertyCount, @@ -1410,7 +1396,7 @@ void WrappedVulkan::FirstFrame() template bool WrappedVulkan::Serialise_BeginCaptureFrame(SerialiserType &ser) { - std::vector imgBarriers; + rdcarray imgBarriers; { SCOPED_LOCK(m_ImageLayoutsLock); // not needed on replay, but harmless also @@ -2909,7 +2895,7 @@ bool WrappedVulkan::ProcessChunk(ReadSerialiser &ser, VulkanChunk chunk) return Serialise_vkCmdSetDiscardRectangleEXT(ser, VK_NULL_HANDLE, 0, 0, NULL); case VulkanChunk::DeviceMemoryRefs: { - std::vector data; + rdcarray data; return GetResourceManager()->Serialise_DeviceMemoryRefs(ser, data); } case VulkanChunk::vkResetQueryPoolEXT: @@ -2918,7 +2904,7 @@ bool WrappedVulkan::ProcessChunk(ReadSerialiser &ser, VulkanChunk chunk) return Serialise_vkCmdSetLineStippleEXT(ser, VK_NULL_HANDLE, 0, 0); case VulkanChunk::ImageRefs: { - std::vector data; + rdcarray data; return GetResourceManager()->Serialise_ImageRefs(ser, data); } case VulkanChunk::vkQueuePresentKHR: @@ -3064,7 +3050,7 @@ void WrappedVulkan::ReplayLog(uint32_t startEventID, uint32_t endEventID, Replay // something). We do a 'safe' transition from current layout to what's expected in the // attachment, which should always be a nop or overriding an UNDEFINED transition. Then we put // it back again afterwards. - std::vector loadRPImgBarriers; + rdcarray loadRPImgBarriers; // we'll need our own command buffer if we're replaying just a subsection // of events within a single command buffer record - always if it's only @@ -3174,7 +3160,7 @@ void WrappedVulkan::ReplayLog(uint32_t startEventID, uint32_t endEventID, Replay template void WrappedVulkan::Serialise_DebugMessages(SerialiserType &ser) { - std::vector DebugMessages; + rdcarray DebugMessages; if(ser.IsWriting()) { @@ -3214,10 +3200,10 @@ void WrappedVulkan::ProcessDebugMessage(DebugMessage &msg) { if(strstr(msg.description.c_str(), "0x")) { - std::string desc = msg.description; + rdcstr desc = msg.description; - size_t offs = desc.find("0x"); - while(offs != std::string::npos) + int32_t offs = desc.find("0x"); + while(offs >= 0) { // if we're on a word boundary if(offs == 0 || !isalnum(desc[offs - 1])) @@ -3275,13 +3261,13 @@ void WrappedVulkan::ProcessDebugMessage(DebugMessage &msg) if(id != ResourceId()) { - std::string idstr = ToStr(id); + rdcstr idstr = ToStr(id); desc.erase(offs, end - offs); desc.insert(offs, idstr.c_str()); - offs = desc.find("0x", offs + idstr.length()); + offs = desc.find("0x", offs + idstr.count()); continue; } } @@ -3295,15 +3281,14 @@ void WrappedVulkan::ProcessDebugMessage(DebugMessage &msg) } } -std::vector WrappedVulkan::GetDebugMessages() +rdcarray WrappedVulkan::GetDebugMessages() { - std::vector ret; + rdcarray ret; ret.swap(m_DebugMessages); return ret; } -void WrappedVulkan::AddDebugMessage(MessageCategory c, MessageSeverity sv, MessageSource src, - std::string d) +void WrappedVulkan::AddDebugMessage(MessageCategory c, MessageSeverity sv, MessageSource src, rdcstr d) { DebugMessage msg; msg.eventId = 0; @@ -3448,7 +3433,7 @@ VkBool32 VKAPI_PTR WrappedVulkan::DebugUtilsCallbackStatic( if(messageTypes & VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT) category = MessageCategory::Performance; - std::string msgid; + rdcstr msgid; const char *pMessageId = pCallbackData->pMessageIdName; int messageCode = pCallbackData->messageIdNumber; @@ -3593,11 +3578,11 @@ void WrappedVulkan::AddDrawcall(const DrawcallDescription &d, bool hasEvents) if(fb != ResourceId() && rp != ResourceId()) { - std::vector &atts = m_BakedCmdBufferInfo[m_LastCmdBufferID].state.fbattachments; + rdcarray &atts = m_BakedCmdBufferInfo[m_LastCmdBufferID].state.fbattachments; RDCASSERT(sp < m_CreationInfo.m_RenderPass[rp].subpasses.size()); - std::vector &colAtt = m_CreationInfo.m_RenderPass[rp].subpasses[sp].colorAttachments; + rdcarray &colAtt = m_CreationInfo.m_RenderPass[rp].subpasses[sp].colorAttachments; int32_t dsAtt = m_CreationInfo.m_RenderPass[rp].subpasses[sp].depthstencilAttachment; RDCASSERT(colAtt.size() <= ARRAY_COUNT(draw.outputs)); @@ -3633,9 +3618,9 @@ void WrappedVulkan::AddDrawcall(const DrawcallDescription &d, bool hasEvents) if(hasEvents) { - std::vector &srcEvents = m_LastCmdBufferID != ResourceId() - ? m_BakedCmdBufferInfo[m_LastCmdBufferID].curEvents - : m_RootEvents; + rdcarray &srcEvents = m_LastCmdBufferID != ResourceId() + ? m_BakedCmdBufferInfo[m_LastCmdBufferID].curEvents + : m_RootEvents; draw.events = srcEvents; srcEvents.clear(); @@ -3652,15 +3637,16 @@ void WrappedVulkan::AddDrawcall(const DrawcallDescription &d, bool hasEvents) if(m_LastCmdBufferID != ResourceId()) AddUsage(node, m_BakedCmdBufferInfo[m_LastCmdBufferID].debugMessages); - node.children.insert(node.children.begin(), draw.children.begin(), draw.children.end()); + node.children.reserve(draw.children.size()); + for(const DrawcallDescription &child : draw.children) + node.children.push_back(VulkanDrawcallTreeNode(child)); GetDrawcallStack().back()->children.push_back(node); } else RDCERR("Somehow lost drawcall stack!"); } -void WrappedVulkan::AddUsage(VulkanDrawcallTreeNode &drawNode, - std::vector &debugMessages) +void WrappedVulkan::AddUsage(VulkanDrawcallTreeNode &drawNode, rdcarray &debugMessages) { DrawcallDescription &d = drawNode.draw; @@ -3711,7 +3697,7 @@ void WrappedVulkan::AddUsage(VulkanDrawcallTreeNode &drawNode, ResourceId origShad = GetResourceManager()->GetOriginalID(sh.module); // 5 is the compute shader's index (VS, TCS, TES, GS, FS, CS) - const std::vector &descSets = + const rdcarray &descSets = (shad == 5 ? state.computeDescSets : state.graphicsDescSets); RDCASSERT(sh.mapping); @@ -3846,7 +3832,7 @@ void WrappedVulkan::AddUsage(VulkanDrawcallTreeNode &drawNode, void WrappedVulkan::AddFramebufferUsage(VulkanDrawcallTreeNode &drawNode, ResourceId renderPass, ResourceId framebuffer, uint32_t subpass, - const std::vector &fbattachments) + const rdcarray &fbattachments) { VulkanCreationInfo &c = m_CreationInfo; uint32_t e = drawNode.draw.eventId; @@ -3898,7 +3884,7 @@ void WrappedVulkan::AddFramebufferUsage(VulkanDrawcallTreeNode &drawNode, Resour void WrappedVulkan::AddFramebufferUsageAllChildren(VulkanDrawcallTreeNode &drawNode, ResourceId renderPass, ResourceId framebuffer, uint32_t subpass, - const std::vector &fbattachments) + const rdcarray &fbattachments) { for(VulkanDrawcallTreeNode &c : drawNode.children) AddFramebufferUsageAllChildren(c, renderPass, framebuffer, subpass, fbattachments); @@ -3925,10 +3911,7 @@ void WrappedVulkan::AddEvent() if(m_LastCmdBufferID != ResourceId()) { m_BakedCmdBufferInfo[m_LastCmdBufferID].curEvents.push_back(apievent); - - std::vector &msgs = m_BakedCmdBufferInfo[m_LastCmdBufferID].debugMessages; - - msgs.insert(msgs.end(), m_EventMessages.begin(), m_EventMessages.end()); + m_BakedCmdBufferInfo[m_LastCmdBufferID].debugMessages.append(m_EventMessages); } else { @@ -3936,7 +3919,7 @@ void WrappedVulkan::AddEvent() m_Events.resize(apievent.eventId + 1); m_Events[apievent.eventId] = apievent; - m_DebugMessages.insert(m_DebugMessages.end(), m_EventMessages.begin(), m_EventMessages.end()); + m_DebugMessages.append(m_EventMessages); } m_EventMessages.clear(); @@ -3970,17 +3953,14 @@ const DrawcallDescription *WrappedVulkan::GetDrawcall(uint32_t eventId) TEST_CASE("Validate supported extensions list", "[vulkan]") { - std::vector unsorted; - unsorted.insert(unsorted.begin(), &supportedExtensions[0], - &supportedExtensions[ARRAY_COUNT(supportedExtensions)]); - - std::vector sorted = unsorted; + rdcarray unsorted(&supportedExtensions[0], ARRAY_COUNT(supportedExtensions)); + rdcarray sorted = unsorted; std::sort(sorted.begin(), sorted.end()); for(size_t i = 0; i < unsorted.size(); i++) { - CHECK(std::string(unsorted[i].extensionName) == std::string(sorted[i].extensionName)); + CHECK(rdcstr(unsorted[i].extensionName) == rdcstr(sorted[i].extensionName)); } } diff --git a/renderdoc/driver/vulkan/vk_core.h b/renderdoc/driver/vulkan/vk_core.h index 010b7494b..16050d491 100644 --- a/renderdoc/driver/vulkan/vk_core.h +++ b/renderdoc/driver/vulkan/vk_core.h @@ -24,7 +24,6 @@ #pragma once -#include #include "common/timing.h" #include "serialise/serialiser.h" #include "vk_common.h" @@ -42,12 +41,12 @@ struct VkInitParams { void Set(const VkInstanceCreateInfo *pCreateInfo, ResourceId inst); - std::string AppName, EngineName; + rdcstr AppName, EngineName; uint32_t AppVersion = 0, EngineVersion = 0; VkPackedVersion APIVersion; - std::vector Layers; - std::vector Extensions; + rdcarray Layers; + rdcarray Extensions; ResourceId InstanceID; // remember to update this function if you add more members @@ -121,13 +120,13 @@ struct VulkanDrawcallTreeNode VulkanDrawcallTreeNode() {} explicit VulkanDrawcallTreeNode(const DrawcallDescription &d) : draw(d) {} DrawcallDescription draw; - std::vector children; + rdcarray children; VkIndirectPatchData indirectPatch; - std::vector> resourceUsage; + rdcarray> resourceUsage; - std::vector executedCmds; + rdcarray executedCmds; VulkanDrawcallTreeNode &operator=(const DrawcallDescription &d) { @@ -168,9 +167,9 @@ struct VulkanDrawcallTreeNode children[i].UpdateIDs(baseEventID, baseDrawID); } - std::vector Bake() + rdcarray Bake() { - std::vector ret; + rdcarray ret; if(children.empty()) return ret; @@ -251,7 +250,7 @@ private: ScopedDebugMessageSink(WrappedVulkan *driver); ~ScopedDebugMessageSink(); - std::vector msgs; + rdcarray msgs; WrappedVulkan *m_pDriver; }; @@ -265,18 +264,18 @@ private: // the messages retrieved for the current event (filled in Serialise_vk...() and read in // AddEvent()) - std::vector m_EventMessages; + rdcarray m_EventMessages; // list of all debug messages by EID in the frame - std::vector m_DebugMessages; + rdcarray m_DebugMessages; template void Serialise_DebugMessages(SerialiserType &ser); void ProcessDebugMessage(DebugMessage &DebugMessages); - std::vector GetDebugMessages(); + rdcarray GetDebugMessages(); void AddDebugMessage(DebugMessage msg); - void AddDebugMessage(MessageCategory c, MessageSeverity sv, MessageSource src, std::string d); + void AddDebugMessage(MessageCategory c, MessageSeverity sv, MessageSource src, rdcstr d); CaptureState m_State; bool m_AppControlledCapture = false; @@ -287,7 +286,7 @@ private: uint64_t threadSerialiserTLSSlot; Threading::CriticalSection m_ThreadSerialisersLock; - std::vector m_ThreadSerialisers; + rdcarray m_ThreadSerialisers; uint64_t tempMemoryTLSSlot; struct TempMem @@ -297,7 +296,7 @@ private: size_t size; }; Threading::CriticalSection m_ThreadTempMemLock; - std::vector m_ThreadTempMem; + rdcarray m_ThreadTempMem; VulkanReplay *m_Replay; ReplayOptions m_ReplayOptions; @@ -319,7 +318,7 @@ private: // by queue submit order anyway, so it's OK to lose the record // order). Threading::CriticalSection m_CmdBufferRecordsLock; - std::vector m_CmdBufferRecords; + rdcarray m_CmdBufferRecords; VulkanResourceManager *m_ResourceManager = NULL; VulkanDebugManager *m_DebugManager = NULL; @@ -349,11 +348,11 @@ private: uint32_t HandlePreCallback(VkCommandBuffer commandBuffer, DrawFlags type = DrawFlags::Drawcall, uint32_t multiDrawOffset = 0); - std::vector m_SupportedWindowSystems; + rdcarray m_SupportedWindowSystems; uint32_t m_FrameCounter = 0; - std::vector m_CapturedFrames; + rdcarray m_CapturedFrames; rdcarray m_Drawcalls; struct PhysicalDeviceData @@ -412,19 +411,19 @@ private: // the physical devices. At capture time this is trivial, just the enumerated devices. // At replay time this is re-ordered from the real list to try and match - std::vector m_PhysicalDevices; + rdcarray m_PhysicalDevices; // replay only, information we need for remapping. The original vector keeps information about the // physical devices used at capture time, and the replay vector contains the real unmodified list // of physical devices at replay time. - std::vector m_OriginalPhysicalDevices; - std::vector m_ReplayPhysicalDevices; - std::vector m_ReplayPhysicalDevicesUsed; + rdcarray m_OriginalPhysicalDevices; + rdcarray m_ReplayPhysicalDevices; + rdcarray m_ReplayPhysicalDevicesUsed; // the queue families (an array of count for each) for the created device - std::vector m_QueueFamilies; - std::vector m_QueueFamilyCounts; - std::vector m_QueueFamilyIndices; + rdcarray m_QueueFamilies; + rdcarray m_QueueFamilyCounts; + rdcarray m_QueueFamilyIndices; // a small amount of helper code during capture for handling resources on different queues in init // states @@ -434,7 +433,7 @@ private: VkCommandPool pool = VK_NULL_HANDLE; VkCommandBuffer buffer = VK_NULL_HANDLE; }; - std::vector m_ExternalQueues; + rdcarray m_ExternalQueues; VkCommandBuffer GetExtQueueCmd(uint32_t queueFamilyIdx); void SubmitAndFlushExtQueue(uint32_t queueFamilyIdx); @@ -448,7 +447,7 @@ private: // for each queue family in the original captured physical device, we have a remapping vector. // Each element in the vector is an available queue in that family, and the uint64 is packed as // (targetQueueFamily << 32) | (targetQueueIndex) - std::vector m_QueueRemapping[16]; + rdcarray m_QueueRemapping[16]; void WrapAndProcessCreatedSwapchain(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo, VkSwapchainKHR *pSwapChain); @@ -474,18 +473,18 @@ private: VkCommandPool cmdpool; // the command pool used for allocating our own command buffers - std::vector freecmds; + rdcarray freecmds; // -> GetNextCmd() -> - std::vector pendingcmds; + rdcarray pendingcmds; // -> SubmitCmds() -> - std::vector submittedcmds; + rdcarray submittedcmds; // -> FlushQ() ------back to freecmds------^ - std::vector freesems; + rdcarray freesems; // -> GetNextSemaphore() -> - std::vector pendingsems; + rdcarray pendingsems; // -> SubmitSemaphores() -> - std::vector submittedsems; + rdcarray submittedsems; // -> FlushQ() ----back to freesems-------^ } m_InternalCmds; @@ -494,7 +493,7 @@ private: // Each memory scope gets a separate vector of allocation objects. The vector contains the list of // all 'base' allocations. The offset is used to indicate the current offset, and the size is the // total size, thus the free space can be determined with size - offset. - std::vector m_MemoryBlocks[arraydim()]; + rdcarray m_MemoryBlocks[arraydim()]; // Per memory scope, the size of the next allocation. This allows us to balance number of memory // allocation objects with size by incrementally allocating larger blocks. @@ -509,8 +508,8 @@ private: MemoryAllocation AllocateMemoryForResource(bool buffer, VkMemoryRequirements mrq, MemoryScope scope, MemoryType type); - std::vector m_CleanupEvents; - std::vector m_PersistentEvents; + rdcarray m_CleanupEvents; + rdcarray m_PersistentEvents; const VkFormatProperties &GetFormatProperties(VkFormat f) { @@ -531,11 +530,11 @@ private: { } ~BakedCmdBufferInfo() { SAFE_DELETE(draw); } - std::vector curEvents; - std::vector debugMessages; - std::list drawStack; + rdcarray curEvents; + rdcarray debugMessages; + rdcarray drawStack; - std::vector indirectCopies; + rdcarray indirectCopies; uint32_t beginChunk = 0; uint32_t endChunk = 0; @@ -547,7 +546,7 @@ private: int markerCount; - std::vector> resourceUsage; + rdcarray> resourceUsage; struct CmdBufferState { @@ -556,24 +555,24 @@ private: struct DescriptorAndOffsets { ResourceId descSet; - std::vector offsets; + rdcarray offsets; }; - std::vector graphicsDescSets, computeDescSets; + rdcarray graphicsDescSets, computeDescSets; uint32_t idxWidth = 0; ResourceId ibuffer; - std::vector vbuffers; - std::vector xfbbuffers; + rdcarray vbuffers; + rdcarray xfbbuffers; uint32_t xfbfirst = 0; uint32_t xfbcount = 0; ResourceId renderPass; ResourceId framebuffer; - std::vector fbattachments; + rdcarray fbattachments; uint32_t subpass = 0; } state; - std::vector> imgbarriers; + rdcarray> imgbarriers; ResourceId pushDescriptorID[2][64]; @@ -606,7 +605,7 @@ private: return eventId < o.eventId; } }; - std::vector m_DrawcallUses; + rdcarray m_DrawcallUses; enum PartialReplayIndex { @@ -649,7 +648,7 @@ private: // event IDs, since they could be submitted multiple times in the frame and we don't want to // rebase all of them each time. // Map from bakeID -> vector - std::map> cmdBufferSubmits; + std::map> cmdBufferSubmits; // identifies the baked ID of the command buffer that's actually partial at each level. ResourceId partialParent; @@ -676,7 +675,7 @@ private: // we store the list here, since we need to keep all command buffers until the whole replay is // finished, but if a command buffer is re-recorded multiple times it would be overwritten in the // above map - std::vector> m_RerecordCmdList; + rdcarray> m_RerecordCmdList; // There is only a state while currently partially replaying, it's // undefined/empty otherwise. @@ -697,7 +696,7 @@ private: DescriptorSetInfo &operator=(const DescriptorSetInfo &) = default; ~DescriptorSetInfo() { clear(); } ResourceId layout; - std::vector currentBindings; + rdcarray currentBindings; bool push; void clear() @@ -715,7 +714,7 @@ private: ResourceId m_LastSwap; // holds the current list of coherent mapped memory. Locked against concurrent use - std::vector m_CoherentMaps; + rdcarray m_CoherentMaps; Threading::CriticalSection m_CoherentMapsLock; rdcarray m_ForcedReferences; @@ -769,7 +768,7 @@ private: // immutable creation data VulkanCreationInfo m_CreationInfo; - std::map> m_ResourceUses; + std::map> m_ResourceUses; std::map m_EventFlags; // returns thread-local temporary memory @@ -817,8 +816,8 @@ private: VkDeviceSize memoryOffset, VkMemoryRequirements mrq); void AddImplicitResolveResourceUsage(uint32_t subpass = 0); - std::vector GetImplicitRenderPassBarriers(uint32_t subpass = 0); - std::string MakeRenderPassOpString(bool store); + rdcarray GetImplicitRenderPassBarriers(uint32_t subpass = 0); + rdcstr MakeRenderPassOpString(bool store); bool IsDrawInRenderPass(); @@ -834,7 +833,7 @@ private: template bool Serialise_SetShaderDebugPath(SerialiserType &ser, VkShaderModule ShaderObject, - std::string DebugPath); + rdcstr DebugPath); // replay @@ -853,7 +852,7 @@ private: void ApplyInitialContents(); - std::vector m_RootEvents, m_Events; + rdcarray m_RootEvents, m_Events; bool m_AddedDrawcall; uint64_t m_CurChunkOffset; @@ -871,16 +870,16 @@ private: bool m_LayersEnabled[VkCheckLayer_Max] = {}; // in vk_.cpp - void AddRequiredExtensions(bool instance, std::vector &extensionList, - const std::set &supportedExtensions); + void AddRequiredExtensions(bool instance, rdcarray &extensionList, + const std::set &supportedExtensions); bool PatchIndirectDraw(VkIndirectPatchType type, DrawcallDescription &draw, byte *&argptr, byte *argend); void InsertDrawsAndRefreshIDs(BakedCmdBufferInfo &cmdBufInfo); - std::list m_DrawcallStack; + rdcarray m_DrawcallStack; - std::list &GetDrawcallStack() + rdcarray &GetDrawcallStack() { if(m_LastCmdBufferID != ResourceId()) return m_BakedCmdBufferInfo[m_LastCmdBufferID].drawStack; @@ -895,13 +894,13 @@ private: void AddDrawcall(const DrawcallDescription &d, bool hasEvents); void AddEvent(); - void AddUsage(VulkanDrawcallTreeNode &drawNode, std::vector &debugMessages); + void AddUsage(VulkanDrawcallTreeNode &drawNode, rdcarray &debugMessages); void AddFramebufferUsage(VulkanDrawcallTreeNode &drawNode, ResourceId renderPass, ResourceId framebuffer, uint32_t subpass, - const std::vector &fbattachments); + const rdcarray &fbattachments); void AddFramebufferUsageAllChildren(VulkanDrawcallTreeNode &drawNode, ResourceId renderPass, ResourceId framebuffer, uint32_t subpass, - const std::vector &fbattachments); + const rdcarray &fbattachments); // no copy semantics WrappedVulkan(const WrappedVulkan &); @@ -923,9 +922,9 @@ private: void AddFrameTerminator(uint64_t queueMarkerTag); void ImageInitializationBarriers(ResourceId id, WrappedVkRes *live, InitPolicy policy, bool initialized, const ImgRefs *imgRefs, - std::vector &setupBarriers, - std::vector &cleanupBarriers) const; - void SubmitExtQBarriers(const std::map> &extQBarriers); + rdcarray &setupBarriers, + rdcarray &cleanupBarriers) const; + void SubmitExtQBarriers(const std::map> &extQBarriers); public: WrappedVulkan(); @@ -979,7 +978,7 @@ public: uint32_t GetGPULocalMemoryIndex(uint32_t resourceRequiredBitmask); EventFlags GetEventFlags(uint32_t eid) { return m_EventFlags[eid]; } - std::vector GetUsage(ResourceId id) { return m_ResourceUses[id]; } + rdcarray GetUsage(ResourceId id) { return m_ResourceUses[id]; } // return the pre-selected device and queue VkDevice GetDev() { @@ -1015,8 +1014,8 @@ public: void SetDrawcallCB(VulkanDrawcallCallback *cb) { m_DrawcallCallback = cb; } void SetSubmitChain(void *submitChain) { m_SubmitChain = submitChain; } static bool IsSupportedExtension(const char *extName); - static void FilterToSupportedExtensions(std::vector &exts, - std::vector &filtered); + static void FilterToSupportedExtensions(rdcarray &exts, + rdcarray &filtered); VkResult FilterDeviceExtensionProperties(VkPhysicalDevice physDev, const char *pLayerName, uint32_t *pPropertyCount, VkExtensionProperties *pProperties); diff --git a/renderdoc/driver/vulkan/vk_counters.cpp b/renderdoc/driver/vulkan/vk_counters.cpp index 54888eb48..1a6ad8d60 100644 --- a/renderdoc/driver/vulkan/vk_counters.cpp +++ b/renderdoc/driver/vulkan/vk_counters.cpp @@ -496,11 +496,11 @@ rdcarray VulkanReplay::FetchCountersAMD(const rdcarraym_AliasEvents[i].first; // find the result we're aliasing - auto it = std::find(ret.begin(), ret.end(), search); - if(it != ret.end()) + int32_t idx = ret.indexOf(search); + if(idx >= 0) { // duplicate the result and append - CounterResult aliased = *it; + CounterResult aliased = ret[idx]; aliased.eventId = m_pAMDDrawCallback->m_AliasEvents[i].second; ret.push_back(aliased); } @@ -677,11 +677,11 @@ rdcarray VulkanReplay::FetchCountersKHR(const rdcarray= 0) { // duplicate the result and append - CounterResult aliased = *it; + CounterResult aliased = ret[idx]; aliased.eventId = cb.m_AliasEvents[i].second; ret.push_back(aliased); } @@ -981,11 +981,11 @@ rdcarray VulkanReplay::FetchCounters(const rdcarray & search.eventId = cb.m_AliasEvents[i].first; // find the result we're aliasing - auto it = std::find(ret.begin(), ret.end(), search); - if(it != ret.end()) + int32_t idx = ret.indexOf(search); + if(idx >= 0) { // duplicate the result and append - CounterResult aliased = *it; + CounterResult aliased = ret[idx]; aliased.eventId = cb.m_AliasEvents[i].second; ret.push_back(aliased); } diff --git a/renderdoc/driver/vulkan/vk_debug.cpp b/renderdoc/driver/vulkan/vk_debug.cpp index cbdbf9d4c..d1bd77fcf 100644 --- a/renderdoc/driver/vulkan/vk_debug.cpp +++ b/renderdoc/driver/vulkan/vk_debug.cpp @@ -2549,7 +2549,7 @@ void VulkanReplay::HistogramMinMax::Init(WrappedVulkan *driver, VkDescriptorPool shaderCache->SetCaching(true); - std::string glsl; + rdcstr glsl; CREATE_OBJECT(m_HistogramDescSetLayout, { @@ -2591,13 +2591,13 @@ void VulkanReplay::HistogramMinMax::Init(WrappedVulkan *driver, VkDescriptorPool SPIRVBlob minmaxtile = NULL; SPIRVBlob minmaxresult = NULL; SPIRVBlob histogram = NULL; - std::string err; + rdcstr err; - std::string defines = shaderCache->GetGlobalDefines(); + rdcstr defines = shaderCache->GetGlobalDefines(); - defines += std::string("#define SHADER_RESTYPE ") + ToStr(t) + "\n"; - defines += std::string("#define UINT_TEX ") + (f == 1 ? "1" : "0") + "\n"; - defines += std::string("#define SINT_TEX ") + (f == 2 ? "1" : "0") + "\n"; + defines += rdcstr("#define SHADER_RESTYPE ") + ToStr(t) + "\n"; + defines += rdcstr("#define UINT_TEX ") + (f == 1 ? "1" : "0") + "\n"; + defines += rdcstr("#define SINT_TEX ") + (f == 2 ? "1" : "0") + "\n"; glsl = GenerateGLSLShader(GetEmbeddedResource(glsl_histogram_comp), ShaderType::Vulkan, 430, defines); diff --git a/renderdoc/driver/vulkan/vk_info.cpp b/renderdoc/driver/vulkan/vk_info.cpp index 392fbfb11..09e0d57b6 100644 --- a/renderdoc/driver/vulkan/vk_info.cpp +++ b/renderdoc/driver/vulkan/vk_info.cpp @@ -127,7 +127,7 @@ void DescSetLayout::Init(VulkanResourceManager *resourceMan, VulkanCreationInfo } } -void DescSetLayout::CreateBindingsArray(std::vector &descBindings) const +void DescSetLayout::CreateBindingsArray(rdcarray &descBindings) const { descBindings.resize(bindings.size()); for(size_t i = 0; i < bindings.size(); i++) @@ -138,7 +138,7 @@ void DescSetLayout::CreateBindingsArray(std::vector &descBi } void DescSetLayout::UpdateBindingsArray(const DescSetLayout &prevLayout, - std::vector &descBindings) const + rdcarray &descBindings) const { // if we have fewer bindings now, delete the orphaned bindings arrays for(size_t i = bindings.size(); i < prevLayout.bindings.size(); i++) @@ -457,10 +457,8 @@ void VulkanCreationInfo::Pipeline::Init(VulkanResourceManager *resourceMan, if(!dynamicStates[VkDynamicSampleLocationsEXT]) { sampleLocations.gridSize = sampleLoc->sampleLocationsInfo.sampleLocationGridSize; - sampleLocations.locations.insert(sampleLocations.locations.begin(), - sampleLoc->sampleLocationsInfo.pSampleLocations, - sampleLoc->sampleLocationsInfo.pSampleLocations + - sampleLoc->sampleLocationsInfo.sampleLocationsCount); + sampleLocations.locations.assign(sampleLoc->sampleLocationsInfo.pSampleLocations, + sampleLoc->sampleLocationsInfo.sampleLocationsCount); RDCASSERTEQUAL(sampleLoc->sampleLocationsInfo.sampleLocationsPerPixel, rasterizationSamples); } @@ -1049,17 +1047,16 @@ void VulkanCreationInfo::ShaderModule::Init(VulkanResourceManager *resourceMan, else { RDCASSERT(pCreateInfo->codeSize % sizeof(uint32_t) == 0); - spirv.Parse(std::vector( - (uint32_t *)(pCreateInfo->pCode), - (uint32_t *)(pCreateInfo->pCode + pCreateInfo->codeSize / sizeof(uint32_t)))); + spirv.Parse(rdcarray((uint32_t *)(pCreateInfo->pCode), + pCreateInfo->codeSize / sizeof(uint32_t))); } } void VulkanCreationInfo::ShaderModuleReflection::Init(VulkanResourceManager *resourceMan, ResourceId id, const rdcspv::Reflector &spv, - const std::string &entry, + const rdcstr &entry, VkShaderStageFlagBits stage, - const std::vector &specInfo) + const rdcarray &specInfo) { if(entryPoint.empty()) { @@ -1078,7 +1075,7 @@ void VulkanCreationInfo::DescSetPool::Init(VulkanResourceManager *resourceMan, const VkDescriptorPoolCreateInfo *pCreateInfo) { maxSets = pCreateInfo->maxSets; - poolSizes.assign(pCreateInfo->pPoolSizes, pCreateInfo->pPoolSizes + pCreateInfo->poolSizeCount); + poolSizes.assign(pCreateInfo->pPoolSizes, pCreateInfo->poolSizeCount); } void VulkanCreationInfo::DescSetPool::CreateOverflow(VkDevice device, @@ -1109,8 +1106,7 @@ void VulkanCreationInfo::DescSetPool::CreateOverflow(VkDevice device, void DescUpdateTemplate::Init(VulkanResourceManager *resourceMan, VulkanCreationInfo &info, const VkDescriptorUpdateTemplateCreateInfo *pCreateInfo) { - updates.insert(updates.begin(), pCreateInfo->pDescriptorUpdateEntries, - pCreateInfo->pDescriptorUpdateEntries + pCreateInfo->descriptorUpdateEntryCount); + updates.assign(pCreateInfo->pDescriptorUpdateEntries, pCreateInfo->descriptorUpdateEntryCount); bindPoint = pCreateInfo->pipelineBindPoint; @@ -1171,7 +1167,7 @@ void DescUpdateTemplate::Init(VulkanResourceManager *resourceMan, VulkanCreation } else { - const std::vector &descSetLayouts = + const rdcarray &descSetLayouts = info.m_PipelineLayout[GetResID(pCreateInfo->pipelineLayout)].descSetLayouts; layout = info.m_DescSetLayout[descSetLayouts[pCreateInfo->set]]; diff --git a/renderdoc/driver/vulkan/vk_info.h b/renderdoc/driver/vulkan/vk_info.h index 8860f7cf4..209dfba90 100644 --- a/renderdoc/driver/vulkan/vk_info.h +++ b/renderdoc/driver/vulkan/vk_info.h @@ -60,9 +60,9 @@ struct DescSetLayout void Init(VulkanResourceManager *resourceMan, VulkanCreationInfo &info, const VkDescriptorSetLayoutCreateInfo *pCreateInfo); - void CreateBindingsArray(std::vector &descBindings) const; + void CreateBindingsArray(rdcarray &descBindings) const; void UpdateBindingsArray(const DescSetLayout &prevLayout, - std::vector &descBindings) const; + rdcarray &descBindings) const; struct Binding { @@ -108,7 +108,7 @@ struct DescSetLayout VkShaderStageFlags stageFlags; ResourceId *immutableSampler; }; - std::vector bindings; + rdcarray bindings; uint32_t dynamicCount; VkDescriptorSetLayoutCreateFlags flags; @@ -119,11 +119,11 @@ struct DescSetLayout struct DescUpdateTemplateApplication { - std::vector bufInfo; - std::vector imgInfo; - std::vector bufView; + rdcarray bufInfo; + rdcarray imgInfo; + rdcarray bufView; - std::vector writes; + rdcarray writes; }; struct DescUpdateTemplate @@ -143,7 +143,7 @@ struct DescUpdateTemplate uint32_t bufferInfoCount; uint32_t imageInfoCount; - std::vector updates; + rdcarray updates; }; struct VulkanCreationInfo @@ -168,15 +168,15 @@ struct VulkanCreationInfo struct ShaderModuleReflection { uint32_t stageIndex; - std::string entryPoint; - std::string disassembly; + rdcstr entryPoint; + rdcstr disassembly; ShaderReflection refl; ShaderBindpointMapping mapping; SPIRVPatchData patchData; void Init(VulkanResourceManager *resourceMan, ResourceId id, const rdcspv::Reflector &spv, - const std::string &entry, VkShaderStageFlagBits stage, - const std::vector &specInfo); + const rdcstr &entry, VkShaderStageFlagBits stage, + const rdcarray &specInfo); }; struct Pipeline @@ -202,12 +202,12 @@ struct VulkanCreationInfo { Shader() : refl(NULL), mapping(NULL), patchData(NULL) {} ResourceId module; - std::string entryPoint; + rdcstr entryPoint; ShaderReflection *refl; ShaderBindpointMapping *mapping; SPIRVPatchData *patchData; - std::vector specialization; + rdcarray specialization; }; Shader shaders[6]; @@ -221,7 +221,7 @@ struct VulkanCreationInfo // VkVertexInputBindingDivisorDescriptionEXT uint32_t instanceDivisor; }; - std::vector vertexBindings; + rdcarray vertexBindings; struct Attribute { @@ -230,7 +230,7 @@ struct VulkanCreationInfo VkFormat format; uint32_t byteoffset; }; - std::vector vertexAttrs; + rdcarray vertexAttrs; // VkPipelineInputAssemblyStateCreateInfo VkPrimitiveTopology topology; @@ -244,8 +244,8 @@ struct VulkanCreationInfo // VkPipelineViewportStateCreateInfo uint32_t viewportCount; - std::vector viewports; - std::vector scissors; + rdcarray viewports; + rdcarray scissors; // VkPipelineRasterizationStateCreateInfo bool depthClampEnable; @@ -288,7 +288,7 @@ struct VulkanCreationInfo { bool enabled; VkExtent2D gridSize; - std::vector locations; + rdcarray locations; } sampleLocations; // VkPipelineDepthStencilStateCreateInfo @@ -320,13 +320,13 @@ struct VulkanCreationInfo uint8_t channelWriteMask; }; - std::vector attachments; + rdcarray attachments; // VkPipelineDynamicStateCreateInfo bool dynamicStates[VkDynamicCount]; // VkPipelineDiscardRectangleStateCreateInfoEXT - std::vector discardRectangles; + rdcarray discardRectangles; VkDiscardRectangleModeEXT discardMode; }; std::map m_Pipeline; @@ -336,8 +336,8 @@ struct VulkanCreationInfo void Init(VulkanResourceManager *resourceMan, VulkanCreationInfo &info, const VkPipelineLayoutCreateInfo *pCreateInfo); - std::vector pushRanges; - std::vector descSetLayouts; + rdcarray pushRanges; + rdcarray descSetLayouts; }; std::map m_PipelineLayout; @@ -361,30 +361,30 @@ struct VulkanCreationInfo VkImageLayout finalLayout; }; - std::vector attachments; + rdcarray attachments; struct Subpass { // these are split apart since they layout is // rarely used but the indices are often used - std::vector inputAttachments; - std::vector colorAttachments; - std::vector resolveAttachments; + rdcarray inputAttachments; + rdcarray colorAttachments; + rdcarray resolveAttachments; int32_t depthstencilAttachment; int32_t fragmentDensityAttachment; - std::vector inputLayouts; - std::vector colorLayouts; + rdcarray inputLayouts; + rdcarray colorLayouts; VkImageLayout depthstencilLayout; VkImageLayout fragmentDensityLayout; - std::vector multiviews; + rdcarray multiviews; }; - std::vector subpasses; + rdcarray subpasses; // one for each subpass, as we preserve attachments // in the layout that the subpass uses - std::vector loadRPs; + rdcarray loadRPs; }; std::map m_RenderPass; @@ -398,13 +398,13 @@ struct VulkanCreationInfo ResourceId createdView; bool hasStencil; }; - std::vector attachments; + rdcarray attachments; bool imageless; uint32_t width, height, layers; // See above in loadRPs - we need to duplicate and make framebuffer equivalents for each - std::vector loadFBs; + rdcarray loadFBs; }; std::map m_Framebuffer; @@ -527,7 +527,7 @@ struct VulkanCreationInfo rdcspv::Reflector spirv; - std::string unstrippedPath; + rdcstr unstrippedPath; std::map m_Reflections; }; @@ -539,15 +539,15 @@ struct VulkanCreationInfo const VkDescriptorPoolCreateInfo *pCreateInfo); uint32_t maxSets; - std::vector poolSizes; + rdcarray poolSizes; void CreateOverflow(VkDevice device, VulkanResourceManager *resourceMan); - std::vector overflow; + rdcarray overflow; }; std::map m_DescSetPool; - std::map m_Names; + std::map m_Names; std::map m_SwapChain; std::map m_DescSetLayout; std::map m_DescUpdateTemplate; diff --git a/renderdoc/driver/vulkan/vk_initstate.cpp b/renderdoc/driver/vulkan/vk_initstate.cpp index 8fed21077..07f28adc5 100644 --- a/renderdoc/driver/vulkan/vk_initstate.cpp +++ b/renderdoc/driver/vulkan/vk_initstate.cpp @@ -1181,7 +1181,7 @@ bool WrappedVulkan::Serialise_InitialState(SerialiserType &ser, ResourceId id, if(IsBlockFormat(fmt)) bufAlignment = (VkDeviceSize)GetByteSize(1, 1, 1, fmt, 0); - std::vector mainCopies, stencilCopies; + rdcarray mainCopies, stencilCopies; // copy each slice/mip individually for(int a = 0; a < numLayers; a++) @@ -1340,8 +1340,8 @@ void WrappedVulkan::Create_InitialState(ResourceId id, WrappedVkRes *live, bool void WrappedVulkan::ImageInitializationBarriers(ResourceId id, WrappedVkRes *live, InitPolicy policy, bool initialized, const ImgRefs *imgRefs, - std::vector &setupBarriers, - std::vector &cleanupBarriers) const + rdcarray &setupBarriers, + rdcarray &cleanupBarriers) const { // For each subresource that will be initialized (either copy or fill), create barriers that will // transition the subresource from UNDEFINED to TRANSFER_DST_OPTIMAL before the write (in @@ -1429,10 +1429,10 @@ void WrappedVulkan::ImageInitializationBarriers(ResourceId id, WrappedVkRes *liv } } -std::map > GetExtQBarriers( - const std::vector &barriers) +std::map > GetExtQBarriers( + const rdcarray &barriers) { - std::map > extQBarriers; + std::map > extQBarriers; for(auto barrierIt = barriers.begin(); barrierIt != barriers.end(); ++barrierIt) { @@ -1445,14 +1445,14 @@ std::map > GetExtQBarriers( } void WrappedVulkan::SubmitExtQBarriers( - const std::map > &extQBarriers) + const std::map > &extQBarriers) { VkCommandBufferBeginInfo beginInfo = {VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, NULL, VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT}; for(auto extQBarrierIt = extQBarriers.begin(); extQBarrierIt != extQBarriers.end(); ++extQBarrierIt) { uint32_t queueFamilyIndex = extQBarrierIt->first; - const std::vector &queueFamilyBarriers = extQBarrierIt->second; + const rdcarray &queueFamilyBarriers = extQBarrierIt->second; VkCommandBuffer extQCmd = GetExtQueueCmd(queueFamilyIndex); @@ -1487,7 +1487,7 @@ void WrappedVulkan::Apply_InitialState(WrappedVkRes *live, const VkInitialConten // need to blat over the current descriptor set contents, so these are available // when we want to fetch pipeline state - std::vector &bindings = m_DescriptorSetState[id].currentBindings; + rdcarray &bindings = m_DescriptorSetState[id].currentBindings; for(uint32_t i = 0; i < initial.numDescriptors; i++) { @@ -2022,7 +2022,7 @@ void WrappedVulkan::Apply_InitialState(WrappedVkRes *live, const VkInitialConten } } - std::vector setupBarriers, cleanupBarriers; + rdcarray setupBarriers, cleanupBarriers; ImageInitializationBarriers(id, live, policy, initialized, imgRefs, setupBarriers, cleanupBarriers); DoPipelineBarrier(cmd, (uint32_t)setupBarriers.size(), setupBarriers.data()); @@ -2036,8 +2036,8 @@ void WrappedVulkan::Apply_InitialState(WrappedVkRes *live, const VkInitialConten if(IsBlockFormat(fmt)) bufAlignment = (VkDeviceSize)GetByteSize(1, 1, 1, fmt, 0); - std::vector copyRegions; - std::vector clearRegions; + rdcarray copyRegions; + rdcarray clearRegions; // copy each slice/mip individually for(int a = 0; a < m_CreationInfo.m_Image[id].arrayLayers; a++) @@ -2181,7 +2181,7 @@ void WrappedVulkan::Apply_InitialState(WrappedVkRes *live, const VkInitialConten vkr = ObjDisp(cmd)->EndCommandBuffer(Unwrap(cmd)); RDCASSERTEQUAL(vkr, VK_SUCCESS); - std::map > extQBarriers = + std::map > extQBarriers = GetExtQBarriers(cleanupBarriers); if(extQBarriers.size() > 0) { @@ -2251,7 +2251,7 @@ void WrappedVulkan::Apply_InitialState(WrappedVkRes *live, const VkInitialConten vkr = ObjDisp(cmd)->BeginCommandBuffer(Unwrap(cmd), &beginInfo); RDCASSERTEQUAL(vkr, VK_SUCCESS); - std::vector regions; + rdcarray regions; uint32_t fillCount = 0; for(auto it = resetReq.begin(); it != resetReq.end(); it++) { diff --git a/renderdoc/driver/vulkan/vk_manager.cpp b/renderdoc/driver/vulkan/vk_manager.cpp index 10c96204e..a69749ae9 100644 --- a/renderdoc/driver/vulkan/vk_manager.cpp +++ b/renderdoc/driver/vulkan/vk_manager.cpp @@ -35,44 +35,46 @@ template void VulkanResourceManager::RecordSingleBarrier( - std::vector > &dststates, ResourceId id, + rdcarray> &dststates, ResourceId id, const SrcBarrierType &t, uint32_t nummips, uint32_t numslices) { bool done = false; - auto it = dststates.begin(); - for(; it != dststates.end(); ++it) + size_t i = 0; + for(; i < dststates.size(); i++) { + rdcpair &state = dststates[i]; + // image barriers are handled by initially inserting one subresource range for each aspect, // and whenever we need more fine-grained detail we split it immediately for one range for // each subresource in that aspect. Thereafter if a barrier comes in that covers multiple // subresources, we update all matching ranges. // find the states matching this id - if(it->first < id) + if(state.first < id) continue; - if(it->first != id) + if(state.first != id) break; - it->second.dstQueueFamilyIndex = t.dstQueueFamilyIndex; + state.second.dstQueueFamilyIndex = t.dstQueueFamilyIndex; { // we've found a range that completely matches our region, doesn't matter if that's // a whole image and the barrier is the whole image, or it's one subresource. // note that for images with only one array/mip slice (e.g. render targets) we'll never // really have to worry about the else{} branch - if(it->second.subresourceRange.baseMipLevel == t.subresourceRange.baseMipLevel && - it->second.subresourceRange.levelCount == nummips && - it->second.subresourceRange.baseArrayLayer == t.subresourceRange.baseArrayLayer && - it->second.subresourceRange.layerCount == numslices) + if(state.second.subresourceRange.baseMipLevel == t.subresourceRange.baseMipLevel && + state.second.subresourceRange.levelCount == nummips && + state.second.subresourceRange.baseArrayLayer == t.subresourceRange.baseArrayLayer && + state.second.subresourceRange.layerCount == numslices) { // verify // RDCASSERT(it->second.newLayout == t.oldLayout); // apply it (prevstate is from the start of all barriers accumulated, so only set once) - if(it->second.oldLayout == UNKNOWN_PREV_IMG_LAYOUT) - it->second.oldLayout = t.oldLayout; - it->second.newLayout = t.newLayout; + if(state.second.oldLayout == UNKNOWN_PREV_IMG_LAYOUT) + state.second.oldLayout = t.oldLayout; + state.second.newLayout = t.newLayout; done = true; break; @@ -86,23 +88,21 @@ void VulkanResourceManager::RecordSingleBarrier( // satisfied. // // note that regardless of how we lay out our subresources (slice-major or mip-major) the - // new - // range could be sparse, but that's OK as we only break out of the loop once we go past the - // whole - // aspect. Any subresources that don't match the range, after the split, will fail to meet - // any - // of the handled cases, so we'll just continue processing. - if(it->second.subresourceRange.levelCount == 1 && - it->second.subresourceRange.layerCount == 1 && - it->second.subresourceRange.baseMipLevel >= t.subresourceRange.baseMipLevel && - it->second.subresourceRange.baseMipLevel < t.subresourceRange.baseMipLevel + nummips && - it->second.subresourceRange.baseArrayLayer >= t.subresourceRange.baseArrayLayer && - it->second.subresourceRange.baseArrayLayer < t.subresourceRange.baseArrayLayer + numslices) + // new range could be sparse, but that's OK as we only break out of the loop once we go past + // the whole aspect. Any subresources that don't match the range, after the split, will fail + // to meet any of the handled cases, so we'll just continue processing. + if(state.second.subresourceRange.levelCount == 1 && + state.second.subresourceRange.layerCount == 1 && + state.second.subresourceRange.baseMipLevel >= t.subresourceRange.baseMipLevel && + state.second.subresourceRange.baseMipLevel < t.subresourceRange.baseMipLevel + nummips && + state.second.subresourceRange.baseArrayLayer >= t.subresourceRange.baseArrayLayer && + state.second.subresourceRange.baseArrayLayer < + t.subresourceRange.baseArrayLayer + numslices) { // apply it (prevstate is from the start of all barriers accumulated, so only set once) - if(it->second.oldLayout == UNKNOWN_PREV_IMG_LAYOUT) - it->second.oldLayout = t.oldLayout; - it->second.newLayout = t.newLayout; + if(state.second.oldLayout == UNKNOWN_PREV_IMG_LAYOUT) + state.second.oldLayout = t.oldLayout; + state.second.newLayout = t.newLayout; // continue as there might be more, but we're done done = true; @@ -113,52 +113,50 @@ void VulkanResourceManager::RecordSingleBarrier( // case, so we know that the barrier doesn't cover the whole range. // Also, if we've already done the split this case won't be hit and we'll either fall into // the case above, or we'll finish as we've covered the whole barrier. - else if(it->second.subresourceRange.levelCount > 1 || - it->second.subresourceRange.layerCount > 1) + else if(state.second.subresourceRange.levelCount > 1 || + state.second.subresourceRange.layerCount > 1) { - rdcpair existing = *it; + const uint32_t levelCount = state.second.subresourceRange.levelCount; + const uint32_t layerCount = state.second.subresourceRange.layerCount; - // remember where we were in the array, as after this iterators will be - // invalidated. - size_t offs = it - dststates.begin(); - size_t count = - it->second.subresourceRange.levelCount * it->second.subresourceRange.layerCount; + size_t count = levelCount * layerCount; - // only insert count-1 as we want count entries total - one per subresource - dststates.insert(it, count - 1, existing); + // reset layer/level count + state.second.subresourceRange.levelCount = 1; + state.second.subresourceRange.layerCount = 1; - // it now points at the first subresource, but we need to modify the ranges - // to be valid - it = dststates.begin() + offs; + // insert new copies of the current state to expand out the subresources. Only insert + // count-1 as we want count entries total - one per subresource + for(size_t sub = 0; sub < count - 1; sub++) + dststates.insert(i, state); - for(size_t i = 0; i < count; i++) + for(size_t sub = 0; sub < count; sub++) { - it->second.subresourceRange.levelCount = 1; - it->second.subresourceRange.layerCount = 1; + rdcpair &subState = dststates[i + sub]; - // slice-major - it->second.subresourceRange.baseArrayLayer = - uint32_t(i / existing.second.subresourceRange.levelCount); - it->second.subresourceRange.baseMipLevel = - uint32_t(i % existing.second.subresourceRange.levelCount); - it++; + // slice-major, update base of each subresource + subState.second.subresourceRange.baseArrayLayer = uint32_t(sub / levelCount); + subState.second.subresourceRange.baseMipLevel = uint32_t(sub % levelCount); } - // reset the iterator to point to the first subresource - it = dststates.begin() + offs; + // can't use state here, as it may no longer be valid if the inserts above resized the + // array + rdcpair &firstState = dststates[i]; // the loop will continue after this point and look at the next subresources // so we need to check to see if the first subresource lies in the range here - if(it->second.subresourceRange.baseMipLevel >= t.subresourceRange.baseMipLevel && - it->second.subresourceRange.baseMipLevel < t.subresourceRange.baseMipLevel + nummips && - it->second.subresourceRange.baseArrayLayer >= t.subresourceRange.baseArrayLayer && - it->second.subresourceRange.baseArrayLayer < + if(firstState.second.subresourceRange.baseMipLevel >= t.subresourceRange.baseMipLevel && + firstState.second.subresourceRange.baseMipLevel < + t.subresourceRange.baseMipLevel + nummips && + firstState.second.subresourceRange.baseArrayLayer >= t.subresourceRange.baseArrayLayer && + firstState.second.subresourceRange.baseArrayLayer < t.subresourceRange.baseArrayLayer + numslices) { - // apply it (prevstate is from the start of all barriers accumulated, so only set once) - if(it->second.oldLayout == UNKNOWN_PREV_IMG_LAYOUT) - it->second.oldLayout = t.oldLayout; - it->second.newLayout = t.newLayout; + // apply it (prevstate is from the start of all barriers accumulated, so only set + // once) + if(firstState.second.oldLayout == UNKNOWN_PREV_IMG_LAYOUT) + firstState.second.oldLayout = t.oldLayout; + firstState.second.newLayout = t.newLayout; // continue as there might be more, but we're done done = true; @@ -181,11 +179,11 @@ void VulkanResourceManager::RecordSingleBarrier( VkImageSubresourceRange subRange = t.subresourceRange; subRange.levelCount = nummips; subRange.layerCount = numslices; - dststates.insert(it, make_rdcpair(id, ImageRegionState(VK_QUEUE_FAMILY_IGNORED, subRange, - t.oldLayout, t.newLayout))); + dststates.insert(i, make_rdcpair(id, ImageRegionState(VK_QUEUE_FAMILY_IGNORED, subRange, + t.oldLayout, t.newLayout))); } -void VulkanResourceManager::RecordBarriers(std::vector > &states, +void VulkanResourceManager::RecordBarriers(rdcarray> &states, const std::map &layouts, uint32_t numBarriers, const VkImageMemoryBarrier *barriers) { @@ -230,9 +228,8 @@ void VulkanResourceManager::RecordBarriers(std::vector > &dststates, - std::vector > &srcstates) +void VulkanResourceManager::MergeBarriers(rdcarray> &dststates, + rdcarray> &srcstates) { TRDBG("Merging %u states", (uint32_t)srcstates.size()); @@ -249,13 +246,13 @@ void VulkanResourceManager::MergeBarriers( template void VulkanResourceManager::SerialiseImageStates(SerialiserType &ser, std::map &states, - std::vector &barriers) + rdcarray &barriers) { SERIALISE_ELEMENT_LOCAL(NumImages, (uint32_t)states.size()); auto srcit = states.begin(); - std::vector > vec; + rdcarray> vec; std::set updatedState; @@ -360,15 +357,17 @@ void VulkanResourceManager::SerialiseImageStates(SerialiserType &ser, } // erase any do-nothing barriers - for(auto it = barriers.begin(); it != barriers.end();) + for(size_t i = 0; i < barriers.size();) { - if(it->oldLayout == UNKNOWN_PREV_IMG_LAYOUT) - it->oldLayout = VK_IMAGE_LAYOUT_UNDEFINED; + VkImageMemoryBarrier &b = barriers[i]; - if(it->oldLayout == it->newLayout) - it = barriers.erase(it); + if(b.oldLayout == UNKNOWN_PREV_IMG_LAYOUT) + b.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED; + + if(b.oldLayout == b.newLayout) + barriers.erase(i); else - ++it; + i++; } // try to merge images that have been split up by subresource but are now all in the same state @@ -396,8 +395,7 @@ void VulkanResourceManager::SerialiseImageStates(SerialiserType &ser, if(allIdentical) { - layouts.subresourceStates.erase(layouts.subresourceStates.begin() + 1, - layouts.subresourceStates.end()); + layouts.subresourceStates.erase(1, ~0U); layouts.subresourceStates[0].subresourceRange.baseArrayLayer = 0; layouts.subresourceStates[0].subresourceRange.baseMipLevel = 0; layouts.subresourceStates[0].subresourceRange.layerCount = imageInfo.layerCount; @@ -409,10 +407,10 @@ void VulkanResourceManager::SerialiseImageStates(SerialiserType &ser, template void VulkanResourceManager::SerialiseImageStates(ReadSerialiser &ser, std::map &states, - std::vector &barriers); + rdcarray &barriers); template void VulkanResourceManager::SerialiseImageStates(WriteSerialiser &ser, std::map &states, - std::vector &barriers); + rdcarray &barriers); template void DoSerialise(SerialiserType &ser, MemRefInterval &el) @@ -424,7 +422,7 @@ void DoSerialise(SerialiserType &ser, MemRefInterval &el) template bool VulkanResourceManager::Serialise_DeviceMemoryRefs(SerialiserType &ser, - std::vector &data) + rdcarray &data) { SERIALISE_ELEMENT(data); @@ -506,12 +504,12 @@ bool VulkanResourceManager::Serialise_DeviceMemoryRefs(SerialiserType &ser, } template bool VulkanResourceManager::Serialise_DeviceMemoryRefs(ReadSerialiser &ser, - std::vector &data); + rdcarray &data); template bool VulkanResourceManager::Serialise_DeviceMemoryRefs(WriteSerialiser &ser, - std::vector &data); + rdcarray &data); template -bool VulkanResourceManager::Serialise_ImageRefs(SerialiserType &ser, std::vector &data) +bool VulkanResourceManager::Serialise_ImageRefs(SerialiserType &ser, rdcarray &data) { SERIALISE_ELEMENT(data); @@ -528,13 +526,13 @@ bool VulkanResourceManager::Serialise_ImageRefs(SerialiserType &ser, std::vector } template bool VulkanResourceManager::Serialise_ImageRefs(ReadSerialiser &ser, - std::vector &imageRefs); + rdcarray &imageRefs); template bool VulkanResourceManager::Serialise_ImageRefs(WriteSerialiser &ser, - std::vector &imageRefs); + rdcarray &imageRefs); void VulkanResourceManager::InsertDeviceMemoryRefs(WriteSerialiser &ser) { - std::vector data; + rdcarray data; for(auto it = m_MemFrameRefs.begin(); it != m_MemFrameRefs.end(); it++) { @@ -554,7 +552,7 @@ void VulkanResourceManager::InsertDeviceMemoryRefs(WriteSerialiser &ser) void VulkanResourceManager::InsertImageRefs(WriteSerialiser &ser) { - std::vector data; + rdcarray data; data.reserve(m_ImgFrameRefs.size()); size_t sizeEstimate = 32; @@ -604,7 +602,7 @@ void VulkanResourceManager::SetInternalResource(ResourceId id) } void VulkanResourceManager::ApplyBarriers(uint32_t queueFamilyIndex, - std::vector > &states, + rdcarray> &states, std::map &layouts) { TRDBG("Applying %u barriers", (uint32_t)states.size()); @@ -657,12 +655,13 @@ void VulkanResourceManager::ApplyBarriers(uint32_t queueFamilyIndex, TRDBG("Matching image has %u subresource states", stit->second.subresourceStates.size()); - auto it = stit->second.subresourceStates.begin(); - for(; it != stit->second.subresourceStates.end(); ++it) + for(size_t i = 0; i < stit->second.subresourceStates.size(); i++) { - TRDBG(".. state %s (%u->%u, %u->%u) from %s to %s", ToStr(it->subresourceRange.aspect).c_str(), - it->range.baseMipLevel, it->range.levelCount, it->range.baseArrayLayer, - it->range.layerCount, ToStr(it->oldLayout).c_str(), ToStr(it->newLayout).c_str()); + ImageRegionState &state = stit->second.subresourceStates[i]; + TRDBG(".. state %s (%u->%u, %u->%u) from %s to %s", + ToStr(state.subresourceRange.aspect).c_str(), state.range.baseMipLevel, + state.range.levelCount, state.range.baseArrayLayer, state.range.layerCount, + ToStr(state.oldLayout).c_str(), ToStr(state.newLayout).c_str()); // image barriers are handled by initially inserting one subresource range for the whole // object, @@ -680,22 +679,15 @@ void VulkanResourceManager::ApplyBarriers(uint32_t queueFamilyIndex, // a whole image and the barrier is the whole image, or it's one subresource. // note that for images with only one array/mip slice (e.g. render targets) we'll never // really have to worry about the else{} branch - if(it->subresourceRange.baseMipLevel == t.subresourceRange.baseMipLevel && - it->subresourceRange.levelCount == nummips && - it->subresourceRange.baseArrayLayer == t.subresourceRange.baseArrayLayer && - it->subresourceRange.layerCount == numslices) + if(state.subresourceRange.baseMipLevel == t.subresourceRange.baseMipLevel && + state.subresourceRange.levelCount == nummips && + state.subresourceRange.baseArrayLayer == t.subresourceRange.baseArrayLayer && + state.subresourceRange.layerCount == numslices) { - /* - RDCASSERT(t.oldLayout == UNKNOWN_PREV_IMG_LAYOUT || it->newLayout == - UNKNOWN_PREV_IMG_LAYOUT || // renderdoc untracked/ignored - it->newLayout == t.oldLayout || // valid barrier - t.oldLayout == VK_IMAGE_LAYOUT_UNDEFINED); // can barrier from UNDEFINED to any - state - */ - if(it->oldLayout == UNKNOWN_PREV_IMG_LAYOUT) - it->oldLayout = t.oldLayout; - t.oldLayout = it->newLayout; - it->newLayout = t.newLayout; + if(state.oldLayout == UNKNOWN_PREV_IMG_LAYOUT) + state.oldLayout = t.oldLayout; + t.oldLayout = state.newLayout; + state.newLayout = t.newLayout; done = true; break; @@ -709,23 +701,20 @@ void VulkanResourceManager::ApplyBarriers(uint32_t queueFamilyIndex, // satisfied. // // note that regardless of how we lay out our subresources (slice-major or mip-major) the - // new - // range could be sparse, but that's OK as we only break out of the loop once we go past - // the whole - // aspect. Any subresources that don't match the range, after the split, will fail to meet - // any - // of the handled cases, so we'll just continue processing. - if(it->subresourceRange.levelCount == 1 && it->subresourceRange.layerCount == 1 && - it->subresourceRange.baseMipLevel >= t.subresourceRange.baseMipLevel && - it->subresourceRange.baseMipLevel < t.subresourceRange.baseMipLevel + nummips && - it->subresourceRange.baseArrayLayer >= t.subresourceRange.baseArrayLayer && - it->subresourceRange.baseArrayLayer < t.subresourceRange.baseArrayLayer + numslices) + // new range could be sparse, but that's OK as we only break out of the loop once we go + // past the whole aspect. Any subresources that don't match the range, after the split, + // will fail to meet any of the handled cases, so we'll just continue processing. + if(state.subresourceRange.levelCount == 1 && state.subresourceRange.layerCount == 1 && + state.subresourceRange.baseMipLevel >= t.subresourceRange.baseMipLevel && + state.subresourceRange.baseMipLevel < t.subresourceRange.baseMipLevel + nummips && + state.subresourceRange.baseArrayLayer >= t.subresourceRange.baseArrayLayer && + state.subresourceRange.baseArrayLayer < t.subresourceRange.baseArrayLayer + numslices) { // apply it (prevstate is from the start of all barriers accumulated, so only set once) - if(it->oldLayout == UNKNOWN_PREV_IMG_LAYOUT) - it->oldLayout = t.oldLayout; - t.oldLayout = it->newLayout; - it->newLayout = t.newLayout; + if(state.oldLayout == UNKNOWN_PREV_IMG_LAYOUT) + state.oldLayout = t.oldLayout; + t.oldLayout = state.newLayout; + state.newLayout = t.newLayout; // continue as there might be more, but we're done done = true; @@ -736,50 +725,49 @@ void VulkanResourceManager::ApplyBarriers(uint32_t queueFamilyIndex, // case, so we know that the barrier doesn't cover the whole range. // Also, if we've already done the split this case won't be hit and we'll either fall into // the case above, or we'll finish as we've covered the whole barrier. - else if(it->subresourceRange.levelCount > 1 || it->subresourceRange.layerCount > 1) + else if(state.subresourceRange.levelCount > 1 || state.subresourceRange.layerCount > 1) { - ImageRegionState existing = *it; + const uint32_t levelCount = state.subresourceRange.levelCount; + const uint32_t layerCount = state.subresourceRange.layerCount; - // remember where we were in the array, as after this iterators will be - // invalidated. - size_t offs = it - stit->second.subresourceStates.begin(); - size_t count = it->subresourceRange.levelCount * it->subresourceRange.layerCount; + size_t count = levelCount * layerCount; - // only insert count-1 as we want count entries total - one per subresource - stit->second.subresourceStates.insert(it, count - 1, existing); + // reset layer/level count + state.subresourceRange.levelCount = 1; + state.subresourceRange.layerCount = 1; - // it now points at the first subresource, but we need to modify the ranges - // to be valid - it = stit->second.subresourceStates.begin() + offs; + // insert new copies of the current state to expand out the subresources. Only insert + // count-1 as we want count entries total - one per subresource + for(size_t sub = 0; sub < count - 1; sub++) + stit->second.subresourceStates.insert(i, state); - for(size_t i = 0; i < count; i++) + for(size_t sub = 0; sub < count; sub++) { - it->subresourceRange.levelCount = 1; - it->subresourceRange.layerCount = 1; + ImageRegionState &subState = stit->second.subresourceStates[i + sub]; - // slice-major - it->subresourceRange.baseArrayLayer = - uint32_t(i / existing.subresourceRange.levelCount); - it->subresourceRange.baseMipLevel = uint32_t(i % existing.subresourceRange.levelCount); - it++; + // slice-major, update base of each subresource + subState.subresourceRange.baseArrayLayer = uint32_t(sub / levelCount); + subState.subresourceRange.baseMipLevel = uint32_t(sub % levelCount); } - // reset the iterator to point to the first subresource - it = stit->second.subresourceStates.begin() + offs; + // can't use state here, as it may no longer be valid if the inserts above resized the + // array + ImageRegionState &firstState = stit->second.subresourceStates[i]; // the loop will continue after this point and look at the next subresources // so we need to check to see if the first subresource lies in the range here - if(it->subresourceRange.baseMipLevel >= t.subresourceRange.baseMipLevel && - it->subresourceRange.baseMipLevel < t.subresourceRange.baseMipLevel + nummips && - it->subresourceRange.baseArrayLayer >= t.subresourceRange.baseArrayLayer && - it->subresourceRange.baseArrayLayer < t.subresourceRange.baseArrayLayer + numslices) + if(firstState.subresourceRange.baseMipLevel >= t.subresourceRange.baseMipLevel && + firstState.subresourceRange.baseMipLevel < t.subresourceRange.baseMipLevel + nummips && + firstState.subresourceRange.baseArrayLayer >= t.subresourceRange.baseArrayLayer && + firstState.subresourceRange.baseArrayLayer < + t.subresourceRange.baseArrayLayer + numslices) { // apply it (prevstate is from the start of all barriers accumulated, so only set // once) - if(it->oldLayout == UNKNOWN_PREV_IMG_LAYOUT) - it->oldLayout = t.oldLayout; - t.oldLayout = it->newLayout; - it->newLayout = t.newLayout; + if(firstState.oldLayout == UNKNOWN_PREV_IMG_LAYOUT) + firstState.oldLayout = t.oldLayout; + t.oldLayout = firstState.newLayout; + firstState.newLayout = t.newLayout; // continue as there might be more, but we're done done = true; diff --git a/renderdoc/driver/vulkan/vk_manager.h b/renderdoc/driver/vulkan/vk_manager.h index 1222fa2a6..66f15b7f1 100644 --- a/renderdoc/driver/vulkan/vk_manager.h +++ b/renderdoc/driver/vulkan/vk_manager.h @@ -250,29 +250,29 @@ public: // handling memory & image layouts template - void RecordSingleBarrier(std::vector > &states, ResourceId id, + void RecordSingleBarrier(rdcarray > &states, ResourceId id, const SrcBarrierType &t, uint32_t nummips, uint32_t numslices); - void RecordBarriers(std::vector > &states, + void RecordBarriers(rdcarray > &states, const std::map &layouts, uint32_t numBarriers, const VkImageMemoryBarrier *barriers); - void MergeBarriers(std::vector > &dststates, - std::vector > &srcstates); + void MergeBarriers(rdcarray > &dststates, + rdcarray > &srcstates); void ApplyBarriers(uint32_t queueFamilyIndex, - std::vector > &states, + rdcarray > &states, std::map &layouts); template void SerialiseImageStates(SerialiserType &ser, std::map &states, - std::vector &barriers); + rdcarray &barriers); template - bool Serialise_DeviceMemoryRefs(SerialiserType &ser, std::vector &data); + bool Serialise_DeviceMemoryRefs(SerialiserType &ser, rdcarray &data); template - bool Serialise_ImageRefs(SerialiserType &ser, std::vector &data); + bool Serialise_ImageRefs(SerialiserType &ser, rdcarray &data); void InsertDeviceMemoryRefs(WriteSerialiser &ser); void InsertImageRefs(WriteSerialiser &ser); @@ -358,18 +358,10 @@ public: if(record->pool) { - // here we lock against concurrent alloc/delete + // here we lock against concurrent alloc/delete and remove it from our pool so we don't try + // and destroy it record->pool->LockChunks(); - for(auto it = record->pool->pooledChildren.begin(); - it != record->pool->pooledChildren.end(); ++it) - { - if(*it == record) - { - // remove it from our pool so we don't try and destroy it - record->pool->pooledChildren.erase(it); - break; - } - } + record->pool->pooledChildren.removeOne(record); record->pool->UnlockChunks(); } else if(record->pooledChildren.size()) diff --git a/renderdoc/driver/vulkan/vk_memory.cpp b/renderdoc/driver/vulkan/vk_memory.cpp index 75c91bf5b..0b6095c85 100644 --- a/renderdoc/driver/vulkan/vk_memory.cpp +++ b/renderdoc/driver/vulkan/vk_memory.cpp @@ -101,7 +101,7 @@ MemoryAllocation WrappedVulkan::AllocateMemoryForResource(bool buffer, VkMemoryR ret.size, mrq.size, mrq.alignment, mrq.memoryTypeBits, buffer ? "buffer" : "image", ToStr(type).c_str(), ToStr(scope).c_str()); - std::vector &blockList = m_MemoryBlocks[(size_t)scope]; + rdcarray &blockList = m_MemoryBlocks[(size_t)scope]; // first try to find a match int i = 0; @@ -271,7 +271,7 @@ MemoryAllocation WrappedVulkan::AllocateMemoryForResource(VkBuffer buf, MemorySc void WrappedVulkan::FreeAllMemory(MemoryScope scope) { - std::vector &allocList = m_MemoryBlocks[(size_t)scope]; + rdcarray &allocList = m_MemoryBlocks[(size_t)scope]; if(allocList.empty()) return; diff --git a/renderdoc/driver/vulkan/vk_overlay.cpp b/renderdoc/driver/vulkan/vk_overlay.cpp index fcb5fc9f2..2585bf10f 100644 --- a/renderdoc/driver/vulkan/vk_overlay.cpp +++ b/renderdoc/driver/vulkan/vk_overlay.cpp @@ -54,7 +54,7 @@ struct VulkanQuadOverdrawCallback : public VulkanDrawcallCallback ~VulkanQuadOverdrawCallback() { m_pDriver->SetDrawcallCB(NULL); } void PreDraw(uint32_t eid, VkCommandBuffer cmd) { - if(std::find(m_Events.begin(), m_Events.end(), eid) == m_Events.end()) + if(!m_Events.contains(eid)) return; // we customise the pipeline to disable framebuffer writes, but perform normal testing @@ -90,7 +90,7 @@ struct VulkanQuadOverdrawCallback : public VulkanDrawcallCallback // this layout has storage image and descSetLayouts[descSet] = m_DescSetLayout; - const std::vector &push = c.m_PipelineLayout[p.layout].pushRanges; + const rdcarray &push = c.m_PipelineLayout[p.layout].pushRanges; VkPipelineLayoutCreateInfo pipeLayoutInfo = { VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, @@ -227,7 +227,7 @@ struct VulkanQuadOverdrawCallback : public VulkanDrawcallCallback bool PostDraw(uint32_t eid, VkCommandBuffer cmd) { - if(std::find(m_Events.begin(), m_Events.end(), eid) == m_Events.end()) + if(!m_Events.contains(eid)) return false; // restore the render state and go ahead with the real draw @@ -1290,8 +1290,7 @@ ResourceId VulkanReplay::RenderOverlay(ResourceId texid, CompType typeCast, Floa attDescs[1].format = depthImageInfo.format; attDescs[0].samples = attDescs[1].samples = iminfo.samples; - std::vector &depthStates = - m_pDriver->m_ImageLayouts[depthIm].subresourceStates; + rdcarray &depthStates = m_pDriver->m_ImageLayouts[depthIm].subresourceStates; for(ImageRegionState &ds : depthStates) { @@ -1622,7 +1621,7 @@ ResourceId VulkanReplay::RenderOverlay(ResourceId texid, CompType typeCast, Floa VkClearAttachment clearatt = {VK_IMAGE_ASPECT_COLOR_BIT, 0, {}}; memcpy(clearatt.clearValue.color.float32, &clearCol.x, sizeof(clearatt.clearValue.color.float32)); - std::vector atts; + rdcarray atts; VulkanCreationInfo::Framebuffer &fb = m_pDriver->m_CreationInfo.m_Framebuffer[m_pDriver->m_RenderState.GetFramebuffer()]; @@ -2049,7 +2048,7 @@ ResourceId VulkanReplay::RenderOverlay(ResourceId texid, CompType typeCast, Floa attDescs[1].format = depthImageInfo.format; attDescs[0].samples = attDescs[1].samples = iminfo.samples; - std::vector &depthStates = + rdcarray &depthStates = m_pDriver->m_ImageLayouts[depthIm].subresourceStates; for(ImageRegionState &ds : depthStates) diff --git a/renderdoc/driver/vulkan/vk_pixelhistory.cpp b/renderdoc/driver/vulkan/vk_pixelhistory.cpp index ad262635d..a1bfd9c44 100644 --- a/renderdoc/driver/vulkan/vk_pixelhistory.cpp +++ b/renderdoc/driver/vulkan/vk_pixelhistory.cpp @@ -23,7 +23,6 @@ ******************************************************************************/ #include -#include #include "driver/shaders/spirv/spirv_editor.h" #include "driver/shaders/spirv/spirv_op_helpers.h" #include "vk_debug.h" @@ -113,7 +112,7 @@ rdcarray VulkanReplay::PixelHistory(rdcarray even const Subresource &sub, CompType typeCast) { VULKANNOTIMP("PixelHistory"); - return std::vector(); + return rdcarray(); } #else @@ -131,7 +130,7 @@ struct VulkanPixelHistoryCallback : public VulkanDrawcallCallback VkFormat format, VkExtent3D extent, uint32_t sampleMask, VkQueryPool occlusionPool, VkImageView colorImageView, VkImageView stencilImageView, VkImage colorImage, VkImage stencilImage, - VkBuffer dstBuffer, const std::vector &events) + VkBuffer dstBuffer, const rdcarray &events) : m_pDriver(vk), m_X(x), m_Y(y), @@ -326,7 +325,7 @@ struct VulkanPixelHistoryCallback : public VulkanDrawcallCallback // Returns true if the shader was modified. bool StripSideEffects(const SPIRVPatchData &patchData, const char *entryName, - std::vector &modSpirv) + rdcarray &modSpirv) { rdcspv::Editor editor(modSpirv); @@ -455,12 +454,12 @@ struct VulkanPixelHistoryCallback : public VulkanDrawcallCallback const VulkanCreationInfo::Pipeline &p = m_pDriver->GetRenderState().m_CreationInfo->m_Pipeline[pipeline]; - std::vector prevStages; + rdcarray prevStages; prevStages.resize(pipeCreateInfo.stageCount); memcpy(prevStages.data(), pipeCreateInfo.pStages, sizeof(VkPipelineShaderStageCreateInfo) * pipeCreateInfo.stageCount); - std::vector stages; + rdcarray stages; stages.resize(pipeCreateInfo.stageCount); memcpy(stages.data(), pipeCreateInfo.pStages, sizeof(VkPipelineShaderStageCreateInfo) * pipeCreateInfo.stageCount); @@ -533,7 +532,7 @@ struct VulkanPixelHistoryCallback : public VulkanDrawcallCallback // Check if we processed this shader before. if(it != m_ShaderCache.end()) return it->second; - std::vector modSpirv = moduleInfo.spirv.GetSPIRV(); + rdcarray modSpirv = moduleInfo.spirv.GetSPIRV(); bool modified = StripSideEffects(*shader.patchData, shader.entryPoint.c_str(), modSpirv); // In some cases a shader might just be binding a RW resource but not writing to it. // If there are no writes (shader was not modified), no need to replace the shader, @@ -712,7 +711,7 @@ struct VulkanPixelHistoryCallback : public VulkanDrawcallCallback ResourceId prevState = pipestate.graphics.pipeline; ResourceId prevRenderpass = pipestate.renderPass; ResourceId prevFramebuffer = pipestate.GetFramebuffer(); - std::vector prevFBattachments = pipestate.GetFramebufferAttachments(); + rdcarray prevFBattachments = pipestate.GetFramebufferAttachments(); const VulkanCreationInfo::Pipeline &p = m_pDriver->GetRenderState().m_CreationInfo->m_Pipeline[pipestate.graphics.pipeline]; uint32_t prevSubpass = pipestate.subpass; @@ -1055,7 +1054,7 @@ bool VulkanDebugManager::PixelHistoryDestroyResources(const PixelHistoryResource void VulkanDebugManager::PixelHistoryCopyPixel(VkCommandBuffer cmd, CopyPixelParams &p, size_t offset) { - std::vector regions; + rdcarray regions; // Check if depth image includes depth and stencil VkImageAspectFlags aspectFlags = 0; VkBufferImageCopy region = {}; @@ -1157,7 +1156,7 @@ rdcarray VulkanReplay::PixelHistory(rdcarray even const Subresource &sub, CompType typeCast) { RDCDEBUG("PixelHistory: pixel: (%u, %u) with %u events", x, y, events.size()); - std::vector history; + rdcarray history; VkResult vkr; VkDevice dev = m_pDriver->GetDev(); @@ -1209,7 +1208,7 @@ rdcarray VulkanReplay::PixelHistory(rdcarray even m_pDriver->FlushQ(); cb.DestroyResources(); - std::vector occlusionResults; + rdcarray occlusionResults; if(cb.m_OcclusionQueries.size() > 0) { occlusionResults.resize(cb.m_OcclusionQueries.size()); diff --git a/renderdoc/driver/vulkan/vk_posix.cpp b/renderdoc/driver/vulkan/vk_posix.cpp index 12070d79d..2b65f6a3a 100644 --- a/renderdoc/driver/vulkan/vk_posix.cpp +++ b/renderdoc/driver/vulkan/vk_posix.cpp @@ -45,8 +45,8 @@ bool VulkanReplay::IsOutputWindowVisible(uint64_t id) return true; } -void WrappedVulkan::AddRequiredExtensions(bool instance, std::vector &extensionList, - const std::set &supportedExtensions) +void WrappedVulkan::AddRequiredExtensions(bool instance, rdcarray &extensionList, + const std::set &supportedExtensions) { bool device = !instance; @@ -66,8 +66,7 @@ void WrappedVulkan::AddRequiredExtensions(bool instance, std::vector= 0) { json = json.substr(0, idx) + STRINGIZE(RENDERDOC_VERSION_MAJOR) + json.substr(idx + sizeof(majorString) - 1); @@ -297,7 +275,7 @@ static std::string GenerateJSON(const std::string &sopath) const char minorString[] = "@RENDERDOC_VERSION_MINOR@"; idx = json.find(minorString); - while(idx != std::string::npos) + while(idx >= 0) { json = json.substr(0, idx) + STRINGIZE(RENDERDOC_VERSION_MINOR) + json.substr(idx + sizeof(minorString) - 1); @@ -308,12 +286,12 @@ static std::string GenerateJSON(const std::string &sopath) return json; } -static bool FileExists(const std::string &path) +static bool FileExists(const rdcstr &path) { return access(path.c_str(), F_OK) == 0; } -static std::string GetSOFromJSON(const std::string &json) +static rdcstr GetSOFromJSON(const rdcstr &json) { char *json_string = new char[1024]; memset(json_string, 0, 1024); @@ -327,7 +305,7 @@ static std::string GetSOFromJSON(const std::string &json) fclose(f); } - std::string ret = ""; + rdcstr ret = ""; // The line is: // "library_path": "/foo/bar/librenderdoc.so", @@ -362,7 +340,7 @@ enum class LayerPath : int ITERABLE_OPERATORS(LayerPath); -std::string LayerRegistrationPath(LayerPath path) +rdcstr LayerRegistrationPath(LayerPath path) { switch(path) { @@ -372,10 +350,10 @@ std::string LayerRegistrationPath(LayerPath path) { const char *xdg = getenv("XDG_DATA_HOME"); if(xdg && FileIO::exists(xdg)) - return std::string(xdg) + "/vulkan/implicit_layer.d/renderdoc_capture.json"; + return rdcstr(xdg) + "/vulkan/implicit_layer.d/renderdoc_capture.json"; const char *home_path = getenv("HOME"); - return std::string(home_path != NULL ? home_path : "") + + return rdcstr(home_path != NULL ? home_path : "") + "/.local/share/vulkan/implicit_layer.d/renderdoc_capture.json"; } default: break; @@ -384,9 +362,9 @@ std::string LayerRegistrationPath(LayerPath path) return ""; } -void MakeParentDirs(std::string file) +void MakeParentDirs(rdcstr file) { - std::string dir = get_dirname(file); + rdcstr dir = get_dirname(file); if(dir == "/" || dir.empty()) return; @@ -407,7 +385,7 @@ bool VulkanReplay::CheckVulkanLayer(VulkanLayerFlags &flags, rdcarray &m const char *home_path = getenv("HOME"); if(home_path == NULL) home_path = ""; - if(FileExists(std::string(home_path) + "/.renderdoc/ignore_vulkan_layer_issues")) + if(FileExists(rdcstr(home_path) + "/.renderdoc/ignore_vulkan_layer_issues")) { flags = VulkanLayerFlags::ThisInstallRegistered; return false; @@ -541,9 +519,9 @@ bool VulkanReplay::CheckVulkanLayer(VulkanLayerFlags &flags, rdcarray &m void VulkanReplay::InstallVulkanLayer(bool systemLevel) { - std::string usrPath = LayerRegistrationPath(LayerPath::usr); - std::string homePath = LayerRegistrationPath(LayerPath::home); - std::string etcPath = LayerRegistrationPath(LayerPath::etc); + rdcstr usrPath = LayerRegistrationPath(LayerPath::usr); + rdcstr homePath = LayerRegistrationPath(LayerPath::home); + rdcstr etcPath = LayerRegistrationPath(LayerPath::etc); if(FileExists(usrPath)) { @@ -597,8 +575,8 @@ void VulkanReplay::InstallVulkanLayer(bool systemLevel) LayerPath idx = systemLevel ? LayerPath::etc : LayerPath::home; - std::string jsonPath = LayerRegistrationPath(idx); - std::string path = GetSOFromJSON(jsonPath); + rdcstr jsonPath = LayerRegistrationPath(idx); + rdcstr path = GetSOFromJSON(jsonPath); rdcstr libPath; FileIO::GetLibraryFilename(libPath); diff --git a/renderdoc/driver/vulkan/vk_postvs.cpp b/renderdoc/driver/vulkan/vk_postvs.cpp index cd74cb4fc..f5458ac2b 100644 --- a/renderdoc/driver/vulkan/vk_postvs.cpp +++ b/renderdoc/driver/vulkan/vk_postvs.cpp @@ -52,7 +52,7 @@ static const uint32_t MeshOutputTBufferArraySize = 16; static const uint32_t MeshOutputReservedBindings = 5; static void ConvertToMeshOutputCompute(const ShaderReflection &refl, const SPIRVPatchData &patchData, - const char *entryName, std::vector instDivisor, + const char *entryName, rdcarray instDivisor, const DrawcallDescription *draw, uint32_t numVerts, uint32_t numViews, rdcarray &modSpirv, uint32_t &bufStride) @@ -119,9 +119,9 @@ static void ConvertToMeshOutputCompute(const ShaderReflection &refl, const SPIRV // For outputs, used to 'read' from the global at the end. rdcspv::Id privatePtrID; }; - std::vector ins; + rdcarray ins; ins.resize(numInputs); - std::vector outs; + rdcarray outs; outs.resize(numOutputs); std::set inputs; @@ -581,7 +581,7 @@ static void ConvertToMeshOutputCompute(const ShaderReflection &refl, const SPIRV // declare the output buffer and its type { - std::vector members; + rdcarray members; for(uint32_t o = 0; o < numOutputs; o++) members.push_back(outs[o].basetypeID); @@ -742,7 +742,7 @@ static void ConvertToMeshOutputCompute(const ShaderReflection &refl, const SPIRV // add the wrapper function { - std::vector ops; + rdcarray ops; rdcspv::Id voidType = editor.DeclareType(rdcspv::scalar()); rdcspv::Id funcType = editor.DeclareType(rdcspv::FunctionType(voidType, {})); @@ -1027,7 +1027,7 @@ static void ConvertToMeshOutputCompute(const ShaderReflection &refl, const SPIRV { result = editor.MakeId(); - std::vector ids; + rdcarray ids; for(uint32_t c = 0; c < refl.inputSignature[i].compCount; c++) ids.push_back(comps[c]); @@ -1052,7 +1052,7 @@ static void ConvertToMeshOutputCompute(const ShaderReflection &refl, const SPIRV rdcspv::Id swizzleIn = result; result = editor.MakeId(); - std::vector swizzle; + rdcarray swizzle; for(uint32_t c = 0; c < refl.inputSignature[i].compCount; c++) swizzle.push_back(c); @@ -1074,7 +1074,7 @@ static void ConvertToMeshOutputCompute(const ShaderReflection &refl, const SPIRV { // for composite types we need to access chain first rdcspv::Id subElement = editor.MakeId(); - std::vector chain; + rdcarray chain; for(uint32_t accessIdx : patchData.inputs[i].accessChain) { @@ -1114,7 +1114,7 @@ static void ConvertToMeshOutputCompute(const ShaderReflection &refl, const SPIRV loaded = editor.MakeId(); // structure member, need to access chain first - std::vector chain; + rdcarray chain; for(uint32_t idx : patchData.outputs[o].accessChain) { @@ -1195,10 +1195,10 @@ void VulkanReplay::PatchReservedDescriptors(const VulkanStatePipeline &pipe, VkResult vkr = VK_SUCCESS; { - std::vector descWrites; - std::vector allocImgWrites; - std::vector allocBufWrites; - std::vector allocBufViewWrites; + rdcarray descWrites; + rdcarray allocImgWrites; + rdcarray allocBufWrites; + rdcarray allocBufViewWrites; // one for each descriptor type. 1 of each to start with, we then increment for each descriptor // we need to allocate @@ -1220,11 +1220,11 @@ void VulkanReplay::PatchReservedDescriptors(const VulkanStatePipeline &pipe, for(size_t i = 0; i < newBindingsCount; i++) poolSizes[newBindings[i].descriptorType].descriptorCount += newBindings[i].descriptorCount; - const std::vector &pipeDescSetLayouts = + const rdcarray &pipeDescSetLayouts = creationInfo.m_PipelineLayout[pipeInfo.layout].descSetLayouts; // need to add our added bindings to the first descriptor set - std::vector bindings(newBindings, newBindings + newBindingsCount); + rdcarray bindings(newBindings, newBindingsCount); // if there are fewer sets bound than were declared in the pipeline layout, only process the // bound sets (as otherwise we'd fail to copy from them). Assume the application knew what it @@ -1586,7 +1586,7 @@ void VulkanReplay::FetchVSOut(uint32_t eventId) // create pipeline layout with new descriptor set layouts { - std::vector push = creationInfo.m_PipelineLayout[pipeInfo.layout].pushRanges; + rdcarray push = creationInfo.m_PipelineLayout[pipeInfo.layout].pushRanges; // ensure the push range is visible to the compute shader for(VkPushConstantRange &range : push) @@ -1645,7 +1645,7 @@ void VulkanReplay::FetchVSOut(uint32_t eventId) const bool restart = pipeCreateInfo.pInputAssemblyState->primitiveRestartEnable && SupportsRestart(drawcall->topology); bytebuf idxdata; - std::vector indices; + rdcarray indices; uint8_t *idx8 = NULL; uint16_t *idx16 = NULL; uint32_t *idx32 = NULL; @@ -1737,13 +1737,13 @@ void VulkanReplay::FetchVSOut(uint32_t eventId) if(it != indices.end() && *it == i32) continue; - indices.insert(it, i32); + indices.insert(it - indices.begin(), i32); } // if we read out of bounds, we'll also have a 0 index being referenced // (as 0 is read). Don't insert 0 if we already have 0 though if(numIndices < drawcall->numIndices && (indices.empty() || indices[0] != 0)) - indices.insert(indices.begin(), 0); + indices.insert(0, 0); maxIndex = indices.back(); @@ -1912,7 +1912,7 @@ void VulkanReplay::FetchVSOut(uint32_t eventId) VkBufferView view; }; - std::vector attrInstDivisor; + rdcarray attrInstDivisor; CompactedAttrBuffer vbuffers[64]; RDCEraseEl(vbuffers); @@ -1929,7 +1929,7 @@ void VulkanReplay::FetchVSOut(uint32_t eventId) // we fetch the vertex buffer data up front here since there's a very high chance of either // overlap due to interleaved attributes, or no overlap and no wastage due to separate compact // attributes. - std::vector origVBs; + rdcarray origVBs; origVBs.reserve(16); for(uint32_t vb = 0; vb < vi->vertexBindingDescriptionCount; vb++) @@ -2978,7 +2978,7 @@ void VulkanReplay::FetchTessGSOut(uint32_t eventId) dataSize = generatedSize; } - std::vector instData; + rdcarray instData; // instanced draws must be replayed one at a time so we can record the number of primitives from // each drawcall, as due to expansion this can vary per-instance. @@ -3035,7 +3035,7 @@ void VulkanReplay::FetchTessGSOut(uint32_t eventId) m_pDriver->SubmitCmds(); m_pDriver->FlushQ(); - std::vector queryResults; + rdcarray queryResults; queryResults.resize(drawcall->numInstances); vkr = ObjDisp(dev)->GetQueryPoolResults( Unwrap(dev), Unwrap(m_PostVS.XFBQueryPool), 0, drawcall->numInstances, diff --git a/renderdoc/driver/vulkan/vk_rendertext.cpp b/renderdoc/driver/vulkan/vk_rendertext.cpp index ccd8ff130..da7bb522d 100644 --- a/renderdoc/driver/vulkan/vk_rendertext.cpp +++ b/renderdoc/driver/vulkan/vk_rendertext.cpp @@ -317,7 +317,7 @@ VulkanTextRenderer::VulkanTextRenderer(WrappedVulkan *driver) VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, }; - std::string font = GetEmbeddedResource(sourcecodepro_ttf); + rdcstr font = GetEmbeddedResource(sourcecodepro_ttf); byte *ttfdata = (byte *)font.c_str(); const int firstChar = FONT_FIRST_CHAR; diff --git a/renderdoc/driver/vulkan/vk_rendertexture.cpp b/renderdoc/driver/vulkan/vk_rendertexture.cpp index c71c6e150..70fe163f8 100644 --- a/renderdoc/driver/vulkan/vk_rendertexture.cpp +++ b/renderdoc/driver/vulkan/vk_rendertexture.cpp @@ -447,7 +447,7 @@ bool VulkanReplay::RenderTextureInternal(TextureDisplay cfg, VkRenderPassBeginIn VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, NULL, &heatubodesc, NULL}, }; - std::vector writeSets; + rdcarray writeSets; for(size_t i = 0; i < ARRAY_COUNT(writeSet); i++) { if(writeSet[i].descriptorCount > 0) diff --git a/renderdoc/driver/vulkan/vk_replay.cpp b/renderdoc/driver/vulkan/vk_replay.cpp index 6b52c4f2b..ded955e06 100644 --- a/renderdoc/driver/vulkan/vk_replay.cpp +++ b/renderdoc/driver/vulkan/vk_replay.cpp @@ -23,6 +23,7 @@ ******************************************************************************/ #include "vk_replay.h" +#include #include #include #include @@ -544,7 +545,7 @@ rdcstr VulkanReplay::DisassembleShader(ResourceId pipeline, const ShaderReflecti if(target == SPIRVDisassemblyTarget || target.empty()) { - std::string &disasm = it->second.GetReflection(refl->entryPoint, pipeline).disassembly; + rdcstr &disasm = it->second.GetReflection(refl->entryPoint, pipeline).disassembly; if(disasm.empty()) disasm = it->second.spirv.Disassemble(refl->entryPoint.c_str()); @@ -572,7 +573,7 @@ rdcstr VulkanReplay::DisassembleShader(ResourceId pipeline, const ShaderReflecti vt->GetShaderInfoAMD(Unwrap(dev), Unwrap(pipe), stageBit, VK_SHADER_INFO_TYPE_DISASSEMBLY_AMD, &size, NULL); - std::string disasm; + rdcstr disasm; disasm.resize(size); vt->GetShaderInfoAMD(Unwrap(dev), Unwrap(pipe), stageBit, VK_SHADER_INFO_TYPE_DISASSEMBLY_AMD, &size, (void *)disasm.data()); @@ -596,7 +597,7 @@ rdcstr VulkanReplay::DisassembleShader(ResourceId pipeline, const ShaderReflecti const rdcarray &executables = m_PipelineExecutables[pipeline]; - std::string disasm; + rdcstr disasm; for(const PipelineExecutables &exec : executables) { @@ -617,7 +618,7 @@ rdcstr VulkanReplay::DisassembleShader(ResourceId pipeline, const ShaderReflecti for(const VkPipelineExecutableStatisticKHR &stat : exec.statistics) { - std::string value; + rdcstr value; switch(stat.format) { @@ -648,8 +649,8 @@ rdcstr VulkanReplay::DisassembleShader(ResourceId pipeline, const ShaderReflecti for(const VkPipelineExecutableInternalRepresentationKHR &ir : exec.representations) { - disasm += "---- " + std::string(ir.name) + " ----\n\n"; - disasm += "; " + std::string(ir.description) + "\n\n"; + disasm += "---- " + rdcstr(ir.name) + " ----\n\n"; + disasm += "; " + rdcstr(ir.description) + "\n\n"; if(ir.isText) { char *str = (char *)ir.pData; @@ -809,7 +810,7 @@ void VulkanReplay::RenderCheckerboard() vt->CmdClearAttachments(Unwrap(cmd), 1, &light, 1, &fullRect); - std::vector squares; + rdcarray squares; for(int32_t y = 0; y < (int32_t)outw.height; y += 128) { @@ -1004,7 +1005,7 @@ void VulkanReplay::SetDriverInformation(const VkPhysicalDeviceProperties &props) { VkDriverInfo info(props); m_DriverInfo.vendor = info.Vendor(); - std::string versionString = + rdcstr versionString = StringFormat::Fmt("%s %u.%u.%u", props.deviceName, info.Major(), info.Minor(), info.Patch()); versionString.resize(RDCMIN(versionString.size(), ARRAY_COUNT(m_DriverInfo.version) - 1)); memcpy(m_DriverInfo.version, versionString.c_str(), versionString.size()); @@ -1529,7 +1530,7 @@ void VulkanReplay::SavePipelineState(uint32_t eventId) &m_VulkanPipelineState.graphics.descriptorSets, &m_VulkanPipelineState.compute.descriptorSets, }; - const std::vector *srcs[] = { + const rdcarray *srcs[] = { &state.graphics.descSets, &state.compute.descSets, }; @@ -2282,7 +2283,7 @@ bool VulkanReplay::GetMinMax(ResourceId texid, const Subresource &sub, CompType 0, 1, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, NULL, &bufdescs[2], NULL}, }; - std::vector writeSets; + rdcarray writeSets; for(size_t i = 0; i < ARRAY_COUNT(writeSet); i++) { if(writeSet[i].descriptorCount > 0) @@ -2603,7 +2604,7 @@ bool VulkanReplay::GetHistogram(ResourceId texid, const Subresource &sub, CompTy altimdesc, NULL, NULL}, }; - std::vector writeSets; + rdcarray writeSets; for(size_t i = 0; i < ARRAY_COUNT(writeSet); i++) { if(writeSet[i].descriptorCount > 0) @@ -3746,7 +3747,7 @@ void VulkanReplay::GetTextureData(ResourceId tex, const Subresource &sub, // for some reason reading direct from mapped memory here is *super* slow on android (1.5s to // iterate over the image), so we memcpy to a temporary buffer. - std::vector tmp; + rdcarray tmp; tmp.resize((size_t)copyregion[1].bufferOffset + pixelCount * sizeof(uint8_t)); memcpy(tmp.data(), pData, tmp.size()); @@ -4017,7 +4018,7 @@ void VulkanReplay::RefreshDerivedReplacements() // we defer deletes of old replaced resources since it will invalidate elements in the vector // we're iterating - std::vector deletequeue; + rdcarray deletequeue; // remake and replace any pipelines that reference a replaced shader for(auto it = m_pDriver->m_CreationInfo.m_Pipeline.begin(); diff --git a/renderdoc/driver/vulkan/vk_resources.cpp b/renderdoc/driver/vulkan/vk_resources.cpp index 11758417f..e37f0f96a 100644 --- a/renderdoc/driver/vulkan/vk_resources.cpp +++ b/renderdoc/driver/vulkan/vk_resources.cpp @@ -3255,7 +3255,7 @@ InitReqType ImgRefs::SubresourceRangeMaxInitReq(VkImageSubresourceRange range, I bool initialized) const { InitReqType initReq = eInitReq_None; - std::vector splitAspectIndices; + rdcarray splitAspectIndices; if(areAspectsSplit) { int aspectIndex = 0; @@ -3296,12 +3296,12 @@ InitReqType ImgRefs::SubresourceRangeMaxInitReq(VkImageSubresourceRange range, I return initReq; } -std::vector > ImgRefs::SubresourceRangeInitReqs( +rdcarray > ImgRefs::SubresourceRangeInitReqs( VkImageSubresourceRange range, InitPolicy policy, bool initialized) const { VkImageSubresourceRange out(range); - std::vector > res; - std::vector > splitAspects; + rdcarray > res; + rdcarray > splitAspects; if(areAspectsSplit) { int aspectIndex = 0; @@ -3671,14 +3671,15 @@ void ResourceInfo::Update(uint32_t numBindings, const VkSparseMemoryBind *pBindi for(uint32_t b = 0; b < numBindings; b++) { - const VkSparseMemoryBind &curRange = pBindings[b]; + const VkSparseMemoryBind &newRange = pBindings[b]; bool found = false; // this could be improved to do a binary search since the vector is sorted. - for(auto it = opaquemappings.begin(); it != opaquemappings.end(); ++it) + // for(auto it = opaquemappings.begin(); it != opaquemappings.end(); ++it) + for(size_t i = 0; i < opaquemappings.size(); i++) { - VkSparseMemoryBind &newRange = *it; + VkSparseMemoryBind &curRange = opaquemappings[i]; // the binding we're applying is after this item in the list, // keep searching @@ -3689,49 +3690,50 @@ void ResourceInfo::Update(uint32_t numBindings, const VkSparseMemoryBind *pBindi // overlap. Insert before us in the list if(curRange.resourceOffset >= newRange.resourceOffset + newRange.size) { - opaquemappings.insert(it, newRange); + opaquemappings.insert(i, newRange); found = true; break; } // with sparse mappings it will be reasonably common to update an exact // existing range, so check that first - if(curRange.resourceOffset == newRange.resourceOffset && curRange.size == newRange.size) + if(newRange.resourceOffset == curRange.resourceOffset && newRange.size == curRange.size) { - *it = curRange; + curRange = newRange; found = true; break; } // handle subranges within the current range - if(curRange.resourceOffset <= newRange.resourceOffset && - curRange.resourceOffset + curRange.size >= newRange.resourceOffset + newRange.size) + if(newRange.resourceOffset >= curRange.resourceOffset && + newRange.resourceOffset + newRange.size <= curRange.resourceOffset + curRange.size) { // they start in the same place - if(curRange.resourceOffset == newRange.resourceOffset) + if(newRange.resourceOffset == curRange.resourceOffset) { // change the current range to be the leftover second half - it->resourceOffset += curRange.size; + curRange.resourceOffset += newRange.size; + curRange.size -= newRange.size; // insert the new mapping before our current one - opaquemappings.insert(it, newRange); + opaquemappings.insert(i, newRange); found = true; break; } // they end in the same place - else if(curRange.resourceOffset + curRange.size == newRange.resourceOffset + newRange.size) + else if(newRange.resourceOffset + newRange.size == curRange.resourceOffset + curRange.size) { // save a copy - VkSparseMemoryBind cur = curRange; + VkSparseMemoryBind first = curRange; // set the new size of the first half - cur.size = newRange.resourceOffset - curRange.resourceOffset; + first.size = newRange.resourceOffset - newRange.resourceOffset; // add the new range where the current iterator was - *it = newRange; + curRange = newRange; // insert the old truncated mapping before our current position - opaquemappings.insert(it, cur); + opaquemappings.insert(i, first); found = true; break; } @@ -3742,16 +3744,18 @@ void ResourceInfo::Update(uint32_t numBindings, const VkSparseMemoryBind *pBindi VkSparseMemoryBind first = curRange; // set the new size of the first part - first.size = newRange.resourceOffset - curRange.resourceOffset; + first.size = newRange.resourceOffset - first.resourceOffset; // set the current range (third part) to start after the new range ends - it->resourceOffset = newRange.resourceOffset + newRange.size; + curRange.size = + (curRange.resourceOffset + curRange.size) - (newRange.resourceOffset + newRange.size); + curRange.resourceOffset = newRange.resourceOffset + newRange.size; // first insert the new range before our current range - it = opaquemappings.insert(it, newRange); + opaquemappings.insert(i, newRange); // now insert the remaining first part before that - opaquemappings.insert(it, first); + opaquemappings.insert(i, first); found = true; break; @@ -3761,28 +3765,29 @@ void ResourceInfo::Update(uint32_t numBindings, const VkSparseMemoryBind *pBindi // this new range overlaps the current one and some subsequent ranges. Merge together // find where this new range stops overlapping - auto endit = it; - for(; endit != opaquemappings.end(); ++endit) + size_t endi = i; + for(; endi < opaquemappings.size(); endi++) { - if(newRange.resourceOffset + newRange.size <= endit->resourceOffset + endit->size) + if(newRange.resourceOffset + newRange.size <= + opaquemappings[endi].resourceOffset + opaquemappings[endi].size) break; } + VkSparseMemoryBind &endRange = opaquemappings[endi]; + // see if there are any leftovers of the overlapped ranges at the start or end - bool leftoverstart = (curRange.resourceOffset < newRange.resourceOffset); - bool leftoverend = - (endit != opaquemappings.end() && - (endit->resourceOffset + endit->size > newRange.resourceOffset + newRange.size)); + bool leftoverstart = (newRange.resourceOffset < curRange.resourceOffset); + bool leftoverend = (endi < opaquemappings.size() && (endRange.resourceOffset + endRange.size > + curRange.resourceOffset + curRange.size)); // no leftovers, the new range entirely covers the current and last (if there is one) if(!leftoverstart && !leftoverend) { - // erase all of the ranges. If endit points to a valid range, - // it won't be erased, so we overwrite it. Otherwise it pointed - // to end() so we just push_back() - auto last = opaquemappings.erase(it, endit); - if(last != opaquemappings.end()) - *last = newRange; + // erase all of the ranges. If endi is a valid index, it won't be erased, so we overwrite + // it. Otherwise there was no subsequent range so we just push_back() + opaquemappings.erase(i, endi - i); + if(endi < opaquemappings.size()) + endRange = newRange; else opaquemappings.push_back(newRange); } @@ -3790,21 +3795,21 @@ void ResourceInfo::Update(uint32_t numBindings, const VkSparseMemoryBind *pBindi else if(leftoverstart && !leftoverend) { // save the current range - VkSparseMemoryBind cur = curRange; + VkSparseMemoryBind first = curRange; // modify the size to reflect what's left over - cur.size = newRange.resourceOffset - cur.resourceOffset; + first.size = newRange.resourceOffset - first.resourceOffset; // as above, erase and either re-insert or push_back() - auto last = opaquemappings.erase(it, endit); - if(last != opaquemappings.end()) + opaquemappings.erase(i, endi - i); + if(endi < opaquemappings.size()) { - *last = newRange; - opaquemappings.insert(last, cur); + endRange = newRange; + opaquemappings.insert(endi, first); } else { - opaquemappings.push_back(cur); + opaquemappings.push_back(first); opaquemappings.push_back(newRange); } } @@ -3812,29 +3817,31 @@ void ResourceInfo::Update(uint32_t numBindings, const VkSparseMemoryBind *pBindi else if(!leftoverstart && leftoverend) { // erase up to but not including endit - auto last = opaquemappings.erase(it, endit); + opaquemappings.erase(i, endi - i); // modify the leftovers at the end - last->resourceOffset = newRange.resourceOffset + newRange.size; + endRange.resourceOffset = newRange.resourceOffset + newRange.size; // insert the new range before - opaquemappings.insert(last, newRange); + opaquemappings.insert(i, newRange); } // leftovers at both ends else { // save the current range - VkSparseMemoryBind cur = curRange; + VkSparseMemoryBind first = curRange; // modify the size to reflect what's left over - cur.size = newRange.resourceOffset - cur.resourceOffset; + first.size = newRange.resourceOffset - first.resourceOffset; // erase up to but not including endit - auto last = opaquemappings.erase(it, endit); + opaquemappings.erase(i, endi - i); // modify the leftovers at the end - last->resourceOffset = newRange.resourceOffset + newRange.size; + endRange.size = + (endRange.resourceOffset + endRange.size) - (newRange.resourceOffset + newRange.size); + endRange.resourceOffset = newRange.resourceOffset + newRange.size; // insert the new range before - auto newit = opaquemappings.insert(last, newRange); + opaquemappings.insert(i, newRange); // insert the modified leftovers before that - opaquemappings.insert(newit, cur); + opaquemappings.insert(i, first); } found = true; @@ -3843,7 +3850,7 @@ void ResourceInfo::Update(uint32_t numBindings, const VkSparseMemoryBind *pBindi // if it wasn't found, this binding is after all mappings in our list if(!found) - opaquemappings.push_back(curRange); + opaquemappings.push_back(newRange); } } @@ -4372,7 +4379,7 @@ TEST_CASE("Vulkan formats", "[format][vulkan]") { const uint32_t width = 24, height = 24; - std::vector > > tests = { + rdcarray > > tests = { {VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM, {576, 144, 144}}, {VK_FORMAT_G8_B8R8_2PLANE_420_UNORM, {576, 288}}, {VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM, {576, 288, 288}}, @@ -4395,7 +4402,7 @@ TEST_CASE("Vulkan formats", "[format][vulkan]") {VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM, {1152, 1152, 1152}}, }; - for(rdcpair > e : tests) + for(rdcpair > e : tests) { INFO("Format is " << ToStr(e.first)); for(uint32_t p = 0; p < e.second.size(); p++) diff --git a/renderdoc/driver/vulkan/vk_resources.h b/renderdoc/driver/vulkan/vk_resources.h index adc42e3b4..c920878e8 100644 --- a/renderdoc/driver/vulkan/vk_resources.h +++ b/renderdoc/driver/vulkan/vk_resources.h @@ -876,7 +876,7 @@ struct SwapchainInfo VkImageView view; VkFramebuffer fb; }; - std::vector images; + rdcarray images; uint32_t lastPresent; }; @@ -938,7 +938,7 @@ struct ResourceInfo } // for buffers or non-sparse-resident images (bound with opaque mappings) - std::vector opaquemappings; + rdcarray opaquemappings; VkMemoryRequirements memreqs; @@ -969,7 +969,7 @@ struct CmdBufferRecordingInfo VkResourceRecord *framebuffer = NULL; VkResourceRecord *allocRecord = NULL; - std::vector > imgbarriers; + rdcarray > imgbarriers; // sparse resources referenced by this command buffer (at submit time // need to go through the sparse mapping and reference all memory) @@ -986,9 +986,9 @@ struct CmdBufferRecordingInfo // barriers to apply when the current render pass ends. Calculated at begin time in case the // framebuffer is imageless and we need to use the image views passed in at begin time to // construct the proper barriers. - std::vector rpbarriers; + rdcarray rpbarriers; - std::vector subcmds; + rdcarray subcmds; std::map imgFrameRefs; std::map memFrameRefs; @@ -1013,7 +1013,7 @@ struct DescriptorSetData // descriptor set bindings for this descriptor set. Filled out on // create from the layout. - std::vector descBindings; + rdcarray descBindings; // lock protecting bindFrameRefs and bindMemRefs Threading::CriticalSection refLock; @@ -1031,7 +1031,7 @@ struct DescriptorSetData struct PipelineLayoutData { - std::vector layouts; + rdcarray layouts; }; struct MemMapState @@ -1114,7 +1114,7 @@ VkImageAspectFlags FormatImageAspects(VkFormat fmt); struct ImgRefs { - std::vector rangeRefs; + rdcarray rangeRefs; WrappedVkRes *initializedLiveRes = NULL; ImageInfo imageInfo; VkImageAspectFlags aspectMask; @@ -1127,10 +1127,9 @@ struct ImgRefs ImgRefs() : initializedLiveRes(NULL) {} inline ImgRefs(const ImageInfo &imageInfo) - : rangeRefs(1, eFrameRef_None), - imageInfo(imageInfo), - aspectMask(FormatImageAspects(imageInfo.format)) + : imageInfo(imageInfo), aspectMask(FormatImageAspects(imageInfo.format)) { + rangeRefs.fill(1, eFrameRef_None); if(imageInfo.extent.depth > 1) // Depth slices of 3D views are treated as array layers this->imageInfo.layerCount = imageInfo.extent.depth; @@ -1148,7 +1147,7 @@ struct ImgRefs } InitReqType SubresourceRangeMaxInitReq(VkImageSubresourceRange range, InitPolicy policy, bool initialized) const; - std::vector > SubresourceRangeInitReqs( + rdcarray > SubresourceRangeInitReqs( VkImageSubresourceRange range, InitPolicy policy, bool initialized) const; void Split(bool splitAspects, bool splitLevels, bool splitLayers); template @@ -1243,7 +1242,7 @@ FrameRefType ImgRefs::Update(ImageRange range, FrameRefType refType, Compose com range.baseMipLevel != 0 || (int)range.levelCount != imageInfo.levelCount, range.baseArrayLayer != 0 || (int)range.layerCount != imageInfo.layerCount); - std::vector splitAspects; + rdcarray splitAspects; if(areAspectsSplit) { for(auto aspectIt = ImageAspectFlagIter::begin(aspectMask); @@ -1592,7 +1591,7 @@ public: // pointer to either the pool this item is allocated from, or the children allocated // from this pool. Protected by the chunk lock VkResourceRecord *pool; - std::vector pooledChildren; + rdcarray pooledChildren; // we only need a couple of bytes to store the view's range, // so just pack/unpack into bitfields @@ -1714,7 +1713,7 @@ public: struct ImageLayouts { uint32_t queueFamilyIndex = 0; - std::vector subresourceStates; + rdcarray subresourceStates; bool isMemoryBound = false; ResourceId boundMemory = ResourceId(); VkDeviceSize boundMemoryOffset = 0ull; diff --git a/renderdoc/driver/vulkan/vk_serialise.cpp b/renderdoc/driver/vulkan/vk_serialise.cpp index ec09d3578..ae8f2be22 100644 --- a/renderdoc/driver/vulkan/vk_serialise.cpp +++ b/renderdoc/driver/vulkan/vk_serialise.cpp @@ -8059,7 +8059,7 @@ void DoSerialise(SerialiserType &ser, VkImportMemoryWin32HandleInfoKHR &el) } { - std::string name; + rdcstr name; if(ser.IsWriting()) name = el.name ? StringFormat::Wide2UTF8(el.name) : ""; @@ -8097,7 +8097,7 @@ void DoSerialise(SerialiserType &ser, VkExportMemoryWin32HandleInfoKHR &el) SERIALISE_MEMBER_TYPED(uint32_t, dwAccess); { - std::string name; + rdcstr name; if(ser.IsWriting()) name = el.name ? StringFormat::Wide2UTF8(el.name) : ""; @@ -8166,7 +8166,7 @@ void DoSerialise(SerialiserType &ser, VkExportFenceWin32HandleInfoKHR &el) SERIALISE_MEMBER_TYPED(uint32_t, dwAccess); { - std::string name; + rdcstr name; if(ser.IsWriting()) name = el.name ? StringFormat::Wide2UTF8(el.name) : ""; @@ -8205,7 +8205,7 @@ void DoSerialise(SerialiserType &ser, VkImportFenceWin32HandleInfoKHR &el) } { - std::string name; + rdcstr name; if(ser.IsWriting()) name = el.name ? StringFormat::Wide2UTF8(el.name) : ""; @@ -8259,7 +8259,7 @@ void DoSerialise(SerialiserType &ser, VkExportSemaphoreWin32HandleInfoKHR &el) SERIALISE_MEMBER_TYPED(uint32_t, dwAccess); { - std::string name; + rdcstr name; if(ser.IsWriting()) name = el.name ? StringFormat::Wide2UTF8(el.name) : ""; @@ -8298,7 +8298,7 @@ void DoSerialise(SerialiserType &ser, VkImportSemaphoreWin32HandleInfoKHR &el) } { - std::string name; + rdcstr name; if(ser.IsWriting()) name = el.name ? StringFormat::Wide2UTF8(el.name) : ""; diff --git a/renderdoc/driver/vulkan/vk_shader_cache.cpp b/renderdoc/driver/vulkan/vk_shader_cache.cpp index ea52b82ac..1c511fdfa 100644 --- a/renderdoc/driver/vulkan/vk_shader_cache.cpp +++ b/renderdoc/driver/vulkan/vk_shader_cache.cpp @@ -141,7 +141,7 @@ VulkanShaderCache::VulkanShaderCache(WrappedVulkan *driver) if(driverVersion.RunningOnMetal()) m_GlobalDefines += "#define METAL_BACKEND\n"; - std::string src; + rdcstr src; rdcspv::CompilationSettings compileSettings; compileSettings.lang = rdcspv::InputLanguage::VulkanGLSL; @@ -185,20 +185,20 @@ VulkanShaderCache::VulkanShaderCache(WrappedVulkan *driver) if(config.stage == rdcspv::ShaderStage::Geometry && !features.geometryShader) continue; - std::string defines = m_GlobalDefines; + rdcstr defines = m_GlobalDefines; if(config.builtin == BuiltinShader::TexRemapFloat) - defines += std::string("#define UINT_TEX 0\n#define SINT_TEX 0\n"); + defines += rdcstr("#define UINT_TEX 0\n#define SINT_TEX 0\n"); else if(config.builtin == BuiltinShader::TexRemapUInt) - defines += std::string("#define UINT_TEX 1\n#define SINT_TEX 0\n"); + defines += rdcstr("#define UINT_TEX 1\n#define SINT_TEX 0\n"); else if(config.builtin == BuiltinShader::TexRemapSInt) - defines += std::string("#define UINT_TEX 0\n#define SINT_TEX 1\n"); + defines += rdcstr("#define UINT_TEX 0\n#define SINT_TEX 1\n"); src = GenerateGLSLShader(GetDynamicEmbeddedResource(config.resource), ShaderType::Vulkan, 430, defines); compileSettings.stage = config.stage; - std::string err = GetSPIRVBlob(compileSettings, src, m_BuiltinShaderBlobs[i]); + rdcstr err = GetSPIRVBlob(compileSettings, src, m_BuiltinShaderBlobs[i]); if(!err.empty() || m_BuiltinShaderBlobs[i] == VK_NULL_HANDLE) { @@ -242,8 +242,8 @@ VulkanShaderCache::~VulkanShaderCache() m_pDriver->vkDestroyShaderModule(m_Device, m_BuiltinShaderModules[i], NULL); } -std::string VulkanShaderCache::GetSPIRVBlob(const rdcspv::CompilationSettings &settings, - const rdcstr &src, SPIRVBlob &outBlob) +rdcstr VulkanShaderCache::GetSPIRVBlob(const rdcspv::CompilationSettings &settings, + const rdcstr &src, SPIRVBlob &outBlob) { RDCASSERT(!src.empty()); @@ -296,10 +296,10 @@ void VulkanShaderCache::MakeGraphicsPipelineInfo(VkGraphicsPipelineCreateInfo &p static VkPipelineShaderStageCreateInfo stages[6]; static VkSpecializationInfo specInfo[6]; - static std::vector specMapEntries; + static rdcarray specMapEntries; // the specialization constants can't use more than a uint64_t, so we just over-allocate - static std::vector specdata; + static rdcarray specdata; size_t specEntries = 0; @@ -654,10 +654,10 @@ void VulkanShaderCache::MakeComputePipelineInfo(VkComputePipelineCreateInfo &pip VkPipelineShaderStageCreateInfo stage; // Returned by value static VkSpecializationInfo specInfo; - static std::vector specMapEntries; + static rdcarray specMapEntries; // the specialization constants can't use more than a uint64_t, so we just over-allocate - static std::vector specdata; + static rdcarray specdata; const uint32_t i = 5; // Compute stage RDCASSERT(pipeInfo.shaders[i].module != ResourceId()); diff --git a/renderdoc/driver/vulkan/vk_shader_cache.h b/renderdoc/driver/vulkan/vk_shader_cache.h index 5d5c57c5b..0b8a8bbca 100644 --- a/renderdoc/driver/vulkan/vk_shader_cache.h +++ b/renderdoc/driver/vulkan/vk_shader_cache.h @@ -65,8 +65,8 @@ public: VulkanShaderCache(WrappedVulkan *driver); ~VulkanShaderCache(); - std::string GetSPIRVBlob(const rdcspv::CompilationSettings &settings, const rdcstr &src, - SPIRVBlob &outBlob); + rdcstr GetSPIRVBlob(const rdcspv::CompilationSettings &settings, const rdcstr &src, + SPIRVBlob &outBlob); SPIRVBlob GetBuiltinBlob(BuiltinShader builtin) { return m_BuiltinShaderBlobs[(size_t)builtin]; } VkShaderModule GetBuiltinModule(BuiltinShader builtin) @@ -77,7 +77,7 @@ public: void MakeGraphicsPipelineInfo(VkGraphicsPipelineCreateInfo &pipeCreateInfo, ResourceId pipeline); void MakeComputePipelineInfo(VkComputePipelineCreateInfo &pipeCreateInfo, ResourceId pipeline); - std::string GetGlobalDefines() { return m_GlobalDefines; } + rdcstr GetGlobalDefines() { return m_GlobalDefines; } void SetCaching(bool enabled) { m_CacheShaders = enabled; } private: static const uint32_t m_ShaderCacheMagic = 0xf00d00d5; @@ -86,7 +86,7 @@ private: WrappedVulkan *m_pDriver = NULL; VkDevice m_Device = VK_NULL_HANDLE; - std::string m_GlobalDefines; + rdcstr m_GlobalDefines; bool m_ShaderCacheDirty = false, m_CacheShaders = false; std::map m_ShaderCache; diff --git a/renderdoc/driver/vulkan/vk_sparse_initstate.cpp b/renderdoc/driver/vulkan/vk_sparse_initstate.cpp index 93cb315c9..71d9d378f 100644 --- a/renderdoc/driver/vulkan/vk_sparse_initstate.cpp +++ b/renderdoc/driver/vulkan/vk_sparse_initstate.cpp @@ -148,7 +148,7 @@ bool WrappedVulkan::Prepare_SparseInitialState(WrappedVkBuffer *buf) readbackmem.offs); RDCASSERTEQUAL(vkr, VK_SUCCESS); - std::vector bufdeletes; + rdcarray bufdeletes; bufdeletes.push_back(dstBuf); VkCommandBufferBeginInfo beginInfo = {VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, NULL, @@ -310,7 +310,7 @@ bool WrappedVulkan::Prepare_SparseInitialState(WrappedVkImage *im) readbackmem.offs); RDCASSERTEQUAL(vkr, VK_SUCCESS); - std::vector bufdeletes; + rdcarray bufdeletes; bufdeletes.push_back(dstBuf); VkCommandBufferBeginInfo beginInfo = {VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, NULL, diff --git a/renderdoc/driver/vulkan/vk_state.cpp b/renderdoc/driver/vulkan/vk_state.cpp index f042d927c..c595cb16b 100644 --- a/renderdoc/driver/vulkan/vk_state.cpp +++ b/renderdoc/driver/vulkan/vk_state.cpp @@ -60,7 +60,7 @@ void VulkanRenderState::BeginRenderPassAndApplyState(VkCommandBuffer cmd, Pipeli VkRenderPassAttachmentBeginInfoKHR imagelessAttachments = { VK_STRUCTURE_TYPE_RENDER_PASS_ATTACHMENT_BEGIN_INFO_KHR, }; - std::vector imagelessViews; + rdcarray imagelessViews; if(fbinfo.imageless) { @@ -101,8 +101,8 @@ void VulkanRenderState::EndTransformFeedback(VkCommandBuffer cmd) { if(!xfbcounters.empty()) { - std::vector buffers; - std::vector offsets; + rdcarray buffers; + rdcarray offsets; for(size_t i = 0; i < xfbcounters.size(); i++) { @@ -140,7 +140,7 @@ void VulkanRenderState::BindPipeline(VkCommandBuffer cmd, PipelineBinding bindin ResourceId pipeLayoutId = m_CreationInfo->m_Pipeline[graphics.pipeline].layout; VkPipelineLayout layout = GetResourceManager()->GetCurrentHandle(pipeLayoutId); - const std::vector &pushRanges = + const rdcarray &pushRanges = m_CreationInfo->m_PipelineLayout[pipeLayoutId].pushRanges; bool dynamicStates[VkDynamicCount] = {0}; @@ -209,7 +209,7 @@ void VulkanRenderState::BindPipeline(VkCommandBuffer cmd, PipelineBinding bindin pushRanges[i].offset, pushRanges[i].size, pushconsts + pushRanges[i].offset); - const std::vector &descSetLayouts = + const rdcarray &descSetLayouts = m_CreationInfo->m_PipelineLayout[pipeLayoutId].descSetLayouts; // only iterate over the desc sets that this layout actually uses, not all that were bound @@ -318,8 +318,8 @@ void VulkanRenderState::BindPipeline(VkCommandBuffer cmd, PipelineBinding bindin if(!xfbcounters.empty()) { - std::vector buffers; - std::vector offsets; + rdcarray buffers; + rdcarray offsets; for(size_t i = 0; i < xfbcounters.size(); i++) { @@ -342,7 +342,7 @@ void VulkanRenderState::BindPipeline(VkCommandBuffer cmd, PipelineBinding bindin ResourceId pipeLayoutId = m_CreationInfo->m_Pipeline[compute.pipeline].layout; VkPipelineLayout layout = GetResourceManager()->GetCurrentHandle(pipeLayoutId); - const std::vector &pushRanges = + const rdcarray &pushRanges = m_CreationInfo->m_PipelineLayout[pipeLayoutId].pushRanges; // only set push constant ranges that the layout uses @@ -351,7 +351,7 @@ void VulkanRenderState::BindPipeline(VkCommandBuffer cmd, PipelineBinding bindin pushRanges[i].offset, pushRanges[i].size, pushconsts + pushRanges[i].offset); - const std::vector &descSetLayouts = + const rdcarray &descSetLayouts = m_CreationInfo->m_PipelineLayout[pipeLayoutId].descSetLayouts; for(size_t i = 0; i < descSetLayouts.size(); i++) @@ -419,12 +419,12 @@ void VulkanRenderState::BindDescriptorSet(const DescSetLayout &descLayout, VkCom { // this isn't a real descriptor set, it's a push descriptor, so we need to push the // current state. - std::vector writes; + rdcarray writes; // any allocated arrays - std::vector allocImgWrites; - std::vector allocBufWrites; - std::vector allocBufViewWrites; + rdcarray allocImgWrites; + rdcarray allocBufWrites; + rdcarray allocBufViewWrites; WrappedVulkan::DescriptorSetInfo &setInfo = m_pDriver->m_DescriptorSetState[descSet]; diff --git a/renderdoc/driver/vulkan/vk_state.h b/renderdoc/driver/vulkan/vk_state.h index c47f5e849..6ad4d6687 100644 --- a/renderdoc/driver/vulkan/vk_state.h +++ b/renderdoc/driver/vulkan/vk_state.h @@ -24,7 +24,6 @@ #pragma once -#include #include "vk_common.h" struct VulkanCreationInfo; @@ -40,9 +39,9 @@ struct VulkanStatePipeline { ResourceId pipeLayout; ResourceId descSet; - std::vector offsets; + rdcarray offsets; }; - std::vector descSets; + rdcarray descSets; }; struct VulkanRenderState @@ -69,8 +68,8 @@ struct VulkanRenderState bool IsConditionalRenderingEnabled(); // dynamic state - std::vector views; - std::vector scissors; + rdcarray views; + rdcarray scissors; float lineWidth = 1.0f; struct { @@ -92,10 +91,10 @@ struct VulkanRenderState { VkSampleCountFlagBits sampleCount; VkExtent2D gridSize; - std::vector locations; + rdcarray locations; } sampleLocations; - std::vector discardRectangles; + rdcarray discardRectangles; uint32_t stippleFactor = 0; uint16_t stipplePattern = 0; @@ -112,13 +111,13 @@ struct VulkanRenderState // only the framebuffer without updating the attachments void SetFramebuffer(ResourceId fb, const VkRenderPassAttachmentBeginInfoKHR *attachmentsInfo = NULL); - void SetFramebuffer(ResourceId fb, const std::vector &dynamicAttachments) + void SetFramebuffer(ResourceId fb, const rdcarray &dynamicAttachments) { framebuffer = fb; fbattachments = dynamicAttachments; } ResourceId GetFramebuffer() const { return framebuffer; } - const std::vector &GetFramebufferAttachments() const { return fbattachments; } + const rdcarray &GetFramebufferAttachments() const { return fbattachments; } // VkRect2D renderArea = {}; @@ -137,7 +136,7 @@ struct VulkanRenderState ResourceId buf; VkDeviceSize offs = 0; }; - std::vector vbuffers; + rdcarray vbuffers; struct XFBBuffer { @@ -145,7 +144,7 @@ struct VulkanRenderState VkDeviceSize offs = 0; VkDeviceSize size = 0; }; - std::vector xfbbuffers; + rdcarray xfbbuffers; struct XFBCounter { @@ -153,7 +152,7 @@ struct VulkanRenderState VkDeviceSize offs = 0; }; uint32_t firstxfbcounter = 0; - std::vector xfbcounters; + rdcarray xfbcounters; struct ConditionalRendering { @@ -170,5 +169,5 @@ struct VulkanRenderState private: ResourceId framebuffer; - std::vector fbattachments; + rdcarray fbattachments; }; diff --git a/renderdoc/driver/vulkan/vk_win32.cpp b/renderdoc/driver/vulkan/vk_win32.cpp index 1d6d9a3fd..2e3f99977 100644 --- a/renderdoc/driver/vulkan/vk_win32.cpp +++ b/renderdoc/driver/vulkan/vk_win32.cpp @@ -84,8 +84,8 @@ bool VulkanReplay::IsOutputWindowVisible(uint64_t id) return (IsWindowVisible(m_OutputWindows[id].wnd) == TRUE); } -void WrappedVulkan::AddRequiredExtensions(bool instance, std::vector &extensionList, - const std::set &supportedExtensions) +void WrappedVulkan::AddRequiredExtensions(bool instance, rdcarray &extensionList, + const std::set &supportedExtensions) { bool device = !instance; @@ -99,8 +99,7 @@ void WrappedVulkan::AddRequiredExtensions(bool instance, std::vector *ot while(ret == ERROR_SUCCESS) { // convert the name here so we preserve casing - std::string utf8name = StringFormat::Wide2UTF8(name); + rdcstr utf8name = StringFormat::Wide2UTF8(name); for(DWORD i = 0; i <= nameSize && name[i]; i++) name[i] = towlower(name[i]); diff --git a/renderdoc/driver/vulkan/wrappers/vk_cmd_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_cmd_funcs.cpp index 9443470d5..fc2daf7de 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_cmd_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_cmd_funcs.cpp @@ -24,7 +24,7 @@ #include "../vk_core.h" -static std::string ToHumanStr(const VkAttachmentLoadOp &el) +static rdcstr ToHumanStr(const VkAttachmentLoadOp &el) { BEGIN_ENUM_STRINGISE(VkAttachmentLoadOp); { @@ -35,7 +35,7 @@ static std::string ToHumanStr(const VkAttachmentLoadOp &el) END_ENUM_STRINGISE(); } -static std::string ToHumanStr(const VkAttachmentStoreOp &el) +static rdcstr ToHumanStr(const VkAttachmentStoreOp &el) { BEGIN_ENUM_STRINGISE(VkAttachmentStoreOp); { @@ -57,7 +57,7 @@ void WrappedVulkan::AddImplicitResolveResourceUsage(uint32_t subpass) else subpass = m_BakedCmdBufferInfo[m_LastCmdBufferID].state.subpass; - const std::vector &fbattachments = + const rdcarray &fbattachments = m_BakedCmdBufferInfo[m_LastCmdBufferID].state.fbattachments; for(size_t i = 0; i < rpinfo.subpasses[subpass].resolveAttachments.size(); i++) { @@ -71,10 +71,10 @@ void WrappedVulkan::AddImplicitResolveResourceUsage(uint32_t subpass) } } -std::vector WrappedVulkan::GetImplicitRenderPassBarriers(uint32_t subpass) +rdcarray WrappedVulkan::GetImplicitRenderPassBarriers(uint32_t subpass) { ResourceId rp, fb; - std::vector fbattachments; + rdcarray fbattachments; if(m_LastCmdBufferID == ResourceId()) { @@ -89,12 +89,12 @@ std::vector WrappedVulkan::GetImplicitRenderPassBarriers(u fbattachments = m_BakedCmdBufferInfo[m_LastCmdBufferID].state.fbattachments; } - std::vector ret; + rdcarray ret; VulkanCreationInfo::Framebuffer fbinfo = m_CreationInfo.m_Framebuffer[fb]; VulkanCreationInfo::RenderPass rpinfo = m_CreationInfo.m_RenderPass[rp]; - std::vector atts; + rdcarray atts; // a bit of dancing to get a subpass index. Because we don't increment // the subpass counter on EndRenderPass the value is the same for the last @@ -246,27 +246,22 @@ std::vector WrappedVulkan::GetImplicitRenderPassBarriers(u } // erase any do-nothing barriers - for(auto it = ret.begin(); it != ret.end();) - { - if(it->oldLayout == it->newLayout) - it = ret.erase(it); - else - ++it; - } + ret.removeIf( + [](const VkImageMemoryBarrier &barrier) { return barrier.oldLayout == barrier.newLayout; }); return ret; } -std::string WrappedVulkan::MakeRenderPassOpString(bool store) +rdcstr WrappedVulkan::MakeRenderPassOpString(bool store) { - std::string opDesc = ""; + rdcstr opDesc = ""; const VulkanCreationInfo::RenderPass &info = m_CreationInfo.m_RenderPass[m_BakedCmdBufferInfo[m_LastCmdBufferID].state.renderPass]; const VulkanCreationInfo::Framebuffer &fbinfo = m_CreationInfo.m_Framebuffer[m_BakedCmdBufferInfo[m_LastCmdBufferID].state.framebuffer]; - const std::vector &atts = info.attachments; + const rdcarray &atts = info.attachments; if(atts.empty()) { @@ -291,7 +286,7 @@ std::string WrappedVulkan::MakeRenderPassOpString(bool store) depthonly = info.subpasses[subpass].colorAttachments.size() == 0; } - const std::vector &cols = info.subpasses[subpass].colorAttachments; + const rdcarray &cols = info.subpasses[subpass].colorAttachments; // we check all non-UNUSED attachments to see if they're all the same. // To begin with we point to an invalid attachment index @@ -707,8 +702,7 @@ bool WrappedVulkan::Serialise_vkBeginCommandBuffer(SerialiserType &ser, VkComman // check for partial execution of this command buffer for(int p = 0; p < ePartialNum; p++) { - const std::vector &submissions = - m_Partial[p].cmdBufferSubmits[BakedCommandBuffer]; + const rdcarray &submissions = m_Partial[p].cmdBufferSubmits[BakedCommandBuffer]; for(auto it = submissions.begin(); it != submissions.end(); ++it) { @@ -997,19 +991,19 @@ bool WrappedVulkan::Serialise_vkEndCommandBuffer(SerialiserType &ser, VkCommandB // subpass uint32_t &sub = m_BakedCmdBufferInfo[m_LastCmdBufferID].state.subpass; - std::vector > imgbarriers; + rdcarray > imgbarriers; for(sub = m_RenderState.subpass; sub < numSubpasses - 1; sub++) { ObjDisp(commandBuffer)->CmdNextSubpass(Unwrap(commandBuffer), VK_SUBPASS_CONTENTS_INLINE); - std::vector subpassBarriers = GetImplicitRenderPassBarriers(); + rdcarray subpassBarriers = GetImplicitRenderPassBarriers(); GetResourceManager()->RecordBarriers( imgbarriers, m_ImageLayouts, (uint32_t)subpassBarriers.size(), &subpassBarriers[0]); } - std::vector finalBarriers = GetImplicitRenderPassBarriers(~0U); + rdcarray finalBarriers = GetImplicitRenderPassBarriers(~0U); GetResourceManager()->RecordBarriers(imgbarriers, m_ImageLayouts, (uint32_t)finalBarriers.size(), &finalBarriers[0]); @@ -1018,7 +1012,7 @@ bool WrappedVulkan::Serialise_vkEndCommandBuffer(SerialiserType &ser, VkCommandB // undo any implicit transitions we just went through, so that we can pretend that the // image stayed in the same layout as it was when we stopped partially replaying. - std::vector revertBarriers; + rdcarray revertBarriers; for(auto it = imgbarriers.begin(); it != imgbarriers.end(); ++it) { @@ -1241,7 +1235,7 @@ bool WrappedVulkan::Serialise_vkCmdBeginRenderPass(SerialiserType &ser, VkComman ObjDisp(commandBuffer)->CmdBeginRenderPass(Unwrap(commandBuffer), &unwrappedInfo, contents); - std::vector imgBarriers = GetImplicitRenderPassBarriers(); + rdcarray imgBarriers = GetImplicitRenderPassBarriers(); ResourceId cmd = GetResID(commandBuffer); GetResourceManager()->RecordBarriers(m_BakedCmdBufferInfo[cmd].imgbarriers, m_ImageLayouts, @@ -1283,7 +1277,7 @@ bool WrappedVulkan::Serialise_vkCmdBeginRenderPass(SerialiserType &ser, VkComman } } - std::vector imgBarriers = GetImplicitRenderPassBarriers(); + rdcarray imgBarriers = GetImplicitRenderPassBarriers(); ResourceId cmd = GetResID(commandBuffer); GetResourceManager()->RecordBarriers(m_BakedCmdBufferInfo[cmd].imgbarriers, m_ImageLayouts, @@ -1335,7 +1329,7 @@ void WrappedVulkan::vkCmdBeginRenderPass(VkCommandBuffer commandBuffer, record->MarkResourceFrameReferenced(fb->GetResourceID(), eFrameRef_Read); - std::vector &barriers = record->cmdInfo->rpbarriers; + rdcarray &barriers = record->cmdInfo->rpbarriers; barriers.clear(); @@ -1414,7 +1408,7 @@ bool WrappedVulkan::Serialise_vkCmdNextSubpass(SerialiserType &ser, VkCommandBuf ObjDisp(commandBuffer)->CmdNextSubpass(Unwrap(commandBuffer), contents); - std::vector imgBarriers = GetImplicitRenderPassBarriers(); + rdcarray imgBarriers = GetImplicitRenderPassBarriers(); ResourceId cmd = GetResID(commandBuffer); GetResourceManager()->RecordBarriers(m_BakedCmdBufferInfo[cmd].imgbarriers, m_ImageLayouts, @@ -1430,7 +1424,7 @@ bool WrappedVulkan::Serialise_vkCmdNextSubpass(SerialiserType &ser, VkCommandBuf // track while reading, for fetching the right set of outputs in AddDrawcall m_BakedCmdBufferInfo[m_LastCmdBufferID].state.subpass++; - std::vector imgBarriers = GetImplicitRenderPassBarriers(); + rdcarray imgBarriers = GetImplicitRenderPassBarriers(); ResourceId cmd = GetResID(commandBuffer); GetResourceManager()->RecordBarriers(m_BakedCmdBufferInfo[cmd].imgbarriers, m_ImageLayouts, @@ -1487,7 +1481,7 @@ bool WrappedVulkan::Serialise_vkCmdEndRenderPass(SerialiserType &ser, VkCommandB { commandBuffer = RerecordCmdBuf(m_LastCmdBufferID); - std::vector imgBarriers = GetImplicitRenderPassBarriers(~0U); + rdcarray imgBarriers = GetImplicitRenderPassBarriers(~0U); // always track this, for WrappedVulkan::IsDrawInRenderPass() m_BakedCmdBufferInfo[m_LastCmdBufferID].state.renderPass = ResourceId(); @@ -1517,7 +1511,7 @@ bool WrappedVulkan::Serialise_vkCmdEndRenderPass(SerialiserType &ser, VkCommandB m_BakedCmdBufferInfo[m_LastCmdBufferID].indirectCopies.clear(); - std::vector imgBarriers = GetImplicitRenderPassBarriers(~0U); + rdcarray imgBarriers = GetImplicitRenderPassBarriers(~0U); ResourceId cmd = GetResID(commandBuffer); GetResourceManager()->RecordBarriers(m_BakedCmdBufferInfo[cmd].imgbarriers, m_ImageLayouts, @@ -1560,7 +1554,7 @@ void WrappedVulkan::vkCmdEndRenderPass(VkCommandBuffer commandBuffer) record->AddChunk(scope.Get()); - const std::vector &barriers = record->cmdInfo->rpbarriers; + const rdcarray &barriers = record->cmdInfo->rpbarriers; // apply the implicit layout transitions here { @@ -1657,7 +1651,7 @@ bool WrappedVulkan::Serialise_vkCmdBeginRenderPass2KHR(SerialiserType &ser, ObjDisp(commandBuffer) ->CmdBeginRenderPass2KHR(Unwrap(commandBuffer), &unwrappedInfo, &unwrappedBeginInfo); - std::vector imgBarriers = GetImplicitRenderPassBarriers(); + rdcarray imgBarriers = GetImplicitRenderPassBarriers(); ResourceId cmd = GetResID(commandBuffer); GetResourceManager()->RecordBarriers(m_BakedCmdBufferInfo[cmd].imgbarriers, m_ImageLayouts, @@ -1700,7 +1694,7 @@ bool WrappedVulkan::Serialise_vkCmdBeginRenderPass2KHR(SerialiserType &ser, } } - std::vector imgBarriers = GetImplicitRenderPassBarriers(); + rdcarray imgBarriers = GetImplicitRenderPassBarriers(); ResourceId cmd = GetResID(commandBuffer); GetResourceManager()->RecordBarriers(m_BakedCmdBufferInfo[cmd].imgbarriers, m_ImageLayouts, @@ -1758,7 +1752,7 @@ void WrappedVulkan::vkCmdBeginRenderPass2KHR(VkCommandBuffer commandBuffer, record->MarkResourceFrameReferenced(fb->GetResourceID(), eFrameRef_Read); - std::vector &barriers = record->cmdInfo->rpbarriers; + rdcarray &barriers = record->cmdInfo->rpbarriers; barriers.clear(); @@ -1850,7 +1844,7 @@ bool WrappedVulkan::Serialise_vkCmdNextSubpass2KHR(SerialiserType &ser, VkComman ObjDisp(commandBuffer) ->CmdNextSubpass2KHR(Unwrap(commandBuffer), &unwrappedBeginInfo, &unwrappedEndInfo); - std::vector imgBarriers = GetImplicitRenderPassBarriers(); + rdcarray imgBarriers = GetImplicitRenderPassBarriers(); ResourceId cmd = GetResID(commandBuffer); GetResourceManager()->RecordBarriers(m_BakedCmdBufferInfo[cmd].imgbarriers, m_ImageLayouts, @@ -1867,7 +1861,7 @@ bool WrappedVulkan::Serialise_vkCmdNextSubpass2KHR(SerialiserType &ser, VkComman // track while reading, for fetching the right set of outputs in AddDrawcall m_BakedCmdBufferInfo[m_LastCmdBufferID].state.subpass++; - std::vector imgBarriers = GetImplicitRenderPassBarriers(); + rdcarray imgBarriers = GetImplicitRenderPassBarriers(); ResourceId cmd = GetResID(commandBuffer); GetResourceManager()->RecordBarriers(m_BakedCmdBufferInfo[cmd].imgbarriers, m_ImageLayouts, @@ -1947,7 +1941,7 @@ bool WrappedVulkan::Serialise_vkCmdEndRenderPass2KHR(SerialiserType &ser, { commandBuffer = RerecordCmdBuf(m_LastCmdBufferID); - std::vector imgBarriers = GetImplicitRenderPassBarriers(~0U); + rdcarray imgBarriers = GetImplicitRenderPassBarriers(~0U); // always track this, for WrappedVulkan::IsDrawInRenderPass() m_BakedCmdBufferInfo[m_LastCmdBufferID].state.renderPass = ResourceId(); @@ -1969,7 +1963,7 @@ bool WrappedVulkan::Serialise_vkCmdEndRenderPass2KHR(SerialiserType &ser, { ObjDisp(commandBuffer)->CmdEndRenderPass2KHR(Unwrap(commandBuffer), &unwrappedEndInfo); - std::vector imgBarriers = GetImplicitRenderPassBarriers(~0U); + rdcarray imgBarriers = GetImplicitRenderPassBarriers(~0U); ResourceId cmd = GetResID(commandBuffer); GetResourceManager()->RecordBarriers(m_BakedCmdBufferInfo[cmd].imgbarriers, m_ImageLayouts, @@ -2018,7 +2012,7 @@ void WrappedVulkan::vkCmdEndRenderPass2KHR(VkCommandBuffer commandBuffer, record->AddChunk(scope.Get()); - const std::vector &barriers = record->cmdInfo->rpbarriers; + const rdcarray &barriers = record->cmdInfo->rpbarriers; // apply the implicit layout transitions here { @@ -2207,7 +2201,7 @@ bool WrappedVulkan::Serialise_vkCmdBindDescriptorSets( if(ShouldUpdateRenderState(m_LastCmdBufferID)) { - std::vector &descsets = + rdcarray &descsets = (pipelineBindPoint == VK_PIPELINE_BIND_POINT_GRAPHICS) ? m_RenderState.graphics.descSets : m_RenderState.compute.descSets; @@ -2216,7 +2210,7 @@ bool WrappedVulkan::Serialise_vkCmdBindDescriptorSets( if(descsets.size() < firstSet + setCount) descsets.resize(firstSet + setCount); - const std::vector &descSetLayouts = + const rdcarray &descSetLayouts = m_CreationInfo.m_PipelineLayout[GetResID(layout)].descSetLayouts; const uint32_t *offsIter = pDynamicOffsets; @@ -2229,7 +2223,7 @@ bool WrappedVulkan::Serialise_vkCmdBindDescriptorSets( descsets[firstSet + i].descSet = GetResID(pDescriptorSets[i]); uint32_t dynCount = m_CreationInfo.m_DescSetLayout[descSetLayouts[firstSet + i]].dynamicCount; - descsets[firstSet + i].offsets.assign(offsIter, offsIter + dynCount); + descsets[firstSet + i].offsets.assign(offsIter, dynCount); offsIter += dynCount; dynConsumed += dynCount; RDCASSERT(dynConsumed <= dynamicOffsetCount); @@ -2277,7 +2271,7 @@ bool WrappedVulkan::Serialise_vkCmdBindDescriptorSets( else { // track while reading, as we need to track resource usage - std::vector &descsets = + rdcarray &descsets = (pipelineBindPoint == VK_PIPELINE_BIND_POINT_GRAPHICS) ? m_BakedCmdBufferInfo[m_LastCmdBufferID].state.graphicsDescSets : m_BakedCmdBufferInfo[m_LastCmdBufferID].state.computeDescSets; @@ -2732,8 +2726,8 @@ bool WrappedVulkan::Serialise_vkCmdPipelineBarrier( SERIALISE_CHECK_READ_ERRORS(); - std::vector imgBarriers; - std::vector bufBarriers; + rdcarray imgBarriers; + rdcarray bufBarriers; // it's possible for buffer or image to be NULL if it refers to a resource that is otherwise // not in the log (barriers do not mark resources referenced). If the resource in question does @@ -3211,7 +3205,7 @@ bool WrappedVulkan::Serialise_vkCmdExecuteCommands(SerialiserType &ser, VkComman // append deferred indirect copies { - std::vector &dstIndirect = + rdcarray &dstIndirect = m_BakedCmdBufferInfo[m_LastCmdBufferID].indirectCopies; for(uint32_t i = 0; i < commandBufferCount; i++) @@ -3219,10 +3213,8 @@ bool WrappedVulkan::Serialise_vkCmdExecuteCommands(SerialiserType &ser, VkComman // indirectCopies are stored in m_BakedCmdBufferInfo[m_LastCmdBufferID] which is an // original ID ResourceId origId = GetResourceManager()->GetOriginalID(GetResID(pCommandBuffers[i])); - const std::vector &srcIndirect = - m_BakedCmdBufferInfo[origId].indirectCopies; - dstIndirect.insert(dstIndirect.end(), srcIndirect.begin(), srcIndirect.end()); + dstIndirect.append(m_BakedCmdBufferInfo[origId].indirectCopies); } } @@ -3398,7 +3390,7 @@ bool WrappedVulkan::Serialise_vkCmdExecuteCommands(SerialiserType &ser, VkComman uint32_t eid = startEID; - std::vector rerecordedCmds; + rdcarray rerecordedCmds; for(uint32_t c = 0; c < commandBufferCount; c++) { @@ -3724,11 +3716,11 @@ void WrappedVulkan::ApplyPushDescriptorWrites(VkPipelineBindPoint pipelineBindPo ResourceId setId = m_BakedCmdBufferInfo[m_LastCmdBufferID].pushDescriptorID[pipelineBindPoint][set]; - const std::vector &descSetLayouts = pipeLayoutInfo.descSetLayouts; + const rdcarray &descSetLayouts = pipeLayoutInfo.descSetLayouts; const DescSetLayout &desclayout = m_CreationInfo.m_DescSetLayout[descSetLayouts[set]]; - std::vector &bindings = m_DescriptorSetState[setId].currentBindings; + rdcarray &bindings = m_DescriptorSetState[setId].currentBindings; ResourceId prevLayout = m_DescriptorSetState[setId].layout; if(prevLayout == ResourceId()) @@ -3854,7 +3846,7 @@ bool WrappedVulkan::Serialise_vkCmdPushDescriptorSetKHR(SerialiserType &ser, if(ShouldUpdateRenderState(m_LastCmdBufferID)) { - std::vector &descsets = + rdcarray &descsets = (pipelineBindPoint == VK_PIPELINE_BIND_POINT_GRAPHICS) ? m_RenderState.graphics.descSets : m_RenderState.compute.descSets; @@ -3877,7 +3869,7 @@ bool WrappedVulkan::Serialise_vkCmdPushDescriptorSetKHR(SerialiserType &ser, else { // track while reading, as we need to track resource usage - std::vector &descsets = + rdcarray &descsets = (pipelineBindPoint == VK_PIPELINE_BIND_POINT_GRAPHICS) ? m_BakedCmdBufferInfo[m_LastCmdBufferID].state.graphicsDescSets : m_BakedCmdBufferInfo[m_LastCmdBufferID].state.computeDescSets; @@ -4123,7 +4115,7 @@ bool WrappedVulkan::Serialise_vkCmdPushDescriptorSetWithTemplateKHR( if(ShouldUpdateRenderState(m_LastCmdBufferID)) { - std::vector &descsets = + rdcarray &descsets = (bindPoint == VK_PIPELINE_BIND_POINT_GRAPHICS) ? m_RenderState.graphics.descSets : m_RenderState.compute.descSets; @@ -4145,7 +4137,7 @@ bool WrappedVulkan::Serialise_vkCmdPushDescriptorSetWithTemplateKHR( else { // track while reading, as we need to track resource usage - std::vector &descsets = + rdcarray &descsets = (m_CreationInfo.m_DescUpdateTemplate[GetResID(descriptorUpdateTemplate)].bindPoint == VK_PIPELINE_BIND_POINT_GRAPHICS) ? m_BakedCmdBufferInfo[m_LastCmdBufferID].state.graphicsDescSets @@ -4211,10 +4203,10 @@ void WrappedVulkan::vkCmdPushDescriptorSetWithTemplateKHR( // since it's relatively expensive to walk the memory, we gather frame references at the same time // as unwrapping - std::vector > frameRefs; - std::vector > imgViewFrameRefs; - std::vector > bufViewFrameRefs; - std::vector > bufFrameRefs; + rdcarray > frameRefs; + rdcarray > imgViewFrameRefs; + rdcarray > bufViewFrameRefs; + rdcarray > bufFrameRefs; { DescUpdateTemplate *tempInfo = GetRecord(descriptorUpdateTemplate)->descTemplateInfo; diff --git a/renderdoc/driver/vulkan/wrappers/vk_descriptor_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_descriptor_funcs.cpp index 6f690c6c9..8fdf328d8 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_descriptor_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_descriptor_funcs.cpp @@ -653,7 +653,7 @@ void WrappedVulkan::ReplayDescriptorSetWrite(VkDevice device, const VkWriteDescr ObjDisp(device)->UpdateDescriptorSets(Unwrap(device), 1, &unwrapped, 0, NULL); // update our local tracking - std::vector &bindings = + rdcarray &bindings = m_DescriptorSetState[GetResID(writeDesc.dstSet)].currentBindings; { @@ -744,8 +744,8 @@ void WrappedVulkan::ReplayDescriptorSetCopy(VkDevice device, const VkCopyDescrip ResourceId srcSetId = GetResID(copyDesc.srcSet); // update our local tracking - std::vector &dstbindings = m_DescriptorSetState[dstSetId].currentBindings; - std::vector &srcbindings = m_DescriptorSetState[srcSetId].currentBindings; + rdcarray &dstbindings = m_DescriptorSetState[dstSetId].currentBindings; + rdcarray &srcbindings = m_DescriptorSetState[srcSetId].currentBindings; { RDCASSERT(copyDesc.dstBinding < dstbindings.size()); diff --git a/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp index 9e3d2f8a1..492fa9354 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp @@ -93,90 +93,78 @@ void InitInstanceTable(VkInstance inst, PFN_vkGetInstanceProcAddr gpa); // and // instance are destroyed. We only clean up after our own objects. -static void StripUnwantedLayers(std::vector &Layers) +static void StripUnwantedLayers(rdcarray &Layers) { - for(auto it = Layers.begin(); it != Layers.end();) - { + Layers.removeIf([](const rdcstr &layer) { // don't try and create our own layer on replay! - if(*it == RENDERDOC_VULKAN_LAYER_NAME) + if(layer == RENDERDOC_VULKAN_LAYER_NAME) { - it = Layers.erase(it); - continue; + return true; } // don't enable tracing or dumping layers just in case they // came along with the application - if(*it == "VK_LAYER_LUNARG_api_dump" || *it == "VK_LAYER_LUNARG_vktrace") + if(layer == "VK_LAYER_LUNARG_api_dump" || layer == "VK_LAYER_LUNARG_vktrace") { - it = Layers.erase(it); - continue; + return true; } // also remove the framerate monitor layer as it's buggy and doesn't do anything // in our case - if(*it == "VK_LAYER_LUNARG_monitor") + if(layer == "VK_LAYER_LUNARG_monitor") { - it = Layers.erase(it); - continue; + return true; } // remove the optimus layer just in case it was explicitly enabled. - if(*it == "VK_LAYER_NV_optimus") + if(layer == "VK_LAYER_NV_optimus") { - it = Layers.erase(it); - continue; + return true; } // filter out validation layers - if(*it == "VK_LAYER_LUNARG_standard_validation" || *it == "VK_LAYER_KHRONOS_validation" || - *it == "VK_LAYER_LUNARG_core_validation" || *it == "VK_LAYER_LUNARG_device_limits" || - *it == "VK_LAYER_LUNARG_image" || *it == "VK_LAYER_LUNARG_object_tracker" || - *it == "VK_LAYER_LUNARG_parameter_validation" || *it == "VK_LAYER_LUNARG_swapchain" || - *it == "VK_LAYER_GOOGLE_threading" || *it == "VK_LAYER_GOOGLE_unique_objects" || - *it == "VK_LAYER_LUNARG_assistant_layer") + if(layer == "VK_LAYER_LUNARG_standard_validation" || layer == "VK_LAYER_KHRONOS_validation" || + layer == "VK_LAYER_LUNARG_core_validation" || layer == "VK_LAYER_LUNARG_device_limits" || + layer == "VK_LAYER_LUNARG_image" || layer == "VK_LAYER_LUNARG_object_tracker" || + layer == "VK_LAYER_LUNARG_parameter_validation" || layer == "VK_LAYER_LUNARG_swapchain" || + layer == "VK_LAYER_GOOGLE_threading" || layer == "VK_LAYER_GOOGLE_unique_objects" || + layer == "VK_LAYER_LUNARG_assistant_layer") { - it = Layers.erase(it); - continue; + return true; } - ++it; - } + return false; + }); } -static void StripUnwantedExtensions(std::vector &Extensions) +static void StripUnwantedExtensions(rdcarray &Extensions) { // strip out any WSI/direct display extensions. We'll add the ones we want for creating windows // on the current platforms below, and we don't replay any of the WSI functionality // directly so these extensions aren't needed - for(auto it = Extensions.begin(); it != Extensions.end();) - { + Extensions.removeIf([](const rdcstr &ext) { // remove surface extensions - if(*it == "VK_KHR_xlib_surface" || *it == "VK_KHR_xcb_surface" || - *it == "VK_KHR_wayland_surface" || *it == "VK_KHR_mir_surface" || - *it == "VK_MVK_macos_surface" || *it == "VK_KHR_android_surface" || - *it == "VK_KHR_win32_surface" || *it == "VK_GGP_stream_descriptor_surface") + if(ext == "VK_KHR_xlib_surface" || ext == "VK_KHR_xcb_surface" || + ext == "VK_KHR_wayland_surface" || ext == "VK_KHR_mir_surface" || + ext == "VK_MVK_macos_surface" || ext == "VK_KHR_android_surface" || + ext == "VK_KHR_win32_surface" || ext == "VK_GGP_stream_descriptor_surface") { - it = Extensions.erase(it); - continue; + return true; } // remove direct display extensions - if(*it == "VK_KHR_display" || *it == "VK_EXT_direct_mode_display" || - *it == "VK_EXT_acquire_xlib_display" || *it == "VK_EXT_display_surface_counter") + if(ext == "VK_KHR_display" || ext == "VK_EXT_direct_mode_display" || + ext == "VK_EXT_acquire_xlib_display" || ext == "VK_EXT_display_surface_counter") { - it = Extensions.erase(it); - continue; + return true; } // remove fullscreen exclusive extension - if(*it == "VK_EXT_full_screen_exclusive") - { - it = Extensions.erase(it); - continue; - } + if(ext == "VK_EXT_full_screen_exclusive") + return true; - ++it; - } + return false; + }); } ReplayStatus WrappedVulkan::Initialise(VkInitParams ¶ms, uint64_t sectionVersion, @@ -191,7 +179,7 @@ ReplayStatus WrappedVulkan::Initialise(VkInitParams ¶ms, uint64_t sectionVer StripUnwantedLayers(params.Layers); StripUnwantedExtensions(params.Extensions); - std::set supportedLayers; + std::set supportedLayers; { uint32_t count = 0; @@ -230,19 +218,17 @@ ReplayStatus WrappedVulkan::Initialise(VkInitParams ¶ms, uint64_t sectionVer } // complain about any missing layers, but remove them from the list and continue - for(auto it = params.Layers.begin(); it != params.Layers.end();) - { - if(supportedLayers.find(*it) == supportedLayers.end()) + params.Layers.removeIf([&supportedLayers](const rdcstr &layer) { + if(supportedLayers.find(layer) == supportedLayers.end()) { - RDCERR("Capture used layer '%s' which is not available, continuing without it", it->c_str()); - it = params.Layers.erase(it); - continue; + RDCERR("Capture used layer '%s' which is not available, continuing without it", layer.c_str()); + return true; } - ++it; - } + return false; + }); - std::set supportedExtensions; + std::set supportedExtensions; for(size_t i = 0; i <= params.Layers.size(); i++) { @@ -263,7 +249,7 @@ ReplayStatus WrappedVulkan::Initialise(VkInitParams ¶ms, uint64_t sectionVer if(!m_Replay->IsRemoteProxy()) { size_t i = 0; - for(const std::string &ext : supportedExtensions) + for(const rdcstr &ext : supportedExtensions) { RDCLOG("Inst Ext %u: %s", i, ext.c_str()); i++; @@ -279,8 +265,7 @@ ReplayStatus WrappedVulkan::Initialise(VkInitParams ¶ms, uint64_t sectionVer if(supportedExtensions.find(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME) != supportedExtensions.end()) { - if(std::find(params.Extensions.begin(), params.Extensions.end(), - VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME) == params.Extensions.end()) + if(!params.Extensions.contains(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME)) params.Extensions.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); } } @@ -294,8 +279,7 @@ ReplayStatus WrappedVulkan::Initialise(VkInitParams ¶ms, uint64_t sectionVer } else { - if(std::find(params.Extensions.begin(), params.Extensions.end(), - VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME) == params.Extensions.end()) + if(!params.Extensions.contains(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME)) params.Extensions.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); } } @@ -312,16 +296,14 @@ ReplayStatus WrappedVulkan::Initialise(VkInitParams ¶ms, uint64_t sectionVer // we always want debug extensions if it available, and not already enabled if(supportedExtensions.find(VK_EXT_DEBUG_UTILS_EXTENSION_NAME) != supportedExtensions.end() && - std::find(params.Extensions.begin(), params.Extensions.end(), - VK_EXT_DEBUG_UTILS_EXTENSION_NAME) == params.Extensions.end()) + !params.Extensions.contains(VK_EXT_DEBUG_UTILS_EXTENSION_NAME)) { if(!m_Replay->IsRemoteProxy()) RDCLOG("Enabling VK_EXT_debug_utils"); params.Extensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME); } else if(supportedExtensions.find(VK_EXT_DEBUG_REPORT_EXTENSION_NAME) != supportedExtensions.end() && - std::find(params.Extensions.begin(), params.Extensions.end(), - VK_EXT_DEBUG_REPORT_EXTENSION_NAME) == params.Extensions.end()) + !params.Extensions.contains(VK_EXT_DEBUG_REPORT_EXTENSION_NAME)) { if(!m_Replay->IsRemoteProxy()) RDCLOG("Enabling VK_EXT_debug_report"); @@ -341,8 +323,7 @@ ReplayStatus WrappedVulkan::Initialise(VkInitParams ¶ms, uint64_t sectionVer void *instNext = NULL; if(supportedExtensions.find(VK_EXT_VALIDATION_FEATURES_EXTENSION_NAME) != supportedExtensions.end() && - std::find(params.Extensions.begin(), params.Extensions.end(), - VK_EXT_VALIDATION_FEATURES_EXTENSION_NAME) == params.Extensions.end()) + !params.Extensions.contains(VK_EXT_VALIDATION_FEATURES_EXTENSION_NAME)) { if(!m_Replay->IsRemoteProxy()) RDCLOG("Enabling VK_EXT_validation_features"); @@ -352,8 +333,7 @@ ReplayStatus WrappedVulkan::Initialise(VkInitParams ¶ms, uint64_t sectionVer } else if(supportedExtensions.find(VK_EXT_VALIDATION_FLAGS_EXTENSION_NAME) != supportedExtensions.end() && - std::find(params.Extensions.begin(), params.Extensions.end(), - VK_EXT_VALIDATION_FLAGS_EXTENSION_NAME) == params.Extensions.end()) + !params.Extensions.contains(VK_EXT_VALIDATION_FLAGS_EXTENSION_NAME)) { if(!m_Replay->IsRemoteProxy()) RDCLOG("Enabling VK_EXT_validation_flags"); @@ -581,7 +561,7 @@ VkResult WrappedVulkan::vkCreateInstance(const VkInstanceCreateInfo *pCreateInfo hasDebugUtils = true; } - std::vector supportedExts; + rdcarray supportedExts; // enumerate what instance extensions are available void *module = LoadVulkanLibrary(); @@ -685,16 +665,16 @@ VkResult WrappedVulkan::vkCreateInstance(const VkInstanceCreateInfo *pCreateInfo if(renderdocAppInfo.apiVersion > VK_API_VERSION_1_0) record->instDevInfo->vulkanVersion = renderdocAppInfo.apiVersion; - std::set availablePhysDeviceFunctions; + std::set availablePhysDeviceFunctions; { uint32_t count = 0; ObjDisp(m_Instance)->EnumeratePhysicalDevices(Unwrap(m_Instance), &count, NULL); - std::vector physDevs(count); + rdcarray physDevs(count); ObjDisp(m_Instance)->EnumeratePhysicalDevices(Unwrap(m_Instance), &count, physDevs.data()); - std::vector exts; + rdcarray exts; for(VkPhysicalDevice p : physDevs) { ObjDisp(m_Instance)->EnumerateDeviceExtensionProperties(p, NULL, &count, NULL); @@ -1435,7 +1415,7 @@ bool WrappedVulkan::Serialise_vkCreateDevice(SerialiserType &ser, VkPhysicalDevi // in the serialised VkDeviceCreateInfo don't double-free VkDeviceCreateInfo createInfo = CreateInfo; - std::vector Extensions; + rdcarray Extensions; for(uint32_t i = 0; i < createInfo.enabledExtensionCount; i++) { // don't include the debug marker extension @@ -1454,13 +1434,13 @@ bool WrappedVulkan::Serialise_vkCreateDevice(SerialiserType &ser, VkPhysicalDevi Extensions.push_back(createInfo.ppEnabledExtensionNames[i]); } - std::vector Layers; + rdcarray Layers; for(uint32_t i = 0; i < createInfo.enabledLayerCount; i++) Layers.push_back(createInfo.ppEnabledLayerNames[i]); StripUnwantedLayers(Layers); - std::set supportedExtensions; + std::set supportedExtensions; for(size_t i = 0; i <= Layers.size(); i++) { @@ -1811,7 +1791,7 @@ bool WrappedVulkan::Serialise_vkCreateDevice(SerialiserType &ser, VkPhysicalDevi } // remove any duplicates that have been created - std::vector queueInfos; + rdcarray queueInfos; for(uint32_t i = 0; i < createInfo.queueCreateInfoCount; i++) { @@ -2510,10 +2490,7 @@ bool WrappedVulkan::Serialise_vkCreateDevice(SerialiserType &ser, VkPhysicalDevi "VK_KHR_pipeline_executable_properties is available, but the physical device feature " "is not. Disabling"); - auto it = std::find(Extensions.begin(), Extensions.end(), - VK_KHR_PIPELINE_EXECUTABLE_PROPERTIES_EXTENSION_NAME); - RDCASSERT(it != Extensions.end()); - Extensions.erase(it); + Extensions.removeOne(VK_KHR_PIPELINE_EXECUTABLE_PROPERTIES_EXTENSION_NAME); } } @@ -2556,10 +2533,7 @@ bool WrappedVulkan::Serialise_vkCreateDevice(SerialiserType &ser, VkPhysicalDevi "VK_EXT_transform_feedback is available, but the physical device feature is not. " "Disabling"); - auto it = std::find(Extensions.begin(), Extensions.end(), - VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME); - RDCASSERT(it != Extensions.end()); - Extensions.erase(it); + Extensions.removeOne(VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME); } } @@ -2598,21 +2572,18 @@ bool WrappedVulkan::Serialise_vkCreateDevice(SerialiserType &ser, VkPhysicalDevi } else { - auto it = - std::find(Extensions.begin(), Extensions.end(), VK_KHR_PERFORMANCE_QUERY_EXTENSION_NAME); - RDCASSERT(it != Extensions.end()); - Extensions.erase(it); + Extensions.removeOne(VK_KHR_PERFORMANCE_QUERY_EXTENSION_NAME); } } - std::vector layerArray(Layers.size()); + rdcarray layerArray(Layers.size()); for(size_t i = 0; i < Layers.size(); i++) layerArray[i] = Layers[i].c_str(); createInfo.enabledLayerCount = (uint32_t)layerArray.size(); createInfo.ppEnabledLayerNames = layerArray.data(); - std::vector extArray(Extensions.size()); + rdcarray extArray(Extensions.size()); for(size_t i = 0; i < Extensions.size(); i++) extArray[i] = Extensions[i].c_str(); @@ -2780,9 +2751,8 @@ VkResult WrappedVulkan::vkCreateDevice(VkPhysicalDevice physicalDevice, } } - std::vector Extensions( - createInfo.ppEnabledExtensionNames, - createInfo.ppEnabledExtensionNames + createInfo.enabledExtensionCount); + rdcarray Extensions(createInfo.ppEnabledExtensionNames, + createInfo.enabledExtensionCount); // enable VK_KHR_driver_properties if it's available { @@ -2897,8 +2867,7 @@ VkResult WrappedVulkan::vkCreateDevice(VkPhysicalDevice physicalDevice, for(uint32_t q = 0; q < count; q++) m_QueueFamilies[family][q] = VK_NULL_HANDLE; - if(std::find(m_QueueFamilyIndices.begin(), m_QueueFamilyIndices.end(), family) == - m_QueueFamilyIndices.end()) + if(!m_QueueFamilyIndices.contains(family)) m_QueueFamilyIndices.push_back(family); } diff --git a/renderdoc/driver/vulkan/wrappers/vk_draw_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_draw_funcs.cpp index 7746a57ed..4d13945b0 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_draw_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_draw_funcs.cpp @@ -600,7 +600,7 @@ bool WrappedVulkan::Serialise_vkCmdDrawIndirect(SerialiserType &ser, VkCommandBu m_IndirectBufferSize = RDCMAX(m_IndirectBufferSize, sizeof(VkDrawIndirectCommand) + (count > 0 ? count - 1 : 0) * stride); - std::string name = "vkCmdDrawIndirect"; + rdcstr name = "vkCmdDrawIndirect"; if(!IsDrawInRenderPass()) { @@ -978,7 +978,7 @@ bool WrappedVulkan::Serialise_vkCmdDrawIndexedIndirect(SerialiserType &ser, m_IndirectBufferSize = RDCMAX(m_IndirectBufferSize, sizeof(VkDrawIndexedIndirectCommand) + (count > 0 ? count - 1 : 0) * stride); - std::string name = "vkCmdDrawIndexedIndirect"; + rdcstr name = "vkCmdDrawIndexedIndirect"; if(!IsDrawInRenderPass()) { @@ -2306,7 +2306,7 @@ bool WrappedVulkan::Serialise_vkCmdClearAttachments(SerialiserType &ser, { AddEvent(); - std::string name = "vkCmdClearAttachments("; + rdcstr name = "vkCmdClearAttachments("; for(uint32_t a = 0; a < attachmentCount; a++) { name += ToStr(pAttachments[a].colorAttachment); @@ -2706,7 +2706,7 @@ bool WrappedVulkan::Serialise_vkCmdDrawIndirectCountKHR( RDCMAX(m_IndirectBufferSize, sizeof(VkDrawIndirectCommand) + (maxDrawCount > 0 ? maxDrawCount - 1 : 0) * stride); - std::string name = "vkCmdDrawIndirectCountKHR"; + rdcstr name = "vkCmdDrawIndirectCountKHR"; if(!IsDrawInRenderPass()) { @@ -3020,7 +3020,7 @@ bool WrappedVulkan::Serialise_vkCmdDrawIndexedIndirectCountKHR( RDCMAX(m_IndirectBufferSize, sizeof(VkDrawIndexedIndirectCommand) + (maxDrawCount > 0 ? maxDrawCount - 1 : 0) * stride); - std::string name = "vkCmdDrawIndexedIndirectCountKHR"; + rdcstr name = "vkCmdDrawIndexedIndirectCountKHR"; if(!IsDrawInRenderPass()) { @@ -3181,7 +3181,7 @@ bool WrappedVulkan::Serialise_vkCmdDrawIndirectByteCountEXT( Unwrap(counterBuffer), counterBufferOffset, counterOffset, vertexStride); - std::string name = "vkCmdDrawIndirectByteCountEXT"; + rdcstr name = "vkCmdDrawIndirectByteCountEXT"; if(!IsDrawInRenderPass()) { diff --git a/renderdoc/driver/vulkan/wrappers/vk_dynamic_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_dynamic_funcs.cpp index 2ee176c66..df3f30542 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_dynamic_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_dynamic_funcs.cpp @@ -625,10 +625,8 @@ bool WrappedVulkan::Serialise_vkCmdSetSampleLocationsEXT( if(ShouldUpdateRenderState(m_LastCmdBufferID)) { - m_RenderState.sampleLocations.locations.clear(); - m_RenderState.sampleLocations.locations.insert( - m_RenderState.sampleLocations.locations.begin(), sampleInfo.pSampleLocations, - sampleInfo.pSampleLocations + sampleInfo.sampleLocationsCount); + m_RenderState.sampleLocations.locations.assign(sampleInfo.pSampleLocations, + sampleInfo.sampleLocationsCount); m_RenderState.sampleLocations.gridSize = sampleInfo.sampleLocationGridSize; m_RenderState.sampleLocations.sampleCount = sampleInfo.sampleLocationsPerPixel; } diff --git a/renderdoc/driver/vulkan/wrappers/vk_misc_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_misc_funcs.cpp index e0e7cf248..580d6f75c 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_misc_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_misc_funcs.cpp @@ -1786,7 +1786,7 @@ static ObjData GetObjData(VkDebugReportObjectTypeEXT objType, uint64_t object) template bool WrappedVulkan::Serialise_SetShaderDebugPath(SerialiserType &ser, VkShaderModule ShaderObject, - std::string DebugPath) + rdcstr DebugPath) { SERIALISE_ELEMENT(ShaderObject); SERIALISE_ELEMENT(DebugPath); @@ -1815,8 +1815,7 @@ VkResult WrappedVulkan::vkDebugMarkerSetObjectTagEXT(VkDevice device, { CACHE_THREAD_SERIALISER(); - char *tag = (char *)pTagInfo->pTag; - std::string DebugPath = std::string(tag, tag + pTagInfo->tagSize); + rdcstr DebugPath = rdcstr((char *)pTagInfo->pTag, pTagInfo->tagSize); SCOPED_SERIALISE_CHUNK(VulkanChunk::SetShaderDebugPath); Serialise_SetShaderDebugPath(ser, (VkShaderModule)(uint64_t)data.record->Resource, DebugPath); @@ -2014,8 +2013,7 @@ VkResult WrappedVulkan::vkSetDebugUtilsObjectTagEXT(VkDevice device, { CACHE_THREAD_SERIALISER(); - char *tag = (char *)pTagInfo->pTag; - std::string DebugPath = std::string(tag, tag + pTagInfo->tagSize); + rdcstr DebugPath = rdcstr((char *)pTagInfo->pTag, pTagInfo->tagSize); SCOPED_SERIALISE_CHUNK(VulkanChunk::SetShaderDebugPath); Serialise_SetShaderDebugPath(ser, (VkShaderModule)(uint64_t)data.record->Resource, DebugPath); @@ -2055,7 +2053,7 @@ INSTANTIATE_FUNCTION_SERIALISED(VkResult, vkCreateQueryPool, VkDevice device, const VkAllocationCallbacks *pAllocator, VkQueryPool *pQueryPool); INSTANTIATE_FUNCTION_SERIALISED(void, SetShaderDebugPath, VkShaderModule ShaderObject, - std::string DebugPath); + rdcstr DebugPath); INSTANTIATE_FUNCTION_SERIALISED(VkResult, vkDebugMarkerSetObjectNameEXT, VkDevice device, const VkDebugMarkerObjectNameInfoEXT *pNameInfo); diff --git a/renderdoc/driver/vulkan/wrappers/vk_queue_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_queue_funcs.cpp index 307d6ed3c..2d0535a9f 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_queue_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_queue_funcs.cpp @@ -220,7 +220,7 @@ bool WrappedVulkan::Serialise_vkQueueSubmit(SerialiserType &ser, VkQueue queue, // insert in sorted location auto drawit = std::lower_bound(m_DrawcallUses.begin(), m_DrawcallUses.end(), use); - m_DrawcallUses.insert(drawit, use); + m_DrawcallUses.insert(drawit - m_DrawcallUses.begin(), use); } for(uint32_t sub = 0; sub < submitCount; sub++) @@ -259,7 +259,7 @@ bool WrappedVulkan::Serialise_vkQueueSubmit(SerialiserType &ser, VkQueue queue, // we're adding multiple events, need to increment ourselves m_RootEventID++; - std::string basename = StringFormat::Fmt("vkQueueSubmit(%u)", submitInfo.commandBufferCount); + rdcstr basename = StringFormat::Fmt("vkQueueSubmit(%u)", submitInfo.commandBufferCount); for(uint32_t c = 0; c < submitInfo.commandBufferCount; c++) { @@ -272,8 +272,8 @@ bool WrappedVulkan::Serialise_vkQueueSubmit(SerialiserType &ser, VkQueue queue, m_BakedCmdBufferInfo[liveCmd].imgbarriers, m_ImageLayouts); - std::string name = StringFormat::Fmt("=> %s[%u]: vkBeginCommandBuffer(%s)", - basename.c_str(), c, ToStr(cmd).c_str()); + rdcstr name = StringFormat::Fmt("=> %s[%u]: vkBeginCommandBuffer(%s)", basename.c_str(), + c, ToStr(cmd).c_str()); // add a fake marker DrawcallDescription draw; @@ -293,7 +293,7 @@ bool WrappedVulkan::Serialise_vkQueueSubmit(SerialiserType &ser, VkQueue queue, for(size_t e = 0; e < cmdBufInfo.draw->executedCmds.size(); e++) { - std::vector &submits = + rdcarray &submits = m_Partial[Secondary].cmdBufferSubmits[cmdBufInfo.draw->executedCmds[e]]; for(size_t s = 0; s < submits.size(); s++) @@ -374,7 +374,7 @@ bool WrappedVulkan::Serialise_vkQueueSubmit(SerialiserType &ser, VkQueue queue, uint32_t eid = startEID; - std::vector rerecordedCmds; + rdcarray rerecordedCmds; for(uint32_t c = 0; c < submitInfo.commandBufferCount; c++) { @@ -538,7 +538,7 @@ bool WrappedVulkan::PatchIndirectDraw(VkIndirectPatchType type, DrawcallDescript void WrappedVulkan::InsertDrawsAndRefreshIDs(BakedCmdBufferInfo &cmdBufInfo) { - std::vector &cmdBufNodes = cmdBufInfo.draw->children; + rdcarray &cmdBufNodes = cmdBufInfo.draw->children; // assign new drawcall IDs for(size_t i = 0; i < cmdBufNodes.size(); i++) @@ -616,10 +616,7 @@ void WrappedVulkan::InsertDrawsAndRefreshIDs(BakedCmdBufferInfo &cmdBufInfo) uint32_t shiftCount = n.indirectPatch.count - indirectCount; // i is the pushmarker, so i + 1 is the first of the sub draws. - // i + 1 + n.indirectPatch.count is the last of the draws, we don't want to erase the next - // one (the popmarker) - cmdBufNodes.erase(cmdBufNodes.begin() + i + 1 + indirectCount, - cmdBufNodes.begin() + i + 1 + n.indirectPatch.count); + cmdBufNodes.erase(i + 1 + indirectCount, shiftCount); for(size_t j = i + 1 + indirectCount; j < cmdBufNodes.size(); j++) { cmdBufNodes[j].draw.eventId -= shiftCount; @@ -640,7 +637,7 @@ void WrappedVulkan::InsertDrawsAndRefreshIDs(BakedCmdBufferInfo &cmdBufInfo) for(size_t e = 0; e < cmdBufInfo.draw->executedCmds.size(); e++) { - std::vector &submits = + rdcarray &submits = m_Partial[Secondary].cmdBufferSubmits[cmdBufInfo.draw->executedCmds[e]]; for(size_t s = 0; s < submits.size(); s++) @@ -718,7 +715,7 @@ void WrappedVulkan::InsertDrawsAndRefreshIDs(BakedCmdBufferInfo &cmdBufInfo) // insert in sorted location auto drawit = std::lower_bound(m_DrawcallUses.begin(), m_DrawcallUses.end(), use); - m_DrawcallUses.insert(drawit, use); + m_DrawcallUses.insert(drawit - m_DrawcallUses.begin(), use); } RDCASSERT(n.children.empty()); @@ -955,7 +952,7 @@ VkResult WrappedVulkan::vkQueueSubmit(VkQueue queue, uint32_t submitCount, if(fence != VK_NULL_HANDLE) GetResourceManager()->MarkResourceFrameReferenced(GetResID(fence), eFrameRef_Read); - std::vector maps; + rdcarray maps; { SCOPED_LOCK(m_CoherentMapsLock); maps = m_CoherentMaps; diff --git a/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp index f3da48d31..c3b8648d8 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp @@ -198,7 +198,7 @@ bool WrappedVulkan::CheckMemoryRequirements(const char *resourceName, ResourceId // verify type if((mrq.memoryTypeBits & bit) == 0) { - std::string bitsString; + rdcstr bitsString; for(uint32_t i = 0; i < 32; i++) { @@ -537,10 +537,7 @@ void WrappedVulkan::vkFreeMemory(VkDevice device, VkDeviceMemory memory, { SCOPED_LOCK(m_CoherentMapsLock); - - auto it = std::find(m_CoherentMaps.begin(), m_CoherentMaps.end(), wrapped->record); - if(it != m_CoherentMaps.end()) - m_CoherentMaps.erase(it); + m_CoherentMaps.removeOne(wrapped->record); } } @@ -714,11 +711,11 @@ void WrappedVulkan::vkUnmapMemory(VkDevice device, VkDeviceMemory mem) { SCOPED_LOCK(m_CoherentMapsLock); - auto it = std::find(m_CoherentMaps.begin(), m_CoherentMaps.end(), memrecord); - if(it == m_CoherentMaps.end()) + int32_t idx = m_CoherentMaps.indexOf(memrecord); + if(idx < 0) RDCERR("vkUnmapMemory for memory handle that's not currently mapped"); else - m_CoherentMaps.erase(it); + m_CoherentMaps.erase(idx); } } diff --git a/renderdoc/driver/vulkan/wrappers/vk_sync_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_sync_funcs.cpp index 47b4e0db4..a98af20ad 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_sync_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_sync_funcs.cpp @@ -775,8 +775,8 @@ bool WrappedVulkan::Serialise_vkCmdWaitEvents( SERIALISE_CHECK_READ_ERRORS(); - std::vector imgBarriers; - std::vector bufBarriers; + rdcarray imgBarriers; + rdcarray bufBarriers; // it's possible for buffer or image to be NULL if it refers to a resource that is otherwise // not in the log (barriers do not mark resources referenced). If the resource in question does diff --git a/renderdoc/driver/vulkan/wrappers/vk_wsi_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_wsi_funcs.cpp index b25007f07..abf6b35ae 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_wsi_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_wsi_funcs.cpp @@ -722,8 +722,8 @@ VkResult WrappedVulkan::vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR RDCWARN("Presenting multiple swapchains at once - only first will be processed"); } - std::vector unwrappedSwaps; - std::vector unwrappedSems; + rdcarray unwrappedSwaps; + rdcarray unwrappedSems; VkPresentInfoKHR unwrappedInfo = *pPresentInfo; @@ -835,8 +835,7 @@ VkResult WrappedVulkan::vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR m_TextRenderer->BeginText(textstate); int flags = activeWindow ? RenderDoc::eOverlay_ActiveWindow : 0; - std::string overlayText = - RenderDoc::Inst().GetOverlayText(RDCDriver::Vulkan, m_FrameCounter, flags); + rdcstr overlayText = RenderDoc::Inst().GetOverlayText(RDCDriver::Vulkan, m_FrameCounter, flags); if(!overlayText.empty()) m_TextRenderer->RenderText(textstate, 0.0f, 0.0f, overlayText.c_str()); @@ -852,8 +851,8 @@ VkResult WrappedVulkan::vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR ObjDisp(textstate.cmd)->EndCommandBuffer(Unwrap(textstate.cmd)); - std::vector waitStage(unwrappedSems.size(), - VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); + rdcarray waitStage; + waitStage.fill(unwrappedSems.size(), VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); SubmitCmds(unwrappedSems.data(), waitStage.data(), (uint32_t)unwrappedSems.size()); if(swapQueueIndex != m_QueueFamilyIdx)