diff --git a/renderdoc/3rdparty/catch/catch.cpp b/renderdoc/3rdparty/catch/catch.cpp index aa844bbca..f68b55b3d 100644 --- a/renderdoc/3rdparty/catch/catch.cpp +++ b/renderdoc/3rdparty/catch/catch.cpp @@ -28,6 +28,7 @@ #define CATCH_CONFIG_RUNNER #define CATCH_CONFIG_NOSTDOUT + #include "serialise/serialiser.h" #include "strings/string_utils.h" #include "catch.hpp" @@ -320,6 +321,8 @@ extern "C" RENDERDOC_API int RENDERDOC_CC RENDERDOC_RunUnitTests(const rdcstr &c #else #include "api/replay/apidefs.h" +#include "api/replay/rdcarray.h" +#include "api/replay/rdcstr.h" extern "C" RENDERDOC_API int RENDERDOC_CC RENDERDOC_RunUnitTests(const rdcstr &command, const rdcarray &args) diff --git a/renderdoc/android/android.cpp b/renderdoc/android/android.cpp index 9e880f158..79d82c802 100644 --- a/renderdoc/android/android.cpp +++ b/renderdoc/android/android.cpp @@ -23,6 +23,7 @@ ******************************************************************************/ #include "android.h" +#include #include #include "api/replay/version.h" #include "common/formatting.h" @@ -35,7 +36,7 @@ namespace Android { -void adbForwardPorts(uint16_t portbase, const std::string &deviceID, uint16_t jdwpPort, int pid, +void adbForwardPorts(uint16_t portbase, const rdcstr &deviceID, uint16_t jdwpPort, int pid, bool silent) { const char *forwardCommand = "forward tcp:%i localabstract:renderdoc_%i"; @@ -67,7 +68,7 @@ uint16_t GetJdwpPort() return portBase + portIndex; } -std::string GetDefaultActivityForPackage(const std::string &deviceID, const std::string &packageName) +rdcstr GetDefaultActivityForPackage(const rdcstr &deviceID, const rdcstr &packageName) { Process::ProcessResult activity = adbExecCommand(deviceID, StringFormat::Fmt("shell cmd package resolve-activity" @@ -135,7 +136,7 @@ std::string GetDefaultActivityForPackage(const std::string &deviceID, const std: return ""; } -int GetCurrentPID(const std::string &deviceID, const std::string &packageName) +int GetCurrentPID(const rdcstr &deviceID, const rdcstr &packageName) { // try 5 times, 200ms apart to find the pid for(int i = 0; i < 5; i++) @@ -182,13 +183,13 @@ int GetCurrentPID(const std::string &deviceID, const std::string &packageName) return 0; } -bool CheckAndroidServerVersion(const std::string &deviceID, ABI abi) +bool CheckAndroidServerVersion(const rdcstr &deviceID, ABI abi) { // assume all servers are updated at the same rate. Only check first ABI's version - std::string packageName = GetRenderDocPackageForABI(abi); + rdcstr packageName = GetRenderDocPackageForABI(abi); RDCLOG("Checking installed version of %s on %s", packageName.c_str(), deviceID.c_str()); - std::string dump = adbExecCommand(deviceID, "shell pm dump " + packageName).strStdout; + rdcstr dump = adbExecCommand(deviceID, "shell pm dump " + packageName).strStdout; if(dump.empty()) RDCERR("Unable to pm dump %s", packageName.c_str()); @@ -219,9 +220,9 @@ bool CheckAndroidServerVersion(const std::string &deviceID, ABI abi) } // Compare the server's versionCode and versionName with the host's for compatibility - std::string hostVersionCode = std::string(STRINGIZE(RENDERDOC_VERSION_MAJOR)) + - std::string(STRINGIZE(RENDERDOC_VERSION_MINOR)); - std::string hostVersionName = GitVersionHash; + rdcstr hostVersionCode = + rdcstr(STRINGIZE(RENDERDOC_VERSION_MAJOR)) + rdcstr(STRINGIZE(RENDERDOC_VERSION_MINOR)); + rdcstr hostVersionName = GitVersionHash; // False positives will hurt us, so check for explicit matches if((hostVersionCode == versionCode) && (hostVersionName == versionName)) @@ -237,11 +238,11 @@ bool CheckAndroidServerVersion(const std::string &deviceID, ABI abi) return false; } -ReplayStatus InstallRenderDocServer(const std::string &deviceID) +ReplayStatus InstallRenderDocServer(const rdcstr &deviceID) { ReplayStatus status = ReplayStatus::Succeeded; - std::vector abis = GetSupportedABIs(deviceID); + rdcarray abis = GetSupportedABIs(deviceID); if(abis.empty()) { @@ -254,7 +255,7 @@ ReplayStatus InstallRenderDocServer(const std::string &deviceID) FileIO::GetLibraryFilename(libPath); rdcstr libDir = get_dirname(FileIO::GetFullPathname(libPath)); - std::vector paths; + rdcarray paths; #if defined(RENDERDOC_APK_PATH) string customPath(RENDERDOC_APK_PATH); @@ -269,8 +270,7 @@ ReplayStatus InstallRenderDocServer(const std::string &deviceID) paths.push_back(customPath); #endif - std::string suff = GetRenderDocPackageForABI(abis[0], '-'); - suff.erase(0, strlen(RENDERDOC_ANDROID_PACKAGE_BASE)); + rdcstr suff = GetPlainABIName(abis[0]); paths.push_back(libDir + "/plugins/android/"); // Windows install paths.push_back(libDir + "/../share/renderdoc/plugins/android/"); // Linux install @@ -281,14 +281,14 @@ ReplayStatus InstallRenderDocServer(const std::string &deviceID) paths.push_back(libDir + "/../../../../../build-android" + suff + "/bin/"); // macOS ABI build // use the first ABI for searching - std::string apk = GetRenderDocPackageForABI(abis[0]); - std::string apksFolder; + rdcstr apk = GetRenderDocPackageForABI(abis[0]); + rdcstr apksFolder; for(uint32_t i = 0; i < paths.size(); i++) { RDCLOG("Checking for server APK in %s", paths[i].c_str()); - std::string apkpath = paths[i] + apk + ".apk"; + rdcstr apkpath = paths[i] + apk + ".apk"; if(FileIO::exists(apkpath.c_str())) { @@ -311,13 +311,9 @@ ReplayStatus InstallRenderDocServer(const std::string &deviceID) { apk = apksFolder; - size_t abiSuffix = apk.find(suff); - if(abiSuffix != std::string::npos) - { - std::string abisuff = GetRenderDocPackageForABI(abi, '-'); - abisuff.erase(0, strlen(RENDERDOC_ANDROID_PACKAGE_BASE)); - apk.replace(abiSuffix, suff.size(), abisuff); - } + int abiSuffix = apk.find(suff); + if(abiSuffix >= 0) + apk.replace(abiSuffix, suff.size(), GetPlainABIName(abi)); apk += GetRenderDocPackageForABI(abi) + ".apk"; @@ -374,9 +370,9 @@ ReplayStatus InstallRenderDocServer(const std::string &deviceID) return status; } -bool RemoveRenderDocAndroidServer(const std::string &deviceID) +bool RemoveRenderDocAndroidServer(const rdcstr &deviceID) { - std::vector abis = GetSupportedABIs(deviceID); + rdcarray abis = GetSupportedABIs(deviceID); if(abis.empty()) return false; @@ -386,13 +382,12 @@ bool RemoveRenderDocAndroidServer(const std::string &deviceID) for(ABI abi : abis) { - std::string packageName = GetRenderDocPackageForABI(abi); + rdcstr packageName = GetRenderDocPackageForABI(abi); adbExecCommand(deviceID, "uninstall " + packageName); // Ensure uninstall succeeded - std::string adbCheck = - adbExecCommand(deviceID, "shell pm list packages " + packageName).strStdout; + rdcstr adbCheck = adbExecCommand(deviceID, "shell pm list packages " + packageName).strStdout; if(!adbCheck.empty()) { @@ -404,7 +399,7 @@ bool RemoveRenderDocAndroidServer(const std::string &deviceID) return true; } -void ResetCaptureSettings(const std::string &deviceID) +void ResetCaptureSettings(const rdcstr &deviceID) { Android::adbExecCommand(deviceID, "shell setprop debug.vulkan.layers :", ".", true); Android::adbExecCommand(deviceID, "shell settings delete global enable_gpu_debug_layers", ".", @@ -423,7 +418,7 @@ rdcarray EnumerateDevices() rdcarray lines; split(adbStdout, lines, '\n'); - for(const std::string &line : lines) + for(const rdcstr &line : lines) { rdcarray tokens; split(line, tokens, '\t'); @@ -493,7 +488,7 @@ struct AndroidRemoteServer : public RemoteServer rdcarray lines; split(adbStdout, lines, '\n'); - std::vector packages; + rdcarray packages; for(const rdcstr &line : lines) { // hide our own internal packages @@ -522,7 +517,7 @@ struct AndroidRemoteServer : public RemoteServer bool activitySection = false; - for(const std::string &line : lines) + for(const rdcstr &line : lines) { // the activity section ends when we reach a line that starts at column 0, which is the // start of a section. Reset the flag to false @@ -530,7 +525,7 @@ struct AndroidRemoteServer : public RemoteServer activitySection = false; // if this is the start of the activity section, set the flag to true - if(line.find("Activity Resolver Table:") != std::string::npos) + if(line.contains("Activity Resolver Table:")) activitySection = true; // if the flag is false, skip @@ -538,7 +533,7 @@ struct AndroidRemoteServer : public RemoteServer continue; // quick check, look for a / - if(line.find('/') == std::string::npos) + if(!line.contains('/')) continue; // line should be something like: ' 78f9sba com.package.name/.NameOfActivity .....' @@ -560,7 +555,7 @@ struct AndroidRemoteServer : public RemoteServer c++; // expect the package now. Search to see if it's one of the ones we listed above - std::string package; + rdcstr package; for(const PathEntry &p : packages) if(!strncmp(c, p.filename.c_str(), p.filename.size())) @@ -598,7 +593,7 @@ struct AndroidRemoteServer : public RemoteServer if(!package.empty() && package[0] == '/') package.erase(0, 1); - std::vector activities; + rdcarray activities; for(const Activity &act : m_AndroidActivities) { @@ -836,7 +831,7 @@ struct AndroidController : public IDeviceProtocolHandler rdcarray packages; split(packagesOutput, packages, '\n'); - std::vector abis = Android::GetSupportedABIs(deviceID); + rdcarray abis = Android::GetSupportedABIs(deviceID); RDCLOG("Starting RenderDoc server, supported ABIs:"); for(Android::ABI abi : abis) @@ -955,8 +950,8 @@ ExecuteResult AndroidRemoteServer::ExecuteAndInject(const char *a, const char *w { LazilyStartLogcatThread(); - std::string packageAndActivity = a && a[0] ? a : ""; - std::string intentArgs = c && c[0] ? c : ""; + rdcstr packageAndActivity = a && a[0] ? a : ""; + rdcstr intentArgs = c && c[0] ? c : ""; // we spin up a thread to Ping() every second, since starting a package can block for a long time. volatile int32_t done = 0; @@ -972,11 +967,11 @@ ExecuteResult AndroidRemoteServer::ExecuteAndInject(const char *a, const char *w ret.status = ReplayStatus::UnknownError; ret.ident = RenderDoc_FirstTargetControlPort; - std::string packageName = + rdcstr packageName = Android::GetPackageName(packageAndActivity); // Remove leading '/' if any // adb shell cmd package resolve-activity -c android.intent.category.LAUNCHER com.jake.cube1 - std::string activityName = Android::GetActivityName(packageAndActivity); + rdcstr activityName = Android::GetActivityName(packageAndActivity); // if the activity name isn't specified, get the default one if(activityName.empty() || activityName == "#DefaultActivity") @@ -1000,8 +995,8 @@ ExecuteResult AndroidRemoteServer::ExecuteAndInject(const char *a, const char *w // set up environment variables for the package, and point to ourselves for vulkan and GLES // layers - std::string installedABI = Android::DetermineInstalledABI(m_deviceID, packageName); - std::string layerPackage = GetRenderDocPackageForABI(Android::GetABI(installedABI)); + rdcstr installedABI = Android::DetermineInstalledABI(m_deviceID, packageName); + rdcstr layerPackage = GetRenderDocPackageForABI(Android::GetABI(installedABI)); Android::adbExecCommand(m_deviceID, "shell settings put global enable_gpu_debug_layers 1"); Android::adbExecCommand(m_deviceID, "shell settings put global gpu_debug_app " + packageName); Android::adbExecCommand(m_deviceID, @@ -1033,7 +1028,7 @@ ExecuteResult AndroidRemoteServer::ExecuteAndInject(const char *a, const char *w StringFormat::Fmt("shell setprop debug.rdoc.RENDERDOC_CAPOPTS %s", opts.EncodeAsString().c_str())); - std::string installedPath = Android::GetPathForPackage(m_deviceID, packageName); + rdcstr installedPath = Android::GetPathForPackage(m_deviceID, packageName); rdcstr RDCLib = Android::adbExecCommand(m_deviceID, "shell ls " + installedPath + "/lib/*/" RENDERDOC_ANDROID_LIBRARY) diff --git a/renderdoc/android/android.h b/renderdoc/android/android.h index d14abab95..057eae09c 100644 --- a/renderdoc/android/android.h +++ b/renderdoc/android/android.h @@ -24,22 +24,21 @@ #pragma once -#include #include "os/os_specific.h" // public interface, for other non-android parts of the code namespace Android { bool IsHostADB(const char *hostname); -std::string GetPackageName(const std::string &packageAndActivity); -std::string GetActivityName(const std::string &packageAndActivity); -void ResetCaptureSettings(const std::string &deviceID); -void ExtractDeviceIDAndIndex(const std::string &hostname, int &index, std::string &deviceID); -Process::ProcessResult adbExecCommand(const std::string &deviceID, const std::string &args, - const std::string &workDir = ".", bool silent = false); +rdcstr GetPackageName(const rdcstr &packageAndActivity); +rdcstr GetActivityName(const rdcstr &packageAndActivity); +void ResetCaptureSettings(const rdcstr &deviceID); +void ExtractDeviceIDAndIndex(const rdcstr &hostname, int &index, rdcstr &deviceID); +Process::ProcessResult adbExecCommand(const rdcstr &deviceID, const rdcstr &args, + const rdcstr &workDir = ".", bool silent = false); void initAdb(); void shutdownAdb(); -bool InjectWithJDWP(const std::string &deviceID, uint16_t jdwpport); +bool InjectWithJDWP(const rdcstr &deviceID, uint16_t jdwpport); struct LogcatThread { @@ -68,17 +67,17 @@ private: // the last log line we saw, so we start printing after that point. If we ever have a line here // and we don't see it in the backlog. - std::string lastLogcatLine; + rdcstr lastLogcatLine; // the device ID we're monitoring - std::string deviceID; + rdcstr deviceID; // the thread handle Threading::ThreadHandle thread = 0; - friend LogcatThread *ProcessLogcat(std::string deviceID); + friend LogcatThread *ProcessLogcat(rdcstr deviceID); }; void TickDeviceLogcat(); -LogcatThread *ProcessLogcat(std::string deviceID); +LogcatThread *ProcessLogcat(rdcstr deviceID); }; diff --git a/renderdoc/android/android_manifest.cpp b/renderdoc/android/android_manifest.cpp index 9203b2376..2a9fdbecd 100644 --- a/renderdoc/android/android_manifest.cpp +++ b/renderdoc/android/android_manifest.cpp @@ -32,7 +32,7 @@ const uint32_t addingStringIndex = 0x8b8b8b8b; namespace Android { -std::string GetStringPoolValue(ResStringPool_header *stringpool, ResStringPool_ref ref) +rdcstr GetStringPoolValue(ResStringPool_header *stringpool, ResStringPool_ref ref) { byte *base = (byte *)stringpool; @@ -94,7 +94,7 @@ std::string GetStringPoolValue(ResStringPool_header *stringpool, ResStringPool_r else str += 2; - return std::string((char *)str, (char *)(str + len)); + return rdcstr((char *)str, len); } } @@ -254,7 +254,7 @@ bool PatchManifest(bytebuf &manifestBytes) ResXMLTree_attrExt *startElement = (ResXMLTree_attrExt *)(cur + node->headerSize); - std::string name = GetStringPoolValue(stringpool, startElement->name); + rdcstr name = GetStringPoolValue(stringpool, startElement->name); if(name != "application") { @@ -285,7 +285,7 @@ bool PatchManifest(bytebuf &manifestBytes) ResXMLTree_attribute *attribute = (ResXMLTree_attribute *)(attributesStart + startElement->attributeSize * i); - std::string attr = GetStringPoolValue(stringpool, attribute->name); + rdcstr attr = GetStringPoolValue(stringpool, attribute->name); if(attr != "debuggable") continue; @@ -375,7 +375,7 @@ bool PatchManifest(bytebuf &manifestBytes) { if(resourceMapping[i] == debuggableResourceId) { - std::string str = GetStringPoolValue(stringpool, {i}); + rdcstr str = GetStringPoolValue(stringpool, {i}); if(str != "debuggable") { @@ -401,7 +401,7 @@ bool PatchManifest(bytebuf &manifestBytes) // search the stringpool for the schema, it should be there already. for(uint32_t i = 0; i < stringpool->stringCount; i++) { - std::string val = GetStringPoolValue(stringpool, {i}); + rdcstr val = GetStringPoolValue(stringpool, {i}); if(val == "http://schemas.android.com/apk/res/android") { debuggable.ns.index = i; @@ -533,8 +533,10 @@ bool PatchManifest(bytebuf &manifestBytes) RDCDEBUG("Inserting %u padding bytes to align %u up to %u", paddingLen, stringpool->header.size, alignedSize); - InsertBytes(manifestBytes, base + stringpool->header.size, - std::vector((size_t)paddingLen, 0)); + bytebuf padding; + padding.resize(paddingLen); + + InsertBytes(manifestBytes, base + stringpool->header.size, padding); stringpool->header.size += paddingLen; } diff --git a/renderdoc/android/android_patch.cpp b/renderdoc/android/android_patch.cpp index 6b5635c01..b6c802840 100644 --- a/renderdoc/android/android_patch.cpp +++ b/renderdoc/android/android_patch.cpp @@ -33,11 +33,11 @@ static const char keystoreName[] = "renderdoc.keystore"; namespace Android { -bool RemoveAPKSignature(const std::string &apk) +bool RemoveAPKSignature(const rdcstr &apk) { RDCLOG("Checking for existing signature"); - std::string aapt = getToolPath(ToolDir::BuildTools, "aapt", false); + rdcstr aapt = getToolPath(ToolDir::BuildTools, "aapt", false); // Get the list of files in META-INF rdcstr fileList = execCommand(aapt, "list \"" + apk + "\"").strStdout; @@ -80,7 +80,7 @@ bool RemoveAPKSignature(const std::string &apk) return true; } -bool ExtractAndRemoveManifest(const std::string &apk, bytebuf &manifest) +bool ExtractAndRemoveManifest(const rdcstr &apk, bytebuf &manifest) { // pull out the manifest with miniz mz_zip_archive zip; @@ -119,7 +119,7 @@ bool ExtractAndRemoveManifest(const std::string &apk, bytebuf &manifest) if(manifest.empty()) return false; - std::string aapt = getToolPath(ToolDir::BuildTools, "aapt", false); + rdcstr aapt = getToolPath(ToolDir::BuildTools, "aapt", false); RDCDEBUG("Removing AndroidManifest.xml"); execCommand(aapt, "remove \"" + apk + "\" AndroidManifest.xml"); @@ -141,9 +141,9 @@ bool ExtractAndRemoveManifest(const std::string &apk, bytebuf &manifest) return true; } -bool AddManifestToAPK(const std::string &apk, const std::string &tmpDir, const bytebuf &manifest) +bool AddManifestToAPK(const rdcstr &apk, const rdcstr &tmpDir, const bytebuf &manifest) { - std::string aapt = getToolPath(ToolDir::BuildTools, "aapt", false); + rdcstr aapt = getToolPath(ToolDir::BuildTools, "aapt", false); // write the manifest to disk FileIO::WriteAll((tmpDir + "AndroidManifest.xml").c_str(), manifest); @@ -161,13 +161,13 @@ bool AddManifestToAPK(const std::string &apk, const std::string &tmpDir, const b return true; } -bool RealignAPK(const std::string &apk, std::string &alignedAPK, const std::string &tmpDir) +bool RealignAPK(const rdcstr &apk, rdcstr &alignedAPK, const rdcstr &tmpDir) { - std::string zipalign = getToolPath(ToolDir::BuildTools, "zipalign", false); + rdcstr zipalign = getToolPath(ToolDir::BuildTools, "zipalign", false); // Re-align the APK for performance RDCLOG("Realigning APK"); - std::string errOut = + rdcstr errOut = execCommand(zipalign, "-f 4 \"" + apk + "\" \"" + alignedAPK + "\"", tmpDir).strStderror; if(!errOut.empty()) @@ -192,22 +192,22 @@ bool RealignAPK(const std::string &apk, std::string &alignedAPK, const std::stri return false; } -std::string GetAndroidDebugKey() +rdcstr GetAndroidDebugKey() { - std::string keystore = getToolPath(ToolDir::None, keystoreName, false); + rdcstr keystore = getToolPath(ToolDir::None, keystoreName, false); // if we found the keystore, use that. if(FileIO::exists(keystore.c_str())) return keystore; // otherwise, see if we generated a temporary one - std::string key = FileIO::GetTempFolderFilename() + keystoreName; + rdcstr key = FileIO::GetTempFolderFilename() + keystoreName; if(FileIO::exists(key.c_str())) return key; // locate keytool and use it to generate a keystore - std::string create; + rdcstr create; create += " -genkey"; create += " -keystore \"" + key + "\""; create += " -storepass android"; @@ -218,7 +218,7 @@ std::string GetAndroidDebugKey() create += " -validity 10000"; create += " -dname \"CN=, OU=, O=, L=, S=, C=\""; - std::string keytool = getToolPath(ToolDir::Java, "keytool", false); + rdcstr keytool = getToolPath(ToolDir::Java, "keytool", false); Process::ProcessResult result = execCommand(keytool, create); @@ -228,16 +228,16 @@ std::string GetAndroidDebugKey() return key; } -bool DebugSignAPK(const std::string &apk, const std::string &workDir) +bool DebugSignAPK(const rdcstr &apk, const rdcstr &workDir) { RDCLOG("Signing with debug key"); - std::string aapt = getToolPath(ToolDir::BuildTools, "aapt", false); - std::string apksigner = getToolPath(ToolDir::BuildToolsLib, "apksigner.jar", false); + rdcstr aapt = getToolPath(ToolDir::BuildTools, "aapt", false); + rdcstr apksigner = getToolPath(ToolDir::BuildToolsLib, "apksigner.jar", false); - std::string debugKey = GetAndroidDebugKey(); + rdcstr debugKey = GetAndroidDebugKey(); - std::string args; + rdcstr args; args += " sign "; args += " --ks \"" + debugKey + "\" "; args += " --ks-pass pass:android "; @@ -245,7 +245,7 @@ bool DebugSignAPK(const std::string &apk, const std::string &workDir) args += " --ks-key-alias androiddebugkey "; args += "\"" + apk + "\""; - if(apksigner.find(".jar") == std::string::npos) + if(!apksigner.contains(".jar")) { // if we found the non-jar version, then the jar wasn't located and we found the wrapper script // in PATH. Execute it as a script @@ -254,11 +254,11 @@ bool DebugSignAPK(const std::string &apk, const std::string &workDir) else { // otherwise, find and invoke java on the .jar - std::string java = getToolPath(ToolDir::Java, "java", false); + rdcstr java = getToolPath(ToolDir::Java, "java", false); - std::string signerdir = get_dirname(FileIO::GetFullPathname(apksigner)); + rdcstr signerdir = get_dirname(FileIO::GetFullPathname(apksigner)); - std::string javaargs; + rdcstr javaargs; javaargs += " \"-Djava.ext.dirs=" + signerdir + "\""; javaargs += " -jar \"" + apksigner + "\""; javaargs += args; @@ -281,15 +281,14 @@ bool DebugSignAPK(const std::string &apk, const std::string &workDir) return false; } -bool UninstallOriginalAPK(const std::string &deviceID, const std::string &packageName, - const std::string &workDir) +bool UninstallOriginalAPK(const rdcstr &deviceID, const rdcstr &packageName, const rdcstr &workDir) { RDCLOG("Uninstalling previous version of application"); adbExecCommand(deviceID, "uninstall " + packageName, workDir); // Wait until uninstall completes - std::string uninstallResult; + rdcstr uninstallResult; uint32_t elapsed = 0; uint32_t timeout = 10000; // 10 seconds while(elapsed < timeout) @@ -309,8 +308,8 @@ bool UninstallOriginalAPK(const std::string &deviceID, const std::string &packag return false; } -bool ReinstallPatchedAPK(const std::string &deviceID, const std::string &apk, const std::string &abi, - const std::string &packageName, const std::string &workDir) +bool ReinstallPatchedAPK(const rdcstr &deviceID, const rdcstr &apk, const rdcstr &abi, + const rdcstr &packageName, const rdcstr &workDir) { RDCLOG("Reinstalling APK"); @@ -320,7 +319,7 @@ bool ReinstallPatchedAPK(const std::string &deviceID, const std::string &apk, co adbExecCommand(deviceID, "install --abi " + abi + " \"" + apk + "\"", workDir); // Wait until re-install completes - std::string reinstallResult; + rdcstr reinstallResult; uint32_t elapsed = 0; uint32_t timeout = 10000; // 10 seconds while(elapsed < timeout) @@ -343,8 +342,8 @@ bool ReinstallPatchedAPK(const std::string &deviceID, const std::string &apk, co bool CheckPatchingRequirements() { // check for required tools for patching - std::vector> requirements; - std::vector missingTools; + rdcarray> requirements; + rdcarray missingTools; requirements.push_back({ToolDir::BuildTools, "aapt"}); requirements.push_back({ToolDir::BuildTools, "zipalign"}); requirements.push_back({ToolDir::BuildToolsLib, "apksigner.jar"}); @@ -352,7 +351,7 @@ bool CheckPatchingRequirements() for(uint32_t i = 0; i < requirements.size(); i++) { - std::string tool = getToolPath(requirements[i].first, requirements[i].second, true); + rdcstr tool = getToolPath(requirements[i].first, requirements[i].second, true); // if we located the tool, we're fine. if(toolExists(tool)) @@ -364,12 +363,12 @@ bool CheckPatchingRequirements() // keytool is special - we look for a debug key first { - std::string key = getToolPath(ToolDir::None, keystoreName, true); + rdcstr key = getToolPath(ToolDir::None, keystoreName, true); if(key.empty()) { // if we don't have the debug key, check that we can find keytool. First in our normal search - std::string tool = getToolPath(ToolDir::Java, "keytool", true); + rdcstr tool = getToolPath(ToolDir::Java, "keytool", true); if(tool.empty()) { @@ -389,7 +388,7 @@ bool CheckPatchingRequirements() return true; } -bool PullAPK(const std::string &deviceID, const std::string &pkgPath, const std::string &apk) +bool PullAPK(const rdcstr &deviceID, const rdcstr &pkgPath, const rdcstr &apk) { RDCLOG("Pulling APK to patch"); @@ -414,19 +413,19 @@ bool PullAPK(const std::string &deviceID, const std::string &pkgPath, const std: return false; } -void CopyAPK(const std::string &deviceID, const std::string &pkgPath, const std::string ©Path) +void CopyAPK(const rdcstr &deviceID, const rdcstr &pkgPath, const rdcstr ©Path) { RDCLOG("Copying APK to %s", copyPath.c_str()); adbExecCommand(deviceID, "shell cp " + pkgPath + " " + copyPath); } -void RemoveAPK(const std::string &deviceID, const std::string &path) +void RemoveAPK(const rdcstr &deviceID, const rdcstr &path) { RDCLOG("Removing APK from %s", path.c_str()); adbExecCommand(deviceID, "shell rm -f " + path); } -bool HasRootAccess(const std::string &deviceID) +bool HasRootAccess(const rdcstr &deviceID) { RDCLOG("Checking for root access on %s", deviceID.c_str()); @@ -462,13 +461,13 @@ rdcstr GetFirstMatchingLine(const rdcstr &haystack, const rdcstr &needle) return haystack.substr(needleOffset, nextLine == -1 ? ~0U : size_t(nextLine - needleOffset)); } -bool IsDebuggable(const std::string &deviceID, const std::string &packageName) +bool IsDebuggable(const rdcstr &deviceID, const rdcstr &packageName) { RDCLOG("Checking that APK is debuggable"); - std::string info = adbExecCommand(deviceID, "shell dumpsys package " + packageName).strStdout; + rdcstr info = adbExecCommand(deviceID, "shell dumpsys package " + packageName).strStdout; - std::string pkgFlags = GetFirstMatchingLine(info, "pkgFlags=["); + rdcstr pkgFlags = GetFirstMatchingLine(info, "pkgFlags=["); if(pkgFlags == "") { @@ -476,7 +475,7 @@ bool IsDebuggable(const std::string &deviceID, const std::string &packageName) return false; } - return pkgFlags.find("DEBUGGABLE") != std::string::npos; + return pkgFlags.contains("DEBUGGABLE"); } }; @@ -511,7 +510,7 @@ RENDERDOC_CheckAndroidPackage(const char *URL, const char *packageAndActivity, A extern "C" RENDERDOC_API AndroidFlags RENDERDOC_CC RENDERDOC_MakeDebuggablePackage( const char *URL, const char *packageAndActivity, RENDERDOC_ProgressCallback progress) { - std::string package = Android::GetPackageName(packageAndActivity); + rdcstr package = Android::GetPackageName(packageAndActivity); Process::ProcessResult result = {}; @@ -530,21 +529,21 @@ extern "C" RENDERDOC_API AndroidFlags RENDERDOC_CC RENDERDOC_MakeDebuggablePacka progress(0.02f); - std::string abi = Android::DetermineInstalledABI(deviceID, package); + rdcstr abi = Android::DetermineInstalledABI(deviceID, package); // Find the APK on the device - std::string pkgPath = Android::GetPathForPackage(deviceID, package) + "base.apk"; + rdcstr pkgPath = Android::GetPathForPackage(deviceID, package) + "base.apk"; - std::string tmpDir = FileIO::GetTempFolderFilename(); - std::string origAPK(tmpDir + package + ".orig.apk"); - std::string alignedAPK(origAPK + ".aligned.apk"); + rdcstr tmpDir = FileIO::GetTempFolderFilename(); + rdcstr origAPK(tmpDir + package + ".orig.apk"); + rdcstr alignedAPK(origAPK + ".aligned.apk"); bytebuf manifest; // Try the following steps, bailing if anything fails if(!Android::PullAPK(deviceID, pkgPath, origAPK)) { // Copy the APK to public storage, then try to pull again - std::string copyPath = "/sdcard/" + package + ".copy.apk"; + rdcstr copyPath = "/sdcard/" + package + ".copy.apk"; Android::CopyAPK(deviceID, pkgPath, copyPath); bool success = Android::PullAPK(deviceID, copyPath, origAPK); Android::RemoveAPK(deviceID, copyPath); diff --git a/renderdoc/android/android_tools.cpp b/renderdoc/android/android_tools.cpp index 70071d955..019029f80 100644 --- a/renderdoc/android/android_tools.cpp +++ b/renderdoc/android/android_tools.cpp @@ -30,16 +30,16 @@ namespace Android { static bool adbKillServer = false; -bool toolExists(const std::string &path) +bool toolExists(const rdcstr &path) { if(path.empty()) return false; return FileIO::exists(path.c_str()) || FileIO::exists((path + ".exe").c_str()); } -std::string getToolInSDK(ToolDir subdir, const std::string &jdkroot, const std::string &sdkroot, - const std::string &toolname) +rdcstr getToolInSDK(ToolDir subdir, const rdcstr &jdkroot, const rdcstr &sdkroot, + const rdcstr &toolname) { - std::string toolpath; + rdcstr toolpath; switch(subdir) { @@ -87,7 +87,7 @@ std::string getToolInSDK(ToolDir subdir, const std::string &jdkroot, const std:: break; uint32_t bestversion = 0; - std::string bestpath; + rdcstr bestpath; for(const PathEntry &path : paths) { @@ -153,8 +153,8 @@ std::string getToolInSDK(ToolDir subdir, const std::string &jdkroot, const std:: struct ToolPathCache { - std::string sdk, jdk; - std::map paths; + rdcstr sdk, jdk; + std::map paths; }; static ToolPathCache &getCache() @@ -163,7 +163,7 @@ static ToolPathCache &getCache() return *cache; } -std::string getToolPath(ToolDir subdir, const std::string &toolname, bool checkExist) +rdcstr getToolPath(ToolDir subdir, const rdcstr &toolname, bool checkExist) { // search path for tools: // 1. First look relative to the configured paths, these come from the user manually setting them @@ -178,8 +178,8 @@ std::string getToolPath(ToolDir subdir, const std::string &toolname, bool checkE // its client-server setup, so if we run our bundled adb that might be newer than the user's, they // will then get fighting back and forth when trying to run their own. - std::string sdk = RenderDoc::Inst().GetConfigSetting("androidSDKPath"); - std::string jdk = RenderDoc::Inst().GetConfigSetting("androidJDKPath"); + rdcstr sdk = RenderDoc::Inst().GetConfigSetting("androidSDKPath"); + rdcstr jdk = RenderDoc::Inst().GetConfigSetting("androidJDKPath"); ToolPathCache &cache = getCache(); @@ -195,7 +195,7 @@ std::string getToolPath(ToolDir subdir, const std::string &toolname, bool checkE if(toolExists(cache.paths[toolname])) return cache.paths[toolname]; - std::string &toolpath = cache.paths[toolname]; + rdcstr &toolpath = cache.paths[toolname]; // first try according to the configured paths toolpath = getToolInSDK(subdir, jdk, sdk, toolname); @@ -215,10 +215,9 @@ std::string getToolPath(ToolDir subdir, const std::string &toolname, bool checkE // if the tool name contains a .jar then try stripping that and look for the non-.jar version in // the PATH. - if(toolname.find(".jar") != std::string::npos) + if(toolname.contains(".jar")) { - toolpath = toolname; - toolpath.erase(toolpath.rfind(".jar"), 4); + toolpath = strip_extension(toolname); toolpath = FileIO::FindFileInPath(toolpath); if(toolExists(toolpath)) @@ -257,13 +256,13 @@ std::string getToolPath(ToolDir subdir, const std::string &toolname, bool checkE // Library folder first, then the global folder if(sdk.empty() || !FileIO::exists(sdk.c_str())) { - std::string librarySDK = FileIO::GetHomeFolderFilename() + "/Library/Android/sdk"; + rdcstr librarySDK = FileIO::GetHomeFolderFilename() + "/Library/Android/sdk"; sdk = FileIO::exists(librarySDK.c_str()) ? librarySDK : ""; } if(sdk.empty() || !FileIO::exists(sdk.c_str())) { - std::string librarySDK = "/Library/Android/sdk"; + rdcstr librarySDK = "/Library/Android/sdk"; sdk = FileIO::exists(librarySDK.c_str()) ? librarySDK : ""; } #endif @@ -303,8 +302,8 @@ std::string getToolPath(ToolDir subdir, const std::string &toolname, bool checkE // otherwise we at least return the tool name so that there's something to try and run return toolname; } -Process::ProcessResult execScript(const std::string &script, const std::string &args, - const std::string &workDir, bool silent) +Process::ProcessResult execScript(const rdcstr &script, const rdcstr &args, const rdcstr &workDir, + bool silent) { if(!silent) RDCLOG("SCRIPT: %s", script.c_str()); @@ -313,8 +312,8 @@ Process::ProcessResult execScript(const std::string &script, const std::string & Process::LaunchScript(script.c_str(), workDir.c_str(), args.c_str(), true, &result); return result; } -Process::ProcessResult execCommand(const std::string &exe, const std::string &args, - const std::string &workDir, bool silent) +Process::ProcessResult execCommand(const rdcstr &exe, const rdcstr &args, const rdcstr &workDir, + bool silent) { if(!silent) RDCLOG("COMMAND: %s '%s'", exe.c_str(), args.c_str()); @@ -323,12 +322,12 @@ Process::ProcessResult execCommand(const std::string &exe, const std::string &ar Process::LaunchProcess(exe.c_str(), workDir.c_str(), args.c_str(), true, &result); return result; } -Process::ProcessResult adbExecCommand(const std::string &device, const std::string &args, - const std::string &workDir, bool silent) +Process::ProcessResult adbExecCommand(const rdcstr &device, const rdcstr &args, + const rdcstr &workDir, bool silent) { - std::string adb = getToolPath(ToolDir::PlatformTools, "adb", false); + rdcstr adb = getToolPath(ToolDir::PlatformTools, "adb", false); Process::ProcessResult result; - std::string deviceArgs; + rdcstr deviceArgs; if(device.empty()) deviceArgs = args; else @@ -338,9 +337,9 @@ Process::ProcessResult adbExecCommand(const std::string &device, const std::stri void initAdb() { // we don't use adbExecCommand because we need to be sure we don't wait for it to exit - std::string adb = getToolPath(ToolDir::PlatformTools, "adb", false); - std::string workdir = "."; - if(adb.find('/') != std::string::npos || adb.find('\\') != std::string::npos) + rdcstr adb = getToolPath(ToolDir::PlatformTools, "adb", false); + rdcstr workdir = "."; + if(adb.contains('/') || adb.contains('\\')) workdir = get_dirname(adb); RDCLOG("Initialising adb using '%s'", adb.c_str()); diff --git a/renderdoc/android/android_utils.cpp b/renderdoc/android/android_utils.cpp index 568df6d21..900c09e3b 100644 --- a/renderdoc/android/android_utils.cpp +++ b/renderdoc/android/android_utils.cpp @@ -23,6 +23,7 @@ ******************************************************************************/ #include "android_utils.h" +#include #include #include "common/formatting.h" #include "common/threading.h" @@ -36,7 +37,7 @@ bool IsHostADB(const char *hostname) return !strncmp(hostname, "adb:", 4); } -void ExtractDeviceIDAndIndex(const std::string &hostname, int &index, std::string &deviceID) +void ExtractDeviceIDAndIndex(const rdcstr &hostname, int &index, rdcstr &deviceID) { if(!IsHostADB(hostname.c_str())) return; @@ -59,41 +60,41 @@ void ExtractDeviceIDAndIndex(const std::string &hostname, int &index, std::strin deviceID = c; } -std::string GetPackageName(const std::string &packageAndActivity) +rdcstr GetPackageName(const rdcstr &packageAndActivity) { if(packageAndActivity.empty()) return ""; - size_t start = 0; + int32_t start = 0; if(packageAndActivity[0] == '/') start++; - size_t activitySep = packageAndActivity.find('/', start); + int32_t activitySep = packageAndActivity.find('/', start); - if(activitySep == std::string::npos) + if(activitySep < 0) return packageAndActivity.substr(start); return packageAndActivity.substr(start, activitySep - start); } -std::string GetActivityName(const std::string &packageAndActivity) +rdcstr GetActivityName(const rdcstr &packageAndActivity) { if(packageAndActivity.empty()) return ""; - size_t start = 0; + int32_t start = 0; if(packageAndActivity[0] == '/') start++; - size_t activitySep = packageAndActivity.find('/', start); + int32_t activitySep = packageAndActivity.find('/', start); - if(activitySep == std::string::npos) + if(activitySep < 0) return ""; return packageAndActivity.substr(activitySep + 1); } -ABI GetABI(const std::string &abiName) +ABI GetABI(const rdcstr &abiName) { if(abiName == "armeabi-v7a") return ABI::armeabi_v7a; @@ -109,7 +110,21 @@ ABI GetABI(const std::string &abiName) return ABI::unknown; } -std::vector GetSupportedABIs(const std::string &deviceID) +rdcstr GetPlainABIName(ABI abi) +{ + switch(abi) + { + case ABI::arm64_v8a: return "arm64"; + case ABI::armeabi_v7a: return "arm32"; + case ABI::x86_64: return "x64"; + case ABI::x86: return "x86"; + default: break; + } + + return "unsupported"; +} + +rdcarray GetSupportedABIs(const rdcstr &deviceID) { rdcstr adbAbi = adbExecCommand(deviceID, "shell getprop ro.product.cpu.abi").strStdout.trimmed(); @@ -127,24 +142,12 @@ std::vector GetSupportedABIs(const std::string &deviceID) return {}; } -std::string GetRenderDocPackageForABI(ABI abi, char sep) +rdcstr GetRenderDocPackageForABI(ABI abi) { - std::string ret = RENDERDOC_ANDROID_PACKAGE_BASE; - ret += sep; - - switch(abi) - { - case ABI::arm64_v8a: return ret + "arm64"; - case ABI::armeabi_v7a: return ret + "arm32"; - case ABI::x86_64: return ret + "x64"; - case ABI::x86: return ret + "x86"; - default: break; - } - - return ret + "unknown"; + return RENDERDOC_ANDROID_PACKAGE_BASE "." + GetPlainABIName(abi); } -std::string GetPathForPackage(const std::string &deviceID, const std::string &packageName) +rdcstr GetPathForPackage(const rdcstr &deviceID, const rdcstr &packageName) { rdcstr pkgPath = adbExecCommand(deviceID, "shell pm path " + packageName).strStdout.trimmed(); @@ -166,7 +169,7 @@ std::string GetPathForPackage(const std::string &deviceID, const std::string &pa return pkgPath; } -bool IsSupported(std::string deviceID) +bool IsSupported(rdcstr deviceID) { rdcstr api = Android::adbExecCommand(deviceID, "shell getprop ro.build.version.sdk").strStdout.trimmed(); @@ -199,10 +202,10 @@ bool SupportsNativeLayers(const rdcstr &deviceID) return false; } -std::string DetermineInstalledABI(const std::string &deviceID, const std::string &packageName) +rdcstr DetermineInstalledABI(const rdcstr &deviceID, const rdcstr &packageName) { RDCLOG("Checking installed ABI for %s", packageName.c_str()); - std::string abi; + rdcstr abi; rdcstr dump = adbExecCommand(deviceID, "shell pm dump " + packageName).strStdout; if(dump.empty()) @@ -244,7 +247,7 @@ rdcstr GetFriendlyName(const rdcstr &deviceID) rdcstr model = Android::adbExecCommand(deviceID, "shell getprop ro.product.model").strStdout.trimmed(); - std::string combined; + rdcstr combined; if(manuf.empty() && model.empty()) combined = ""; @@ -285,11 +288,11 @@ struct LogLine time_t timestamp = 0; uint32_t pid = 0; LogType logtype = LogType::Comment; - std::string filename; + rdcstr filename; uint32_t line_number = 0; - std::string message; + rdcstr message; - bool parse(const std::string &line) + bool parse(const rdcstr &line) { #define EXPECT_CHAR(c) \ if(idx >= line.length() || line[idx] != c) \ @@ -454,11 +457,7 @@ struct LogLine } // strip spaces - while(!filename.empty() && isspace(filename[0])) - filename.erase(0, 1); - - while(!filename.empty() && isspace(filename.back())) - filename.pop_back(); + filename.trim(); if(filename.empty()) return false; @@ -481,19 +480,14 @@ struct LogLine EXPECT_CHAR('-'); EXPECT_CHAR(' '); - std::string logtype_str; + rdcstr logtype_str; while(idx < line.length() && line[idx] != '-') { logtype_str.push_back(line[idx]); idx++; } - // strip spaces - while(!logtype_str.empty() && isspace(logtype_str[0])) - logtype_str.erase(0); - - while(!logtype_str.empty() && isspace(logtype_str.back())) - logtype_str.pop_back(); + logtype_str.trim(); if(logtype_str == "Debug") logtype = LogType::Debug; @@ -529,9 +523,9 @@ struct LogLine // we need to keep track of logcat threads, so that if we start a new one up on a device before the // old one has finished, we don't start overlapping and double-printing messages. static Threading::CriticalSection logcatThreadLock; -static std::map logcatThreads; +static std::map logcatThreads; -LogcatThread *ProcessLogcat(std::string deviceID) +LogcatThread *ProcessLogcat(rdcstr deviceID) { LogcatThread *ret = NULL; @@ -656,7 +650,7 @@ void LogcatThread::Tick() // DEBUG:* // or from DEBUG (prints crash messages) // // This gives us all messages from renderdoc since the last timestamp. - std::string command = + rdcstr command = StringFormat::Fmt("logcat -t %u -v brief -s renderdoc:* libc:* DEBUG:*", lineBacklog); rdcstr logcat = Android::adbExecCommand(deviceID, command, ".", true).strStdout.trimmed(); @@ -684,7 +678,7 @@ void LogcatThread::Tick() RDCWARN("Couldn't find last line. Potentially missed logcat messages."); } - for(const std::string &line : lines) + for(const rdcstr &line : lines) { LogLine logline; @@ -808,7 +802,7 @@ TEST_CASE("Test that log line parsing is robust", "[android]") SECTION("Invalid strings - truncated") { - std::string truncated = + rdcstr truncated = R"(I/renderdoc( 1234): @1234567812345678@ RDOC 001234: [01:02:03] filename.cpp( 123) - Warning - H)"; LogLine working; diff --git a/renderdoc/android/android_utils.h b/renderdoc/android/android_utils.h index 8f9b0a865..50f55dad5 100644 --- a/renderdoc/android/android_utils.h +++ b/renderdoc/android/android_utils.h @@ -32,10 +32,10 @@ namespace Android { -Process::ProcessResult execScript(const std::string &script, const std::string &args, - const std::string &workDir = ".", bool silent = false); -Process::ProcessResult execCommand(const std::string &exe, const std::string &args, - const std::string &workDir = ".", bool silent = false); +Process::ProcessResult execScript(const rdcstr &script, const rdcstr &args, + const rdcstr &workDir = ".", bool silent = false); +Process::ProcessResult execCommand(const rdcstr &exe, const rdcstr &args, + const rdcstr &workDir = ".", bool silent = false); enum class ToolDir { @@ -45,14 +45,14 @@ enum class ToolDir BuildToolsLib, PlatformTools, }; -std::string getToolPath(ToolDir subdir, const std::string &toolname, bool checkExist); -bool toolExists(const std::string &path); +rdcstr getToolPath(ToolDir subdir, const rdcstr &toolname, bool checkExist); +bool toolExists(const rdcstr &path); rdcstr GetFirstMatchingLine(const rdcstr &haystack, const rdcstr &needle); -bool IsSupported(std::string deviceID); +bool IsSupported(rdcstr deviceID); bool SupportsNativeLayers(const rdcstr &deviceID); -std::string DetermineInstalledABI(const std::string &deviceID, const std::string &packageName); +rdcstr DetermineInstalledABI(const rdcstr &deviceID, const rdcstr &packageName); rdcstr GetFriendlyName(const rdcstr &deviceID); // supported ABIs @@ -65,10 +65,11 @@ enum class ABI x86_64, }; -ABI GetABI(const std::string &abiName); -std::vector GetSupportedABIs(const std::string &deviceID); -std::string GetRenderDocPackageForABI(ABI abi, char sep = '.'); -std::string GetPathForPackage(const std::string &deviceID, const std::string &packageName); +ABI GetABI(const rdcstr &abiName); +rdcstr GetPlainABIName(ABI abi); +rdcarray GetSupportedABIs(const rdcstr &deviceID); +rdcstr GetRenderDocPackageForABI(ABI abi); +rdcstr GetPathForPackage(const rdcstr &deviceID, const rdcstr &packageName); bool PatchManifest(bytebuf &manifest); }; diff --git a/renderdoc/android/jdwp.cpp b/renderdoc/android/jdwp.cpp index 6629ee2e3..53214cf55 100644 --- a/renderdoc/android/jdwp.cpp +++ b/renderdoc/android/jdwp.cpp @@ -32,7 +32,7 @@ namespace JDWP { void InjectVulkanLayerSearchPath(Connection &conn, threadID thread, int32_t slotIdx, - const std::string &libPath) + const rdcstr &libPath) { referenceTypeID stringClass = conn.GetType("Ljava/lang/String;"); methodID stringConcat = conn.GetMethod(stringClass, "concat"); @@ -48,7 +48,7 @@ void InjectVulkanLayerSearchPath(Connection &conn, threadID thread, int32_t slot } // get the callstack frames - std::vector stack = conn.GetCallStack(thread); + rdcarray stack = conn.GetCallStack(thread); if(stack.empty()) { @@ -96,7 +96,7 @@ void InjectVulkanLayerSearchPath(Connection &conn, threadID thread, int32_t slot conn.SetLocalValue(thread, stack[0].id, slotIdx, temp); } -bool InjectLibraries(const std::string &deviceID, Network::Socket *sock) +bool InjectLibraries(const rdcstr &deviceID, Network::Socket *sock) { Connection conn(sock); @@ -146,7 +146,7 @@ bool InjectLibraries(const std::string &deviceID, Network::Socket *sock) abi = Android::ABI::armeabi_v7a; } - std::string libPath = Android::GetPathForPackage(deviceID, Android::GetRenderDocPackageForABI(abi)); + rdcstr libPath = Android::GetPathForPackage(deviceID, Android::GetRenderDocPackageForABI(abi)); switch(abi) { @@ -213,7 +213,7 @@ bool InjectLibraries(const std::string &deviceID, Network::Socket *sock) if(vulkanLoaderMethod) { - std::vector slots = conn.GetLocalVariables(vulkanLoaderClass, vulkanLoaderMethod); + rdcarray slots = conn.GetLocalVariables(vulkanLoaderClass, vulkanLoaderMethod); int32_t slotIdx = -1, thisSlotIdx = -1; bool slot4Exists = false; @@ -305,7 +305,7 @@ bool InjectLibraries(const std::string &deviceID, Network::Socket *sock) } // get the callstack frames - std::vector stack = conn.GetCallStack(thread); + rdcarray stack = conn.GetCallStack(thread); if(stack.empty()) { @@ -431,7 +431,7 @@ bool InjectLibraries(const std::string &deviceID, Network::Socket *sock) namespace Android { -bool InjectWithJDWP(const std::string &deviceID, uint16_t jdwpport) +bool InjectWithJDWP(const rdcstr &deviceID, uint16_t jdwpport) { Network::Socket *sock = Network::CreateClientSocket("localhost", jdwpport, 500); diff --git a/renderdoc/android/jdwp.h b/renderdoc/android/jdwp.h index 25f1175f5..9e355dd3e 100644 --- a/renderdoc/android/jdwp.h +++ b/renderdoc/android/jdwp.h @@ -323,24 +323,24 @@ struct Location struct Method { methodID id; - std::string name; - std::string signature; + rdcstr name; + rdcstr signature; int32_t modBits; }; struct Field { fieldID id; - std::string name; - std::string signature; + rdcstr name; + rdcstr signature; int32_t modBits; }; struct VariableSlot { uint64_t codeIndex; - std::string name; - std::string signature; + rdcstr name; + rdcstr signature; uint32_t length; int32_t slot; }; @@ -373,7 +373,7 @@ struct Event threadID thread; TypeTag refTypeTag; referenceTypeID typeID; - std::string signature; + rdcstr signature; union { // get around strict aliasing @@ -406,13 +406,13 @@ private: uint32_t length = 0; uint32_t id = 0; Error error = Error::None; - std::vector data; + bytebuf data; }; // a helper class for reading/writing the payload of a packet, with endian swapping. struct CommandData { - CommandData(std::vector &dataStore) : data(dataStore) {} + CommandData(bytebuf &dataStore) : data(dataStore) {} template CommandData &Read(T &val) { @@ -433,7 +433,7 @@ struct CommandData // called when we've finished reading, to ensure we consumed all the data void Done() { RDCASSERT(offs == data.size(), offs, data.size()); } private: - std::vector &data; + bytebuf &data; size_t offs = 0; void ReadBytes(void *bytes, size_t length); @@ -442,9 +442,9 @@ private: // overloads for the basic types we want to read and write template <> -CommandData &CommandData::Read(std::string &str); +CommandData &CommandData::Read(rdcstr &str); template <> -CommandData &CommandData::Write(const std::string &str); +CommandData &CommandData::Write(const rdcstr &str); template <> CommandData &CommandData::Read(taggedObjectID &id); template <> @@ -500,13 +500,13 @@ public: void SetupIDSizes(); // get the type handle for a given JNI signature - referenceTypeID GetType(const std::string &signature); + referenceTypeID GetType(const rdcstr &signature); // get the type handle for an object referenceTypeID GetType(objectID obj); // get a field handle. If signature is empty, it's ignored for matching - fieldID GetField(referenceTypeID type, const std::string &name, const std::string &signature = ""); + fieldID GetField(referenceTypeID type, const rdcstr &name, const rdcstr &signature = ""); // get the value of a static field value GetFieldValue(referenceTypeID type, fieldID field); @@ -514,29 +514,29 @@ public: // get a method handle. If signature is empty, it's ignored for matching // The actual class for the method (possibly a parent of 'type') will be returned in methClass if // non-NULL - methodID GetMethod(referenceTypeID type, const std::string &name, - const std::string &signature = "", referenceTypeID *methClass = NULL); + methodID GetMethod(referenceTypeID type, const rdcstr &name, const rdcstr &signature = "", + referenceTypeID *methClass = NULL); // get local variable slots - std::vector GetLocalVariables(referenceTypeID type, methodID method); + rdcarray GetLocalVariables(referenceTypeID type, methodID method); // get a thread's stack frames - std::vector GetCallStack(threadID thread); + rdcarray GetCallStack(threadID thread); // get the this pointer for a given stack frame objectID GetThis(threadID thread, frameID frame); // get the value of a string object - std::string GetString(objectID str); + rdcstr GetString(objectID str); // resume the VM and wait for an event to happen, filtered by some built-in filters or a callback. // Returns the matching event and leaves the VM suspended, or an empty event if there was a // problem - Event WaitForEvent(EventKind kind, const std::vector &eventFilters, + Event WaitForEvent(EventKind kind, const rdcarray &eventFilters, EventFilterFunction filterCallback); // create a new string reference on the given thread - value NewString(threadID thread, const std::string &str); + value NewString(threadID thread, const rdcstr &str); // get/set local variables value GetLocalValue(threadID thread, frameID frame, int32_t slot, Tag tag); @@ -544,7 +544,7 @@ public: // invoke a static method value InvokeStatic(threadID thread, classID clazz, methodID method, - const std::vector &arguments, + const rdcarray &arguments, InvokeOptions options = InvokeOptions::SingleThreaded) { // instance detects if object is empty, and invokes as static @@ -552,7 +552,7 @@ public: } // invoke an instance method value InvokeInstance(threadID thread, classID clazz, methodID method, objectID object, - const std::vector &arguments, + const rdcarray &arguments, InvokeOptions options = InvokeOptions::SingleThreaded); private: @@ -566,7 +566,7 @@ private: void ReadEvent(CommandData &data, Event &ev); classID GetSuper(classID clazz); - std::string GetSignature(referenceTypeID typeID); - std::vector GetMethods(referenceTypeID searchClass); + rdcstr GetSignature(referenceTypeID typeID); + rdcarray GetMethods(referenceTypeID searchClass); }; }; diff --git a/renderdoc/android/jdwp_connection.cpp b/renderdoc/android/jdwp_connection.cpp index a4bd188d0..6d7364050 100644 --- a/renderdoc/android/jdwp_connection.cpp +++ b/renderdoc/android/jdwp_connection.cpp @@ -28,7 +28,7 @@ namespace JDWP { // short helper functions to read/write vectors - always preceeded by an int length template -void ReadVector(CommandData &data, std::vector &vec, +void ReadVector(CommandData &data, rdcarray &vec, std::function process) { int32_t count = 0; @@ -40,7 +40,7 @@ void ReadVector(CommandData &data, std::vector &vec, } template -void WriteVector(CommandData &data, const std::vector &vec, +void WriteVector(CommandData &data, const rdcarray &vec, std::function process) { int32_t count = (int32_t)vec.size(); @@ -199,7 +199,7 @@ void Connection::Resume() SendReceive(cmd); } -referenceTypeID Connection::GetType(const std::string &signature) +referenceTypeID Connection::GetType(const rdcstr &signature) { Command cmd(CommandSet::VirtualMachine, 2); cmd.GetData().Write(signature); @@ -237,8 +237,8 @@ referenceTypeID Connection::GetType(objectID obj) return ret; } -methodID Connection::GetMethod(referenceTypeID type, const std::string &name, - const std::string &signature, referenceTypeID *methClass) +methodID Connection::GetMethod(referenceTypeID type, const rdcstr &name, const rdcstr &signature, + referenceTypeID *methClass) { referenceTypeID searchClass = type; @@ -249,7 +249,7 @@ methodID Connection::GetMethod(referenceTypeID type, const std::string &name, GetSignature(searchClass).c_str()); */ - std::vector methods = GetMethods(searchClass); + rdcarray methods = GetMethods(searchClass); for(const Method &m : methods) { @@ -267,7 +267,7 @@ methodID Connection::GetMethod(referenceTypeID type, const std::string &name, return {}; } -std::vector Connection::GetLocalVariables(referenceTypeID type, methodID method) +rdcarray Connection::GetLocalVariables(referenceTypeID type, methodID method) { Command cmd(CommandSet::Method, 2); cmd.GetData().Write(type).Write(method); @@ -276,7 +276,7 @@ std::vector Connection::GetLocalVariables(referenceTypeID type, me return {}; int32_t argumentCount = 0; - std::vector slots; + rdcarray slots; CommandData data = cmd.GetData(); data.Read(argumentCount); // unused for now @@ -288,8 +288,7 @@ std::vector Connection::GetLocalVariables(referenceTypeID type, me return slots; } -fieldID Connection::GetField(referenceTypeID type, const std::string &name, - const std::string &signature) +fieldID Connection::GetField(referenceTypeID type, const rdcstr &name, const rdcstr &signature) { Command cmd(CommandSet::ReferenceType, 4); cmd.GetData().Write(type); @@ -297,7 +296,7 @@ fieldID Connection::GetField(referenceTypeID type, const std::string &name, if(!SendReceive(cmd)) return {}; - std::vector fields; + rdcarray fields; CommandData data = cmd.GetData(); ReadVector(data, fields, [](CommandData &d, Field &f) { d.Read(f.id).Read(f.name).Read(f.signature).Read(f.modBits); @@ -330,7 +329,7 @@ value Connection::GetFieldValue(referenceTypeID type, fieldID field) return ret; } -std::vector Connection::GetCallStack(threadID thread) +rdcarray Connection::GetCallStack(threadID thread) { Command cmd(CommandSet::ThreadReference, 6); // always fetch full stack @@ -339,7 +338,7 @@ std::vector Connection::GetCallStack(threadID thread) if(!SendReceive(cmd)) return {}; - std::vector ret; + rdcarray ret; CommandData data = cmd.GetData(); ReadVector(data, ret, [](CommandData &d, StackFrame &f) { d.Read(f.id).Read(f.location); }); @@ -389,7 +388,7 @@ void Connection::ReadEvent(CommandData &data, Event &ev) } } -Event Connection::WaitForEvent(EventKind kind, const std::vector &eventFilters, +Event Connection::WaitForEvent(EventKind kind, const rdcarray &eventFilters, EventFilterFunction filterCallback) { int32_t eventRequestID = 0; @@ -429,7 +428,7 @@ Event Connection::WaitForEvent(EventKind kind, const std::vector &e while(!reader.IsErrored()) { SuspendPolicy suspendPolicy; - std::vector events; + rdcarray events; Command msg; msg.Recv(reader); @@ -477,7 +476,7 @@ Event Connection::WaitForEvent(EventKind kind, const std::vector &e return {}; } -value Connection::NewString(threadID thread, const std::string &str) +value Connection::NewString(threadID thread, const rdcstr &str) { Command cmd(CommandSet::VirtualMachine, 11); cmd.GetData().Write(str); @@ -519,7 +518,7 @@ void Connection::SetLocalValue(threadID thread, frameID frame, int32_t slot, val } value Connection::InvokeInstance(threadID thread, classID clazz, methodID method, objectID object, - const std::vector &arguments, InvokeOptions options) + const rdcarray &arguments, InvokeOptions options) { Command cmd; CommandData data = cmd.GetData(); @@ -561,7 +560,7 @@ value Connection::InvokeInstance(threadID thread, classID clazz, methodID method return returnValue; } -std::string Connection::GetString(objectID str) +rdcstr Connection::GetString(objectID str) { Command cmd(CommandSet::StringReference, 1); cmd.GetData().Write(str); @@ -569,7 +568,7 @@ std::string Connection::GetString(objectID str) if(!SendReceive(cmd)) return ""; - std::string ret; + rdcstr ret; cmd.GetData().Read(ret).Done(); return ret; } @@ -587,7 +586,7 @@ classID Connection::GetSuper(classID clazz) return ret; } -std::string Connection::GetSignature(referenceTypeID typeID) +rdcstr Connection::GetSignature(referenceTypeID typeID) { Command cmd(CommandSet::ReferenceType, 1); cmd.GetData().Write(typeID); @@ -595,12 +594,12 @@ std::string Connection::GetSignature(referenceTypeID typeID) if(!SendReceive(cmd)) return {}; - std::string ret; + rdcstr ret; cmd.GetData().Read(ret).Done(); return ret; } -std::vector Connection::GetMethods(referenceTypeID searchClass) +rdcarray Connection::GetMethods(referenceTypeID searchClass) { Command cmd(CommandSet::ReferenceType, 5); cmd.GetData().Write(searchClass); @@ -608,7 +607,7 @@ std::vector Connection::GetMethods(referenceTypeID searchClass) if(!SendReceive(cmd)) return {}; - std::vector ret; + rdcarray ret; CommandData data = cmd.GetData(); ReadVector(data, ret, [](CommandData &d, Method &m) { d.Read(m.id).Read(m.name).Read(m.signature).Read(m.modBits); diff --git a/renderdoc/android/jdwp_util.cpp b/renderdoc/android/jdwp_util.cpp index 690023151..6aa765374 100644 --- a/renderdoc/android/jdwp_util.cpp +++ b/renderdoc/android/jdwp_util.cpp @@ -108,12 +108,11 @@ void CommandData::ReadBytes(void *bytes, size_t length) void CommandData::WriteBytes(const void *bytes, size_t length) { - const byte *start = (const byte *)bytes; - data.insert(data.end(), start, start + length); + data.append((const byte *)bytes, length); } template <> -CommandData &CommandData::Read(std::string &str) +CommandData &CommandData::Read(rdcstr &str) { uint32_t length = 0; Read(length); @@ -123,7 +122,7 @@ CommandData &CommandData::Read(std::string &str) } template <> -CommandData &CommandData::Write(const std::string &str) +CommandData &CommandData::Write(const rdcstr &str) { uint32_t length = (uint32_t)str.size(); Write(length); diff --git a/renderdoc/api/replay/pipestate.inl b/renderdoc/api/replay/pipestate.inl index d2dc32478..ea556c2a9 100644 --- a/renderdoc/api/replay/pipestate.inl +++ b/renderdoc/api/replay/pipestate.inl @@ -22,6 +22,8 @@ * THE SOFTWARE. ******************************************************************************/ +#include + rdcstr PipeState::GetResourceLayout(ResourceId id) const { if(IsCaptureLoaded()) @@ -697,7 +699,7 @@ rdcarray PipeState::GetVertexInputs() const bool needsSemanticIdx = false; for(int j = 0; j < layouts.count(); j++) { - if(i != j && striequal(semName, std::string(layouts[j].semanticName))) + if(i != j && striequal(semName, rdcstr(layouts[j].semanticName))) { needsSemanticIdx = true; break; diff --git a/renderdoc/api/replay/renderdoc_tostr.inl b/renderdoc/api/replay/renderdoc_tostr.inl index 580a7c35e..65163d1bd 100644 --- a/renderdoc/api/replay/renderdoc_tostr.inl +++ b/renderdoc/api/replay/renderdoc_tostr.inl @@ -459,12 +459,12 @@ rdcstr DoStringise(const QualityHint &el) template <> rdcstr DoStringise(const TextureFilter &el) { - std::string filter = ""; - std::string filtPrefix = ""; - std::string filtVal = ""; + rdcstr filter = ""; + rdcstr filtPrefix = ""; + rdcstr filtVal = ""; - std::string filters[] = {ToStr(el.minify), ToStr(el.magnify), ToStr(el.mip)}; - std::string filterPrefixes[] = {"Min", "Mag", "Mip"}; + rdcstr filters[] = {ToStr(el.minify), ToStr(el.magnify), ToStr(el.mip)}; + rdcstr filterPrefixes[] = {"Min", "Mag", "Mip"}; for(int a = 0; a < 3; a++) { diff --git a/renderdoc/common/common.cpp b/renderdoc/common/common.cpp index dd962ad52..74ca2c066 100644 --- a/renderdoc/common/common.cpp +++ b/renderdoc/common/common.cpp @@ -26,7 +26,6 @@ #include "common.h" #include #include -#include #include "common/threading.h" #include "os/os_specific.h" #include "strings/string_utils.h" @@ -246,7 +245,7 @@ uint64_t Log2Floor(uint64_t value) } #endif -static std::string logfile; +static rdcstr logfile; static FileIO::LogFileHandle *logfileHandle = NULL; const char *rdclog_getfilename() @@ -256,7 +255,7 @@ const char *rdclog_getfilename() void rdclog_filename(const char *filename) { - std::string previous = logfile; + rdcstr previous = logfile; logfile = ""; if(filename && filename[0]) @@ -458,7 +457,7 @@ void rdclog_direct(time_t utcTime, uint32_t pid, LogType type, const char *proje { char backup[2]; - std::string prefixText(base, size_t(prefixEnd - base)); + rdcstr prefixText(base, size_t(prefixEnd - base)); bool first = true; diff --git a/renderdoc/common/custom_assert.h b/renderdoc/common/custom_assert.h index ceb6bee36..f8aa08f59 100644 --- a/renderdoc/common/custom_assert.h +++ b/renderdoc/common/custom_assert.h @@ -105,25 +105,25 @@ //////////////////////////////////////////////////////////////////////////////////////////////////////////// -#define RDCASSERTMSG(msg, ...) \ - do \ - { \ - if(!(RDCASSERT_IFCOND(__VA_ARGS__))) \ - { \ - const char custommsg[] = msg; \ - (void)custommsg; \ - std::string assertmsg = "'" STRINGIZE(RDCASSERT_GETCOND(__VA_ARGS__)) "' "; \ - assertmsg += (sizeof(custommsg) > 1) ? msg " " : ""; \ - std::string failmsg; \ - RDCASSERT_FAILMSG(__VA_ARGS__); \ - if(!failmsg.empty()) \ - { \ - failmsg.pop_back(); \ - failmsg.pop_back(); \ - } \ - std::string combinedmsg = assertmsg + (failmsg.empty() ? "" : "(" + failmsg + ")"); \ - rdcassert(combinedmsg.c_str(), __FILE__, __LINE__, __PRETTY_FUNCTION_SIGNATURE__); \ - rdclog_flush(); \ - RDCBREAK(); \ - } \ +#define RDCASSERTMSG(msg, ...) \ + do \ + { \ + if(!(RDCASSERT_IFCOND(__VA_ARGS__))) \ + { \ + const char custommsg[] = msg; \ + (void)custommsg; \ + rdcstr assertmsg = "'" STRINGIZE(RDCASSERT_GETCOND(__VA_ARGS__)) "' "; \ + assertmsg += (sizeof(custommsg) > 1) ? msg " " : ""; \ + rdcstr failmsg; \ + RDCASSERT_FAILMSG(__VA_ARGS__); \ + if(!failmsg.empty()) \ + { \ + failmsg.pop_back(); \ + failmsg.pop_back(); \ + } \ + rdcstr combinedmsg = assertmsg + (failmsg.empty() ? "" : "(" + failmsg + ")"); \ + rdcassert(combinedmsg.c_str(), __FILE__, __LINE__, __PRETTY_FUNCTION_SIGNATURE__); \ + rdclog_flush(); \ + RDCBREAK(); \ + } \ } while((void)0, 0) diff --git a/renderdoc/common/shader_cache.h b/renderdoc/common/shader_cache.h index 223106831..00160da68 100644 --- a/renderdoc/common/shader_cache.h +++ b/renderdoc/common/shader_cache.h @@ -32,7 +32,7 @@ template bool LoadShaderCache(const char *filename, const uint32_t magicNumber, const uint32_t versionNumber, std::map &resultCache, const ShaderCallbacks &callbacks) { - std::string shadercache = FileIO::GetAppFolderFilename(filename); + rdcstr shadercache = FileIO::GetAppFolderFilename(filename); FILE *f = FileIO::fopen(shadercache.c_str(), "rb"); @@ -154,7 +154,7 @@ template void SaveShaderCache(const char *filename, uint32_t magicNumber, uint32_t versionNumber, const std::map &cache, const ShaderCallbacks &callbacks) { - std::string shadercache = FileIO::GetAppFolderFilename(filename); + rdcstr shadercache = FileIO::GetAppFolderFilename(filename); FILE *f = FileIO::fopen(shadercache.c_str(), "wb"); diff --git a/renderdoc/common/threading_tests.cpp b/renderdoc/common/threading_tests.cpp index 14bc19f19..275b29eab 100644 --- a/renderdoc/common/threading_tests.cpp +++ b/renderdoc/common/threading_tests.cpp @@ -35,8 +35,8 @@ TEST_CASE("Test spin lock", "[threading]") { int finalValue = 0; - std::vector threads; - std::vector threadcount; + rdcarray threads; + rdcarray threadcount; threads.resize(8); threadcount.resize(8); diff --git a/renderdoc/common/timing.h b/renderdoc/common/timing.h index 6d4d87478..46c87e73c 100644 --- a/renderdoc/common/timing.h +++ b/renderdoc/common/timing.h @@ -27,7 +27,6 @@ #include #include -#include #include "os/os_specific.h" #include "common.h" @@ -94,7 +93,7 @@ public: double GetMaxFrameTime() const { return m_MaxFrametime; } private: PerformanceTimer m_HighPrecisionTimer; - std::vector m_FrameTimes; + rdcarray m_FrameTimes; double m_TotalTime; double m_AvgFrametime; double m_MinFrametime; @@ -130,7 +129,7 @@ public: private: const char *m_File; unsigned int m_Line; - std::string m_Message; + rdcstr m_Message; PerformanceTimer m_Timer; }; diff --git a/renderdoc/common/wrapped_pool.h b/renderdoc/common/wrapped_pool.h index c3199868b..a2f9f0475 100644 --- a/renderdoc/common/wrapped_pool.h +++ b/renderdoc/common/wrapped_pool.h @@ -233,7 +233,7 @@ private: }; ItemPool m_ImmediatePool; - std::vector m_AdditionalPools; + rdcarray m_AdditionalPools; friend typename FriendMaker::Type; }; diff --git a/renderdoc/core/bit_flag_iterator_tests.cpp b/renderdoc/core/bit_flag_iterator_tests.cpp index 49de722f9..0b1a565c3 100644 --- a/renderdoc/core/bit_flag_iterator_tests.cpp +++ b/renderdoc/core/bit_flag_iterator_tests.cpp @@ -22,21 +22,22 @@ * THE SOFTWARE. ******************************************************************************/ -#include "bit_flag_iterator.h" #include "common/globalconfig.h" #if ENABLED(ENABLE_UNIT_TESTS) +#include "api/replay/rdcarray.h" +#include "bit_flag_iterator.h" + #include "3rdparty/catch/catch.hpp" #include -#include typedef BitFlagIterator TestFlagIter; -std::vector get_bits(const TestFlagIter &begin, const TestFlagIter &end) +rdcarray get_bits(const TestFlagIter &begin, const TestFlagIter &end) { - std::vector bits; + rdcarray bits; for(TestFlagIter it = begin; it != end; ++it) { bits.push_back(*it); @@ -48,12 +49,12 @@ TEST_CASE("Test BitFlagIterator type", "[bit_flag_iterator]") { SECTION("empty") { - std::vector expected = {}; + rdcarray expected = {}; CHECK(get_bits(TestFlagIter::begin(0x0), TestFlagIter::end()) == expected); }; SECTION("full") { - std::vector expected = { + rdcarray expected = { 0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80, 0x100, 0x200, 0x400, 0x800, 0x1000, 0x2000, 0x4000, 0x8000, 0x10000, 0x20000, 0x40000, 0x80000, 0x100000, 0x200000, 0x400000, 0x800000, @@ -62,16 +63,16 @@ TEST_CASE("Test BitFlagIterator type", "[bit_flag_iterator]") }; SECTION("even") { - std::vector expected = { - 0x1, 0x4, 0x10, 0x40, 0x100, 0x400, 0x1000, 0x4000, - 0x10000, 0x40000, 0x100000, 0x400000, 0x1000000, 0x4000000, 0x10000000, 0x40000000}; + rdcarray expected = {0x1, 0x4, 0x10, 0x40, 0x100, 0x400, + 0x1000, 0x4000, 0x10000, 0x40000, 0x100000, 0x400000, + 0x1000000, 0x4000000, 0x10000000, 0x40000000}; CHECK(get_bits(TestFlagIter::begin(0x55555555), TestFlagIter::end()) == expected); }; SECTION("odd") { - std::vector expected = { - 0x2, 0x8, 0x20, 0x80, 0x200, 0x800, 0x2000, 0x8000, - 0x20000, 0x80000, 0x200000, 0x800000, 0x2000000, 0x8000000, 0x20000000, 0x80000000}; + rdcarray expected = {0x2, 0x8, 0x20, 0x80, 0x200, 0x800, + 0x2000, 0x8000, 0x20000, 0x80000, 0x200000, 0x800000, + 0x2000000, 0x8000000, 0x20000000, 0x80000000}; CHECK(get_bits(TestFlagIter::begin(0xAAAAAAAA), TestFlagIter::end()) == expected); }; SECTION("single") @@ -79,18 +80,18 @@ TEST_CASE("Test BitFlagIterator type", "[bit_flag_iterator]") for(int i = 0; i < 32; i++) { uint32_t b = 1 << i; - std::vector expected = {b}; + rdcarray expected = {b}; CHECK(get_bits(TestFlagIter::begin(b), TestFlagIter::end()) == expected); } }; SECTION("empty from bit") { - std::vector expected = {}; + rdcarray expected = {}; CHECK(get_bits(TestFlagIter(0x0, 0x4), TestFlagIter::end()) == expected); }; SECTION("full from bit") { - std::vector expected = { + rdcarray expected = { 0x4, 0x8, 0x10, 0x20, 0x40, 0x80, 0x100, 0x200, 0x400, 0x800, 0x1000, 0x2000, 0x4000, 0x8000, 0x10000, 0x20000, 0x40000, 0x80000, 0x100000, 0x200000, 0x400000, 0x800000, 0x1000000, 0x2000000, @@ -99,17 +100,17 @@ TEST_CASE("Test BitFlagIterator type", "[bit_flag_iterator]") }; SECTION("even from bit") { - std::vector expected = {0x4, 0x10, 0x40, 0x100, 0x400, - 0x1000, 0x4000, 0x10000, 0x40000, 0x100000, - 0x400000, 0x1000000, 0x4000000, 0x10000000, 0x40000000}; + rdcarray expected = {0x4, 0x10, 0x40, 0x100, 0x400, + 0x1000, 0x4000, 0x10000, 0x40000, 0x100000, + 0x400000, 0x1000000, 0x4000000, 0x10000000, 0x40000000}; CHECK(get_bits(TestFlagIter(0x55555555, 0x2), TestFlagIter::end()) == expected); CHECK(get_bits(TestFlagIter(0x55555555, 0x4), TestFlagIter::end()) == expected); }; SECTION("odd from bit") { - std::vector expected = {0x8, 0x20, 0x80, 0x200, 0x800, - 0x2000, 0x8000, 0x20000, 0x80000, 0x200000, - 0x800000, 0x2000000, 0x8000000, 0x20000000, 0x80000000}; + rdcarray expected = {0x8, 0x20, 0x80, 0x200, 0x800, + 0x2000, 0x8000, 0x20000, 0x80000, 0x200000, + 0x800000, 0x2000000, 0x8000000, 0x20000000, 0x80000000}; CHECK(get_bits(TestFlagIter(0xAAAAAAAA, 0x4), TestFlagIter::end()) == expected); CHECK(get_bits(TestFlagIter(0xAAAAAAAA, 0x8), TestFlagIter::end()) == expected); }; @@ -118,12 +119,12 @@ TEST_CASE("Test BitFlagIterator type", "[bit_flag_iterator]") for(int i = 0; i < 32; i++) { uint32_t b = 1 << i; - std::vector expected = {b}; + rdcarray expected = {b}; if(i > 0) CHECK(get_bits(TestFlagIter(b, 1 << (i - 1)), TestFlagIter::end()) == expected); CHECK(get_bits(TestFlagIter(b, 1 << i), TestFlagIter::end()) == expected); if(i < 31) - CHECK(get_bits(TestFlagIter(b, 1 << (i + 1)), TestFlagIter::end()) == std::vector()); + CHECK(get_bits(TestFlagIter(b, 1 << (i + 1)), TestFlagIter::end()) == rdcarray()); } }; }; diff --git a/renderdoc/core/core.cpp b/renderdoc/core/core.cpp index ac68aba6d..4fa117186 100644 --- a/renderdoc/core/core.cpp +++ b/renderdoc/core/core.cpp @@ -263,7 +263,7 @@ void RenderDoc::RecreateCrashHandler() #if ENABLED(RDOC_WIN32) // there are way too many invalid reports coming from chrome, completely disable the crash handler // in that case. - std::string exename; + rdcstr exename; FileIO::GetExecutableFilename(exename); exename = strlower(exename); @@ -513,7 +513,7 @@ void RenderDoc::Shutdown() } } -void RenderDoc::ProcessGlobalEnvironment(GlobalEnvironment env, const std::vector &args) +void RenderDoc::ProcessGlobalEnvironment(GlobalEnvironment env, const rdcarray &args) { m_GlobalEnv = env; @@ -643,7 +643,7 @@ void RenderDoc::RegisterShutdownFunction(ShutdownFunction func) { auto it = std::lower_bound(m_ShutdownFunctions.begin(), m_ShutdownFunctions.end(), func); if(it == m_ShutdownFunctions.end() || *it != func) - m_ShutdownFunctions.insert(it, func); + m_ShutdownFunctions.insert(it - m_ShutdownFunctions.begin(), func); } bool RenderDoc::MatchClosestWindow(void *&dev, void *&wnd) @@ -770,7 +770,7 @@ bool RenderDoc::IsTargetControlConnected() return !RenderDoc::Inst().m_SingleClientName.empty(); } -std::string RenderDoc::GetTargetControlUsername() +rdcstr RenderDoc::GetTargetControlUsername() { SCOPED_LOCK(RenderDoc::Inst().m_SingleClientLock); return RenderDoc::Inst().m_SingleClientName; @@ -829,18 +829,18 @@ void RenderDoc::CycleActiveWindow() } } -std::string RenderDoc::GetOverlayText(RDCDriver driver, uint32_t frameNumber, int flags) +rdcstr RenderDoc::GetOverlayText(RDCDriver driver, uint32_t frameNumber, int flags) { const bool activeWindow = (flags & eOverlay_ActiveWindow); const bool capturesEnabled = (flags & eOverlay_CaptureDisabled) == 0; uint32_t overlay = GetOverlayBits(); - std::string overlayText = ToStr(driver) + ". "; + rdcstr overlayText = ToStr(driver) + ". "; if(activeWindow) { - std::vector keys = GetCaptureKeys(); + rdcarray keys = GetCaptureKeys(); if(capturesEnabled) { @@ -905,7 +905,7 @@ std::string RenderDoc::GetOverlayText(RDCDriver driver, uint32_t frameNumber, in } else if(capturesEnabled) { - std::vector keys = GetFocusKeys(); + rdcarray keys = GetFocusKeys(); overlayText += "Inactive window."; @@ -932,7 +932,7 @@ void RenderDoc::QueueCapture(uint32_t frameNumber) { auto it = std::lower_bound(m_QueuedFrameCaptures.begin(), m_QueuedFrameCaptures.end(), frameNumber); if(it == m_QueuedFrameCaptures.end() || *it != frameNumber) - m_QueuedFrameCaptures.insert(it, frameNumber); + m_QueuedFrameCaptures.insert(it - m_QueuedFrameCaptures.begin(), frameNumber); } bool RenderDoc::ShouldTriggerCapture(uint32_t frameNumber) @@ -942,7 +942,7 @@ bool RenderDoc::ShouldTriggerCapture(uint32_t frameNumber) if(m_Cap > 0) m_Cap--; - std::vector frames; + rdcarray frames; frames.swap(m_QueuedFrameCaptures); for(auto it = frames.begin(); it != frames.end(); ++it) { @@ -1070,6 +1070,7 @@ void RenderDoc::ResamplePixels(const FramePixels &in, RDCThumb &out) } } } + void RenderDoc::EncodePixelsPNG(const RDCThumb &in, RDCThumb &out) { if(in.width == 0 || in.height == 0) @@ -1080,13 +1081,12 @@ void RenderDoc::EncodePixelsPNG(const RDCThumb &in, RDCThumb &out) struct WriteCallbackData { - std::vector buffer; + bytebuf buffer; static void writeData(void *context, void *data, int size) { WriteCallbackData *pThis = (WriteCallbackData *)context; - const byte *start = (const byte *)data; - pThis->buffer.insert(pThis->buffer.end(), start, start + size); + pThis->buffer.append((const byte *)data, size); } }; @@ -1105,7 +1105,7 @@ RDCFile *RenderDoc::CreateRDC(RDCDriver driver, uint32_t frameNum, const FramePi { RDCFile *ret = new RDCFile; - std::string suffix = StringFormat::Fmt("_frame%u", frameNum); + rdcstr suffix = StringFormat::Fmt("_frame%u", frameNum); if(frameNum == ~0U) suffix = "_capture"; @@ -1198,7 +1198,7 @@ void RenderDoc::RegisterStructuredProcessor(RDCDriver driver, StructuredProcesso void RenderDoc::RegisterCaptureExporter(CaptureExporter exporter, CaptureFileFormat description) { - std::string filetype = description.extension; + rdcstr filetype = description.extension; for(const CaptureFileFormat &fmt : m_ImportExportFormats) { @@ -1220,7 +1220,7 @@ void RenderDoc::RegisterCaptureExporter(CaptureExporter exporter, CaptureFileFor void RenderDoc::RegisterCaptureImportExporter(CaptureImporter importer, CaptureExporter exporter, CaptureFileFormat description) { - std::string filetype = description.extension; + rdcstr filetype = description.extension; for(const CaptureFileFormat &fmt : m_ImportExportFormats) { @@ -1313,9 +1313,9 @@ IDeviceProtocolHandler *RenderDoc::GetDeviceProtocol(const rdcstr &protocol) return NULL; } -std::vector RenderDoc::GetCaptureFileFormats() +rdcarray RenderDoc::GetCaptureFileFormats() { - std::vector ret = m_ImportExportFormats; + rdcarray ret = m_ImportExportFormats; std::sort(ret.begin(), ret.end()); @@ -1327,7 +1327,7 @@ std::vector RenderDoc::GetCaptureFileFormats() rdc.openSupported = true; rdc.convertSupported = true; - ret.insert(ret.begin(), rdc); + ret.insert(0, rdc); } return ret; @@ -1484,17 +1484,17 @@ std::map RenderDoc::GetActiveDrivers() return ret; } -std::map RenderDoc::GetReplayDrivers() +std::map RenderDoc::GetReplayDrivers() { - std::map ret; + std::map ret; for(auto it = m_ReplayDriverProviders.begin(); it != m_ReplayDriverProviders.end(); ++it) ret[it->first] = ToStr(it->first); return ret; } -std::map RenderDoc::GetRemoteDrivers() +std::map RenderDoc::GetRemoteDrivers() { - std::map ret; + std::map ret; for(auto it = m_RemoteDriverProviders.begin(); it != m_RemoteDriverProviders.end(); ++it) ret[it->first] = ToStr(it->first); @@ -1649,13 +1649,13 @@ void RenderDoc::AddChildProcess(uint32_t pid, uint32_t ident) m_Children.push_back(make_rdcpair(pid, ident)); } -std::vector > RenderDoc::GetChildProcesses() +rdcarray > RenderDoc::GetChildProcesses() { SCOPED_LOCK(m_ChildLock); return m_Children; } -std::vector RenderDoc::GetCaptures() +rdcarray RenderDoc::GetCaptures() { SCOPED_LOCK(m_CaptureLock); return m_Captures; diff --git a/renderdoc/core/core.h b/renderdoc/core/core.h index ddb706eed..aea90b520 100644 --- a/renderdoc/core/core.h +++ b/renderdoc/core/core.h @@ -27,8 +27,6 @@ #include #include -#include -#include #include "api/app/renderdoc_app.h" #include "api/replay/apidefs.h" #include "api/replay/capture_options.h" @@ -226,11 +224,12 @@ ITERABLE_OPERATORS(VendorExtensions); struct CaptureData { - CaptureData(std::string p, uint64_t t, RDCDriver d, uint32_t f) + CaptureData() : timestamp(0), driver(RDCDriver::Unknown), frameNumber(0), retrieved(false) {} + CaptureData(rdcstr p, uint64_t t, RDCDriver d, uint32_t f) : path(p), timestamp(t), driver(d), frameNumber(f), retrieved(false) { } - std::string path; + rdcstr path; uint64_t timestamp; RDCDriver driver; uint32_t frameNumber; @@ -336,8 +335,8 @@ typedef ReplayStatus (*CaptureExporter)(const char *filename, const RDCFile &rdc RENDERDOC_ProgressCallback progress); typedef IDeviceProtocolHandler *(*ProtocolHandler)(); -typedef bool (*VulkanLayerCheck)(VulkanLayerFlags &flags, std::vector &myJSONs, - std::vector &otherJSONs); +typedef bool (*VulkanLayerCheck)(VulkanLayerFlags &flags, rdcarray &myJSONs, + rdcarray &otherJSONs); typedef void (*VulkanLayerInstall)(bool systemLevel); typedef void (*ShutdownFunction)(); @@ -411,14 +410,14 @@ public: uint64_t GetMicrosecondTimestamp() { return uint64_t(m_Timer.GetMicroseconds()); } const GlobalEnvironment &GetGlobalEnvironment() { return m_GlobalEnv; } - void ProcessGlobalEnvironment(GlobalEnvironment env, const std::vector &args); + void ProcessGlobalEnvironment(GlobalEnvironment env, const rdcarray &args); int32_t GetForwardedPortSlot() { return Atomic::Inc32(&m_PortSlot); } void RegisterShutdownFunction(ShutdownFunction func); void SetReplayApp(bool replay) { m_Replay = replay; } bool IsReplayApp() const { return m_Replay; } - const std::string &GetConfigSetting(std::string name) { return m_ConfigSettings[name]; } - void SetConfigSetting(std::string name, std::string value) { m_ConfigSettings[name] = value; } + const rdcstr &GetConfigSetting(rdcstr name) { return m_ConfigSettings[name]; } + void SetConfigSetting(rdcstr name, rdcstr value) { m_ConfigSettings[name] = value; } void BecomeRemoteServer(const char *listenhost, uint16_t port, RENDERDOC_KillCallback killReplay, RENDERDOC_PreviewWindowCallback previewWindow); @@ -440,9 +439,9 @@ public: void FinishCaptureWriting(RDCFile *rdc, uint32_t frameNumber); void AddChildProcess(uint32_t pid, uint32_t ident); - std::vector > GetChildProcesses(); + rdcarray > GetChildProcesses(); - std::vector GetCaptures(); + rdcarray GetCaptures(); void MarkCaptureRetrieved(uint32_t idx); @@ -464,13 +463,13 @@ public: rdcarray GetSupportedDeviceProtocols(); IDeviceProtocolHandler *GetDeviceProtocol(const rdcstr &protocol); - std::vector GetCaptureFileFormats(); + rdcarray GetCaptureFileFormats(); rdcarray GetAvailableGPUs(); void SetVulkanLayerCheck(VulkanLayerCheck callback) { m_VulkanCheck = callback; } void SetVulkanLayerInstall(VulkanLayerInstall callback) { m_VulkanInstall = callback; } - bool NeedVulkanLayerRegistration(VulkanLayerFlags &flags, std::vector &myJSONs, - std::vector &otherJSONs) + bool NeedVulkanLayerRegistration(VulkanLayerFlags &flags, rdcarray &myJSONs, + rdcarray &otherJSONs) { if(m_VulkanCheck) return m_VulkanCheck(flags, myJSONs, otherJSONs); @@ -496,8 +495,8 @@ public: bool HasReplaySupport(RDCDriver driverType); - std::map GetReplayDrivers(); - std::map GetRemoteDrivers(); + std::map GetReplayDrivers(); + std::map GetRemoteDrivers(); bool HasReplayDriver(RDCDriver driver) const; bool HasRemoteDriver(RDCDriver driver) const; @@ -507,7 +506,7 @@ public: uint32_t GetTargetControlIdent() const { return m_RemoteIdent; } bool IsTargetControlConnected(); - std::string GetTargetControlUsername(); + rdcstr GetTargetControlUsername(); void Tick(); @@ -555,8 +554,8 @@ public: m_CaptureKeys[i] = keys[i]; } - const std::vector &GetFocusKeys() { return m_FocusKeys; } - const std::vector &GetCaptureKeys() { return m_CaptureKeys; } + const rdcarray &GetFocusKeys() { return m_FocusKeys; } + const rdcarray &GetCaptureKeys() { return m_CaptureKeys; } bool ShouldTriggerCapture(uint32_t frameNumber); enum @@ -565,7 +564,7 @@ public: eOverlay_CaptureDisabled = 0x2, }; - std::string GetOverlayText(RDCDriver driver, uint32_t frameNumber, int flags); + rdcstr GetOverlayText(RDCDriver driver, uint32_t frameNumber, int flags); void CycleActiveWindow(); uint32_t GetCapturableWindowCount() { return (uint32_t)m_WindowFrameCapturers.size(); } @@ -581,8 +580,8 @@ private: uint32_t m_Cap; - std::vector m_FocusKeys; - std::vector m_CaptureKeys; + rdcarray m_FocusKeys; + rdcarray m_CaptureKeys; GlobalEnvironment m_GlobalEnv; @@ -593,12 +592,12 @@ private: rdcstr m_LoggingFilename; rdcstr m_Target; - std::string m_CaptureFileTemplate; - std::string m_CurrentLogFile; + rdcstr m_CaptureFileTemplate; + rdcstr m_CurrentLogFile; CaptureOptions m_Options; uint32_t m_Overlay; - std::vector m_QueuedFrameCaptures; + rdcarray m_QueuedFrameCaptures; uint32_t m_RemoteIdent; Threading::ThreadHandle m_RemoteThread; @@ -613,28 +612,28 @@ private: std::map m_ProgressCallbacks; Threading::CriticalSection m_CaptureLock; - std::vector m_Captures; + rdcarray m_Captures; Threading::CriticalSection m_ChildLock; - std::vector > m_Children; + rdcarray > m_Children; - std::map m_ConfigSettings; + std::map m_ConfigSettings; std::map m_ReplayDriverProviders; std::map m_RemoteDriverProviders; std::map m_StructProcesssors; - std::vector m_ImportExportFormats; - std::map m_Importers; - std::map m_Exporters; + rdcarray m_ImportExportFormats; + std::map m_Importers; + std::map m_Exporters; std::map m_Protocols; VulkanLayerCheck m_VulkanCheck; VulkanLayerInstall m_VulkanInstall; - std::vector m_ShutdownFunctions; + rdcarray m_ShutdownFunctions; struct FrameCap { @@ -687,7 +686,7 @@ private: volatile bool m_TargetControlThreadShutdown; volatile bool m_ControlClientThreadShutdown; Threading::CriticalSection m_SingleClientLock; - std::string m_SingleClientName; + rdcstr m_SingleClientName; PerformanceTimer m_Timer; diff --git a/renderdoc/core/crash_handler.h b/renderdoc/core/crash_handler.h index 7eb01dbaf..9005bd75c 100644 --- a/renderdoc/core/crash_handler.h +++ b/renderdoc/core/crash_handler.h @@ -80,11 +80,11 @@ public: RenderDoc::Inst().IsReplayApp() ? L"1" : L"0"), }; - std::wstring wideStr = StringFormat::UTF82Wide(std::string(FULL_VERSION_STRING)); + std::wstring wideStr = StringFormat::UTF82Wide(rdcstr(FULL_VERSION_STRING)); breakpadCustomInfo[0].set_value(wideStr.c_str()); - wideStr = StringFormat::UTF82Wide(std::string(RDCGETLOGFILE())); + wideStr = StringFormat::UTF82Wide(rdcstr(RDCGETLOGFILE())); breakpadCustomInfo[1].set_value(wideStr.c_str()); - wideStr = StringFormat::UTF82Wide(std::string(GitVersionHash)); + wideStr = StringFormat::UTF82Wide(rdcstr(GitVersionHash)); breakpadCustomInfo[2].set_value(wideStr.c_str()); google_breakpad::CustomClientInfo custom = {&breakpadCustomInfo[0], diff --git a/renderdoc/core/image_viewer.cpp b/renderdoc/core/image_viewer.cpp index c62fa73e6..6f34fcb34 100644 --- a/renderdoc/core/image_viewer.cpp +++ b/renderdoc/core/image_viewer.cpp @@ -72,7 +72,7 @@ public: bool IsRemoteProxy() { return true; } void Shutdown() { delete this; } // pass through necessary operations to proxy - std::vector GetSupportedWindowSystems() + rdcarray GetSupportedWindowSystems() { return m_Proxy->GetSupportedWindowSystems(); } @@ -129,7 +129,7 @@ public: return m_Proxy->GetMinMax(m_TextureID, sub, typeCast, minval, maxval); } bool GetHistogram(ResourceId texid, const Subresource &sub, CompType typeCast, float minval, - float maxval, bool channels[4], std::vector &histogram) + float maxval, bool channels[4], rdcarray &histogram) { return m_Proxy->GetHistogram(m_TextureID, sub, typeCast, minval, maxval, channels, histogram); } @@ -156,9 +156,9 @@ public: { return m_Proxy->GetCustomShaderEncodings(); } - void BuildCustomShader(ShaderEncoding sourceEncoding, bytebuf source, const std::string &entry, - const ShaderCompileFlags &compileFlags, ShaderStage type, ResourceId *id, - std::string *errors) + void BuildCustomShader(ShaderEncoding sourceEncoding, const bytebuf &source, const rdcstr &entry, + const ShaderCompileFlags &compileFlags, ShaderStage type, ResourceId &id, + rdcstr &errors) { m_Proxy->BuildCustomShader(sourceEncoding, source, entry, compileFlags, type, id, errors); } @@ -169,8 +169,8 @@ public: m_CustomTexID = m_Proxy->ApplyCustomShader(shader, m_TextureID, sub, typeCast); return m_CustomTexID; } - const std::vector &GetResources() { return m_Resources; } - std::vector GetTextures() { return {m_TextureID}; } + const rdcarray &GetResources() { return m_Resources; } + rdcarray GetTextures() { return {m_TextureID}; } TextureDescription GetTexture(ResourceId id) { return m_TexDetails; } void GetTextureData(ResourceId tex, const Subresource &sub, const GetTextureDataParams ¶ms, bytebuf &data) @@ -188,12 +188,11 @@ public: return ReplayStatus::Succeeded; } const SDFile &GetStructuredFile() { return m_File; } - void RenderMesh(uint32_t eventId, const std::vector &secondaryDraws, - const MeshDisplay &cfg) + void RenderMesh(uint32_t eventId, const rdcarray &secondaryDraws, const MeshDisplay &cfg) { } - std::vector GetBuffers() { return std::vector(); } - std::vector GetDebugMessages() { return std::vector(); } + rdcarray GetBuffers() { return rdcarray(); } + rdcarray GetDebugMessages() { return rdcarray(); } BufferDescription GetBuffer(ResourceId id) { BufferDescription ret; @@ -211,8 +210,8 @@ public: const GLPipe::State *GetGLPipelineState() { return NULL; } const VKPipe::State *GetVulkanPipelineState() { return NULL; } void ReplayLog(uint32_t endEventID, ReplayLogType replayType) {} - std::vector GetPassEvents(uint32_t eventId) { return std::vector(); } - std::vector GetUsage(ResourceId id) { return std::vector(); } + rdcarray GetPassEvents(uint32_t eventId) { return rdcarray(); } + rdcarray GetUsage(ResourceId id) { return rdcarray(); } bool IsRenderOutput(ResourceId id) { return false; } ResourceId GetLiveID(ResourceId id) { return id; } rdcarray EnumerateCounters() { return {}; } @@ -223,13 +222,13 @@ public: return desc; } rdcarray FetchCounters(const rdcarray &counters) { return {}; } - void FillCBufferVariables(ResourceId pipeline, ResourceId shader, std::string entryPoint, + void FillCBufferVariables(ResourceId pipeline, ResourceId shader, rdcstr entryPoint, uint32_t cbufSlot, rdcarray &outvars, const bytebuf &data) { } void GetBufferData(ResourceId buff, uint64_t offset, uint64_t len, bytebuf &retData) {} void InitPostVSBuffers(uint32_t eventId) {} - void InitPostVSBuffers(const std::vector &eventId) {} + void InitPostVSBuffers(const rdcarray &eventId) {} MeshFormat GetPostVSBuffers(uint32_t eventId, uint32_t instID, uint32_t viewID, MeshDataStage stage) { MeshFormat ret; @@ -238,7 +237,7 @@ public: } ResourceId RenderOverlay(ResourceId texid, CompType typeCast, FloatVector clearCol, DebugOverlay overlay, uint32_t eventId, - const std::vector &passEvents) + const rdcarray &passEvents) { return ResourceId(); } @@ -247,18 +246,16 @@ public: { return NULL; } - std::vector GetDisassemblyTargets() { return {"N/A"}; } - std::string DisassembleShader(ResourceId pipeline, const ShaderReflection *refl, - const std::string &target) + rdcarray GetDisassemblyTargets() { return {"N/A"}; } + rdcstr DisassembleShader(ResourceId pipeline, const ShaderReflection *refl, const rdcstr &target) { return ""; } void FreeTargetResource(ResourceId id) {} - std::vector PixelHistory(std::vector events, ResourceId target, - uint32_t x, uint32_t y, const Subresource &sub, - CompType typeCast) + rdcarray PixelHistory(rdcarray events, ResourceId target, uint32_t x, + uint32_t y, const Subresource &sub, CompType typeCast) { - return std::vector(); + return rdcarray(); } ShaderDebugTrace DebugVertex(uint32_t eventId, uint32_t vertid, uint32_t instid, uint32_t idx, uint32_t instOffset, uint32_t vertOffset) @@ -281,14 +278,12 @@ public: RDCEraseEl(ret); return ret; } - void BuildTargetShader(ShaderEncoding sourceEncoding, bytebuf source, const std::string &entry, - const ShaderCompileFlags &compileFlags, ShaderStage type, ResourceId *id, - std::string *errors) + void BuildTargetShader(ShaderEncoding sourceEncoding, const bytebuf &source, const rdcstr &entry, + const ShaderCompileFlags &compileFlags, ShaderStage type, ResourceId &id, + rdcstr &errors) { - if(id) - *id = ResourceId(); - if(errors) - *errors = "Building target shaders is unsupported"; + id = ResourceId(); + errors = "Building target shaders is unsupported"; } void ReplaceResource(ResourceId from, ResourceId to) {} void RemoveReplacement(ResourceId id) {} @@ -324,9 +319,9 @@ private: FrameRecord m_FrameRecord; D3D11Pipe::State m_PipelineState; IReplayDriver *m_Proxy; - std::string m_Filename; + rdcstr m_Filename; ResourceId m_TextureID, m_CustomTexID; - std::vector m_Resources; + rdcarray m_Resources; SDFile m_File; TextureDescription m_TexDetails; }; @@ -336,7 +331,7 @@ ReplayStatus IMG_CreateReplayDevice(RDCFile *rdc, IReplayDriver **driver) if(!rdc) return ReplayStatus::InternalError; - std::string filename; + rdcstr filename; FILE *f = rdc->StealImageFileHandle(filename); if(!f) @@ -351,7 +346,7 @@ ReplayStatus IMG_CreateReplayDevice(RDCFile *rdc, IReplayDriver **driver) uint64_t size = FileIO::ftell64(f); FileIO::fseek64(f, 0, SEEK_SET); - std::vector buffer; + bytebuf buffer; buffer.resize((size_t)size); FileIO::fread(&buffer[0], 1, buffer.size(), f); @@ -532,7 +527,7 @@ void ImageViewer::RefreshFile() FileIO::fseek64(f, 0, SEEK_SET); - std::vector buffer; + bytebuf buffer; buffer.resize((size_t)fileSize); FileIO::fread(buffer.data(), 1, buffer.size(), f); diff --git a/renderdoc/core/intervals_tests.cpp b/renderdoc/core/intervals_tests.cpp index 1bc55b5df..9022e619c 100644 --- a/renderdoc/core/intervals_tests.cpp +++ b/renderdoc/core/intervals_tests.cpp @@ -22,15 +22,16 @@ * THE SOFTWARE. ******************************************************************************/ -#include "intervals.h" #include "common/globalconfig.h" #if ENABLED(ENABLE_UNIT_TESTS) +#include "api/replay/rdcarray.h" +#include "intervals.h" + #include "3rdparty/catch/catch.hpp" #include -#include struct Interval { @@ -39,7 +40,7 @@ struct Interval uint64_t end; }; -void check_intervals(Intervals &value, const std::vector &expected) +void check_intervals(Intervals &value, const rdcarray &expected) { auto i = value.begin(); auto j = expected.begin(); @@ -53,7 +54,7 @@ void check_intervals(Intervals &value, const std::vector &ex CHECK((j == expected.end())); } -Intervals make_intervals(const std::vector &intervals) +Intervals make_intervals(const rdcarray &intervals) { Intervals res; for(auto i = intervals.begin(); i != intervals.end(); i++) diff --git a/renderdoc/core/plugins.cpp b/renderdoc/core/plugins.cpp index b9600ca6d..0f9a0365c 100644 --- a/renderdoc/core/plugins.cpp +++ b/renderdoc/core/plugins.cpp @@ -26,15 +26,15 @@ #include "os/os_specific.h" #include "strings/string_utils.h" -std::string LocatePluginFile(const std::string &path, const std::string &fileName) +rdcstr LocatePluginFile(const rdcstr &path, const rdcstr &fileName) { - std::string ret; + rdcstr ret; rdcstr libpath; FileIO::GetLibraryFilename(libpath); libpath = get_dirname(libpath); - std::vector paths; + rdcarray paths; #if defined(RENDERDOC_PLUGINS_PATH) string customPath(RENDERDOC_PLUGINS_PATH); @@ -72,7 +72,7 @@ std::string LocatePluginFile(const std::string &path, const std::string &fileNam for(uint32_t i = 0; i < paths.size(); i++) { - std::string check = paths[i] + "/" + path + "/" + fileName; + rdcstr check = paths[i] + "/" + path + "/" + fileName; if(FileIO::exists(check.c_str())) { ret = check; diff --git a/renderdoc/core/plugins.h b/renderdoc/core/plugins.h index 64a955bc2..04a766104 100644 --- a/renderdoc/core/plugins.h +++ b/renderdoc/core/plugins.h @@ -22,6 +22,6 @@ * THE SOFTWARE. ******************************************************************************/ -#include +#include "api/replay/rdcstr.h" -std::string LocatePluginFile(const std::string &path, const std::string &fileName); +rdcstr LocatePluginFile(const rdcstr &path, const rdcstr &fileName); diff --git a/renderdoc/core/remote_server.cpp b/renderdoc/core/remote_server.cpp index 55f91ca54..682e51dfb 100644 --- a/renderdoc/core/remote_server.cpp +++ b/renderdoc/core/remote_server.cpp @@ -125,7 +125,7 @@ rdcstr DoStringise(const RemoteServerPacket &el) END_ENUM_STRINGISE(); } -std::string GetRemoteServerChunkName(uint32_t idx) +rdcstr GetRemoteServerChunkName(uint32_t idx) { if(idx < eRemoteServer_RemoteServerCount) return ToStr((RemoteServerPacket)idx); @@ -261,7 +261,7 @@ static void ActiveRemoteClientThread(ClientThread *threadData, } } - std::vector tempFiles; + rdcarray tempFiles; IRemoteDriver *remoteDriver = NULL; IReplayDriver *replayDriver = NULL; ReplayProxy *proxy = NULL; @@ -308,7 +308,7 @@ static void ActiveRemoteClientThread(ClientThread *threadData, { reader.EndChunk(); - std::map drivers = RenderDoc::Inst().GetRemoteDrivers(); + std::map drivers = RenderDoc::Inst().GetRemoteDrivers(); uint32_t count = (uint32_t)drivers.size(); WRITE_DATA_SCOPE(); @@ -318,7 +318,7 @@ static void ActiveRemoteClientThread(ClientThread *threadData, for(auto it = drivers.begin(); it != drivers.end(); ++it) { RDCDriver driverType = it->first; - const std::string &driverName = it->second; + const rdcstr &driverName = it->second; SERIALISE_ELEMENT(driverType); SERIALISE_ELEMENT(driverName); @@ -328,7 +328,7 @@ static void ActiveRemoteClientThread(ClientThread *threadData, { reader.EndChunk(); - std::string home = FileIO::GetHomeFolderFilename(); + rdcstr home = FileIO::GetHomeFolderFilename(); { WRITE_DATA_SCOPE(); @@ -338,7 +338,7 @@ static void ActiveRemoteClientThread(ClientThread *threadData, } else if(type == eRemoteServer_ListDir) { - std::string path; + rdcstr path; { READ_DATA_SCOPE(); @@ -358,7 +358,7 @@ static void ActiveRemoteClientThread(ClientThread *threadData, } else if(type == eRemoteServer_CopyCaptureFromRemote) { - std::string path; + rdcstr path; { READ_DATA_SCOPE(); @@ -415,7 +415,7 @@ static void ActiveRemoteClientThread(ClientThread *threadData, } else if(type == eRemoteServer_TakeOwnershipCapture) { - std::string path; + rdcstr path; { READ_DATA_SCOPE(); @@ -456,7 +456,7 @@ static void ActiveRemoteClientThread(ClientThread *threadData, } else if(type == eRemoteServer_OpenLog) { - std::string path; + rdcstr path; ReplayOptions opts; { @@ -588,7 +588,7 @@ static void ActiveRemoteClientThread(ClientThread *threadData, { StreamReader *sectionReader = rdc->ReadSection(sectionIndex); - std::vector buf; + bytebuf buf; buf.resize((size_t)sectionReader->GetSize()); success = sectionReader->Read(buf.data(), sectionReader->GetSize()); @@ -665,7 +665,7 @@ static void ActiveRemoteClientThread(ClientThread *threadData, { reader.EndChunk(); - std::string driver = rdc ? rdc->GetDriverName() : ""; + rdcstr driver = rdc ? rdc->GetDriverName() : ""; { WRITE_DATA_SCOPE(); SCOPED_SERIALISE_CHUNK(eRemoteServer_GetDriverName); @@ -686,7 +686,7 @@ static void ActiveRemoteClientThread(ClientThread *threadData, } else if(type == eRemoteServer_FindSectionByName) { - std::string name; + rdcstr name; { READ_DATA_SCOPE(); @@ -825,7 +825,7 @@ static void ActiveRemoteClientThread(ClientThread *threadData, } else if(type == eRemoteServer_ExecuteAndInject) { - std::string app, workingDir, cmdLine, logfile; + rdcstr app, workingDir, cmdLine, logfile; CaptureOptions opts; rdcarray env; @@ -903,7 +903,7 @@ void RenderDoc::BecomeRemoteServer(const char *listenhost, uint16_t port, if(sock == NULL) return; - std::vector > listenRanges; + rdcarray > listenRanges; bool allowExecution = true; FILE *f = FileIO::fopen(FileIO::GetAppFolderFilename("remoteserver.conf").c_str(), "r"); @@ -998,7 +998,7 @@ void RenderDoc::BecomeRemoteServer(const char *listenhost, uint16_t port, ClientThread *activeClientData = NULL; - std::vector inactives; + rdcarray inactives; while(!killReplay()) { @@ -1015,7 +1015,7 @@ void RenderDoc::BecomeRemoteServer(const char *listenhost, uint16_t port, Threading::JoinThread(inactives[i]->thread); Threading::CloseThread(inactives[i]->thread); delete inactives[i]; - inactives.erase(inactives.begin() + i); + inactives.erase(i); break; } } @@ -1234,7 +1234,7 @@ RemoteServer::RemoteServer(Network::Socket *sock, const rdcstr &deviceID) writer->SetStreamingMode(true); reader->SetStreamingMode(true); - std::map m = RenderDoc::Inst().GetReplayDrivers(); + std::map m = RenderDoc::Inst().GetReplayDrivers(); m_Proxies.reserve(m.size()); for(auto it = m.begin(); it != m.end(); ++it) @@ -1335,7 +1335,7 @@ rdcarray RemoteServer::RemoteSupportedReplays() for(uint32_t i = 0; i < count; i++) { RDCDriver driverType = RDCDriver::Unknown; - std::string driverName = ""; + rdcstr driverName = ""; SERIALISE_ELEMENT(driverType); SERIALISE_ELEMENT(driverName); @@ -1420,9 +1420,9 @@ ExecuteResult RemoteServer::ExecuteAndInject(const char *a, const char *w, const const rdcarray &env, const CaptureOptions &opts) { - std::string app = a && a[0] ? a : ""; - std::string workingDir = w && w[0] ? w : ""; - std::string cmdline = c && c[0] ? c : ""; + rdcstr app = a && a[0] ? a : ""; + rdcstr workingDir = w && w[0] ? w : ""; + rdcstr cmdline = c && c[0] ? c : ""; { WRITE_DATA_SCOPE(); @@ -1458,7 +1458,7 @@ ExecuteResult RemoteServer::ExecuteAndInject(const char *a, const char *w, const void RemoteServer::CopyCaptureFromRemote(const char *remotepath, const char *localpath, RENDERDOC_ProgressCallback progress) { - std::string path = remotepath; + rdcstr path = remotepath; { WRITE_DATA_SCOPE(); @@ -1501,7 +1501,7 @@ rdcstr RemoteServer::CopyCaptureToRemote(const char *filename, RENDERDOC_Progres ser.SerialiseStream(filename, fileStream, progress); } - std::string path; + rdcstr path; { READ_DATA_SCOPE(); @@ -1524,7 +1524,7 @@ rdcstr RemoteServer::CopyCaptureToRemote(const char *filename, RENDERDOC_Progres void RemoteServer::TakeOwnershipCapture(const char *filename) { - std::string path = filename; + rdcstr path = filename; { WRITE_DATA_SCOPE(); @@ -1664,7 +1664,7 @@ rdcstr RemoteServer::DriverName() SCOPED_SERIALISE_CHUNK(eRemoteServer_GetDriverName); } - std::string driverName = ""; + rdcstr driverName = ""; { READ_DATA_SCOPE(); diff --git a/renderdoc/core/replay_proxy.cpp b/renderdoc/core/replay_proxy.cpp index 1db0afab9..de20087b8 100644 --- a/renderdoc/core/replay_proxy.cpp +++ b/renderdoc/core/replay_proxy.cpp @@ -354,12 +354,12 @@ rdcarray ReplayProxy::GetAvailableGPUs() } template -std::vector ReplayProxy::Proxied_GetDebugMessages(ParamSerialiser ¶mser, - ReturnSerialiser &retser) +rdcarray ReplayProxy::Proxied_GetDebugMessages(ParamSerialiser ¶mser, + ReturnSerialiser &retser) { const ReplayProxyPacket expectedPacket = eReplayProxy_GetDebugMessages; ReplayProxyPacket packet = eReplayProxy_GetDebugMessages; - std::vector ret; + rdcarray ret; { BEGIN_PARAMS(); @@ -377,18 +377,18 @@ std::vector ReplayProxy::Proxied_GetDebugMessages(ParamSerialiser return ret; } -std::vector ReplayProxy::GetDebugMessages() +rdcarray ReplayProxy::GetDebugMessages() { PROXY_FUNCTION(GetDebugMessages); } template -std::vector ReplayProxy::Proxied_GetTextures(ParamSerialiser ¶mser, - ReturnSerialiser &retser) +rdcarray ReplayProxy::Proxied_GetTextures(ParamSerialiser ¶mser, + ReturnSerialiser &retser) { const ReplayProxyPacket expectedPacket = eReplayProxy_GetTextures; ReplayProxyPacket packet = eReplayProxy_GetTextures; - std::vector ret; + rdcarray ret; { BEGIN_PARAMS(); @@ -406,7 +406,7 @@ std::vector ReplayProxy::Proxied_GetTextures(ParamSerialiser ¶ms return ret; } -std::vector ReplayProxy::GetTextures() +rdcarray ReplayProxy::GetTextures() { PROXY_FUNCTION(GetTextures); } @@ -445,12 +445,12 @@ TextureDescription ReplayProxy::GetTexture(ResourceId id) } template -std::vector ReplayProxy::Proxied_GetBuffers(ParamSerialiser ¶mser, - ReturnSerialiser &retser) +rdcarray ReplayProxy::Proxied_GetBuffers(ParamSerialiser ¶mser, + ReturnSerialiser &retser) { const ReplayProxyPacket expectedPacket = eReplayProxy_GetBuffers; ReplayProxyPacket packet = eReplayProxy_GetBuffers; - std::vector ret; + rdcarray ret; { BEGIN_PARAMS(); @@ -468,14 +468,14 @@ std::vector ReplayProxy::Proxied_GetBuffers(ParamSerialiser ¶mse return ret; } -std::vector ReplayProxy::GetBuffers() +rdcarray ReplayProxy::GetBuffers() { PROXY_FUNCTION(GetBuffers); } template -const std::vector &ReplayProxy::Proxied_GetResources(ParamSerialiser ¶mser, - ReturnSerialiser &retser) +const rdcarray &ReplayProxy::Proxied_GetResources(ParamSerialiser ¶mser, + ReturnSerialiser &retser) { const ReplayProxyPacket expectedPacket = eReplayProxy_GetResources; ReplayProxyPacket packet = eReplayProxy_GetResources; @@ -496,7 +496,7 @@ const std::vector &ReplayProxy::Proxied_GetResources(ParamS return m_Resources; } -const std::vector &ReplayProxy::GetResources() +const rdcarray &ReplayProxy::GetResources() { PROXY_FUNCTION(GetResources); } @@ -532,12 +532,12 @@ BufferDescription ReplayProxy::GetBuffer(ResourceId id) } template -std::vector ReplayProxy::Proxied_GetPassEvents(ParamSerialiser ¶mser, - ReturnSerialiser &retser, uint32_t eventId) +rdcarray ReplayProxy::Proxied_GetPassEvents(ParamSerialiser ¶mser, + ReturnSerialiser &retser, uint32_t eventId) { const ReplayProxyPacket expectedPacket = eReplayProxy_GetPassEvents; ReplayProxyPacket packet = eReplayProxy_GetPassEvents; - std::vector ret; + rdcarray ret; { BEGIN_PARAMS(); @@ -556,18 +556,18 @@ std::vector ReplayProxy::Proxied_GetPassEvents(ParamSerialiser ¶ms return ret; } -std::vector ReplayProxy::GetPassEvents(uint32_t eventId) +rdcarray ReplayProxy::GetPassEvents(uint32_t eventId) { PROXY_FUNCTION(GetPassEvents, eventId); } template -std::vector ReplayProxy::Proxied_GetUsage(ParamSerialiser ¶mser, - ReturnSerialiser &retser, ResourceId id) +rdcarray ReplayProxy::Proxied_GetUsage(ParamSerialiser ¶mser, + ReturnSerialiser &retser, ResourceId id) { const ReplayProxyPacket expectedPacket = eReplayProxy_GetUsage; ReplayProxyPacket packet = eReplayProxy_GetUsage; - std::vector ret; + rdcarray ret; { BEGIN_PARAMS(); @@ -586,7 +586,7 @@ std::vector ReplayProxy::Proxied_GetUsage(ParamSerialiser ¶mser, return ret; } -std::vector ReplayProxy::GetUsage(ResourceId id) +rdcarray ReplayProxy::GetUsage(ResourceId id) { PROXY_FUNCTION(GetUsage, id); } @@ -764,7 +764,7 @@ CounterDescription ReplayProxy::DescribeCounter(GPUCounter counterID) template void ReplayProxy::Proxied_FillCBufferVariables(ParamSerialiser ¶mser, ReturnSerialiser &retser, ResourceId pipeline, ResourceId shader, - std::string entryPoint, uint32_t cbufSlot, + rdcstr entryPoint, uint32_t cbufSlot, rdcarray &outvars, const bytebuf &data) { const ReplayProxyPacket expectedPacket = eReplayProxy_FillCBufferVariables; @@ -789,9 +789,9 @@ void ReplayProxy::Proxied_FillCBufferVariables(ParamSerialiser ¶mser, Return SERIALISE_RETURN(outvars); } -void ReplayProxy::FillCBufferVariables(ResourceId pipeline, ResourceId shader, - std::string entryPoint, uint32_t cbufSlot, - rdcarray &outvars, const bytebuf &data) +void ReplayProxy::FillCBufferVariables(ResourceId pipeline, ResourceId shader, rdcstr entryPoint, + uint32_t cbufSlot, rdcarray &outvars, + const bytebuf &data) { PROXY_FUNCTION(FillCBufferVariables, pipeline, shader, entryPoint, cbufSlot, outvars, data); } @@ -982,7 +982,7 @@ void ReplayProxy::InitPostVSBuffers(uint32_t eventId) template void ReplayProxy::Proxied_InitPostVSBuffers(ParamSerialiser ¶mser, ReturnSerialiser &retser, - const std::vector &events) + const rdcarray &events) { const ReplayProxyPacket expectedPacket = eReplayProxy_InitPostVSVec; ReplayProxyPacket packet = eReplayProxy_InitPostVSVec; @@ -1002,7 +1002,7 @@ void ReplayProxy::Proxied_InitPostVSBuffers(ParamSerialiser ¶mser, ReturnSer SERIALISE_RETURN_VOID(); } -void ReplayProxy::InitPostVSBuffers(const std::vector &events) +void ReplayProxy::InitPostVSBuffers(const rdcarray &events) { PROXY_FUNCTION(InitPostVSBuffers, events); } @@ -1046,8 +1046,7 @@ template ResourceId ReplayProxy::Proxied_RenderOverlay(ParamSerialiser ¶mser, ReturnSerialiser &retser, ResourceId texid, CompType typeCast, FloatVector clearCol, DebugOverlay overlay, - uint32_t eventId, - const std::vector &passEvents) + uint32_t eventId, const rdcarray &passEvents) { const ReplayProxyPacket expectedPacket = eReplayProxy_RenderOverlay; ReplayProxyPacket packet = eReplayProxy_RenderOverlay; @@ -1077,7 +1076,7 @@ ResourceId ReplayProxy::Proxied_RenderOverlay(ParamSerialiser ¶mser, ReturnS ResourceId ReplayProxy::RenderOverlay(ResourceId texid, CompType typeCast, FloatVector clearCol, DebugOverlay overlay, uint32_t eventId, - const std::vector &passEvents) + const rdcarray &passEvents) { PROXY_FUNCTION(RenderOverlay, texid, typeCast, clearCol, overlay, eventId, passEvents); } @@ -1170,16 +1169,15 @@ ShaderReflection *ReplayProxy::GetShader(ResourceId pipeline, ResourceId shader, } template -std::string ReplayProxy::Proxied_DisassembleShader(ParamSerialiser ¶mser, - ReturnSerialiser &retser, ResourceId pipeline, - const ShaderReflection *refl, - const std::string &target) +rdcstr ReplayProxy::Proxied_DisassembleShader(ParamSerialiser ¶mser, ReturnSerialiser &retser, + ResourceId pipeline, const ShaderReflection *refl, + const rdcstr &target) { const ReplayProxyPacket expectedPacket = eReplayProxy_DisassembleShader; ReplayProxyPacket packet = eReplayProxy_DisassembleShader; ResourceId Shader; ShaderEntryPoint EntryPoint; - std::string ret; + rdcstr ret; if(refl) { @@ -1208,19 +1206,19 @@ std::string ReplayProxy::Proxied_DisassembleShader(ParamSerialiser ¶mser, return ret; } -std::string ReplayProxy::DisassembleShader(ResourceId pipeline, const ShaderReflection *refl, - const std::string &target) +rdcstr ReplayProxy::DisassembleShader(ResourceId pipeline, const ShaderReflection *refl, + const rdcstr &target) { PROXY_FUNCTION(DisassembleShader, pipeline, refl, target); } template -std::vector ReplayProxy::Proxied_GetDisassemblyTargets(ParamSerialiser ¶mser, - ReturnSerialiser &retser) +rdcarray ReplayProxy::Proxied_GetDisassemblyTargets(ParamSerialiser ¶mser, + ReturnSerialiser &retser) { const ReplayProxyPacket expectedPacket = eReplayProxy_GetDisassemblyTargets; ReplayProxyPacket packet = eReplayProxy_GetDisassemblyTargets; - std::vector ret; + rdcarray ret; { BEGIN_PARAMS(); @@ -1238,7 +1236,7 @@ std::vector ReplayProxy::Proxied_GetDisassemblyTargets(ParamSeriali return ret; } -std::vector ReplayProxy::GetDisassemblyTargets() +rdcarray ReplayProxy::GetDisassemblyTargets() { PROXY_FUNCTION(GetDisassemblyTargets); } @@ -1301,15 +1299,15 @@ rdcarray ReplayProxy::GetTargetShaderEncodings() template void ReplayProxy::Proxied_BuildTargetShader(ParamSerialiser ¶mser, ReturnSerialiser &retser, - ShaderEncoding sourceEncoding, bytebuf source, - const std::string &entry, + ShaderEncoding sourceEncoding, const bytebuf &source, + const rdcstr &entry, const ShaderCompileFlags &compileFlags, - ShaderStage type, ResourceId *id, std::string *errors) + ShaderStage type, ResourceId &id, rdcstr &errors) { const ReplayProxyPacket expectedPacket = eReplayProxy_BuildTargetShader; ReplayProxyPacket packet = eReplayProxy_BuildTargetShader; ResourceId ret_id; - std::string ret_errors; + rdcstr ret_errors; { BEGIN_PARAMS(); @@ -1324,8 +1322,8 @@ void ReplayProxy::Proxied_BuildTargetShader(ParamSerialiser ¶mser, ReturnSer { REMOTE_EXECUTION(); if(paramser.IsReading() && !paramser.IsErrored() && !m_IsErrored) - m_Remote->BuildTargetShader(sourceEncoding, source, entry, compileFlags, type, &ret_id, - &ret_errors); + m_Remote->BuildTargetShader(sourceEncoding, source, entry, compileFlags, type, ret_id, + ret_errors); } { @@ -1336,18 +1334,16 @@ void ReplayProxy::Proxied_BuildTargetShader(ParamSerialiser ¶mser, ReturnSer SERIALISE_ELEMENT(packet); ser.EndChunk(); - if(id) - *id = ret_id; - if(errors) - *errors = ret_errors; + id = ret_id; + errors = ret_errors; } CheckError(packet, expectedPacket); } -void ReplayProxy::BuildTargetShader(ShaderEncoding sourceEncoding, bytebuf source, - const std::string &entry, const ShaderCompileFlags &compileFlags, - ShaderStage type, ResourceId *id, std::string *errors) +void ReplayProxy::BuildTargetShader(ShaderEncoding sourceEncoding, const bytebuf &source, + const rdcstr &entry, const ShaderCompileFlags &compileFlags, + ShaderStage type, ResourceId &id, rdcstr &errors) { PROXY_FUNCTION(BuildTargetShader, sourceEncoding, source, entry, compileFlags, type, id, errors); } @@ -1408,13 +1404,13 @@ void ReplayProxy::RemoveReplacement(ResourceId id) } template -std::vector ReplayProxy::Proxied_PixelHistory( - ParamSerialiser ¶mser, ReturnSerialiser &retser, std::vector events, +rdcarray ReplayProxy::Proxied_PixelHistory( + ParamSerialiser ¶mser, ReturnSerialiser &retser, rdcarray events, ResourceId target, uint32_t x, uint32_t y, const Subresource &sub, CompType typeCast) { const ReplayProxyPacket expectedPacket = eReplayProxy_PixelHistory; ReplayProxyPacket packet = eReplayProxy_PixelHistory; - std::vector ret; + rdcarray ret; { BEGIN_PARAMS(); @@ -1438,9 +1434,9 @@ std::vector ReplayProxy::Proxied_PixelHistory( return ret; } -std::vector ReplayProxy::PixelHistory(std::vector events, - ResourceId target, uint32_t x, uint32_t y, - const Subresource &sub, CompType typeCast) +rdcarray ReplayProxy::PixelHistory(rdcarray events, + ResourceId target, uint32_t x, uint32_t y, + const Subresource &sub, CompType typeCast) { PROXY_FUNCTION(PixelHistory, events, target, x, y, sub, typeCast); } @@ -2677,7 +2673,7 @@ bool ReplayProxy::Tick(int type) case eReplayProxy_FreeTargetResource: FreeTargetResource(ResourceId()); break; case eReplayProxy_FetchCounters: { - std::vector counters; + rdcarray counters; FetchCounters(counters); break; } @@ -2693,16 +2689,18 @@ bool ReplayProxy::Tick(int type) case eReplayProxy_InitPostVS: InitPostVSBuffers(0); break; case eReplayProxy_InitPostVSVec: { - std::vector dummy; + rdcarray dummy; InitPostVSBuffers(dummy); break; } case eReplayProxy_GetPostVS: GetPostVSBuffers(0, 0, 0, MeshDataStage::Unknown); break; case eReplayProxy_BuildTargetShader: { - std::string entry; + rdcstr entry; + ResourceId id; + rdcstr errors; BuildTargetShader(ShaderEncoding::Unknown, bytebuf(), entry, ShaderCompileFlags(), - ShaderStage::Vertex, NULL, NULL); + ShaderStage::Vertex, id, errors); break; } case eReplayProxy_ReplaceResource: ReplaceResource(ResourceId(), ResourceId()); break; @@ -2718,10 +2716,10 @@ bool ReplayProxy::Tick(int type) } case eReplayProxy_RenderOverlay: RenderOverlay(ResourceId(), CompType::Typeless, FloatVector(), DebugOverlay::NoOverlay, 0, - std::vector()); + rdcarray()); break; case eReplayProxy_PixelHistory: - PixelHistory(std::vector(), ResourceId(), 0, 0, Subresource(), CompType::Typeless); + PixelHistory(rdcarray(), ResourceId(), 0, 0, Subresource(), CompType::Typeless); break; case eReplayProxy_DisassembleShader: DisassembleShader(ResourceId(), NULL, ""); break; case eReplayProxy_GetDisassemblyTargets: GetDisassemblyTargets(); break; diff --git a/renderdoc/core/replay_proxy.h b/renderdoc/core/replay_proxy.h index 851ce872e..8cc044571 100644 --- a/renderdoc/core/replay_proxy.h +++ b/renderdoc/core/replay_proxy.h @@ -168,11 +168,11 @@ public: return ReplayStatus::Succeeded; } AMDRGPControl *GetRGPControl() { return NULL; } - std::vector GetSupportedWindowSystems() + rdcarray GetSupportedWindowSystems() { if(m_Proxy) return m_Proxy->GetSupportedWindowSystems(); - return std::vector(); + return rdcarray(); } uint64_t MakeOutputWindow(WindowingData window, bool depth) { @@ -311,7 +311,7 @@ public: } bool GetHistogram(ResourceId texid, const Subresource &sub, CompType typeCast, float minval, - float maxval, bool channels[4], std::vector &histogram) + float maxval, bool channels[4], rdcarray &histogram) { if(m_Proxy) { @@ -326,8 +326,7 @@ public: return false; } - void RenderMesh(uint32_t eventId, const std::vector &secondaryDraws, - const MeshDisplay &cfg) + void RenderMesh(uint32_t eventId, const rdcarray &secondaryDraws, const MeshDisplay &cfg) { if(m_Proxy && cfg.position.vertexResourceId != ResourceId()) { @@ -351,7 +350,7 @@ public: proxiedCfg.position.indexResourceId = m_ProxyBufferIds[proxiedCfg.position.indexResourceId]; } - std::vector secDraws = secondaryDraws; + rdcarray secDraws = secondaryDraws; for(size_t i = 0; i < secDraws.size(); i++) { @@ -402,9 +401,9 @@ public: return ~0U; } - void BuildCustomShader(ShaderEncoding sourceEncoding, bytebuf source, const std::string &entry, - const ShaderCompileFlags &compileFlags, ShaderStage type, ResourceId *id, - std::string *errors) + void BuildCustomShader(ShaderEncoding sourceEncoding, const bytebuf &source, const rdcstr &entry, + const ShaderCompileFlags &compileFlags, ShaderStage type, ResourceId &id, + rdcstr &errors) { if(m_Proxy) { @@ -412,10 +411,8 @@ public: } else { - if(id) - *id = ResourceId(); - if(errors) - *errors = "Unsupported BuildShader call on proxy without local renderer"; + id = ResourceId(); + errors = "Unsupported BuildShader call on proxy without local renderer"; } } @@ -461,26 +458,26 @@ public: const SDFile &GetStructuredFile() { return m_StructuredFile; } IMPLEMENT_FUNCTION_PROXIED(void, FetchStructuredFile); - IMPLEMENT_FUNCTION_PROXIED(const std::vector &, GetResources); + IMPLEMENT_FUNCTION_PROXIED(const rdcarray &, GetResources); - IMPLEMENT_FUNCTION_PROXIED(std::vector, GetBuffers); + IMPLEMENT_FUNCTION_PROXIED(rdcarray, GetBuffers); IMPLEMENT_FUNCTION_PROXIED(BufferDescription, GetBuffer, ResourceId id); - IMPLEMENT_FUNCTION_PROXIED(std::vector, GetTextures); + IMPLEMENT_FUNCTION_PROXIED(rdcarray, GetTextures); IMPLEMENT_FUNCTION_PROXIED(TextureDescription, GetTexture, ResourceId id); IMPLEMENT_FUNCTION_PROXIED(APIProperties, GetAPIProperties); IMPLEMENT_FUNCTION_PROXIED(DriverInformation, GetDriverInfo); IMPLEMENT_FUNCTION_PROXIED(rdcarray, GetAvailableGPUs); - IMPLEMENT_FUNCTION_PROXIED(std::vector, GetDebugMessages); + IMPLEMENT_FUNCTION_PROXIED(rdcarray, GetDebugMessages); IMPLEMENT_FUNCTION_PROXIED(void, SavePipelineState, uint32_t eventId); IMPLEMENT_FUNCTION_PROXIED(void, ReplayLog, uint32_t endEventID, ReplayLogType replayType); - IMPLEMENT_FUNCTION_PROXIED(std::vector, GetPassEvents, uint32_t eventId); + IMPLEMENT_FUNCTION_PROXIED(rdcarray, GetPassEvents, uint32_t eventId); - IMPLEMENT_FUNCTION_PROXIED(std::vector, GetUsage, ResourceId id); + IMPLEMENT_FUNCTION_PROXIED(rdcarray, GetUsage, ResourceId id); IMPLEMENT_FUNCTION_PROXIED(FrameRecord, GetFrameRecord); IMPLEMENT_FUNCTION_PROXIED(bool, IsRenderOutput, ResourceId id); @@ -493,7 +490,7 @@ public: const rdcarray &counterID); IMPLEMENT_FUNCTION_PROXIED(void, FillCBufferVariables, ResourceId pipeline, ResourceId shader, - std::string entryPoint, uint32_t cbufSlot, + rdcstr entryPoint, uint32_t cbufSlot, rdcarray &outvars, const bytebuf &data); IMPLEMENT_FUNCTION_PROXIED(void, GetBufferData, ResourceId buff, uint64_t offset, uint64_t len, @@ -502,27 +499,27 @@ public: const GetTextureDataParams ¶ms, bytebuf &data); IMPLEMENT_FUNCTION_PROXIED(void, InitPostVSBuffers, uint32_t eventId); - IMPLEMENT_FUNCTION_PROXIED(void, InitPostVSBuffers, const std::vector &passEvents); + IMPLEMENT_FUNCTION_PROXIED(void, InitPostVSBuffers, const rdcarray &passEvents); IMPLEMENT_FUNCTION_PROXIED(MeshFormat, GetPostVSBuffers, uint32_t eventId, uint32_t instID, uint32_t viewID, MeshDataStage stage); IMPLEMENT_FUNCTION_PROXIED(ResourceId, RenderOverlay, ResourceId texid, CompType typeCast, FloatVector clearCol, DebugOverlay overlay, uint32_t eventId, - const std::vector &passEvents); + const rdcarray &passEvents); IMPLEMENT_FUNCTION_PROXIED(rdcarray, GetShaderEntryPoints, ResourceId shader); IMPLEMENT_FUNCTION_PROXIED(ShaderReflection *, GetShader, ResourceId pipeline, ResourceId, ShaderEntryPoint entry); - IMPLEMENT_FUNCTION_PROXIED(std::vector, GetDisassemblyTargets); - IMPLEMENT_FUNCTION_PROXIED(std::string, DisassembleShader, ResourceId pipeline, - const ShaderReflection *refl, const std::string &target); + IMPLEMENT_FUNCTION_PROXIED(rdcarray, GetDisassemblyTargets); + IMPLEMENT_FUNCTION_PROXIED(rdcstr, DisassembleShader, ResourceId pipeline, + const ShaderReflection *refl, const rdcstr &target); IMPLEMENT_FUNCTION_PROXIED(void, FreeTargetResource, ResourceId id); - IMPLEMENT_FUNCTION_PROXIED(std::vector, PixelHistory, - std::vector events, ResourceId target, uint32_t x, - uint32_t y, const Subresource &sub, CompType typeCast); + IMPLEMENT_FUNCTION_PROXIED(rdcarray, PixelHistory, rdcarray events, + ResourceId target, uint32_t x, uint32_t y, const Subresource &sub, + CompType typeCast); IMPLEMENT_FUNCTION_PROXIED(ShaderDebugTrace, DebugVertex, uint32_t eventId, uint32_t vertid, uint32_t instid, uint32_t idx, uint32_t instOffset, uint32_t vertOffset); IMPLEMENT_FUNCTION_PROXIED(ShaderDebugTrace, DebugPixel, uint32_t eventId, uint32_t x, uint32_t y, @@ -531,9 +528,10 @@ public: const uint32_t groupid[3], const uint32_t threadid[3]); IMPLEMENT_FUNCTION_PROXIED(rdcarray, GetTargetShaderEncodings); - IMPLEMENT_FUNCTION_PROXIED(void, BuildTargetShader, ShaderEncoding sourceEncoding, bytebuf source, - const std::string &entry, const ShaderCompileFlags &compileFlags, - ShaderStage type, ResourceId *id, std::string *errors); + IMPLEMENT_FUNCTION_PROXIED(void, BuildTargetShader, ShaderEncoding sourceEncoding, + const bytebuf &source, const rdcstr &entry, + const ShaderCompileFlags &compileFlags, ShaderStage type, + ResourceId &id, rdcstr &errors); IMPLEMENT_FUNCTION_PROXIED(void, ReplaceResource, ResourceId from, ResourceId to); IMPLEMENT_FUNCTION_PROXIED(void, RemoveReplacement, ResourceId id); @@ -710,11 +708,11 @@ private: APIProperties m_APIProps; std::map m_TextureInfo; - std::vector m_Drawcalls; + rdcarray m_Drawcalls; SDFile m_StructuredFile; - std::vector m_Resources; + rdcarray m_Resources; D3D11Pipe::State m_D3D11PipelineState; D3D12Pipe::State m_D3D12PipelineState; diff --git a/renderdoc/core/resource_manager.h b/renderdoc/core/resource_manager.h index 109b08cd8..5b9243e97 100644 --- a/renderdoc/core/resource_manager.h +++ b/renderdoc/core/resource_manager.h @@ -370,14 +370,7 @@ struct ResourceRecord void RemoveChunk(Chunk *chunk) { LockChunks(); - for(auto it = m_Chunks.begin(); it != m_Chunks.end(); ++it) - { - if(it->second == chunk) - { - m_Chunks.erase(it); - break; - } - } + m_Chunks.removeOneIf([chunk](const rdcpair &c) { return c.second == chunk; }); UnlockChunks(); } @@ -500,7 +493,7 @@ protected: return Atomic::Inc32(&globalIDCounter); } - std::vector> m_Chunks; + rdcarray> m_Chunks; Threading::CriticalSection *m_ChunkLock; std::map m_FrameRefs; @@ -661,7 +654,7 @@ protected: const InitialContentData *initialData) = 0; virtual void Create_InitialState(ResourceId id, WrappedResourceType live, bool hasData) = 0; virtual void Apply_InitialState(WrappedResourceType live, const InitialContentData &initial) = 0; - virtual std::vector InitialContentResources(); + virtual rdcarray InitialContentResources(); // very coarse lock, protects EVERYTHING. This could certainly be improved and it may be a // bottleneck @@ -908,7 +901,7 @@ void ResourceManager::Serialise_InitialContentsNeeded(WriteSerial SCOPED_LOCK(m_Lock); - std::vector WrittenRecords; + rdcarray WrittenRecords; // reasonable estimate, and these records are small WrittenRecords.reserve(m_FrameReferencedResources.size()); @@ -1055,7 +1048,7 @@ void ResourceManager::CreateInitialContents(ReadSerialiser &ser) std::set neededInitials; - std::vector WrittenRecords; + rdcarray WrittenRecords; SERIALISE_ELEMENT(WrittenRecords); for(const WrittenRecord &wr : WrittenRecords) @@ -1089,7 +1082,7 @@ template void ResourceManager::ApplyInitialContents() { RDCDEBUG("Applying initial contents"); - std::vector resources = InitialContentResources(); + rdcarray resources = InitialContentResources(); for(auto it = resources.begin(); it != resources.end(); ++it) { ResourceId id = *it; @@ -1101,9 +1094,9 @@ void ResourceManager::ApplyInitialContents() } template -std::vector ResourceManager::InitialContentResources() +rdcarray ResourceManager::InitialContentResources() { - std::vector resources; + rdcarray resources; for(auto it = m_InitialContents.begin(); it != m_InitialContents.end(); ++it) { ResourceId id = it->first; diff --git a/renderdoc/core/target_control.cpp b/renderdoc/core/target_control.cpp index d131e404e..74e7b2dcf 100644 --- a/renderdoc/core/target_control.cpp +++ b/renderdoc/core/target_control.cpp @@ -108,7 +108,7 @@ void RenderDoc::TargetControlClientThread(uint32_t version, Network::Socket *cli writer.SetStreamingMode(true); reader.SetStreamingMode(true); - std::string target = RenderDoc::Inst().GetCurrentTarget(); + rdcstr target = RenderDoc::Inst().GetCurrentTarget(); uint32_t mypid = Process::GetCurrentPID(); { @@ -141,8 +141,8 @@ void RenderDoc::TargetControlClientThread(uint32_t version, Network::Socket *cli const int progresstime = 100; // update capture progress every 100ms int curtime = 0; - std::vector captures; - std::vector > children; + rdcarray captures; + rdcarray > children; std::map drivers; float prevCaptureProgress = captureProgress; uint32_t prevWindows = 0; @@ -160,8 +160,8 @@ void RenderDoc::TargetControlClientThread(uint32_t version, Network::Socket *cli std::map curdrivers = RenderDoc::Inst().GetActiveDrivers(); - std::vector caps = RenderDoc::Inst().GetCaptures(); - std::vector > childprocs = RenderDoc::Inst().GetChildProcesses(); + rdcarray caps = RenderDoc::Inst().GetCaptures(); + rdcarray > childprocs = RenderDoc::Inst().GetChildProcesses(); uint32_t curWindows = RenderDoc::Inst().GetCapturableWindowCount(); @@ -204,7 +204,7 @@ void RenderDoc::TargetControlClientThread(uint32_t version, Network::Socket *cli captures.push_back(caps[idx]); - std::string path = FileIO::GetFullPathname(captures.back().path); + rdcstr path = FileIO::GetFullPathname(captures.back().path); bytebuf buf; @@ -339,7 +339,7 @@ void RenderDoc::TargetControlClientThread(uint32_t version, Network::Socket *cli SCOPED_SERIALISE_CHUNK(ePacket_CopyCapture); SERIALISE_ELEMENT(id); - std::string filename = caps[id].path; + rdcstr filename = caps[id].path; StreamReader fileStream(FileIO::fopen(filename.c_str(), "rb")); ser.SerialiseStream(filename, fileStream); @@ -403,8 +403,8 @@ void RenderDoc::TargetControlServerThread(Network::Socket *sock) continue; } - std::string existingClient; - std::string newClient; + rdcstr existingClient; + rdcstr newClient; uint32_t version; bool kick = false; @@ -472,7 +472,7 @@ void RenderDoc::TargetControlServerThread(Network::Socket *sock) ser.SetStreamingMode(true); - std::string target = RenderDoc::Inst().GetCurrentTarget(); + rdcstr target = RenderDoc::Inst().GetCurrentTarget(); { SCOPED_SERIALISE_CHUNK(ePacket_Busy); SERIALISE_ELEMENT(TargetControlProtocolVersion); @@ -498,12 +498,12 @@ void RenderDoc::TargetControlServerThread(Network::Socket *sock) struct TargetControl : public ITargetControl { public: - TargetControl(Network::Socket *sock, std::string clientName, bool forceConnection) + TargetControl(Network::Socket *sock, rdcstr clientName, bool forceConnection) : m_Socket(sock), reader(new StreamReader(sock, Ownership::Nothing), Ownership::Stream), writer(new StreamWriter(sock, Ownership::Nothing), Ownership::Stream) { - std::vector payload; + bytebuf payload; writer.SetStreamingMode(true); reader.SetStreamingMode(true); @@ -856,10 +856,10 @@ private: Network::Socket *m_Socket; WriteSerialiser writer; ReadSerialiser reader; - std::string m_Target, m_API, m_BusyClient; + rdcstr m_Target, m_API, m_BusyClient; uint32_t m_Version, m_PID; - std::map m_CaptureCopies; + std::map m_CaptureCopies; }; extern "C" RENDERDOC_API ITargetControl *RENDERDOC_CC RENDERDOC_CreateTargetControl( diff --git a/renderdoc/data/glsl_shaders.cpp b/renderdoc/data/glsl_shaders.cpp index 320189a01..b560ca738 100644 --- a/renderdoc/data/glsl_shaders.cpp +++ b/renderdoc/data/glsl_shaders.cpp @@ -38,7 +38,7 @@ class EmbeddedIncluder : public glslang::TShader::Includer { -#define DECL(header) std::string header = GetEmbeddedResource(CONCAT(glsl_, CONCAT(header, _h))); +#define DECL(header) rdcstr header = GetEmbeddedResource(CONCAT(glsl_, CONCAT(header, _h))); GLSL_HEADERS(DECL) #undef DECL @@ -68,13 +68,12 @@ public: virtual void releaseInclude(IncludeResult *result) override { delete result; } }; -std::string GenerateGLSLShader(const std::string &shader, ShaderType type, int version, - const std::string &defines) +rdcstr GenerateGLSLShader(const rdcstr &shader, ShaderType type, int version, const rdcstr &defines) { // shader stage doesn't matter for us since we're just pre-processing. glslang::TShader sh(EShLangFragment); - std::string combined; + rdcstr combined; if(type == ShaderType::GLSLES) { @@ -93,7 +92,7 @@ std::string GenerateGLSLShader(const std::string &shader, ShaderType type, int v // glslang requires the google extension, but we don't want it in the final shader, so remember it // and remove it later. - std::string include_ext = "#extension GL_GOOGLE_include_directive : require\n"; + rdcstr include_ext = "#extension GL_GOOGLE_include_directive : require\n"; combined += include_ext; @@ -130,23 +129,28 @@ std::string GenerateGLSLShader(const std::string &shader, ShaderType type, int v else if(type == ShaderType::GLSPIRV) flags = EShMessages(flags | EShMsgSpvRules); - std::string ret; + rdcstr ret; + bool success; - bool success = - sh.preprocess(GetDefaultResources(), 100, ENoProfile, false, false, flags, &ret, incl); + { + std::string outstr; + success = + sh.preprocess(GetDefaultResources(), 100, ENoProfile, false, false, flags, &outstr, incl); + ret = outstr; + } - size_t offs = ret.find(include_ext); - if(offs != std::string::npos) + int offs = ret.find(include_ext); + if(offs >= 0) ret.erase(offs, include_ext.size()); // strip any #line directives that got added offs = ret.find("\n#line "); - while(offs != std::string::npos) + while(offs >= 0) { - size_t eol = ret.find('\n', offs + 2); + int eol = ret.find('\n', offs + 2); - if(eol == std::string::npos) - ret.erase(offs + 1); + if(eol < 0) + ret.erase(offs + 1, ~0U); else ret.erase(offs + 1, eol - offs); @@ -182,7 +186,7 @@ void TestGLSLReflection(ShaderType testType, ReflectionMaker compile) SECTION("GL global uniforms") { - std::string source = R"( + rdcstr source = R"( #version 450 core layout(location = 100) uniform vec3 global_var[5]; @@ -256,7 +260,7 @@ void main() { SECTION("GL atomic counters") { - std::string source = R"( + rdcstr source = R"( #version 450 core layout(binding = 0) uniform atomic_uint atom; @@ -307,7 +311,7 @@ void main() { SECTION("Vulkan separate sampler objects") { - std::string source = R"( + rdcstr source = R"( #version 450 core layout (set=1, binding=2) uniform sampler S; @@ -391,7 +395,7 @@ void main() { SECTION("Vulkan specialization constants") { - std::string source = R"( + rdcstr source = R"( #version 450 core layout(constant_id = 17) const int foo = 12; @@ -470,7 +474,7 @@ void main() { SECTION("Vulkan push constants") { - std::string source = R"( + rdcstr source = R"( #version 450 core layout(push_constant) uniform push @@ -563,7 +567,7 @@ void main() { SECTION("Debug information") { - std::string source = R"( + rdcstr source = R"( #version 450 core layout(location = 3) in vec2 a_input; @@ -623,7 +627,7 @@ void main() { SECTION("Input and output signatures") { - std::string source = R"( + rdcstr source = R"( #version 450 core layout(location = 3) in vec2 a_input; @@ -764,7 +768,7 @@ void main() { SECTION("constant buffers") { - std::string source = R"( + rdcstr source = R"( #version 450 core struct glstruct @@ -968,7 +972,7 @@ void main() { SECTION("Textures") { - std::string source = R"( + rdcstr source = R"( #version 450 core layout(binding = 3) uniform sampler2D tex2D; @@ -1050,7 +1054,7 @@ void main() { SECTION("SSBOs") { - std::string source = R"( + rdcstr source = R"( #version 450 core struct glstruct @@ -1341,7 +1345,7 @@ void main() { SECTION("vertex shader fixed function outputs") { - std::string source = R"( + rdcstr source = R"( #version 450 core void main() { @@ -1375,7 +1379,7 @@ void main() { } } - std::string source2 = R"( + rdcstr source2 = R"( #version 450 core void main() { @@ -1426,7 +1430,7 @@ void main() { SECTION("matrix and array outputs") { - std::string source = R"( + rdcstr source = R"( #version 450 core layout(location = 0) out vec3 outarr[3]; @@ -1598,7 +1602,7 @@ void main() SECTION("shader input/output blocks") { - std::string source = R"( + rdcstr source = R"( #version 450 core layout(triangles) in; @@ -1713,7 +1717,7 @@ void main() SECTION("Arrays of opaque resources") { - std::string source = R"( + rdcstr source = R"( #version 450 core layout(binding = 2, std430) buffer ssbo diff --git a/renderdoc/data/glsl_shaders.h b/renderdoc/data/glsl_shaders.h index 832a4de57..36d9cae34 100644 --- a/renderdoc/data/glsl_shaders.h +++ b/renderdoc/data/glsl_shaders.h @@ -31,17 +31,16 @@ enum class ShaderType }; #include -#include -#include +#include "api/replay/rdcstr.h" -std::string GenerateGLSLShader(const std::string &shader, ShaderType type, int version, - const std::string &defines = ""); +rdcstr GenerateGLSLShader(const rdcstr &shader, ShaderType type, int version, + const rdcstr &defines = ""); // for unit tests struct ShaderReflection; struct ShaderBindpointMapping; enum class ShaderStage : uint32_t; using ReflectionMaker = - std::function; void TestGLSLReflection(ShaderType testType, ReflectionMaker compile); diff --git a/renderdoc/driver/d3d11/d3d11_context.cpp b/renderdoc/driver/d3d11/d3d11_context.cpp index 38a2a30a3..d508f4a74 100644 --- a/renderdoc/driver/d3d11/d3d11_context.cpp +++ b/renderdoc/driver/d3d11/d3d11_context.cpp @@ -254,7 +254,7 @@ D3D11ResourceManager *WrappedID3D11DeviceContext::GetResourceManager() return m_pDevice->GetResourceManager(); } -std::string WrappedID3D11DeviceContext::GetChunkName(uint32_t idx) +rdcstr WrappedID3D11DeviceContext::GetChunkName(uint32_t idx) { if((SystemChunk)idx < SystemChunk::FirstDriverChunk) return ToStr((SystemChunk)idx); diff --git a/renderdoc/driver/d3d11/d3d11_context.h b/renderdoc/driver/d3d11/d3d11_context.h index 0a3112721..9e4cc87fb 100644 --- a/renderdoc/driver/d3d11/d3d11_context.h +++ b/renderdoc/driver/d3d11/d3d11_context.h @@ -149,7 +149,7 @@ private: bool m_NeedUpdateSubWorkaround; WriteSerialiser m_ScratchSerialiser; - std::set m_StringDB; + std::set m_StringDB; ResourceId m_CurContextId; @@ -219,7 +219,7 @@ private: std::list m_DrawcallStack; D3D11ResourceManager *GetResourceManager(); - static std::string GetChunkName(uint32_t idx); + static rdcstr GetChunkName(uint32_t idx); template void Serialise_DebugMessages(SerialiserType &ser); diff --git a/renderdoc/driver/d3d11/d3d11_debug.h b/renderdoc/driver/d3d11/d3d11_debug.h index 49b4cc2df..1cdc055fe 100644 --- a/renderdoc/driver/d3d11/d3d11_debug.h +++ b/renderdoc/driver/d3d11/d3d11_debug.h @@ -118,7 +118,7 @@ public: return it->second; return NULL; } - void GetCounterBuffers(std::vector &ret) + void GetCounterBuffers(rdcarray &ret) { for(auto pair : m_CounterBufferToUAV) ret.push_back(pair.first); diff --git a/renderdoc/driver/d3d11/d3d11_device.cpp b/renderdoc/driver/d3d11/d3d11_device.cpp index 6dd013d51..7bea2a4c8 100644 --- a/renderdoc/driver/d3d11/d3d11_device.cpp +++ b/renderdoc/driver/d3d11/d3d11_device.cpp @@ -781,7 +781,7 @@ HRESULT WrappedID3D11Device::QueryInterface(REFIID riid, void **ppvObject) return m_RefCounter.QueryInterface(riid, ppvObject); } -std::string WrappedID3D11Device::GetChunkName(uint32_t idx) +rdcstr WrappedID3D11Device::GetChunkName(uint32_t idx) { if((SystemChunk)idx < SystemChunk::FirstDriverChunk) return ToStr((SystemChunk)idx); @@ -1245,7 +1245,7 @@ ReplayStatus WrappedID3D11Device::ReadLogInitialisation(RDCFile *rdc, bool store SetupDrawcallPointers(m_Drawcalls, GetReplay()->WriteFrameRecord().drawcallList); // propagate any UAV names onto counter buffers - std::vector counterBuffers; + rdcarray counterBuffers; GetDebugManager()->GetCounterBuffers(counterBuffers); for(ResourceId buffId : counterBuffers) diff --git a/renderdoc/driver/d3d11/d3d11_device.h b/renderdoc/driver/d3d11/d3d11_device.h index b3d8b4869..992c43ddf 100644 --- a/renderdoc/driver/d3d11/d3d11_device.h +++ b/renderdoc/driver/d3d11/d3d11_device.h @@ -339,7 +339,7 @@ private: bool m_D3DThreadSafe = false; WriteSerialiser m_ScratchSerialiser; - std::set m_StringDB; + std::set m_StringDB; ResourceId m_ResourceID; D3D11ResourceRecord *m_DeviceRecord; @@ -387,7 +387,7 @@ private: std::vector m_DebugMessages; std::vector m_CapturedFrames; - std::vector m_Drawcalls; + rdcarray m_Drawcalls; public: static const int AllocPoolCount = 4; @@ -415,7 +415,7 @@ public: void AddResourceCurChunk(ResourceId id); ID3D11Device *GetReal() { return m_pDevice; } - static std::string GetChunkName(uint32_t idx); + static rdcstr GetChunkName(uint32_t idx); D3D11ShaderCache *GetShaderCache() { return m_ShaderCache; } D3D11ResourceManager *GetResourceManager() { return m_ResourceManager; } D3D11DebugManager *GetDebugManager() { return m_DebugManager; } diff --git a/renderdoc/driver/d3d11/d3d11_overlay.cpp b/renderdoc/driver/d3d11/d3d11_overlay.cpp index 3337d7501..31c235e11 100644 --- a/renderdoc/driver/d3d11/d3d11_overlay.cpp +++ b/renderdoc/driver/d3d11/d3d11_overlay.cpp @@ -40,7 +40,7 @@ ResourceId D3D11Replay::RenderOverlay(ResourceId texid, CompType typeCast, FloatVector clearCol, DebugOverlay overlay, uint32_t eventId, - const std::vector &passEvents) + const rdcarray &passEvents) { TextureShaderDetails details = GetDebugManager()->GetShaderDetails(texid, typeCast, false); @@ -572,7 +572,7 @@ ResourceId D3D11Replay::RenderOverlay(ResourceId texid, CompType typeCast, Float } else if(overlay == DebugOverlay::ClearBeforePass || overlay == DebugOverlay::ClearBeforeDraw) { - std::vector events = passEvents; + rdcarray events = passEvents; if(overlay == DebugOverlay::ClearBeforeDraw) events.clear(); @@ -659,7 +659,7 @@ ResourceId D3D11Replay::RenderOverlay(ResourceId texid, CompType typeCast, Float float overlayConsts[] = {0.0f, 0.0f, 0.0f, 0.0f}; m_pImmediateContext->ClearRenderTargetView(rtv, overlayConsts); - std::vector events = passEvents; + rdcarray events = passEvents; if(overlay == DebugOverlay::TriangleSizeDraw) events.clear(); @@ -785,7 +785,7 @@ ResourceId D3D11Replay::RenderOverlay(ResourceId texid, CompType typeCast, Float { SCOPED_TIMER("Quad Overdraw"); - std::vector events = passEvents; + rdcarray events = passEvents; if(overlay == DebugOverlay::QuadOverdrawDraw) events.clear(); diff --git a/renderdoc/driver/d3d11/d3d11_pixelhistory.cpp b/renderdoc/driver/d3d11/d3d11_pixelhistory.cpp index 146b9e54b..726168aa3 100644 --- a/renderdoc/driver/d3d11/d3d11_pixelhistory.cpp +++ b/renderdoc/driver/d3d11/d3d11_pixelhistory.cpp @@ -281,11 +281,11 @@ void D3D11DebugManager::PixelHistoryCopyPixel(CopyPixelParams &p, uint32_t x, ui SAFE_RELEASE(curCSUAV[i]); } -std::vector D3D11Replay::PixelHistory(std::vector events, - ResourceId target, uint32_t x, uint32_t y, - const Subresource &sub, CompType typeCast) +rdcarray D3D11Replay::PixelHistory(rdcarray events, + ResourceId target, uint32_t x, uint32_t y, + const Subresource &sub, CompType typeCast) { - std::vector history; + rdcarray history; // this function needs a *huge* amount of tidying, refactoring and documenting. @@ -2006,7 +2006,7 @@ std::vector D3D11Replay::PixelHistory(std::vector PixelModification mod = history[h]; for(int32_t f = 1; f < frags; f++) - history.insert(history.begin() + h + 1, mod); + history.insert(h + 1, mod); for(int32_t f = 0; f < frags; f++) { diff --git a/renderdoc/driver/d3d11/d3d11_postvs.cpp b/renderdoc/driver/d3d11/d3d11_postvs.cpp index 83952d4d9..053c5fd0c 100644 --- a/renderdoc/driver/d3d11/d3d11_postvs.cpp +++ b/renderdoc/driver/d3d11/d3d11_postvs.cpp @@ -1042,7 +1042,7 @@ void D3D11Replay::InitPostVSBuffers(uint32_t eventId) } } -void D3D11Replay::InitPostVSBuffers(const std::vector &passEvents) +void D3D11Replay::InitPostVSBuffers(const rdcarray &passEvents) { uint32_t prev = 0; diff --git a/renderdoc/driver/d3d11/d3d11_rendermesh.cpp b/renderdoc/driver/d3d11/d3d11_rendermesh.cpp index 342d2844a..fb0381f4a 100644 --- a/renderdoc/driver/d3d11/d3d11_rendermesh.cpp +++ b/renderdoc/driver/d3d11/d3d11_rendermesh.cpp @@ -33,7 +33,7 @@ #include "data/hlsl/hlsl_cbuffers.h" -void D3D11Replay::RenderMesh(uint32_t eventId, const std::vector &secondaryDraws, +void D3D11Replay::RenderMesh(uint32_t eventId, const rdcarray &secondaryDraws, const MeshDisplay &cfg) { if(cfg.position.vertexResourceId == ResourceId() || cfg.position.numIndices == 0) @@ -368,16 +368,16 @@ void D3D11Replay::RenderMesh(uint32_t eventId, const std::vector &se FloatVector activeVertex; // primitive this vert is a part of (red prim, optional) - std::vector activePrim; + rdcarray activePrim; // for patch lists, to show other verts in patch (green dots, optional) // for non-patch lists, we use the activePrim and adjacentPrimVertices // to show what other verts are related - std::vector inactiveVertices; + rdcarray inactiveVertices; // adjacency (line or tri, strips or lists) (green prims, optional) // will be N*M long, N adjacent prims of M verts each. M = primSize below - std::vector adjacentPrimVertices; + rdcarray adjacentPrimVertices; D3D11_PRIMITIVE_TOPOLOGY primTopo = D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST; // tri or line list diff --git a/renderdoc/driver/d3d11/d3d11_replay.cpp b/renderdoc/driver/d3d11/d3d11_replay.cpp index 5019e20ef..29f646169 100644 --- a/renderdoc/driver/d3d11/d3d11_replay.cpp +++ b/renderdoc/driver/d3d11/d3d11_replay.cpp @@ -455,18 +455,13 @@ ShaderReflection *D3D11Replay::GetShader(ResourceId pipeline, ResourceId shader, return &ret; } -std::vector D3D11Replay::GetDisassemblyTargets() +rdcarray D3D11Replay::GetDisassemblyTargets() { - std::vector ret; - - // DXBC is always first - ret.insert(ret.begin(), DXBCDisassemblyTarget); - - return ret; + return {DXBCDisassemblyTarget}; } -std::string D3D11Replay::DisassembleShader(ResourceId pipeline, const ShaderReflection *refl, - const std::string &target) +rdcstr D3D11Replay::DisassembleShader(ResourceId pipeline, const ShaderReflection *refl, + const rdcstr &target) { auto it = WrappedShader::m_ShaderList.find(m_pDevice->GetResourceManager()->GetLiveID(refl->resourceId)); @@ -502,12 +497,12 @@ void D3D11Replay::FreeCustomShader(ResourceId id) } } -std::vector D3D11Replay::GetUsage(ResourceId id) +rdcarray D3D11Replay::GetUsage(ResourceId id) { return m_pDevice->GetImmediateContext()->GetUsage(id); } -std::vector D3D11Replay::GetDebugMessages() +rdcarray D3D11Replay::GetDebugMessages() { return m_pDevice->GetDebugMessages(); } @@ -583,14 +578,14 @@ ResourceDescription &D3D11Replay::GetResourceDesc(ResourceId id) return m_Resources[it->second]; } -const std::vector &D3D11Replay::GetResources() +const rdcarray &D3D11Replay::GetResources() { return m_Resources; } -std::vector D3D11Replay::GetBuffers() +rdcarray D3D11Replay::GetBuffers() { - std::vector ret; + rdcarray ret; ret.reserve(WrappedID3D11Buffer::m_BufferList.size()); @@ -653,9 +648,9 @@ BufferDescription D3D11Replay::GetBuffer(ResourceId id) return ret; } -std::vector D3D11Replay::GetTextures() +rdcarray D3D11Replay::GetTextures() { - std::vector ret; + rdcarray ret; ret.reserve(WrappedID3D11Texture1D::m_TextureList.size() + WrappedID3D11Texture2D1::m_TextureList.size() + @@ -1560,9 +1555,9 @@ const SDFile &D3D11Replay::GetStructuredFile() return m_pDevice->GetStructuredFile(); } -std::vector D3D11Replay::GetPassEvents(uint32_t eventId) +rdcarray D3D11Replay::GetPassEvents(uint32_t eventId) { - std::vector passEvents; + rdcarray passEvents; const DrawcallDescription *draw = m_pDevice->GetDrawcall(eventId); @@ -1800,7 +1795,7 @@ bool D3D11Replay::GetMinMax(ResourceId texid, const Subresource &sub, CompType t bool D3D11Replay::GetHistogram(ResourceId texid, const Subresource &sub, CompType typeCast, float minval, float maxval, bool channels[4], - std::vector &histogram) + rdcarray &histogram) { if(minval >= maxval) return false; @@ -2508,16 +2503,14 @@ D3D11DebugManager *D3D11Replay::GetDebugManager() return m_pDevice->GetDebugManager(); } -void D3D11Replay::BuildShader(ShaderEncoding sourceEncoding, bytebuf source, - const std::string &entry, const ShaderCompileFlags &compileFlags, - ShaderStage type, ResourceId *id, std::string *errors) +void D3D11Replay::BuildShader(ShaderEncoding sourceEncoding, const bytebuf &source, + const rdcstr &entry, const ShaderCompileFlags &compileFlags, + ShaderStage type, ResourceId &id, rdcstr &errors) { - if(id == NULL || errors == NULL) - { - if(id) - *id = ResourceId(); - return; - } + bytebuf compiledDXBC; + + const byte *dxbcBytes = source.data(); + size_t dxbcLength = source.size(); if(sourceEncoding == ShaderEncoding::HLSL) { @@ -2535,7 +2528,7 @@ void D3D11Replay::BuildShader(ShaderEncoding sourceEncoding, bytebuf source, case ShaderStage::Compute: profile = "cs_5_0"; break; default: RDCERR("Unexpected type in BuildShader!"); - *id = ResourceId(); + id = ResourceId(); return; } @@ -2544,17 +2537,19 @@ void D3D11Replay::BuildShader(ShaderEncoding sourceEncoding, bytebuf source, ID3DBlob *blob = NULL; - *errors = m_pDevice->GetShaderCache()->GetShaderBlob(hlsl.c_str(), entry.c_str(), flags, - profile, &blob); + errors = m_pDevice->GetShaderCache()->GetShaderBlob(hlsl.c_str(), entry.c_str(), flags, profile, + &blob); if(blob == NULL) { - *id = ResourceId(); + id = ResourceId(); return; } - source.clear(); - source.assign((byte *)blob->GetBufferPointer(), blob->GetBufferSize()); + compiledDXBC.assign((byte *)blob->GetBufferPointer(), blob->GetBufferSize()); + + dxbcBytes = compiledDXBC.data(); + dxbcLength = compiledDXBC.size(); SAFE_RELEASE(blob); } @@ -2564,109 +2559,109 @@ void D3D11Replay::BuildShader(ShaderEncoding sourceEncoding, bytebuf source, case ShaderStage::Vertex: { ID3D11VertexShader *sh = NULL; - HRESULT hr = m_pDevice->CreateVertexShader(source.data(), source.size(), NULL, &sh); + HRESULT hr = m_pDevice->CreateVertexShader(dxbcBytes, dxbcLength, NULL, &sh); if(sh != NULL) { - *id = ((WrappedID3D11Shader *)sh)->GetResourceID(); + id = ((WrappedID3D11Shader *)sh)->GetResourceID(); } else { - *errors = StringFormat::Fmt("Failed to create shader: %s", ToStr(hr).c_str()); - *id = ResourceId(); + errors = StringFormat::Fmt("Failed to create shader: %s", ToStr(hr).c_str()); + id = ResourceId(); } return; } case ShaderStage::Hull: { ID3D11HullShader *sh = NULL; - HRESULT hr = m_pDevice->CreateHullShader(source.data(), source.size(), NULL, &sh); + HRESULT hr = m_pDevice->CreateHullShader(dxbcBytes, dxbcLength, NULL, &sh); if(sh != NULL) { - *id = ((WrappedID3D11Shader *)sh)->GetResourceID(); + id = ((WrappedID3D11Shader *)sh)->GetResourceID(); } else { - *errors = StringFormat::Fmt("Failed to create shader: %s", ToStr(hr).c_str()); - *id = ResourceId(); + errors = StringFormat::Fmt("Failed to create shader: %s", ToStr(hr).c_str()); + id = ResourceId(); } return; } case ShaderStage::Domain: { ID3D11DomainShader *sh = NULL; - HRESULT hr = m_pDevice->CreateDomainShader(source.data(), source.size(), NULL, &sh); + HRESULT hr = m_pDevice->CreateDomainShader(dxbcBytes, dxbcLength, NULL, &sh); if(sh != NULL) { - *id = ((WrappedID3D11Shader *)sh)->GetResourceID(); + id = ((WrappedID3D11Shader *)sh)->GetResourceID(); } else { - *errors = StringFormat::Fmt("Failed to create shader: %s", ToStr(hr).c_str()); - *id = ResourceId(); + errors = StringFormat::Fmt("Failed to create shader: %s", ToStr(hr).c_str()); + id = ResourceId(); } return; } case ShaderStage::Geometry: { ID3D11GeometryShader *sh = NULL; - HRESULT hr = m_pDevice->CreateGeometryShader(source.data(), source.size(), NULL, &sh); + HRESULT hr = m_pDevice->CreateGeometryShader(dxbcBytes, dxbcLength, NULL, &sh); if(sh != NULL) { - *id = ((WrappedID3D11Shader *)sh)->GetResourceID(); + id = ((WrappedID3D11Shader *)sh)->GetResourceID(); } else { - *errors = StringFormat::Fmt("Failed to create shader: %s", ToStr(hr).c_str()); - *id = ResourceId(); + errors = StringFormat::Fmt("Failed to create shader: %s", ToStr(hr).c_str()); + id = ResourceId(); } return; } case ShaderStage::Pixel: { ID3D11PixelShader *sh = NULL; - HRESULT hr = m_pDevice->CreatePixelShader(source.data(), source.size(), NULL, &sh); + HRESULT hr = m_pDevice->CreatePixelShader(dxbcBytes, dxbcLength, NULL, &sh); if(sh != NULL) { - *id = ((WrappedID3D11Shader *)sh)->GetResourceID(); + id = ((WrappedID3D11Shader *)sh)->GetResourceID(); } else { - *errors = StringFormat::Fmt("Failed to create shader: %s", ToStr(hr).c_str()); - *id = ResourceId(); + errors = StringFormat::Fmt("Failed to create shader: %s", ToStr(hr).c_str()); + id = ResourceId(); } return; } case ShaderStage::Compute: { ID3D11ComputeShader *sh = NULL; - HRESULT hr = m_pDevice->CreateComputeShader(source.data(), source.size(), NULL, &sh); + HRESULT hr = m_pDevice->CreateComputeShader(dxbcBytes, dxbcLength, NULL, &sh); if(sh != NULL) { - *id = ((WrappedID3D11Shader *)sh)->GetResourceID(); + id = ((WrappedID3D11Shader *)sh)->GetResourceID(); } else { - *errors = StringFormat::Fmt("Failed to create shader: %s", ToStr(hr).c_str()); - *id = ResourceId(); + errors = StringFormat::Fmt("Failed to create shader: %s", ToStr(hr).c_str()); + id = ResourceId(); } return; } default: break; } - RDCERR("Unexpected type in BuildShader!"); - *id = ResourceId(); + errors = "Unexpected type in BuildShader!"; + id = ResourceId(); } -void D3D11Replay::BuildTargetShader(ShaderEncoding sourceEncoding, bytebuf source, - const std::string &entry, const ShaderCompileFlags &compileFlags, - ShaderStage type, ResourceId *id, std::string *errors) +void D3D11Replay::BuildTargetShader(ShaderEncoding sourceEncoding, const bytebuf &source, + const rdcstr &entry, const ShaderCompileFlags &compileFlags, + ShaderStage type, ResourceId &id, rdcstr &errors) { ShaderCompileFlags debugCompileFlags = DXBC::EncodeFlags(DXBC::DecodeFlags(compileFlags) | D3DCOMPILE_DEBUG); @@ -2674,9 +2669,9 @@ void D3D11Replay::BuildTargetShader(ShaderEncoding sourceEncoding, bytebuf sourc BuildShader(sourceEncoding, source, entry, debugCompileFlags, type, id, errors); } -void D3D11Replay::BuildCustomShader(ShaderEncoding sourceEncoding, bytebuf source, - const std::string &entry, const ShaderCompileFlags &compileFlags, - ShaderStage type, ResourceId *id, std::string *errors) +void D3D11Replay::BuildCustomShader(ShaderEncoding sourceEncoding, const bytebuf &source, + const rdcstr &entry, const ShaderCompileFlags &compileFlags, + ShaderStage type, ResourceId &id, rdcstr &errors) { BuildTargetShader(sourceEncoding, source, entry, compileFlags, type, id, errors); } @@ -2808,9 +2803,9 @@ void D3D11Replay::RenderHighlightBox(float w, float h, float scale) } } -void D3D11Replay::FillCBufferVariables(ResourceId pipeline, ResourceId shader, - std::string entryPoint, uint32_t cbufSlot, - rdcarray &outvars, const bytebuf &data) +void D3D11Replay::FillCBufferVariables(ResourceId pipeline, ResourceId shader, rdcstr entryPoint, + uint32_t cbufSlot, rdcarray &outvars, + const bytebuf &data) { auto it = WrappedShader::m_ShaderList.find(shader); diff --git a/renderdoc/driver/d3d11/d3d11_replay.h b/renderdoc/driver/d3d11/d3d11_replay.h index 6278ced12..ce8f721a1 100644 --- a/renderdoc/driver/d3d11/d3d11_replay.h +++ b/renderdoc/driver/d3d11/d3d11_replay.h @@ -61,7 +61,7 @@ struct D3D11PostVSData uint32_t instStride = 0; // complex case - expansion per instance - std::vector instData; + rdcarray instData; bool useIndices = false; ID3D11Buffer *idxBuf = NULL; @@ -117,24 +117,23 @@ public: APIProperties GetAPIProperties(); ResourceDescription &GetResourceDesc(ResourceId id); - const std::vector &GetResources(); + const rdcarray &GetResources(); - std::vector GetBuffers(); + rdcarray GetBuffers(); BufferDescription GetBuffer(ResourceId id); - std::vector GetTextures(); + rdcarray GetTextures(); TextureDescription GetTexture(ResourceId id); - std::vector GetDebugMessages(); + rdcarray GetDebugMessages(); rdcarray GetShaderEntryPoints(ResourceId shader); ShaderReflection *GetShader(ResourceId pipeline, ResourceId shader, ShaderEntryPoint entry); - std::vector GetDisassemblyTargets(); - std::string DisassembleShader(ResourceId pipeline, const ShaderReflection *refl, - const std::string &target); + rdcarray GetDisassemblyTargets(); + rdcstr DisassembleShader(ResourceId pipeline, const ShaderReflection *refl, const rdcstr &target); - std::vector GetUsage(ResourceId id); + rdcarray GetUsage(ResourceId id); FrameRecord &WriteFrameRecord() { return m_FrameRecord; } FrameRecord GetFrameRecord() { return m_FrameRecord; } @@ -150,11 +149,11 @@ public: void ReplayLog(uint32_t endEventID, ReplayLogType replayType); const SDFile &GetStructuredFile(); - std::vector GetPassEvents(uint32_t eventId); + rdcarray GetPassEvents(uint32_t eventId); - std::vector GetSupportedWindowSystems() + rdcarray GetSupportedWindowSystems() { - std::vector ret; + rdcarray ret; ret.push_back(WindowingSystem::Win32); return ret; } @@ -173,7 +172,7 @@ public: void FlipOutputWindow(uint64_t id); void InitPostVSBuffers(uint32_t eventId); - void InitPostVSBuffers(const std::vector &passEvents); + void InitPostVSBuffers(const rdcarray &passEvents); ResourceId GetLiveID(ResourceId id); @@ -182,7 +181,7 @@ public: bool GetMinMax(ResourceId texid, const Subresource &sub, CompType typeCast, float *minval, float *maxval); bool GetHistogram(ResourceId texid, const Subresource &sub, CompType typeCast, float minval, - float maxval, bool channels[4], std::vector &histogram); + float maxval, bool channels[4], rdcarray &histogram); MeshFormat GetPostVSBuffers(uint32_t eventId, uint32_t instID, uint32_t viewID, MeshDataStage stage); @@ -199,9 +198,9 @@ public: { return {ShaderEncoding::DXBC, ShaderEncoding::HLSL}; } - void BuildTargetShader(ShaderEncoding sourceEncoding, bytebuf source, const std::string &entry, - const ShaderCompileFlags &compileFlags, ShaderStage type, ResourceId *id, - std::string *errors); + void BuildTargetShader(ShaderEncoding sourceEncoding, const bytebuf &source, const rdcstr &entry, + const ShaderCompileFlags &compileFlags, ShaderStage type, ResourceId &id, + rdcstr &errors); void ReplaceResource(ResourceId from, ResourceId to); void RemoveReplacement(ResourceId id); @@ -217,7 +216,7 @@ public: ResourceId CreateProxyBuffer(const BufferDescription &templateBuf); void SetProxyBufferData(ResourceId bufid, byte *data, size_t dataSize); - void RenderMesh(uint32_t eventId, const std::vector &secondaryDraws, + void RenderMesh(uint32_t eventId, const rdcarray &secondaryDraws, const MeshDisplay &cfg); bool RenderTexture(TextureDisplay cfg); @@ -226,13 +225,12 @@ public: void RenderHighlightBox(float w, float h, float scale); - void FillCBufferVariables(ResourceId pipeline, ResourceId shader, std::string entryPoint, + void FillCBufferVariables(ResourceId pipeline, ResourceId shader, rdcstr entryPoint, uint32_t cbufSlot, rdcarray &outvars, const bytebuf &data); - std::vector PixelHistory(std::vector events, ResourceId target, - uint32_t x, uint32_t y, const Subresource &sub, - CompType typeCast); + rdcarray PixelHistory(rdcarray events, ResourceId target, uint32_t x, + uint32_t y, const Subresource &sub, CompType typeCast); ShaderDebugTrace DebugVertex(uint32_t eventId, uint32_t vertid, uint32_t instid, uint32_t idx, uint32_t instOffset, uint32_t vertOffset); ShaderDebugTrace DebugPixel(uint32_t eventId, uint32_t x, uint32_t y, uint32_t sample, @@ -244,11 +242,11 @@ public: ResourceId RenderOverlay(ResourceId texid, CompType typeCast, FloatVector clearCol, DebugOverlay overlay, uint32_t eventId, - const std::vector &passEvents); + const rdcarray &passEvents); - void BuildCustomShader(ShaderEncoding sourceEncoding, bytebuf source, const std::string &entry, - const ShaderCompileFlags &compileFlags, ShaderStage type, ResourceId *id, - std::string *errors); + void BuildCustomShader(ShaderEncoding sourceEncoding, const bytebuf &source, const rdcstr &entry, + const ShaderCompileFlags &compileFlags, ShaderStage type, ResourceId &id, + rdcstr &errors); ResourceId ApplyCustomShader(ResourceId shader, ResourceId texid, const Subresource &sub, CompType typeCast); @@ -261,9 +259,9 @@ private: D3D11DebugManager *GetDebugManager(); // shared by BuildCustomShader and BuildTargetShader - void BuildShader(ShaderEncoding sourceEncoding, bytebuf source, const std::string &entry, - const ShaderCompileFlags &compileFlags, ShaderStage type, ResourceId *id, - std::string *errors); + void BuildShader(ShaderEncoding sourceEncoding, const bytebuf &source, const rdcstr &entry, + const ShaderCompileFlags &compileFlags, ShaderStage type, ResourceId &id, + rdcstr &errors); void ClearPostVSCache(); @@ -295,7 +293,7 @@ private: m_OutputHeight = float(h); } - std::vector m_ProxyResources; + rdcarray m_ProxyResources; std::map m_ProxyTypeCastDefault; struct OutputWindow @@ -346,7 +344,7 @@ private: uint64_t m_SOBufferSize = 32 * 1024 * 1024; ID3D11Buffer *m_SOBuffer = NULL; ID3D11Buffer *m_SOStagingBuffer = NULL; - std::vector m_SOStatsQueries; + rdcarray m_SOStatsQueries; ID3D11Texture2D *m_CustomShaderTex = NULL; ResourceId m_CustomShaderResourceId; @@ -479,7 +477,7 @@ private: ID3D11PixelShader *PrimitiveIDPS = NULL; } m_PixelHistory; - std::vector m_Resources; + rdcarray m_Resources; std::map m_ResourceIdx; FrameRecord m_FrameRecord; diff --git a/renderdoc/driver/d3d12/d3d12_command_list.h b/renderdoc/driver/d3d12/d3d12_command_list.h index 0f33e734b..c0b080def 100644 --- a/renderdoc/driver/d3d12/d3d12_command_list.h +++ b/renderdoc/driver/d3d12/d3d12_command_list.h @@ -149,7 +149,7 @@ private: D3D12_COMMAND_LIST_TYPE type; } m_Init; - static std::string GetChunkName(uint32_t idx); + static rdcstr GetChunkName(uint32_t idx); D3D12ResourceManager *GetResourceManager() { return m_pDevice->GetResourceManager(); } public: static const int AllocPoolCount = 8192; diff --git a/renderdoc/driver/d3d12/d3d12_command_queue.h b/renderdoc/driver/d3d12/d3d12_command_queue.h index fb5a97e0c..301eedb41 100644 --- a/renderdoc/driver/d3d12/d3d12_command_queue.h +++ b/renderdoc/driver/d3d12/d3d12_command_queue.h @@ -121,7 +121,7 @@ class WrappedID3D12CommandQueue : public ID3D12CommandQueue, // D3D12 guarantees that queues are thread-safe Threading::CriticalSection m_Lock; - std::set m_StringDB; + std::set m_StringDB; WriteSerialiser &GetThreadSerialiser(); @@ -136,7 +136,7 @@ class WrappedID3D12CommandQueue : public ID3D12CommandQueue, bool ProcessChunk(ReadSerialiser &ser, D3D12Chunk context); - static std::string GetChunkName(uint32_t idx); + static rdcstr GetChunkName(uint32_t idx); D3D12ResourceManager *GetResourceManager() { return m_pDevice->GetResourceManager(); } public: static const int AllocPoolCount = 16; diff --git a/renderdoc/driver/d3d12/d3d12_commands.cpp b/renderdoc/driver/d3d12/d3d12_commands.cpp index bb802e5fe..16c8cfe61 100644 --- a/renderdoc/driver/d3d12/d3d12_commands.cpp +++ b/renderdoc/driver/d3d12/d3d12_commands.cpp @@ -452,7 +452,7 @@ WriteSerialiser &WrappedID3D12CommandQueue::GetThreadSerialiser() return m_pDevice->GetThreadSerialiser(); } -std::string WrappedID3D12CommandQueue::GetChunkName(uint32_t idx) +rdcstr WrappedID3D12CommandQueue::GetChunkName(uint32_t idx) { if((SystemChunk)idx < SystemChunk::FirstDriverChunk) return ToStr((SystemChunk)idx); @@ -1073,7 +1073,7 @@ WriteSerialiser &WrappedID3D12GraphicsCommandList::GetThreadSerialiser() return m_pDevice->GetThreadSerialiser(); } -std::string WrappedID3D12GraphicsCommandList::GetChunkName(uint32_t idx) +rdcstr WrappedID3D12GraphicsCommandList::GetChunkName(uint32_t idx) { if((SystemChunk)idx < SystemChunk::FirstDriverChunk) return ToStr((SystemChunk)idx); diff --git a/renderdoc/driver/d3d12/d3d12_device.cpp b/renderdoc/driver/d3d12/d3d12_device.cpp index 0117b7505..788829fad 100644 --- a/renderdoc/driver/d3d12/d3d12_device.cpp +++ b/renderdoc/driver/d3d12/d3d12_device.cpp @@ -56,7 +56,7 @@ void WrappedID3D12Device::RemoveQueue(WrappedID3D12CommandQueue *queue) RDCERR("Unknown wrapped queue %p being remvoed", queue); } -std::string WrappedID3D12Device::GetChunkName(uint32_t idx) +rdcstr WrappedID3D12Device::GetChunkName(uint32_t idx) { if((SystemChunk)idx < SystemChunk::FirstDriverChunk) return ToStr((SystemChunk)idx); diff --git a/renderdoc/driver/d3d12/d3d12_device.h b/renderdoc/driver/d3d12/d3d12_device.h index 64f75619c..9df607287 100644 --- a/renderdoc/driver/d3d12/d3d12_device.h +++ b/renderdoc/driver/d3d12/d3d12_device.h @@ -432,7 +432,7 @@ private: uint32_t m_FrameCounter = 0; std::vector m_CapturedFrames; - std::vector m_Drawcalls; + rdcarray m_Drawcalls; ReplayStatus m_FailedReplayStatus = ReplayStatus::APIReplayFailed; @@ -453,7 +453,7 @@ private: D3D12ResourceRecord *m_FrameCaptureRecord; Chunk *m_HeaderChunk; - std::set m_StringDB; + std::set m_StringDB; ResourceId m_ResourceID; D3D12ResourceRecord *m_DeviceRecord; @@ -540,7 +540,7 @@ public: WriteSerialiser &GetThreadSerialiser(); ID3D12Device *GetReal() { return m_pDevice; } - static std::string GetChunkName(uint32_t idx); + static rdcstr GetChunkName(uint32_t idx); D3D12ResourceManager *GetResourceManager() { return m_ResourceManager; } D3D12ShaderCache *GetShaderCache() { return m_ShaderCache; } D3D12DebugManager *GetDebugManager(); diff --git a/renderdoc/driver/d3d12/d3d12_overlay.cpp b/renderdoc/driver/d3d12/d3d12_overlay.cpp index 70b808752..601fa8997 100644 --- a/renderdoc/driver/d3d12/d3d12_overlay.cpp +++ b/renderdoc/driver/d3d12/d3d12_overlay.cpp @@ -43,7 +43,7 @@ struct D3D12QuadOverdrawCallback : public D3D12DrawcallCallback { D3D12QuadOverdrawCallback(WrappedID3D12Device *dev, D3D12_SHADER_BYTECODE quadWrite, - const std::vector &events, PortableHandle uav) + const rdcarray &events, PortableHandle uav) : m_pDevice(dev), m_QuadWritePS(quadWrite), m_Events(events), m_UAV(uav) { m_pDevice->GetQueue()->GetCommandData()->m_DrawcallCallback = this; @@ -54,7 +54,7 @@ struct D3D12QuadOverdrawCallback : public D3D12DrawcallCallback } void PreDraw(uint32_t eid, ID3D12GraphicsCommandListX *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 @@ -156,7 +156,7 @@ struct D3D12QuadOverdrawCallback : public D3D12DrawcallCallback bool PostDraw(uint32_t eid, ID3D12GraphicsCommandListX *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 @@ -185,7 +185,7 @@ struct D3D12QuadOverdrawCallback : public D3D12DrawcallCallback WrappedID3D12Device *m_pDevice; D3D12_SHADER_BYTECODE m_QuadWritePS; - const std::vector &m_Events; + const rdcarray &m_Events; PortableHandle m_UAV; // cache modified pipelines @@ -202,7 +202,7 @@ struct D3D12QuadOverdrawCallback : public D3D12DrawcallCallback ResourceId D3D12Replay::RenderOverlay(ResourceId texid, CompType typeCast, FloatVector clearCol, DebugOverlay overlay, uint32_t eventId, - const std::vector &passEvents) + const rdcarray &passEvents) { ID3D12Resource *resource = m_pDevice->GetResourceList()[texid]; @@ -647,7 +647,7 @@ ResourceId D3D12Replay::RenderOverlay(ResourceId texid, CompType typeCast, Float } else if(overlay == DebugOverlay::ClearBeforePass || overlay == DebugOverlay::ClearBeforeDraw) { - std::vector events = passEvents; + rdcarray events = passEvents; if(overlay == DebugOverlay::ClearBeforeDraw) events.clear(); @@ -759,7 +759,7 @@ ResourceId D3D12Replay::RenderOverlay(ResourceId texid, CompType typeCast, Float { SCOPED_TIMER("Triangle size"); - std::vector events = passEvents; + rdcarray events = passEvents; if(overlay == DebugOverlay::TriangleSizeDraw) events.clear(); @@ -770,7 +770,7 @@ ResourceId D3D12Replay::RenderOverlay(ResourceId texid, CompType typeCast, Float // remove any non-drawcalls, like the pass boundary. if(!(draw->flags & DrawFlags::Drawcall)) - events.erase(events.begin()); + events.erase(0); else break; } @@ -953,7 +953,7 @@ ResourceId D3D12Replay::RenderOverlay(ResourceId texid, CompType typeCast, Float { SCOPED_TIMER("Quad Overdraw"); - std::vector events = passEvents; + rdcarray events = passEvents; if(overlay == DebugOverlay::QuadOverdrawDraw) events.clear(); diff --git a/renderdoc/driver/d3d12/d3d12_postvs.cpp b/renderdoc/driver/d3d12/d3d12_postvs.cpp index 510821480..3d3be4948 100644 --- a/renderdoc/driver/d3d12/d3d12_postvs.cpp +++ b/renderdoc/driver/d3d12/d3d12_postvs.cpp @@ -1307,7 +1307,7 @@ void D3D12Replay::InitPostVSBuffers(uint32_t eventId) struct D3D12InitPostVSCallback : public D3D12DrawcallCallback { D3D12InitPostVSCallback(WrappedID3D12Device *dev, D3D12Replay *replay, - const std::vector &events) + const rdcarray &events) : m_pDevice(dev), m_Replay(replay), m_Events(events) { m_pDevice->GetQueue()->GetCommandData()->m_DrawcallCallback = this; @@ -1315,7 +1315,7 @@ struct D3D12InitPostVSCallback : public D3D12DrawcallCallback ~D3D12InitPostVSCallback() { m_pDevice->GetQueue()->GetCommandData()->m_DrawcallCallback = NULL; } void PreDraw(uint32_t eid, ID3D12GraphicsCommandListX *cmd) override { - if(std::find(m_Events.begin(), m_Events.end(), eid) != m_Events.end()) + if(m_Events.contains(eid)) m_Replay->InitPostVSBuffers(eid); } @@ -1328,16 +1328,16 @@ struct D3D12InitPostVSCallback : public D3D12DrawcallCallback void PreCloseCommandList(ID3D12GraphicsCommandListX *cmd) override {} void AliasEvent(uint32_t primary, uint32_t alias) override { - if(std::find(m_Events.begin(), m_Events.end(), primary) != m_Events.end()) + if(m_Events.contains(primary)) m_Replay->AliasPostVSBuffers(primary, alias); } WrappedID3D12Device *m_pDevice; D3D12Replay *m_Replay; - const std::vector &m_Events; + const rdcarray &m_Events; }; -void D3D12Replay::InitPostVSBuffers(const std::vector &events) +void D3D12Replay::InitPostVSBuffers(const rdcarray &events) { // first we must replay up to the first event without replaying it. This ensures any // non-command buffer calls like memory unmaps etc all happen correctly before this diff --git a/renderdoc/driver/d3d12/d3d12_rendermesh.cpp b/renderdoc/driver/d3d12/d3d12_rendermesh.cpp index b510a447b..8bcda77ee 100644 --- a/renderdoc/driver/d3d12/d3d12_rendermesh.cpp +++ b/renderdoc/driver/d3d12/d3d12_rendermesh.cpp @@ -227,7 +227,7 @@ MeshDisplayPipelines D3D12DebugManager::CacheMeshDisplayPipelines(const MeshForm return cache; } -void D3D12Replay::RenderMesh(uint32_t eventId, const std::vector &secondaryDraws, +void D3D12Replay::RenderMesh(uint32_t eventId, const rdcarray &secondaryDraws, const MeshDisplay &cfg) { if(cfg.position.vertexResourceId == ResourceId() || cfg.position.numIndices == 0) @@ -664,16 +664,16 @@ void D3D12Replay::RenderMesh(uint32_t eventId, const std::vector &se FloatVector activeVertex; // primitive this vert is a part of (red prim, optional) - std::vector activePrim; + rdcarray activePrim; // for patch lists, to show other verts in patch (green dots, optional) // for non-patch lists, we use the activePrim and adjacentPrimVertices // to show what other verts are related - std::vector inactiveVertices; + rdcarray inactiveVertices; // adjacency (line or tri, strips or lists) (green prims, optional) // will be N*M long, N adjacent prims of M verts each. M = primSize below - std::vector adjacentPrimVertices; + rdcarray adjacentPrimVertices; helper.topology = Topology::TriangleList; uint32_t primSize = 3; // number of verts per primitive diff --git a/renderdoc/driver/d3d12/d3d12_replay.cpp b/renderdoc/driver/d3d12/d3d12_replay.cpp index 5bea9babb..cb8c4f3e6 100644 --- a/renderdoc/driver/d3d12/d3d12_replay.cpp +++ b/renderdoc/driver/d3d12/d3d12_replay.cpp @@ -301,14 +301,14 @@ ResourceDescription &D3D12Replay::GetResourceDesc(ResourceId id) return m_Resources[it->second]; } -const std::vector &D3D12Replay::GetResources() +const rdcarray &D3D12Replay::GetResources() { return m_Resources; } -std::vector D3D12Replay::GetBuffers() +rdcarray D3D12Replay::GetBuffers() { - std::vector ret; + rdcarray ret; for(auto it = m_pDevice->GetResourceList().begin(); it != m_pDevice->GetResourceList().end(); it++) if(it->second->GetDesc().Dimension == D3D12_RESOURCE_DIMENSION_BUFFER) @@ -317,9 +317,9 @@ std::vector D3D12Replay::GetBuffers() return ret; } -std::vector D3D12Replay::GetTextures() +rdcarray D3D12Replay::GetTextures() { - std::vector ret; + rdcarray ret; for(auto it = m_pDevice->GetResourceList().begin(); it != m_pDevice->GetResourceList().end(); it++) { @@ -462,12 +462,12 @@ ShaderReflection *D3D12Replay::GetShader(ResourceId pipeline, ResourceId shader, return NULL; } -std::vector D3D12Replay::GetDisassemblyTargets() +rdcarray D3D12Replay::GetDisassemblyTargets() { - std::vector ret; + rdcarray ret; // DXBC is always first - ret.insert(ret.begin(), DXBCDisassemblyTarget); + ret.push_back(DXBCDisassemblyTarget); if(!m_ISAChecked && m_TexRender.BlendPipe) { @@ -498,8 +498,8 @@ std::vector D3D12Replay::GetDisassemblyTargets() return ret; } -std::string D3D12Replay::DisassembleShader(ResourceId pipeline, const ShaderReflection *refl, - const std::string &target) +rdcstr D3D12Replay::DisassembleShader(ResourceId pipeline, const ShaderReflection *refl, + const rdcstr &target) { WrappedID3D12Shader *sh = m_pDevice->GetResourceManager()->GetLiveAs(refl->resourceId); @@ -640,7 +640,7 @@ ResourceId D3D12Replay::GetLiveID(ResourceId id) return m_pDevice->GetResourceManager()->GetLiveID(id); } -std::vector D3D12Replay::GetUsage(ResourceId id) +rdcarray D3D12Replay::GetUsage(ResourceId id) { return m_pDevice->GetQueue()->GetUsage(id); } @@ -2423,7 +2423,7 @@ bool D3D12Replay::GetMinMax(ResourceId texid, const Subresource &sub, CompType t bool D3D12Replay::GetHistogram(ResourceId texid, const Subresource &sub, CompType typeCast, float minval, float maxval, bool channels[4], - std::vector &histogram) + rdcarray &histogram) { if(minval >= maxval) return false; @@ -2601,9 +2601,9 @@ bool D3D12Replay::IsRenderOutput(ResourceId id) return false; } -std::vector D3D12Replay::GetPassEvents(uint32_t eventId) +rdcarray D3D12Replay::GetPassEvents(uint32_t eventId) { - std::vector passEvents; + rdcarray passEvents; const DrawcallDescription *draw = m_pDevice->GetDrawcall(eventId); @@ -2691,9 +2691,9 @@ void D3D12Replay::GetBufferData(ResourceId buff, uint64_t offset, uint64_t lengt GetDebugManager()->GetBufferData(buffer, offset, length, retData); } -void D3D12Replay::FillCBufferVariables(ResourceId pipeline, ResourceId shader, - std::string entryPoint, uint32_t cbufSlot, - rdcarray &outvars, const bytebuf &data) +void D3D12Replay::FillCBufferVariables(ResourceId pipeline, ResourceId shader, rdcstr entryPoint, + uint32_t cbufSlot, rdcarray &outvars, + const bytebuf &data) { if(shader == ResourceId()) return; @@ -2772,21 +2772,19 @@ void D3D12Replay::FillCBufferVariables(ResourceId pipeline, ResourceId shader, rootData.empty() ? data : rootData); } -std::vector D3D12Replay::GetDebugMessages() +rdcarray D3D12Replay::GetDebugMessages() { return m_pDevice->GetDebugMessages(); } -void D3D12Replay::BuildShader(ShaderEncoding sourceEncoding, bytebuf source, - const std::string &entry, const ShaderCompileFlags &compileFlags, - ShaderStage type, ResourceId *id, std::string *errors) +void D3D12Replay::BuildShader(ShaderEncoding sourceEncoding, const bytebuf &source, + const rdcstr &entry, const ShaderCompileFlags &compileFlags, + ShaderStage type, ResourceId &id, rdcstr &errors) { - if(id == NULL || errors == NULL) - { - if(id) - *id = ResourceId(); - return; - } + bytebuf compiledDXBC; + + const byte *dxbcBytes = source.data(); + size_t dxbcLength = source.size(); if(sourceEncoding == ShaderEncoding::HLSL) { @@ -2804,7 +2802,7 @@ void D3D12Replay::BuildShader(ShaderEncoding sourceEncoding, bytebuf source, case ShaderStage::Compute: profile = "cs_5_1"; break; default: RDCERR("Unexpected type in BuildShader!"); - *id = ResourceId(); + id = ResourceId(); return; } @@ -2812,33 +2810,35 @@ void D3D12Replay::BuildShader(ShaderEncoding sourceEncoding, bytebuf source, hlsl.assign((const char *)source.data(), source.size()); ID3DBlob *blob = NULL; - *errors = m_pDevice->GetShaderCache()->GetShaderBlob(hlsl.c_str(), entry.c_str(), flags, - profile, &blob); + errors = m_pDevice->GetShaderCache()->GetShaderBlob(hlsl.c_str(), entry.c_str(), flags, profile, + &blob); if(blob == NULL) { - *id = ResourceId(); + id = ResourceId(); return; } - source.clear(); - source.assign((byte *)blob->GetBufferPointer(), blob->GetBufferSize()); + compiledDXBC.assign((byte *)blob->GetBufferPointer(), blob->GetBufferSize()); + + dxbcBytes = compiledDXBC.data(); + dxbcLength = compiledDXBC.size(); SAFE_RELEASE(blob); } D3D12_SHADER_BYTECODE byteCode; - byteCode.BytecodeLength = source.size(); - byteCode.pShaderBytecode = source.data(); + byteCode.BytecodeLength = dxbcLength; + byteCode.pShaderBytecode = dxbcBytes; WrappedID3D12Shader *sh = WrappedID3D12Shader::AddShader(byteCode, m_pDevice, NULL); - *id = sh->GetResourceID(); + id = sh->GetResourceID(); } -void D3D12Replay::BuildTargetShader(ShaderEncoding sourceEncoding, bytebuf source, - const std::string &entry, const ShaderCompileFlags &compileFlags, - ShaderStage type, ResourceId *id, std::string *errors) +void D3D12Replay::BuildTargetShader(ShaderEncoding sourceEncoding, const bytebuf &source, + const rdcstr &entry, const ShaderCompileFlags &compileFlags, + ShaderStage type, ResourceId &id, rdcstr &errors) { ShaderCompileFlags debugCompileFlags = DXBC::EncodeFlags(DXBC::DecodeFlags(compileFlags) | D3DCOMPILE_DEBUG); @@ -3564,9 +3564,9 @@ void D3D12Replay::GetTextureData(ResourceId tex, const Subresource &sub, SAFE_RELEASE(tmpTexture); } -void D3D12Replay::BuildCustomShader(ShaderEncoding sourceEncoding, bytebuf source, - const std::string &entry, const ShaderCompileFlags &compileFlags, - ShaderStage type, ResourceId *id, std::string *errors) +void D3D12Replay::BuildCustomShader(ShaderEncoding sourceEncoding, const bytebuf &source, + const rdcstr &entry, const ShaderCompileFlags &compileFlags, + ShaderStage type, ResourceId &id, rdcstr &errors) { BuildShader(sourceEncoding, source, entry, compileFlags, type, id, errors); } @@ -3669,11 +3669,11 @@ ResourceId D3D12Replay::ApplyCustomShader(ResourceId shader, ResourceId texid, #pragma region not yet implemented -std::vector D3D12Replay::PixelHistory(std::vector events, - ResourceId target, uint32_t x, uint32_t y, - const Subresource &sub, CompType typeCast) +rdcarray D3D12Replay::PixelHistory(rdcarray events, + ResourceId target, uint32_t x, uint32_t y, + const Subresource &sub, CompType typeCast) { - return std::vector(); + return {}; } ResourceId D3D12Replay::CreateProxyTexture(const TextureDescription &templateTex) diff --git a/renderdoc/driver/d3d12/d3d12_replay.h b/renderdoc/driver/d3d12/d3d12_replay.h index ce6625c0e..13bac6926 100644 --- a/renderdoc/driver/d3d12/d3d12_replay.h +++ b/renderdoc/driver/d3d12/d3d12_replay.h @@ -70,24 +70,23 @@ public: APIProperties GetAPIProperties(); ResourceDescription &GetResourceDesc(ResourceId id); - const std::vector &GetResources(); + const rdcarray &GetResources(); - std::vector GetBuffers(); + rdcarray GetBuffers(); BufferDescription GetBuffer(ResourceId id); - std::vector GetTextures(); + rdcarray GetTextures(); TextureDescription GetTexture(ResourceId id); - std::vector GetDebugMessages(); + rdcarray GetDebugMessages(); rdcarray GetShaderEntryPoints(ResourceId shader); ShaderReflection *GetShader(ResourceId pipeline, ResourceId shader, ShaderEntryPoint entry); - std::vector GetDisassemblyTargets(); - std::string DisassembleShader(ResourceId pipeline, const ShaderReflection *refl, - const std::string &target); + rdcarray GetDisassemblyTargets(); + rdcstr DisassembleShader(ResourceId pipeline, const ShaderReflection *refl, const rdcstr &target); - std::vector GetUsage(ResourceId id); + rdcarray GetUsage(ResourceId id); FrameRecord &WriteFrameRecord() { return m_FrameRecord; } FrameRecord GetFrameRecord() { return m_FrameRecord; } @@ -103,11 +102,11 @@ public: void ReplayLog(uint32_t endEventID, ReplayLogType replayType); const SDFile &GetStructuredFile(); - std::vector GetPassEvents(uint32_t eventId); + rdcarray GetPassEvents(uint32_t eventId); - std::vector GetSupportedWindowSystems() + rdcarray GetSupportedWindowSystems() { - std::vector ret; + rdcarray ret; ret.push_back(WindowingSystem::Win32); return ret; } @@ -126,7 +125,7 @@ public: void FlipOutputWindow(uint64_t id); void InitPostVSBuffers(uint32_t eventId); - void InitPostVSBuffers(const std::vector &passEvents); + void InitPostVSBuffers(const rdcarray &passEvents); // indicates that EID alias is the same as eventId void AliasPostVSBuffers(uint32_t eventId, uint32_t alias) { m_PostVSAlias[alias] = eventId; } @@ -137,7 +136,7 @@ public: bool GetMinMax(ResourceId texid, const Subresource &sub, CompType typeCast, float *minval, float *maxval); bool GetHistogram(ResourceId texid, const Subresource &sub, CompType typeCast, float minval, - float maxval, bool channels[4], std::vector &histogram); + float maxval, bool channels[4], rdcarray &histogram); MeshFormat GetPostVSBuffers(uint32_t eventId, uint32_t instID, uint32_t viewID, MeshDataStage stage); @@ -154,9 +153,9 @@ public: { return {ShaderEncoding::DXBC, ShaderEncoding::HLSL}; } - void BuildTargetShader(ShaderEncoding sourceEncoding, bytebuf source, const std::string &entry, - const ShaderCompileFlags &compileFlags, ShaderStage type, ResourceId *id, - std::string *errors); + void BuildTargetShader(ShaderEncoding sourceEncoding, const bytebuf &source, const rdcstr &entry, + const ShaderCompileFlags &compileFlags, ShaderStage type, ResourceId &id, + rdcstr &errors); void ReplaceResource(ResourceId from, ResourceId to); void RemoveReplacement(ResourceId id); @@ -172,7 +171,7 @@ public: ResourceId CreateProxyBuffer(const BufferDescription &templateBuf); void SetProxyBufferData(ResourceId bufid, byte *data, size_t dataSize); - void RenderMesh(uint32_t eventId, const std::vector &secondaryDraws, + void RenderMesh(uint32_t eventId, const rdcarray &secondaryDraws, const MeshDisplay &cfg); bool RenderTexture(TextureDisplay cfg); @@ -181,13 +180,12 @@ public: void RenderHighlightBox(float w, float h, float scale); - void FillCBufferVariables(ResourceId pipeline, ResourceId shader, std::string entryPoint, + void FillCBufferVariables(ResourceId pipeline, ResourceId shader, rdcstr entryPoint, uint32_t cbufSlot, rdcarray &outvars, const bytebuf &data); - std::vector PixelHistory(std::vector events, ResourceId target, - uint32_t x, uint32_t y, const Subresource &sub, - CompType typeCast); + rdcarray PixelHistory(rdcarray events, ResourceId target, uint32_t x, + uint32_t y, const Subresource &sub, CompType typeCast); ShaderDebugTrace DebugVertex(uint32_t eventId, uint32_t vertid, uint32_t instid, uint32_t idx, uint32_t instOffset, uint32_t vertOffset); ShaderDebugTrace DebugPixel(uint32_t eventId, uint32_t x, uint32_t y, uint32_t sample, @@ -199,11 +197,11 @@ public: ResourceId RenderOverlay(ResourceId texid, CompType typeCast, FloatVector clearCol, DebugOverlay overlay, uint32_t eventId, - const std::vector &passEvents); + const rdcarray &passEvents); - void BuildCustomShader(ShaderEncoding sourceEncoding, bytebuf source, const std::string &entry, - const ShaderCompileFlags &compileFlags, ShaderStage type, ResourceId *id, - std::string *errors); + void BuildCustomShader(ShaderEncoding sourceEncoding, const bytebuf &source, const rdcstr &entry, + const ShaderCompileFlags &compileFlags, ShaderStage type, ResourceId &id, + rdcstr &errors); ResourceId ApplyCustomShader(ResourceId shader, ResourceId texid, const Subresource &sub, CompType typeCast); @@ -224,9 +222,9 @@ private: void RefreshDerivedReplacements(); - void BuildShader(ShaderEncoding sourceEncoding, bytebuf source, const std::string &entry, - const ShaderCompileFlags &compileFlags, ShaderStage type, ResourceId *id, - std::string *errors); + void BuildShader(ShaderEncoding sourceEncoding, const bytebuf &source, const rdcstr &entry, + const ShaderCompileFlags &compileFlags, ShaderStage type, ResourceId &id, + rdcstr &errors); bool RenderTextureInternal(D3D12_CPU_DESCRIPTOR_HANDLE rtv, TextureDisplay cfg, TexDisplayFlags flags); @@ -257,7 +255,7 @@ private: uint32_t instStride = 0; // complex case - expansion per instance - std::vector instData; + rdcarray instData; bool useIndices = false; ID3D12Resource *idxBuf = NULL; @@ -293,7 +291,7 @@ private: bool m_Proxy, m_D3D12On7; - std::vector m_ProxyResources; + rdcarray m_ProxyResources; struct OutputWindow { @@ -413,7 +411,7 @@ private: ID3D12Resource *MinMaxTileBuffer = NULL; } m_Histogram; - std::vector m_Resources; + rdcarray m_Resources; std::map m_ResourceIdx; bool m_ISAChecked = false; diff --git a/renderdoc/driver/gl/egl_platform.cpp b/renderdoc/driver/gl/egl_platform.cpp index 007fab32e..874c5fa71 100644 --- a/renderdoc/driver/gl/egl_platform.cpp +++ b/renderdoc/driver/gl/egl_platform.cpp @@ -249,7 +249,7 @@ class EGLPlatform : public GLPlatform EGL_NONE, }; - std::vector versions = GetReplayVersions(RDCDriver::OpenGLES); + rdcarray versions = GetReplayVersions(RDCDriver::OpenGLES); for(GLVersion v : versions) { diff --git a/renderdoc/driver/gl/gl_common.h b/renderdoc/driver/gl/gl_common.h index 8c3c6b30a..3732a87ee 100644 --- a/renderdoc/driver/gl/gl_common.h +++ b/renderdoc/driver/gl/gl_common.h @@ -318,7 +318,7 @@ struct GLVersion int minor; }; -std::vector GetReplayVersions(RDCDriver api); +rdcarray GetReplayVersions(RDCDriver api); #if defined(RENDERDOC_SUPPORT_GL) diff --git a/renderdoc/driver/gl/gl_debug.cpp b/renderdoc/driver/gl/gl_debug.cpp index 811af6f22..dc29c7059 100644 --- a/renderdoc/driver/gl/gl_debug.cpp +++ b/renderdoc/driver/gl/gl_debug.cpp @@ -1649,7 +1649,7 @@ bool GLReplay::GetMinMax(ResourceId texid, const Subresource &sub, CompType type } bool GLReplay::GetHistogram(ResourceId texid, const Subresource &sub, CompType typeCast, float minval, - float maxval, bool channels[4], std::vector &histogram) + float maxval, bool channels[4], rdcarray &histogram) { if(minval >= maxval || texid == ResourceId()) return false; @@ -2047,7 +2047,7 @@ uint32_t GLReplay::PickVertex(uint32_t eventId, int32_t width, int32_t height, byte *idxs = new byte[numIndices * cfg.position.indexByteStride]; memset(idxs, 0, numIndices * cfg.position.indexByteStride); - std::vector outidxs; + rdcarray outidxs; outidxs.resize(numIndices); drv.glBindBuffer(eGL_COPY_READ_BUFFER, ib); diff --git a/renderdoc/driver/gl/gl_driver.cpp b/renderdoc/driver/gl/gl_driver.cpp index eb9d6ca2f..d3352e377 100644 --- a/renderdoc/driver/gl/gl_driver.cpp +++ b/renderdoc/driver/gl/gl_driver.cpp @@ -915,7 +915,7 @@ void WrappedOpenGL::CreateReplayBackbuffer(const GLInitParams ¶ms, ResourceI GL.glBindBuffer(eGL_PIXEL_UNPACK_BUFFER, unpackbuf); } -std::string WrappedOpenGL::GetChunkName(uint32_t idx) +rdcstr WrappedOpenGL::GetChunkName(uint32_t idx) { if((SystemChunk)idx < SystemChunk::FirstDriverChunk) return ToStr((SystemChunk)idx); diff --git a/renderdoc/driver/gl/gl_driver.h b/renderdoc/driver/gl/gl_driver.h index 3b552b936..8b0da51bd 100644 --- a/renderdoc/driver/gl/gl_driver.h +++ b/renderdoc/driver/gl/gl_driver.h @@ -148,7 +148,7 @@ private: ReplayOptions m_ReplayOptions; WriteSerialiser m_ScratchSerialiser; - std::set m_StringDB; + std::set m_StringDB; StreamReader *m_FrameReader = NULL; @@ -238,7 +238,7 @@ private: } std::vector m_CapturedFrames; - std::vector m_Drawcalls; + rdcarray m_Drawcalls; // replay @@ -569,7 +569,7 @@ public: APIProperties APIProps; uint64_t GetLogVersion() { return m_SectionVersion; } - static std::string GetChunkName(uint32_t idx); + static rdcstr GetChunkName(uint32_t idx); GLResourceManager *GetResourceManager() { return m_ResourceManager; } CaptureState GetState() { return m_State; } GLReplay *GetReplay() { return m_Replay; } @@ -652,7 +652,7 @@ public: std::vector sources; std::vector includepaths; rdcspv::Reflector spirv; - std::string disassembly; + rdcstr disassembly; ShaderReflection reflection; int version; diff --git a/renderdoc/driver/gl/gl_overlay.cpp b/renderdoc/driver/gl/gl_overlay.cpp index 2eef4c37d..b1a40a1b2 100644 --- a/renderdoc/driver/gl/gl_overlay.cpp +++ b/renderdoc/driver/gl/gl_overlay.cpp @@ -229,7 +229,7 @@ bool GLReplay::CreateOverlayProgram(GLuint Program, GLuint Pipeline, GLuint frag ResourceId GLReplay::RenderOverlay(ResourceId texid, CompType typeCast, FloatVector clearCol, DebugOverlay overlay, uint32_t eventId, - const std::vector &passEvents) + const rdcarray &passEvents) { WrappedOpenGL &drv = *m_pDriver; @@ -477,7 +477,7 @@ ResourceId GLReplay::RenderOverlay(ResourceId texid, CompType typeCast, FloatVec const DrawcallDescription *draw = m_pDriver->GetDrawcall(eventId); - std::vector patchedIndices; + rdcarray patchedIndices; // readback the index buffer data if(idxbuf) @@ -513,7 +513,7 @@ ResourceId GLReplay::RenderOverlay(ResourceId texid, CompType typeCast, FloatVec else { // generate 'index' list - std::vector idxs; + rdcarray idxs; idxs.resize(draw->numIndices); for(uint32_t i = 0; i < draw->numIndices; i++) idxs[i] = i; @@ -914,7 +914,7 @@ ResourceId GLReplay::RenderOverlay(ResourceId texid, CompType typeCast, FloatVec float col[] = {0.0f, 0.0f, 0.0f, 0.0f}; drv.glClearBufferfv(eGL_COLOR, 0, col); - std::vector events = passEvents; + rdcarray events = passEvents; if(overlay == DebugOverlay::ClearBeforeDraw) events.clear(); @@ -971,7 +971,7 @@ ResourceId GLReplay::RenderOverlay(ResourceId texid, CompType typeCast, FloatVec *v = Vec4f(rs.Viewports[0].width, rs.Viewports[0].height); drv.glUnmapBuffer(eGL_COPY_WRITE_BUFFER); - std::vector events = passEvents; + rdcarray events = passEvents; if(overlay == DebugOverlay::TriangleSizeDraw) events.clear(); @@ -1340,7 +1340,7 @@ ResourceId GLReplay::RenderOverlay(ResourceId texid, CompType typeCast, FloatVec float black[] = {0.0f, 0.0f, 0.0f, 0.0f}; drv.glClearBufferfv(eGL_COLOR, 0, black); - std::vector events = passEvents; + rdcarray events = passEvents; if(overlay == DebugOverlay::QuadOverdrawDraw) events.clear(); diff --git a/renderdoc/driver/gl/gl_postvs.cpp b/renderdoc/driver/gl/gl_postvs.cpp index 3b6c322e7..bf7680b0c 100644 --- a/renderdoc/driver/gl/gl_postvs.cpp +++ b/renderdoc/driver/gl/gl_postvs.cpp @@ -1811,7 +1811,7 @@ void GLReplay::InitPostVSBuffers(uint32_t eventId) drv.glDeleteShader(dummyFrag); } -void GLReplay::InitPostVSBuffers(const std::vector &passEvents) +void GLReplay::InitPostVSBuffers(const rdcarray &passEvents) { uint32_t prev = 0; diff --git a/renderdoc/driver/gl/gl_rendermesh.cpp b/renderdoc/driver/gl/gl_rendermesh.cpp index 5bc28b1e6..fc211a8e7 100644 --- a/renderdoc/driver/gl/gl_rendermesh.cpp +++ b/renderdoc/driver/gl/gl_rendermesh.cpp @@ -33,7 +33,7 @@ #define OPENGL 1 #include "data/glsl/glsl_ubos_cpp.h" -void GLReplay::RenderMesh(uint32_t eventId, const std::vector &secondaryDraws, +void GLReplay::RenderMesh(uint32_t eventId, const rdcarray &secondaryDraws, const MeshDisplay &cfg) { WrappedOpenGL &drv = *m_pDriver; @@ -551,16 +551,16 @@ void GLReplay::RenderMesh(uint32_t eventId, const std::vector &secon FloatVector activeVertex; // primitive this vert is a part of (red prim, optional) - std::vector activePrim; + rdcarray activePrim; // for patch lists, to show other verts in patch (green dots, optional) // for non-patch lists, we use the activePrim and adjacentPrimVertices // to show what other verts are related - std::vector inactiveVertices; + rdcarray inactiveVertices; // adjacency (line or tri, strips or lists) (green prims, optional) // will be N*M long, N adjacent prims of M verts each. M = primSize below - std::vector adjacentPrimVertices; + rdcarray adjacentPrimVertices; GLenum primTopo = eGL_TRIANGLES; uint32_t primSize = 3; // number of verts per primitive diff --git a/renderdoc/driver/gl/gl_replay.cpp b/renderdoc/driver/gl/gl_replay.cpp index 340819634..2214cfd92 100644 --- a/renderdoc/driver/gl/gl_replay.cpp +++ b/renderdoc/driver/gl/gl_replay.cpp @@ -104,9 +104,9 @@ const SDFile &GLReplay::GetStructuredFile() return m_pDriver->GetStructuredFile(); } -std::vector GLReplay::GetPassEvents(uint32_t eventId) +rdcarray GLReplay::GetPassEvents(uint32_t eventId) { - std::vector passEvents; + rdcarray passEvents; const DrawcallDescription *draw = m_pDriver->GetDrawcall(eventId); @@ -136,9 +136,9 @@ std::vector GLReplay::GetPassEvents(uint32_t eventId) return passEvents; } -std::vector GLReplay::GetSupportedWindowSystems() +rdcarray GLReplay::GetSupportedWindowSystems() { - std::vector ret; + rdcarray ret; #if ENABLED(RDOC_LINUX) @@ -194,9 +194,9 @@ APIProperties GLReplay::GetAPIProperties() return ret; } -std::vector GLReplay::GetBuffers() +rdcarray GLReplay::GetBuffers() { - std::vector ret; + rdcarray ret; for(auto it = m_pDriver->m_Buffers.begin(); it != m_pDriver->m_Buffers.end(); ++it) { @@ -224,14 +224,14 @@ ResourceDescription &GLReplay::GetResourceDesc(ResourceId id) return m_Resources[it->second]; } -const std::vector &GLReplay::GetResources() +const rdcarray &GLReplay::GetResources() { return m_Resources; } -std::vector GLReplay::GetTextures() +rdcarray GLReplay::GetTextures() { - std::vector ret; + rdcarray ret; ret.reserve(m_pDriver->m_Textures.size()); for(auto it = m_pDriver->m_Textures.begin(); it != m_pDriver->m_Textures.end(); ++it) @@ -278,7 +278,7 @@ void GLReplay::SetReplayData(GLWindowingData data) const char *vendor = (const char *)drv.glGetString(eGL_VENDOR); const char *renderer = (const char *)drv.glGetString(eGL_RENDERER); - for(std::string haystack : {strlower(version), strlower(vendor), strlower(renderer)}) + for(rdcstr haystack : {strlower(version), strlower(vendor), strlower(renderer)}) { haystack = " " + haystack + " "; @@ -286,7 +286,7 @@ void GLReplay::SetReplayData(GLWindowingData data) // or renderer - except for nouveau which we look for separately for(const char *needle : {" mesa ", "nouveau"}) { - if(haystack.find(needle) != std::string::npos) + if(haystack.contains(needle)) { isMesa = true; break; @@ -727,7 +727,7 @@ BufferDescription GLReplay::GetBuffer(ResourceId id) return ret; } -std::vector GLReplay::GetDebugMessages() +rdcarray GLReplay::GetDebugMessages() { return m_pDriver->GetDebugMessages(); } @@ -761,18 +761,13 @@ ShaderReflection *GLReplay::GetShader(ResourceId pipeline, ResourceId shader, Sh return &shaderDetails.reflection; } -std::vector GLReplay::GetDisassemblyTargets() +rdcarray GLReplay::GetDisassemblyTargets() { - std::vector ret; - - // default is always first - ret.insert(ret.begin(), SPIRVDisassemblyTarget); - - return ret; + return {SPIRVDisassemblyTarget}; } -std::string GLReplay::DisassembleShader(ResourceId pipeline, const ShaderReflection *refl, - const std::string &target) +rdcstr GLReplay::DisassembleShader(ResourceId pipeline, const ShaderReflection *refl, + const rdcstr &target) { auto &shaderDetails = m_pDriver->m_Shaders[m_pDriver->GetResourceManager()->GetLiveID(refl->resourceId)]; @@ -782,7 +777,7 @@ std::string GLReplay::DisassembleShader(ResourceId pipeline, const ShaderReflect if(target == SPIRVDisassemblyTarget || target.empty()) { - std::string &disasm = shaderDetails.disassembly; + rdcstr &disasm = shaderDetails.disassembly; if(disasm.empty()) disasm = shaderDetails.spirv.Disassemble(refl->entryPoint.c_str()); @@ -1953,8 +1948,7 @@ void GLReplay::SavePipelineState(uint32_t eventId) } void GLReplay::OpenGLFillCBufferVariables(ResourceId shader, GLuint prog, bool bufferBacked, - std::string prefix, - const rdcarray &variables, + rdcstr prefix, const rdcarray &variables, rdcarray &outvars, const bytebuf &bufferData) { @@ -2016,7 +2010,7 @@ void GLReplay::OpenGLFillCBufferVariables(ResourceId shader, GLuint prog, bool b // need to query offset and strides as there's no way to know what layout was used // (and if it's not an std layout it's implementation defined :( ) - std::string fullname = prefix + var.name.c_str(); + rdcstr fullname = prefix + var.name; GLuint idx = GL.glGetProgramResourceIndex(prog, eGL_UNIFORM, fullname.c_str()); @@ -2038,7 +2032,7 @@ void GLReplay::OpenGLFillCBufferVariables(ResourceId shader, GLuint prog, bool b // if this is an array, generate empty members if(desc.elements > 0) { - std::vector elems; + rdcarray elems; for(uint32_t a = 0; a < desc.elements; a++) { ShaderVariable el = var; @@ -2109,7 +2103,7 @@ void GLReplay::OpenGLFillCBufferVariables(ResourceId shader, GLuint prog, bool b } else { - std::vector elems; + rdcarray elems; for(uint32_t a = 0; a < desc.elements; a++) { ShaderVariable el = var; @@ -2171,7 +2165,7 @@ void GLReplay::OpenGLFillCBufferVariables(ResourceId shader, GLuint prog, bool b } } -void GLReplay::FillCBufferVariables(ResourceId pipeline, ResourceId shader, std::string entryPoint, +void GLReplay::FillCBufferVariables(ResourceId pipeline, ResourceId shader, rdcstr entryPoint, uint32_t cbufSlot, rdcarray &outvars, const bytebuf &data) { @@ -2786,9 +2780,9 @@ void GLReplay::GetTextureData(ResourceId tex, const Subresource &sub, drv.glDeleteTextures(1, &tempTex); } -void GLReplay::BuildCustomShader(ShaderEncoding sourceEncoding, bytebuf source, - const std::string &entry, const ShaderCompileFlags &compileFlags, - ShaderStage type, ResourceId *id, std::string *errors) +void GLReplay::BuildCustomShader(ShaderEncoding sourceEncoding, const bytebuf &source, + const rdcstr &entry, const ShaderCompileFlags &compileFlags, + ShaderStage type, ResourceId &id, rdcstr &errors) { BuildTargetShader(sourceEncoding, source, entry, compileFlags, type, id, errors); } @@ -2886,17 +2880,10 @@ void GLReplay::FreeCustomShader(ResourceId id) m_pDriver->glDeleteShader(m_pDriver->GetResourceManager()->GetCurrentResource(id).name); } -void GLReplay::BuildTargetShader(ShaderEncoding sourceEncoding, bytebuf source, - const std::string &entry, const ShaderCompileFlags &compileFlags, - ShaderStage type, ResourceId *id, std::string *errors) +void GLReplay::BuildTargetShader(ShaderEncoding sourceEncoding, const bytebuf &source, + const rdcstr &entry, const ShaderCompileFlags &compileFlags, + ShaderStage type, ResourceId &id, rdcstr &errors) { - if(id == NULL || errors == NULL) - { - if(id) - *id = ResourceId(); - return; - } - WrappedOpenGL &drv = *m_pDriver; MakeCurrentReplayContext(m_DebugCtx); @@ -2913,36 +2900,34 @@ void GLReplay::BuildTargetShader(ShaderEncoding sourceEncoding, bytebuf source, default: { RDCERR("Unknown shader type %u", type); - if(id) - *id = ResourceId(); + id = ResourceId(); return; } } - std::string glsl((char *)source.begin(), (char *)source.end()); - const char *src = glsl.c_str(); + const char *src = (const char *)source.data(); + GLint len = source.count(); GLuint shader = drv.glCreateShader(shtype); - drv.glShaderSource(shader, 1, &src, NULL); + drv.glShaderSource(shader, 1, &src, &len); drv.glCompileShader(shader); GLint status = 0; drv.glGetShaderiv(shader, eGL_COMPILE_STATUS, &status); - if(errors) { - GLint len = 1024; + len = 1024; drv.glGetShaderiv(shader, eGL_INFO_LOG_LENGTH, &len); char *buffer = new char[len + 1]; drv.glGetShaderInfoLog(shader, len, NULL, buffer); buffer[len] = 0; - *errors = buffer; + errors = buffer; delete[] buffer; } if(status == 0) - *id = ResourceId(); + id = ResourceId(); else - *id = m_pDriver->GetResourceManager()->GetID(ShaderRes(m_pDriver->GetCtx(), shader)); + id = m_pDriver->GetResourceManager()->GetID(ShaderRes(m_pDriver->GetCtx(), shader)); } void GLReplay::ReplaceResource(ResourceId from, ResourceId to) @@ -3062,7 +3047,7 @@ ResourceId GLReplay::CreateProxyTexture(const TextureDescription &templateTex) { GLsizei compSize = (GLsizei)GetCompressedByteSize(w, h, d, intFormat); - std::vector dummy; + bytebuf dummy; dummy.resize(compSize); if(dim == 1) @@ -3439,17 +3424,17 @@ void GLReplay::SetProxyBufferData(ResourceId bufid, byte *data, size_t dataSize) m_pDriver->glNamedBufferSubDataEXT(buf, 0, dataSize, data); } -std::vector GLReplay::GetUsage(ResourceId id) +rdcarray GLReplay::GetUsage(ResourceId id) { return m_pDriver->GetUsage(id); } -std::vector GLReplay::PixelHistory(std::vector events, - ResourceId target, uint32_t x, uint32_t y, - const Subresource &sub, CompType typeCast) +rdcarray GLReplay::PixelHistory(rdcarray events, ResourceId target, + uint32_t x, uint32_t y, const Subresource &sub, + CompType typeCast) { GLNOTIMP("GLReplay::PixelHistory"); - return std::vector(); + return {}; } ShaderDebugTrace GLReplay::DebugVertex(uint32_t eventId, uint32_t vertid, uint32_t instid, @@ -3634,7 +3619,7 @@ static StructuredProcessRegistration GLProcessRegistration(RDCDriver::OpenGL, &G static StructuredProcessRegistration GLESProcessRegistration(RDCDriver::OpenGLES, &GL_ProcessStructured); -std::vector GetReplayVersions(RDCDriver api) +rdcarray GetReplayVersions(RDCDriver api) { // try to create all versions from highest down to lowest in order to get the highest versioned // context we can diff --git a/renderdoc/driver/gl/gl_replay.h b/renderdoc/driver/gl/gl_replay.h index 266578cea..359877c86 100644 --- a/renderdoc/driver/gl/gl_replay.h +++ b/renderdoc/driver/gl/gl_replay.h @@ -55,7 +55,7 @@ struct GLPostVSData uint32_t instStride = 0; // complex case - expansion per instance - std::vector instData; + rdcarray instData; bool useIndices = false; GLuint idxBuf = 0; @@ -104,24 +104,23 @@ public: APIProperties GetAPIProperties(); ResourceDescription &GetResourceDesc(ResourceId id); - const std::vector &GetResources(); + const rdcarray &GetResources(); - std::vector GetBuffers(); + rdcarray GetBuffers(); BufferDescription GetBuffer(ResourceId id); - std::vector GetTextures(); + rdcarray GetTextures(); TextureDescription GetTexture(ResourceId id); rdcarray GetShaderEntryPoints(ResourceId shader); ShaderReflection *GetShader(ResourceId pipeline, ResourceId shader, ShaderEntryPoint entry); - std::vector GetDisassemblyTargets(); - std::string DisassembleShader(ResourceId pipeline, const ShaderReflection *refl, - const std::string &target); + rdcarray GetDisassemblyTargets(); + rdcstr DisassembleShader(ResourceId pipeline, const ShaderReflection *refl, const rdcstr &target); - std::vector GetDebugMessages(); + rdcarray GetDebugMessages(); - std::vector GetUsage(ResourceId id); + rdcarray GetUsage(ResourceId id); FrameRecord &WriteFrameRecord() { return m_FrameRecord; } FrameRecord GetFrameRecord() { return m_FrameRecord; } @@ -136,9 +135,9 @@ public: void ReplayLog(uint32_t endEventID, ReplayLogType replayType); const SDFile &GetStructuredFile(); - std::vector GetPassEvents(uint32_t eventId); + rdcarray GetPassEvents(uint32_t eventId); - std::vector GetSupportedWindowSystems(); + rdcarray GetSupportedWindowSystems(); AMDRGPControl *GetRGPControl() { return NULL; } uint64_t MakeOutputWindow(WindowingData window, bool depth); @@ -154,7 +153,7 @@ public: void FlipOutputWindow(uint64_t id); void InitPostVSBuffers(uint32_t eventId); - void InitPostVSBuffers(const std::vector &passEvents); + void InitPostVSBuffers(const rdcarray &passEvents); ResourceId GetLiveID(ResourceId id); @@ -163,7 +162,7 @@ public: bool GetMinMax(ResourceId texid, const Subresource &sub, CompType typeCast, float *minval, float *maxval); bool GetHistogram(ResourceId texid, const Subresource &sub, CompType typeCast, float minval, - float maxval, bool channels[4], std::vector &histogram); + float maxval, bool channels[4], rdcarray &histogram); MeshFormat GetPostVSBuffers(uint32_t eventId, uint32_t instID, uint32_t viewID, MeshDataStage stage); @@ -179,17 +178,17 @@ public: CounterDescription DescribeCounter(GPUCounter counterID); rdcarray FetchCounters(const rdcarray &counters); - void RenderMesh(uint32_t eventId, const std::vector &secondaryDraws, + void RenderMesh(uint32_t eventId, const rdcarray &secondaryDraws, const MeshDisplay &cfg); rdcarray GetCustomShaderEncodings() { return {ShaderEncoding::GLSL}; } rdcarray GetTargetShaderEncodings() { return {ShaderEncoding::GLSL}; } - void BuildTargetShader(ShaderEncoding sourceEncoding, bytebuf source, const std::string &entry, - const ShaderCompileFlags &compileFlags, ShaderStage type, ResourceId *id, - std::string *errors); - void BuildCustomShader(ShaderEncoding sourceEncoding, bytebuf source, const std::string &entry, - const ShaderCompileFlags &compileFlags, ShaderStage type, ResourceId *id, - std::string *errors); + void BuildTargetShader(ShaderEncoding sourceEncoding, const bytebuf &source, const rdcstr &entry, + const ShaderCompileFlags &compileFlags, ShaderStage type, ResourceId &id, + rdcstr &errors); + void BuildCustomShader(ShaderEncoding sourceEncoding, const bytebuf &source, const rdcstr &entry, + const ShaderCompileFlags &compileFlags, ShaderStage type, ResourceId &id, + rdcstr &errors); void FreeCustomShader(ResourceId id); bool RenderTexture(TextureDisplay cfg); @@ -199,13 +198,12 @@ public: void RenderHighlightBox(float w, float h, float scale); - void FillCBufferVariables(ResourceId pipeline, ResourceId shader, std::string entryPoint, + void FillCBufferVariables(ResourceId pipeline, ResourceId shader, rdcstr entryPoint, uint32_t cbufSlot, rdcarray &outvars, const bytebuf &data); - std::vector PixelHistory(std::vector events, ResourceId target, - uint32_t x, uint32_t y, const Subresource &sub, - CompType typeCast); + rdcarray PixelHistory(rdcarray events, ResourceId target, uint32_t x, + uint32_t y, const Subresource &sub, CompType typeCast); ShaderDebugTrace DebugVertex(uint32_t eventId, uint32_t vertid, uint32_t instid, uint32_t idx, uint32_t instOffset, uint32_t vertOffset); ShaderDebugTrace DebugPixel(uint32_t eventId, uint32_t x, uint32_t y, uint32_t sample, @@ -217,7 +215,7 @@ public: ResourceId RenderOverlay(ResourceId id, CompType typeCast, FloatVector clearCol, DebugOverlay overlay, uint32_t eventId, - const std::vector &passEvents); + const rdcarray &passEvents); ResourceId ApplyCustomShader(ResourceId shader, ResourceId texid, const Subresource &sub, CompType typeCast); @@ -237,8 +235,8 @@ public: bool IsReplayContext(void *ctx) { return m_ReplayCtx.ctx == NULL || ctx == m_ReplayCtx.ctx; } bool HasDebugContext() { return m_DebugCtx != NULL; } private: - void OpenGLFillCBufferVariables(ResourceId shader, GLuint prog, bool bufferBacked, - std::string prefix, const rdcarray &variables, + void OpenGLFillCBufferVariables(ResourceId shader, GLuint prog, bool bufferBacked, rdcstr prefix, + const rdcarray &variables, rdcarray &outvars, const bytebuf &data); bool GetMinMax(ResourceId texid, const Subresource &sub, CompType typeCast, bool stencil, @@ -355,7 +353,7 @@ private: GLuint triHighlightBuffer; GLuint feedbackObj; - std::vector feedbackQueries; + rdcarray feedbackQueries; GLuint feedbackBuffer; uint64_t feedbackBufferSize = 32 * 1024 * 1024; @@ -427,7 +425,7 @@ private: WrappedOpenGL *m_pDriver; - std::vector m_Resources; + rdcarray m_Resources; std::map m_ResourceIdx; GLPipe::State m_CurPipelineState; diff --git a/renderdoc/driver/gl/glx_platform.cpp b/renderdoc/driver/gl/glx_platform.cpp index 0710a0776..fde5d4814 100644 --- a/renderdoc/driver/gl/glx_platform.cpp +++ b/renderdoc/driver/gl/glx_platform.cpp @@ -382,7 +382,7 @@ class GLXPlatform : public GLPlatform { X11ErrorHandler prev = XSetErrorHandler(&NonFatalX11ErrorHandler); - std::vector versions = GetReplayVersions(api); + rdcarray versions = GetReplayVersions(api); for(GLVersion v : versions) { diff --git a/renderdoc/driver/gl/wgl_platform.cpp b/renderdoc/driver/gl/wgl_platform.cpp index 629c2cf0e..4371f9259 100644 --- a/renderdoc/driver/gl/wgl_platform.cpp +++ b/renderdoc/driver/gl/wgl_platform.cpp @@ -383,7 +383,7 @@ class WGLPlatform : public GLPlatform rc = NULL; - std::vector versions = GetReplayVersions(api); + rdcarray versions = GetReplayVersions(api); for(GLVersion v : versions) { diff --git a/renderdoc/driver/gl/wrappers/gl_emulated.cpp b/renderdoc/driver/gl/wrappers/gl_emulated.cpp index a732fdcf9..a8b1dc1d6 100644 --- a/renderdoc/driver/gl/wrappers/gl_emulated.cpp +++ b/renderdoc/driver/gl/wrappers/gl_emulated.cpp @@ -3565,7 +3565,7 @@ void MakeOnlineShaderReflection(ShaderStage stage, const std::string &source, RDCASSERT(entryPoint == "main"); - std::map replays = RenderDoc::Inst().GetReplayDrivers(); + std::map replays = RenderDoc::Inst().GetReplayDrivers(); if(replays.find(RDCDriver::OpenGL) != replays.end()) status = RenderDoc::Inst().CreateProxyReplayDriver(RDCDriver::OpenGL, &driver); @@ -3577,12 +3577,12 @@ void MakeOnlineShaderReflection(ShaderStage stage, const std::string &source, } ResourceId id; - std::string errors; + rdcstr errors; bytebuf buf; buf.resize(source.size()); memcpy(buf.data(), source.data(), source.size()); - driver->BuildCustomShader(ShaderEncoding::GLSL, buf, "main", ShaderCompileFlags(), stage, &id, - &errors); + driver->BuildCustomShader(ShaderEncoding::GLSL, buf, "main", ShaderCompileFlags(), stage, id, + errors); if(id == ResourceId()) { diff --git a/renderdoc/driver/vulkan/vk_bindless_feedback.cpp b/renderdoc/driver/vulkan/vk_bindless_feedback.cpp index 6338e819f..a9563a0bf 100644 --- a/renderdoc/driver/vulkan/vk_bindless_feedback.cpp +++ b/renderdoc/driver/vulkan/vk_bindless_feedback.cpp @@ -620,8 +620,8 @@ void VulkanReplay::FetchShaderFeedback(uint32_t eventId) VkDeviceAddress bufferAddress = 0; VkDescriptorPool descpool = VK_NULL_HANDLE; - std::vector setLayouts; - std::vector descSets; + rdcarray setLayouts; + rdcarray descSets; VkPipelineLayout pipeLayout = VK_NULL_HANDLE; diff --git a/renderdoc/driver/vulkan/vk_core.cpp b/renderdoc/driver/vulkan/vk_core.cpp index 6136a4c75..a5238620f 100644 --- a/renderdoc/driver/vulkan/vk_core.cpp +++ b/renderdoc/driver/vulkan/vk_core.cpp @@ -456,7 +456,7 @@ uint32_t WrappedVulkan::HandlePreCallback(VkCommandBuffer commandBuffer, DrawFla return eventId; } -std::string WrappedVulkan::GetChunkName(uint32_t idx) +rdcstr WrappedVulkan::GetChunkName(uint32_t idx) { if((SystemChunk)idx < SystemChunk::FirstDriverChunk) return ToStr((SystemChunk)idx); diff --git a/renderdoc/driver/vulkan/vk_core.h b/renderdoc/driver/vulkan/vk_core.h index 375a5ac9b..010b7494b 100644 --- a/renderdoc/driver/vulkan/vk_core.h +++ b/renderdoc/driver/vulkan/vk_core.h @@ -307,7 +307,7 @@ private: StreamReader *m_FrameReader = NULL; - std::set m_StringDB; + std::set m_StringDB; VkResourceRecord *m_FrameCaptureRecord; Chunk *m_HeaderChunk; @@ -354,7 +354,7 @@ private: uint32_t m_FrameCounter = 0; std::vector m_CapturedFrames; - std::vector m_Drawcalls; + rdcarray m_Drawcalls; struct PhysicalDeviceData { @@ -933,7 +933,7 @@ public: APIProperties APIProps; - static std::string GetChunkName(uint32_t idx); + static rdcstr GetChunkName(uint32_t idx); VulkanResourceManager *GetResourceManager() { return m_ResourceManager; } VulkanDebugManager *GetDebugManager() { return m_DebugManager; } VulkanShaderCache *GetShaderCache() { return m_ShaderCache; } diff --git a/renderdoc/driver/vulkan/vk_debug.cpp b/renderdoc/driver/vulkan/vk_debug.cpp index 95f3e05b2..cbdbf9d4c 100644 --- a/renderdoc/driver/vulkan/vk_debug.cpp +++ b/renderdoc/driver/vulkan/vk_debug.cpp @@ -1072,7 +1072,7 @@ uint32_t VulkanReplay::PickVertex(uint32_t eventId, int32_t w, int32_t h, const if(!idxs.empty()) { - std::vector idxtmp; + rdcarray idxtmp; // if it's a triangle fan that allows restart, we'll have to unpack it. // Allocate enough space for the list on the GPU, and enough temporary space to upcast into diff --git a/renderdoc/driver/vulkan/vk_manager.cpp b/renderdoc/driver/vulkan/vk_manager.cpp index f387c42d3..10c96204e 100644 --- a/renderdoc/driver/vulkan/vk_manager.cpp +++ b/renderdoc/driver/vulkan/vk_manager.cpp @@ -940,9 +940,9 @@ void VulkanResourceManager::Apply_InitialState(WrappedVkRes *live, const VkIniti return m_Core->Apply_InitialState(live, initial); } -std::vector VulkanResourceManager::InitialContentResources() +rdcarray VulkanResourceManager::InitialContentResources() { - std::vector resources = + rdcarray resources = ResourceManager::InitialContentResources(); std::sort(resources.begin(), resources.end(), [this](ResourceId a, ResourceId b) { return m_InitialContents[a].data.type < m_InitialContents[b].data.type; diff --git a/renderdoc/driver/vulkan/vk_manager.h b/renderdoc/driver/vulkan/vk_manager.h index 091854347..1222fa2a6 100644 --- a/renderdoc/driver/vulkan/vk_manager.h +++ b/renderdoc/driver/vulkan/vk_manager.h @@ -471,7 +471,7 @@ private: const VkInitialContents *initial); void Create_InitialState(ResourceId id, WrappedVkRes *live, bool hasData); void Apply_InitialState(WrappedVkRes *live, const VkInitialContents &initial); - std::vector InitialContentResources(); + rdcarray InitialContentResources(); WrappedVulkan *m_Core; std::map m_MemFrameRefs; diff --git a/renderdoc/driver/vulkan/vk_outputwindow.cpp b/renderdoc/driver/vulkan/vk_outputwindow.cpp index 7c596b206..8090cf067 100644 --- a/renderdoc/driver/vulkan/vk_outputwindow.cpp +++ b/renderdoc/driver/vulkan/vk_outputwindow.cpp @@ -1188,7 +1188,7 @@ void VulkanReplay::DestroyOutputWindow(uint64_t id) m_OutputWindows.erase(it); } -std::vector VulkanReplay::GetSupportedWindowSystems() +rdcarray VulkanReplay::GetSupportedWindowSystems() { return m_pDriver->m_SupportedWindowSystems; } diff --git a/renderdoc/driver/vulkan/vk_overlay.cpp b/renderdoc/driver/vulkan/vk_overlay.cpp index 5341d7885..52775aa9d 100644 --- a/renderdoc/driver/vulkan/vk_overlay.cpp +++ b/renderdoc/driver/vulkan/vk_overlay.cpp @@ -42,7 +42,7 @@ struct VulkanQuadOverdrawCallback : public VulkanDrawcallCallback { VulkanQuadOverdrawCallback(WrappedVulkan *vk, VkDescriptorSetLayout descSetLayout, - VkDescriptorSet descSet, const std::vector &events) + VkDescriptorSet descSet, const rdcarray &events) : m_pDriver(vk), m_DescSetLayout(descSetLayout), m_DescSet(descSet), @@ -261,7 +261,7 @@ struct VulkanQuadOverdrawCallback : public VulkanDrawcallCallback WrappedVulkan *m_pDriver; VkDescriptorSetLayout m_DescSetLayout; VkDescriptorSet m_DescSet; - const std::vector &m_Events; + const rdcarray &m_Events; // cache modified pipelines struct CachedPipeline @@ -355,7 +355,7 @@ void VulkanDebugManager::PatchLineStripIndexBuffer(const DrawcallDescription *dr } // we just patch up to 32-bit since we'll be adding more indices and we might overflow 16-bit. - std::vector patchedIndices; + rdcarray patchedIndices; ::PatchLineStripIndexBuffer(draw, idx8, idx16, idx32, patchedIndices); @@ -400,7 +400,7 @@ void VulkanDebugManager::PatchLineStripIndexBuffer(const DrawcallDescription *dr ResourceId VulkanReplay::RenderOverlay(ResourceId texid, CompType typeCast, FloatVector clearCol, DebugOverlay overlay, uint32_t eventId, - const std::vector &passEvents) + const rdcarray &passEvents) { const VkDevDispatchTable *vt = ObjDisp(m_Device); @@ -1568,7 +1568,7 @@ ResourceId VulkanReplay::RenderOverlay(ResourceId texid, CompType typeCast, Floa DoPipelineBarrier(cmd, 1, &barrier); - std::vector events = passEvents; + rdcarray events = passEvents; if(overlay == DebugOverlay::ClearBeforeDraw) events.clear(); @@ -1694,7 +1694,7 @@ ResourceId VulkanReplay::RenderOverlay(ResourceId texid, CompType typeCast, Floa DoPipelineBarrier(cmd, 1, &barrier); - std::vector events = passEvents; + rdcarray events = passEvents; if(overlay == DebugOverlay::QuadOverdrawDraw) events.clear(); @@ -1708,7 +1708,7 @@ ResourceId VulkanReplay::RenderOverlay(ResourceId texid, CompType typeCast, Floa { const DrawcallDescription *draw = m_pDriver->GetDrawcall(events[0]); if(draw->flags & DrawFlags::BeginPass) - events.erase(events.begin()); + events.erase(0); } VkImage quadImg; @@ -1950,7 +1950,7 @@ ResourceId VulkanReplay::RenderOverlay(ResourceId texid, CompType typeCast, Floa m_pDriver->SubmitCmds(); #endif - std::vector events = passEvents; + rdcarray events = passEvents; if(overlay == DebugOverlay::TriangleSizeDraw) events.clear(); @@ -1961,7 +1961,7 @@ ResourceId VulkanReplay::RenderOverlay(ResourceId texid, CompType typeCast, Floa // remove any non-drawcalls, like the pass boundary. if(!draw || !(draw->flags & DrawFlags::Drawcall)) - events.erase(events.begin()); + events.erase(0); else break; } diff --git a/renderdoc/driver/vulkan/vk_pixelhistory.cpp b/renderdoc/driver/vulkan/vk_pixelhistory.cpp index 5d2efd124..ad262635d 100644 --- a/renderdoc/driver/vulkan/vk_pixelhistory.cpp +++ b/renderdoc/driver/vulkan/vk_pixelhistory.cpp @@ -108,9 +108,9 @@ struct EventInfo #if 1 -std::vector VulkanReplay::PixelHistory(std::vector events, - ResourceId target, uint32_t x, uint32_t y, - const Subresource &sub, CompType typeCast) +rdcarray VulkanReplay::PixelHistory(rdcarray events, + ResourceId target, uint32_t x, uint32_t y, + const Subresource &sub, CompType typeCast) { VULKANNOTIMP("PixelHistory"); return std::vector(); @@ -1152,9 +1152,9 @@ VkImageLayout VulkanDebugManager::GetImageLayout(ResourceId image, VkImageAspect return imgLayout; } -std::vector VulkanReplay::PixelHistory(std::vector events, - ResourceId target, uint32_t x, uint32_t y, - const Subresource &sub, CompType typeCast) +rdcarray VulkanReplay::PixelHistory(rdcarray events, + ResourceId target, uint32_t x, uint32_t y, + const Subresource &sub, CompType typeCast) { RDCDEBUG("PixelHistory: pixel: (%u, %u) with %u events", x, y, events.size()); std::vector history; diff --git a/renderdoc/driver/vulkan/vk_posix.cpp b/renderdoc/driver/vulkan/vk_posix.cpp index 06c0542ec..12070d79d 100644 --- a/renderdoc/driver/vulkan/vk_posix.cpp +++ b/renderdoc/driver/vulkan/vk_posix.cpp @@ -260,8 +260,8 @@ extern unsigned char driver_vulkan_renderdoc_json[]; extern int driver_vulkan_renderdoc_json_len; #if ENABLED(RDOC_ANDROID) -bool VulkanReplay::CheckVulkanLayer(VulkanLayerFlags &flags, std::vector &myJSONs, - std::vector &otherJSONs) +bool VulkanReplay::CheckVulkanLayer(VulkanLayerFlags &flags, rdcarray &myJSONs, + rdcarray &otherJSONs) { return false; } @@ -399,8 +399,8 @@ void MakeParentDirs(std::string file) mkdir(dir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); } -bool VulkanReplay::CheckVulkanLayer(VulkanLayerFlags &flags, std::vector &myJSONs, - std::vector &otherJSONs) +bool VulkanReplay::CheckVulkanLayer(VulkanLayerFlags &flags, rdcarray &myJSONs, + rdcarray &otherJSONs) { // see if the user has suppressed all this checking as a "I know what I'm doing" measure diff --git a/renderdoc/driver/vulkan/vk_postvs.cpp b/renderdoc/driver/vulkan/vk_postvs.cpp index 59a43f2f2..96cca40a0 100644 --- a/renderdoc/driver/vulkan/vk_postvs.cpp +++ b/renderdoc/driver/vulkan/vk_postvs.cpp @@ -1181,8 +1181,8 @@ void VulkanReplay::ClearPostVSCache() void VulkanReplay::PatchReservedDescriptors(const VulkanStatePipeline &pipe, VkDescriptorPool &descpool, - std::vector &setLayouts, - std::vector &descSets, + rdcarray &setLayouts, + rdcarray &descSets, VkShaderStageFlagBits patchedBindingStage, const VkDescriptorSetLayoutBinding *newBindings, size_t newBindingsCount) @@ -1545,8 +1545,8 @@ void VulkanReplay::FetchVSOut(uint32_t eventId) VkDevice dev = m_Device; VkDescriptorPool descpool; - std::vector setLayouts; - std::vector descSets; + rdcarray setLayouts; + rdcarray descSets; VkPipelineLayout pipeLayout; @@ -3225,7 +3225,7 @@ void VulkanReplay::InitPostVSBuffers(uint32_t eventId) struct VulkanInitPostVSCallback : public VulkanDrawcallCallback { - VulkanInitPostVSCallback(WrappedVulkan *vk, const std::vector &events) + VulkanInitPostVSCallback(WrappedVulkan *vk, const rdcarray &events) : m_pDriver(vk), m_Events(events) { m_pDriver->SetDrawcallCB(this); @@ -3233,7 +3233,7 @@ struct VulkanInitPostVSCallback : public VulkanDrawcallCallback ~VulkanInitPostVSCallback() { 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)) m_pDriver->GetReplay()->InitPostVSBuffers(eid); } @@ -3250,15 +3250,15 @@ struct VulkanInitPostVSCallback : public VulkanDrawcallCallback void PreEndCommandBuffer(VkCommandBuffer cmd) {} void AliasEvent(uint32_t primary, uint32_t alias) { - if(std::find(m_Events.begin(), m_Events.end(), primary) != m_Events.end()) + if(m_Events.contains(primary)) m_pDriver->GetReplay()->AliasPostVSBuffers(primary, alias); } WrappedVulkan *m_pDriver; - const std::vector &m_Events; + const rdcarray &m_Events; }; -void VulkanReplay::InitPostVSBuffers(const std::vector &events) +void VulkanReplay::InitPostVSBuffers(const rdcarray &events) { // first we must replay up to the first event without replaying it. This ensures any // non-command buffer calls like memory unmaps etc all happen correctly before this diff --git a/renderdoc/driver/vulkan/vk_rendermesh.cpp b/renderdoc/driver/vulkan/vk_rendermesh.cpp index 8f9b22316..f6e000940 100644 --- a/renderdoc/driver/vulkan/vk_rendermesh.cpp +++ b/renderdoc/driver/vulkan/vk_rendermesh.cpp @@ -372,7 +372,7 @@ MeshDisplayPipelines VulkanDebugManager::CacheMeshDisplayPipelines(VkPipelineLay return cache; } -void VulkanReplay::RenderMesh(uint32_t eventId, const std::vector &secondaryDraws, +void VulkanReplay::RenderMesh(uint32_t eventId, const rdcarray &secondaryDraws, const MeshDisplay &cfg) { if(cfg.position.vertexResourceId == ResourceId() || cfg.position.numIndices == 0) @@ -908,16 +908,16 @@ void VulkanReplay::RenderMesh(uint32_t eventId, const std::vector &s FloatVector activeVertex; // primitive this vert is a part of (red prim, optional) - std::vector activePrim; + rdcarray activePrim; // for patch lists, to show other verts in patch (green dots, optional) // for non-patch lists, we use the activePrim and adjacentPrimVertices // to show what other verts are related - std::vector inactiveVertices; + rdcarray inactiveVertices; // adjacency (line or tri, strips or lists) (green prims, optional) // will be N*M long, N adjacent prims of M verts each. M = primSize below - std::vector adjacentPrimVertices; + rdcarray adjacentPrimVertices; helper.topology = Topology::TriangleList; uint32_t primSize = 3; // number of verts per primitive diff --git a/renderdoc/driver/vulkan/vk_replay.cpp b/renderdoc/driver/vulkan/vk_replay.cpp index 0bcd09862..e8161c54a 100644 --- a/renderdoc/driver/vulkan/vk_replay.cpp +++ b/renderdoc/driver/vulkan/vk_replay.cpp @@ -203,9 +203,9 @@ const SDFile &VulkanReplay::GetStructuredFile() return m_pDriver->GetStructuredFile(); } -std::vector VulkanReplay::GetPassEvents(uint32_t eventId) +rdcarray VulkanReplay::GetPassEvents(uint32_t eventId) { - std::vector passEvents; + rdcarray passEvents; const DrawcallDescription *draw = m_pDriver->GetDrawcall(eventId); @@ -271,7 +271,7 @@ ResourceId VulkanReplay::GetLiveID(ResourceId id) return m_pDriver->GetResourceManager()->GetLiveID(id); } -std::vector VulkanReplay::GetDebugMessages() +rdcarray VulkanReplay::GetDebugMessages() { return m_pDriver->GetDebugMessages(); } @@ -290,14 +290,14 @@ ResourceDescription &VulkanReplay::GetResourceDesc(ResourceId id) return m_Resources[it->second]; } -const std::vector &VulkanReplay::GetResources() +const rdcarray &VulkanReplay::GetResources() { return m_Resources; } -std::vector VulkanReplay::GetTextures() +rdcarray VulkanReplay::GetTextures() { - std::vector texs; + rdcarray texs; for(auto it = m_pDriver->m_ImageLayouts.begin(); it != m_pDriver->m_ImageLayouts.end(); ++it) { @@ -311,9 +311,9 @@ std::vector VulkanReplay::GetTextures() return texs; } -std::vector VulkanReplay::GetBuffers() +rdcarray VulkanReplay::GetBuffers() { - std::vector bufs; + rdcarray bufs; for(auto it = m_pDriver->m_CreationInfo.m_Buffer.begin(); it != m_pDriver->m_CreationInfo.m_Buffer.end(); ++it) @@ -441,9 +441,9 @@ ShaderReflection *VulkanReplay::GetShader(ResourceId pipeline, ResourceId shader return &shad->second.GetReflection(entry.name, pipeline).refl; } -std::vector VulkanReplay::GetDisassemblyTargets() +rdcarray VulkanReplay::GetDisassemblyTargets() { - std::vector ret; + rdcarray ret; if(m_pDriver->GetExtensions(NULL).ext_AMD_shader_info) ret.push_back(AMDShaderInfoTarget); @@ -452,7 +452,7 @@ std::vector VulkanReplay::GetDisassemblyTargets() ret.push_back(KHRExecutablePropertiesTarget); // default is always first - ret.insert(ret.begin(), SPIRVDisassemblyTarget); + ret.insert(0, SPIRVDisassemblyTarget); // could add canonical disassembly here if spirv-dis is available // Ditto for SPIRV-cross (to glsl/hlsl) @@ -533,8 +533,8 @@ void VulkanReplay::CachePipelineExecutables(ResourceId pipeline) } } -std::string VulkanReplay::DisassembleShader(ResourceId pipeline, const ShaderReflection *refl, - const std::string &target) +rdcstr VulkanReplay::DisassembleShader(ResourceId pipeline, const ShaderReflection *refl, + const rdcstr &target) { auto it = m_pDriver->m_CreationInfo.m_ShaderModule.find( GetResourceManager()->GetLiveID(refl->resourceId)); @@ -1906,9 +1906,9 @@ void VulkanReplay::SavePipelineState(uint32_t eventId) } } -void VulkanReplay::FillCBufferVariables(ResourceId pipeline, ResourceId shader, - std::string entryPoint, uint32_t cbufSlot, - rdcarray &outvars, const bytebuf &data) +void VulkanReplay::FillCBufferVariables(ResourceId pipeline, ResourceId shader, rdcstr entryPoint, + uint32_t cbufSlot, rdcarray &outvars, + const bytebuf &data) { auto it = m_pDriver->m_CreationInfo.m_ShaderModule.find(shader); @@ -2470,7 +2470,7 @@ bool VulkanReplay::GetMinMax(ResourceId texid, const Subresource &sub, CompType bool VulkanReplay::GetHistogram(ResourceId texid, const Subresource &sub, CompType typeCast, float minval, float maxval, bool channels[4], - std::vector &histogram) + rdcarray &histogram) { if(minval >= maxval) return false; @@ -2777,14 +2777,14 @@ bool VulkanReplay::GetHistogram(ResourceId texid, const Subresource &sub, CompTy uint32_t *buckets = (uint32_t *)m_Histogram.m_HistogramReadback.Map(NULL); - histogram.assign(buckets, buckets + HGRAM_NUM_BUCKETS); + histogram.assign(buckets, HGRAM_NUM_BUCKETS); m_Histogram.m_HistogramReadback.Unmap(); return true; } -std::vector VulkanReplay::GetUsage(ResourceId id) +rdcarray VulkanReplay::GetUsage(ResourceId id) { return m_pDriver->GetUsage(id); } @@ -3848,9 +3848,9 @@ void VulkanReplay::GetTextureData(ResourceId tex, const Subresource &sub, } } -void VulkanReplay::BuildCustomShader(ShaderEncoding sourceEncoding, bytebuf source, - const std::string &entry, const ShaderCompileFlags &compileFlags, - ShaderStage type, ResourceId *id, std::string *errors) +void VulkanReplay::BuildCustomShader(ShaderEncoding sourceEncoding, const bytebuf &source, + const rdcstr &entry, const ShaderCompileFlags &compileFlags, + ShaderStage type, ResourceId &id, rdcstr &errors) { BuildTargetShader(sourceEncoding, source, entry, compileFlags, type, id, errors); } @@ -3917,9 +3917,9 @@ ResourceId VulkanReplay::ApplyCustomShader(ResourceId shader, ResourceId texid, return GetResID(GetDebugManager()->GetCustomTexture()); } -void VulkanReplay::BuildTargetShader(ShaderEncoding sourceEncoding, bytebuf source, - const std::string &entry, const ShaderCompileFlags &compileFlags, - ShaderStage type, ResourceId *id, std::string *errors) +void VulkanReplay::BuildTargetShader(ShaderEncoding sourceEncoding, const bytebuf &source, + const rdcstr &entry, const ShaderCompileFlags &compileFlags, + ShaderStage type, ResourceId &id, rdcstr &errors) { std::vector spirv; @@ -3937,7 +3937,7 @@ void VulkanReplay::BuildTargetShader(ShaderEncoding sourceEncoding, bytebuf sour case ShaderStage::Compute: stage = rdcspv::ShaderStage::Compute; break; default: RDCERR("Unexpected type in BuildShader!"); - *id = ResourceId(); + id = ResourceId(); return; } @@ -3950,8 +3950,8 @@ void VulkanReplay::BuildTargetShader(ShaderEncoding sourceEncoding, bytebuf sour if(spirv.empty()) { - *id = ResourceId(); - *errors = output; + id = ResourceId(); + errors = output; return; } } @@ -3973,7 +3973,7 @@ void VulkanReplay::BuildTargetShader(ShaderEncoding sourceEncoding, bytebuf sour VkResult vkr = m_pDriver->vkCreateShaderModule(m_pDriver->GetDev(), &modinfo, NULL, &module); RDCASSERTEQUAL(vkr, VK_SUCCESS); - *id = GetResID(module); + id = GetResID(module); } void VulkanReplay::FreeTargetResource(ResourceId id) diff --git a/renderdoc/driver/vulkan/vk_replay.h b/renderdoc/driver/vulkan/vk_replay.h index c3803dc34..1f3b4a620 100644 --- a/renderdoc/driver/vulkan/vk_replay.h +++ b/renderdoc/driver/vulkan/vk_replay.h @@ -167,7 +167,7 @@ struct VulkanPostVSData uint32_t instStride; // complex case - expansion per instance - std::vector instData; + rdcarray instData; uint32_t numViews; @@ -233,7 +233,7 @@ struct BindIdx struct DynamicUsedBinds { bool compute = false, valid = false; - std::vector used; + rdcarray used; }; enum TexDisplayFlags @@ -266,26 +266,25 @@ public: APIProperties GetAPIProperties(); ResourceDescription &GetResourceDesc(ResourceId id); - const std::vector &GetResources(); + const rdcarray &GetResources(); - std::vector GetBuffers(); + rdcarray GetBuffers(); BufferDescription GetBuffer(ResourceId id); - std::vector GetTextures(); + rdcarray GetTextures(); TextureDescription GetTexture(ResourceId id); rdcarray GetShaderEntryPoints(ResourceId shader); ShaderReflection *GetShader(ResourceId pipeline, ResourceId shader, ShaderEntryPoint entry); - std::vector GetDisassemblyTargets(); - std::string DisassembleShader(ResourceId pipeline, const ShaderReflection *refl, - const std::string &target); + rdcarray GetDisassemblyTargets(); + rdcstr DisassembleShader(ResourceId pipeline, const ShaderReflection *refl, const rdcstr &target); - std::vector GetUsage(ResourceId id); + rdcarray GetUsage(ResourceId id); FrameRecord &WriteFrameRecord() { return m_FrameRecord; } FrameRecord GetFrameRecord() { return m_FrameRecord; } - std::vector GetDebugMessages(); + rdcarray GetDebugMessages(); void SavePipelineState(uint32_t eventId); const D3D11Pipe::State *GetD3D11PipelineState() { return NULL; } @@ -298,9 +297,9 @@ public: void ReplayLog(uint32_t endEventID, ReplayLogType replayType); const SDFile &GetStructuredFile(); - std::vector GetPassEvents(uint32_t eventId); + rdcarray GetPassEvents(uint32_t eventId); - std::vector GetSupportedWindowSystems(); + rdcarray GetSupportedWindowSystems(); AMDRGPControl *GetRGPControl() { return m_RGP; } uint64_t MakeOutputWindow(WindowingData window, bool depth); @@ -326,10 +325,10 @@ public: bool GetMinMax(ResourceId texid, const Subresource &sub, CompType typeCast, float *minval, float *maxval); bool GetHistogram(ResourceId texid, const Subresource &sub, CompType typeCast, float minval, - float maxval, bool channels[4], std::vector &histogram); + float maxval, bool channels[4], rdcarray &histogram); void InitPostVSBuffers(uint32_t eventId); - void InitPostVSBuffers(const std::vector &passEvents); + void InitPostVSBuffers(const rdcarray &passEvents); // indicates that EID alias is the same as eventId void AliasPostVSBuffers(uint32_t eventId, uint32_t alias) { m_PostVS.Alias[alias] = eventId; } @@ -343,7 +342,7 @@ public: void ReplaceResource(ResourceId from, ResourceId to); void RemoveReplacement(ResourceId id); - void RenderMesh(uint32_t eventId, const std::vector &secondaryDraws, + void RenderMesh(uint32_t eventId, const rdcarray &secondaryDraws, const MeshDisplay &cfg); rdcarray GetCustomShaderEncodings() @@ -354,12 +353,12 @@ public: { return {ShaderEncoding::SPIRV, ShaderEncoding::GLSL}; } - void BuildTargetShader(ShaderEncoding sourceEncoding, bytebuf source, const std::string &entry, - const ShaderCompileFlags &compileFlags, ShaderStage type, ResourceId *id, - std::string *errors); - void BuildCustomShader(ShaderEncoding sourceEncoding, bytebuf source, const std::string &entry, - const ShaderCompileFlags &compileFlags, ShaderStage type, ResourceId *id, - std::string *errors); + void BuildTargetShader(ShaderEncoding sourceEncoding, const bytebuf &source, const rdcstr &entry, + const ShaderCompileFlags &compileFlags, ShaderStage type, ResourceId &id, + rdcstr &errors); + void BuildCustomShader(ShaderEncoding sourceEncoding, const bytebuf &source, const rdcstr &entry, + const ShaderCompileFlags &compileFlags, ShaderStage type, ResourceId &id, + rdcstr &errors); void FreeCustomShader(ResourceId id); bool RenderTexture(TextureDisplay cfg); @@ -368,13 +367,12 @@ public: void RenderHighlightBox(float w, float h, float scale); - void FillCBufferVariables(ResourceId pipeline, ResourceId shader, std::string entryPoint, + void FillCBufferVariables(ResourceId pipeline, ResourceId shader, rdcstr entryPoint, uint32_t cbufSlot, rdcarray &outvars, const bytebuf &data); - std::vector PixelHistory(std::vector events, ResourceId target, - uint32_t x, uint32_t y, const Subresource &sub, - CompType typeCast); + rdcarray PixelHistory(rdcarray events, ResourceId target, uint32_t x, + uint32_t y, const Subresource &sub, CompType typeCast); ShaderDebugTrace DebugVertex(uint32_t eventId, uint32_t vertid, uint32_t instid, uint32_t idx, uint32_t instOffset, uint32_t vertOffset); ShaderDebugTrace DebugPixel(uint32_t eventId, uint32_t x, uint32_t y, uint32_t sample, @@ -386,7 +384,7 @@ public: ResourceId RenderOverlay(ResourceId cfg, CompType typeCast, FloatVector clearCol, DebugOverlay overlay, uint32_t eventId, - const std::vector &passEvents); + const rdcarray &passEvents); ResourceId ApplyCustomShader(ResourceId shader, ResourceId texid, const Subresource &sub, CompType typeCast); @@ -410,8 +408,8 @@ public: // but for developers running builds locally or just in case, we need to be able to update the // layer registration ourselves. // These functions are defined in vk_.cpp - static bool CheckVulkanLayer(VulkanLayerFlags &flags, std::vector &myJSONs, - std::vector &otherJSONs); + static bool CheckVulkanLayer(VulkanLayerFlags &flags, rdcarray &myJSONs, + rdcarray &otherJSONs); static void InstallVulkanLayer(bool systemLevel); void GetInitialDriverVersion(); void SetDriverInformation(const VkPhysicalDeviceProperties &props); @@ -422,8 +420,8 @@ private: void ClearFeedbackCache(); void PatchReservedDescriptors(const VulkanStatePipeline &pipe, VkDescriptorPool &descpool, - std::vector &setLayouts, - std::vector &descSets, + rdcarray &setLayouts, + rdcarray &descSets, VkShaderStageFlagBits patchedBindingStage, const VkDescriptorSetLayoutBinding *newBindings, size_t newBindingsCount); @@ -698,7 +696,7 @@ private: std::map Usage; } m_BindlessFeedback; - std::vector m_Resources; + rdcarray m_Resources; std::map m_ResourceIdx; VKPipe::State m_VulkanPipelineState; diff --git a/renderdoc/driver/vulkan/vk_win32.cpp b/renderdoc/driver/vulkan/vk_win32.cpp index 7c4ef1c39..1d6d9a3fd 100644 --- a/renderdoc/driver/vulkan/vk_win32.cpp +++ b/renderdoc/driver/vulkan/vk_win32.cpp @@ -256,7 +256,7 @@ static HKEY GetImplicitLayersKey(bool writeable, bool wow6432) return key; } -bool ProcessImplicitLayersKey(HKEY key, const rdcstr &path, std::vector *otherJSONs, +bool ProcessImplicitLayersKey(HKEY key, const rdcstr &path, rdcarray *otherJSONs, bool deleteOthers) { bool thisRegistered = false; @@ -299,8 +299,8 @@ bool ProcessImplicitLayersKey(HKEY key, const rdcstr &path, std::vector &myJSONs, - std::vector &otherJSONs) +bool VulkanReplay::CheckVulkanLayer(VulkanLayerFlags &flags, rdcarray &myJSONs, + rdcarray &otherJSONs) { rdcstr normalPath = GetJSONPath(false); myJSONs.push_back(normalPath); diff --git a/renderdoc/hooks/hooks.cpp b/renderdoc/hooks/hooks.cpp index cde586d43..005cc9ff3 100644 --- a/renderdoc/hooks/hooks.cpp +++ b/renderdoc/hooks/hooks.cpp @@ -26,9 +26,9 @@ #include "hooks.h" #include "common/common.h" -static std::vector &LibList() +static rdcarray &LibList() { - static std::vector libs; + static rdcarray libs; return libs; } diff --git a/renderdoc/hooks/hooks.h b/renderdoc/hooks/hooks.h index e998e67d6..52c102462 100644 --- a/renderdoc/hooks/hooks.h +++ b/renderdoc/hooks/hooks.h @@ -34,7 +34,7 @@ struct FunctionHook FunctionHook() : orig(NULL), hook(NULL) {} FunctionHook(const char *f, void **o, void *d) : function(f), orig(o), hook(d) {} bool operator<(const FunctionHook &h) const { return function < h.function; } - std::string function; + rdcstr function; void **orig; void *hook; }; @@ -186,7 +186,7 @@ struct LibraryHook private: friend class LibraryHooks; - static std::vector m_Libraries; + static rdcarray m_Libraries; }; template diff --git a/renderdoc/os/posix/apple/apple_hook.cpp b/renderdoc/os/posix/apple/apple_hook.cpp index b54b7714e..4067278fd 100644 --- a/renderdoc/os/posix/apple/apple_hook.cpp +++ b/renderdoc/os/posix/apple/apple_hook.cpp @@ -27,7 +27,6 @@ #include #include #include -#include #include "common/common.h" #include "common/threading.h" #include "hooks/hooks.h" diff --git a/renderdoc/os/posix/ggp/ggp_callstack.cpp b/renderdoc/os/posix/ggp/ggp_callstack.cpp index 36979bd40..10314f57d 100644 --- a/renderdoc/os/posix/ggp/ggp_callstack.cpp +++ b/renderdoc/os/posix/ggp/ggp_callstack.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include "common/common.h" #include "common/formatting.h" #include "os/os_specific.h" diff --git a/renderdoc/os/posix/linux/linux_callstack.cpp b/renderdoc/os/posix/linux/linux_callstack.cpp index af7e811c5..deff9648f 100644 --- a/renderdoc/os/posix/linux/linux_callstack.cpp +++ b/renderdoc/os/posix/linux/linux_callstack.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include "common/common.h" #include "common/formatting.h" #include "os/os_specific.h" diff --git a/renderdoc/os/posix/linux/linux_hook.cpp b/renderdoc/os/posix/linux/linux_hook.cpp index a438cf93e..7e1e3748b 100644 --- a/renderdoc/os/posix/linux/linux_hook.cpp +++ b/renderdoc/os/posix/linux/linux_hook.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include "3rdparty/plthook/plthook.h" #include "common/threading.h" #include "hooks/hooks.h" diff --git a/renderdoc/os/posix/posix_network.cpp b/renderdoc/os/posix/posix_network.cpp index 51a14dd96..bdd24b5dc 100644 --- a/renderdoc/os/posix/posix_network.cpp +++ b/renderdoc/os/posix/posix_network.cpp @@ -34,7 +34,6 @@ #include #include #include -#include #include "api/replay/data_types.h" #include "common/common.h" #include "common/formatting.h" diff --git a/renderdoc/os/win32/win32_callstack.cpp b/renderdoc/os/win32/win32_callstack.cpp index 03e02651a..6a5c1ccee 100644 --- a/renderdoc/os/win32/win32_callstack.cpp +++ b/renderdoc/os/win32/win32_callstack.cpp @@ -33,8 +33,6 @@ #include #include #include -#include -#include #include "common/formatting.h" #include "core/core.h" #include "dbghelp/dbghelp.h" diff --git a/renderdoc/os/win32/win32_hook.cpp b/renderdoc/os/win32/win32_hook.cpp index 722d70693..d0dd08dd8 100644 --- a/renderdoc/os/win32/win32_hook.cpp +++ b/renderdoc/os/win32/win32_hook.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include "common/common.h" #include "common/threading.h" #include "hooks/hooks.h" diff --git a/renderdoc/os/win32/win32_process.cpp b/renderdoc/os/win32/win32_process.cpp index c60adb249..c0adab45d 100644 --- a/renderdoc/os/win32/win32_process.cpp +++ b/renderdoc/os/win32/win32_process.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include "common/formatting.h" #include "core/core.h" #include "os/os_specific.h" diff --git a/renderdoc/os/win32/win32_shellext.cpp b/renderdoc/os/win32/win32_shellext.cpp index d57e500bf..eadedefa5 100644 --- a/renderdoc/os/win32/win32_shellext.cpp +++ b/renderdoc/os/win32/win32_shellext.cpp @@ -146,7 +146,7 @@ struct RDCThumbnailProvider : public IThumbnailProvider, IInitializeWithStream return S_OK; } - void STDMETHODCALLTYPE ReadLegacyCaptureThumb(rdcarray &captureHeader) + void STDMETHODCALLTYPE ReadLegacyCaptureThumb(bytebuf &captureHeader) { // we want to support old capture files, so we decode the thumbnail by hand here with the // old header. @@ -232,7 +232,7 @@ struct RDCThumbnailProvider : public IThumbnailProvider, IInitializeWithStream // eSectionFlag_LZ4Compressed if(sectionFlags & 0x2) { - rdcarray uncompressed; + bytebuf uncompressed; LZ4_streamDecode_t lZ4Decomp = {}; LZ4_setStreamDecode(&lZ4Decomp, NULL, 0); diff --git a/renderdoc/replay/app_api.cpp b/renderdoc/replay/app_api.cpp index cb835382c..e9e22dd11 100644 --- a/renderdoc/replay/app_api.cpp +++ b/renderdoc/replay/app_api.cpp @@ -80,7 +80,7 @@ static uint32_t GetNumCaptures() static uint32_t GetCapture(uint32_t idx, char *filename, uint32_t *pathlength, uint64_t *timestamp) { - std::vector caps = RenderDoc::Inst().GetCaptures(); + rdcarray caps = RenderDoc::Inst().GetCaptures(); if(idx >= (uint32_t)caps.size()) { @@ -107,10 +107,10 @@ static uint32_t GetCapture(uint32_t idx, char *filename, uint32_t *pathlength, u static void SetCaptureFileComments(const char *filePath, const char *comments) { - std::string path; + rdcstr path; if(filePath == NULL || filePath[0] == 0) { - std::vector caps = RenderDoc::Inst().GetCaptures(); + rdcarray caps = RenderDoc::Inst().GetCaptures(); if(caps.empty()) { RDCERR( @@ -141,7 +141,7 @@ static void SetCaptureFileComments(const char *filePath, const char *comments) if(comments) { - std::string commentsjson = "{\"comments\":\""; + rdcstr commentsjson = "{\"comments\":\""; commentsjson.reserve(strlen(comments)); @@ -195,12 +195,12 @@ static uint32_t IsTargetControlConnected() static uint32_t LaunchReplayUI(uint32_t connectTargetControl, const char *cmdline) { - std::string replayapp = FileIO::GetReplayAppFilename(); + rdcstr replayapp = FileIO::GetReplayAppFilename(); if(replayapp.empty()) return 0; - std::string cmd = cmdline ? cmdline : ""; + rdcstr cmd = cmdline ? cmdline : ""; if(connectTargetControl) cmd += StringFormat::Fmt(" --targetcontrol localhost:%u", RenderDoc::Inst().GetTargetControlIdent()); @@ -313,7 +313,7 @@ extern "C" RENDERDOC_API int RENDERDOC_CC RENDERDOC_GetAPI(RENDERDOC_Version ver int ret = 0; int major = 0, minor = 0, patch = 0; - std::string supportedVersions = ""; + rdcstr supportedVersions = ""; #define API_VERSION_HANDLE(enumver, actualver) \ supportedVersions += " " STRINGIZE(CONCAT(API_, enumver)); \ diff --git a/renderdoc/replay/capture_file.cpp b/renderdoc/replay/capture_file.cpp index f6eca1093..ef01a9a35 100644 --- a/renderdoc/replay/capture_file.cpp +++ b/renderdoc/replay/capture_file.cpp @@ -34,10 +34,8 @@ static void writeToByteVector(void *context, void *data, int size) { - std::vector *vec = (std::vector *)context; - byte *start = (byte *)data; - byte *end = start + size; - vec->insert(vec->end(), start, end); + bytebuf *buf = (bytebuf *)context; + buf->append((byte *)data, size); } static RDCDriver driverFromName(const char *driverName) @@ -184,7 +182,7 @@ private: SDFile m_StructuredData; - std::string m_DriverName, m_Ident, m_ErrorString; + rdcstr m_DriverName, m_Ident, m_ErrorString; ReplaySupport m_Support = ReplaySupport::Unsupported; }; @@ -245,14 +243,12 @@ ReplayStatus CaptureFile::OpenBuffer(const bytebuf &buffer, const char *filetype { CaptureImporter importer = RenderDoc::Inst().GetCaptureImporter(filetype); - std::vector vec(buffer.begin(), buffer.end()); - if(importer) { ReplayStatus ret; { - StreamReader reader(vec); + StreamReader reader(buffer); m_RDC = new RDCFile; ret = importer(NULL, reader, m_RDC, m_StructuredData, progress); } @@ -273,7 +269,7 @@ ReplayStatus CaptureFile::OpenBuffer(const bytebuf &buffer, const char *filetype progress(0.0f); m_RDC = new RDCFile; - m_RDC->Open(vec); + m_RDC->Open(buffer); if(progress) progress(1.0f); @@ -628,13 +624,13 @@ Thumbnail CaptureFile::GetThumbnail(FileType type, uint32_t maxsize) } } - std::vector encodedBytes; + bytebuf encodedBytes; switch(type) { case FileType::Raw: { - encodedBytes.assign(thumbpixels, thumbpixels + (thumbwidth * thumbheight * 3)); + encodedBytes.assign(thumbpixels, thumbwidth * thumbheight * 3); break; } case FileType::JPG: @@ -778,7 +774,7 @@ bool CaptureFile::InitResolver(RENDERDOC_ProgressCallback progress) StreamReader *reader = m_RDC->ReadSection(idx); - std::vector buf; + bytebuf buf; buf.resize((size_t)reader->GetSize()); bool success = reader->Read(buf.data(), reader->GetSize()); diff --git a/renderdoc/replay/entry_points.cpp b/renderdoc/replay/entry_points.cpp index 37d90ef1c..24c430745 100644 --- a/renderdoc/replay/entry_points.cpp +++ b/renderdoc/replay/entry_points.cpp @@ -273,7 +273,7 @@ extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_GetLogFileContents(rdcstr & extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_InitGlobalEnv(GlobalEnvironment env, const rdcarray &args) { - std::vector argsVec; + rdcarray argsVec; argsVec.reserve(args.size()); for(const rdcstr &a : args) argsVec.push_back(a.c_str()); @@ -318,7 +318,7 @@ extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_CreateBugReport(const char if(logfile && logfile[0]) { - std::string contents = FileIO::logfile_readall(logfile); + rdcstr contents = FileIO::logfile_readall(logfile); mz_zip_writer_add_mem(&zip, "error.log", contents.data(), contents.length(), MZ_BEST_COMPRESSION); } @@ -565,8 +565,8 @@ extern "C" RENDERDOC_API bool RENDERDOC_CC RENDERDOC_NeedVulkanLayerRegistration(VulkanLayerRegistrationInfo *info) { VulkanLayerFlags flags = VulkanLayerFlags::NoFlags; - std::vector myJSONs; - std::vector otherJSONs; + rdcarray myJSONs; + rdcarray otherJSONs; bool ret = RenderDoc::Inst().NeedVulkanLayerRegistration(flags, myJSONs, otherJSONs); @@ -660,7 +660,7 @@ extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_UpdateInstalledVersionNumbe DWORD Version = (RENDERDOC_VERSION_MAJOR << 24) | (RENDERDOC_VERSION_MINOR << 16); DWORD VersionMajor = RENDERDOC_VERSION_MAJOR; DWORD VersionMinor = RENDERDOC_VERSION_MINOR; - std::string DisplayVersion = MAJOR_MINOR_VERSION_STRING ".0"; + rdcstr DisplayVersion = MAJOR_MINOR_VERSION_STRING ".0"; RegSetValueExA(subkey, "Version", 0, REG_DWORD, (const BYTE *)&Version, sizeof(Version)); RegSetValueExA(subkey, "VersionMajor", 0, REG_DWORD, (const BYTE *)&VersionMajor, @@ -683,9 +683,9 @@ extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_UpdateInstalledVersionNumbe #endif } -static std::string ResourceFormatName(const ResourceFormat &fmt) +static rdcstr ResourceFormatName(const ResourceFormat &fmt) { - std::string ret; + rdcstr ret; if(fmt.Special()) { @@ -861,7 +861,7 @@ extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_ResourceFormatName(const Re name = ResourceFormatName(fmt); } -static void TestPrintMsg(const std::string &msg) +static void TestPrintMsg(const rdcstr &msg) { OSUtility::WriteOutput(OSUtility::Output_DebugMon, msg.c_str()); OSUtility::WriteOutput(OSUtility::Output_StdErr, msg.c_str()); @@ -873,17 +873,17 @@ extern "C" RENDERDOC_API int RENDERDOC_CC RENDERDOC_RunFunctionalTests(int pytho #if ENABLED(RDOC_WIN32) const char *moduledir = "/pymodules"; const char *modulename = "renderdoc.pyd"; - std::string pythonlibs[] = {"python3?.dll"}; + rdcstr pythonlibs[] = {"python3?.dll"}; #elif ENABLED(RDOC_LINUX) const char *moduledir = ""; const char *modulename = "renderdoc.so"; // we don't care about pymalloc or not - std::string pythonlibs[] = {"libpython3.?m.so.1.0", "libpython3.?.so.1.0", "libpython3.?m.so", - "libpython3.?.so"}; + rdcstr pythonlibs[] = {"libpython3.?m.so.1.0", "libpython3.?.so.1.0", "libpython3.?m.so", + "libpython3.?.so"}; #else const char *moduledir = ""; const char *modulename = ""; - std::string pythonlibs[] = {}; + rdcstr pythonlibs[] = {}; TestPrintMsg( "Running functional tests not directly supported on this platform.\n" "Try running util/test/run_tests.py manually.\n"); @@ -908,7 +908,7 @@ extern "C" RENDERDOC_API int RENDERDOC_CC RENDERDOC_RunFunctionalTests(int pytho // directories from the library will put us at the project root. This is the most common scenario // and we don't add handling for locating the script elsewhere as in that case the user can run it // directly. This is just intended as a useful shortcut for common cases. - std::string scriptPath = libPath + "/../../util/test/run_tests.py"; + rdcstr scriptPath = libPath + "/../../util/test/run_tests.py"; if(!FileIO::exists(scriptPath.c_str())) { @@ -918,7 +918,7 @@ extern "C" RENDERDOC_API int RENDERDOC_CC RENDERDOC_RunFunctionalTests(int pytho void *handle = NULL; - for(std::string py : pythonlibs) + for(rdcstr py : pythonlibs) { // patch up the python minor version char *ver = strchr(&py[0], '?'); diff --git a/renderdoc/replay/replay_controller.cpp b/renderdoc/replay/replay_controller.cpp index 3ba9c2330..362a6d0f9 100644 --- a/renderdoc/replay/replay_controller.cpp +++ b/renderdoc/replay/replay_controller.cpp @@ -148,13 +148,13 @@ rdcarray ReplayController::GetDisassemblyTargets() rdcarray ret; - std::vector targets = m_pDevice->GetDisassemblyTargets(); + rdcarray targets = m_pDevice->GetDisassemblyTargets(); ret.reserve(targets.size()); - for(const std::string &t : targets) + for(const rdcstr &t : targets) ret.push_back(t); - for(const std::string &t : m_GCNTargets) + for(const rdcstr &t : m_GCNTargets) ret.push_back(t); return ret; @@ -165,7 +165,7 @@ rdcstr ReplayController::DisassembleShader(ResourceId pipeline, const ShaderRefl { CHECK_REPLAY_THREAD(); - for(const std::string &t : m_GCNTargets) + for(const rdcstr &t : m_GCNTargets) if(t == target) return GCNISA::Disassemble(refl->encoding, refl->stage, refl->rawBytes, target); @@ -303,7 +303,7 @@ void ReplayController::AddFakeMarkers() if(ContainsMarker(draws)) return; - std::vector ret; + rdcarray ret; int depthpassID = 1; int copypassID = 1; @@ -711,7 +711,7 @@ bool ReplayController::SaveTexture(const TextureSave &saveData, const char *path // otherwise take all mips, as by default } - std::vector subdata; + rdcarray subdata; bool downcast = false; @@ -1480,9 +1480,9 @@ rdcarray ReplayController::PixelHistory(ResourceId target, ui if(id == ResourceId()) return ret; - std::vector usage = m_pDevice->GetUsage(id); + rdcarray usage = m_pDevice->GetUsage(id); - std::vector events; + rdcarray events; for(size_t i = 0; i < usage.size(); i++) { @@ -1594,7 +1594,7 @@ rdcarray ReplayController::GetHistogram(ResourceId textureId, const Su { CHECK_REPLAY_THREAD(); - std::vector hist; + rdcarray hist; m_pDevice->GetHistogram(m_pDevice->GetLiveID(textureId), sub, typeCast, minval, maxval, channels, hist); @@ -1694,7 +1694,7 @@ rdcstr ReplayController::CreateRGPProfile(WindowingData window) return ""; } - std::string path = FileIO::GetTempFolderFilename() + "/renderdoc_rgp_capture.rgp"; + rdcstr path = FileIO::GetTempFolderFilename() + "/renderdoc_rgp_capture.rgp"; ReplayOutput *output = CreateOutput(window, ReplayOutputType::Texture); @@ -1828,15 +1828,15 @@ void ReplayController::ShutdownOutput(IReplayOutput *output) { CHECK_REPLAY_THREAD(); - for(auto it = m_Outputs.begin(); it != m_Outputs.end(); ++it) - { - if((IReplayOutput *)*it == output) + m_Outputs.removeOneIf([output](const ReplayOutput *o) { + if((IReplayOutput *)o == output) { - delete *it; - m_Outputs.erase(it); - return; + delete o; + return true; } - } + + return false; + }); RDCERR("Unrecognised output"); } @@ -1876,7 +1876,7 @@ rdcpair ReplayController::BuildTargetShader( StringFormat::Fmt("Shader Encoding '%s' is not supported", ToStr(sourceEncoding).c_str())); ResourceId id; - std::string errs; + rdcstr errs; switch(type) { @@ -1889,7 +1889,7 @@ rdcpair ReplayController::BuildTargetShader( default: RDCERR("Unexpected type in BuildShader!"); return rdcpair(); } - m_pDevice->BuildTargetShader(sourceEncoding, source, entry, compileFlags, type, &id, &errs); + m_pDevice->BuildTargetShader(sourceEncoding, source, entry, compileFlags, type, id, errs); if(id != ResourceId()) m_TargetResources.insert(id); @@ -1904,7 +1904,7 @@ rdcpair ReplayController::BuildCustomShader( CHECK_REPLAY_THREAD(); ResourceId id; - std::string errs; + rdcstr errs; switch(type) { @@ -1919,7 +1919,7 @@ rdcpair ReplayController::BuildCustomShader( RDCLOG("Building custom shader"); - m_pDevice->BuildCustomShader(sourceEncoding, source, entry, compileFlags, type, &id, &errs); + m_pDevice->BuildCustomShader(sourceEncoding, source, entry, compileFlags, type, id, errs); if(id != ResourceId()) { @@ -2024,7 +2024,7 @@ ReplayStatus ReplayController::PostCreateInit(IReplayDriver *device, RDCFile *rd GCNISA::GetTargets(m_APIProps.pipelineType, m_GCNTargets); { - std::vector ids = m_pDevice->GetBuffers(); + rdcarray ids = m_pDevice->GetBuffers(); m_Buffers.resize(ids.size()); @@ -2033,7 +2033,7 @@ ReplayStatus ReplayController::PostCreateInit(IReplayDriver *device, RDCFile *rd } { - std::vector ids = m_pDevice->GetTextures(); + rdcarray ids = m_pDevice->GetTextures(); m_Textures.resize(ids.size()); diff --git a/renderdoc/replay/replay_controller.h b/renderdoc/replay/replay_controller.h index dc7e9a684..14db641b8 100644 --- a/renderdoc/replay/replay_controller.h +++ b/renderdoc/replay/replay_controller.h @@ -26,7 +26,6 @@ #pragma once #include -#include #include "api/replay/renderdoc_replay.h" #include "common/common.h" #include "core/core.h" @@ -100,7 +99,7 @@ private: ResourceId m_OverlayResourceId; ResourceId m_CustomShaderResourceId; - std::vector m_Thumbnails; + rdcarray m_Thumbnails; float m_ContextX; float m_ContextY; @@ -109,7 +108,7 @@ private: uint32_t m_EventID; ReplayOutputType m_Type; - std::vector passEvents; + rdcarray passEvents; int32_t m_Width; int32_t m_Height; @@ -228,7 +227,7 @@ private: IReplayDriver *GetDevice() { return m_pDevice; } FrameRecord m_FrameRecord; - std::vector m_Drawcalls; + rdcarray m_Drawcalls; uint64_t m_ThreadID; @@ -246,7 +245,7 @@ private: const VKPipe::State *m_VulkanPipelineState; PipeState m_PipeState; - std::vector m_Outputs; + rdcarray m_Outputs; rdcarray m_Resources; rdcarray m_Buffers; diff --git a/renderdoc/replay/replay_driver.cpp b/renderdoc/replay/replay_driver.cpp index 01725a49c..4d087f67f 100644 --- a/renderdoc/replay/replay_driver.cpp +++ b/renderdoc/replay/replay_driver.cpp @@ -58,7 +58,7 @@ static bool PreviousNextExcludedMarker(DrawcallDescription *draw) DrawFlags::APICalls)); } -static DrawcallDescription *SetupDrawcallPointers(std::vector &drawcallTable, +static DrawcallDescription *SetupDrawcallPointers(rdcarray &drawcallTable, rdcarray &draws, DrawcallDescription *parent, DrawcallDescription *&previous) @@ -117,7 +117,7 @@ static DrawcallDescription *SetupDrawcallPointers(std::vector &drawcallTable, +void SetupDrawcallPointers(rdcarray &drawcallTable, rdcarray &draws) { DrawcallDescription *previous = NULL; @@ -130,7 +130,7 @@ void SetupDrawcallPointers(std::vector &drawcallTable, // joining the 'real' linked list after one step. previous = NULL; - std::vector markers; + rdcarray markers; for(DrawcallDescription *draw : drawcallTable) { @@ -165,7 +165,7 @@ void SetupDrawcallPointers(std::vector &drawcallTable, } void PatchLineStripIndexBuffer(const DrawcallDescription *draw, uint8_t *idx8, uint16_t *idx16, - uint32_t *idx32, std::vector &patchedIndices) + uint32_t *idx32, rdcarray &patchedIndices) { const uint32_t restart = 0xffffffff; @@ -258,12 +258,12 @@ void PatchLineStripIndexBuffer(const DrawcallDescription *draw, uint8_t *idx8, u #undef IDX_VALUE } -void PatchTriangleFanRestartIndexBufer(std::vector &patchedIndices, uint32_t restartIndex) +void PatchTriangleFanRestartIndexBufer(rdcarray &patchedIndices, uint32_t restartIndex) { if(patchedIndices.empty()) return; - std::vector newIndices; + rdcarray newIndices; uint32_t firstIndex = patchedIndices[0]; @@ -427,7 +427,7 @@ static void StandardFillCBufferVariables(ResourceId shader, const rdcarray varmembers; + rdcarray varmembers; if(isArray) { @@ -509,10 +509,10 @@ static void StandardFillCBufferVariables(ResourceId shader, const rdcarray varmembers; + rdcarray varmembers; varmembers.resize(elems); - std::string base = outvars[outIdx].name; + rdcstr base = outvars[outIdx].name; for(uint32_t e = 0; e < elems; e++) { @@ -678,7 +678,7 @@ uint64_t inthash(ResourceId id, uint64_t seed) void HighlightCache::CacheHighlightingData(uint32_t eventId, const MeshDisplay &cfg) { - std::string ident; + rdcstr ident; uint64_t newKey = 5381; @@ -800,9 +800,9 @@ void HighlightCache::CacheHighlightingData(uint32_t eventId, const MeshDisplay & } bool HighlightCache::FetchHighlightPositions(const MeshDisplay &cfg, FloatVector &activeVertex, - std::vector &activePrim, - std::vector &adjacentPrimVertices, - std::vector &inactiveVertices) + rdcarray &activePrim, + rdcarray &adjacentPrimVertices, + rdcarray &inactiveVertices) { bool valid = true; diff --git a/renderdoc/replay/replay_driver.h b/renderdoc/replay/replay_driver.h index 7f6a84761..4ce268ab7 100644 --- a/renderdoc/replay/replay_driver.h +++ b/renderdoc/replay/replay_driver.h @@ -114,25 +114,25 @@ public: virtual APIProperties GetAPIProperties() = 0; - virtual const std::vector &GetResources() = 0; + virtual const rdcarray &GetResources() = 0; - virtual std::vector GetBuffers() = 0; + virtual rdcarray GetBuffers() = 0; virtual BufferDescription GetBuffer(ResourceId id) = 0; - virtual std::vector GetTextures() = 0; + virtual rdcarray GetTextures() = 0; virtual TextureDescription GetTexture(ResourceId id) = 0; - virtual std::vector GetDebugMessages() = 0; + virtual rdcarray GetDebugMessages() = 0; virtual rdcarray GetShaderEntryPoints(ResourceId shader) = 0; virtual ShaderReflection *GetShader(ResourceId pipeline, ResourceId shader, ShaderEntryPoint entry) = 0; - virtual std::vector GetDisassemblyTargets() = 0; - virtual std::string DisassembleShader(ResourceId pipeline, const ShaderReflection *refl, - const std::string &target) = 0; + virtual rdcarray GetDisassemblyTargets() = 0; + virtual rdcstr DisassembleShader(ResourceId pipeline, const ShaderReflection *refl, + const rdcstr &target) = 0; - virtual std::vector GetUsage(ResourceId id) = 0; + virtual rdcarray GetUsage(ResourceId id) = 0; virtual void SavePipelineState(uint32_t eventId) = 0; virtual const D3D11Pipe::State *GetD3D11PipelineState() = 0; @@ -146,10 +146,10 @@ public: virtual void ReplayLog(uint32_t endEventID, ReplayLogType replayType) = 0; virtual const SDFile &GetStructuredFile() = 0; - virtual std::vector GetPassEvents(uint32_t eventId) = 0; + virtual rdcarray GetPassEvents(uint32_t eventId) = 0; virtual void InitPostVSBuffers(uint32_t eventId) = 0; - virtual void InitPostVSBuffers(const std::vector &passEvents) = 0; + virtual void InitPostVSBuffers(const rdcarray &passEvents) = 0; virtual ResourceId GetLiveID(ResourceId id) = 0; @@ -160,9 +160,9 @@ public: virtual void GetTextureData(ResourceId tex, const Subresource &sub, const GetTextureDataParams ¶ms, bytebuf &data) = 0; - virtual void BuildTargetShader(ShaderEncoding sourceEncoding, bytebuf source, - const std::string &entry, const ShaderCompileFlags &compileFlags, - ShaderStage type, ResourceId *id, std::string *errors) = 0; + virtual void BuildTargetShader(ShaderEncoding sourceEncoding, const bytebuf &source, + const rdcstr &entry, const ShaderCompileFlags &compileFlags, + ShaderStage type, ResourceId &id, rdcstr &errors) = 0; virtual rdcarray GetTargetShaderEncodings() = 0; virtual void ReplaceResource(ResourceId from, ResourceId to) = 0; virtual void RemoveReplacement(ResourceId id) = 0; @@ -172,13 +172,13 @@ public: virtual CounterDescription DescribeCounter(GPUCounter counterID) = 0; virtual rdcarray FetchCounters(const rdcarray &counterID) = 0; - virtual void FillCBufferVariables(ResourceId pipeline, ResourceId shader, std::string entryPoint, + virtual void FillCBufferVariables(ResourceId pipeline, ResourceId shader, rdcstr entryPoint, uint32_t cbufSlot, rdcarray &outvars, const bytebuf &data) = 0; - virtual std::vector PixelHistory(std::vector events, - ResourceId target, uint32_t x, uint32_t y, - const Subresource &sub, CompType typeCast) = 0; + virtual rdcarray PixelHistory(rdcarray events, ResourceId target, + uint32_t x, uint32_t y, const Subresource &sub, + CompType typeCast) = 0; virtual ShaderDebugTrace DebugVertex(uint32_t eventId, uint32_t vertid, uint32_t instid, uint32_t idx, uint32_t instOffset, uint32_t vertOffset) = 0; virtual ShaderDebugTrace DebugPixel(uint32_t eventId, uint32_t x, uint32_t y, uint32_t sample, @@ -188,7 +188,7 @@ public: virtual ResourceId RenderOverlay(ResourceId texid, CompType typeCast, FloatVector clearCol, DebugOverlay overlay, uint32_t eventId, - const std::vector &passEvents) = 0; + const rdcarray &passEvents) = 0; virtual bool IsRenderOutput(ResourceId id) = 0; @@ -206,7 +206,7 @@ class IReplayDriver : public IRemoteDriver public: virtual bool IsRemoteProxy() = 0; - virtual std::vector GetSupportedWindowSystems() = 0; + virtual rdcarray GetSupportedWindowSystems() = 0; virtual AMDRGPControl *GetRGPControl() = 0; @@ -225,7 +225,7 @@ public: virtual bool GetMinMax(ResourceId texid, const Subresource &sub, CompType typeCast, float *minval, float *maxval) = 0; virtual bool GetHistogram(ResourceId texid, const Subresource &sub, CompType typeCast, float minval, - float maxval, bool channels[4], std::vector &histogram) = 0; + float maxval, bool channels[4], rdcarray &histogram) = 0; virtual void PickPixel(ResourceId texture, uint32_t x, uint32_t y, const Subresource &sub, CompType typeCast, float pixel[4]) = 0; @@ -237,13 +237,13 @@ public: virtual ResourceId CreateProxyBuffer(const BufferDescription &templateBuf) = 0; virtual void SetProxyBufferData(ResourceId bufid, byte *data, size_t dataSize) = 0; - virtual void RenderMesh(uint32_t eventId, const std::vector &secondaryDraws, + virtual void RenderMesh(uint32_t eventId, const rdcarray &secondaryDraws, const MeshDisplay &cfg) = 0; virtual bool RenderTexture(TextureDisplay cfg) = 0; - virtual void BuildCustomShader(ShaderEncoding sourceEncoding, bytebuf source, - const std::string &entry, const ShaderCompileFlags &compileFlags, - ShaderStage type, ResourceId *id, std::string *errors) = 0; + virtual void BuildCustomShader(ShaderEncoding sourceEncoding, const bytebuf &source, + const rdcstr &entry, const ShaderCompileFlags &compileFlags, + ShaderStage type, ResourceId &id, rdcstr &errors) = 0; virtual rdcarray GetCustomShaderEncodings() = 0; virtual ResourceId ApplyCustomShader(ResourceId shader, ResourceId texid, const Subresource &sub, CompType typeCast) = 0; @@ -276,15 +276,15 @@ struct IDeviceProtocolHandler : public IDeviceProtocolController }; // utility functions useful in any driver implementation -void SetupDrawcallPointers(std::vector &drawcallTable, +void SetupDrawcallPointers(rdcarray &drawcallTable, rdcarray &draws); // for hardware/APIs that can't do line rasterization, manually expand any triangle input topology // to a linestrip with strip restart indices. void PatchLineStripIndexBuffer(const DrawcallDescription *draw, uint8_t *idx8, uint16_t *idx16, - uint32_t *idx32, std::vector &patchedIndices); + uint32_t *idx32, rdcarray &patchedIndices); -void PatchTriangleFanRestartIndexBufer(std::vector &patchedIndices, uint32_t restartIndex); +void PatchTriangleFanRestartIndexBufer(rdcarray &patchedIndices, uint32_t restartIndex); uint64_t CalcMeshOutputSize(uint64_t curSize, uint64_t requiredOutput); @@ -306,14 +306,14 @@ struct HighlightCache bool idxData; bytebuf vertexData; - std::vector indices; + rdcarray indices; void CacheHighlightingData(uint32_t eventId, const MeshDisplay &cfg); bool FetchHighlightPositions(const MeshDisplay &cfg, FloatVector &activeVertex, - std::vector &activePrim, - std::vector &adjacentPrimVertices, - std::vector &inactiveVertices); + rdcarray &activePrim, + rdcarray &adjacentPrimVertices, + rdcarray &inactiveVertices); static FloatVector InterpretVertex(const byte *data, uint32_t vert, uint32_t vertexByteStride, const ResourceFormat &fmt, const byte *end, bool &valid); diff --git a/renderdoc/replay/replay_output.cpp b/renderdoc/replay/replay_output.cpp index 78ed4ae6f..3437a0990 100644 --- a/renderdoc/replay/replay_output.cpp +++ b/renderdoc/replay/replay_output.cpp @@ -787,7 +787,7 @@ void ReplayOutput::DisplayMesh() mesh.second.vertexResourceId = m_pDevice->GetLiveID(mesh.second.vertexResourceId); mesh.second.indexResourceId = m_pDevice->GetLiveID(mesh.second.indexResourceId); - std::vector secondaryDraws; + rdcarray secondaryDraws; // we choose a pallette here so that the colours stay consistent (i.e the // current draw is always the same colour), but also to indicate somewhat diff --git a/renderdoc/serialise/codecs/chrome_json_codec.cpp b/renderdoc/serialise/codecs/chrome_json_codec.cpp index e9691b7a7..733bc6acb 100644 --- a/renderdoc/serialise/codecs/chrome_json_codec.cpp +++ b/renderdoc/serialise/codecs/chrome_json_codec.cpp @@ -36,7 +36,7 @@ ReplayStatus exportChrome(const char *filename, const RDCFile &rdc, const SDFile if(!f) return ReplayStatus::FileIOFailed; - std::string str; + rdcstr str; // add header, customise this as needed. str = R"({ diff --git a/renderdoc/serialise/codecs/vk_cpp_codec_common.h b/renderdoc/serialise/codecs/vk_cpp_codec_common.h index c94a17359..2b681ca40 100644 --- a/renderdoc/serialise/codecs/vk_cpp_codec_common.h +++ b/renderdoc/serialise/codecs/vk_cpp_codec_common.h @@ -23,11 +23,7 @@ ******************************************************************************/ #pragma once -#include - -#include #include -#include #include "serialise/rdcfile.h" @@ -42,21 +38,21 @@ inline const char *Type(SDObject *ptr) // crawl through the entire SDObject list and patch every object ignoring Vulkan // specifics. - // Vulkan doesn't use std::string, so need to cast it to const char * + // Vulkan doesn't use string objects, so need to cast it to const char * if(ptr->IsString() || ptr->type.name == "string") return "const char* "; return ptr->type.name.c_str(); } -inline std::string ValueStr(SDObject *ptr) +inline rdcstr ValueStr(SDObject *ptr) { RDCASSERT(ptr->IsSimpleType()); - std::string result; + rdcstr result; if(ptr->IsBuffer()) { - std::string buf_name = ptr->AsString(); + rdcstr buf_name = ptr->AsString(); RDCASSERT(!buf_name.empty()); // A value for for a Buffer is it's $name.data(). result = buf_name + ".data()"; @@ -88,7 +84,7 @@ inline std::string ValueStr(SDObject *ptr) } else if(ptr->IsString()) { - std::string escaped; + rdcstr escaped; escaped.reserve(ptr->data.str.size()); for(char c : ptr->data.str) { @@ -122,7 +118,7 @@ inline std::string ValueStr(SDObject *ptr) break; } } - result = std::string("\"") + escaped + std::string("\""); + result = "\"" + escaped + "\""; } return result; } @@ -144,8 +140,8 @@ inline uint64_t CanonicalUnionBranch(SDObject *ptr) return 0; } -typedef std::vector SDObjectVec; -typedef SDObjectVec::iterator SDObjectVecIter; +typedef rdcarray SDObjectVec; +typedef SDObject *SDObjectVecIter; typedef std::map SDObjectIDMap; typedef SDObjectIDMap::iterator SDObjectIDMapIter; @@ -155,8 +151,8 @@ typedef std::map SDObjectVecIDMap; typedef SDObjectVecIDMap::iterator SDObjectVecIDMapIter; typedef std::pair SDObjectVecIDMapPair; -typedef std::vector SDChunkVec; -typedef SDChunkVec::iterator SDChunkVecIter; +typedef rdcarray SDChunkVec; +typedef SDChunk *SDChunkVecIter; typedef std::map SDChunkIDMap; typedef SDChunkIDMap::iterator SDChunkIDMapIter; diff --git a/renderdoc/serialise/codecs/xml_codec.cpp b/renderdoc/serialise/codecs/xml_codec.cpp index bc6bbeefc..679ef0e8e 100644 --- a/renderdoc/serialise/codecs/xml_codec.cpp +++ b/renderdoc/serialise/codecs/xml_codec.cpp @@ -27,6 +27,7 @@ #include "common/common.h" #include "common/formatting.h" #include "serialise/rdcfile.h" +#include "strings/string_utils.h" #include "3rdparty/miniz/miniz.h" #include "3rdparty/pugixml/pugixml.hpp" @@ -43,7 +44,7 @@ static const char *typeNames[] = { }; template -std::string GetBufferName(inttype i) +rdcstr GetBufferName(inttype i) { return StringFormat::Fmt("%06u", (uint32_t)i); } @@ -88,7 +89,7 @@ static constexpr byte FromHex(const char c) : (c >= 'a' && c <= 'f' ? byte(c - 'a') + 10 : 0)); } -static void HexEncode(const std::vector &in, std::string &out) +static void HexEncode(const bytebuf &in, rdcstr &out) { const size_t bytesPerLine = 32; const size_t bytesPerGroup = 4; @@ -105,7 +106,7 @@ static void HexEncode(const std::vector &in, std::string &out) out = "\n"; // accumulate ascii representation for each line - std::string ascii; + rdcstr ascii; size_t i = 0; for(byte c : in) @@ -151,7 +152,7 @@ static void HexEncode(const std::vector &in, std::string &out) } } -static void HexDecode(const char *str, const char *end, std::vector &out) +static void HexDecode(const char *str, const char *end, bytebuf &out) { out.reserve((end - str) / 2); @@ -372,7 +373,7 @@ static ReplayStatus Structured2XML(const char *filename, const RDCFile &file, ui pugi::xml_node type = xSection.append_child("type"); type.text() = (uint32_t)props.type; - std::vector contents; + bytebuf contents; contents.resize((size_t)reader->GetSize()); reader->Read(contents.data(), reader->GetSize()); @@ -386,7 +387,7 @@ static ReplayStatus Structured2XML(const char *filename, const RDCFile &file, ui else { // encode to simple hex. Not efficient, but easy. - std::string hexdata; + rdcstr hexdata; hexdata.reserve(contents.size() * 2); HexEncode(contents, hexdata); data.text().set(hexdata.c_str()); @@ -456,7 +457,7 @@ static SDObject *XML2Obj(pugi::xml_node &obj) SDObject *ret = new SDObject(obj.attribute("name").as_string(), obj.attribute("typename").as_string()); - std::string name = obj.name(); + rdcstr name = obj.name(); for(size_t i = 0; i < ARRAY_COUNT(typeNames); i++) { @@ -580,7 +581,7 @@ static ReplayStatus XML2Structured(const char *xml, const ThumbTypeAndData &thum } RDCDriver driver = (RDCDriver)xDriver.attribute("id").as_uint(); - std::string driverName = xDriver.text().as_string(); + rdcstr driverName = xDriver.text().as_string(); pugi::xml_node xIdent = xDriver.next_sibling(); @@ -697,7 +698,7 @@ static ReplayStatus XML2Structured(const char *xml, const ThumbTypeAndData &thum } else { - std::vector decoded; + bytebuf decoded; HexDecode(str, str + len, decoded); writer->Write(decoded.data(), decoded.size()); } @@ -787,12 +788,11 @@ static ReplayStatus XML2Structured(const char *xml, const ThumbTypeAndData &thum return ReplayStatus::Succeeded; } -static ReplayStatus Buffers2ZIP(const std::string &filename, const RDCFile &file, +static ReplayStatus Buffers2ZIP(const rdcstr &filename, const RDCFile &file, const StructuredBufferList &buffers, RENDERDOC_ProgressCallback progress) { - std::string zipFile = filename; - zipFile.erase(zipFile.size() - 4); // remove the .xml, leave only the .zip + rdcstr zipFile = strip_extension(filename); mz_zip_archive zip; memset(&zip, 0, sizeof(zip)); @@ -869,12 +869,10 @@ static ReplayStatus Buffers2ZIP(const std::string &filename, const RDCFile &file return ReplayStatus::Succeeded; } -static bool ZIP2Buffers(const std::string &filename, ThumbTypeAndData &thumb, - ThumbTypeAndData &extThumb, StructuredBufferList &buffers, - RENDERDOC_ProgressCallback progress) +static bool ZIP2Buffers(const rdcstr &filename, ThumbTypeAndData &thumb, ThumbTypeAndData &extThumb, + StructuredBufferList &buffers, RENDERDOC_ProgressCallback progress) { - std::string zipFile = filename; - zipFile.erase(zipFile.size() - 4); // remove the .xml, leave only the .zip + rdcstr zipFile = strip_extension(filename); if(!FileIO::exists(zipFile.c_str())) { diff --git a/renderdoc/serialise/rdcfile.cpp b/renderdoc/serialise/rdcfile.cpp index 23167b345..c1c953406 100644 --- a/renderdoc/serialise/rdcfile.cpp +++ b/renderdoc/serialise/rdcfile.cpp @@ -488,7 +488,7 @@ void RDCFile::Init(StreamReader &reader) if(reader.IsErrored() || reader.AtEnd()) RETURNERROR(ContainerError::Corrupt, "Invalid truncated ASCII data section"); - std::string name; + rdcstr name; c = 0; @@ -837,7 +837,7 @@ StreamWriter *RDCFile::WriteSection(const SectionProperties &props) StreamWriter *w = new StreamWriter(64 * 1024); w->AddCloseCallback([this, props, w]() { - m_MemorySections.push_back(std::vector(w->GetData(), w->GetData() + w->GetOffset())); + m_MemorySections.push_back(bytebuf(w->GetData(), (size_t)w->GetOffset())); m_Sections.push_back(props); m_Sections.back().compressedSize = m_Sections.back().uncompressedSize = @@ -877,7 +877,7 @@ StreamWriter *RDCFile::WriteSection(const SectionProperties &props) return new StreamWriter(StreamWriter::InvalidStream); } - std::string name = props.name; + rdcstr name = props.name; SectionType type = props.type; // normalise names for known sections @@ -928,16 +928,16 @@ StreamWriter *RDCFile::WriteSection(const SectionProperties &props) FILE *origFile = m_File; // save the sections - std::vector origSections = m_Sections; - std::vector origSectionLocations = m_SectionLocations; + rdcarray origSections = m_Sections; + rdcarray origSectionLocations = m_SectionLocations; SectionLocation oldCaptureLocation = m_SectionLocations[0]; // remove section 0, the frame capture, since it will be fixed up separately - origSections.erase(origSections.begin()); - origSectionLocations.erase(origSectionLocations.begin()); + origSections.erase(0); + origSectionLocations.erase(0); - std::string tempFilename = FileIO::GetTempFolderFilename() + "capture_rewrite.rdc"; + rdcstr tempFilename = FileIO::GetTempFolderFilename() + "capture_rewrite.rdc"; // create the file, this will overwrite m_File with the new file and file header using the // existing loaded metadata @@ -1018,15 +1018,15 @@ StreamWriter *RDCFile::WriteSection(const SectionProperties &props) RDCASSERT(index >= 0); - std::vector origSectionData; - std::vector origHeaderSizes; + rdcarray origSectionData; + rdcarray origHeaderSizes; uint64_t overwriteLocation = m_SectionLocations[index].headerOffset; uint64_t oldLength = m_SectionLocations[index].diskLength; // erase the target section. The others will be moved up to match - m_Sections.erase(m_Sections.begin() + index); - m_SectionLocations.erase(m_SectionLocations.begin() + index); + m_Sections.erase(index); + m_SectionLocations.erase(index); origSectionData.reserve(NumSections() - index); origHeaderSizes.reserve(NumSections() - index); @@ -1207,7 +1207,7 @@ StreamWriter *RDCFile::WriteSection(const SectionProperties &props) return compWriter ? compWriter : fileWriter; } -FILE *RDCFile::StealImageFileHandle(std::string &filename) +FILE *RDCFile::StealImageFileHandle(rdcstr &filename) { if(m_Driver != RDCDriver::Image) { diff --git a/renderdoc/serialise/rdcfile.h b/renderdoc/serialise/rdcfile.h index 147845827..0a8c1a7d8 100644 --- a/renderdoc/serialise/rdcfile.h +++ b/renderdoc/serialise/rdcfile.h @@ -84,9 +84,9 @@ public: void Create(const char *filename); ContainerError ErrorCode() const { return m_Error; } - std::string ErrorString() const { return m_ErrorString; } + rdcstr ErrorString() const { return m_ErrorString; } RDCDriver GetDriver() const { return m_Driver; } - const std::string &GetDriverName() const { return m_DriverName; } + const rdcstr &GetDriverName() const { return m_DriverName; } uint64_t GetMachineIdent() const { return m_MachineIdent; } const RDCThumb &GetThumbnail() const { return m_Thumb; } int SectionIndex(SectionType type) const; @@ -98,13 +98,13 @@ public: // Only valid if GetDriver returns RDCDriver::Image, passes over the underlying FILE * for use // loading the image directly, since the RDC container isn't there to read from a section. - FILE *StealImageFileHandle(std::string &filename); + FILE *StealImageFileHandle(rdcstr &filename); private: void Init(StreamReader &reader); FILE *m_File = NULL; - std::string m_Filename; + rdcstr m_Filename; bytebuf m_Buffer; SectionProperties m_CurrentWritingProps; @@ -112,12 +112,12 @@ private: uint32_t m_SerVer = 0; RDCDriver m_Driver = RDCDriver::Unknown; - std::string m_DriverName; + rdcstr m_DriverName; uint64_t m_MachineIdent = 0; RDCThumb m_Thumb; ContainerError m_Error = ContainerError::NoError; - std::string m_ErrorString; + rdcstr m_ErrorString; struct SectionLocation { @@ -126,7 +126,7 @@ private: uint64_t diskLength; }; - std::vector m_Sections; - std::vector m_SectionLocations; - std::vector> m_MemorySections; + rdcarray m_Sections; + rdcarray m_SectionLocations; + rdcarray m_MemorySections; }; diff --git a/renderdoc/serialise/serialiser.cpp b/renderdoc/serialise/serialiser.cpp index 10caa9c35..ba6da9ab1 100644 --- a/renderdoc/serialise/serialiser.cpp +++ b/renderdoc/serialise/serialiser.cpp @@ -38,7 +38,7 @@ void DumpObject(FileIO::LogFileHandle *log, const rdcstr &indent, SDObject *obj) { if(obj->NumChildren() > 0) { - std::string msg = + rdcstr msg = StringFormat::Fmt("%s%s%s %s:\n", indent.c_str(), obj->type.name.c_str(), obj->type.basetype == SDBasic::Array ? "[]" : "", obj->name.c_str()); FileIO::logfile_append(log, msg.c_str(), msg.size()); @@ -67,16 +67,16 @@ void DumpObject(FileIO::LogFileHandle *log, const rdcstr &indent, SDObject *obj) case SDBasic::Character: val = ToStr(obj->data.basic.c); break; case SDBasic::Resource: val = ToStr(obj->data.basic.id); break; } - std::string msg = StringFormat::Fmt("%s%s %s = %s\n", indent.c_str(), obj->type.name.c_str(), - obj->name.c_str(), val.c_str()); + rdcstr msg = StringFormat::Fmt("%s%s %s = %s\n", indent.c_str(), obj->type.name.c_str(), + obj->name.c_str(), val.c_str()); FileIO::logfile_append(log, msg.c_str(), msg.size()); } } void DumpChunk(bool reading, FileIO::LogFileHandle *log, SDChunk *chunk) { - std::string msg = StringFormat::Fmt("%s %s @ %llu:\n", reading ? "Read" : "Wrote", - chunk->name.c_str(), chunk->metadata.timestampMicro); + rdcstr msg = StringFormat::Fmt("%s %s @ %llu:\n", reading ? "Read" : "Wrote", chunk->name.c_str(), + chunk->metadata.timestampMicro); FileIO::logfile_append(log, msg.c_str(), msg.size()); DumpObject(log, " ", chunk); } @@ -173,7 +173,7 @@ uint32_t Serialiser::BeginChunk(uint32_t, uint64_t) if(ExportStructure()) { - std::string name = m_ChunkLookup ? m_ChunkLookup(chunkID) : ""; + rdcstr name = m_ChunkLookup ? m_ChunkLookup(chunkID) : ""; if(name.empty()) name = ""; @@ -435,7 +435,7 @@ uint32_t Serialiser::BeginChunk(uint32_t chunkID, uint6 if(ExportStructure()) { - std::string name = m_ChunkLookup ? m_ChunkLookup(chunkID) : ""; + rdcstr name = m_ChunkLookup ? m_ChunkLookup(chunkID) : ""; if(name.empty()) name = ""; diff --git a/renderdoc/serialise/serialiser.h b/renderdoc/serialise/serialiser.h index f4fa9aa71..6bbe5d185 100644 --- a/renderdoc/serialise/serialiser.h +++ b/renderdoc/serialise/serialiser.h @@ -26,8 +26,6 @@ #include #include -#include -#include #include "api/replay/structured_data.h" #include "common/formatting.h" #include "streamio.h" @@ -52,7 +50,7 @@ void Deserialise(const T &el) template void DoSerialise(Serialiser &, type &); \ template void DoSerialise(Serialiser &, type &); -typedef std::string (*ChunkLookup)(uint32_t chunkType); +typedef rdcstr (*ChunkLookup)(uint32_t chunkType); enum class SerialiserFlags { @@ -136,7 +134,7 @@ public: static uint64_t GetChunkAlignment() { return ChunkAlignment; } void *GetUserData() { return m_pUserData; } void SetUserData(void *userData) { m_pUserData = userData; } - void SetStringDatabase(std::set *db) { m_ExtStringDB = db; } + void SetStringDatabase(std::set *db) { m_ExtStringDB = db; } // jumps to the byte after the current chunk, can be called any time after BeginChunk void SkipCurrentChunk(); @@ -173,7 +171,7 @@ public: uint32_t BeginChunk(uint32_t chunkID, uint64_t byteLength); void EndChunk(); - std::string GetCurChunkName() + rdcstr GetCurChunkName() { if(m_ChunkLookup) return m_ChunkLookup(m_ChunkMetadata.chunkID); @@ -641,7 +639,7 @@ public: Serialiser &Serialise(const rdcliteral &name, char (&el)[N], SerialiserFlags flags = SerialiserFlags::NoFlags) { - std::string str; + rdcstr str; if(IsWriting()) str = el; Serialise(name, str, flags); @@ -1141,7 +1139,7 @@ public: return SerialiseNullable(name, (T *&)el, flags); } - Serialiser &SerialiseStream(const std::string &name, StreamReader &stream, + Serialiser &SerialiseStream(const rdcstr &name, StreamReader &stream, RENDERDOC_ProgressCallback progress = RENDERDOC_ProgressCallback()) { RDCCOMPILE_ASSERT(IsWriting(), "Can't read into a StreamReader"); @@ -1162,7 +1160,7 @@ public: return *this; } - Serialiser &SerialiseStream(const std::string &name, StreamWriter &stream, + Serialiser &SerialiseStream(const rdcstr &name, StreamWriter &stream, RENDERDOC_ProgressCallback progress) { RDCCOMPILE_ASSERT(IsReading(), "Can't write from a StreamWriter"); @@ -1453,7 +1451,7 @@ public: } else { - std::string str; + rdcstr str; str.resize(len); if(len > 0) m_Read->Read(&str[0], len); @@ -1564,19 +1562,19 @@ private: bool m_InternalElement = false; SDFile m_StructData; SDFile *m_StructuredFile = &m_StructData; - std::vector m_StructureStack; + rdcarray m_StructureStack; uint32_t m_ChunkFlags = 0; SDChunkMetaData m_ChunkMetadata; // a database of strings read from the file, useful when serialised structures // expect a char* to return and point to static memory - std::set m_StringDB; + std::set m_StringDB; // external storage - so the string storage can persist after the lifetime of the serialiser - std::set *m_ExtStringDB = NULL; + std::set *m_ExtStringDB = NULL; - const char *StringDB(const std::string &s) + const char *StringDB(const rdcstr &s) { if(m_ExtStringDB) { diff --git a/renderdoc/serialise/serialiser_tests.cpp b/renderdoc/serialise/serialiser_tests.cpp index 453e32e18..7a14f3955 100644 --- a/renderdoc/serialise/serialiser_tests.cpp +++ b/renderdoc/serialise/serialiser_tests.cpp @@ -46,7 +46,7 @@ void WriteAllBasicTypes(WriteSerialiser &ser) double k = 11.11011011; float l = 12.12012012f; - std::string m = "mmmm"; + rdcstr m = "mmmm"; char n[5] = "nnnn"; const char *s = "ssss"; @@ -113,7 +113,7 @@ TEST_CASE("Read/write basic types", "[serialiser][structured]") double k; float l; - std::string m; + rdcstr m; char n[5]; const char *s; @@ -159,8 +159,8 @@ TEST_CASE("Read/write basic types", "[serialiser][structured]") CHECK(l == 12.12012012f); CHECK(m == "mmmm"); - CHECK(std::string(n) == "nnnn"); - CHECK(std::string(s) == "ssss"); + CHECK(rdcstr(n) == "nnnn"); + CHECK(rdcstr(s) == "ssss"); CHECK(t[0] == 20); CHECK(t[1] == 20); @@ -187,7 +187,7 @@ TEST_CASE("Read/write via structured of basic types", "[serialiser]") { ReadSerialiser ser(new StreamReader(buf->GetData(), buf->GetOffset()), Ownership::Stream); - ChunkLookup testChunkLoop = [](uint32_t) -> std::string { return "TestChunk"; }; + ChunkLookup testChunkLoop = [](uint32_t) -> rdcstr { return "TestChunk"; }; ser.ConfigureStructuredExport(testChunkLoop, true); @@ -207,7 +207,7 @@ TEST_CASE("Read/write via structured of basic types", "[serialiser]") double k; float l; - std::string m; + rdcstr m; char n[5]; const char *s; @@ -532,7 +532,7 @@ TEST_CASE("Read/write chunk metadata", "[serialiser]") { ReadSerialiser ser(new StreamReader(buf->GetData(), buf->GetOffset()), Ownership::Stream); - ChunkLookup testChunkLoop = [](uint32_t) -> std::string { return "TestChunk"; }; + ChunkLookup testChunkLoop = [](uint32_t) -> rdcstr { return "TestChunk"; }; ser.ConfigureStructuredExport(testChunkLoop, true); @@ -575,7 +575,7 @@ TEST_CASE("Verify multiple chunks can be merged", "[serialiser][chunks]") }; // write some chunks individually - std::vector chunks; + rdcarray chunks; { WriteSerialiser ser(new StreamWriter(StreamWriter::DefaultScratchSize), Ownership::Stream); @@ -595,7 +595,7 @@ TEST_CASE("Verify multiple chunks can be merged", "[serialiser][chunks]") { SCOPED_SERIALISE_CHUNK(STRING_AND_INT); - std::string s = "string in STRING_AND_INT"; + rdcstr s = "string in STRING_AND_INT"; int i = 4096; SERIALISE_ELEMENT(s); @@ -695,7 +695,7 @@ TEST_CASE("Verify multiple chunks can be merged", "[serialiser][chunks]") } case STRING_AND_INT: { - std::string s; + rdcstr s; int i = 0; SERIALISE_ELEMENT(s); @@ -732,8 +732,8 @@ TEST_CASE("Read/write container types", "[serialiser][structured]") { SCOPED_SERIALISE_CHUNK(5); - std::vector v; - rdcpair p; + rdcarray v; + rdcpair p; std::list l; v.push_back(1); @@ -769,8 +769,8 @@ TEST_CASE("Read/write container types", "[serialiser][structured]") CHECK(chunkID == 5); - std::vector v; - rdcpair p; + rdcarray v; + rdcpair p; std::list l; SERIALISE_ELEMENT(v); @@ -814,12 +814,12 @@ TEST_CASE("Read/write container types", "[serialiser][structured]") { ReadSerialiser ser(new StreamReader(buf->GetData(), buf->GetOffset()), Ownership::Stream); - ser.ConfigureStructuredExport([](uint32_t) -> std::string { return "TestChunk"; }, true); + ser.ConfigureStructuredExport([](uint32_t) -> rdcstr { return "TestChunk"; }, true); ser.ReadChunk(); { - std::vector v; - rdcpair p; + rdcarray v; + rdcpair p; std::list l; SERIALISE_ELEMENT(v); @@ -967,9 +967,9 @@ void DoSerialise(SerialiserType &ser, struct1 &el) struct struct2 { - std::string name; - std::vector floats; - std::vector viewports; + rdcstr name; + rdcarray floats; + rdcarray viewports; }; DECLARE_REFLECTION_STRUCT(struct2); @@ -1018,7 +1018,7 @@ TEST_CASE("Read/write complex types", "[serialiser][structured]") SERIALISE_ELEMENT(enumVal); - std::vector sparseStructArray; + rdcarray sparseStructArray; sparseStructArray.resize(10); @@ -1059,7 +1059,7 @@ TEST_CASE("Read/write complex types", "[serialiser][structured]") SERIALISE_ELEMENT(enumVal); - std::vector sparseStructArray; + rdcarray sparseStructArray; SERIALISE_ELEMENT(sparseStructArray); @@ -1119,7 +1119,7 @@ TEST_CASE("Read/write complex types", "[serialiser][structured]") { ReadSerialiser ser(new StreamReader(buf->GetData(), buf->GetOffset()), Ownership::Stream); - ser.ConfigureStructuredExport([](uint32_t) -> std::string { return "TestChunk"; }, true); + ser.ConfigureStructuredExport([](uint32_t) -> rdcstr { return "TestChunk"; }, true); ser.ReadChunk(); { @@ -1127,7 +1127,7 @@ TEST_CASE("Read/write complex types", "[serialiser][structured]") SERIALISE_ELEMENT(enumVal); - std::vector sparseStructArray; + rdcarray sparseStructArray; SERIALISE_ELEMENT(sparseStructArray); diff --git a/renderdoc/serialise/streamio.h b/renderdoc/serialise/streamio.h index 92f97957d..fde14d973 100644 --- a/renderdoc/serialise/streamio.h +++ b/renderdoc/serialise/streamio.h @@ -26,7 +26,6 @@ #include #include -#include #include "common/common.h" #include "os/os_specific.h" @@ -252,7 +251,7 @@ private: Ownership m_Ownership; // callbacks that will be invoked when this stream is being destroyed - std::vector m_Callbacks; + rdcarray m_Callbacks; }; class StreamWriter @@ -503,7 +502,7 @@ private: Ownership m_Ownership; // callbacks that will be invoked when this stream is being destroyed - std::vector m_Callbacks; + rdcarray m_Callbacks; }; void StreamTransfer(StreamWriter *writer, StreamReader *reader, RENDERDOC_ProgressCallback progress); diff --git a/renderdoc/serialise/streamio_tests.cpp b/renderdoc/serialise/streamio_tests.cpp index 6a0189152..f1940d6bf 100644 --- a/renderdoc/serialise/streamio_tests.cpp +++ b/renderdoc/serialise/streamio_tests.cpp @@ -170,9 +170,8 @@ TEST_CASE("Test stream I/O operations over the network", "[streamio][network]") // we have to do the send/receive on threads since it is blocking - std::vector receivedValues; - std::vector list = {1, 1, 2, 3, 5, 8, 13, 21, 34, - 55, 89, 144, 233, 377, 610, 987, 1597}; + rdcarray receivedValues; + rdcarray list = {1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597}; // Tracks the lifetime of each thread. volatile int32_t threadA = 0, threadB = 0; @@ -256,7 +255,7 @@ TEST_CASE("Test stream I/O operations over the network", "[streamio][network]") // keep reading indefinitely until we hit an error (i.e. socket disconnected) while(!reader.IsErrored()) { - receivedValues.insert(receivedValues.end(), tmp, tmp + ARRAY_COUNT(tmp)); + receivedValues.append(tmp, ARRAY_COUNT(tmp)); reader.Read(tmp); } diff --git a/renderdoc/strings/string_utils.cpp b/renderdoc/strings/string_utils.cpp index cb5f4b3c3..6863ce55a 100644 --- a/renderdoc/strings/string_utils.cpp +++ b/renderdoc/strings/string_utils.cpp @@ -160,8 +160,8 @@ void split(const rdcstr &in, rdcarray &out, const char sep) out.clear(); } - size_t begin = 0; - int end = in.find(sep); + int32_t begin = 0; + int32_t end = in.find(sep); while(end >= 0) { @@ -171,7 +171,7 @@ void split(const rdcstr &in, rdcarray &out, const char sep) end = in.find(sep, begin); } - if(begin < in.size() || (begin == in.size() && in.back() == sep)) + if(begin < in.count() || (begin == in.count() && in.back() == sep)) out.push_back(in.substr(begin)); }