Include EID in shader reflection cache key for GL. Closes #951

* On GL shader reflection is mutable but only between different events
  (we can expect it to be consistent/cacheable for a single event).
* We don't want to delete shader reflection pointers out from under the
  UI, and it's not feasible to invalidate all pointers it might hold at
  any point - e.g. previous to this change when a ReplayLog happens.
* Instead we just add another dimension to the cache key and allow the
  cache to bloat more on GL, preserving possibly redundant reflection
  objects.
This commit is contained in:
baldurk
2018-04-09 17:11:26 +01:00
parent bd983ad783
commit 4dca51ae0b
2 changed files with 11 additions and 14 deletions
+5 -12
View File
@@ -822,7 +822,8 @@ ShaderReflection *ReplayProxy::Proxied_GetShader(ParamSerialiser &paramser, Retu
const ReplayProxyPacket packet = eReplayProxy_GetShader;
ShaderReflection *ret = NULL;
ShaderReflKey key(id, entry);
// only consider eventID part of the key on APIs where shaders are mutable
ShaderReflKey key(m_APIProps.shadersMutable ? m_EventID : 0, id, entry);
if(retser.IsReading() && m_ShaderReflectionCache.find(key) != m_ShaderReflectionCache.end())
return m_ShaderReflectionCache[key];
@@ -1300,21 +1301,13 @@ void ReplayProxy::Proxied_ReplayLog(ParamSerialiser &paramser, ReturnSerialiser
if(paramser.IsReading() && !paramser.IsErrored() && !m_IsErrored)
m_Remote->ReplayLog(endEventID, replayType);
if(m_RemoteServer)
m_PreviewEvent = endEventID;
if(retser.IsReading())
{
m_TextureProxyCache.clear();
m_BufferProxyCache.clear();
if(m_APIProps.shadersMutable)
{
for(auto it = m_ShaderReflectionCache.begin(); it != m_ShaderReflectionCache.end(); ++it)
delete it->second;
m_ShaderReflectionCache.clear();
}
}
m_EventID = endEventID;
}
void ReplayProxy::ReplayLog(uint32_t endEventID, ReplayLogType replayType)
@@ -1916,7 +1909,7 @@ void ReplayProxy::RefreshPreviewWindow()
m_Replay->RenderCheckerboard();
const DrawcallDescription *curDraw = FindDraw(m_FrameRecord.drawcallList, m_PreviewEvent);
const DrawcallDescription *curDraw = FindDraw(m_FrameRecord.drawcallList, m_EventID);
if(curDraw)
{
+6 -2
View File
@@ -597,11 +597,15 @@ private:
struct ShaderReflKey
{
ShaderReflKey() {}
ShaderReflKey(ResourceId i, ShaderEntryPoint e) : id(i), entry(e) {}
ShaderReflKey(uint32_t eid, ResourceId i, ShaderEntryPoint e) : eventId(eid), id(i), entry(e) {}
uint32_t eventId;
ResourceId id;
ShaderEntryPoint entry;
bool operator<(const ShaderReflKey &o) const
{
if(eventId != o.eventId)
return eventId < o.eventId;
if(id != o.id)
return id < o.id;
@@ -637,7 +641,7 @@ private:
// The previous windowing data, so we can detect changes and recreate the window
WindowingData m_PreviewWindowingData;
uint32_t m_PreviewEvent = 0;
uint32_t m_EventID = 0;
bool m_IsErrored = false;