From 37a255c8a4d8915cfed5dfec721e798084ebdef1 Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 6 Dec 2019 12:57:55 +0000 Subject: [PATCH] Remove std::vector/std::string use from D3D12 driver --- renderdoc/driver/d3d12/d3d12_command_list.h | 4 +- .../driver/d3d12/d3d12_command_list1_wrap.cpp | 18 ++-- .../driver/d3d12/d3d12_command_list4_wrap.cpp | 2 +- .../driver/d3d12/d3d12_command_list_wrap.cpp | 45 +++++---- renderdoc/driver/d3d12/d3d12_command_queue.h | 11 +-- .../driver/d3d12/d3d12_command_queue_wrap.cpp | 18 ++-- renderdoc/driver/d3d12/d3d12_commands.cpp | 25 ++--- renderdoc/driver/d3d12/d3d12_commands.h | 44 ++++----- renderdoc/driver/d3d12/d3d12_common.cpp | 38 ++++---- renderdoc/driver/d3d12/d3d12_common.h | 35 ++++--- renderdoc/driver/d3d12/d3d12_counters.cpp | 12 +-- renderdoc/driver/d3d12/d3d12_debug.cpp | 26 +++--- renderdoc/driver/d3d12/d3d12_debug.h | 2 +- renderdoc/driver/d3d12/d3d12_device.cpp | 92 +++++++------------ renderdoc/driver/d3d12/d3d12_device.h | 56 +++++------ renderdoc/driver/d3d12/d3d12_device_wrap.cpp | 27 +++--- renderdoc/driver/d3d12/d3d12_device_wrap4.cpp | 4 +- renderdoc/driver/d3d12/d3d12_initstate.cpp | 12 +-- renderdoc/driver/d3d12/d3d12_manager.cpp | 30 +++--- renderdoc/driver/d3d12/d3d12_manager.h | 16 ++-- renderdoc/driver/d3d12/d3d12_overlay.cpp | 8 +- renderdoc/driver/d3d12/d3d12_postvs.cpp | 18 ++-- renderdoc/driver/d3d12/d3d12_rendermesh.cpp | 2 +- renderdoc/driver/d3d12/d3d12_rendertext.cpp | 6 +- .../driver/d3d12/d3d12_rendertexture.cpp | 7 +- renderdoc/driver/d3d12/d3d12_replay.cpp | 44 ++++----- renderdoc/driver/d3d12/d3d12_resources.cpp | 10 +- renderdoc/driver/d3d12/d3d12_resources.h | 18 ++-- renderdoc/driver/d3d12/d3d12_serialise.cpp | 2 +- renderdoc/driver/d3d12/d3d12_shader_cache.cpp | 37 ++++---- renderdoc/driver/d3d12/d3d12_shader_cache.h | 6 +- renderdoc/driver/d3d12/d3d12_shaderdebug.cpp | 44 ++++----- renderdoc/driver/d3d12/d3d12_state.cpp | 12 +-- renderdoc/driver/d3d12/d3d12_state.h | 22 ++--- 34 files changed, 359 insertions(+), 394 deletions(-) diff --git a/renderdoc/driver/d3d12/d3d12_command_list.h b/renderdoc/driver/d3d12/d3d12_command_list.h index c0b080def..9c6618712 100644 --- a/renderdoc/driver/d3d12/d3d12_command_list.h +++ b/renderdoc/driver/d3d12/d3d12_command_list.h @@ -218,7 +218,7 @@ public: else if(guid == WKPDID_D3DDebugObjectNameW) { rdcwstr wName((const wchar_t *)pData, DataSize / 2); - std::string sName = StringFormat::Wide2UTF8(wName); + rdcstr sName = StringFormat::Wide2UTF8(wName); m_pDevice->SetName(this, sName.c_str()); } @@ -232,7 +232,7 @@ public: HRESULT STDMETHODCALLTYPE SetName(LPCWSTR Name) { - std::string utf8 = StringFormat::Wide2UTF8(Name); + rdcstr utf8 = StringFormat::Wide2UTF8(Name); m_pDevice->SetName(this, utf8.c_str()); return m_pList->SetName(Name); diff --git a/renderdoc/driver/d3d12/d3d12_command_list1_wrap.cpp b/renderdoc/driver/d3d12/d3d12_command_list1_wrap.cpp index 7b6cb0eb8..2d43c246e 100644 --- a/renderdoc/driver/d3d12/d3d12_command_list1_wrap.cpp +++ b/renderdoc/driver/d3d12/d3d12_command_list1_wrap.cpp @@ -57,7 +57,7 @@ bool WrappedID3D12GraphicsCommandList::Serialise_AtomicCopyBufferUINT( { if(m_Cmd->InRerecordRange(m_Cmd->m_LastCmdListID)) { - std::vector deps; + rdcarray deps; deps.resize(Dependencies); for(size_t i = 0; i < deps.size(); i++) deps[i] = Unwrap(ppDependentResources[i]); @@ -70,7 +70,7 @@ bool WrappedID3D12GraphicsCommandList::Serialise_AtomicCopyBufferUINT( } else { - std::vector deps; + rdcarray deps; deps.resize(Dependencies); for(size_t i = 0; i < deps.size(); i++) deps[i] = Unwrap(ppDependentResources[i]); @@ -175,7 +175,7 @@ bool WrappedID3D12GraphicsCommandList::Serialise_AtomicCopyBufferUINT64( { if(m_Cmd->InRerecordRange(m_Cmd->m_LastCmdListID)) { - std::vector deps; + rdcarray deps; deps.resize(Dependencies); for(size_t i = 0; i < deps.size(); i++) deps[i] = Unwrap(ppDependentResources[i]); @@ -188,7 +188,7 @@ bool WrappedID3D12GraphicsCommandList::Serialise_AtomicCopyBufferUINT64( } else { - std::vector deps; + rdcarray deps; deps.resize(Dependencies); for(size_t i = 0; i < deps.size(); i++) deps[i] = Unwrap(ppDependentResources[i]); @@ -362,12 +362,9 @@ bool WrappedID3D12GraphicsCommandList::Serialise_SetSamplePositions( { D3D12RenderState &state = m_Cmd->m_RenderState; - std::vector pos( - pSamplePositions, pSamplePositions + (NumSamplesPerPixel * NumPixels)); - state.samplePos.NumSamplesPerPixel = NumSamplesPerPixel; state.samplePos.NumPixels = NumPixels; - state.samplePos.Positions.swap(pos); + state.samplePos.Positions.assign(pSamplePositions, NumSamplesPerPixel * NumPixels); } } } @@ -379,12 +376,9 @@ bool WrappedID3D12GraphicsCommandList::Serialise_SetSamplePositions( { D3D12RenderState &state = m_Cmd->m_BakedCmdListInfo[m_Cmd->m_LastCmdListID].state; - std::vector pos(pSamplePositions, - pSamplePositions + (NumSamplesPerPixel * NumPixels)); - state.samplePos.NumSamplesPerPixel = NumSamplesPerPixel; state.samplePos.NumPixels = NumPixels; - state.samplePos.Positions.swap(pos); + state.samplePos.Positions.assign(pSamplePositions, NumSamplesPerPixel * NumPixels); } } } diff --git a/renderdoc/driver/d3d12/d3d12_command_list4_wrap.cpp b/renderdoc/driver/d3d12/d3d12_command_list4_wrap.cpp index e8cea78f4..8875a2898 100644 --- a/renderdoc/driver/d3d12/d3d12_command_list4_wrap.cpp +++ b/renderdoc/driver/d3d12/d3d12_command_list4_wrap.cpp @@ -40,7 +40,7 @@ bool WrappedID3D12GraphicsCommandList::Serialise_BeginRenderPass( // since CPU handles are consumed in the call, we need to read out and serialise the contents // here. - std::vector RTVs; + rdcarray RTVs; D3D12Descriptor DSV; { diff --git a/renderdoc/driver/d3d12/d3d12_command_list_wrap.cpp b/renderdoc/driver/d3d12/d3d12_command_list_wrap.cpp index c91bec939..3fddc7bf5 100644 --- a/renderdoc/driver/d3d12/d3d12_command_list_wrap.cpp +++ b/renderdoc/driver/d3d12/d3d12_command_list_wrap.cpp @@ -222,7 +222,7 @@ bool WrappedID3D12GraphicsCommandList::Serialise_Reset(SerialiserType &ser, // check for partial execution of this command list for(int p = 0; p < D3D12CommandData::ePartialNum; p++) { - const std::vector &baseEvents = m_Cmd->m_Partial[p].cmdListExecs[BakedCommandList]; + const rdcarray &baseEvents = m_Cmd->m_Partial[p].cmdListExecs[BakedCommandList]; for(auto it = baseEvents.begin(); it != baseEvents.end(); ++it) { @@ -462,7 +462,7 @@ bool WrappedID3D12GraphicsCommandList::Serialise_ResourceBarrier( { m_Cmd->m_LastCmdListID = GetResourceManager()->GetOriginalID(GetResID(pCommandList)); - std::vector filtered; + rdcarray filtered; { filtered.reserve(NumBarriers); @@ -593,8 +593,7 @@ void WrappedID3D12GraphicsCommandList::ResourceBarrier(UINT NumBarriers, m_ListRecord->AddChunk(scope.Get()); - m_ListRecord->cmdInfo->barriers.insert(m_ListRecord->cmdInfo->barriers.end(), pBarriers, - pBarriers + NumBarriers); + m_ListRecord->cmdInfo->barriers.append(pBarriers, NumBarriers); } } @@ -958,7 +957,7 @@ bool WrappedID3D12GraphicsCommandList::Serialise_SetDescriptorHeaps( { if(m_Cmd->InRerecordRange(m_Cmd->m_LastCmdListID)) { - std::vector heaps; + rdcarray heaps; heaps.resize(NumDescriptorHeaps); for(size_t i = 0; i < heaps.size(); i++) heaps[i] = Unwrap(ppDescriptorHeaps[i]); @@ -976,7 +975,7 @@ bool WrappedID3D12GraphicsCommandList::Serialise_SetDescriptorHeaps( } else { - std::vector heaps; + rdcarray heaps; heaps.resize(NumDescriptorHeaps); for(size_t i = 0; i < heaps.size(); i++) heaps[i] = Unwrap(ppDescriptorHeaps[i]); @@ -1336,7 +1335,7 @@ bool WrappedID3D12GraphicsCommandList::Serialise_OMSetRenderTargets( SERIALISE_ELEMENT(pCommandList); SERIALISE_ELEMENT(NumRenderTargetDescriptors); - std::vector RTVs; + rdcarray RTVs; if(ser.VersionAtLeast(0x5)) { @@ -1348,7 +1347,7 @@ bool WrappedID3D12GraphicsCommandList::Serialise_OMSetRenderTargets( { const D3D12Descriptor *descs = GetWrapped(pRenderTargetDescriptors[0]); - RTVs.insert(RTVs.begin(), descs, descs + NumRenderTargetDescriptors); + RTVs.assign(descs, NumRenderTargetDescriptors); } } else @@ -1383,7 +1382,7 @@ bool WrappedID3D12GraphicsCommandList::Serialise_OMSetRenderTargets( { const D3D12Descriptor *descs = GetWrapped(pRenderTargetDescriptors[0]); - RTVs.insert(RTVs.begin(), descs, descs + NumRenderTargetDescriptors); + RTVs.assign(descs, NumRenderTargetDescriptors); } } else @@ -1429,7 +1428,7 @@ bool WrappedID3D12GraphicsCommandList::Serialise_OMSetRenderTargets( { m_Cmd->m_LastCmdListID = GetResourceManager()->GetOriginalID(GetResID(pCommandList)); - std::vector unwrappedRTs; + rdcarray unwrappedRTs; unwrappedRTs.resize(RTVs.size()); for(size_t i = 0; i < RTVs.size(); i++) { @@ -1659,7 +1658,7 @@ void WrappedID3D12GraphicsCommandList::SetComputeRootDescriptorTable( m_ListRecord->MarkResourceFrameReferenced(GetWrapped(BaseDescriptor)->GetHeapResourceId(), eFrameRef_Read); - std::vector &ranges = + rdcarray &ranges = GetWrapped(m_CurCompRootSig)->sig.Parameters[RootParameterIndex].ranges; D3D12Descriptor *base = GetWrapped(BaseDescriptor); @@ -1688,7 +1687,7 @@ void WrappedID3D12GraphicsCommandList::SetComputeRootDescriptorTable( if(!RenderDoc::Inst().GetCaptureOptions().refAllResources) { - std::vector &descs = m_ListRecord->cmdInfo->boundDescs; + rdcarray &descs = m_ListRecord->cmdInfo->boundDescs; descs.reserve(descs.size() + num); for(UINT d = 0; d < num; d++) @@ -2223,7 +2222,7 @@ void WrappedID3D12GraphicsCommandList::SetGraphicsRootDescriptorTable( m_ListRecord->MarkResourceFrameReferenced(GetWrapped(BaseDescriptor)->GetHeapResourceId(), eFrameRef_Read); - std::vector &ranges = + rdcarray &ranges = GetWrapped(m_CurGfxRootSig)->sig.Parameters[RootParameterIndex].ranges; D3D12Descriptor *base = GetWrapped(BaseDescriptor); @@ -2252,7 +2251,7 @@ void WrappedID3D12GraphicsCommandList::SetGraphicsRootDescriptorTable( if(!RenderDoc::Inst().GetCaptureOptions().refAllResources) { - std::vector &descs = m_ListRecord->cmdInfo->boundDescs; + rdcarray &descs = m_ListRecord->cmdInfo->boundDescs; descs.reserve(descs.size() + num); for(UINT d = 0; d < num; d++) @@ -2848,7 +2847,7 @@ template bool WrappedID3D12GraphicsCommandList::Serialise_SetMarker(SerialiserType &ser, UINT Metadata, const void *pData, UINT Size) { - std::string MarkerText = ""; + rdcstr MarkerText = ""; if(ser.IsWriting() && pData && Size) MarkerText = DecodeMarkerString(Metadata, pData, Size); @@ -2911,7 +2910,7 @@ template bool WrappedID3D12GraphicsCommandList::Serialise_BeginEvent(SerialiserType &ser, UINT Metadata, const void *pData, UINT Size) { - std::string MarkerText = ""; + rdcstr MarkerText = ""; if(ser.IsWriting() && pData && Size) MarkerText = DecodeMarkerString(Metadata, pData, Size); @@ -3362,7 +3361,7 @@ void WrappedID3D12GraphicsCommandList::ExecuteBundle(ID3D12GraphicsCommandList * CmdListRecordingInfo *dst = m_ListRecord->cmdInfo; CmdListRecordingInfo *src = record->bakedCommands->cmdInfo; - dst->boundDescs.insert(dst->boundDescs.end(), src->boundDescs.begin(), src->boundDescs.end()); + dst->boundDescs.append(src->boundDescs); dst->dirtied.insert(src->dirtied.begin(), src->dirtied.end()); dst->bundles.push_back(record); @@ -3473,7 +3472,7 @@ void WrappedID3D12GraphicsCommandList::PatchExecuteIndirect(BakedCmdListInfo &in byte *mapPtr = NULL; exec.argBuf->Map(0, &range, (void **)&mapPtr); - std::vector &draws = info.draw->children; + rdcarray &draws = info.draw->children; size_t idx = 0; uint32_t eid = exec.baseEvent; @@ -3654,11 +3653,11 @@ void WrappedID3D12GraphicsCommandList::PatchExecuteIndirect(BakedCmdListInfo &in if(arg.Constant.RootParameterIndex < state.graphics.sigelems.size()) state.graphics.sigelems[arg.Constant.RootParameterIndex].constants.assign( - data32, data32 + arg.Constant.Num32BitValuesToSet); + data32, arg.Constant.Num32BitValuesToSet); if(arg.Constant.RootParameterIndex < state.compute.sigelems.size()) state.compute.sigelems[arg.Constant.RootParameterIndex].constants.assign( - data32, data32 + arg.Constant.Num32BitValuesToSet); + data32, arg.Constant.Num32BitValuesToSet); // advance only the EID, since we're still in the same draw eid++; @@ -3796,7 +3795,7 @@ void WrappedID3D12GraphicsCommandList::PatchExecuteIndirect(BakedCmdListInfo &in while(idx < draws.size() && draws[idx].draw.eventId < lastEID) { - draws.erase(draws.begin() + idx); + draws.erase(idx); shiftDrawID++; } @@ -3807,7 +3806,7 @@ void WrappedID3D12GraphicsCommandList::PatchExecuteIndirect(BakedCmdListInfo &in if(!multidraw && exec.maxCount > 1) { // remove pop event - draws.erase(draws.begin() + idx); + draws.erase(idx); info.ShiftForRemoved(1, 1, idx); } @@ -3869,7 +3868,7 @@ void WrappedID3D12GraphicsCommandList::ReplayExecuteIndirect(ID3D12GraphicsComma byte *dataPtr = &data[0]; - std::vector &sigelems = + rdcarray &sigelems = gfx ? m_Cmd->m_RenderState.graphics.sigelems : m_Cmd->m_RenderState.compute.sigelems; // while executing, decide where to start and stop. We do this by modifying the max count and diff --git a/renderdoc/driver/d3d12/d3d12_command_queue.h b/renderdoc/driver/d3d12/d3d12_command_queue.h index 301eedb41..3a996e4ac 100644 --- a/renderdoc/driver/d3d12/d3d12_command_queue.h +++ b/renderdoc/driver/d3d12/d3d12_command_queue.h @@ -24,7 +24,6 @@ #pragma once -#include #include "common/wrapped_pool.h" #include "d3d12_commands.h" #include "d3d12_common.h" @@ -116,7 +115,7 @@ class WrappedID3D12CommandQueue : public ID3D12CommandQueue, WrappedID3D12DebugCommandQueue m_WrappedDebug; - std::vector m_CmdListRecords; + rdcarray m_CmdListRecords; // D3D12 guarantees that queues are thread-safe Threading::CriticalSection m_Lock; @@ -150,7 +149,7 @@ public: ID3D12CommandQueue *GetReal() { return m_pReal; } D3D12ResourceRecord *GetResourceRecord() { return m_QueueRecord; } WrappedID3D12Device *GetWrappedDevice() { return m_pDevice; } - const std::vector &GetCmdLists() { return m_CmdListRecords; } + const rdcarray &GetCmdLists() { return m_CmdListRecords; } D3D12DrawcallTreeNode &GetParentDrawcall() { return m_Cmd.m_ParentDrawcall; } const APIEvent &GetEvent(uint32_t eventId); uint32_t GetMaxEID() { return m_Cmd.m_Events.back().eventId; } @@ -160,7 +159,7 @@ public: bool partial); void SetFrameReader(StreamReader *reader) { m_FrameReader = reader; } D3D12CommandData *GetCommandData() { return &m_Cmd; } - const std::vector &GetUsage(ResourceId id) { return m_Cmd.m_ResourceUses[id]; } + const rdcarray &GetUsage(ResourceId id) { return m_Cmd.m_ResourceUses[id]; } // interface for DXGI virtual IUnknown *GetRealIUnknown() { return GetReal(); } virtual IID GetBackbufferUUID() { return __uuidof(ID3D12Resource); } @@ -248,7 +247,7 @@ public: else if(guid == WKPDID_D3DDebugObjectNameW) { rdcwstr wName((const wchar_t *)pData, DataSize / 2); - std::string sName = StringFormat::Wide2UTF8(wName); + rdcstr sName = StringFormat::Wide2UTF8(wName); m_pDevice->SetName(this, sName.c_str()); } @@ -262,7 +261,7 @@ public: HRESULT STDMETHODCALLTYPE SetName(LPCWSTR Name) { - std::string utf8 = StringFormat::Wide2UTF8(Name); + rdcstr utf8 = StringFormat::Wide2UTF8(Name); m_pDevice->SetName(this, utf8.c_str()); return m_pReal->SetName(Name); diff --git a/renderdoc/driver/d3d12/d3d12_command_queue_wrap.cpp b/renderdoc/driver/d3d12/d3d12_command_queue_wrap.cpp index 6876dc568..890300131 100644 --- a/renderdoc/driver/d3d12/d3d12_command_queue_wrap.cpp +++ b/renderdoc/driver/d3d12/d3d12_command_queue_wrap.cpp @@ -83,7 +83,7 @@ bool WrappedID3D12CommandQueue::Serialise_ExecuteCommandLists(SerialiserType &se SERIALISE_ELEMENT_ARRAY(ppCommandLists, NumCommandLists); { - std::vector DebugMessages; + rdcarray DebugMessages; if(ser.IsWriting()) DebugMessages = m_pDevice->GetDebugMessages(); @@ -170,7 +170,7 @@ bool WrappedID3D12CommandQueue::Serialise_ExecuteCommandLists(SerialiserType &se m_pDevice->ApplyBarriers(m_Cmd.m_BakedCmdListInfo[cmd].barriers); } - std::string basename = StringFormat::Fmt("ExecuteCommandLists(%u)", NumCommandLists); + rdcstr basename = StringFormat::Fmt("ExecuteCommandLists(%u)", NumCommandLists); for(uint32_t c = 0; c < NumCommandLists; c++) { @@ -197,8 +197,8 @@ bool WrappedID3D12CommandQueue::Serialise_ExecuteCommandLists(SerialiserType &se for(size_t e = 0; e < cmdListInfo.draw->executedCmds.size(); e++) { - std::vector &submits = m_Cmd.m_Partial[D3D12CommandData::Secondary] - .cmdListExecs[cmdListInfo.draw->executedCmds[e]]; + rdcarray &submits = m_Cmd.m_Partial[D3D12CommandData::Secondary] + .cmdListExecs[cmdListInfo.draw->executedCmds[e]]; for(size_t s = 0; s < submits.size(); s++) submits[s] += m_Cmd.m_RootEventID; @@ -271,7 +271,7 @@ bool WrappedID3D12CommandQueue::Serialise_ExecuteCommandLists(SerialiserType &se uint32_t eid = startEID; - std::vector rerecordedCmds; + rdcarray rerecordedCmds; for(uint32_t c = 0; c < NumCommandLists; c++) { @@ -393,7 +393,7 @@ void WrappedID3D12CommandQueue::ExecuteCommandListsInternal(UINT NumCommandLists // any descriptor copies or writes could reference new resources not in the // bound descs list yet. So we take all of those referenced descriptors and // include them to see if we need to flush - std::vector dynDescRefs; + rdcarray dynDescRefs; m_pDevice->GetDynamicDescriptorReferences(dynDescRefs); for(size_t d = 0; d < dynDescRefs.size(); d++) @@ -475,7 +475,7 @@ void WrappedID3D12CommandQueue::ExecuteCommandListsInternal(UINT NumCommandLists if(capframe) { - std::vector maps = m_pDevice->GetMaps(); + rdcarray maps = m_pDevice->GetMaps(); for(auto it = maps.begin(); it != maps.end(); ++it) { @@ -548,7 +548,7 @@ template bool WrappedID3D12CommandQueue::Serialise_SetMarker(SerialiserType &ser, UINT Metadata, const void *pData, UINT Size) { - std::string MarkerText = ""; + rdcstr MarkerText = ""; if(ser.IsWriting() && pData && Size) MarkerText = DecodeMarkerString(Metadata, pData, Size); @@ -597,7 +597,7 @@ template bool WrappedID3D12CommandQueue::Serialise_BeginEvent(SerialiserType &ser, UINT Metadata, const void *pData, UINT Size) { - std::string MarkerText = ""; + rdcstr MarkerText = ""; if(ser.IsWriting() && pData && Size) MarkerText = DecodeMarkerString(Metadata, pData, Size); diff --git a/renderdoc/driver/d3d12/d3d12_commands.cpp b/renderdoc/driver/d3d12/d3d12_commands.cpp index 16c8cfe61..414a82b61 100644 --- a/renderdoc/driver/d3d12/d3d12_commands.cpp +++ b/renderdoc/driver/d3d12/d3d12_commands.cpp @@ -490,7 +490,7 @@ bool WrappedID3D12CommandQueue::ProcessChunk(ReadSerialiser &ser, D3D12Chunk chu break; case D3D12Chunk::Device_CopyDescriptors: case D3D12Chunk::Device_CopyDescriptorsSimple: - ret = m_pDevice->Serialise_DynamicDescriptorCopies(ser, std::vector()); + ret = m_pDevice->Serialise_DynamicDescriptorCopies(ser, rdcarray()); break; case D3D12Chunk::Queue_ExecuteCommandLists: @@ -1234,7 +1234,7 @@ HRESULT STDMETHODCALLTYPE WrappedID3D12GraphicsCommandList::QueryInterface(REFII void BakedCmdListInfo::ShiftForRemoved(uint32_t shiftDrawID, uint32_t shiftEID, size_t idx) { - std::vector &draws = draw->children; + rdcarray &draws = draw->children; drawCount -= shiftDrawID; eventCount -= shiftEID; @@ -1486,9 +1486,9 @@ void D3D12CommandData::AddEvent() { m_BakedCmdListInfo[m_LastCmdListID].curEvents.push_back(apievent); - std::vector &msgs = m_BakedCmdListInfo[m_LastCmdListID].debugMessages; + rdcarray &msgs = m_BakedCmdListInfo[m_LastCmdListID].debugMessages; - msgs.insert(msgs.end(), m_EventMessages.begin(), m_EventMessages.end()); + msgs.append(m_EventMessages); } else { @@ -1555,7 +1555,7 @@ void D3D12CommandData::AddUsage(const D3D12RenderState &state, D3D12DrawcallTree make_rdcpair(state.streamouts[i].countbuf, EventUsage(e, ResourceUsage::StreamOut))); } - std::vector rts = state.GetRTVIDs(); + rdcarray rts = state.GetRTVIDs(); for(size_t i = 0; i < rts.size(); i++) { @@ -1721,7 +1721,7 @@ void D3D12CommandData::AddDrawcall(const DrawcallDescription &d, bool hasEvents, draw.topology = MakePrimitiveTopology(m_BakedCmdListInfo[m_LastCmdListID].state.topo); draw.indexByteWidth = m_BakedCmdListInfo[m_LastCmdListID].state.ibuffer.bytewidth; - std::vector rts = m_BakedCmdListInfo[m_LastCmdListID].state.GetRTVIDs(); + rdcarray rts = m_BakedCmdListInfo[m_LastCmdListID].state.GetRTVIDs(); for(size_t i = 0; i < ARRAY_COUNT(draw.outputs); i++) { @@ -1747,9 +1747,9 @@ void D3D12CommandData::AddDrawcall(const DrawcallDescription &d, bool hasEvents, if(hasEvents) { - std::vector &srcEvents = m_LastCmdListID != ResourceId() - ? m_BakedCmdListInfo[m_LastCmdListID].curEvents - : m_RootEvents; + rdcarray &srcEvents = m_LastCmdListID != ResourceId() + ? m_BakedCmdListInfo[m_LastCmdListID].curEvents + : m_RootEvents; draw.events = srcEvents; srcEvents.clear(); @@ -1766,7 +1766,8 @@ void D3D12CommandData::AddDrawcall(const DrawcallDescription &d, bool hasEvents, if(m_LastCmdListID != ResourceId() && addUsage) AddUsage(m_BakedCmdListInfo[m_LastCmdListID].state, node); - node.children.insert(node.children.begin(), draw.children.begin(), draw.children.end()); + for(const DrawcallDescription &child : draw.children) + node.children.push_back(D3D12DrawcallTreeNode(child)); GetDrawcallStack().back()->children.push_back(node); } else @@ -1774,7 +1775,7 @@ void D3D12CommandData::AddDrawcall(const DrawcallDescription &d, bool hasEvents, } void D3D12CommandData::InsertDrawsAndRefreshIDs(ResourceId cmd, - std::vector &cmdBufNodes) + rdcarray &cmdBufNodes) { // assign new drawcall IDs for(size_t i = 0; i < cmdBufNodes.size(); i++) @@ -1804,7 +1805,7 @@ void D3D12CommandData::InsertDrawsAndRefreshIDs(ResourceId cmd, // insert in sorted location auto drawit = std::lower_bound(m_DrawcallUses.begin(), m_DrawcallUses.end(), use); - m_DrawcallUses.insert(drawit, use); + m_DrawcallUses.insert(drawit - m_DrawcallUses.begin(), use); RDCASSERT(n.children.empty()); diff --git a/renderdoc/driver/d3d12/d3d12_commands.h b/renderdoc/driver/d3d12/d3d12_commands.h index b8d075fa6..15cc1dfe6 100644 --- a/renderdoc/driver/d3d12/d3d12_commands.h +++ b/renderdoc/driver/d3d12/d3d12_commands.h @@ -35,13 +35,13 @@ struct D3D12DrawcallTreeNode D3D12DrawcallTreeNode(const D3D12DrawcallTreeNode &other) { *this = other; } ~D3D12DrawcallTreeNode() { SAFE_DELETE(state); } DrawcallDescription draw; - std::vector children; + rdcarray children; D3D12RenderState *state = NULL; - std::vector > resourceUsage; + rdcarray > resourceUsage; - std::vector executedCmds; + rdcarray executedCmds; D3D12DrawcallTreeNode &operator=(const DrawcallDescription &d) { @@ -85,9 +85,9 @@ struct D3D12DrawcallTreeNode } } - std::vector Bake() + rdcarray Bake() { - std::vector ret; + rdcarray ret; if(children.empty()) return ret; @@ -188,21 +188,21 @@ struct BakedCmdListInfo UINT realCount = 0; }; - std::vector crackedLists; - std::vector executeEvents; + rdcarray crackedLists; + rdcarray executeEvents; - std::vector curEvents; - std::vector debugMessages; - std::list drawStack; + rdcarray curEvents; + rdcarray debugMessages; + rdcarray drawStack; - std::vector > resourceUsage; + rdcarray > resourceUsage; ResourceId allocator; D3D12_COMMAND_LIST_TYPE type; UINT nodeMask; D3D12RenderState state; - std::vector barriers; + rdcarray barriers; ResourceId parentList; @@ -233,7 +233,7 @@ struct D3D12CommandData std::map m_CrackedAllocators; - std::vector m_IndirectBuffers; + rdcarray m_IndirectBuffers; static const uint64_t m_IndirectSize = 4 * 1024 * 1024; uint64_t m_IndirectOffset; @@ -272,7 +272,7 @@ struct D3D12CommandData // However, a single baked command list can be executed multiple times - so we have to have a // list of base events // Map from bakeID -> vector - std::map > cmdListExecs; + std::map > cmdListExecs; // This is just the baked ID of the parent command list that's partially replayed // If we are in the middle of a partial replay - allows fast checking in all CmdList chunks, @@ -298,7 +298,7 @@ struct D3D12CommandData // so we just set this command list ID3D12GraphicsCommandListX *m_OutsideCmdList = NULL; - void InsertDrawsAndRefreshIDs(ResourceId cmd, std::vector &cmdBufNodes); + void InsertDrawsAndRefreshIDs(ResourceId cmd, rdcarray &cmdBufNodes); // this is a list of uint64_t file offset -> uint32_t EIDs of where each // drawcall is used. E.g. the drawcall at offset 873954 is EID 50. If a @@ -322,16 +322,16 @@ struct D3D12CommandData return eventId < o.eventId; } }; - std::vector m_DrawcallUses; + rdcarray m_DrawcallUses; - std::vector m_EventMessages; + rdcarray m_EventMessages; std::map m_RerecordCmds; - std::vector m_RerecordCmdList; + rdcarray m_RerecordCmdList; bool m_AddedDrawcall; - std::vector m_RootEvents, m_Events; + rdcarray m_RootEvents, m_Events; uint64_t m_CurChunkOffset; SDChunkMetaData m_ChunkMetadata; @@ -343,13 +343,13 @@ struct D3D12CommandData SDFile *m_StructuredFile; - std::map > m_ResourceUses; + std::map > m_ResourceUses; D3D12DrawcallTreeNode m_ParentDrawcall; - std::list m_RootDrawcallStack; + rdcarray m_RootDrawcallStack; - std::list &GetDrawcallStack() + rdcarray &GetDrawcallStack() { if(m_LastCmdListID != ResourceId()) return m_BakedCmdListInfo[m_LastCmdListID].drawStack; diff --git a/renderdoc/driver/d3d12/d3d12_common.cpp b/renderdoc/driver/d3d12/d3d12_common.cpp index 469a5d957..832de5346 100644 --- a/renderdoc/driver/d3d12/d3d12_common.cpp +++ b/renderdoc/driver/d3d12/d3d12_common.cpp @@ -28,7 +28,7 @@ #include "d3d12_manager.h" #include "d3d12_resources.h" -D3D12MarkerRegion::D3D12MarkerRegion(ID3D12GraphicsCommandList *l, const std::string &marker) +D3D12MarkerRegion::D3D12MarkerRegion(ID3D12GraphicsCommandList *l, const rdcstr &marker) { list = l; queue = NULL; @@ -36,7 +36,7 @@ D3D12MarkerRegion::D3D12MarkerRegion(ID3D12GraphicsCommandList *l, const std::st D3D12MarkerRegion::Begin(list, marker); } -D3D12MarkerRegion::D3D12MarkerRegion(ID3D12CommandQueue *q, const std::string &marker) +D3D12MarkerRegion::D3D12MarkerRegion(ID3D12CommandQueue *q, const rdcstr &marker) { list = NULL; queue = q; @@ -52,7 +52,7 @@ D3D12MarkerRegion::~D3D12MarkerRegion() D3D12MarkerRegion::End(queue); } -void D3D12MarkerRegion::Begin(ID3D12GraphicsCommandList *list, const std::string &marker) +void D3D12MarkerRegion::Begin(ID3D12GraphicsCommandList *list, const rdcstr &marker) { if(list) { @@ -65,7 +65,7 @@ void D3D12MarkerRegion::Begin(ID3D12GraphicsCommandList *list, const std::string } } -void D3D12MarkerRegion::Begin(ID3D12CommandQueue *queue, const std::string &marker) +void D3D12MarkerRegion::Begin(ID3D12CommandQueue *queue, const rdcstr &marker) { if(queue) { @@ -75,7 +75,7 @@ void D3D12MarkerRegion::Begin(ID3D12CommandQueue *queue, const std::string &mark } } -void D3D12MarkerRegion::Set(ID3D12GraphicsCommandList *list, const std::string &marker) +void D3D12MarkerRegion::Set(ID3D12GraphicsCommandList *list, const rdcstr &marker) { if(list) { @@ -85,7 +85,7 @@ void D3D12MarkerRegion::Set(ID3D12GraphicsCommandList *list, const std::string & } } -void D3D12MarkerRegion::Set(ID3D12CommandQueue *queue, const std::string &marker) +void D3D12MarkerRegion::Set(ID3D12CommandQueue *queue, const rdcstr &marker) { if(queue) { @@ -676,7 +676,7 @@ inline void PIX3DecodeStringInfo(const UINT64 BlobData, UINT64 &Alignment, UINT6 IsShortcut = (BlobData >> PIXEventsStringIsShortcutBitShift) & PIXEventsStringIsShortcutWriteMask; } -const UINT64 *PIX3DecodeStringParam(const UINT64 *pData, std::string &DecodedString) +const UINT64 *PIX3DecodeStringParam(const UINT64 *pData, rdcstr &DecodedString) { UINT64 alignment; UINT64 copyChunkSize; @@ -690,7 +690,7 @@ const UINT64 *PIX3DecodeStringParam(const UINT64 *pData, std::string &DecodedStr { const char *c = (const char *)pData; UINT formatStringCharCount = UINT(strlen((const char *)pData)); - DecodedString = std::string(c, c + formatStringCharCount); + DecodedString = rdcstr(c, formatStringCharCount); totalStringBytes = formatStringCharCount + 1; } else @@ -708,18 +708,18 @@ const UINT64 *PIX3DecodeStringParam(const UINT64 *pData, std::string &DecodedStr return pData; } -std::string PIX3SprintfParams(const std::string &Format, const UINT64 *pData) +rdcstr PIX3SprintfParams(const rdcstr &Format, const UINT64 *pData) { - std::string finalString; - std::string formatPart; - size_t lastFind = 0; + rdcstr finalString; + rdcstr formatPart; + int32_t lastFind = 0; - for(size_t found = Format.find_first_of("%"); found != std::string::npos;) + for(int32_t found = Format.indexOf('%'); found >= 0;) { finalString += Format.substr(lastFind, found - lastFind); - size_t endOfFormat = Format.find_first_of("%diufFeEgGxXoscpaAn", found + 1); - if(endOfFormat == std::string::npos) + int32_t endOfFormat = Format.find_first_of("%diufFeEgGxXoscpaAn", found + 1); + if(endOfFormat < 0) { finalString += ""; break; @@ -730,7 +730,7 @@ std::string PIX3SprintfParams(const std::string &Format, const UINT64 *pData) // strings if(formatPart.back() == 's') { - std::string stringParam; + rdcstr stringParam; pData = PIX3DecodeStringParam(pData, stringParam); finalString += stringParam; } @@ -745,7 +745,7 @@ std::string PIX3SprintfParams(const std::string &Format, const UINT64 *pData) } lastFind = endOfFormat + 1; - found = Format.find_first_of("%", lastFind); + found = Format.indexOf('%', lastFind); } finalString += Format.substr(lastFind); @@ -753,7 +753,7 @@ std::string PIX3SprintfParams(const std::string &Format, const UINT64 *pData) return finalString; } -std::string PIX3DecodeEventString(const UINT64 *pData) +rdcstr PIX3DecodeEventString(const UINT64 *pData) { // event header UINT64 timestamp; @@ -780,7 +780,7 @@ std::string PIX3DecodeEventString(const UINT64 *pData) ++pData; // format string - std::string formatString; + rdcstr formatString; pData = PIX3DecodeStringParam(pData, formatString); if(eventType == ePIXEvent_BeginEvent_NoArgs) diff --git a/renderdoc/driver/d3d12/d3d12_common.h b/renderdoc/driver/d3d12/d3d12_common.h index 73badfd30..c20114350 100644 --- a/renderdoc/driver/d3d12/d3d12_common.h +++ b/renderdoc/driver/d3d12/d3d12_common.h @@ -40,16 +40,16 @@ using ID3D12GraphicsCommandListX = ID3D12GraphicsCommandList5; // replay only class for handling marker regions struct D3D12MarkerRegion { - D3D12MarkerRegion(ID3D12GraphicsCommandList *list, const std::string &marker); - D3D12MarkerRegion(ID3D12CommandQueue *queue, const std::string &marker); + D3D12MarkerRegion(ID3D12GraphicsCommandList *list, const rdcstr &marker); + D3D12MarkerRegion(ID3D12CommandQueue *queue, const rdcstr &marker); ~D3D12MarkerRegion(); - static void Set(ID3D12GraphicsCommandList *list, const std::string &marker); - static void Set(ID3D12CommandQueue *queue, const std::string &marker); + static void Set(ID3D12GraphicsCommandList *list, const rdcstr &marker); + static void Set(ID3D12CommandQueue *queue, const rdcstr &marker); - static void Begin(ID3D12GraphicsCommandList *list, const std::string &marker); + static void Begin(ID3D12GraphicsCommandList *list, const rdcstr &marker); static void End(ID3D12GraphicsCommandList *list); - static void Begin(ID3D12CommandQueue *queue, const std::string &marker); + static void Begin(ID3D12CommandQueue *queue, const rdcstr &marker); static void End(ID3D12CommandQueue *queue); ID3D12GraphicsCommandList *list = NULL; @@ -59,7 +59,7 @@ struct D3D12MarkerRegion bool EnableD3D12DebugLayer(PFN_D3D12_GET_DEBUG_INTERFACE getDebugInterface = NULL); HRESULT EnumAdapterByLuid(IDXGIFactory1 *factory, LUID luid, IDXGIAdapter **pAdapter); -inline void SetObjName(ID3D12Object *obj, const std::string &utf8name) +inline void SetObjName(ID3D12Object *obj, const rdcstr &utf8name) { obj->SetName(StringFormat::UTF82Wide(utf8name).c_str()); } @@ -68,11 +68,11 @@ inline void SetObjName(ID3D12Object *obj, const std::string &utf8name) #define PIX_EVENT_ANSI_VERSION 1 #define PIX_EVENT_PIX3BLOB_VERSION 2 -std::string PIX3DecodeEventString(const UINT64 *pData); +rdcstr PIX3DecodeEventString(const UINT64 *pData); -inline std::string DecodeMarkerString(UINT Metadata, const void *pData, UINT Size) +inline rdcstr DecodeMarkerString(UINT Metadata, const void *pData, UINT Size) { - std::string MarkerText = ""; + rdcstr MarkerText = ""; // There may be a space appended to the marker string - see D3D12MarkerRegion::Begin // If we encounter this extra space (or a null terminator), remove it. @@ -86,7 +86,7 @@ inline std::string DecodeMarkerString(UINT Metadata, const void *pData, UINT Siz else if(Metadata == PIX_EVENT_ANSI_VERSION) { const char *c = (const char *)pData; - MarkerText = std::string(c, c + Size); + MarkerText = rdcstr(c, Size); if(!MarkerText.empty() && (MarkerText.back() == ' ' || MarkerText.back() == 0)) MarkerText.pop_back(); } @@ -315,7 +315,7 @@ struct D3D12RootSignatureParameter : D3D12_ROOT_PARAMETER1 } } - std::vector ranges; + rdcarray ranges; }; DECLARE_REFLECTION_STRUCT(D3D12RootSignatureParameter); @@ -326,8 +326,8 @@ struct D3D12RootSignature uint32_t dwordLength = 0; D3D12_ROOT_SIGNATURE_FLAGS Flags = D3D12_ROOT_SIGNATURE_FLAG_NONE; - std::vector Parameters; - std::vector StaticSamplers; + rdcarray Parameters; + rdcarray StaticSamplers; }; DECLARE_REFLECTION_STRUCT(D3D12RootSignature); @@ -337,7 +337,7 @@ struct D3D12CommandSignature bool graphics = true; UINT numDraws = 0; UINT ByteStride = 0; - std::vector arguments; + rdcarray arguments; }; #define IMPLEMENT_IUNKNOWN_WITH_REFCOUNTER_CUSTOMQUERY \ @@ -413,6 +413,11 @@ DECLARE_REFLECTION_STRUCT(D3D12BufferLocation); DECLARE_REFLECTION_STRUCT(D3D12_CPU_DESCRIPTOR_HANDLE); DECLARE_REFLECTION_STRUCT(D3D12_GPU_DESCRIPTOR_HANDLE); +inline bool operator==(const D3D12_CPU_DESCRIPTOR_HANDLE &l, const D3D12_CPU_DESCRIPTOR_HANDLE &r) +{ + return l.ptr == r.ptr; +} + // expanded version of D3D12_GRAPHICS_PIPELINE_STATE_DESC / D3D12_COMPUTE_PIPELINE_STATE_DESC with // all subobjects. No enums suitable to make this a stream though. struct D3D12_EXPANDED_PIPELINE_STATE_STREAM_DESC diff --git a/renderdoc/driver/d3d12/d3d12_counters.cpp b/renderdoc/driver/d3d12/d3d12_counters.cpp index 8c8d69b47..e0c7a54aa 100644 --- a/renderdoc/driver/d3d12/d3d12_counters.cpp +++ b/renderdoc/driver/d3d12/d3d12_counters.cpp @@ -340,11 +340,11 @@ rdcarray D3D12Replay::FetchCountersAMD(const rdcarray search.eventId = m_pAMDDrawCallback->m_AliasEvents[i].first; // find the result we're aliasing - auto it = std::find(ret.begin(), ret.end(), search); - if(it != ret.end()) + int32_t idx = ret.indexOf(search); + if(idx >= 0) { // duplicate the result and append - CounterResult aliased = *it; + CounterResult aliased = ret[idx]; aliased.eventId = m_pAMDDrawCallback->m_AliasEvents[i].second; ret.push_back(aliased); } @@ -669,11 +669,11 @@ rdcarray D3D12Replay::FetchCounters(const rdcarray &c search.eventId = cb.m_AliasEvents[i].first; // find the result we're aliasing - auto it = std::find(ret.begin(), ret.end(), search); - if(it != ret.end()) + int32_t idx = ret.indexOf(search); + if(idx >= 0) { // duplicate the result and append - CounterResult aliased = *it; + CounterResult aliased = ret[idx]; aliased.eventId = cb.m_AliasEvents[i].second; ret.push_back(aliased); } diff --git a/renderdoc/driver/d3d12/d3d12_debug.cpp b/renderdoc/driver/d3d12/d3d12_debug.cpp index 22547fee1..dd65731d0 100644 --- a/renderdoc/driver/d3d12/d3d12_debug.cpp +++ b/renderdoc/driver/d3d12/d3d12_debug.cpp @@ -256,7 +256,7 @@ D3D12DebugManager::D3D12DebugManager(WrappedID3D12Device *wrapper) } { - std::string meshhlsl = GetEmbeddedResource(mesh_hlsl); + rdcstr meshhlsl = GetEmbeddedResource(mesh_hlsl); shaderCache->GetShaderBlob(meshhlsl.c_str(), "RENDERDOC_MeshVS", D3DCOMPILE_WARNINGS_ARE_ERRORS, "vs_5_0", &m_MeshVS); @@ -267,14 +267,14 @@ D3D12DebugManager::D3D12DebugManager(WrappedID3D12Device *wrapper) } { - std::string hlsl = GetEmbeddedResource(misc_hlsl); + rdcstr hlsl = GetEmbeddedResource(misc_hlsl); shaderCache->GetShaderBlob(hlsl.c_str(), "RENDERDOC_FullscreenVS", D3DCOMPILE_WARNINGS_ARE_ERRORS, "vs_5_0", &m_FullscreenVS); } { - std::string multisamplehlsl = GetEmbeddedResource(multisample_hlsl); + rdcstr multisamplehlsl = GetEmbeddedResource(multisample_hlsl); shaderCache->GetShaderBlob(multisamplehlsl.c_str(), "RENDERDOC_CopyMSToArray", D3DCOMPILE_WARNINGS_ARE_ERRORS, "ps_5_0", &m_IntMS2Array); @@ -828,7 +828,7 @@ void D3D12Replay::GeneralMisc::Init(WrappedID3D12Device *device, D3D12DebugManag } { - std::string hlsl = GetEmbeddedResource(misc_hlsl); + rdcstr hlsl = GetEmbeddedResource(misc_hlsl); ID3DBlob *FullscreenVS = NULL; ID3DBlob *CheckerboardPS = NULL; @@ -961,7 +961,7 @@ void D3D12Replay::TextureRendering::Init(WrappedID3D12Device *device, D3D12Debug } { - std::string hlsl = GetEmbeddedResource(texdisplay_hlsl); + rdcstr hlsl = GetEmbeddedResource(texdisplay_hlsl); ID3DBlob *TexDisplayPS = NULL; @@ -1124,7 +1124,7 @@ void D3D12Replay::OverlayRendering::Init(WrappedID3D12Device *device, D3D12Debug shaderCache->SetCaching(true); { - std::string meshhlsl = GetEmbeddedResource(mesh_hlsl); + rdcstr meshhlsl = GetEmbeddedResource(mesh_hlsl); shaderCache->GetShaderBlob(meshhlsl.c_str(), "RENDERDOC_TriangleSizeGS", D3DCOMPILE_WARNINGS_ARE_ERRORS, "gs_5_0", &TriangleSizeGS); @@ -1134,7 +1134,7 @@ void D3D12Replay::OverlayRendering::Init(WrappedID3D12Device *device, D3D12Debug shaderCache->GetShaderBlob(meshhlsl.c_str(), "RENDERDOC_MeshVS", D3DCOMPILE_WARNINGS_ARE_ERRORS, "vs_5_0", &MeshVS); - std::string hlsl = GetEmbeddedResource(quadoverdraw_hlsl); + rdcstr hlsl = GetEmbeddedResource(quadoverdraw_hlsl); shaderCache->GetShaderBlob(hlsl.c_str(), "RENDERDOC_QuadOverdrawPS", D3DCOMPILE_WARNINGS_ARE_ERRORS, "ps_5_0", &QuadOverdrawWritePS); @@ -1155,7 +1155,7 @@ void D3D12Replay::OverlayRendering::Init(WrappedID3D12Device *device, D3D12Debug } { - std::string hlsl = GetEmbeddedResource(misc_hlsl); + rdcstr hlsl = GetEmbeddedResource(misc_hlsl); ID3DBlob *FullscreenVS = NULL; shaderCache->GetShaderBlob(hlsl.c_str(), "RENDERDOC_FullscreenVS", @@ -1247,7 +1247,7 @@ void D3D12Replay::VertexPicking::Init(WrappedID3D12Device *device, D3D12DebugMan } { - std::string meshhlsl = GetEmbeddedResource(mesh_hlsl); + rdcstr meshhlsl = GetEmbeddedResource(mesh_hlsl); ID3DBlob *meshPickCS; @@ -1420,7 +1420,7 @@ void D3D12Replay::HistogramMinMax::Init(WrappedID3D12Device *device, D3D12DebugM } { - std::string histogramhlsl = GetEmbeddedResource(histogram_hlsl); + rdcstr histogramhlsl = GetEmbeddedResource(histogram_hlsl); D3D12_COMPUTE_PIPELINE_STATE_DESC compPipeDesc = {}; @@ -1439,9 +1439,9 @@ void D3D12Replay::HistogramMinMax::Init(WrappedID3D12Device *device, D3D12DebugM ID3DBlob *result = NULL; ID3DBlob *histogram = NULL; - 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; shaderCache->GetShaderBlob(hlsl.c_str(), "RENDERDOC_TileMinMaxCS", diff --git a/renderdoc/driver/d3d12/d3d12_debug.h b/renderdoc/driver/d3d12/d3d12_debug.h index 96be9cdcd..589b311f1 100644 --- a/renderdoc/driver/d3d12/d3d12_debug.h +++ b/renderdoc/driver/d3d12/d3d12_debug.h @@ -160,7 +160,7 @@ public: D3D12_CPU_DESCRIPTOR_HANDLE GetUAVClearHandle(CBVUAVSRVSlot slot); void PrepareTextureSampling(ID3D12Resource *resource, CompType typeCast, int &resType, - std::vector &barriers); + rdcarray &barriers); MeshDisplayPipelines CacheMeshDisplayPipelines(const MeshFormat &primary, const MeshFormat &secondary); diff --git a/renderdoc/driver/d3d12/d3d12_device.cpp b/renderdoc/driver/d3d12/d3d12_device.cpp index 788829fad..517f8a5ac 100644 --- a/renderdoc/driver/d3d12/d3d12_device.cpp +++ b/renderdoc/driver/d3d12/d3d12_device.cpp @@ -47,13 +47,7 @@ std::map WrappedID3D12Device::m_DeviceWra void WrappedID3D12Device::RemoveQueue(WrappedID3D12CommandQueue *queue) { - auto it = std::remove_if(m_Queues.begin(), m_Queues.end(), - [queue](const WrappedID3D12CommandQueue *q) { return q == queue; }); - - if(it != m_Queues.end()) - m_Queues.erase(it); - else - RDCERR("Unknown wrapped queue %p being remvoed", queue); + m_Queues.removeOne(queue); } rdcstr WrappedID3D12Device::GetChunkName(uint32_t idx) @@ -294,7 +288,7 @@ WrappedID3D12Device::WrappedID3D12Device(ID3D12Device *realDevice, D3D12InitPara if(realDevice) { m_ResourceList = new std::map(); - m_PipelineList = new std::vector(); + m_PipelineList = new rdcarray(); } m_FrameCaptureRecord = NULL; @@ -337,7 +331,7 @@ WrappedID3D12Device::WrappedID3D12Device(ID3D12Device *realDevice, D3D12InitPara m_InitParams.AdapterDesc = desc; GPUVendor vendor = GPUVendorFromPCIVendor(desc.VendorId); - std::string descString = GetDriverVersion(desc); + rdcstr descString = GetDriverVersion(desc); RDCLOG("New D3D12 device created: %s / %s", ToStr(vendor).c_str(), descString.c_str()); @@ -955,7 +949,7 @@ void WrappedID3D12Device::FirstFrame(IDXGISwapper *swapper) } } -void WrappedID3D12Device::ApplyBarriers(std::vector &barriers) +void WrappedID3D12Device::ApplyBarriers(rdcarray &barriers) { SCOPED_LOCK(m_ResourceStatesLock); GetResourceManager()->ApplyBarriers(barriers, m_ResourceStates); @@ -1076,7 +1070,7 @@ bool WrappedID3D12Device::Serialise_WrapSwapchainBuffer(SerialiserType &ser, IDX SubresourceStateVector &states = m_ResourceStates[wrapped->GetResourceID()]; - states.resize(1, D3D12_RESOURCE_STATE_PRESENT); + states = {D3D12_RESOURCE_STATE_PRESENT}; } } @@ -1138,7 +1132,7 @@ IUnknown *WrappedID3D12Device::WrapSwapchainBuffer(IDXGISwapper *swapper, DXGI_F SCOPED_LOCK(m_ResourceStatesLock); SubresourceStateVector &states = m_ResourceStates[id]; - states.resize(1, D3D12_RESOURCE_STATE_PRESENT); + states = {D3D12_RESOURCE_STATE_PRESENT}; } } } @@ -1215,21 +1209,19 @@ void WrappedID3D12Device::Unmap(ID3D12Resource *Resource, UINT Subresource, byte const D3D12_RANGE *pWrittenRange) { MapState map = {}; + { SCOPED_LOCK(m_MapsLock); - for(auto it = m_Maps.begin(); it != m_Maps.end(); ++it) - { - if(it->res == Resource && it->subres == Subresource) - { - map = *it; - m_Maps.erase(it); - break; - } - } - } + map.res = Resource; + map.subres = Subresource; - if(map.res == NULL) - return; + int32_t idx = m_Maps.indexOf(map); + + if(idx < 0) + return; + + map = m_Maps.takeAt(idx); + } bool capframe = false; { @@ -1592,7 +1584,7 @@ HRESULT WrappedID3D12Device::Present(ID3D12GraphicsCommandList *pOverlayCommandL list->OMSetRenderTargets(1, &rtv, FALSE, NULL); int flags = activeWindow ? RenderDoc::eOverlay_ActiveWindow : 0; - std::string overlayText = + rdcstr overlayText = RenderDoc::Inst().GetOverlayText(RDCDriver::D3D12, m_FrameCounter, flags); if(m_InvalidPSO) @@ -1717,7 +1709,7 @@ bool WrappedID3D12Device::Serialise_CaptureScope(SerialiserType &ser) template bool WrappedID3D12Device::Serialise_BeginCaptureFrame(SerialiserType &ser) { - std::vector barriers; + rdcarray barriers; { SCOPED_LOCK(m_ResourceStatesLock); // not needed on replay, but harmless also @@ -1870,7 +1862,7 @@ bool WrappedID3D12Device::EndFrameCapture(void *dev, void *wnd) if(swapper != NULL) backbuffer = (ID3D12Resource *)swapper->GetBackbuffers()[swapper->GetLastPresentedBuffer()]; - std::vector queues; + rdcarray queues; // transition back to IDLE and readback initial states atomically { @@ -2080,7 +2072,7 @@ bool WrappedID3D12Device::EndFrameCapture(void *dev, void *wnd) { WrappedID3D12CommandQueue *q = *it; - const std::vector &cmdListRecords = q->GetCmdLists(); + const rdcarray &cmdListRecords = q->GetCmdLists(); RDCDEBUG("Flushing %u command list records from queue %llu", (uint32_t)cmdListRecords.size(), q->GetResourceID()); @@ -2150,7 +2142,7 @@ bool WrappedID3D12Device::DiscardFrameCapture(void *dev, void *wnd) m_CapturedFrames.pop_back(); - std::vector queues; + rdcarray queues; // transition back to IDLE and readback initial states atomically { @@ -2269,7 +2261,7 @@ HRESULT WrappedID3D12Device::CreatePipeState(D3D12_EXPANDED_PIPELINE_STATE_STREA } void WrappedID3D12Device::AddDebugMessage(MessageCategory c, MessageSeverity sv, MessageSource src, - std::string d) + rdcstr d) { D3D12CommandData &cmd = *m_Queue->GetCommandData(); @@ -2305,9 +2297,9 @@ void WrappedID3D12Device::AddDebugMessage(const DebugMessage &msg) m_DebugMessages.push_back(msg); } -std::vector WrappedID3D12Device::GetDebugMessages() +rdcarray WrappedID3D12Device::GetDebugMessages() { - std::vector ret; + rdcarray ret; if(IsActiveReplaying(m_State)) { @@ -2392,7 +2384,7 @@ std::vector WrappedID3D12Device::GetDebugMessages() } msg.messageID = (uint32_t)message->ID; - msg.description = std::string(message->pDescription); + msg.description = rdcstr(message->pDescription); // during capture add all messages. Otherwise only add this message if it's different to the // last one - due to our replay with real and cracked lists we get many duplicated messages @@ -2418,8 +2410,8 @@ std::vector WrappedID3D12Device::GetDebugMessages() void WrappedID3D12Device::FlushPendingDescriptorWrites() { - std::vector writes; - std::vector copies; + rdcarray writes; + rdcarray copies; { SCOPED_LOCK(m_DynDescLock); @@ -2653,13 +2645,11 @@ void WrappedID3D12Device::FreeRTV(D3D12_CPU_DESCRIPTOR_HANDLE handle) if(handle.ptr == 0) return; - auto it = - std::find_if(m_UsedRTVs.begin(), m_UsedRTVs.end(), - [handle](const D3D12_CPU_DESCRIPTOR_HANDLE a) { return a.ptr == handle.ptr; }); + int32_t idx = m_UsedRTVs.indexOf(handle); - if(it != m_UsedRTVs.end()) + if(idx >= 0) { - m_UsedRTVs.erase(it); + m_UsedRTVs.erase(idx); m_FreeRTVs.push_back(handle); } else @@ -2888,15 +2878,7 @@ void WrappedID3D12Device::ExecuteList(ID3D12GraphicsCommandListX *list, void WrappedID3D12Device::MarkListExecuted(ID3D12GraphicsCommandListX *list) { - for(auto it = m_InternalCmds.pendingcmds.begin(); it != m_InternalCmds.pendingcmds.end(); ++it) - { - if(list == *it) - { - m_InternalCmds.pendingcmds.erase(it); - break; - } - } - + m_InternalCmds.pendingcmds.removeOne(list); m_InternalCmds.submittedcmds.push_back(list); } @@ -2906,7 +2888,7 @@ void WrappedID3D12Device::ExecuteLists(WrappedID3D12CommandQueue *queue, bool In if(m_InternalCmds.pendingcmds.empty()) return; - std::vector cmds; + rdcarray cmds; cmds.resize(m_InternalCmds.pendingcmds.size()); for(size_t i = 0; i < cmds.size(); i++) cmds[i] = m_InternalCmds.pendingcmds[i]; @@ -2916,9 +2898,7 @@ void WrappedID3D12Device::ExecuteLists(WrappedID3D12CommandQueue *queue, bool In queue->ExecuteCommandListsInternal((UINT)cmds.size(), &cmds[0], InFrameCaptureBoundary, false); - m_InternalCmds.submittedcmds.insert(m_InternalCmds.submittedcmds.end(), - m_InternalCmds.pendingcmds.begin(), - m_InternalCmds.pendingcmds.end()); + m_InternalCmds.submittedcmds.append(m_InternalCmds.pendingcmds); m_InternalCmds.pendingcmds.clear(); } @@ -2929,9 +2909,7 @@ void WrappedID3D12Device::FlushLists(bool forceSync, ID3D12CommandQueue *queue) GPUSync(queue); if(!m_InternalCmds.submittedcmds.empty()) - m_InternalCmds.freecmds.insert(m_InternalCmds.freecmds.end(), - m_InternalCmds.submittedcmds.begin(), - m_InternalCmds.submittedcmds.end()); + m_InternalCmds.freecmds.append(m_InternalCmds.submittedcmds); m_InternalCmds.submittedcmds.clear(); if(m_InternalCmds.pendingcmds.empty()) @@ -3199,7 +3177,7 @@ ReplayStatus WrappedID3D12Device::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); diff --git a/renderdoc/driver/d3d12/d3d12_device.h b/renderdoc/driver/d3d12/d3d12_device.h index 9df607287..98eab64e9 100644 --- a/renderdoc/driver/d3d12/d3d12_device.h +++ b/renderdoc/driver/d3d12/d3d12_device.h @@ -358,8 +358,8 @@ private: ID3D12DeviceDownlevel *m_pDownlevel; // list of all queues being captured - std::vector m_Queues; - std::vector m_QueueFences; + rdcarray m_Queues; + rdcarray m_QueueFences; // the queue we use for all internal work, the first DIRECT queue WrappedID3D12CommandQueue *m_Queue; @@ -375,13 +375,13 @@ private: WrappedDRED m_DRED; WrappedDREDSettings m_DREDSettings; - std::vector m_CommandAllocators; + rdcarray m_CommandAllocators; D3D12_CPU_DESCRIPTOR_HANDLE AllocRTV(); void FreeRTV(D3D12_CPU_DESCRIPTOR_HANDLE handle); - std::vector m_FreeRTVs; - std::vector m_UsedRTVs; + rdcarray m_FreeRTVs; + rdcarray m_UsedRTVs; void CreateInternalResources(); void DestroyInternalResources(); @@ -401,7 +401,7 @@ private: std::map m_UploadBuffers; Threading::CriticalSection m_MapsLock; - std::vector m_Maps; + rdcarray m_Maps; bool ProcessChunk(ReadSerialiser &ser, D3D12Chunk context); @@ -413,7 +413,7 @@ private: uint64_t threadSerialiserTLSSlot; Threading::CriticalSection m_ThreadSerialisersLock; - std::vector m_ThreadSerialisers; + rdcarray m_ThreadSerialisers; uint64_t tempMemoryTLSSlot; struct TempMem @@ -423,15 +423,15 @@ private: size_t size; }; Threading::CriticalSection m_ThreadTempMemLock; - std::vector m_ThreadTempMem; + rdcarray m_ThreadTempMem; - std::vector m_DebugMessages; + rdcarray m_DebugMessages; SDFile *m_StructuredFile = NULL; SDFile m_StoredStructuredData; uint32_t m_FrameCounter = 0; - std::vector m_CapturedFrames; + rdcarray m_CapturedFrames; rdcarray m_Drawcalls; ReplayStatus m_FailedReplayStatus = ReplayStatus::APIReplayFailed; @@ -459,9 +459,9 @@ private: D3D12ResourceRecord *m_DeviceRecord; Threading::CriticalSection m_DynDescLock; - std::vector m_DynamicDescriptorCopies; - std::vector m_DynamicDescriptorWrites; - std::vector m_DynamicDescriptorRefs; + rdcarray m_DynamicDescriptorCopies; + rdcarray m_DynamicDescriptorWrites; + rdcarray m_DynamicDescriptorRefs; GPUAddressRangeTracker m_GPUAddresses; @@ -474,11 +474,11 @@ private: std::set m_Cubemaps; - std::map m_ResourceNames; + std::map m_ResourceNames; // only valid on replay std::map *m_ResourceList = NULL; - std::vector *m_PipelineList = NULL; + rdcarray *m_PipelineList = NULL; struct SwapPresentInfo { @@ -531,7 +531,7 @@ public: // only valid on replay std::map &GetResourceList() { return *m_ResourceList; } - std::vector &GetPipelineList() { return *m_PipelineList; } + rdcarray &GetPipelineList() { return *m_PipelineList; } //////////////////////////////////////////////////////////////// // non wrapping interface @@ -551,9 +551,9 @@ public: const DrawcallDescription *GetDrawcall(uint32_t eventId); ResourceId GetFrameCaptureResourceId() { return m_FrameCaptureRecord->GetResourceID(); } - void AddDebugMessage(MessageCategory c, MessageSeverity sv, MessageSource src, std::string d); + void AddDebugMessage(MessageCategory c, MessageSeverity sv, MessageSource src, rdcstr d); void AddDebugMessage(const DebugMessage &msg); - std::vector GetDebugMessages(); + rdcarray GetDebugMessages(); ResourceDescription &GetResourceDesc(ResourceId id); void AddResource(ResourceId id, ResourceType type, const char *defaultNamePrefix); @@ -562,8 +562,8 @@ public: void AddResourceCurChunk(ResourceDescription &descr); void AddResourceCurChunk(ResourceId id); - const std::string &GetResourceName(ResourceId id) { return m_ResourceNames[id]; } - std::vector &GetSubresourceStates(ResourceId id) + const rdcstr &GetResourceName(ResourceId id) { return m_ResourceNames[id]; } + rdcarray &GetSubresourceStates(ResourceId id) { return m_ResourceStates[id]; } @@ -585,9 +585,9 @@ public: D3D12Replay *GetReplay() { return m_Replay; } WrappedID3D12CommandQueue *GetQueue() { return m_Queue; } ID3D12CommandAllocator *GetAlloc() { return m_Alloc; } - void ApplyBarriers(std::vector &barriers); + void ApplyBarriers(rdcarray &barriers); - void GetDynamicDescriptorReferences(std::vector &refs) + void GetDynamicDescriptorReferences(rdcarray &refs) { SCOPED_LOCK(m_DynDescLock); m_DynamicDescriptorRefs.swap(refs); @@ -616,11 +616,11 @@ public: submittedcmds.clear(); } - std::vector freecmds; + rdcarray freecmds; // -> GetNextCmd() -> - std::vector pendingcmds; + rdcarray pendingcmds; // -> ExecuteLists() -> - std::vector submittedcmds; + rdcarray submittedcmds; // -> FlushLists()--------back to freecmds--------^ } m_InternalCmds; @@ -663,7 +663,7 @@ public: bool Serialise_DynamicDescriptorWrite(SerialiserType &ser, const DynamicDescriptorWrite *write); template bool Serialise_DynamicDescriptorCopies(SerialiserType &ser, - const std::vector &DescriptorCopies); + const rdcarray &DescriptorCopies); ReplayStatus ReadLogInitialisation(RDCFile *rdc, bool storeStructuredBuffers); void ReplayLog(uint32_t startEventID, uint32_t endEventID, ReplayLogType replayType); @@ -786,9 +786,9 @@ public: UINT Subresource, const D3D12_BOX *pDstBox, const void *pSrcData, UINT SrcRowPitch, UINT SrcDepthPitch); - std::vector GetMaps() + rdcarray GetMaps() { - std::vector ret; + rdcarray ret; { SCOPED_LOCK(m_MapsLock); ret = m_Maps; diff --git a/renderdoc/driver/d3d12/d3d12_device_wrap.cpp b/renderdoc/driver/d3d12/d3d12_device_wrap.cpp index bcd4d773e..56bee5c80 100644 --- a/renderdoc/driver/d3d12/d3d12_device_wrap.cpp +++ b/renderdoc/driver/d3d12/d3d12_device_wrap.cpp @@ -1346,7 +1346,7 @@ bool WrappedID3D12Device::Serialise_CreateCommittedResource( GetResourceManager()->AddLiveResource(pResource, ret); SubresourceStateVector &states = m_ResourceStates[GetResID(ret)]; - states.resize(GetNumSubresources(m_pDevice, &desc), InitialResourceState); + states.fill(GetNumSubresources(m_pDevice, &desc), InitialResourceState); ResourceType type = ResourceType::Texture; const char *prefix = "Texture"; @@ -1461,7 +1461,7 @@ HRESULT WrappedID3D12Device::CreateCommittedResource(const D3D12_HEAP_PROPERTIES SCOPED_LOCK(m_ResourceStatesLock); SubresourceStateVector &states = m_ResourceStates[wrapped->GetResourceID()]; - states.resize(GetNumSubresources(m_pDevice, pDesc), InitialResourceState); + states.fill(GetNumSubresources(m_pDevice, pDesc), InitialResourceState); } *ppvResource = (ID3D12Resource *)wrapped; @@ -1624,7 +1624,7 @@ bool WrappedID3D12Device::Serialise_CreatePlacedResource( GetResourceManager()->AddLiveResource(pResource, ret); SubresourceStateVector &states = m_ResourceStates[GetResID(ret)]; - states.resize(GetNumSubresources(m_pDevice, &Descriptor), InitialState); + states.fill(GetNumSubresources(m_pDevice, &Descriptor), InitialState); } ResourceType type = ResourceType::Texture; @@ -1736,7 +1736,7 @@ HRESULT WrappedID3D12Device::CreatePlacedResource(ID3D12Heap *pHeap, UINT64 Heap SCOPED_LOCK(m_ResourceStatesLock); SubresourceStateVector &states = m_ResourceStates[wrapped->GetResourceID()]; - states.resize(GetNumSubresources(m_pDevice, pDesc), InitialState); + states.fill(GetNumSubresources(m_pDevice, pDesc), InitialState); } *ppvResource = (ID3D12Resource *)wrapped; @@ -1962,8 +1962,7 @@ bool WrappedID3D12Device::Serialise_CreateCommandSignature(SerialiserType &ser, WrappedID3D12CommandSignature *wrapped = new WrappedID3D12CommandSignature(ret, this); wrapped->sig.ByteStride = Descriptor.ByteStride; - wrapped->sig.arguments.insert(wrapped->sig.arguments.begin(), Descriptor.pArgumentDescs, - Descriptor.pArgumentDescs + Descriptor.NumArgumentDescs); + wrapped->sig.arguments.assign(Descriptor.pArgumentDescs, Descriptor.NumArgumentDescs); wrapped->sig.graphics = true; wrapped->sig.numDraws = 0; @@ -2063,7 +2062,7 @@ HRESULT WrappedID3D12Device::CreateSharedHandle(ID3D12DeviceChild *pObject, template bool WrappedID3D12Device::Serialise_DynamicDescriptorCopies( - SerialiserType &ser, const std::vector &DescriptorCopies) + SerialiserType &ser, const rdcarray &DescriptorCopies) { SERIALISE_ELEMENT(DescriptorCopies); @@ -2107,7 +2106,7 @@ void WrappedID3D12Device::CopyDescriptors( D3D12Descriptor *src = GetWrapped(pSrcDescriptorRangeStarts[0]); D3D12Descriptor *dst = GetWrapped(pDestDescriptorRangeStarts[0]); - std::vector copies; + rdcarray copies; bool capframe = false; @@ -2188,7 +2187,7 @@ void WrappedID3D12Device::CopyDescriptors( { SCOPED_LOCK(m_DynDescLock); - m_DynamicDescriptorCopies.insert(m_DynamicDescriptorCopies.end(), copies.begin(), copies.end()); + m_DynamicDescriptorCopies.append(copies); for(size_t i = 0; i < copies.size(); i++) { copies[i].src->GetHeap()->AddRef(); @@ -2255,14 +2254,14 @@ void WrappedID3D12Device::CopyDescriptorsSimple(UINT NumDescriptors, GetResourceManager()->MarkResourceFrameReferenced(desc->GetHeapResourceId(), eFrameRef_Read); } - std::vector copies; + rdcarray copies; copies.reserve(NumDescriptors); for(UINT i = 0; i < NumDescriptors; i++) copies.push_back(DynamicDescriptorCopy(&dst[i], &src[i], DescriptorHeapsType)); { SCOPED_LOCK(m_DynDescLock); - m_DynamicDescriptorCopies.insert(m_DynamicDescriptorCopies.end(), copies.begin(), copies.end()); + m_DynamicDescriptorCopies.append(copies); for(size_t i = 0; i < copies.size(); i++) { copies[i].src->GetHeap()->AddRef(); @@ -2385,7 +2384,7 @@ bool WrappedID3D12Device::Serialise_OpenSharedHandle(SerialiserType &ser, HANDLE GetResourceManager()->AddLiveResource(resourceId, ret); SubresourceStateVector &states = m_ResourceStates[GetResID(ret)]; - states.resize(GetNumSubresources(m_pDevice, &desc), InitialResourceState); + states.fill(GetNumSubresources(m_pDevice, &desc), InitialResourceState); ResourceType type = ResourceType::Texture; const char *prefix = "Texture"; @@ -2557,7 +2556,7 @@ HRESULT WrappedID3D12Device::OpenSharedHandleInternal(D3D12Chunk chunkType, REFI SCOPED_LOCK(m_ResourceStatesLock); SubresourceStateVector &states = m_ResourceStates[wrapped->GetResourceID()]; - states.resize(GetNumSubresources(m_pDevice, &desc), InitialResourceState); + states.fill(GetNumSubresources(m_pDevice, &desc), InitialResourceState); } } @@ -2821,6 +2820,6 @@ INSTANTIATE_FUNCTION_SERIALISED(void, WrappedID3D12Device, CreateCommandSignatur ID3D12RootSignature *pRootSignature, REFIID riid, void **ppvCommandSignature); INSTANTIATE_FUNCTION_SERIALISED(void, WrappedID3D12Device, DynamicDescriptorCopies, - const std::vector &DescriptorCopies); + const rdcarray &DescriptorCopies); INSTANTIATE_FUNCTION_SERIALISED(void, WrappedID3D12Device, OpenSharedHandle, HANDLE NTHandle, REFIID riid, void **ppvObj); diff --git a/renderdoc/driver/d3d12/d3d12_device_wrap4.cpp b/renderdoc/driver/d3d12/d3d12_device_wrap4.cpp index 7937a9ac4..34e0c2bb9 100644 --- a/renderdoc/driver/d3d12/d3d12_device_wrap4.cpp +++ b/renderdoc/driver/d3d12/d3d12_device_wrap4.cpp @@ -270,7 +270,7 @@ bool WrappedID3D12Device::Serialise_CreateCommittedResource1( GetResourceManager()->AddLiveResource(pResource, ret); SubresourceStateVector &states = m_ResourceStates[GetResID(ret)]; - states.resize(GetNumSubresources(m_pDevice, &desc), InitialResourceState); + states.fill(GetNumSubresources(m_pDevice, &desc), InitialResourceState); ResourceType type = ResourceType::Texture; const char *prefix = "Texture"; @@ -375,7 +375,7 @@ HRESULT WrappedID3D12Device::CreateCommittedResource1( SCOPED_LOCK(m_ResourceStatesLock); SubresourceStateVector &states = m_ResourceStates[wrapped->GetResourceID()]; - states.resize(GetNumSubresources(m_pDevice, pDesc), InitialResourceState); + states.fill(GetNumSubresources(m_pDevice, pDesc), InitialResourceState); } *ppvResource = (ID3D12Resource *)wrapped; diff --git a/renderdoc/driver/d3d12/d3d12_initstate.cpp b/renderdoc/driver/d3d12/d3d12_initstate.cpp index f94e212db..3a0239290 100644 --- a/renderdoc/driver/d3d12/d3d12_initstate.cpp +++ b/renderdoc/driver/d3d12/d3d12_initstate.cpp @@ -107,8 +107,7 @@ bool D3D12ResourceManager::Prepare_InitialState(ID3D12DeviceChild *res) if(nonresident) m_Device->MakeResident(1, &pageable); - const std::vector &states = - m_Device->GetSubresourceStates(GetResID(res)); + const rdcarray &states = m_Device->GetSubresourceStates(GetResID(res)); RDCASSERT(states.size() == 1); D3D12_RESOURCE_BARRIER barrier; @@ -212,11 +211,10 @@ bool D3D12ResourceManager::Prepare_InitialState(ID3D12DeviceChild *res) ID3D12GraphicsCommandList *list = Unwrap(m_Device->GetInitialStateList()); - std::vector barriers; + rdcarray barriers; { - const std::vector &states = - m_Device->GetSubresourceStates(GetResID(r)); + const rdcarray &states = m_Device->GetSubresourceStates(GetResID(r)); barriers.reserve(states.size()); @@ -927,9 +925,9 @@ void D3D12ResourceManager::Apply_InitialState(ID3D12DeviceChild *live, ID3D12GraphicsCommandList *list = Unwrap(m_Device->GetInitialStateList()); - std::vector barriers; + rdcarray barriers; - const std::vector &states = + const rdcarray &states = m_Device->GetSubresourceStates(GetResID(live)); barriers.reserve(states.size()); diff --git a/renderdoc/driver/d3d12/d3d12_manager.cpp b/renderdoc/driver/d3d12/d3d12_manager.cpp index 8a9652a6a..3360ab724 100644 --- a/renderdoc/driver/d3d12/d3d12_manager.cpp +++ b/renderdoc/driver/d3d12/d3d12_manager.cpp @@ -649,7 +649,7 @@ D3D12Descriptor *DescriptorFromPortableHandle(D3D12ResourceManager *manager, Por #define BARRIER_ASSERT(...) #endif -void D3D12ResourceManager::ApplyBarriers(std::vector &barriers, +void D3D12ResourceManager::ApplyBarriers(rdcarray &barriers, std::map &states) { for(size_t b = 0; b < barriers.size(); b++) @@ -683,7 +683,7 @@ void D3D12ResourceManager::ApplyBarriers(std::vector &ba template void D3D12ResourceManager::SerialiseResourceStates(SerialiserType &ser, - std::vector &barriers, + rdcarray &barriers, std::map &states) { SERIALISE_ELEMENT_LOCAL(NumMems, (uint32_t)states.size()); @@ -720,22 +720,18 @@ void D3D12ResourceManager::SerialiseResourceStates(SerialiserType &ser, } // erase any do-nothing barriers - for(auto it = barriers.begin(); it != barriers.end();) - { - if(it->Transition.StateBefore == it->Transition.StateAfter) - it = barriers.erase(it); - else - ++it; - } + barriers.removeIf([](const D3D12_RESOURCE_BARRIER &barrier) { + return barrier.Transition.StateBefore == barrier.Transition.StateAfter; + }); ApplyBarriers(barriers, states); } template void D3D12ResourceManager::SerialiseResourceStates( - ReadSerialiser &ser, std::vector &barriers, + ReadSerialiser &ser, rdcarray &barriers, std::map &states); template void D3D12ResourceManager::SerialiseResourceStates( - WriteSerialiser &ser, std::vector &barriers, + WriteSerialiser &ser, rdcarray &barriers, std::map &states); void D3D12ResourceManager::SetInternalResource(ID3D12DeviceChild *res) @@ -766,26 +762,26 @@ void GPUAddressRangeTracker::AddTo(const GPUAddressRange &range) SCOPED_WRITELOCK(addressLock); auto it = std::lower_bound(addresses.begin(), addresses.end(), range.start); - addresses.insert(it, range); + addresses.insert(it - addresses.begin(), range); } void GPUAddressRangeTracker::RemoveFrom(const GPUAddressRange &range) { { SCOPED_WRITELOCK(addressLock); - auto it = std::lower_bound(addresses.begin(), addresses.end(), range.start); + size_t i = std::lower_bound(addresses.begin(), addresses.end(), range.start) - addresses.begin(); // there might be multiple buffers with the same range start, find the exact range for this // buffer - while(it != addresses.end() && it->start == range.start) + while(i < addresses.size() && addresses[i].start == range.start) { - if(it->id == range.id) + if(addresses[i].id == range.id) { - addresses.erase(it); + addresses.erase(i); return; } - ++it; + ++i; } } diff --git a/renderdoc/driver/d3d12/d3d12_manager.h b/renderdoc/driver/d3d12/d3d12_manager.h index 066500b34..7d7af6bc4 100644 --- a/renderdoc/driver/d3d12/d3d12_manager.h +++ b/renderdoc/driver/d3d12/d3d12_manager.h @@ -418,7 +418,7 @@ struct D3D12ResourceRecord; struct CmdListRecordingInfo { - std::vector barriers; + rdcarray barriers; // a list of all resources dirtied by this command list std::set dirtied; @@ -430,10 +430,10 @@ struct CmdListRecordingInfo // expand a bit more to contain duplicates and then deal with it during frame // capture, than to constantly be deduplicating during record (e.g. with a // set or sorted vector). - std::vector boundDescs; + rdcarray boundDescs; // bundles executed - std::vector bundles; + rdcarray bundles; }; class WrappedID3D12Resource1; @@ -459,7 +459,7 @@ struct GPUAddressRangeTracker GPUAddressRangeTracker(const GPUAddressRangeTracker &); GPUAddressRangeTracker &operator=(const GPUAddressRangeTracker &); - std::vector addresses; + rdcarray addresses; Threading::RWLock addressLock; void AddTo(const GPUAddressRange &range); @@ -472,6 +472,8 @@ struct MapState ID3D12Resource *res; UINT subres; UINT64 totalSize; + + bool operator==(const MapState &o) { return res == o.res && subres == o.subres; } }; struct D3D12ResourceRecord : public ResourceRecord @@ -524,7 +526,7 @@ struct D3D12ResourceRecord : public ResourceRecord Threading::CriticalSection m_MapLock; }; -typedef std::vector SubresourceStateVector; +typedef rdcarray SubresourceStateVector; struct D3D12InitialContents { @@ -638,11 +640,11 @@ public: return (T *)GetCurrentResource(id); } - void ApplyBarriers(std::vector &barriers, + void ApplyBarriers(rdcarray &barriers, std::map &states); template - void SerialiseResourceStates(SerialiserType &ser, std::vector &barriers, + void SerialiseResourceStates(SerialiserType &ser, rdcarray &barriers, std::map &states); template diff --git a/renderdoc/driver/d3d12/d3d12_overlay.cpp b/renderdoc/driver/d3d12/d3d12_overlay.cpp index 601fa8997..55fb8831d 100644 --- a/renderdoc/driver/d3d12/d3d12_overlay.cpp +++ b/renderdoc/driver/d3d12/d3d12_overlay.cpp @@ -214,7 +214,7 @@ ResourceId D3D12Replay::RenderOverlay(ResourceId texid, CompType typeCast, Float D3D12_RESOURCE_DESC resourceDesc = resource->GetDesc(); - std::vector barriers; + rdcarray barriers; int resType = 0; GetDebugManager()->PrepareTextureSampling(resource, typeCast, resType, barriers); @@ -305,10 +305,10 @@ ResourceId D3D12Replay::RenderOverlay(ResourceId texid, CompType typeCast, Float ID3D12GraphicsCommandList *list = m_pDevice->GetNewList(); - const std::vector &states = + const rdcarray &states = m_pDevice->GetSubresourceStates(GetResID(realDepth)); - std::vector depthBarriers; + rdcarray depthBarriers; depthBarriers.reserve(states.size()); for(size_t i = 0; i < states.size(); i++) { @@ -659,7 +659,7 @@ ResourceId D3D12Replay::RenderOverlay(ResourceId texid, CompType typeCast, Float list->Close(); list = NULL; - std::vector rts = rs.rts; + rdcarray rts = rs.rts; if(overlay == DebugOverlay::ClearBeforePass) m_pDevice->ReplayLog(0, events[0], eReplay_WithoutDraw); diff --git a/renderdoc/driver/d3d12/d3d12_postvs.cpp b/renderdoc/driver/d3d12/d3d12_postvs.cpp index 3d3be4948..c0a8392fd 100644 --- a/renderdoc/driver/d3d12/d3d12_postvs.cpp +++ b/renderdoc/driver/d3d12/d3d12_postvs.cpp @@ -249,7 +249,7 @@ void D3D12Replay::InitPostVSBuffers(uint32_t eventId) } } - std::vector sodecls; + rdcarray sodecls; UINT stride = 0; int posidx = -1; @@ -290,8 +290,8 @@ void D3D12Replay::InitPostVSBuffers(uint32_t eventId) if(posidx > 0) { D3D12_SO_DECLARATION_ENTRY pos = sodecls[posidx]; - sodecls.erase(sodecls.begin() + posidx); - sodecls.insert(sodecls.begin(), pos); + sodecls.erase(posidx); + sodecls.insert(0, pos); } // set up stream output entries and buffers @@ -399,7 +399,7 @@ void D3D12Replay::InitPostVSBuffers(uint32_t eventId) GetBufferData(rs.ibuffer.buf, rs.ibuffer.offs + drawcall->indexOffset * rs.ibuffer.bytewidth, RDCMIN(drawcall->numIndices * rs.ibuffer.bytewidth, rs.ibuffer.size), idxdata); - std::vector indices; + rdcarray indices; uint16_t *idx16 = (uint16_t *)&idxdata[0]; uint32_t *idx32 = (uint32_t *)&idxdata[0]; @@ -430,13 +430,13 @@ void D3D12Replay::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 @@ -817,8 +817,8 @@ void D3D12Replay::InitPostVSBuffers(uint32_t eventId) if(posidx > 0) { D3D12_SO_DECLARATION_ENTRY pos = sodecls[posidx]; - sodecls.erase(sodecls.begin() + posidx); - sodecls.insert(sodecls.begin(), pos); + sodecls.erase(posidx); + sodecls.insert(0, pos); } // enable the other shader stages again @@ -1137,7 +1137,7 @@ void D3D12Replay::InitPostVSBuffers(uint32_t eventId) uint64_t *counters = (uint64_t *)byteData; uint64_t numBytesWritten = 0; - std::vector instData; + rdcarray instData; if(drawcall->numInstances > 1) { uint64_t prevByteCount = 0; diff --git a/renderdoc/driver/d3d12/d3d12_rendermesh.cpp b/renderdoc/driver/d3d12/d3d12_rendermesh.cpp index 8bcda77ee..06194c147 100644 --- a/renderdoc/driver/d3d12/d3d12_rendermesh.cpp +++ b/renderdoc/driver/d3d12/d3d12_rendermesh.cpp @@ -796,7 +796,7 @@ void D3D12Replay::RenderMesh(uint32_t eventId, const rdcarray &secon if(!inactiveVertices.empty()) { - std::vector inactiveVB; + rdcarray inactiveVB; inactiveVB.reserve(inactiveVertices.size() * 4); for(size_t i = 0; i < inactiveVertices.size(); i++) diff --git a/renderdoc/driver/d3d12/d3d12_rendertext.cpp b/renderdoc/driver/d3d12/d3d12_rendertext.cpp index 4bec84532..a0f015a4a 100644 --- a/renderdoc/driver/d3d12/d3d12_rendertext.cpp +++ b/renderdoc/driver/d3d12/d3d12_rendertext.cpp @@ -116,7 +116,7 @@ D3D12TextRenderer::D3D12TextRenderer(WrappedID3D12Device *wrapper) rm->SetInternalResource(Tex); - std::string font = GetEmbeddedResource(sourcecodepro_ttf); + rdcstr font = GetEmbeddedResource(sourcecodepro_ttf); byte *ttfdata = (byte *)font.c_str(); const int firstChar = int(' ') + 1; @@ -288,7 +288,7 @@ D3D12TextRenderer::D3D12TextRenderer(WrappedID3D12Device *wrapper) ConstRingIdx = 0; - std::vector rootSig; + rdcarray rootSig; D3D12_ROOT_PARAMETER1 param = {}; // Constants @@ -356,7 +356,7 @@ D3D12TextRenderer::D3D12TextRenderer(WrappedID3D12Device *wrapper) SAFE_RELEASE(root); - std::string hlsl = GetEmbeddedResource(text_hlsl); + rdcstr hlsl = GetEmbeddedResource(text_hlsl); ID3DBlob *TextVS = NULL; ID3DBlob *TextPS = NULL; diff --git a/renderdoc/driver/d3d12/d3d12_rendertexture.cpp b/renderdoc/driver/d3d12/d3d12_rendertexture.cpp index 5a3a9c07d..47a02f604 100644 --- a/renderdoc/driver/d3d12/d3d12_rendertexture.cpp +++ b/renderdoc/driver/d3d12/d3d12_rendertexture.cpp @@ -35,7 +35,7 @@ void D3D12DebugManager::PrepareTextureSampling(ID3D12Resource *resource, CompType typeCast, int &resType, - std::vector &barriers) + rdcarray &barriers) { int srvOffset = 0; @@ -169,8 +169,7 @@ void D3D12DebugManager::PrepareTextureSampling(ID3D12Resource *resource, CompTyp } // transition resource to D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE - const std::vector &states = - m_pDevice->GetSubresourceStates(GetResID(resource)); + const rdcarray &states = m_pDevice->GetSubresourceStates(GetResID(resource)); barriers.reserve(states.size()); for(size_t i = 0; i < states.size(); i++) @@ -459,7 +458,7 @@ bool D3D12Replay::RenderTextureInternal(D3D12_CPU_DESCRIPTOR_HANDLE rtv, Texture pixelData.Slice = float( RDCCLAMP(cfg.subresource.slice, 0U, uint32_t(resourceDesc.DepthOrArraySize - 1)) + 0.001f); - std::vector barriers; + rdcarray barriers; int resType = 0; GetDebugManager()->PrepareTextureSampling(resource, cfg.typeCast, resType, barriers); diff --git a/renderdoc/driver/d3d12/d3d12_replay.cpp b/renderdoc/driver/d3d12/d3d12_replay.cpp index cb8c4f3e6..3be2b88e1 100644 --- a/renderdoc/driver/d3d12/d3d12_replay.cpp +++ b/renderdoc/driver/d3d12/d3d12_replay.cpp @@ -128,7 +128,7 @@ void D3D12Replay::Initialise(IDXGIFactory1 *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()); @@ -347,7 +347,7 @@ BufferDescription D3D12Replay::GetBuffer(ResourceId id) ret.creationFlags = BufferCategory::NoFlags; - const std::vector &usage = m_pDevice->GetQueue()->GetUsage(id); + const rdcarray &usage = m_pDevice->GetQueue()->GetUsage(id); for(size_t i = 0; i < usage.size(); i++) { @@ -560,13 +560,13 @@ rdcstr D3D12Replay::DisassembleShader(ResourceId pipeline, const ShaderReflectio } else return "; Unknown error fetching disassembly, invalid string returned\n\n\n" + - std::string(data, data + size); + rdcstr((char *)data, size); - std::string contents; + rdcstr contents; // decode the tags if(!strncmp((char *)iter, " @@ -602,9 +602,9 @@ rdcstr D3D12Replay::DisassembleShader(ResourceId pipeline, const ShaderReflectio idx += 10; // ", idx); + int32_t end = contents.find("]]>", idx); - if(end == std::string::npos) + if(end < 0) return "; Unknown error fetching disassembly, invalid string returned\n\n\n" + contents; return contents.substr(idx, end - idx); @@ -1895,7 +1895,7 @@ uint32_t D3D12Replay::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]; @@ -2033,7 +2033,7 @@ uint32_t D3D12Replay::PickVertex(uint32_t eventId, int32_t width, int32_t height m_pDevice->CreateShaderResourceView(NULL, &sdesc, GetDebugManager()->GetCPUHandle(PICK_VB_SRV)); } - std::vector vbData; + rdcarray vbData; vbData.resize(maxIndex + 1); byte *data = &oldData[0]; @@ -2300,7 +2300,7 @@ bool D3D12Replay::GetMinMax(ResourceId texid, const Subresource &sub, CompType t int blocksY = (int)ceil(cdata.HistogramTextureResolution.y / float(HGRAM_PIXELS_PER_TILE * HGRAM_TILES_PER_BLOCK)); - std::vector barriers; + rdcarray barriers; int resType = 0; GetDebugManager()->PrepareTextureSampling(resource, typeCast, resType, barriers); @@ -2496,7 +2496,7 @@ bool D3D12Replay::GetHistogram(ResourceId texid, const Subresource &sub, CompTyp int tilesY = (int)ceil(cdata.HistogramTextureResolution.y / float(HGRAM_PIXELS_PER_TILE * HGRAM_TILES_PER_BLOCK)); - std::vector barriers; + rdcarray barriers; int resType = 0; GetDebugManager()->PrepareTextureSampling(resource, typeCast, resType, barriers); @@ -2724,7 +2724,7 @@ void D3D12Replay::FillCBufferVariables(ResourceId pipeline, ResourceId shader, r const D3D12RenderState &rs = m_pDevice->GetQueue()->GetCommandData()->m_RenderState; WrappedID3D12RootSignature *sig = NULL; - const std::vector *sigElems = NULL; + const rdcarray *sigElems = NULL; if(refl.stage == ShaderStage::Compute && rs.compute.rootsig != ResourceId()) { @@ -2806,7 +2806,7 @@ void D3D12Replay::BuildShader(ShaderEncoding sourceEncoding, const bytebuf &sour return; } - std::string hlsl; + rdcstr hlsl; hlsl.assign((const char *)source.data(), source.size()); ID3DBlob *blob = NULL; @@ -2875,7 +2875,7 @@ void D3D12Replay::RefreshDerivedReplacements() // we defer deletes of old replaced resources since it will invalidate elements in the vector // we're iterating - std::vector deletequeue; + rdcarray deletequeue; for(WrappedID3D12PipelineState *pipe : m_pDevice->GetPipelineList()) { @@ -3196,9 +3196,9 @@ void D3D12Replay::GetTextureData(ResourceId tex, const Subresource &sub, list = m_pDevice->GetNewList(); // put source texture into resolve source state - const std::vector &states = m_pDevice->GetSubresourceStates(tex); + const rdcarray &states = m_pDevice->GetSubresourceStates(tex); - std::vector barriers; + rdcarray barriers; barriers.reserve(states.size()); for(size_t i = 0; i < states.size(); i++) { @@ -3264,9 +3264,9 @@ void D3D12Replay::GetTextureData(ResourceId tex, const Subresource &sub, list = m_pDevice->GetNewList(); // put source texture into shader read state - const std::vector &states = m_pDevice->GetSubresourceStates(tex); + const rdcarray &states = m_pDevice->GetSubresourceStates(tex); - std::vector barriers; + rdcarray barriers; barriers.reserve(states.size()); for(size_t i = 0; i < states.size(); i++) { @@ -3324,12 +3324,12 @@ void D3D12Replay::GetTextureData(ResourceId tex, const Subresource &sub, if(list == NULL) list = m_pDevice->GetNewList(); - std::vector barriers; + rdcarray barriers; // if we have no tmpImage, we're copying directly from the real image if(tmpTexture == NULL) { - const std::vector &states = m_pDevice->GetSubresourceStates(tex); + const rdcarray &states = m_pDevice->GetSubresourceStates(tex); barriers.reserve(states.size()); for(size_t i = 0; i < states.size(); i++) { diff --git a/renderdoc/driver/d3d12/d3d12_resources.cpp b/renderdoc/driver/d3d12/d3d12_resources.cpp index 91ad17a58..0686200fb 100644 --- a/renderdoc/driver/d3d12/d3d12_resources.cpp +++ b/renderdoc/driver/d3d12/d3d12_resources.cpp @@ -38,7 +38,7 @@ void WrappedID3D12Shader::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 = @@ -59,7 +59,7 @@ void WrappedID3D12Shader::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. @@ -73,7 +73,7 @@ void WrappedID3D12Shader::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"); } @@ -88,7 +88,7 @@ void WrappedID3D12Shader::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, @@ -96,7 +96,7 @@ void WrappedID3D12Shader::TryReplaceOriginalByteCode() if(lz4) { - std::vector decompressed; + rdcarray decompressed; // first try decompressing to 1MB flat decompressed.resize(100 * 1024); diff --git a/renderdoc/driver/d3d12/d3d12_resources.h b/renderdoc/driver/d3d12/d3d12_resources.h index 6906d20a2..6000ae9ed 100644 --- a/renderdoc/driver/d3d12/d3d12_resources.h +++ b/renderdoc/driver/d3d12/d3d12_resources.h @@ -301,7 +301,7 @@ public: else if(guid == WKPDID_D3DDebugObjectNameW) { rdcwstr wName((const wchar_t *)pData, DataSize / 2); - std::string sName = StringFormat::Wide2UTF8(wName); + rdcstr sName = StringFormat::Wide2UTF8(wName); m_pDevice->SetName(this, sName.c_str()); } @@ -321,7 +321,7 @@ public: HRESULT STDMETHODCALLTYPE SetName(LPCWSTR Name) { - std::string utf8 = Name ? StringFormat::Wide2UTF8(Name) : ""; + rdcstr utf8 = Name ? StringFormat::Wide2UTF8(Name) : ""; m_pDevice->SetName(this, utf8.c_str()); if(!m_pReal) @@ -682,8 +682,7 @@ public: ShaderEntry(const D3D12_SHADER_BYTECODE &byteCode, WrappedID3D12Device *device) : WrappedDeviceChild12(NULL, device), m_Key(byteCode) { - const byte *code = (const byte *)byteCode.pShaderBytecode; - m_Bytecode.assign(code, code + byteCode.BytecodeLength); + m_Bytecode.assign((const byte *)byteCode.pShaderBytecode, byteCode.BytecodeLength); m_DebugInfoSearchPaths = NULL; m_DXBCFile = NULL; @@ -736,7 +735,7 @@ public: } DXBCKey GetKey() { return m_Key; } - void SetDebugInfoPath(std::vector *searchPaths, const std::string &path) + void SetDebugInfoPath(rdcarray *searchPaths, const rdcstr &path) { m_DebugInfoSearchPaths = searchPaths; m_DebugInfoPath = path; @@ -784,10 +783,10 @@ public: DXBCKey m_Key; - std::string m_DebugInfoPath; - std::vector *m_DebugInfoSearchPaths; + rdcstr m_DebugInfoPath; + rdcarray *m_DebugInfoSearchPaths; - std::vector m_Bytecode; + rdcarray m_Bytecode; bool m_Built; DXBC::DXBCContainer *m_DXBCFile; @@ -817,8 +816,7 @@ public: virtual ~WrappedID3D12PipelineState() { if(IsReplayMode(m_pDevice->GetState())) - m_pDevice->GetPipelineList().erase(std::find(m_pDevice->GetPipelineList().begin(), - m_pDevice->GetPipelineList().end(), this)); + m_pDevice->GetPipelineList().removeOne(this); Shutdown(); diff --git a/renderdoc/driver/d3d12/d3d12_serialise.cpp b/renderdoc/driver/d3d12/d3d12_serialise.cpp index 5b093735d..996e65498 100644 --- a/renderdoc/driver/d3d12/d3d12_serialise.cpp +++ b/renderdoc/driver/d3d12/d3d12_serialise.cpp @@ -58,7 +58,7 @@ rdcstr DoStringise(const D3D12ComponentMapping &el) { RDCCOMPILE_ASSERT(sizeof(D3D12ComponentMapping) == sizeof(uint32_t), "Enum isn't uint sized"); - std::string ret; + rdcstr ret; // value should always be <= 5, see D3D12_SHADER_COMPONENT_MAPPING const char mapping[] = {'R', 'G', 'B', 'A', '0', '1', '?', '!'}; diff --git a/renderdoc/driver/d3d12/d3d12_shader_cache.cpp b/renderdoc/driver/d3d12/d3d12_shader_cache.cpp index 6740f7315..0133cdd0b 100644 --- a/renderdoc/driver/d3d12/d3d12_shader_cache.cpp +++ b/renderdoc/driver/d3d12/d3d12_shader_cache.cpp @@ -80,13 +80,13 @@ struct D3D12BlobShaderCallbacks struct EmbeddedD3D12Includer : 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; @@ -128,9 +128,9 @@ D3D12ShaderCache::~D3D12ShaderCache() } } -std::string D3D12ShaderCache::GetShaderBlob(const char *source, const char *entry, - const uint32_t compileFlags, const char *profile, - ID3DBlob **srcblob) +rdcstr D3D12ShaderCache::GetShaderBlob(const char *source, const char *entry, + const uint32_t compileFlags, const char *profile, + ID3DBlob **srcblob) { EmbeddedD3D12Includer includer; @@ -172,13 +172,13 @@ std::string D3D12ShaderCache::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) + "..."; @@ -270,8 +270,7 @@ D3D12RootSignature D3D12ShaderCache::GetRootSig(const void *data, size_t dataSiz if(desc->NumStaticSamplers > 0) { - ret.StaticSamplers.assign(desc->pStaticSamplers, - desc->pStaticSamplers + desc->NumStaticSamplers); + ret.StaticSamplers.assign(desc->pStaticSamplers, desc->NumStaticSamplers); for(size_t i = 0; i < ret.StaticSamplers.size(); i++) ret.maxSpaceIndex = RDCMAX(ret.maxSpaceIndex, ret.StaticSamplers[i].RegisterSpace + 1); @@ -329,7 +328,7 @@ D3D12RootSignature D3D12ShaderCache::GetRootSig(const void *data, size_t dataSiz if(desc->NumStaticSamplers > 0) { - ret.StaticSamplers.assign(desc->pStaticSamplers, desc->pStaticSamplers + desc->NumStaticSamplers); + ret.StaticSamplers.assign(desc->pStaticSamplers, desc->NumStaticSamplers); for(size_t i = 0; i < ret.StaticSamplers.size(); i++) ret.maxSpaceIndex = RDCMAX(ret.maxSpaceIndex, ret.StaticSamplers[i].RegisterSpace + 1); @@ -340,7 +339,7 @@ D3D12RootSignature D3D12ShaderCache::GetRootSig(const void *data, size_t dataSiz return ret; } -ID3DBlob *D3D12ShaderCache::MakeRootSig(const std::vector ¶ms, +ID3DBlob *D3D12ShaderCache::MakeRootSig(const rdcarray ¶ms, D3D12_ROOT_SIGNATURE_FLAGS Flags, UINT NumStaticSamplers, const D3D12_STATIC_SAMPLER_DESC *StaticSamplers) { @@ -368,7 +367,7 @@ ID3DBlob *D3D12ShaderCache::MakeRootSig(const std::vector desc.pStaticSamplers = StaticSamplers; desc.NumParameters = (UINT)params.size(); - std::vector params_1_0; + rdcarray params_1_0; params_1_0.resize(params.size()); for(size_t i = 0; i < params.size(); i++) { @@ -426,9 +425,9 @@ ID3DBlob *D3D12ShaderCache::MakeRootSig(const std::vector if(FAILED(hr)) { - std::string errors = (char *)errBlob->GetBufferPointer(); + rdcstr errors = (char *)errBlob->GetBufferPointer(); - std::string logerror = errors; + rdcstr logerror = errors; if(logerror.length() > 1024) logerror = logerror.substr(0, 1024) + "..."; @@ -460,9 +459,9 @@ ID3DBlob *D3D12ShaderCache::MakeRootSig(const std::vector if(FAILED(hr)) { - std::string errors = (char *)errBlob->GetBufferPointer(); + rdcstr errors = (char *)errBlob->GetBufferPointer(); - std::string logerror = errors; + rdcstr logerror = errors; if(logerror.length() > 1024) logerror = logerror.substr(0, 1024) + "..."; @@ -480,7 +479,7 @@ ID3DBlob *D3D12ShaderCache::MakeRootSig(const std::vector ID3DBlob *D3D12ShaderCache::MakeRootSig(const D3D12RootSignature &rootsig) { - std::vector params; + rdcarray params; params.resize(rootsig.Parameters.size()); for(size_t i = 0; i < params.size(); i++) params[i] = rootsig.Parameters[i]; @@ -492,7 +491,7 @@ ID3DBlob *D3D12ShaderCache::MakeRootSig(const D3D12RootSignature &rootsig) ID3DBlob *D3D12ShaderCache::MakeFixedColShader(float overlayConsts[4]) { ID3DBlob *ret = NULL; - std::string hlsl = + rdcstr hlsl = StringFormat::Fmt("float4 main() : SV_Target0 { return float4(%f, %f, %f, %f); }\n", overlayConsts[0], overlayConsts[1], overlayConsts[2], overlayConsts[3]); GetShaderBlob(hlsl.c_str(), "main", D3DCOMPILE_WARNINGS_ARE_ERRORS, "ps_5_0", &ret); diff --git a/renderdoc/driver/d3d12/d3d12_shader_cache.h b/renderdoc/driver/d3d12/d3d12_shader_cache.h index 189d003c5..776c778eb 100644 --- a/renderdoc/driver/d3d12/d3d12_shader_cache.h +++ b/renderdoc/driver/d3d12/d3d12_shader_cache.h @@ -38,11 +38,11 @@ public: D3D12ShaderCache(); ~D3D12ShaderCache(); - 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); D3D12RootSignature GetRootSig(const void *data, size_t dataSize); - ID3DBlob *MakeRootSig(const std::vector ¶ms, + ID3DBlob *MakeRootSig(const rdcarray ¶ms, D3D12_ROOT_SIGNATURE_FLAGS Flags = D3D12_ROOT_SIGNATURE_FLAG_NONE, UINT NumStaticSamplers = 0, const D3D12_STATIC_SAMPLER_DESC *StaticSamplers = NULL); diff --git a/renderdoc/driver/d3d12/d3d12_shaderdebug.cpp b/renderdoc/driver/d3d12/d3d12_shaderdebug.cpp index 57ef40fac..0ca46df03 100644 --- a/renderdoc/driver/d3d12/d3d12_shaderdebug.cpp +++ b/renderdoc/driver/d3d12/d3d12_shaderdebug.cpp @@ -136,7 +136,7 @@ bool D3D12DebugAPIWrapper::CalculateSampleGather( D3D12MarkerRegion region(m_pDevice->GetQueue()->GetReal(), "CalculateSampleGather"); - 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 || @@ -146,13 +146,13 @@ bool D3D12DebugAPIWrapper::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; @@ -385,17 +385,17 @@ bool D3D12DebugAPIWrapper::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; - std::string offsets = ""; + rdcstr sampleIdx = buf; + rdcstr offsets = ""; if(useOffsets) { @@ -412,13 +412,13 @@ bool D3D12DebugAPIWrapper::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; @@ -427,11 +427,11 @@ bool D3D12DebugAPIWrapper::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; UINT texSlot = resourceData.slot; UINT sampSlot = samplerData.slot; @@ -460,7 +460,7 @@ bool D3D12DebugAPIWrapper::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 + @@ -471,19 +471,19 @@ bool D3D12DebugAPIWrapper::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 += "}"; @@ -1052,10 +1052,10 @@ ShaderDebugTrace D3D12Replay::DebugPixel(uint32_t eventId, uint32_t x, uint32_t prevDxbc = vs->GetDXBC(); } - std::vector initialValues; - std::vector floatInputs; - std::vector inputVarNames; - std::string extractHlsl; + rdcarray initialValues; + rdcarray floatInputs; + rdcarray inputVarNames; + rdcstr extractHlsl; int structureStride = 0; ShaderDebug::GatherPSInputDataForInitialValues(*dxbc->GetReflection(), *prevDxbc->GetReflection(), @@ -1125,7 +1125,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"; @@ -1501,7 +1501,7 @@ void ExtractInputsPS(PSInput IN, float4 debug_pixelPos : SV_Position, uint prim ApplyAllDerivatives(global, traces, destIdx, initialValues, (float *)data); } - std::vector states; + rdcarray states; if(dxbc->GetDebugInfo()) dxbc->GetDebugInfo()->GetLocals(0, dxbc->GetDXBCByteCode()->GetInstruction(0).offset, diff --git a/renderdoc/driver/d3d12/d3d12_state.cpp b/renderdoc/driver/d3d12/d3d12_state.cpp index da261e0b2..d2dec8bad 100644 --- a/renderdoc/driver/d3d12/d3d12_state.cpp +++ b/renderdoc/driver/d3d12/d3d12_state.cpp @@ -55,9 +55,9 @@ D3D12RenderState &D3D12RenderState::operator=(const D3D12RenderState &o) return *this; } -std::vector D3D12RenderState::GetRTVIDs() const +rdcarray D3D12RenderState::GetRTVIDs() const { - std::vector ret; + rdcarray ret; for(UINT i = 0; i < rts.size(); i++) { @@ -178,7 +178,7 @@ void D3D12RenderState::ApplyState(WrappedID3D12Device *dev, ID3D12GraphicsComman void D3D12RenderState::ApplyDescriptorHeaps(ID3D12GraphicsCommandListX *cmd) const { - std::vector descHeaps; + rdcarray descHeaps; descHeaps.resize(heaps.size()); for(size_t i = 0; i < heaps.size(); i++) @@ -194,8 +194,7 @@ void D3D12RenderState::ApplyComputeRootElements(ID3D12GraphicsCommandListX *cmd) { // just don't set tables that aren't in the descriptor heaps, since it's invalid and can crash // and is probably just from stale bindings that aren't going to be used - if(compute.sigelems[i].type != eRootTable || - std::find(heaps.begin(), heaps.end(), compute.sigelems[i].id) != heaps.end()) + if(compute.sigelems[i].type != eRootTable || heaps.contains(compute.sigelems[i].id)) { compute.sigelems[i].SetToCompute(GetResourceManager(), cmd, (UINT)i); } @@ -213,8 +212,7 @@ void D3D12RenderState::ApplyGraphicsRootElements(ID3D12GraphicsCommandListX *cmd { // just don't set tables that aren't in the descriptor heaps, since it's invalid and can crash // and is probably just from stale bindings that aren't going to be used - if(graphics.sigelems[i].type != eRootTable || - std::find(heaps.begin(), heaps.end(), graphics.sigelems[i].id) != heaps.end()) + if(graphics.sigelems[i].type != eRootTable || heaps.contains(graphics.sigelems[i].id)) { graphics.sigelems[i].SetToGraphics(GetResourceManager(), cmd, (UINT)i); } diff --git a/renderdoc/driver/d3d12/d3d12_state.h b/renderdoc/driver/d3d12/d3d12_state.h index bbd4eef96..091713e1b 100644 --- a/renderdoc/driver/d3d12/d3d12_state.h +++ b/renderdoc/driver/d3d12/d3d12_state.h @@ -51,20 +51,20 @@ struct D3D12RenderState void ApplyComputeRootElements(ID3D12GraphicsCommandListX *cmd) const; void ApplyGraphicsRootElements(ID3D12GraphicsCommandListX *cmd) const; - std::vector views; - std::vector scissors; + rdcarray views; + rdcarray scissors; // these are D3D12Descriptor copies since the values of the descriptors are read during // OMSetRenderTargets and may not exist anywhere after that if they are immediately overwritten. - std::vector rts; + rdcarray rts; D3D12Descriptor dsv; bool renderpass = false; - std::vector rpRTs; + rdcarray rpRTs; D3D12_RENDER_PASS_DEPTH_STENCIL_DESC rpDSV; D3D12_RENDER_PASS_FLAGS rpFlags; - std::vector GetRTVIDs() const; + rdcarray GetRTVIDs() const; ResourceId GetDSVID() const; ResourceId shadingRateImage; @@ -150,10 +150,10 @@ struct D3D12RenderState ResourceId id; UINT64 offset; - std::vector constants; + rdcarray constants; }; - std::vector heaps; + rdcarray heaps; struct StreamOut { @@ -164,13 +164,13 @@ struct D3D12RenderState ResourceId countbuf; UINT64 countoffs; }; - std::vector streamouts; + rdcarray streamouts; struct RootSignature { ResourceId rootsig; - std::vector sigelems; + rdcarray sigelems; } compute, graphics; ResourceId pipe; @@ -180,7 +180,7 @@ struct D3D12RenderState struct SamplePositions { UINT NumSamplesPerPixel, NumPixels; - std::vector Positions; + rdcarray Positions; } samplePos; D3D12_PRIMITIVE_TOPOLOGY topo = D3D_PRIMITIVE_TOPOLOGY_UNDEFINED; @@ -204,7 +204,7 @@ struct D3D12RenderState UINT stride; UINT size; }; - std::vector vbuffers; + rdcarray vbuffers; D3D12ResourceManager *GetResourceManager() const { return m_ResourceManager; } D3D12ResourceManager *m_ResourceManager = NULL;