mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-12 09:41:03 +00:00
Cache texture lookup and only update whenever it changes
This commit is contained in:
@@ -447,9 +447,17 @@ public:
|
||||
};
|
||||
|
||||
FetchTexture *TextureViewer::GetCurrentTexture()
|
||||
{
|
||||
return m_CachedTexture;
|
||||
}
|
||||
|
||||
void TextureViewer::UI_UpdateCachedTexture()
|
||||
{
|
||||
if(!m_Ctx->LogLoaded())
|
||||
return NULL;
|
||||
{
|
||||
m_CachedTexture = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
ResourceId id = m_LockedId;
|
||||
if(id == ResourceId())
|
||||
@@ -458,7 +466,7 @@ FetchTexture *TextureViewer::GetCurrentTexture()
|
||||
if(id == ResourceId())
|
||||
id = m_TexDisplay.texid;
|
||||
|
||||
return m_Ctx->GetTexture(id);
|
||||
m_CachedTexture = m_Ctx->GetTexture(id);
|
||||
}
|
||||
|
||||
TextureViewer::TextureViewer(CaptureContext *ctx, QWidget *parent)
|
||||
@@ -468,6 +476,8 @@ TextureViewer::TextureViewer(CaptureContext *ctx, QWidget *parent)
|
||||
|
||||
m_Ctx->AddLogViewer(this);
|
||||
|
||||
m_CachedTexture = NULL;
|
||||
|
||||
memset(&m_TexDisplay, 0, sizeof(m_TexDisplay));
|
||||
m_TexDisplay.sampleIdx = ~0U;
|
||||
m_TexDisplay.linearDisplayAsGamma = true;
|
||||
@@ -1529,6 +1539,8 @@ void TextureViewer::textureTab_Changed(int index)
|
||||
m_LockedId = ResourceId();
|
||||
else
|
||||
m_LockedId = w->property("id").value<ResourceId>();
|
||||
|
||||
UI_UpdateCachedTexture();
|
||||
}
|
||||
|
||||
UI_OnTextureSelectionChanged(false);
|
||||
@@ -2082,6 +2094,8 @@ void TextureViewer::thumb_clicked(QMouseEvent *e)
|
||||
m_Following = follow;
|
||||
prev->setSelected(true);
|
||||
|
||||
UI_UpdateCachedTexture();
|
||||
|
||||
ResourceId id = m_Following.GetResourceId(m_Ctx);
|
||||
|
||||
if(id != ResourceId())
|
||||
@@ -2484,7 +2498,10 @@ void TextureViewer::OnLogfileClosed()
|
||||
|
||||
void TextureViewer::OnEventSelected(uint32_t eventID)
|
||||
{
|
||||
UI_UpdateCachedTexture();
|
||||
|
||||
FetchTexture *CurrentTexture = GetCurrentTexture();
|
||||
|
||||
if(!currentTextureIsLocked() ||
|
||||
(CurrentTexture != NULL && m_TexDisplay.texid != CurrentTexture->ID))
|
||||
UI_OnTextureSelectionChanged(true);
|
||||
|
||||
@@ -242,6 +242,7 @@ private:
|
||||
void setScrollPosition(const QPoint &pos);
|
||||
|
||||
FetchTexture *GetCurrentTexture();
|
||||
void UI_UpdateCachedTexture();
|
||||
|
||||
void ShowGotoPopup();
|
||||
|
||||
@@ -285,6 +286,7 @@ private:
|
||||
CaptureContext *m_Ctx = NULL;
|
||||
IReplayOutput *m_Output = NULL;
|
||||
|
||||
FetchTexture *m_CachedTexture;
|
||||
Following m_Following = Following::Default;
|
||||
QMap<ResourceId, TexSettings> m_TextureSettings;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user