mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-04 05:41:06 +00:00
Bullet proof the replay renderer against the proxy going away suddenly
This commit is contained in:
@@ -1681,6 +1681,9 @@ ReplayProxy::~ReplayProxy()
|
||||
|
||||
bool ReplayProxy::SendReplayCommand(ReplayProxyPacket type)
|
||||
{
|
||||
if(!m_Socket->Connected())
|
||||
return false;
|
||||
|
||||
if(!SendPacket(m_Socket, type, *m_ToReplaySerialiser))
|
||||
return false;
|
||||
|
||||
@@ -1696,6 +1699,9 @@ bool ReplayProxy::SendReplayCommand(ReplayProxyPacket type)
|
||||
|
||||
void ReplayProxy::EnsureTexCached(ResourceId texid, uint32_t arrayIdx, uint32_t mip)
|
||||
{
|
||||
if(!m_Socket->Connected())
|
||||
return;
|
||||
|
||||
TextureCacheEntry entry = {texid, arrayIdx, mip};
|
||||
|
||||
if(m_LocalTextures.find(texid) != m_LocalTextures.end())
|
||||
@@ -1725,6 +1731,9 @@ void ReplayProxy::EnsureTexCached(ResourceId texid, uint32_t arrayIdx, uint32_t
|
||||
|
||||
void ReplayProxy::EnsureBufCached(ResourceId bufid)
|
||||
{
|
||||
if(!m_Socket->Connected())
|
||||
return;
|
||||
|
||||
if(m_BufferProxyCache.find(bufid) == m_BufferProxyCache.end())
|
||||
{
|
||||
if(m_ProxyBufferIds.find(bufid) == m_ProxyBufferIds.end())
|
||||
@@ -1750,7 +1759,7 @@ bool ReplayProxy::Tick(int type, Serialiser *incomingPacket)
|
||||
if(!m_RemoteServer)
|
||||
return true;
|
||||
|
||||
if(!m_Socket)
|
||||
if(!m_Socket || !m_Socket->Connected())
|
||||
return false;
|
||||
|
||||
m_ToReplaySerialiser = incomingPacket;
|
||||
@@ -2140,6 +2149,9 @@ ResourceId ReplayProxy::GetLiveID(ResourceId id)
|
||||
if(!m_RemoteServer && m_LocalTextures.find(id) != m_LocalTextures.end())
|
||||
return id;
|
||||
|
||||
if(!m_Socket->Connected())
|
||||
return ResourceId();
|
||||
|
||||
ResourceId ret;
|
||||
|
||||
RDCASSERT(m_RemoteServer || m_ToReplaySerialiser->GetSize() == 0);
|
||||
@@ -2309,7 +2321,10 @@ byte *ReplayProxy::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mi
|
||||
else
|
||||
{
|
||||
if(!SendReplayCommand(eReplayProxy_GetTextureData))
|
||||
{
|
||||
dataSize = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uint32_t uncompressedSize = 0;
|
||||
uint32_t compressedSize = 0;
|
||||
@@ -2317,6 +2332,12 @@ byte *ReplayProxy::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mi
|
||||
m_FromReplaySerialiser->Serialise("", uncompressedSize);
|
||||
m_FromReplaySerialiser->Serialise("", compressedSize);
|
||||
|
||||
if(uncompressedSize == 0 || compressedSize == 0)
|
||||
{
|
||||
dataSize = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dataSize = (size_t)uncompressedSize;
|
||||
|
||||
byte *ret = new byte[dataSize + 512];
|
||||
|
||||
@@ -191,6 +191,8 @@ public:
|
||||
if(m_Proxy)
|
||||
{
|
||||
EnsureTexCached(texid, sliceFace, mip);
|
||||
if(texid == ResourceId() || m_ProxyTextureIds[texid] == ResourceId())
|
||||
return false;
|
||||
return m_Proxy->GetMinMax(m_ProxyTextureIds[texid], sliceFace, mip, sample, typeHint, minval,
|
||||
maxval);
|
||||
}
|
||||
@@ -205,6 +207,8 @@ public:
|
||||
if(m_Proxy)
|
||||
{
|
||||
EnsureTexCached(texid, sliceFace, mip);
|
||||
if(texid == ResourceId() || m_ProxyTextureIds[texid] == ResourceId())
|
||||
return false;
|
||||
return m_Proxy->GetHistogram(m_ProxyTextureIds[texid], sliceFace, mip, sample, typeHint,
|
||||
minval, maxval, channels, histogram);
|
||||
}
|
||||
@@ -217,6 +221,8 @@ public:
|
||||
if(m_Proxy)
|
||||
{
|
||||
EnsureTexCached(cfg.texid, cfg.sliceFace, cfg.mip);
|
||||
if(cfg.texid == ResourceId() || m_ProxyTextureIds[cfg.texid] == ResourceId())
|
||||
return false;
|
||||
cfg.texid = m_ProxyTextureIds[cfg.texid];
|
||||
return m_Proxy->RenderTexture(cfg);
|
||||
}
|
||||
@@ -230,6 +236,8 @@ public:
|
||||
if(m_Proxy)
|
||||
{
|
||||
EnsureTexCached(texture, sliceFace, mip);
|
||||
if(texture == ResourceId() || m_ProxyTextureIds[texture] == ResourceId())
|
||||
return;
|
||||
m_Proxy->PickPixel(m_ProxyTextureIds[texture], x, y, sliceFace, mip, sample, typeHint, pixel);
|
||||
}
|
||||
}
|
||||
@@ -241,6 +249,9 @@ public:
|
||||
MeshDisplay proxiedCfg = cfg;
|
||||
|
||||
EnsureBufCached(proxiedCfg.position.buf);
|
||||
if(proxiedCfg.position.buf == ResourceId() ||
|
||||
m_ProxyBufferIds[proxiedCfg.position.buf] == ResourceId())
|
||||
return;
|
||||
proxiedCfg.position.buf = m_ProxyBufferIds[proxiedCfg.position.buf];
|
||||
|
||||
if(proxiedCfg.second.buf != ResourceId())
|
||||
@@ -282,6 +293,9 @@ public:
|
||||
MeshDisplay proxiedCfg = cfg;
|
||||
|
||||
EnsureBufCached(proxiedCfg.position.buf);
|
||||
if(proxiedCfg.position.buf == ResourceId() ||
|
||||
m_ProxyBufferIds[proxiedCfg.position.buf] == ResourceId())
|
||||
return ~0U;
|
||||
proxiedCfg.position.buf = m_ProxyBufferIds[proxiedCfg.position.buf];
|
||||
|
||||
if(proxiedCfg.second.buf != ResourceId())
|
||||
@@ -330,6 +344,8 @@ public:
|
||||
if(m_Proxy)
|
||||
{
|
||||
EnsureTexCached(texid, 0, mip);
|
||||
if(texid == ResourceId() || m_ProxyTextureIds[texid] == ResourceId())
|
||||
return ResourceId();
|
||||
texid = m_ProxyTextureIds[texid];
|
||||
ResourceId customResourceId =
|
||||
m_Proxy->ApplyCustomShader(shader, texid, mip, arrayIdx, sampleIdx, typeHint);
|
||||
|
||||
@@ -482,13 +482,16 @@ bool ReplayRenderer::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t sz;
|
||||
size_t sz = 0;
|
||||
byte *bytes =
|
||||
m_pDevice->GetTextureData(liveId, arrayIdx, mip, eCompType_None, false, false, 0.0f, 0.0f, sz);
|
||||
|
||||
create_array_init(*data, sz, bytes);
|
||||
if(sz == 0 || bytes == NULL)
|
||||
create_array_uninit(*data, 0);
|
||||
else
|
||||
create_array_init(*data, sz, bytes);
|
||||
|
||||
delete[] bytes;
|
||||
SAFE_DELETE_ARRAY(bytes);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user