mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-06 01:50:38 +00:00
Avoid unnecessary copies/temporaries when returning buffer data
This commit is contained in:
@@ -127,7 +127,7 @@ class ImageViewer : public IReplayDriver
|
||||
void DescribeCounter(uint32_t counterID, CounterDescription &desc) { RDCEraseEl(desc); desc.counterID = counterID; }
|
||||
vector<CounterResult> FetchCounters(uint32_t frameID, uint32_t minEventID, uint32_t maxEventID, const vector<uint32_t> &counters) { return vector<CounterResult>(); }
|
||||
void FillCBufferVariables(ResourceId shader, uint32_t cbufSlot, vector<ShaderVariable> &outvars, const vector<byte> &data) {}
|
||||
vector<byte> GetBufferData(ResourceId buff, uint64_t offset, uint64_t len) { return vector<byte>(); }
|
||||
void GetBufferData(ResourceId buff, uint64_t offset, uint64_t len, vector<byte> &retData) {}
|
||||
void InitPostVSBuffers(uint32_t frameID, uint32_t eventID) {}
|
||||
MeshFormat GetPostVSBuffers(uint32_t frameID, uint32_t eventID, uint32_t instID, MeshDataStage stage) { MeshFormat ret; RDCEraseEl(ret); return ret; }
|
||||
ResourceId RenderOverlay(ResourceId texid, TextureDisplayOverlay overlay, uint32_t frameID, uint32_t eventID, const vector<uint32_t> &passEvents) { return ResourceId(); }
|
||||
|
||||
@@ -1256,7 +1256,8 @@ void ProxySerialiser::EnsureBufCached(ResourceId bufid)
|
||||
|
||||
ResourceId proxyid = m_ProxyBufferIds[bufid];
|
||||
|
||||
vector<byte> data = GetBufferData(bufid, 0, 0);
|
||||
vector<byte> data;
|
||||
GetBufferData(bufid, 0, 0, data);
|
||||
|
||||
if(!data.empty())
|
||||
m_Proxy->SetProxyBufferData(proxyid, &data[0], data.size());
|
||||
@@ -1357,8 +1358,11 @@ bool ProxySerialiser::Tick()
|
||||
break;
|
||||
}
|
||||
case eCommand_GetBufferData:
|
||||
GetBufferData(ResourceId(), 0, 0);
|
||||
{
|
||||
vector<byte> dummy;
|
||||
GetBufferData(ResourceId(), 0, 0, dummy);
|
||||
break;
|
||||
}
|
||||
case eCommand_GetTextureData:
|
||||
{
|
||||
size_t dummy;
|
||||
@@ -1800,34 +1804,30 @@ void ProxySerialiser::FillCBufferVariables(ResourceId shader, uint32_t cbufSlot,
|
||||
return;
|
||||
}
|
||||
|
||||
vector<byte> ProxySerialiser::GetBufferData(ResourceId buff, uint64_t offset, uint64_t len)
|
||||
void ProxySerialiser::GetBufferData(ResourceId buff, uint64_t offset, uint64_t len, vector<byte> &retData)
|
||||
{
|
||||
vector<byte> ret;
|
||||
|
||||
m_ToReplaySerialiser->Serialise("", buff);
|
||||
m_ToReplaySerialiser->Serialise("", offset);
|
||||
m_ToReplaySerialiser->Serialise("", len);
|
||||
|
||||
if(m_ReplayHost)
|
||||
{
|
||||
ret = m_Remote->GetBufferData(buff, offset, len);
|
||||
m_Remote->GetBufferData(buff, offset, len, retData);
|
||||
|
||||
size_t sz = ret.size();
|
||||
size_t sz = retData.size();
|
||||
m_FromReplaySerialiser->Serialise("", sz);
|
||||
m_FromReplaySerialiser->RawWriteBytes(&ret[0], sz);
|
||||
m_FromReplaySerialiser->RawWriteBytes(&retData[0], sz);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!SendReplayCommand(eCommand_GetBufferData))
|
||||
return ret;
|
||||
return;
|
||||
|
||||
size_t sz = 0;
|
||||
m_FromReplaySerialiser->Serialise("", sz);
|
||||
ret.resize(sz);
|
||||
memcpy(&ret[0], m_FromReplaySerialiser->RawReadBytes(sz), sz);
|
||||
retData.resize(sz);
|
||||
memcpy(&retData[0], m_FromReplaySerialiser->RawReadBytes(sz), sz);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
byte *ProxySerialiser::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip, bool resolve, bool forceRGBA8unorm,
|
||||
|
||||
@@ -347,7 +347,7 @@ class ProxySerialiser : public IReplayDriver, Callstack::StackResolver
|
||||
|
||||
void FillCBufferVariables(ResourceId shader, uint32_t cbufSlot, vector<ShaderVariable> &outvars, const vector<byte> &data);
|
||||
|
||||
vector<byte> GetBufferData(ResourceId buff, uint64_t offset, uint64_t len);
|
||||
void GetBufferData(ResourceId buff, uint64_t offset, uint64_t len, vector<byte> &retData);
|
||||
byte *GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip, bool resolve, bool forceRGBA8unorm, float blackPoint, float whitePoint, size_t &dataSize);
|
||||
|
||||
void InitPostVSBuffers(uint32_t frameID, uint32_t eventID);
|
||||
|
||||
@@ -574,7 +574,7 @@ void D3D11DebugManager::CreateShaderGlobalState(ShaderDebug::GlobalState &global
|
||||
{
|
||||
if(WrappedID3D11Buffer::IsAlloc(res))
|
||||
{
|
||||
global.uavs[dsti].data = GetBufferData((ID3D11Buffer *)res, 0, 0, true);
|
||||
GetBufferData((ID3D11Buffer *)res, 0, 0, global.uavs[dsti].data, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -757,7 +757,7 @@ void D3D11DebugManager::CreateShaderGlobalState(ShaderDebug::GlobalState &global
|
||||
{
|
||||
if(WrappedID3D11Buffer::IsAlloc(res))
|
||||
{
|
||||
global.srvs[i].data = GetBufferData((ID3D11Buffer *)res, 0, 0, true);
|
||||
GetBufferData((ID3D11Buffer *)res, 0, 0, global.srvs[i].data, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -884,8 +884,8 @@ ShaderDebugTrace D3D11DebugManager::DebugVertex(uint32_t frameID, uint32_t event
|
||||
UINT i = *it;
|
||||
if(rs->IA.VBs[i])
|
||||
{
|
||||
vertData[i] = GetBufferData(rs->IA.VBs[i], rs->IA.Offsets[i] + rs->IA.Strides[i]*(vertOffset+idx), rs->IA.Strides[i], true);
|
||||
instData[i] = GetBufferData(rs->IA.VBs[i], rs->IA.Offsets[i] + rs->IA.Strides[i]*(instOffset+instid), rs->IA.Strides[i], true);
|
||||
GetBufferData(rs->IA.VBs[i], rs->IA.Offsets[i] + rs->IA.Strides[i]*(vertOffset+idx), rs->IA.Strides[i], vertData[i], true);
|
||||
GetBufferData(rs->IA.VBs[i], rs->IA.Offsets[i] + rs->IA.Strides[i]*(instOffset+instid), rs->IA.Strides[i], instData[i], true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -893,7 +893,7 @@ ShaderDebugTrace D3D11DebugManager::DebugVertex(uint32_t frameID, uint32_t event
|
||||
|
||||
for(int i=0; i < D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT; i++)
|
||||
if(rs->VS.ConstantBuffers[i])
|
||||
cbufData[i] = GetBufferData(rs->VS.ConstantBuffers[i], rs->VS.CBOffsets[i]*sizeof(Vec4f), 0, true);
|
||||
GetBufferData(rs->VS.ConstantBuffers[i], rs->VS.CBOffsets[i]*sizeof(Vec4f), 0, cbufData[i], true);
|
||||
|
||||
ShaderDebugTrace ret;
|
||||
|
||||
@@ -1609,7 +1609,7 @@ ShaderDebugTrace D3D11DebugManager::DebugPixel(uint32_t frameID, uint32_t eventI
|
||||
|
||||
for(int i=0; i < D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT; i++)
|
||||
if(rs->PS.ConstantBuffers[i])
|
||||
cbufData[i] = GetBufferData(rs->PS.ConstantBuffers[i], rs->PS.CBOffsets[i]*sizeof(Vec4f), 0, true);
|
||||
GetBufferData(rs->PS.ConstantBuffers[i], rs->PS.CBOffsets[i]*sizeof(Vec4f), 0, cbufData[i], true);
|
||||
|
||||
D3D11_COMPARISON_FUNC depthFunc = D3D11_COMPARISON_LESS;
|
||||
|
||||
@@ -1968,7 +1968,7 @@ ShaderDebugTrace D3D11DebugManager::DebugThread(uint32_t frameID, uint32_t event
|
||||
|
||||
for(int i=0; i < D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT; i++)
|
||||
if(rs->CS.ConstantBuffers[i])
|
||||
cbufData[i] = GetBufferData(rs->CS.ConstantBuffers[i], rs->CS.CBOffsets[i]*sizeof(Vec4f), 0, true);
|
||||
GetBufferData(rs->CS.ConstantBuffers[i], rs->CS.CBOffsets[i]*sizeof(Vec4f), 0, cbufData[i], true);
|
||||
|
||||
ShaderDebugTrace ret;
|
||||
|
||||
@@ -2134,7 +2134,8 @@ uint32_t D3D11DebugManager::PickVertex(uint32_t frameID, uint32_t eventID, MeshD
|
||||
{
|
||||
FloatVector *vbData = new FloatVector[cfg.position.numVerts];
|
||||
|
||||
vector<byte> oldData = GetBufferData(vb, cfg.position.offset, 0, false);
|
||||
vector<byte> oldData;
|
||||
GetBufferData(vb, cfg.position.offset, 0, oldData, false);
|
||||
|
||||
byte *data = &oldData[0];
|
||||
byte *dataEnd = data + oldData.size();
|
||||
@@ -2166,13 +2167,14 @@ uint32_t D3D11DebugManager::PickVertex(uint32_t frameID, uint32_t eventID, MeshD
|
||||
|
||||
m_pImmediateContext->CopyStructureCount(m_DebugRender.histogramBuff, 0, m_DebugRender.PickResultUAV);
|
||||
|
||||
vector<byte> results = GetBufferData(m_DebugRender.histogramBuff, 0, 0, false);
|
||||
vector<byte> results;
|
||||
GetBufferData(m_DebugRender.histogramBuff, 0, 0, results, false);
|
||||
|
||||
uint32_t numResults = *(uint32_t *)&results[0];
|
||||
|
||||
if(numResults > 0)
|
||||
{
|
||||
results = GetBufferData(m_DebugRender.PickResultBuf, 0, 0, false);
|
||||
GetBufferData(m_DebugRender.PickResultBuf, 0, 0, results, false);
|
||||
|
||||
struct PickResult
|
||||
{
|
||||
|
||||
@@ -3798,7 +3798,8 @@ bool WrappedID3D11DeviceContext::Serialise_DrawIndexedInstancedIndirect(ID3D11Bu
|
||||
{
|
||||
ID3D11Buffer *argBuffer = (ID3D11Buffer *)m_pDevice->GetResourceManager()->GetLiveResource(BufferForArgs);
|
||||
|
||||
vector<byte> args = m_pDevice->GetDebugManager()->GetBufferData(argBuffer, AlignedByteOffsetForArgs, 5*sizeof(uint32_t), true);
|
||||
vector<byte> args;
|
||||
m_pDevice->GetDebugManager()->GetBufferData(argBuffer, AlignedByteOffsetForArgs, 5*sizeof(uint32_t), args, true);
|
||||
uint32_t *uargs = (uint32_t *)&args[0];
|
||||
|
||||
name = "DrawIndexedInstancedIndirect(<" + ToStr::Get(uargs[0])
|
||||
@@ -3872,8 +3873,9 @@ bool WrappedID3D11DeviceContext::Serialise_DrawInstancedIndirect(ID3D11Buffer *p
|
||||
if(m_pDevice->GetResourceManager()->HasLiveResource(BufferForArgs))
|
||||
{
|
||||
ID3D11Buffer *argBuffer = (ID3D11Buffer *)m_pDevice->GetResourceManager()->GetLiveResource(BufferForArgs);
|
||||
|
||||
vector<byte> args = m_pDevice->GetDebugManager()->GetBufferData(argBuffer, AlignedByteOffsetForArgs, 4*sizeof(uint32_t), true);
|
||||
|
||||
vector<byte> args;
|
||||
m_pDevice->GetDebugManager()->GetBufferData(argBuffer, AlignedByteOffsetForArgs, 4*sizeof(uint32_t), args, true);
|
||||
uint32_t *uargs = (uint32_t *)&args[0];
|
||||
|
||||
name = "DrawInstancedIndirect(<" + ToStr::Get(uargs[0])
|
||||
@@ -4578,7 +4580,8 @@ bool WrappedID3D11DeviceContext::Serialise_DispatchIndirect(ID3D11Buffer *pBuffe
|
||||
{
|
||||
ID3D11Buffer *argBuffer = (ID3D11Buffer *)m_pDevice->GetResourceManager()->GetLiveResource(BufferForArgs);
|
||||
|
||||
vector<byte> args = m_pDevice->GetDebugManager()->GetBufferData(argBuffer, AlignedByteOffsetForArgs, 5*sizeof(uint32_t), true);
|
||||
vector<byte> args;
|
||||
m_pDevice->GetDebugManager()->GetBufferData(argBuffer, AlignedByteOffsetForArgs, 5*sizeof(uint32_t), args, true);
|
||||
uint32_t *uargs = (uint32_t *)&args[0];
|
||||
|
||||
name = "DispatchIndirect(<" + ToStr::Get(uargs[0])
|
||||
|
||||
@@ -2121,26 +2121,26 @@ bool D3D11DebugManager::GetMinMax(ResourceId texid, uint32_t sliceFace, uint32_t
|
||||
return true;
|
||||
}
|
||||
|
||||
vector<byte> D3D11DebugManager::GetBufferData(ResourceId buff, uint64_t offset, uint64_t length)
|
||||
void D3D11DebugManager::GetBufferData(ResourceId buff, uint64_t offset, uint64_t length, vector<byte> &retData)
|
||||
{
|
||||
auto it = WrappedID3D11Buffer::m_BufferList.find(buff);
|
||||
|
||||
if(it == WrappedID3D11Buffer::m_BufferList.end())
|
||||
return vector<byte>();
|
||||
return;
|
||||
|
||||
ID3D11Buffer *buffer = it->second.m_Buffer;
|
||||
|
||||
RDCASSERT(buffer);
|
||||
|
||||
return GetBufferData(buffer, offset, length, true);
|
||||
GetBufferData(buffer, offset, length, retData, true);
|
||||
}
|
||||
|
||||
vector<byte> D3D11DebugManager::GetBufferData(ID3D11Buffer *buffer, uint64_t offset, uint64_t length, bool unwrap)
|
||||
void D3D11DebugManager::GetBufferData(ID3D11Buffer *buffer, uint64_t offset, uint64_t length, vector<byte> &ret, bool unwrap)
|
||||
{
|
||||
D3D11_MAPPED_SUBRESOURCE mapped;
|
||||
|
||||
if(buffer == NULL)
|
||||
return vector<byte>();
|
||||
return;
|
||||
|
||||
RDCASSERT(offset < 0xffffffff);
|
||||
RDCASSERT(length <= 0xffffffff);
|
||||
@@ -2164,8 +2164,6 @@ vector<byte> D3D11DebugManager::GetBufferData(ID3D11Buffer *buffer, uint64_t off
|
||||
|
||||
uint32_t outOffs = 0;
|
||||
|
||||
vector<byte> ret;
|
||||
|
||||
ret.resize(len);
|
||||
|
||||
D3D11_BOX box;
|
||||
@@ -2196,7 +2194,7 @@ vector<byte> D3D11DebugManager::GetBufferData(ID3D11Buffer *buffer, uint64_t off
|
||||
if(FAILED(hr))
|
||||
{
|
||||
RDCERR("Failed to map bufferdata buffer %08x", hr);
|
||||
return ret;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2208,8 +2206,6 @@ vector<byte> D3D11DebugManager::GetBufferData(ID3D11Buffer *buffer, uint64_t off
|
||||
outOffs += chunkSize;
|
||||
len -= chunkSize;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void D3D11DebugManager::CopyArrayToTex2DMS(ID3D11Texture2D *destMS, ID3D11Texture2D *srcArray)
|
||||
@@ -3954,7 +3950,8 @@ void D3D11DebugManager::InitPostVSBuffers(uint32_t frameID, uint32_t eventID)
|
||||
|
||||
ID3D11Buffer *origBuf = idxBuf;
|
||||
|
||||
vector<byte> idxdata = GetBufferData(idxBuf, idxOffs + drawcall->indexOffset*bytesize, drawcall->numIndices*bytesize, true);
|
||||
vector<byte> idxdata;
|
||||
GetBufferData(idxBuf, idxOffs + drawcall->indexOffset*bytesize, drawcall->numIndices*bytesize, idxdata, true);
|
||||
|
||||
SAFE_RELEASE(idxBuf);
|
||||
|
||||
@@ -4965,7 +4962,7 @@ void D3D11DebugManager::RenderMesh(uint32_t frameID, uint32_t eventID, const vec
|
||||
bool index16 = (ifmt == DXGI_FORMAT_R16_UINT);
|
||||
UINT bytesize = index16 ? 2 : 4;
|
||||
|
||||
m_HighlightCache.data = GetBufferData(cfg.position.buf, 0, 0);
|
||||
GetBufferData(cfg.position.buf, 0, 0, m_HighlightCache.data);
|
||||
|
||||
if(cfg.position.idxByteWidth == 0 || stage == eMeshDataStage_GSOut)
|
||||
{
|
||||
@@ -4978,7 +4975,7 @@ void D3D11DebugManager::RenderMesh(uint32_t frameID, uint32_t eventID, const vec
|
||||
|
||||
vector<byte> idxdata;
|
||||
if(cfg.position.idxbuf != ResourceId())
|
||||
idxdata = GetBufferData(cfg.position.idxbuf, ioffs, cfg.position.numVerts*bytesize);
|
||||
GetBufferData(cfg.position.idxbuf, ioffs, cfg.position.numVerts*bytesize, idxdata);
|
||||
|
||||
uint16_t *idx16 = (uint16_t *)&idxdata[0];
|
||||
uint32_t *idx32 = (uint32_t *)&idxdata[0];
|
||||
|
||||
@@ -119,8 +119,8 @@ class D3D11DebugManager
|
||||
MeshFormat GetPostVSBuffers(uint32_t frameID, uint32_t eventID, uint32_t instID, MeshDataStage stage);
|
||||
|
||||
uint32_t GetStructCount(ID3D11UnorderedAccessView *uav);
|
||||
vector<byte> GetBufferData(ResourceId buff, uint64_t offset, uint64_t length);
|
||||
vector<byte> GetBufferData(ID3D11Buffer *buff, uint64_t offset, uint64_t length, bool unwrap);
|
||||
void GetBufferData(ResourceId buff, uint64_t offset, uint64_t length, vector<byte> &retData);
|
||||
void GetBufferData(ID3D11Buffer *buff, uint64_t offset, uint64_t length, vector<byte> &retData, bool unwrap);
|
||||
|
||||
byte *GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip, bool resolve, bool forceRGBA8unorm, float blackPoint, float whitePoint, size_t &dataSize);
|
||||
|
||||
|
||||
@@ -1314,9 +1314,9 @@ MeshFormat D3D11Replay::GetPostVSBuffers(uint32_t frameID, uint32_t eventID, uin
|
||||
return m_pDevice->GetDebugManager()->GetPostVSBuffers(frameID, eventID, instID, stage);
|
||||
}
|
||||
|
||||
vector<byte> D3D11Replay::GetBufferData(ResourceId buff, uint64_t offset, uint64_t len)
|
||||
void D3D11Replay::GetBufferData(ResourceId buff, uint64_t offset, uint64_t len, vector<byte> &retData)
|
||||
{
|
||||
return m_pDevice->GetDebugManager()->GetBufferData(buff, offset, len);
|
||||
m_pDevice->GetDebugManager()->GetBufferData(buff, offset, len, retData);
|
||||
}
|
||||
|
||||
byte *D3D11Replay::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip, bool resolve, bool forceRGBA8unorm, float blackPoint, float whitePoint, size_t &dataSize)
|
||||
|
||||
@@ -90,7 +90,7 @@ class D3D11Replay : public IReplayDriver
|
||||
|
||||
MeshFormat GetPostVSBuffers(uint32_t frameID, uint32_t eventID, uint32_t instID, MeshDataStage stage);
|
||||
|
||||
vector<byte> GetBufferData(ResourceId buff, uint64_t offset, uint64_t len);
|
||||
void GetBufferData(ResourceId buff, uint64_t offset, uint64_t len, vector<byte> &retData);
|
||||
byte *GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip, bool resolve, bool forceRGBA8unorm, float blackPoint, float whitePoint, size_t &dataSize);
|
||||
|
||||
void BuildTargetShader(string source, string entry, const uint32_t compileFlags, ShaderStageType type, ResourceId *id, string *errors);
|
||||
|
||||
@@ -1124,7 +1124,8 @@ uint32_t GLReplay::PickVertex(uint32_t frameID, uint32_t eventID, MeshDisplay cf
|
||||
{
|
||||
FloatVector *vbData = new FloatVector[cfg.position.numVerts];
|
||||
|
||||
vector<byte> oldData = GetBufferData(cfg.position.buf, cfg.position.offset, 0);
|
||||
vector<byte> oldData;
|
||||
GetBufferData(cfg.position.buf, cfg.position.offset, 0, oldData);
|
||||
|
||||
byte *data = &oldData[0];
|
||||
byte *dataEnd = data + oldData.size();
|
||||
@@ -2628,7 +2629,8 @@ void GLReplay::InitPostVSBuffers(uint32_t frameID, uint32_t eventID)
|
||||
{
|
||||
ResourceId idxId = rm->GetID(BufferRes(NULL, elArrayBuffer));
|
||||
|
||||
vector<byte> idxdata = GetBufferData(idxId, drawcall->indexOffset*drawcall->indexByteWidth, drawcall->numIndices*drawcall->indexByteWidth);
|
||||
vector<byte> idxdata;
|
||||
GetBufferData(idxId, drawcall->indexOffset*drawcall->indexByteWidth, drawcall->numIndices*drawcall->indexByteWidth, idxdata);
|
||||
|
||||
vector<uint32_t> indices;
|
||||
|
||||
@@ -3812,7 +3814,7 @@ void GLReplay::RenderMesh(uint32_t frameID, uint32_t eventID, const vector<MeshF
|
||||
|
||||
uint32_t bytesize = cfg.position.idxByteWidth;
|
||||
|
||||
m_HighlightCache.data = GetBufferData(cfg.position.buf, 0, 0);
|
||||
GetBufferData(cfg.position.buf, 0, 0, m_HighlightCache.data);
|
||||
|
||||
if(cfg.position.idxByteWidth == 0 || stage == eMeshDataStage_GSOut)
|
||||
{
|
||||
@@ -3825,7 +3827,7 @@ void GLReplay::RenderMesh(uint32_t frameID, uint32_t eventID, const vector<MeshF
|
||||
|
||||
vector<byte> idxdata;
|
||||
if(cfg.position.idxbuf != ResourceId())
|
||||
idxdata = GetBufferData(cfg.position.idxbuf, cfg.position.idxoffs, cfg.position.numVerts*bytesize);
|
||||
GetBufferData(cfg.position.idxbuf, cfg.position.idxoffs, cfg.position.numVerts*bytesize, idxdata);
|
||||
|
||||
uint8_t *idx8 = (uint8_t *)&idxdata[0];
|
||||
uint16_t *idx16 = (uint16_t *)&idxdata[0];
|
||||
|
||||
@@ -308,14 +308,12 @@ void GLReplay::FlipOutputWindow(uint64_t id)
|
||||
SwapBuffers(&outw);
|
||||
}
|
||||
|
||||
vector<byte> GLReplay::GetBufferData(ResourceId buff, uint64_t offset, uint64_t len)
|
||||
void GLReplay::GetBufferData(ResourceId buff, uint64_t offset, uint64_t len, vector<byte> &ret)
|
||||
{
|
||||
vector<byte> ret;
|
||||
|
||||
if(m_pDriver->m_Buffers.find(buff) == m_pDriver->m_Buffers.end())
|
||||
{
|
||||
RDCWARN("Requesting data for non-existant buffer %llu", buff);
|
||||
return ret;
|
||||
return;
|
||||
}
|
||||
|
||||
auto &buf = m_pDriver->m_Buffers[buff];
|
||||
@@ -329,7 +327,7 @@ vector<byte> GLReplay::GetBufferData(ResourceId buff, uint64_t offset, uint64_t
|
||||
if(offset < buf.size)
|
||||
len = ~0ULL; // min below will clamp to max size size
|
||||
else
|
||||
return ret; // offset past buffer size, return empty array
|
||||
return; // offset past buffer size, return empty array
|
||||
}
|
||||
else if(len == 0)
|
||||
{
|
||||
@@ -340,7 +338,7 @@ vector<byte> GLReplay::GetBufferData(ResourceId buff, uint64_t offset, uint64_t
|
||||
// will fail.
|
||||
len = RDCMIN(len, bufsize-offset);
|
||||
|
||||
if(len == 0) return ret;
|
||||
if(len == 0) return;
|
||||
|
||||
ret.resize((size_t)len);
|
||||
|
||||
@@ -354,8 +352,6 @@ vector<byte> GLReplay::GetBufferData(ResourceId buff, uint64_t offset, uint64_t
|
||||
gl.glGetBufferSubData(eGL_COPY_READ_BUFFER, (GLintptr)offset, (GLsizeiptr)len, &ret[0]);
|
||||
|
||||
gl.glBindBuffer(eGL_COPY_READ_BUFFER, oldbuf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool GLReplay::IsRenderOutput(ResourceId id)
|
||||
@@ -2094,7 +2090,8 @@ byte *GLReplay::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip,
|
||||
gl.glGetTextureLevelParameterivEXT(texname, texType, 0, eGL_TEXTURE_BUFFER_OFFSET, (GLint *)&offs);
|
||||
gl.glGetTextureLevelParameterivEXT(texname, texType, 0, eGL_TEXTURE_BUFFER_SIZE, (GLint *)&size);
|
||||
|
||||
vector<byte> data = GetBufferData(id, offs, size);
|
||||
vector<byte> data;
|
||||
GetBufferData(id, offs, size, data);
|
||||
|
||||
dataSize = data.size();
|
||||
ret = new byte[dataSize];
|
||||
|
||||
@@ -136,7 +136,7 @@ class GLReplay : public IReplayDriver
|
||||
|
||||
MeshFormat GetPostVSBuffers(uint32_t frameID, uint32_t eventID, uint32_t instID, MeshDataStage stage);
|
||||
|
||||
vector<byte> GetBufferData(ResourceId buff, uint64_t offset, uint64_t len);
|
||||
void GetBufferData(ResourceId buff, uint64_t offset, uint64_t len, vector<byte> &ret);
|
||||
byte *GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip, bool resolve, bool forceRGBA8unorm, float blackPoint, float whitePoint, size_t &dataSize);
|
||||
|
||||
void ReplaceResource(ResourceId from, ResourceId to);
|
||||
|
||||
@@ -1783,7 +1783,7 @@ void VulkanDebugManager::EndText(const TextPrintState &textstate)
|
||||
ObjDisp(textstate.cmd)->EndCommandBuffer(Unwrap(textstate.cmd));
|
||||
}
|
||||
|
||||
vector<byte> VulkanDebugManager::GetBufferData(ResourceId buff, uint64_t offset, uint64_t len)
|
||||
void VulkanDebugManager::GetBufferData(ResourceId buff, uint64_t offset, uint64_t len, vector<byte> &ret)
|
||||
{
|
||||
VkDevice dev = m_pDriver->GetDev();
|
||||
VkCmdBuffer cmd = m_pDriver->GetNextCmd();
|
||||
@@ -1802,7 +1802,6 @@ vector<byte> VulkanDebugManager::GetBufferData(ResourceId buff, uint64_t offset,
|
||||
len = RDCMIN(len, m_pDriver->m_CreationInfo.m_Buffer[buff].size - offset);
|
||||
}
|
||||
|
||||
vector<byte> ret;
|
||||
ret.resize((size_t)len);
|
||||
|
||||
// VKTODOMED - coarse: wait for all writes to this buffer
|
||||
@@ -1865,8 +1864,6 @@ vector<byte> VulkanDebugManager::GetBufferData(ResourceId buff, uint64_t offset,
|
||||
|
||||
vt->DestroyBuffer(Unwrap(dev), destbuf);
|
||||
vt->FreeMemory(Unwrap(dev), readbackmem);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void VulkanDebugManager::MakeGraphicsPipelineInfo(VkGraphicsPipelineCreateInfo &pipeCreateInfo, ResourceId pipeline)
|
||||
@@ -3991,7 +3988,7 @@ void VulkanDebugManager::InitPostVSBuffers(uint32_t frameID, uint32_t eventID)
|
||||
if((drawcall->flags & eDraw_UseIBuffer) != 0)
|
||||
{
|
||||
// fetch ibuffer
|
||||
idxdata = GetBufferData(state.ibuffer.buf, state.ibuffer.offs + drawcall->indexOffset*idxsize, drawcall->numIndices*idxsize);
|
||||
GetBufferData(state.ibuffer.buf, state.ibuffer.offs + drawcall->indexOffset*idxsize, drawcall->numIndices*idxsize, idxdata);
|
||||
|
||||
// do ibuffer rebasing/remapping
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ class VulkanDebugManager
|
||||
|
||||
void InitPostVSBuffers(uint32_t frameID, uint32_t eventID);
|
||||
MeshFormat GetPostVSBuffers(uint32_t frameID, uint32_t eventID, uint32_t instID, MeshDataStage stage);
|
||||
vector<byte> GetBufferData(ResourceId buff, uint64_t offset, uint64_t len);
|
||||
void GetBufferData(ResourceId buff, uint64_t offset, uint64_t len, vector<byte> &ret);
|
||||
|
||||
struct GPUBuffer
|
||||
{
|
||||
|
||||
@@ -1795,7 +1795,7 @@ void VulkanReplay::RenderMesh(uint32_t frameID, uint32_t eventID, const vector<M
|
||||
vkr = vt->EndCommandBuffer(Unwrap(cmd));
|
||||
RDCASSERT(vkr == VK_SUCCESS);
|
||||
|
||||
m_HighlightCache.data = GetBufferData(cfg.position.buf, 0, 0);
|
||||
GetBufferData(cfg.position.buf, 0, 0, m_HighlightCache.data);
|
||||
|
||||
if(cfg.position.idxByteWidth == 0 || stage == eMeshDataStage_GSOut)
|
||||
{
|
||||
@@ -1808,7 +1808,7 @@ void VulkanReplay::RenderMesh(uint32_t frameID, uint32_t eventID, const vector<M
|
||||
|
||||
vector<byte> idxdata;
|
||||
if(cfg.position.idxbuf != ResourceId())
|
||||
idxdata = GetBufferData(cfg.position.idxbuf, cfg.position.idxoffs, cfg.position.numVerts*bytesize);
|
||||
GetBufferData(cfg.position.idxbuf, cfg.position.idxoffs, cfg.position.numVerts*bytesize, idxdata);
|
||||
|
||||
uint8_t *idx8 = (uint8_t *)&idxdata[0];
|
||||
uint16_t *idx16 = (uint16_t *)&idxdata[0];
|
||||
@@ -2566,9 +2566,9 @@ uint64_t VulkanReplay::MakeOutputWindow(void *wn, bool depth)
|
||||
return id;
|
||||
}
|
||||
|
||||
vector<byte> VulkanReplay::GetBufferData(ResourceId buff, uint64_t offset, uint64_t len)
|
||||
void VulkanReplay::GetBufferData(ResourceId buff, uint64_t offset, uint64_t len, vector<byte> &retData)
|
||||
{
|
||||
return GetDebugManager()->GetBufferData(buff, offset, len);
|
||||
GetDebugManager()->GetBufferData(buff, offset, len, retData);
|
||||
}
|
||||
|
||||
bool VulkanReplay::IsRenderOutput(ResourceId id)
|
||||
|
||||
@@ -125,7 +125,7 @@ class VulkanReplay : public IReplayDriver
|
||||
|
||||
MeshFormat GetPostVSBuffers(uint32_t frameID, uint32_t eventID, uint32_t instID, MeshDataStage stage);
|
||||
|
||||
vector<byte> GetBufferData(ResourceId buff, uint64_t offset, uint64_t len);
|
||||
void GetBufferData(ResourceId buff, uint64_t offset, uint64_t len, vector<byte> &retData);
|
||||
byte *GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip, bool resolve, bool forceRGBA8unorm, float blackPoint, float whitePoint, size_t &dataSize);
|
||||
|
||||
void ReplaceResource(ResourceId from, ResourceId to);
|
||||
|
||||
@@ -84,7 +84,7 @@ class IRemoteDriver
|
||||
|
||||
virtual MeshFormat GetPostVSBuffers(uint32_t frameID, uint32_t eventID, uint32_t instID, MeshDataStage stage) = 0;
|
||||
|
||||
virtual vector<byte> GetBufferData(ResourceId buff, uint64_t offset, uint64_t len) = 0;
|
||||
virtual void GetBufferData(ResourceId buff, uint64_t offset, uint64_t len, vector<byte> &retData) = 0;
|
||||
virtual byte *GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip, bool resolve, bool forceRGBA8unorm, float blackPoint, float whitePoint, size_t &dataSize) = 0;
|
||||
|
||||
virtual void BuildTargetShader(string source, string entry, const uint32_t compileFlags, ShaderStageType type, ResourceId *id, string *errors) = 0;
|
||||
|
||||
@@ -445,7 +445,10 @@ bool ReplayRenderer::GetBufferData(ResourceId buff, uint64_t offset, uint64_t le
|
||||
{
|
||||
if(data == NULL) return false;
|
||||
|
||||
*data = m_pDevice->GetBufferData(m_pDevice->GetLiveID(buff), offset, len);
|
||||
vector<byte> retData;
|
||||
m_pDevice->GetBufferData(m_pDevice->GetLiveID(buff), offset, len, retData);
|
||||
|
||||
create_array_init(*data, retData.size(), !retData.empty() ? &retData[0] : NULL);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -457,8 +460,7 @@ bool ReplayRenderer::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t
|
||||
size_t sz;
|
||||
byte *bytes = m_pDevice->GetTextureData(m_pDevice->GetLiveID(tex), arrayIdx, mip, false, false, 0.0f, 0.0f, sz);
|
||||
|
||||
create_array_uninit(*data, sz);
|
||||
memcpy(data->elems, bytes, sz);
|
||||
create_array_init(*data, sz, bytes);
|
||||
|
||||
delete[] bytes;
|
||||
|
||||
@@ -1292,7 +1294,7 @@ bool ReplayRenderer::GetCBufferVariableContents(ResourceId shader, uint32_t cbuf
|
||||
|
||||
vector<byte> data;
|
||||
if(buffer != ResourceId())
|
||||
data = m_pDevice->GetBufferData(m_pDevice->GetLiveID(buffer), offs, 0);
|
||||
m_pDevice->GetBufferData(m_pDevice->GetLiveID(buffer), offs, 0, data);
|
||||
|
||||
vector<ShaderVariable> v;
|
||||
|
||||
|
||||
@@ -68,4 +68,20 @@ void create_array_uninit(array<T> &ret, size_t count)
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void create_array_init(array<T> &ret, size_t count, const T *src)
|
||||
{
|
||||
ret.Delete();
|
||||
ret.count = (int32_t)count;
|
||||
if(ret.count == 0)
|
||||
{
|
||||
ret.elems = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret.elems = (T*)ret.allocate(sizeof(T)*count);
|
||||
memcpy(ret.elems, src, sizeof(T)*count);
|
||||
}
|
||||
}
|
||||
|
||||
}; // namespace rdctype
|
||||
Reference in New Issue
Block a user