mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-29 13:20:54 +00:00
Use pipeline base mip/slice binding for texture thumbnails. Closes #1327
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -241,8 +241,8 @@ private:
|
||||
|
||||
ResourcePreview *UI_CreateThumbnail(ThumbnailStrip *strip);
|
||||
void UI_CreateThumbnails();
|
||||
void InitResourcePreview(ResourcePreview *prev, ResourceId id, CompType typeHint, bool force,
|
||||
Following &follow, const QString &bindName, const QString &slotName);
|
||||
void InitResourcePreview(ResourcePreview *prev, BoundResource res, bool force, Following &follow,
|
||||
const QString &bindName, const QString &slotName);
|
||||
|
||||
void InitStageResourcePreviews(ShaderStage stage, const rdcarray<ShaderResource> &resourceDetails,
|
||||
const rdcarray<Bindpoint> &mapping,
|
||||
|
||||
@@ -697,10 +697,13 @@ Should only be called for texture outputs.
|
||||
|
||||
:param WindowingData window: A :class:`WindowingData` describing the native window.
|
||||
:param ResourceId textureId: The texture ID to display in the thumbnail preview.
|
||||
:param int slice: The slice of the texture to display.
|
||||
:param int mip: The mip of the texture to display.
|
||||
:return: A boolean indicating if the thumbnail was successfully created.
|
||||
:rtype: ``bool``
|
||||
)");
|
||||
virtual bool AddThumbnail(WindowingData window, ResourceId textureId, CompType typeHint) = 0;
|
||||
virtual bool AddThumbnail(WindowingData window, ResourceId textureId, CompType typeHint,
|
||||
uint32_t mip, uint32_t slice) = 0;
|
||||
|
||||
DOCUMENT(R"(Render to the window handle specified when the output was created.
|
||||
|
||||
|
||||
@@ -47,7 +47,8 @@ public:
|
||||
rdcpair<int32_t, int32_t> GetDimensions();
|
||||
|
||||
void ClearThumbnails();
|
||||
bool AddThumbnail(WindowingData window, ResourceId texID, CompType typeHint);
|
||||
bool AddThumbnail(WindowingData window, ResourceId texID, CompType typeHint, uint32_t mip,
|
||||
uint32_t slice);
|
||||
|
||||
void Display();
|
||||
|
||||
@@ -93,6 +94,8 @@ private:
|
||||
{
|
||||
ResourceId texture;
|
||||
bool depthMode;
|
||||
uint32_t mip;
|
||||
uint32_t slice;
|
||||
uint64_t wndHandle;
|
||||
CompType typeHint;
|
||||
uint64_t outputID;
|
||||
|
||||
@@ -308,7 +308,8 @@ bool ReplayOutput::SetPixelContext(WindowingData window)
|
||||
return m_PixelContext.outputID != 0;
|
||||
}
|
||||
|
||||
bool ReplayOutput::AddThumbnail(WindowingData window, ResourceId texID, CompType typeHint)
|
||||
bool ReplayOutput::AddThumbnail(WindowingData window, ResourceId texID, CompType typeHint,
|
||||
uint32_t mip, uint32_t slice)
|
||||
{
|
||||
CHECK_REPLAY_THREAD();
|
||||
|
||||
@@ -333,11 +334,10 @@ bool ReplayOutput::AddThumbnail(WindowingData window, ResourceId texID, CompType
|
||||
if(m_Thumbnails[i].wndHandle == GetHandle(window))
|
||||
{
|
||||
m_Thumbnails[i].texture = texID;
|
||||
|
||||
m_Thumbnails[i].depthMode = depthMode;
|
||||
|
||||
m_Thumbnails[i].typeHint = typeHint;
|
||||
|
||||
m_Thumbnails[i].mip = mip;
|
||||
m_Thumbnails[i].slice = slice;
|
||||
m_Thumbnails[i].dirty = true;
|
||||
|
||||
return true;
|
||||
@@ -349,6 +349,8 @@ bool ReplayOutput::AddThumbnail(WindowingData window, ResourceId texID, CompType
|
||||
p.texture = texID;
|
||||
p.depthMode = depthMode;
|
||||
p.typeHint = typeHint;
|
||||
p.mip = mip;
|
||||
p.slice = slice;
|
||||
p.dirty = true;
|
||||
|
||||
RDCASSERT(p.outputID > 0);
|
||||
@@ -705,7 +707,7 @@ void ReplayOutput::Display()
|
||||
disp.hdrMultiplier = -1.0f;
|
||||
disp.linearDisplayAsGamma = true;
|
||||
disp.flipY = false;
|
||||
disp.mip = 0;
|
||||
disp.mip = m_Thumbnails[i].mip;
|
||||
disp.sampleIdx = ~0U;
|
||||
disp.customShaderId = ResourceId();
|
||||
disp.resourceId = m_pDevice->GetLiveID(m_Thumbnails[i].texture);
|
||||
@@ -713,7 +715,7 @@ void ReplayOutput::Display()
|
||||
disp.scale = -1.0f;
|
||||
disp.rangeMin = 0.0f;
|
||||
disp.rangeMax = 1.0f;
|
||||
disp.sliceFace = 0;
|
||||
disp.sliceFace = m_Thumbnails[i].slice;
|
||||
disp.xOffset = 0.0f;
|
||||
disp.yOffset = 0.0f;
|
||||
disp.rawOutput = false;
|
||||
|
||||
Reference in New Issue
Block a user