From b850abdfa06aa819d29aa4467c96a25f60bbfa49 Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 6 Dec 2019 12:03:55 +0000 Subject: [PATCH] Remove std::vector/std::string use from D3D11 driver --- renderdoc/driver/d3d11/d3d11_common.cpp | 6 +- renderdoc/driver/d3d11/d3d11_common.h | 12 ++-- renderdoc/driver/d3d11/d3d11_context.cpp | 6 +- renderdoc/driver/d3d11/d3d11_context.h | 11 ++-- renderdoc/driver/d3d11/d3d11_context_wrap.cpp | 12 ++-- renderdoc/driver/d3d11/d3d11_debug.cpp | 32 +++++------ renderdoc/driver/d3d11/d3d11_debug.h | 3 +- renderdoc/driver/d3d11/d3d11_device.cpp | 15 +++-- renderdoc/driver/d3d11/d3d11_device.h | 14 ++--- renderdoc/driver/d3d11/d3d11_device3_wrap.cpp | 4 +- renderdoc/driver/d3d11/d3d11_device_wrap.cpp | 13 ++--- renderdoc/driver/d3d11/d3d11_manager.h | 2 +- renderdoc/driver/d3d11/d3d11_pixelhistory.cpp | 4 +- renderdoc/driver/d3d11/d3d11_postvs.cpp | 18 +++--- renderdoc/driver/d3d11/d3d11_renderstate.cpp | 2 +- renderdoc/driver/d3d11/d3d11_rendertext.cpp | 4 +- .../driver/d3d11/d3d11_rendertexture.cpp | 2 +- renderdoc/driver/d3d11/d3d11_replay.cpp | 18 +++--- renderdoc/driver/d3d11/d3d11_resources.cpp | 16 +++--- renderdoc/driver/d3d11/d3d11_resources.h | 14 ++--- renderdoc/driver/d3d11/d3d11_shader_cache.cpp | 18 +++--- renderdoc/driver/d3d11/d3d11_shader_cache.h | 6 +- renderdoc/driver/d3d11/d3d11_shaderdebug.cpp | 55 +++++++++---------- renderdoc/driver/d3d11/d3d11_video.cpp | 7 +-- 24 files changed, 143 insertions(+), 151 deletions(-) diff --git a/renderdoc/driver/d3d11/d3d11_common.cpp b/renderdoc/driver/d3d11/d3d11_common.cpp index a9dc43f8c..efdeb3bc5 100644 --- a/renderdoc/driver/d3d11/d3d11_common.cpp +++ b/renderdoc/driver/d3d11/d3d11_common.cpp @@ -32,7 +32,7 @@ WrappedID3D11Device *D3D11MarkerRegion::device; -D3D11MarkerRegion::D3D11MarkerRegion(const std::string &marker) +D3D11MarkerRegion::D3D11MarkerRegion(const rdcstr &marker) { D3D11MarkerRegion::Begin(marker); } @@ -42,7 +42,7 @@ D3D11MarkerRegion::~D3D11MarkerRegion() D3D11MarkerRegion::End(); } -void D3D11MarkerRegion::Set(const std::string &marker) +void D3D11MarkerRegion::Set(const rdcstr &marker) { if(device == NULL) return; @@ -53,7 +53,7 @@ void D3D11MarkerRegion::Set(const std::string &marker) annot->SetMarker(StringFormat::UTF82Wide(marker).c_str()); } -void D3D11MarkerRegion::Begin(const std::string &marker) +void D3D11MarkerRegion::Begin(const rdcstr &marker) { if(device == NULL) return; diff --git a/renderdoc/driver/d3d11/d3d11_common.h b/renderdoc/driver/d3d11/d3d11_common.h index 6999f780d..a020f7a34 100644 --- a/renderdoc/driver/d3d11/d3d11_common.h +++ b/renderdoc/driver/d3d11/d3d11_common.h @@ -39,10 +39,10 @@ struct D3D11RenderState; // replay only class for handling marker regions struct D3D11MarkerRegion { - D3D11MarkerRegion(const std::string &marker); + D3D11MarkerRegion(const rdcstr &marker); ~D3D11MarkerRegion(); - static void Set(const std::string &marker); - static void Begin(const std::string &marker); + static void Set(const rdcstr &marker); + static void Begin(const rdcstr &marker); static void End(); static WrappedID3D11Device *device; @@ -186,7 +186,7 @@ inline void SetDebugName(T *pObj, const char *name) } template -inline std::string GetDebugName(T *pObj) +inline rdcstr GetDebugName(T *pObj) { static const UINT DEBUG_NAME_SIZE = 1024; static wchar_t tmpBuf[DEBUG_NAME_SIZE] = {0}; // Used for both char and wchar_t @@ -197,7 +197,7 @@ inline std::string GetDebugName(T *pObj) HRESULT hr = pObj->GetPrivateData(WKPDID_D3DDebugObjectName, &size, (char *)tmpBuf); if(SUCCEEDED(hr)) { - return std::string((char *)tmpBuf, size); + return rdcstr((char *)tmpBuf, size); } // Try wchar_t @@ -211,7 +211,7 @@ inline std::string GetDebugName(T *pObj) } } - return std::string(); + return rdcstr(); } class RefCounter diff --git a/renderdoc/driver/d3d11/d3d11_context.cpp b/renderdoc/driver/d3d11/d3d11_context.cpp index d508f4a74..df5baf3f7 100644 --- a/renderdoc/driver/d3d11/d3d11_context.cpp +++ b/renderdoc/driver/d3d11/d3d11_context.cpp @@ -297,7 +297,7 @@ bool WrappedID3D11DeviceContext::Serialise_BeginCaptureFrame(SerialiserType &ser // used for a DrawAuto(). If the stream-out happens in frame we don't need to worry, // but if it references a buffer from before we need to have that counter available // on replay to 'fake' the DrawAuto() just as a Draw() with known values - std::vector HiddenStreamOutCounters; + rdcarray HiddenStreamOutCounters; if(ser.IsWriting()) { @@ -1250,9 +1250,9 @@ ReplayStatus WrappedID3D11DeviceContext::ReplayLog(CaptureState readType, uint32 // we don't have duplicate uses for(auto it = m_ResourceUses.begin(); it != m_ResourceUses.end(); ++it) { - std::vector &v = it->second; + rdcarray &v = it->second; std::sort(v.begin(), v.end()); - v.erase(std::unique(v.begin(), v.end()), v.end()); + v.erase(std::unique(v.begin(), v.end()) - v.begin(), ~0U); #if CHECK_UNUSED_INITIAL_STATES ResourceId resid = m_pDevice->GetResourceManager()->GetOriginalID(it->first); diff --git a/renderdoc/driver/d3d11/d3d11_context.h b/renderdoc/driver/d3d11/d3d11_context.h index 9e4cc87fb..558fb278b 100644 --- a/renderdoc/driver/d3d11/d3d11_context.h +++ b/renderdoc/driver/d3d11/d3d11_context.h @@ -25,7 +25,6 @@ #pragma once -#include #include #include "core/core.h" #include "d3d11_common.h" @@ -133,7 +132,7 @@ private: std::map m_StreamOutCounters; - std::map > m_ResourceUses; + std::map > m_ResourceUses; WrappedID3D11Device *m_pDevice; ID3D11DeviceContext *m_pRealContext; @@ -182,7 +181,7 @@ private: D3D11RenderState *m_DeferredSavedState; - std::vector m_CurEvents, m_Events; + rdcarray m_CurEvents, m_Events; bool m_AddedDrawcall; bool HasNonMarkerEvents(); @@ -201,7 +200,7 @@ private: uint32_t m_Col; rdcstr m_Name; }; - std::vector m_AnnotationQueue; + rdcarray m_AnnotationQueue; Threading::CriticalSection m_AnnotLock; SDFile *m_StructuredFile = NULL; @@ -216,7 +215,7 @@ private: DrawcallDescription m_ParentDrawcall; std::map m_CmdLists; - std::list m_DrawcallStack; + rdcarray m_DrawcallStack; D3D11ResourceManager *GetResourceManager(); static rdcstr GetChunkName(uint32_t idx); @@ -314,7 +313,7 @@ public: void SetFrameReader(StreamReader *reader) { m_FrameReader = reader; } void MarkResourceReferenced(ResourceId id, FrameRefType refType); - std::vector GetUsage(ResourceId id) { return m_ResourceUses[id]; } + rdcarray GetUsage(ResourceId id) { return m_ResourceUses[id]; } void ClearMaps(); uint32_t GetEventID() { return m_CurEventID; } diff --git a/renderdoc/driver/d3d11/d3d11_context_wrap.cpp b/renderdoc/driver/d3d11/d3d11_context_wrap.cpp index 77c033bc2..8826c5a80 100644 --- a/renderdoc/driver/d3d11/d3d11_context_wrap.cpp +++ b/renderdoc/driver/d3d11/d3d11_context_wrap.cpp @@ -248,7 +248,7 @@ void WrappedID3D11DeviceContext::DrainAnnotationQueue() return; } - std::vector annotations; + rdcarray annotations; annotations.swap(m_AnnotationQueue); m_AnnotLock.Unlock(); @@ -3755,7 +3755,7 @@ void WrappedID3D11DeviceContext::OMSetDepthStencilState(ID3D11DepthStencilState template void WrappedID3D11DeviceContext::Serialise_DebugMessages(SerialiserType &ser) { - std::vector DebugMessages; + rdcarray DebugMessages; m_EmptyCommandList = false; @@ -4203,7 +4203,7 @@ bool WrappedID3D11DeviceContext::Serialise_DrawIndexedInstancedIndirect(Serialis DrawcallDescription draw; - std::string name = "DrawIndexedInstancedIndirect(-, -)"; + rdcstr name = "DrawIndexedInstancedIndirect(-, -)"; if(pBufferForArgs) { @@ -4334,7 +4334,7 @@ bool WrappedID3D11DeviceContext::Serialise_DrawInstancedIndirect(SerialiserType DrawcallDescription draw; - std::string name = "DrawInstancedIndirect(-, -)"; + rdcstr name = "DrawInstancedIndirect(-, -)"; if(pBufferForArgs) { @@ -5046,7 +5046,7 @@ bool WrappedID3D11DeviceContext::Serialise_DispatchIndirect(SerialiserType &ser, DrawcallDescription draw; - std::string name = "DispatchIndirect(-, -, -)"; + rdcstr name = "DispatchIndirect(-, -, -)"; if(pBufferForArgs) { struct DispatchArgs @@ -7724,7 +7724,7 @@ bool WrappedID3D11DeviceContext::Serialise_Unmap(SerialiserType &ser, ID3D11Reso { if(!record->VerifyShadowStorage(ctxMapID)) { - std::string msg = StringFormat::Fmt( + rdcstr msg = StringFormat::Fmt( "Overwrite of %llu byte Map()'d buffer detected\n" "Breakpoint now to see callstack,\nor click 'Yes' to debugbreak.", record->Length); diff --git a/renderdoc/driver/d3d11/d3d11_debug.cpp b/renderdoc/driver/d3d11/d3d11_debug.cpp index 096aa37bc..78f04bacb 100644 --- a/renderdoc/driver/d3d11/d3d11_debug.cpp +++ b/renderdoc/driver/d3d11/d3d11_debug.cpp @@ -135,8 +135,8 @@ void D3D11DebugManager::InitCommonResources() D3D11ShaderCache *shaderCache = m_pDevice->GetShaderCache(); D3D11ResourceManager *rm = m_pDevice->GetResourceManager(); - std::string multisamplehlsl = GetEmbeddedResource(multisample_hlsl); - std::string hlsl = GetEmbeddedResource(misc_hlsl); + rdcstr multisamplehlsl = GetEmbeddedResource(multisample_hlsl); + rdcstr hlsl = GetEmbeddedResource(misc_hlsl); if(m_pDevice->GetFeatureLevel() >= D3D_FEATURE_LEVEL_11_0) { @@ -205,7 +205,7 @@ void D3D11DebugManager::InitReplayResources() HRESULT hr = S_OK; { - std::string hlsl = GetEmbeddedResource(pixelhistory_hlsl); + rdcstr hlsl = GetEmbeddedResource(pixelhistory_hlsl); PixelHistoryUnusedCS = shaderCache->MakeCShader(hlsl.c_str(), "RENDERDOC_PixelHistoryUnused", "cs_5_0"); @@ -456,7 +456,7 @@ void D3D11Replay::GeneralMisc::Init(WrappedID3D11Device *device) RDCERR("Failed to create scissoring rasterizer state HRESULT: %s", ToStr(hr).c_str()); { - std::string hlsl = GetEmbeddedResource(misc_hlsl); + rdcstr hlsl = GetEmbeddedResource(misc_hlsl); FullscreenVS = shaderCache->MakeVShader(hlsl.c_str(), "RENDERDOC_FullscreenVS", "vs_4_0"); @@ -482,14 +482,14 @@ void D3D11Replay::TextureRendering::Init(WrappedID3D11Device *device) HRESULT hr = S_OK; { - std::string hlsl = GetEmbeddedResource(texdisplay_hlsl); + rdcstr hlsl = GetEmbeddedResource(texdisplay_hlsl); TexDisplayVS = shaderCache->MakeVShader(hlsl.c_str(), "RENDERDOC_TexDisplayVS", "vs_4_0"); TexDisplayPS = shaderCache->MakePShader(hlsl.c_str(), "RENDERDOC_TexDisplayPS", "ps_5_0"); } { - std::string hlsl = GetEmbeddedResource(texremap_hlsl); + rdcstr hlsl = GetEmbeddedResource(texremap_hlsl); TexRemapPS[0] = shaderCache->MakePShader(hlsl.c_str(), "RENDERDOC_TexRemapFloat", "ps_5_0"); TexRemapPS[1] = shaderCache->MakePShader(hlsl.c_str(), "RENDERDOC_TexRemapUInt", "ps_5_0"); @@ -564,7 +564,7 @@ void D3D11Replay::OverlayRendering::Init(WrappedID3D11Device *device) D3D11ShaderCache *shaderCache = device->GetShaderCache(); { - std::string hlsl = GetEmbeddedResource(misc_hlsl); + rdcstr hlsl = GetEmbeddedResource(misc_hlsl); FullscreenVS = shaderCache->MakeVShader(hlsl.c_str(), "RENDERDOC_FullscreenVS", "vs_4_0"); @@ -575,7 +575,7 @@ void D3D11Replay::OverlayRendering::Init(WrappedID3D11Device *device) } { - std::string meshhlsl = GetEmbeddedResource(mesh_hlsl); + rdcstr meshhlsl = GetEmbeddedResource(mesh_hlsl); TriangleSizeGS = shaderCache->MakeGShader(meshhlsl.c_str(), "RENDERDOC_TriangleSizeGS", "gs_4_0"); @@ -682,9 +682,9 @@ void D3D11Replay::MeshRendering::Init(WrappedID3D11Device *device) {"pos", 0, DXGI_FORMAT_R32G32B32A32_FLOAT}, {"sec", 0, DXGI_FORMAT_R8G8B8A8_UNORM}, }; - std::string meshhlsl = GetEmbeddedResource(mesh_hlsl); + rdcstr meshhlsl = GetEmbeddedResource(mesh_hlsl); - std::vector bytecode; + rdcarray bytecode; MeshVS = shaderCache->MakeVShader(meshhlsl.c_str(), "RENDERDOC_MeshVS", "vs_4_0", 2, inputDescSecondary, &GenericLayout, &bytecode); @@ -799,7 +799,7 @@ void D3D11Replay::VertexPicking::Init(WrappedID3D11Device *device) HRESULT hr = S_OK; - std::string meshhlsl = GetEmbeddedResource(mesh_hlsl); + rdcstr meshhlsl = GetEmbeddedResource(mesh_hlsl); MeshPickCS = shaderCache->MakeCShader(meshhlsl.c_str(), "RENDERDOC_MeshPickCS", "cs_5_0"); @@ -1031,7 +1031,7 @@ void D3D11Replay::HistogramMinMax::Init(WrappedID3D11Device *device) if(FAILED(hr)) RDCERR("Failed to create result UAV 2 HRESULT: %s", ToStr(hr).c_str()); - std::string histogramhlsl = GetEmbeddedResource(histogram_hlsl); + rdcstr histogramhlsl = GetEmbeddedResource(histogram_hlsl); for(int t = eTexType_1D; t < eTexType_Max; t++) { @@ -1041,9 +1041,9 @@ void D3D11Replay::HistogramMinMax::Init(WrappedID3D11Device *device) // float, uint, sint for(int i = 0; i < 3; i++) { - std::string hlsl = std::string("#define SHADER_RESTYPE ") + ToStr(t) + "\n"; - hlsl += std::string("#define UINT_TEX ") + (i == 1 ? "1" : "0") + "\n"; - hlsl += std::string("#define SINT_TEX ") + (i == 2 ? "1" : "0") + "\n"; + rdcstr hlsl = rdcstr("#define SHADER_RESTYPE ") + ToStr(t) + "\n"; + hlsl += rdcstr("#define UINT_TEX ") + (i == 1 ? "1" : "0") + "\n"; + hlsl += rdcstr("#define SINT_TEX ") + (i == 2 ? "1" : "0") + "\n"; hlsl += histogramhlsl; TileMinMaxCS[t][i] = @@ -1174,7 +1174,7 @@ void D3D11Replay::PixelHistory::Init(WrappedID3D11Device *device) } { - std::string hlsl = GetEmbeddedResource(pixelhistory_hlsl); + rdcstr hlsl = GetEmbeddedResource(pixelhistory_hlsl); PrimitiveIDPS = shaderCache->MakePShader(hlsl.c_str(), "RENDERDOC_PrimitiveIDPS", "ps_5_0"); } diff --git a/renderdoc/driver/d3d11/d3d11_debug.h b/renderdoc/driver/d3d11/d3d11_debug.h index 1cdc055fe..9d8f31494 100644 --- a/renderdoc/driver/d3d11/d3d11_debug.h +++ b/renderdoc/driver/d3d11/d3d11_debug.h @@ -25,7 +25,6 @@ #pragma once -#include #include #include "driver/dx/official/d3d11_4.h" #include "replay/replay_driver.h" @@ -176,7 +175,7 @@ private: static const int NUM_CACHED_SRVS = 64; static const uint32_t STAGE_BUFFER_BYTE_SIZE = 4 * 1024 * 1024; - std::list m_ShaderItemCache; + rdcarray m_ShaderItemCache; std::map m_CounterBufferToUAV; std::map m_UAVToCounterBuffer; diff --git a/renderdoc/driver/d3d11/d3d11_device.cpp b/renderdoc/driver/d3d11/d3d11_device.cpp index 7bea2a4c8..3c0014517 100644 --- a/renderdoc/driver/d3d11/d3d11_device.cpp +++ b/renderdoc/driver/d3d11/d3d11_device.cpp @@ -168,7 +168,7 @@ WrappedID3D11Device::WrappedID3D11Device(ID3D11Device *realDevice, D3D11InitPara m_InitParams.AdapterDesc = desc; GPUVendor vendor = GPUVendorFromPCIVendor(desc.VendorId); - std::string descString = GetDriverVersion(desc); + rdcstr descString = GetDriverVersion(desc); RDCLOG("New D3D11 device created: %s / %s", ToStr(vendor).c_str(), descString.c_str()); @@ -790,7 +790,7 @@ rdcstr WrappedID3D11Device::GetChunkName(uint32_t idx) } void WrappedID3D11Device::AddDebugMessage(MessageCategory c, MessageSeverity sv, MessageSource src, - std::string d) + rdcstr d) { // Only add runtime warnings while executing. // While reading, add the messages from the log, and while writing add messages @@ -815,9 +815,9 @@ void WrappedID3D11Device::AddDebugMessage(DebugMessage msg) m_DebugMessages.push_back(msg); } -std::vector WrappedID3D11Device::GetDebugMessages() +rdcarray WrappedID3D11Device::GetDebugMessages() { - std::vector ret; + rdcarray ret; if(IsActiveReplaying(m_State)) { @@ -902,7 +902,7 @@ std::vector WrappedID3D11Device::GetDebugMessages() } msg.messageID = (uint32_t)message->ID; - msg.description = std::string(message->pDescription); + msg.description = rdcstr(message->pDescription); ret.push_back(msg); @@ -1208,7 +1208,7 @@ ReplayStatus WrappedID3D11Device::ReadLogInitialisation(RDCFile *rdc, bool store if(!IsStructuredExporting(m_State)) { - std::vector savedDebugMessages; + rdcarray savedDebugMessages; // save any debug messages we built up savedDebugMessages.swap(m_DebugMessages); @@ -2247,8 +2247,7 @@ HRESULT WrappedID3D11Device::Present(IDXGISwapper *swapper, UINT SyncInterval, U m_TextRenderer->SetOutputWindow(swapper->GetHWND()); int flags = activeWindow ? RenderDoc::eOverlay_ActiveWindow : 0; - std::string overlayText = - RenderDoc::Inst().GetOverlayText(RDCDriver::D3D11, m_FrameCounter, flags); + rdcstr overlayText = RenderDoc::Inst().GetOverlayText(RDCDriver::D3D11, m_FrameCounter, flags); if(activeWindow && m_FailedFrame > 0) { diff --git a/renderdoc/driver/d3d11/d3d11_device.h b/renderdoc/driver/d3d11/d3d11_device.h index 992c43ddf..5c7f15477 100644 --- a/renderdoc/driver/d3d11/d3d11_device.h +++ b/renderdoc/driver/d3d11/d3d11_device.h @@ -367,7 +367,7 @@ private: void CachedObjectsGarbageCollect(); std::set m_DeferredContexts; - std::map > m_LayoutDescs; + std::map > m_LayoutDescs; std::map m_LayoutShaders; static WrappedID3D11Device *m_pCurrentWrappedDevice; @@ -384,9 +384,9 @@ private: SDFile *m_StructuredFile = NULL; SDFile m_StoredStructuredData; - std::vector m_DebugMessages; + rdcarray m_DebugMessages; - std::vector m_CapturedFrames; + rdcarray m_CapturedFrames; rdcarray m_Drawcalls; public: @@ -446,10 +446,10 @@ public: SDFile &GetStructuredFile() { return *m_StructuredFile; } void FirstFrame(IDXGISwapper *swapper); - std::vector GetDebugMessages(); + rdcarray GetDebugMessages(); void AddDebugMessage(DebugMessage msg); - void AddDebugMessage(MessageCategory c, MessageSeverity sv, MessageSource src, std::string d); - const std::vector &GetLayoutDesc(ID3D11InputLayout *layout) + void AddDebugMessage(MessageCategory c, MessageSeverity sv, MessageSource src, rdcstr d); + const rdcarray &GetLayoutDesc(ID3D11InputLayout *layout) { return m_LayoutDescs[layout]; } @@ -607,7 +607,7 @@ public: } template - std::vector Serialise_CreateTextureData( + rdcarray Serialise_CreateTextureData( SerialiserType &ser, ID3D11Resource *tex, ResourceId id, const D3D11_SUBRESOURCE_DATA *data, UINT w, UINT h, UINT d, DXGI_FORMAT fmt, UINT mips, UINT arr, bool HasData); diff --git a/renderdoc/driver/d3d11/d3d11_device3_wrap.cpp b/renderdoc/driver/d3d11/d3d11_device3_wrap.cpp index 586f5bfbe..f8fa08d8f 100644 --- a/renderdoc/driver/d3d11/d3d11_device3_wrap.cpp +++ b/renderdoc/driver/d3d11/d3d11_device3_wrap.cpp @@ -51,7 +51,7 @@ bool WrappedID3D11Device::Serialise_CreateTexture2D1(SerialiserType &ser, SERIALISE_ELEMENT_LOCAL(pTexture, GetIDForResource(*ppTexture2D)) .TypedAs("ID3D11Texture2D *"_lit); - std::vector descs = + rdcarray descs = Serialise_CreateTextureData(ser, ppTexture2D ? *ppTexture2D : NULL, pTexture, pInitialData, Descriptor.Width, Descriptor.Height, 1, Descriptor.Format, Descriptor.MipLevels, Descriptor.ArraySize, pInitialData != NULL); @@ -191,7 +191,7 @@ bool WrappedID3D11Device::Serialise_CreateTexture3D1(SerialiserType &ser, SERIALISE_ELEMENT_LOCAL(pTexture, GetIDForResource(*ppTexture3D)) .TypedAs("ID3D11Texture3D *"_lit); - std::vector descs = + rdcarray descs = Serialise_CreateTextureData(ser, ppTexture3D ? *ppTexture3D : NULL, pTexture, pInitialData, Descriptor.Width, Descriptor.Height, Descriptor.Depth, Descriptor.Format, Descriptor.MipLevels, 1, pInitialData != NULL); diff --git a/renderdoc/driver/d3d11/d3d11_device_wrap.cpp b/renderdoc/driver/d3d11/d3d11_device_wrap.cpp index a1659692f..ece7a1b39 100644 --- a/renderdoc/driver/d3d11/d3d11_device_wrap.cpp +++ b/renderdoc/driver/d3d11/d3d11_device_wrap.cpp @@ -243,7 +243,7 @@ HRESULT WrappedID3D11Device::CreateBuffer(const D3D11_BUFFER_DESC *pDesc, } template -std::vector WrappedID3D11Device::Serialise_CreateTextureData( +rdcarray WrappedID3D11Device::Serialise_CreateTextureData( SerialiserType &ser, ID3D11Resource *tex, ResourceId id, const D3D11_SUBRESOURCE_DATA *data, UINT w, UINT h, UINT d, DXGI_FORMAT fmt, UINT mips, UINT arr, bool HasData) { @@ -255,7 +255,7 @@ std::vector WrappedID3D11Device::Serialise_CreateTexture numSubresources *= arr; - std::vector descs; + rdcarray descs; if(IsReplayingAndReading() && HasData) descs.resize(numSubresources); @@ -384,7 +384,7 @@ bool WrappedID3D11Device::Serialise_CreateTexture1D(SerialiserType &ser, SERIALISE_ELEMENT_LOCAL(pTexture, GetIDForResource(*ppTexture1D)) .TypedAs("ID3D11Texture1D *"_lit); - std::vector descs = Serialise_CreateTextureData( + rdcarray descs = Serialise_CreateTextureData( ser, ppTexture1D ? *ppTexture1D : NULL, pTexture, pInitialData, Descriptor.Width, 1, 1, Descriptor.Format, Descriptor.MipLevels, Descriptor.ArraySize, pInitialData != NULL); @@ -518,7 +518,7 @@ bool WrappedID3D11Device::Serialise_CreateTexture2D(SerialiserType &ser, SERIALISE_ELEMENT_LOCAL(pTexture, GetIDForResource(*ppTexture2D)) .TypedAs("ID3D11Texture2D *"_lit); - std::vector descs = + rdcarray descs = Serialise_CreateTextureData(ser, ppTexture2D ? *ppTexture2D : NULL, pTexture, pInitialData, Descriptor.Width, Descriptor.Height, 1, Descriptor.Format, Descriptor.MipLevels, Descriptor.ArraySize, pInitialData != NULL); @@ -652,7 +652,7 @@ bool WrappedID3D11Device::Serialise_CreateTexture3D(SerialiserType &ser, SERIALISE_ELEMENT_LOCAL(pTexture, GetIDForResource(*ppTexture3D)) .TypedAs("ID3D11Texture3D *"_lit); - std::vector descs = + rdcarray descs = Serialise_CreateTextureData(ser, ppTexture3D ? *ppTexture3D : NULL, pTexture, pInitialData, Descriptor.Width, Descriptor.Height, Descriptor.Depth, Descriptor.Format, Descriptor.MipLevels, 1, pInitialData != NULL); @@ -1340,8 +1340,7 @@ bool WrappedID3D11Device::Serialise_CreateInputLayout( AddResource(pInputLayout, ResourceType::StateObject, "Input Layout"); if(NumElements > 0) - m_LayoutDescs[ret] = std::vector(pInputElementDescs, - pInputElementDescs + NumElements); + m_LayoutDescs[ret] = rdcarray(pInputElementDescs, NumElements); if(BytecodeLength > 0 && pShaderBytecodeWithInputSignature) m_LayoutShaders[ret] = new WrappedShader(this, pInputLayout, GetIDForResource(ret), diff --git a/renderdoc/driver/d3d11/d3d11_manager.h b/renderdoc/driver/d3d11/d3d11_manager.h index b4670e9f6..74ceed3e6 100644 --- a/renderdoc/driver/d3d11/d3d11_manager.h +++ b/renderdoc/driver/d3d11/d3d11_manager.h @@ -234,7 +234,7 @@ private: ShadowPointerData ImmediateShadow; Threading::CriticalSection DeferredShadowLock; - std::vector DeferredShadow; + rdcarray DeferredShadow; }; struct D3D11InitialContents diff --git a/renderdoc/driver/d3d11/d3d11_pixelhistory.cpp b/renderdoc/driver/d3d11/d3d11_pixelhistory.cpp index 726168aa3..f8e457777 100644 --- a/renderdoc/driver/d3d11/d3d11_pixelhistory.cpp +++ b/renderdoc/driver/d3d11/d3d11_pixelhistory.cpp @@ -335,7 +335,7 @@ rdcarray D3D11Replay::PixelHistory(rdcarray event (uint32_t)events.size()); // these occlusion queries are run with every test possible disabled - std::vector occl; + rdcarray occl; occl.reserve(events.size()); ID3D11Query *testQueries[6] = {0}; // one query for each test we do per-drawcall @@ -656,7 +656,7 @@ rdcarray D3D11Replay::PixelHistory(rdcarray event // while issuing the above queries we can check to see which tests are enabled so we don't // bother checking if depth testing failed if the depth test was disabled - std::vector flags(events.size()); + rdcarray flags(events.size()); enum { TestEnabled_BackfaceCulling = 1 << 0, diff --git a/renderdoc/driver/d3d11/d3d11_postvs.cpp b/renderdoc/driver/d3d11/d3d11_postvs.cpp index 053c5fd0c..6dc69a4c3 100644 --- a/renderdoc/driver/d3d11/d3d11_postvs.cpp +++ b/renderdoc/driver/d3d11/d3d11_postvs.cpp @@ -245,7 +245,7 @@ void D3D11Replay::InitPostVSBuffers(uint32_t eventId) RDCASSERT(dxbcDS); } - std::vector sodecls; + rdcarray sodecls; UINT stride = 0; int posidx = -1; @@ -284,8 +284,8 @@ void D3D11Replay::InitPostVSBuffers(uint32_t eventId) if(posidx > 0) { D3D11_SO_DECLARATION_ENTRY pos = sodecls[posidx]; - sodecls.erase(sodecls.begin() + posidx); - sodecls.insert(sodecls.begin(), pos); + sodecls.erase(posidx); + sodecls.insert(0, pos); } HRESULT hr = m_pDevice->CreateGeometryShaderWithStreamOutput( @@ -357,7 +357,7 @@ void D3D11Replay::InitPostVSBuffers(uint32_t eventId) SAFE_RELEASE(idxBuf); - std::vector indices; + rdcarray indices; uint16_t *idx16 = (uint16_t *)&idxdata[0]; uint32_t *idx32 = (uint32_t *)&idxdata[0]; @@ -388,13 +388,13 @@ void D3D11Replay::InitPostVSBuffers(uint32_t eventId) if(it != indices.end() && *it == i32) continue; - indices.insert(it, i32); + indices.insert(it - indices.begin(), i32); } // if we read out of bounds, we'll also have a 0 index being referenced // (as 0 is read). Don't insert 0 if we already have 0 though if(numIndices < drawcall->numIndices && (indices.empty() || indices[0] != 0)) - indices.insert(indices.begin(), 0); + indices.insert(0, 0); // An index buffer could be something like: 500, 501, 502, 501, 503, 502 // in which case we can't use the existing index buffer without filling 499 slots of vertex @@ -700,8 +700,8 @@ void D3D11Replay::InitPostVSBuffers(uint32_t eventId) if(posidx > 0) { D3D11_SO_DECLARATION_ENTRY pos = sodecls[posidx]; - sodecls.erase(sodecls.begin() + posidx); - sodecls.insert(sodecls.begin(), pos); + sodecls.erase(posidx); + sodecls.insert(0, pos); } streamoutGS = NULL; @@ -845,7 +845,7 @@ void D3D11Replay::InitPostVSBuffers(uint32_t eventId) m_pImmediateContext->CopyResource(m_SOStagingBuffer, m_SOBuffer); - std::vector instData; + rdcarray instData; if((drawcall->flags & DrawFlags::Instanced) && drawcall->numInstances > 1) { diff --git a/renderdoc/driver/d3d11/d3d11_renderstate.cpp b/renderdoc/driver/d3d11/d3d11_renderstate.cpp index 188f290c9..a2ef42be5 100644 --- a/renderdoc/driver/d3d11/d3d11_renderstate.cpp +++ b/renderdoc/driver/d3d11/d3d11_renderstate.cpp @@ -1163,7 +1163,7 @@ bool D3D11RenderState::InputAssembler::Used_VB(WrappedID3D11Device *device, uint if(Layout == NULL) return false; - const std::vector &vec = device->GetLayoutDesc(Layout); + const rdcarray &vec = device->GetLayoutDesc(Layout); for(size_t i = 0; i < vec.size(); i++) if(vec[i].InputSlot == slot) diff --git a/renderdoc/driver/d3d11/d3d11_rendertext.cpp b/renderdoc/driver/d3d11/d3d11_rendertext.cpp index 525ab4327..fb140e5d6 100644 --- a/renderdoc/driver/d3d11/d3d11_rendertext.cpp +++ b/renderdoc/driver/d3d11/d3d11_rendertext.cpp @@ -107,7 +107,7 @@ D3D11TextRenderer::D3D11TextRenderer(WrappedID3D11Device *wrapper) desc.SampleDesc.Count = 1; desc.Usage = D3D11_USAGE_DEFAULT; - std::string font = GetEmbeddedResource(sourcecodepro_ttf); + rdcstr font = GetEmbeddedResource(sourcecodepro_ttf); byte *ttfdata = (byte *)font.c_str(); const int firstChar = int(' ') + 1; @@ -228,7 +228,7 @@ D3D11TextRenderer::D3D11TextRenderer(WrappedID3D11Device *wrapper) m_pDevice->InternalRef(); rm->SetInternalResource(CharBuffer); - std::string hlsl = GetEmbeddedResource(text_hlsl); + rdcstr hlsl = GetEmbeddedResource(text_hlsl); D3D11ShaderCache *shaderCache = wrapper->GetShaderCache(); diff --git a/renderdoc/driver/d3d11/d3d11_rendertexture.cpp b/renderdoc/driver/d3d11/d3d11_rendertexture.cpp index 198ed6ad1..5d33ec4ad 100644 --- a/renderdoc/driver/d3d11/d3d11_rendertexture.cpp +++ b/renderdoc/driver/d3d11/d3d11_rendertexture.cpp @@ -48,7 +48,7 @@ D3D11DebugManager::CacheElem &D3D11DebugManager::GetCachedElem(ResourceId id, Co m_ShaderItemCache.pop_back(); } - m_ShaderItemCache.push_front(CacheElem(id, typeCast, raw)); + m_ShaderItemCache.insert(0, CacheElem(id, typeCast, raw)); return m_ShaderItemCache.front(); } diff --git a/renderdoc/driver/d3d11/d3d11_replay.cpp b/renderdoc/driver/d3d11/d3d11_replay.cpp index 29f646169..5513468d1 100644 --- a/renderdoc/driver/d3d11/d3d11_replay.cpp +++ b/renderdoc/driver/d3d11/d3d11_replay.cpp @@ -111,7 +111,7 @@ void D3D11Replay::CreateResources(IDXGIFactory *factory) m_DriverInfo.vendor = GPUVendorFromPCIVendor(desc.VendorId); - std::string descString = GetDriverVersion(desc); + rdcstr descString = GetDriverVersion(desc); descString.resize(RDCMIN(descString.size(), ARRAY_COUNT(m_DriverInfo.version) - 1)); memcpy(m_DriverInfo.version, descString.c_str(), descString.size()); @@ -265,7 +265,7 @@ TextureDescription D3D11Replay::GetTexture(ResourceId id) { WrappedID3D11Texture1D *d3dtex = (WrappedID3D11Texture1D *)it1D->second.m_Texture; - std::string str = GetDebugName(d3dtex); + rdcstr str = GetDebugName(d3dtex); D3D11_TEXTURE1D_DESC desc; d3dtex->GetDesc(&desc); @@ -312,7 +312,7 @@ TextureDescription D3D11Replay::GetTexture(ResourceId id) { WrappedID3D11Texture2D1 *d3dtex = (WrappedID3D11Texture2D1 *)it2D->second.m_Texture; - std::string str = GetDebugName(d3dtex); + rdcstr str = GetDebugName(d3dtex); D3D11_TEXTURE2D_DESC desc; d3dtex->GetDesc(&desc); @@ -371,7 +371,7 @@ TextureDescription D3D11Replay::GetTexture(ResourceId id) { WrappedID3D11Texture3D1 *d3dtex = (WrappedID3D11Texture3D1 *)it3D->second.m_Texture; - std::string str = GetDebugName(d3dtex); + rdcstr str = GetDebugName(d3dtex); D3D11_TEXTURE3D_DESC desc; d3dtex->GetDesc(&desc); @@ -626,7 +626,7 @@ BufferDescription D3D11Replay::GetBuffer(ResourceId id) WrappedID3D11Buffer *d3dbuf = it->second.m_Buffer; - std::string str = GetDebugName(d3dbuf); + rdcstr str = GetDebugName(d3dbuf); ret.resourceId = m_pDevice->GetResourceManager()->GetOriginalID(it->first); @@ -705,7 +705,7 @@ void D3D11Replay::SavePipelineState(uint32_t eventId) if(rs->IA.Layout) { - const std::vector &vec = m_pDevice->GetLayoutDesc(rs->IA.Layout); + const rdcarray &vec = m_pDevice->GetLayoutDesc(rs->IA.Layout); ResourceId layoutId = GetIDForResource(rs->IA.Layout); @@ -2532,7 +2532,7 @@ void D3D11Replay::BuildShader(ShaderEncoding sourceEncoding, const bytebuf &sour return; } - std::string hlsl; + rdcstr hlsl; hlsl.assign((const char *)source.data(), source.size()); ID3DBlob *blob = NULL; @@ -3023,7 +3023,7 @@ uint32_t D3D11Replay::PickVertex(uint32_t eventId, int32_t width, int32_t height bytebuf idxs; GetBufferData(cfg.position.indexResourceId, cfg.position.indexByteOffset, 0, idxs); - std::vector outidxs; + rdcarray outidxs; outidxs.resize(cfg.position.numIndices); uint16_t *idxs16 = (uint16_t *)&idxs[0]; @@ -3137,7 +3137,7 @@ uint32_t D3D11Replay::PickVertex(uint32_t eventId, int32_t width, int32_t height } } - std::vector vbData; + rdcarray vbData; vbData.resize(maxIndex + 1); byte *data = &oldData[0]; diff --git a/renderdoc/driver/d3d11/d3d11_resources.cpp b/renderdoc/driver/d3d11/d3d11_resources.cpp index f5b7dbc2f..6f8226ef4 100644 --- a/renderdoc/driver/d3d11/d3d11_resources.cpp +++ b/renderdoc/driver/d3d11/d3d11_resources.cpp @@ -67,7 +67,7 @@ std::map std::map WrappedID3D11Buffer::m_BufferList; std::map WrappedShader::m_ShaderList; Threading::CriticalSection WrappedShader::m_ShaderListLock; -std::vector WrappedID3DDeviceContextState::m_List; +rdcarray WrappedID3DDeviceContextState::m_List; Threading::CriticalSection WrappedID3DDeviceContextState::m_Lock; const GUID RENDERDOC_ID3D11ShaderGUID_ShaderDebugMagicValue = RENDERDOC_ShaderDebugMagicValue_struct; @@ -76,7 +76,7 @@ void WrappedShader::ShaderEntry::TryReplaceOriginalByteCode() { if(!DXBC::DXBCContainer::CheckForDebugInfo((const void *)&m_Bytecode[0], m_Bytecode.size())) { - std::string originalPath = m_DebugInfoPath; + rdcstr originalPath = m_DebugInfoPath; if(originalPath.empty()) originalPath = @@ -97,7 +97,7 @@ void WrappedShader::ShaderEntry::TryReplaceOriginalByteCode() size_t numSearchPaths = m_DebugInfoSearchPaths ? m_DebugInfoSearchPaths->size() : 0; - std::string foundPath; + rdcstr foundPath; // while we haven't found a file, keep trying through the search paths. For i==0 // check the path on its own, in case it's an absolute path. @@ -111,7 +111,7 @@ void WrappedShader::ShaderEntry::TryReplaceOriginalByteCode() } else { - const std::string &searchPath = (*m_DebugInfoSearchPaths)[i - 1]; + const rdcstr &searchPath = (*m_DebugInfoSearchPaths)[i - 1]; foundPath = searchPath + "/" + originalPath; originalShaderFile = FileIO::fopen(foundPath.c_str(), "rb"); } @@ -126,7 +126,7 @@ void WrappedShader::ShaderEntry::TryReplaceOriginalByteCode() if(lz4 || originalShaderSize >= m_Bytecode.size()) { - std::vector originalBytecode; + rdcarray originalBytecode; originalBytecode.resize((size_t)originalShaderSize); FileIO::fread(&originalBytecode[0], sizeof(byte), (size_t)originalShaderSize, @@ -134,7 +134,7 @@ void WrappedShader::ShaderEntry::TryReplaceOriginalByteCode() if(lz4) { - std::vector decompressed; + rdcarray decompressed; // first try decompressing to 1MB flat decompressed.resize(100 * 1024); @@ -648,8 +648,6 @@ WrappedID3DDeviceContextState::~WrappedID3DDeviceContextState() { SCOPED_LOCK(WrappedID3DDeviceContextState::m_Lock); - auto it = std::find(WrappedID3DDeviceContextState::m_List.begin(), - WrappedID3DDeviceContextState::m_List.end(), this); - WrappedID3DDeviceContextState::m_List.erase(it); + WrappedID3DDeviceContextState::m_List.removeOne(this); } } diff --git a/renderdoc/driver/d3d11/d3d11_resources.h b/renderdoc/driver/d3d11/d3d11_resources.h index b1159f0d0..5db244845 100644 --- a/renderdoc/driver/d3d11/d3d11_resources.h +++ b/renderdoc/driver/d3d11/d3d11_resources.h @@ -293,7 +293,7 @@ public: const char *pStrData = (const char *)pData; if(DataSize != 0 && pStrData[DataSize - 1] != '\0') { - std::string sName(pStrData, DataSize); + rdcstr sName(pStrData, DataSize); m_pDevice->SetResourceName(this, sName.c_str()); } else @@ -305,7 +305,7 @@ public: { const wchar_t *pStrData = (const wchar_t *)pData; rdcwstr wName(pStrData, DataSize / 2); - std::string sName = StringFormat::Wide2UTF8(wName); + rdcstr sName = StringFormat::Wide2UTF8(wName); m_pDevice->SetResourceName(this, sName.c_str()); } @@ -909,7 +909,7 @@ public: ShaderEntry(WrappedID3D11Device *device, ResourceId id, const byte *code, size_t codeLen) { m_ID = id; - m_Bytecode.assign(code, code + codeLen); + m_Bytecode.assign(code, codeLen); m_DebugInfoSearchPaths = device->GetShaderDebugInfoSearchPaths(); m_DXBCFile = NULL; } @@ -919,7 +919,7 @@ public: SAFE_DELETE(m_DXBCFile); } - void SetDebugInfoPath(const std::string &path) { m_DebugInfoPath = path; } + void SetDebugInfoPath(const rdcstr &path) { m_DebugInfoPath = path; } DXBC::DXBCContainer *GetDXBC() { if(m_DXBCFile == NULL && !m_Bytecode.empty()) @@ -955,10 +955,10 @@ public: ResourceId m_ID; - std::string m_DebugInfoPath; + rdcstr m_DebugInfoPath; rdcarray *m_DebugInfoSearchPaths; - std::vector m_Bytecode; + rdcarray m_Bytecode; bool m_Built = false; DXBC::DXBCContainer *m_DXBCFile; @@ -1336,7 +1336,7 @@ class WrappedID3DDeviceContextState : public WrappedDeviceChild11 m_List; + static rdcarray m_List; static Threading::CriticalSection m_Lock; D3D11RenderState *state; diff --git a/renderdoc/driver/d3d11/d3d11_shader_cache.cpp b/renderdoc/driver/d3d11/d3d11_shader_cache.cpp index cf659b4c7..02b7d84d2 100644 --- a/renderdoc/driver/d3d11/d3d11_shader_cache.cpp +++ b/renderdoc/driver/d3d11/d3d11_shader_cache.cpp @@ -82,13 +82,13 @@ struct D3DBlobShaderCallbacks struct EmbeddedD3D11Includer : public ID3DInclude { - std::string texsample = GetEmbeddedResource(hlsl_texsample_h); - std::string cbuffers = GetEmbeddedResource(hlsl_cbuffers_h); + rdcstr texsample = GetEmbeddedResource(hlsl_texsample_h); + rdcstr cbuffers = GetEmbeddedResource(hlsl_cbuffers_h); virtual HRESULT STDMETHODCALLTYPE Open(D3D_INCLUDE_TYPE IncludeType, LPCSTR pFileName, LPCVOID pParentData, LPCVOID *ppData, UINT *pBytes) override { - std::string *str; + rdcstr *str; if(!strcmp(pFileName, "hlsl_texsample.h")) str = &texsample; @@ -132,9 +132,9 @@ D3D11ShaderCache::~D3D11ShaderCache() } } -std::string D3D11ShaderCache::GetShaderBlob(const char *source, const char *entry, - const uint32_t compileFlags, const char *profile, - ID3DBlob **srcblob) +rdcstr D3D11ShaderCache::GetShaderBlob(const char *source, const char *entry, + const uint32_t compileFlags, const char *profile, + ID3DBlob **srcblob) { EmbeddedD3D11Includer includer; @@ -176,13 +176,13 @@ std::string D3D11ShaderCache::GetShaderBlob(const char *source, const char *entr hr = compileFunc(source, strlen(source), entry, NULL, &includer, entry, profile, flags, 0, &byteBlob, &errBlob); - std::string errors = ""; + rdcstr errors = ""; if(errBlob) { errors = (char *)errBlob->GetBufferPointer(); - std::string logerror = errors; + rdcstr logerror = errors; if(logerror.length() > 1024) logerror = logerror.substr(0, 1024) + "..."; @@ -213,7 +213,7 @@ std::string D3D11ShaderCache::GetShaderBlob(const char *source, const char *entr ID3D11VertexShader *D3D11ShaderCache::MakeVShader(const char *source, const char *entry, const char *profile, int numInputDescs, D3D11_INPUT_ELEMENT_DESC *inputs, - ID3D11InputLayout **ret, std::vector *blob) + ID3D11InputLayout **ret, rdcarray *blob) { ID3DBlob *byteBlob = NULL; diff --git a/renderdoc/driver/d3d11/d3d11_shader_cache.h b/renderdoc/driver/d3d11/d3d11_shader_cache.h index 09a869e75..8c366e555 100644 --- a/renderdoc/driver/d3d11/d3d11_shader_cache.h +++ b/renderdoc/driver/d3d11/d3d11_shader_cache.h @@ -37,11 +37,11 @@ public: D3D11ShaderCache(WrappedID3D11Device *wrapper); ~D3D11ShaderCache(); - std::string GetShaderBlob(const char *source, const char *entry, const uint32_t compileFlags, - const char *profile, ID3DBlob **srcblob); + rdcstr GetShaderBlob(const char *source, const char *entry, const uint32_t compileFlags, + const char *profile, ID3DBlob **srcblob); ID3D11VertexShader *MakeVShader(const char *source, const char *entry, const char *profile, int numInputDescs = 0, D3D11_INPUT_ELEMENT_DESC *inputs = NULL, - ID3D11InputLayout **ret = NULL, std::vector *blob = NULL); + ID3D11InputLayout **ret = NULL, rdcarray *blob = NULL); ID3D11GeometryShader *MakeGShader(const char *source, const char *entry, const char *profile); ID3D11PixelShader *MakePShader(const char *source, const char *entry, const char *profile); ID3D11ComputeShader *MakeCShader(const char *source, const char *entry, const char *profile); diff --git a/renderdoc/driver/d3d11/d3d11_shaderdebug.cpp b/renderdoc/driver/d3d11/d3d11_shaderdebug.cpp index 7c45620c7..4336855c7 100644 --- a/renderdoc/driver/d3d11/d3d11_shaderdebug.cpp +++ b/renderdoc/driver/d3d11/d3d11_shaderdebug.cpp @@ -649,7 +649,7 @@ bool D3D11DebugAPIWrapper::CalculateSampleGather( { using namespace DXBCBytecode; - std::string funcRet = ""; + rdcstr funcRet = ""; DXGI_FORMAT retFmt = DXGI_FORMAT_UNKNOWN; if(opcode == OPCODE_SAMPLE_C || opcode == OPCODE_SAMPLE_C_LZ || opcode == OPCODE_GATHER4_C || @@ -659,13 +659,13 @@ bool D3D11DebugAPIWrapper::CalculateSampleGather( funcRet = "float4"; } - std::string samplerDecl = ""; + rdcstr samplerDecl = ""; if(samplerData.mode == SAMPLER_MODE_DEFAULT) samplerDecl = "SamplerState s"; else if(samplerData.mode == SAMPLER_MODE_COMPARISON) samplerDecl = "SamplerComparisonState s"; - std::string textureDecl = ""; + rdcstr textureDecl = ""; int texdim = 2; int offsetDim = 2; bool useOffsets = true; @@ -897,18 +897,18 @@ bool D3D11DebugAPIWrapper::CalculateSampleGather( StringFormat::snprintf(buf3, 255, formats[offsetDim + texdimOffs - 1][ddyType], ddyCalc.value.i.x, ddyCalc.value.i.y, ddyCalc.value.i.z, ddyCalc.value.i.w); - std::string texcoords = buf; - std::string ddx = buf2; - std::string ddy = buf3; + rdcstr texcoords = buf; + rdcstr ddx = buf2; + rdcstr ddy = buf3; if(opcode == OPCODE_LD_MS) { StringFormat::snprintf(buf, 255, formats[0][1], multisampleIndex); } - std::string sampleIdx = buf; + rdcstr sampleIdx = buf; - std::string offsets = ""; + rdcstr offsets = ""; if(useOffsets) { @@ -925,13 +925,13 @@ bool D3D11DebugAPIWrapper::CalculateSampleGather( } char elems[] = "xyzw"; - std::string strSwizzle = "."; + rdcstr strSwizzle = "."; for(int i = 0; i < 4; ++i) { strSwizzle += elems[swizzle[i]]; } - std::string strGatherChannel; + rdcstr strGatherChannel; switch(gatherChannel) { case ShaderDebug::GatherChannel::Red: strGatherChannel = "Red"; break; @@ -940,11 +940,11 @@ bool D3D11DebugAPIWrapper::CalculateSampleGather( case ShaderDebug::GatherChannel::Alpha: strGatherChannel = "Alpha"; break; } - std::string vsProgram = "float4 main(uint id : SV_VertexID) : SV_Position {\n"; + rdcstr vsProgram = "float4 main(uint id : SV_VertexID) : SV_Position {\n"; vsProgram += "return float4((id == 2) ? 3.0f : -1.0f, (id == 0) ? -3.0f : 1.0f, 0.5, 1.0);\n"; vsProgram += "}"; - std::string sampleProgram; + rdcstr sampleProgram; if(opcode == OPCODE_SAMPLE || opcode == OPCODE_SAMPLE_B || opcode == OPCODE_SAMPLE_D) { @@ -969,7 +969,7 @@ bool D3D11DebugAPIWrapper::CalculateSampleGather( // these operations need derivatives but have no hlsl function to call to provide them, so // we fake it in the vertex shader - std::string uvDim = "1"; + rdcstr uvDim = "1"; uvDim[0] += char(texdim + texdimOffs - 1); vsProgram = "void main(uint id : SV_VertexID, out float4 pos : SV_Position, out float" + uvDim + @@ -980,19 +980,19 @@ bool D3D11DebugAPIWrapper::CalculateSampleGather( uv.value.f.x + ddyCalc.value.f.x * 2.0f, uv.value.f.y + ddyCalc.value.f.y * 2.0f, uv.value.f.z + ddyCalc.value.f.z * 2.0f, uv.value.f.w + ddyCalc.value.f.w * 2.0f); - vsProgram += "if(id == 0) uv = " + std::string(buf) + ";\n"; + vsProgram += "if(id == 0) uv = " + rdcstr(buf) + ";\n"; StringFormat::snprintf(buf, 255, formats[texdim + texdimOffs - 1][texcoordType], uv.value.f.x, uv.value.f.y, uv.value.f.z, uv.value.f.w); - vsProgram += "if(id == 1) uv = " + std::string(buf) + ";\n"; + vsProgram += "if(id == 1) uv = " + rdcstr(buf) + ";\n"; StringFormat::snprintf( buf, 255, formats[texdim + texdimOffs - 1][texcoordType], uv.value.f.x + ddxCalc.value.f.x * 2.0f, uv.value.f.y + ddxCalc.value.f.y * 2.0f, uv.value.f.z + ddxCalc.value.f.z * 2.0f, uv.value.f.w + ddxCalc.value.f.w * 2.0f); - vsProgram += "if(id == 2) uv = " + std::string(buf) + ";\n"; + vsProgram += "if(id == 2) uv = " + rdcstr(buf) + ";\n"; vsProgram += "pos = float4((id == 2) ? 3.0f : -1.0f, (id == 0) ? -3.0f : 1.0f, 0.5, 1.0);\n"; vsProgram += "}"; @@ -1005,8 +1005,7 @@ bool D3D11DebugAPIWrapper::CalculateSampleGather( sampleProgram = textureDecl + " : register(t0);\n" + samplerDecl + " : register(s0);\n\n"; sampleProgram += funcRet + " main(float4 pos : SV_Position, float" + uvDim + " uv : uvs) : SV_Target0\n{\n"; - sampleProgram += - "return t.SampleCmpLevelZero(s, uv, " + std::string(buf) + offsets + ").xxxx;"; + sampleProgram += "return t.SampleCmpLevelZero(s, uv, " + rdcstr(buf) + offsets + ").xxxx;"; sampleProgram += "\n}\n"; } else if(opcode == OPCODE_LOD) @@ -1266,7 +1265,7 @@ bool D3D11DebugAPIWrapper::CalculateMathIntrinsic(DXBCBytecode::OpcodeType opcod const ShaderVariable &input, ShaderVariable &output1, ShaderVariable &output2) { - std::string csProgram = + rdcstr csProgram = "RWBuffer outval : register(u0);\n" "cbuffer srcOper : register(b0) { float4 inval; };\n" "[numthreads(1, 1, 1)]\n" @@ -1729,7 +1728,7 @@ ShaderDebugTrace D3D11Replay::DebugVertex(uint32_t eventId, uint32_t vertid, uin D3D11RenderState *rs = m_pImmediateContext->GetCurrentPipelineState(); - std::vector inputlayout = m_pDevice->GetLayoutDesc(rs->IA.Layout); + rdcarray inputlayout = m_pDevice->GetLayoutDesc(rs->IA.Layout); std::set vertexbuffers; uint32_t trackingOffs[32] = {0}; @@ -1812,11 +1811,11 @@ ShaderDebugTrace D3D11Replay::DebugVertex(uint32_t eventId, uint32_t vertid, uin { const D3D11_INPUT_ELEMENT_DESC *el = NULL; - std::string signame = strlower(dxbc->GetReflection()->InputSig[i].semanticName); + rdcstr signame = strlower(dxbc->GetReflection()->InputSig[i].semanticName); for(size_t l = 0; l < inputlayout.size(); l++) { - std::string layoutname = strlower(inputlayout[l].SemanticName); + rdcstr layoutname = strlower(inputlayout[l].SemanticName); if(signame == layoutname && dxbc->GetReflection()->InputSig[i].semanticIndex == inputlayout[l].SemanticIndex) @@ -2050,7 +2049,7 @@ ShaderDebugTrace D3D11Replay::DebugVertex(uint32_t eventId, uint32_t vertid, uin State last; - std::vector states; + rdcarray states; if(dxbc->GetDebugInfo()) dxbc->GetDebugInfo()->GetLocals(0, dxbc->GetDXBCByteCode()->GetInstruction(0).offset, @@ -2368,7 +2367,7 @@ void ExtractInputsPS(PSInput IN, float4 debug_pixelPos : SV_Position, uint prim keyMask |= (1 << (key.firstComponent + i)); // find the name of the variable matching the operand, in the case of merged input variables. - std::string name, swizzle = "xyzw"; + rdcstr name, swizzle = "xyzw"; for(size_t i = 0; i < dxbc->GetReflection()->InputSig.size(); i++) { if(dxbc->GetReflection()->InputSig[i].regIndex == (uint32_t)key.inputRegisterIndex && @@ -2396,7 +2395,7 @@ void ExtractInputsPS(PSInput IN, float4 debug_pixelPos : SV_Position, uint prim name = StringFormat::Fmt("IN.%s.%s", name.c_str(), swizzle.c_str()); // we must write all components, so just swizzle the values - they'll be ignored later. - std::string expandSwizzle = swizzle; + rdcstr expandSwizzle = swizzle; while(expandSwizzle.size() < 4) expandSwizzle.push_back('x'); @@ -2420,7 +2419,7 @@ void ExtractInputsPS(PSInput IN, float4 debug_pixelPos : SV_Position, uint prim for(size_t i = 0; i < floatInputs.size(); i++) { - const std::string &name = floatInputs[i]; + const rdcstr &name = floatInputs[i]; extractHlsl += " PSInitialBuffer[idx].INddx." + name + " = ddx(IN." + name + ");\n"; extractHlsl += " PSInitialBuffer[idx].INddy." + name + " = ddy(IN." + name + ");\n"; extractHlsl += " PSInitialBuffer[idx].INddxfine." + name + " = ddx_fine(IN." + name + ");\n"; @@ -2819,7 +2818,7 @@ void ExtractInputsPS(PSInput IN, float4 debug_pixelPos : SV_Position, uint prim SAFE_DELETE_ARRAY(initialData); SAFE_DELETE_ARRAY(evalData); - std::vector states; + rdcarray states; if(dxbc->GetDebugInfo()) dxbc->GetDebugInfo()->GetLocals(0, dxbc->GetDXBCByteCode()->GetInstruction(0).offset, @@ -3030,7 +3029,7 @@ ShaderDebugTrace D3D11Replay::DebugThread(uint32_t eventId, const uint32_t group initialState.semantics.ThreadID[i] = threadid[i]; } - std::vector states; + rdcarray states; if(dxbc->GetDebugInfo()) dxbc->GetDebugInfo()->GetLocals(0, dxbc->GetDXBCByteCode()->GetInstruction(0).offset, diff --git a/renderdoc/driver/d3d11/d3d11_video.cpp b/renderdoc/driver/d3d11/d3d11_video.cpp index 42c4b054b..4ed31134b 100644 --- a/renderdoc/driver/d3d11/d3d11_video.cpp +++ b/renderdoc/driver/d3d11/d3d11_video.cpp @@ -555,7 +555,7 @@ APP_DEPRECATED_HRESULT STDMETHODCALLTYPE WrappedID3D11VideoContext2::DecoderExte D3D11_VIDEO_DECODER_EXTENSION unwrappedExt = *pExtensionData; - std::vector unwrappedRes; + rdcarray unwrappedRes; unwrappedRes.resize(unwrappedExt.ResourceCount); for(UINT i = 0; i < unwrappedExt.ResourceCount; i++) @@ -943,8 +943,7 @@ HRESULT STDMETHODCALLTYPE WrappedID3D11VideoContext2::VideoProcessorBlt( /* [annotation] */ _In_ UINT OutputFrame, /* [annotation] */ _In_ UINT StreamCount, /* [annotation] */ _In_reads_(StreamCount) const D3D11_VIDEO_PROCESSOR_STREAM *pStreams) { - std::vector unwrappedStreams; - unwrappedStreams.insert(unwrappedStreams.begin(), pStreams, pStreams + StreamCount); + rdcarray unwrappedStreams(pStreams, StreamCount); size_t numFrames = 0; @@ -961,7 +960,7 @@ HRESULT STDMETHODCALLTYPE WrappedID3D11VideoContext2::VideoProcessorBlt( numFrames += stream.FutureFrames; } - std::vector inputViews; + rdcarray inputViews; inputViews.resize(numFrames);