Show better window titles for edited shaders

This commit is contained in:
baldurk
2021-06-28 12:33:34 +01:00
parent cf78735861
commit cc7115e24c
3 changed files with 24 additions and 14 deletions
+17 -7
View File
@@ -1309,7 +1309,8 @@ void CaptureContext::CloseCapture()
m_TextureList.clear();
m_Resources.clear();
m_ResourceList.clear();
m_ReplacedResources.clear();
m_OrigToReplacedResources.clear();
m_ReplacedToOrigResources.clear();
m_CustomNames.clear();
m_Bookmarks.clear();
@@ -1558,13 +1559,13 @@ void CaptureContext::SetRemoteHost(int hostIdx)
bool CaptureContext::IsResourceReplaced(ResourceId id)
{
return m_ReplacedResources.contains(id);
return m_OrigToReplacedResources.contains(id);
}
ResourceId CaptureContext::GetResourceReplacement(ResourceId id)
{
auto it = m_ReplacedResources.find(id);
if(it != m_ReplacedResources.end())
auto it = m_OrigToReplacedResources.find(id);
if(it != m_OrigToReplacedResources.end())
return it.value();
return ResourceId();
@@ -1572,7 +1573,8 @@ ResourceId CaptureContext::GetResourceReplacement(ResourceId id)
void CaptureContext::RegisterReplacement(ResourceId from, ResourceId to)
{
m_ReplacedResources[from] = to;
m_OrigToReplacedResources[from] = to;
m_ReplacedToOrigResources[to] = from;
CacheResources();
@@ -1581,7 +1583,12 @@ void CaptureContext::RegisterReplacement(ResourceId from, ResourceId to)
void CaptureContext::UnregisterReplacement(ResourceId id)
{
m_ReplacedResources.remove(id);
auto it = m_OrigToReplacedResources.find(id);
if(it != m_OrigToReplacedResources.end())
{
m_ReplacedToOrigResources.remove(it.value());
m_OrigToReplacedResources.remove(it.key());
}
CacheResources();
@@ -1962,6 +1969,9 @@ rdcstr CaptureContext::GetResourceNameUnsuffixed(ResourceId id)
if(id == ResourceId())
return tr("No Resource");
if(m_ReplacedToOrigResources.contains(id))
return GetResourceName(m_ReplacedToOrigResources[id]);
ResourceDescription *desc = GetResource(id);
if(desc)
@@ -1984,7 +1994,7 @@ rdcstr CaptureContext::GetResourceName(ResourceId id)
{
rdcstr ret = GetResourceNameUnsuffixed(id);
if(m_ReplacedResources.contains(id))
if(m_OrigToReplacedResources.contains(id))
ret += tr(" (Edited)");
return ret;
+4 -1
View File
@@ -384,7 +384,10 @@ private:
QMap<ResourceId, QString> m_CustomNames;
int m_CustomNameCachedID = 1;
QMap<ResourceId, ResourceId> m_ReplacedResources;
// map orig replaced -> edited replacement ID
QMap<ResourceId, ResourceId> m_OrigToReplacedResources;
// reverse map, edited ID -> orig
QMap<ResourceId, ResourceId> m_ReplacedToOrigResources;
const SDFile *m_StructuredFile = NULL;
SDFile m_DummySDFile;
+3 -6
View File
@@ -477,10 +477,7 @@ void ShaderViewer::debugShader(const ShaderBindpointMapping *bind, const ShaderR
if(m_ShaderDetails && !m_ShaderDetails->debugInfo.files.isEmpty())
{
if(m_Trace)
setWindowTitle(QFormatStr("Debug %1() - %2").arg(m_ShaderDetails->entryPoint).arg(debugContext));
else
setWindowTitle(m_ShaderDetails->entryPoint);
updateWindowTitle();
// add all the files, skipping any that have empty contents. We push a NULL in that case so the
// indices still match up with what the debug info expects. Debug info *shouldn't* point us at
@@ -950,13 +947,13 @@ void ShaderViewer::updateWindowTitle()
{
if(m_ShaderDetails)
{
QString shaderName = m_Ctx.GetResourceName(m_ShaderDetails->resourceId);
QString shaderName = m_Ctx.GetResourceNameUnsuffixed(m_ShaderDetails->resourceId);
// On D3D12, get the shader name from the pipeline rather than the shader itself
// for the benefit of D3D12 which doesn't have separate shader objects
if(m_Ctx.CurPipelineState().IsCaptureD3D12())
shaderName = QFormatStr("%1 %2")
.arg(m_Ctx.GetResourceName(m_Pipeline))
.arg(m_Ctx.GetResourceNameUnsuffixed(m_Pipeline))
.arg(m_Ctx.CurPipelineState().Abbrev(m_ShaderDetails->stage));
if(m_Trace)