diff --git a/renderdoc/core/image_viewer.cpp b/renderdoc/core/image_viewer.cpp index 7140788d4..e8234be34 100644 --- a/renderdoc/core/image_viewer.cpp +++ b/renderdoc/core/image_viewer.cpp @@ -169,8 +169,8 @@ public: m_CustomTexID = m_Proxy->ApplyCustomShader(shader, m_TextureID, sub, typeCast); return m_CustomTexID; } - const rdcarray &GetResources() { return m_Resources; } - rdcarray GetTextures() { return {m_TextureID}; } + rdcarray GetResources() { return m_Resources; } + rdcarray GetTextures() { return {m_TexDetails}; } TextureDescription GetTexture(ResourceId id) { return m_TexDetails; } void GetTextureData(ResourceId tex, const Subresource &sub, const GetTextureDataParams ¶ms, bytebuf &data) @@ -191,7 +191,7 @@ public: void RenderMesh(uint32_t eventId, const rdcarray &secondaryDraws, const MeshDisplay &cfg) { } - rdcarray GetBuffers() { return rdcarray(); } + rdcarray GetBuffers() { return {}; } rdcarray GetDebugMessages() { return rdcarray(); } BufferDescription GetBuffer(ResourceId id) { diff --git a/renderdoc/core/replay_proxy.cpp b/renderdoc/core/replay_proxy.cpp index 434a3bd2a..336d2241e 100644 --- a/renderdoc/core/replay_proxy.cpp +++ b/renderdoc/core/replay_proxy.cpp @@ -386,12 +386,12 @@ rdcarray ReplayProxy::GetDebugMessages() } template -rdcarray ReplayProxy::Proxied_GetTextures(ParamSerialiser ¶mser, - ReturnSerialiser &retser) +rdcarray ReplayProxy::Proxied_GetTextures(ParamSerialiser ¶mser, + ReturnSerialiser &retser) { const ReplayProxyPacket expectedPacket = eReplayProxy_GetTextures; ReplayProxyPacket packet = eReplayProxy_GetTextures; - rdcarray ret; + rdcarray ret; { BEGIN_PARAMS(); @@ -406,10 +406,16 @@ rdcarray ReplayProxy::Proxied_GetTextures(ParamSerialiser ¶mser, SERIALISE_RETURN(ret); + if(retser.IsReading()) + { + for(const TextureDescription &tex : ret) + m_TextureInfo[tex.resourceId] = tex; + } + return ret; } -rdcarray ReplayProxy::GetTextures() +rdcarray ReplayProxy::GetTextures() { PROXY_FUNCTION(GetTextures); } @@ -448,12 +454,12 @@ TextureDescription ReplayProxy::GetTexture(ResourceId id) } template -rdcarray ReplayProxy::Proxied_GetBuffers(ParamSerialiser ¶mser, - ReturnSerialiser &retser) +rdcarray ReplayProxy::Proxied_GetBuffers(ParamSerialiser ¶mser, + ReturnSerialiser &retser) { const ReplayProxyPacket expectedPacket = eReplayProxy_GetBuffers; ReplayProxyPacket packet = eReplayProxy_GetBuffers; - rdcarray ret; + rdcarray ret; { BEGIN_PARAMS(); @@ -471,17 +477,18 @@ rdcarray ReplayProxy::Proxied_GetBuffers(ParamSerialiser ¶mser, return ret; } -rdcarray ReplayProxy::GetBuffers() +rdcarray ReplayProxy::GetBuffers() { PROXY_FUNCTION(GetBuffers); } template -const rdcarray &ReplayProxy::Proxied_GetResources(ParamSerialiser ¶mser, - ReturnSerialiser &retser) +rdcarray ReplayProxy::Proxied_GetResources(ParamSerialiser ¶mser, + ReturnSerialiser &retser) { const ReplayProxyPacket expectedPacket = eReplayProxy_GetResources; ReplayProxyPacket packet = eReplayProxy_GetResources; + rdcarray ret; { BEGIN_PARAMS(); @@ -491,15 +498,15 @@ const rdcarray &ReplayProxy::Proxied_GetResources(ParamSeri { REMOTE_EXECUTION(); if(paramser.IsReading() && !paramser.IsErrored() && !m_IsErrored) - m_Resources = m_Remote->GetResources(); + ret = m_Remote->GetResources(); } - SERIALISE_RETURN(m_Resources); + SERIALISE_RETURN(ret); - return m_Resources; + return ret; } -const rdcarray &ReplayProxy::GetResources() +rdcarray ReplayProxy::GetResources() { PROXY_FUNCTION(GetResources); } @@ -2798,7 +2805,8 @@ bool ReplayProxy::Tick(int type) PROXY_DEBUG("Processed %s", ToStr(packet).c_str()); - RefreshPreviewWindow(); + if(packet == eReplayProxy_ReplayLog) + RefreshPreviewWindow(); if(CheckError(packet, packet)) return false; diff --git a/renderdoc/core/replay_proxy.h b/renderdoc/core/replay_proxy.h index 92cd88f69..f0c19a8a8 100644 --- a/renderdoc/core/replay_proxy.h +++ b/renderdoc/core/replay_proxy.h @@ -460,12 +460,12 @@ public: const SDFile &GetStructuredFile() { return m_StructuredFile; } IMPLEMENT_FUNCTION_PROXIED(void, FetchStructuredFile); - IMPLEMENT_FUNCTION_PROXIED(const rdcarray &, GetResources); + IMPLEMENT_FUNCTION_PROXIED(rdcarray, GetResources); - IMPLEMENT_FUNCTION_PROXIED(rdcarray, GetBuffers); + IMPLEMENT_FUNCTION_PROXIED(rdcarray, GetBuffers); IMPLEMENT_FUNCTION_PROXIED(BufferDescription, GetBuffer, ResourceId id); - IMPLEMENT_FUNCTION_PROXIED(rdcarray, GetTextures); + IMPLEMENT_FUNCTION_PROXIED(rdcarray, GetTextures); IMPLEMENT_FUNCTION_PROXIED(TextureDescription, GetTexture, ResourceId id); IMPLEMENT_FUNCTION_PROXIED(APIProperties, GetAPIProperties); @@ -715,8 +715,6 @@ private: SDFile m_StructuredFile; - rdcarray m_Resources; - D3D11Pipe::State m_D3D11PipelineState; D3D12Pipe::State m_D3D12PipelineState; GLPipe::State m_GLPipelineState; diff --git a/renderdoc/driver/d3d11/d3d11_debug.h b/renderdoc/driver/d3d11/d3d11_debug.h index af281cee5..cdeb52771 100644 --- a/renderdoc/driver/d3d11/d3d11_debug.h +++ b/renderdoc/driver/d3d11/d3d11_debug.h @@ -111,10 +111,20 @@ public: return it->second; return NULL; } - void GetCounterBuffers(rdcarray &ret) + void GetCounterBuffers(rdcarray &ret) { for(auto pair : m_CounterBufferToUAV) - ret.push_back(pair.first); + { + BufferDescription buf; + + // no original ID for this one + buf.resourceId = pair.first; + buf.length = 4; + buf.gpuAddress = 0; + buf.creationFlags = BufferCategory::ReadWrite; + + ret.push_back(buf); + } } uint32_t GetStructCount(ID3D11UnorderedAccessView *uav); diff --git a/renderdoc/driver/d3d11/d3d11_device.cpp b/renderdoc/driver/d3d11/d3d11_device.cpp index 7e834aef4..92a688d48 100644 --- a/renderdoc/driver/d3d11/d3d11_device.cpp +++ b/renderdoc/driver/d3d11/d3d11_device.cpp @@ -1338,16 +1338,16 @@ ReplayStatus WrappedID3D11Device::ReadLogInitialisation(RDCFile *rdc, bool store SetupDrawcallPointers(m_Drawcalls, GetReplay()->WriteFrameRecord().drawcallList); // propagate any UAV names onto counter buffers - rdcarray counterBuffers; + rdcarray counterBuffers; GetDebugManager()->GetCounterBuffers(counterBuffers); - for(ResourceId buffId : counterBuffers) + for(const BufferDescription &b : counterBuffers) { - ID3D11UnorderedAccessView *uav = GetDebugManager()->GetCounterBufferUAV(buffId); + ID3D11UnorderedAccessView *uav = GetDebugManager()->GetCounterBufferUAV(b.resourceId); ResourceId uavId = GetResourceManager()->GetOriginalID(GetIDForResource(uav)); ResourceDescription &uavDesc = GetReplay()->GetResourceDesc(uavId); - ResourceDescription &bufDesc = GetReplay()->GetResourceDesc(buffId); + ResourceDescription &bufDesc = GetReplay()->GetResourceDesc(b.resourceId); if(uavDesc.autogeneratedName) { diff --git a/renderdoc/driver/d3d11/d3d11_replay.cpp b/renderdoc/driver/d3d11/d3d11_replay.cpp index a1ebf1a80..7d936b634 100644 --- a/renderdoc/driver/d3d11/d3d11_replay.cpp +++ b/renderdoc/driver/d3d11/d3d11_replay.cpp @@ -255,6 +255,195 @@ void D3D11Replay::DestroyResources() SAFE_RELEASE(m_pFactory); } +rdcarray D3D11Replay::GetShaderEntryPoints(ResourceId shader) +{ + auto it = WrappedShader::m_ShaderList.find(shader); + + if(it == WrappedShader::m_ShaderList.end()) + return {}; + + ShaderReflection &ret = it->second->GetDetails(); + + return {{"main", ret.stage}}; +} + +ShaderReflection *D3D11Replay::GetShader(ResourceId pipeline, ResourceId shader, + ShaderEntryPoint entry) +{ + auto it = WrappedShader::m_ShaderList.find(shader); + + if(it == WrappedShader::m_ShaderList.end()) + return NULL; + + ShaderReflection &ret = it->second->GetDetails(); + + return &ret; +} + +rdcarray D3D11Replay::GetDisassemblyTargets() +{ + return {DXBCDisassemblyTarget}; +} + +rdcstr D3D11Replay::DisassembleShader(ResourceId pipeline, const ShaderReflection *refl, + const rdcstr &target) +{ + auto it = + WrappedShader::m_ShaderList.find(m_pDevice->GetResourceManager()->GetLiveID(refl->resourceId)); + + if(it == WrappedShader::m_ShaderList.end()) + return "; Invalid Shader Specified"; + + DXBC::DXBCContainer *dxbc = it->second->GetDXBC(); + + if(target == DXBCDisassemblyTarget || target.empty()) + return dxbc->GetDisassembly(); + + return StringFormat::Fmt("; Invalid disassembly target %s", target.c_str()); +} + +void D3D11Replay::FreeTargetResource(ResourceId id) +{ + if(m_pDevice->GetResourceManager()->HasLiveResource(id)) + { + ID3D11DeviceChild *resource = m_pDevice->GetResourceManager()->GetLiveResource(id); + + SAFE_RELEASE(resource); + } +} + +void D3D11Replay::FreeCustomShader(ResourceId id) +{ + if(m_pDevice->GetResourceManager()->HasLiveResource(id)) + { + ID3D11DeviceChild *resource = m_pDevice->GetResourceManager()->GetLiveResource(id); + + SAFE_RELEASE(resource); + } +} + +rdcarray D3D11Replay::GetUsage(ResourceId id) +{ + return m_pDevice->GetImmediateContext()->GetUsage(id); +} + +rdcarray D3D11Replay::GetDebugMessages() +{ + return m_pDevice->GetDebugMessages(); +} + +rdcarray D3D11Replay::GetAvailableGPUs() +{ + rdcarray ret; + + for(UINT i = 0; i < 10; i++) + { + IDXGIAdapter *adapter = NULL; + + HRESULT hr = m_pFactory->EnumAdapters(i, &adapter); + + if(SUCCEEDED(hr) && adapter) + { + DXGI_ADAPTER_DESC desc; + adapter->GetDesc(&desc); + + GPUDevice dev; + dev.vendor = GPUVendorFromPCIVendor(desc.VendorId); + dev.deviceID = desc.DeviceId; + dev.driver = ""; // D3D doesn't have multiple drivers per API + dev.name = StringFormat::Wide2UTF8(desc.Description); + dev.apis = {GraphicsAPI::D3D11}; + + // don't add duplicate devices even if they get enumerated. Don't add WARP, we'll do that + // manually since it's inconsistently enumerated + if(ret.indexOf(dev) == -1 && dev.vendor != GPUVendor::Software) + ret.push_back(dev); + } + + SAFE_RELEASE(adapter); + } + + { + GPUDevice dev; + dev.vendor = GPUVendor::Software; + dev.deviceID = 0; + dev.driver = ""; // D3D doesn't have multiple drivers per API + dev.name = "WARP Rasterizer"; + dev.apis = {GraphicsAPI::D3D11}; + ret.push_back(dev); + } + + return ret; +} + +APIProperties D3D11Replay::GetAPIProperties() +{ + APIProperties ret = m_pDevice->APIProps; + + ret.pipelineType = GraphicsAPI::D3D11; + ret.localRenderer = GraphicsAPI::D3D11; + ret.vendor = m_DriverInfo.vendor; + ret.degraded = m_WARP; + ret.shadersMutable = false; + ret.shaderDebugging = true; + ret.pixelHistory = true; + + return ret; +} + +ResourceDescription &D3D11Replay::GetResourceDesc(ResourceId id) +{ + auto it = m_ResourceIdx.find(id); + if(it == m_ResourceIdx.end()) + { + m_ResourceIdx[id] = m_Resources.size(); + m_Resources.push_back(ResourceDescription()); + m_Resources.back().resourceId = id; + return m_Resources.back(); + } + + return m_Resources[it->second]; +} + +rdcarray D3D11Replay::GetResources() +{ + return m_Resources; +} + +BufferDescription D3D11Replay::GetBuffer(ResourceId id) +{ + BufferDescription ret = {}; + ret.resourceId = ResourceId(); + + auto it = WrappedID3D11Buffer::m_BufferList.find(id); + + if(it == WrappedID3D11Buffer::m_BufferList.end()) + return ret; + + WrappedID3D11Buffer *d3dbuf = it->second.m_Buffer; + + rdcstr str = GetDebugName(d3dbuf); + + ret.resourceId = m_pDevice->GetResourceManager()->GetOriginalID(it->first); + + D3D11_BUFFER_DESC desc; + it->second.m_Buffer->GetDesc(&desc); + + ret.length = desc.ByteWidth; + + ret.creationFlags = BufferCategory::NoFlags; + if(desc.BindFlags & D3D11_BIND_VERTEX_BUFFER) + ret.creationFlags |= BufferCategory::Vertex; + if(desc.BindFlags & D3D11_BIND_INDEX_BUFFER) + ret.creationFlags |= BufferCategory::Index; + if(desc.BindFlags & D3D11_BIND_UNORDERED_ACCESS) + ret.creationFlags |= BufferCategory::ReadWrite; + if(desc.MiscFlags & D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS) + ret.creationFlags |= BufferCategory::Indirect; + + return ret; +} + TextureDescription D3D11Replay::GetTexture(ResourceId id) { TextureDescription tex = {}; @@ -431,164 +620,9 @@ TextureDescription D3D11Replay::GetTexture(ResourceId id) return tex; } -rdcarray D3D11Replay::GetShaderEntryPoints(ResourceId shader) +rdcarray D3D11Replay::GetBuffers() { - auto it = WrappedShader::m_ShaderList.find(shader); - - if(it == WrappedShader::m_ShaderList.end()) - return {}; - - ShaderReflection &ret = it->second->GetDetails(); - - return {{"main", ret.stage}}; -} - -ShaderReflection *D3D11Replay::GetShader(ResourceId pipeline, ResourceId shader, - ShaderEntryPoint entry) -{ - auto it = WrappedShader::m_ShaderList.find(shader); - - if(it == WrappedShader::m_ShaderList.end()) - return NULL; - - ShaderReflection &ret = it->second->GetDetails(); - - return &ret; -} - -rdcarray D3D11Replay::GetDisassemblyTargets() -{ - return {DXBCDisassemblyTarget}; -} - -rdcstr D3D11Replay::DisassembleShader(ResourceId pipeline, const ShaderReflection *refl, - const rdcstr &target) -{ - auto it = - WrappedShader::m_ShaderList.find(m_pDevice->GetResourceManager()->GetLiveID(refl->resourceId)); - - if(it == WrappedShader::m_ShaderList.end()) - return "; Invalid Shader Specified"; - - DXBC::DXBCContainer *dxbc = it->second->GetDXBC(); - - if(target == DXBCDisassemblyTarget || target.empty()) - return dxbc->GetDisassembly(); - - return StringFormat::Fmt("; Invalid disassembly target %s", target.c_str()); -} - -void D3D11Replay::FreeTargetResource(ResourceId id) -{ - if(m_pDevice->GetResourceManager()->HasLiveResource(id)) - { - ID3D11DeviceChild *resource = m_pDevice->GetResourceManager()->GetLiveResource(id); - - SAFE_RELEASE(resource); - } -} - -void D3D11Replay::FreeCustomShader(ResourceId id) -{ - if(m_pDevice->GetResourceManager()->HasLiveResource(id)) - { - ID3D11DeviceChild *resource = m_pDevice->GetResourceManager()->GetLiveResource(id); - - SAFE_RELEASE(resource); - } -} - -rdcarray D3D11Replay::GetUsage(ResourceId id) -{ - return m_pDevice->GetImmediateContext()->GetUsage(id); -} - -rdcarray D3D11Replay::GetDebugMessages() -{ - return m_pDevice->GetDebugMessages(); -} - -rdcarray D3D11Replay::GetAvailableGPUs() -{ - rdcarray ret; - - for(UINT i = 0; i < 10; i++) - { - IDXGIAdapter *adapter = NULL; - - HRESULT hr = m_pFactory->EnumAdapters(i, &adapter); - - if(SUCCEEDED(hr) && adapter) - { - DXGI_ADAPTER_DESC desc; - adapter->GetDesc(&desc); - - GPUDevice dev; - dev.vendor = GPUVendorFromPCIVendor(desc.VendorId); - dev.deviceID = desc.DeviceId; - dev.driver = ""; // D3D doesn't have multiple drivers per API - dev.name = StringFormat::Wide2UTF8(desc.Description); - dev.apis = {GraphicsAPI::D3D11}; - - // don't add duplicate devices even if they get enumerated. Don't add WARP, we'll do that - // manually since it's inconsistently enumerated - if(ret.indexOf(dev) == -1 && dev.vendor != GPUVendor::Software) - ret.push_back(dev); - } - - SAFE_RELEASE(adapter); - } - - { - GPUDevice dev; - dev.vendor = GPUVendor::Software; - dev.deviceID = 0; - dev.driver = ""; // D3D doesn't have multiple drivers per API - dev.name = "WARP Rasterizer"; - dev.apis = {GraphicsAPI::D3D11}; - ret.push_back(dev); - } - - return ret; -} - -APIProperties D3D11Replay::GetAPIProperties() -{ - APIProperties ret = m_pDevice->APIProps; - - ret.pipelineType = GraphicsAPI::D3D11; - ret.localRenderer = GraphicsAPI::D3D11; - ret.vendor = m_DriverInfo.vendor; - ret.degraded = m_WARP; - ret.shadersMutable = false; - ret.shaderDebugging = true; - ret.pixelHistory = true; - - return ret; -} - -ResourceDescription &D3D11Replay::GetResourceDesc(ResourceId id) -{ - auto it = m_ResourceIdx.find(id); - if(it == m_ResourceIdx.end()) - { - m_ResourceIdx[id] = m_Resources.size(); - m_Resources.push_back(ResourceDescription()); - m_Resources.back().resourceId = id; - return m_Resources.back(); - } - - return m_Resources[it->second]; -} - -const rdcarray &D3D11Replay::GetResources() -{ - return m_Resources; -} - -rdcarray D3D11Replay::GetBuffers() -{ - rdcarray ret; + rdcarray ret; ret.reserve(WrappedID3D11Buffer::m_BufferList.size()); @@ -599,7 +633,7 @@ rdcarray D3D11Replay::GetBuffers() if(m_pDevice->GetResourceManager()->GetOriginalID(it->first) == it->first) continue; - ret.push_back(it->first); + ret.push_back(GetBuffer(it->first)); } GetDebugManager()->GetCounterBuffers(ret); @@ -607,53 +641,9 @@ rdcarray D3D11Replay::GetBuffers() return ret; } -BufferDescription D3D11Replay::GetBuffer(ResourceId id) +rdcarray D3D11Replay::GetTextures() { - BufferDescription ret = {}; - ret.resourceId = ResourceId(); - - if(GetDebugManager()->GetCounterBufferUAV(id)) - { - // no original ID for this one - ret.resourceId = id; - ret.length = 4; - ret.gpuAddress = 0; - ret.creationFlags = BufferCategory::ReadWrite; - return ret; - } - - auto it = WrappedID3D11Buffer::m_BufferList.find(id); - - if(it == WrappedID3D11Buffer::m_BufferList.end()) - return ret; - - WrappedID3D11Buffer *d3dbuf = it->second.m_Buffer; - - rdcstr str = GetDebugName(d3dbuf); - - ret.resourceId = m_pDevice->GetResourceManager()->GetOriginalID(it->first); - - D3D11_BUFFER_DESC desc; - it->second.m_Buffer->GetDesc(&desc); - - ret.length = desc.ByteWidth; - - ret.creationFlags = BufferCategory::NoFlags; - if(desc.BindFlags & D3D11_BIND_VERTEX_BUFFER) - ret.creationFlags |= BufferCategory::Vertex; - if(desc.BindFlags & D3D11_BIND_INDEX_BUFFER) - ret.creationFlags |= BufferCategory::Index; - if(desc.BindFlags & D3D11_BIND_UNORDERED_ACCESS) - ret.creationFlags |= BufferCategory::ReadWrite; - if(desc.MiscFlags & D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS) - ret.creationFlags |= BufferCategory::Indirect; - - return ret; -} - -rdcarray D3D11Replay::GetTextures() -{ - rdcarray ret; + rdcarray ret; ret.reserve(WrappedID3D11Texture1D::m_TextureList.size() + WrappedID3D11Texture2D1::m_TextureList.size() + @@ -666,7 +656,7 @@ rdcarray D3D11Replay::GetTextures() if(m_pDevice->GetResourceManager()->GetOriginalID(it->first) == it->first) continue; - ret.push_back(it->first); + ret.push_back(GetTexture(it->first)); } for(auto it = WrappedID3D11Texture2D1::m_TextureList.begin(); @@ -676,7 +666,7 @@ rdcarray D3D11Replay::GetTextures() if(m_pDevice->GetResourceManager()->GetOriginalID(it->first) == it->first) continue; - ret.push_back(it->first); + ret.push_back(GetTexture(it->first)); } for(auto it = WrappedID3D11Texture3D1::m_TextureList.begin(); @@ -686,7 +676,7 @@ rdcarray D3D11Replay::GetTextures() if(m_pDevice->GetResourceManager()->GetOriginalID(it->first) == it->first) continue; - ret.push_back(it->first); + ret.push_back(GetTexture(it->first)); } return ret; diff --git a/renderdoc/driver/d3d11/d3d11_replay.h b/renderdoc/driver/d3d11/d3d11_replay.h index 9340179d1..659c72c4c 100644 --- a/renderdoc/driver/d3d11/d3d11_replay.h +++ b/renderdoc/driver/d3d11/d3d11_replay.h @@ -117,12 +117,12 @@ public: APIProperties GetAPIProperties(); ResourceDescription &GetResourceDesc(ResourceId id); - const rdcarray &GetResources(); + rdcarray GetResources(); - rdcarray GetBuffers(); + rdcarray GetBuffers(); BufferDescription GetBuffer(ResourceId id); - rdcarray GetTextures(); + rdcarray GetTextures(); TextureDescription GetTexture(ResourceId id); rdcarray GetDebugMessages(); diff --git a/renderdoc/driver/d3d12/d3d12_replay.cpp b/renderdoc/driver/d3d12/d3d12_replay.cpp index 4a33a0d55..3cce0e6c4 100644 --- a/renderdoc/driver/d3d12/d3d12_replay.cpp +++ b/renderdoc/driver/d3d12/d3d12_replay.cpp @@ -304,31 +304,31 @@ ResourceDescription &D3D12Replay::GetResourceDesc(ResourceId id) return m_Resources[it->second]; } -const rdcarray &D3D12Replay::GetResources() +rdcarray D3D12Replay::GetResources() { return m_Resources; } -rdcarray D3D12Replay::GetBuffers() +rdcarray D3D12Replay::GetBuffers() { - rdcarray ret; + rdcarray ret; for(auto it = m_pDevice->GetResourceList().begin(); it != m_pDevice->GetResourceList().end(); it++) if(it->second->GetDesc().Dimension == D3D12_RESOURCE_DIMENSION_BUFFER) - ret.push_back(it->first); + ret.push_back(GetBuffer(it->first)); return ret; } -rdcarray D3D12Replay::GetTextures() +rdcarray D3D12Replay::GetTextures() { - rdcarray ret; + rdcarray ret; for(auto it = m_pDevice->GetResourceList().begin(); it != m_pDevice->GetResourceList().end(); it++) { if(it->second->GetDesc().Dimension != D3D12_RESOURCE_DIMENSION_BUFFER && m_pDevice->GetResourceManager()->GetOriginalID(it->first) != it->first) - ret.push_back(it->first); + ret.push_back(GetTexture(it->first)); } return ret; diff --git a/renderdoc/driver/d3d12/d3d12_replay.h b/renderdoc/driver/d3d12/d3d12_replay.h index e79f4393e..3acaa71f4 100644 --- a/renderdoc/driver/d3d12/d3d12_replay.h +++ b/renderdoc/driver/d3d12/d3d12_replay.h @@ -70,12 +70,12 @@ public: APIProperties GetAPIProperties(); ResourceDescription &GetResourceDesc(ResourceId id); - const rdcarray &GetResources(); + rdcarray GetResources(); - rdcarray GetBuffers(); + rdcarray GetBuffers(); BufferDescription GetBuffer(ResourceId id); - rdcarray GetTextures(); + rdcarray GetTextures(); TextureDescription GetTexture(ResourceId id); rdcarray GetDebugMessages(); diff --git a/renderdoc/driver/gl/gl_replay.cpp b/renderdoc/driver/gl/gl_replay.cpp index daa75a516..85a1683ac 100644 --- a/renderdoc/driver/gl/gl_replay.cpp +++ b/renderdoc/driver/gl/gl_replay.cpp @@ -196,22 +196,6 @@ APIProperties GLReplay::GetAPIProperties() return ret; } -rdcarray GLReplay::GetBuffers() -{ - rdcarray ret; - - for(auto it = m_pDriver->m_Buffers.begin(); it != m_pDriver->m_Buffers.end(); ++it) - { - // skip buffers that aren't from the log - if(m_pDriver->GetResourceManager()->GetOriginalID(it->first) == it->first) - continue; - - ret.push_back(it->first); - } - - return ret; -} - ResourceDescription &GLReplay::GetResourceDesc(ResourceId id) { auto it = m_ResourceIdx.find(id); @@ -226,32 +210,11 @@ ResourceDescription &GLReplay::GetResourceDesc(ResourceId id) return m_Resources[it->second]; } -const rdcarray &GLReplay::GetResources() +rdcarray GLReplay::GetResources() { return m_Resources; } -rdcarray GLReplay::GetTextures() -{ - rdcarray ret; - ret.reserve(m_pDriver->m_Textures.size()); - - for(auto it = m_pDriver->m_Textures.begin(); it != m_pDriver->m_Textures.end(); ++it) - { - auto &res = m_pDriver->m_Textures[it->first]; - - // skip textures that aren't from the log (except the 'default backbuffer' textures) - if(!(res.creationFlags & TextureCategory::SwapBuffer) && - m_pDriver->GetResourceManager()->GetOriginalID(it->first) == it->first) - continue; - - ret.push_back(it->first); - CacheTexture(it->first); - } - - return ret; -} - void GLReplay::SetReplayData(GLWindowingData data) { m_ReplayCtx = data; @@ -407,18 +370,6 @@ bool GLReplay::IsRenderOutput(ResourceId id) return false; } -TextureDescription GLReplay::GetTexture(ResourceId id) -{ - auto it = m_CachedTextures.find(id); - if(it == m_CachedTextures.end()) - { - CacheTexture(id); - return m_CachedTextures[id]; - } - - return it->second; -} - void GLReplay::CacheTexture(ResourceId id) { if(m_CachedTextures.find(id) != m_CachedTextures.end()) @@ -729,6 +680,55 @@ BufferDescription GLReplay::GetBuffer(ResourceId id) return ret; } +TextureDescription GLReplay::GetTexture(ResourceId id) +{ + auto it = m_CachedTextures.find(id); + if(it == m_CachedTextures.end()) + { + CacheTexture(id); + return m_CachedTextures[id]; + } + + return it->second; +} + +rdcarray GLReplay::GetBuffers() +{ + rdcarray ret; + + for(auto it = m_pDriver->m_Buffers.begin(); it != m_pDriver->m_Buffers.end(); ++it) + { + // skip buffers that aren't from the log + if(m_pDriver->GetResourceManager()->GetOriginalID(it->first) == it->first) + continue; + + ret.push_back(GetBuffer(it->first)); + } + + return ret; +} + +rdcarray GLReplay::GetTextures() +{ + rdcarray ret; + ret.reserve(m_pDriver->m_Textures.size()); + + for(auto it = m_pDriver->m_Textures.begin(); it != m_pDriver->m_Textures.end(); ++it) + { + auto &res = m_pDriver->m_Textures[it->first]; + + // skip textures that aren't from the log (except the 'default backbuffer' textures) + if(!(res.creationFlags & TextureCategory::SwapBuffer) && + m_pDriver->GetResourceManager()->GetOriginalID(it->first) == it->first) + continue; + + CacheTexture(it->first); + ret.push_back(m_CachedTextures[it->first]); + } + + return ret; +} + rdcarray GLReplay::GetDebugMessages() { return m_pDriver->GetDebugMessages(); diff --git a/renderdoc/driver/gl/gl_replay.h b/renderdoc/driver/gl/gl_replay.h index 023fe8a7e..6ee6d6e2d 100644 --- a/renderdoc/driver/gl/gl_replay.h +++ b/renderdoc/driver/gl/gl_replay.h @@ -117,12 +117,12 @@ public: APIProperties GetAPIProperties(); ResourceDescription &GetResourceDesc(ResourceId id); - const rdcarray &GetResources(); + rdcarray GetResources(); - rdcarray GetBuffers(); + rdcarray GetBuffers(); BufferDescription GetBuffer(ResourceId id); - rdcarray GetTextures(); + rdcarray GetTextures(); TextureDescription GetTexture(ResourceId id); rdcarray GetShaderEntryPoints(ResourceId shader); diff --git a/renderdoc/driver/vulkan/vk_replay.cpp b/renderdoc/driver/vulkan/vk_replay.cpp index f30c4a916..7a404e40e 100644 --- a/renderdoc/driver/vulkan/vk_replay.cpp +++ b/renderdoc/driver/vulkan/vk_replay.cpp @@ -287,14 +287,14 @@ ResourceDescription &VulkanReplay::GetResourceDesc(ResourceId id) return m_Resources[it->second]; } -const rdcarray &VulkanReplay::GetResources() +rdcarray VulkanReplay::GetResources() { return m_Resources; } -rdcarray VulkanReplay::GetTextures() +rdcarray VulkanReplay::GetTextures() { - rdcarray texs; + rdcarray texs; for(auto it = m_pDriver->m_ImageStates.begin(); it != m_pDriver->m_ImageStates.end(); ++it) { @@ -302,15 +302,15 @@ rdcarray VulkanReplay::GetTextures() if(m_pDriver->GetResourceManager()->GetOriginalID(it->first) == it->first) continue; - texs.push_back(it->first); + texs.push_back(GetTexture(it->first)); } return texs; } -rdcarray VulkanReplay::GetBuffers() +rdcarray VulkanReplay::GetBuffers() { - rdcarray bufs; + rdcarray bufs; for(auto it = m_pDriver->m_CreationInfo.m_Buffer.begin(); it != m_pDriver->m_CreationInfo.m_Buffer.end(); ++it) @@ -319,7 +319,7 @@ rdcarray VulkanReplay::GetBuffers() if(m_pDriver->GetResourceManager()->GetOriginalID(it->first) == it->first) continue; - bufs.push_back(it->first); + bufs.push_back(GetBuffer(it->first)); } return bufs; diff --git a/renderdoc/driver/vulkan/vk_replay.h b/renderdoc/driver/vulkan/vk_replay.h index 35ea8127c..d005255de 100644 --- a/renderdoc/driver/vulkan/vk_replay.h +++ b/renderdoc/driver/vulkan/vk_replay.h @@ -260,12 +260,12 @@ public: APIProperties GetAPIProperties(); ResourceDescription &GetResourceDesc(ResourceId id); - const rdcarray &GetResources(); + rdcarray GetResources(); - rdcarray GetBuffers(); + rdcarray GetBuffers(); BufferDescription GetBuffer(ResourceId id); - rdcarray GetTextures(); + rdcarray GetTextures(); TextureDescription GetTexture(ResourceId id); rdcarray GetShaderEntryPoints(ResourceId shader); diff --git a/renderdoc/replay/replay_controller.cpp b/renderdoc/replay/replay_controller.cpp index 662cf165f..2da06d9f2 100644 --- a/renderdoc/replay/replay_controller.cpp +++ b/renderdoc/replay/replay_controller.cpp @@ -2056,24 +2056,8 @@ ReplayStatus ReplayController::PostCreateInit(IReplayDriver *device, RDCFile *rd // fetch GCN ISA targets GCNISA::GetTargets(m_APIProps.pipelineType, m_GCNTargets); - { - rdcarray ids = m_pDevice->GetBuffers(); - - m_Buffers.resize(ids.size()); - - for(size_t i = 0; i < ids.size(); i++) - m_Buffers[i] = m_pDevice->GetBuffer(ids[i]); - } - - { - rdcarray ids = m_pDevice->GetTextures(); - - m_Textures.resize(ids.size()); - - for(size_t i = 0; i < ids.size(); i++) - m_Textures[i] = m_pDevice->GetTexture(ids[i]); - } - + m_Buffers = m_pDevice->GetBuffers(); + m_Textures = m_pDevice->GetTextures(); m_Resources = m_pDevice->GetResources(); m_FrameRecord = m_pDevice->GetFrameRecord(); diff --git a/renderdoc/replay/replay_driver.h b/renderdoc/replay/replay_driver.h index 542a3e83a..5d844ff7e 100644 --- a/renderdoc/replay/replay_driver.h +++ b/renderdoc/replay/replay_driver.h @@ -114,12 +114,12 @@ public: virtual APIProperties GetAPIProperties() = 0; - virtual const rdcarray &GetResources() = 0; + virtual rdcarray GetResources() = 0; - virtual rdcarray GetBuffers() = 0; + virtual rdcarray GetBuffers() = 0; virtual BufferDescription GetBuffer(ResourceId id) = 0; - virtual rdcarray GetTextures() = 0; + virtual rdcarray GetTextures() = 0; virtual TextureDescription GetTexture(ResourceId id) = 0; virtual rdcarray GetDebugMessages() = 0;