Use pipeline base mip/slice binding for texture thumbnails. Closes #1327

This commit is contained in:
baldurk
2019-05-20 13:13:47 +01:00
parent 420379c50f
commit 06feec392d
5 changed files with 38 additions and 29 deletions
+20 -19
View File
@@ -2041,36 +2041,36 @@ void TextureViewer::OpenResourceContextMenu(ResourceId id, bool input,
}
}
void TextureViewer::InitResourcePreview(ResourcePreview *prev, ResourceId id, CompType typeHint,
bool force, Following &follow, const QString &bindName,
void TextureViewer::InitResourcePreview(ResourcePreview *prev, BoundResource res, bool force,
Following &follow, const QString &bindName,
const QString &slotName)
{
if(id != ResourceId() || force)
if(res.resourceId != ResourceId() || force)
{
QString fullname = bindName;
if(!m_Ctx.IsAutogeneratedName(id))
if(!m_Ctx.IsAutogeneratedName(res.resourceId))
{
if(!fullname.isEmpty())
fullname += lit(" = ");
fullname += m_Ctx.GetResourceName(id);
fullname += m_Ctx.GetResourceName(res.resourceId);
}
if(fullname.isEmpty())
fullname = m_Ctx.GetResourceName(id);
fullname = m_Ctx.GetResourceName(res.resourceId);
prev->setResourceName(fullname);
WindowingData winData = m_Ctx.CreateWindowingData(prev->thumbWidget());
if(m_Ctx.GetTexture(id))
if(m_Ctx.GetTexture(res.resourceId))
{
m_Ctx.Replay().AsyncInvoke([this, winData, id, typeHint](IReplayController *) {
m_Output->AddThumbnail(winData, id, typeHint);
m_Ctx.Replay().AsyncInvoke([this, winData, res](IReplayController *) {
m_Output->AddThumbnail(winData, res.resourceId, res.typeHint, res.firstMip, res.firstSlice);
});
}
else
{
m_Ctx.Replay().AsyncInvoke([this, winData](IReplayController *) {
m_Output->AddThumbnail(winData, ResourceId(), CompType::Typeless);
m_Output->AddThumbnail(winData, ResourceId(), CompType::Typeless, 0, 0);
});
}
@@ -2087,7 +2087,7 @@ void TextureViewer::InitResourcePreview(ResourcePreview *prev, ResourceId id, Co
WindowingData winData = m_Ctx.CreateWindowingData(prev->thumbWidget());
m_Ctx.Replay().AsyncInvoke([this, winData](IReplayController *) {
m_Output->AddThumbnail(winData, ResourceId(), CompType::Typeless);
m_Output->AddThumbnail(winData, ResourceId(), CompType::Typeless, 0, 0);
});
}
else
@@ -2128,8 +2128,10 @@ void TextureViewer::InitStageResourcePreviews(ShaderStage stage,
if(resArray && !resArray->at(arrayIdx).dynamicallyUsed)
continue;
ResourceId id = resArray != NULL ? resArray->at(arrayIdx).resourceId : ResourceId();
CompType typeHint = resArray != NULL ? resArray->at(arrayIdx).typeHint : CompType::Typeless;
BoundResource res = {};
if(resArray)
res = resArray->at(arrayIdx);
bool used = key.used;
@@ -2168,10 +2170,10 @@ void TextureViewer::InitStageResourcePreviews(ShaderStage stage,
bool show = used;
// it's bound, but not referenced, and we have "show disabled"
show = show || (m_ShowUnused && !used && id != ResourceId());
show = show || (m_ShowUnused && !used && res.resourceId != ResourceId());
// it's empty, and we have "show empty"
show = show || (m_ShowEmpty && id == ResourceId());
show = show || (m_ShowEmpty && res.resourceId == ResourceId());
// it's the one we're following
show = show || (follow == m_Following);
@@ -2197,7 +2199,7 @@ void TextureViewer::InitStageResourcePreviews(ShaderStage stage,
prevIndex++;
InitResourcePreview(prev, show ? id : ResourceId(), typeHint, show, follow, bindName, slotName);
InitResourcePreview(prev, show ? res : BoundResource(), show, follow, bindName, slotName);
if(collapseArray)
break;
@@ -2807,8 +2809,7 @@ void TextureViewer::OnEventChanged(uint32_t eventId)
? tr("DST")
: QString(m_Ctx.CurPipelineState().OutputAbbrev() + QString::number(rt));
InitResourcePreview(prev, RTs[rt].resourceId, RTs[rt].typeHint, false, follow, bindName,
slotName);
InitResourcePreview(prev, RTs[rt], false, follow, bindName, slotName);
}
// depth
@@ -2824,7 +2825,7 @@ void TextureViewer::OnEventChanged(uint32_t eventId)
Following follow(FollowType::OutputDepth, ShaderStage::Pixel, 0, 0);
InitResourcePreview(prev, Depth.resourceId, Depth.typeHint, false, follow, QString(), tr("DS"));
InitResourcePreview(prev, Depth, false, follow, QString(), tr("DS"));
}
ShaderStage stages[] = {ShaderStage::Vertex, ShaderStage::Hull, ShaderStage::Domain,