mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-09-24 14:45:53 +00:00
Add shader's ID and entry point to the shader reflection struct
* This allows better identification of a shader from its reflection bundle. The entry point was already 'optionally' in the debug info struct which is no longer a great location for it. * For APIs where the entry point isn't contractual and it might not be listed, instead we just fall back to 'main'. This means that the UI or anyone fetching the info can be guaranteed that some sensible entry point will be listed. * Also for the debug info, remove the 'entryFile' index and instead just guarantee that as much as possible the entry point will be in the first file in the list.
This commit is contained in:
@@ -872,19 +872,11 @@ void D3D11PipelineStateViewer::setShaderState(const D3D11Pipe::Shader &stage, QL
|
||||
else
|
||||
shader->setText(ToQStr(stage.name));
|
||||
|
||||
if(shaderDetails && !shaderDetails->DebugInfo.entryFunc.empty() &&
|
||||
!shaderDetails->DebugInfo.files.empty())
|
||||
if(shaderDetails && !shaderDetails->DebugInfo.files.empty())
|
||||
{
|
||||
QString shaderfn;
|
||||
|
||||
int entryFile = shaderDetails->DebugInfo.entryFile;
|
||||
if(entryFile < 0 || entryFile >= shaderDetails->DebugInfo.files.count)
|
||||
entryFile = 0;
|
||||
|
||||
shaderfn = QFileInfo(ToQStr(shaderDetails->DebugInfo.files[entryFile].first)).fileName();
|
||||
|
||||
shader->setText(
|
||||
QFormatStr("%1() - %2").arg(ToQStr(shaderDetails->DebugInfo.entryFunc)).arg(shaderfn));
|
||||
shader->setText(QFormatStr("%1() - %2")
|
||||
.arg(ToQStr(shaderDetails->EntryPoint))
|
||||
.arg(QFileInfo(ToQStr(shaderDetails->DebugInfo.files[0].first)).fileName()));
|
||||
}
|
||||
|
||||
int vs = 0;
|
||||
@@ -1141,8 +1133,8 @@ void D3D11PipelineStateViewer::setState()
|
||||
{
|
||||
QString layout = ToQStr(state.m_IA.name);
|
||||
|
||||
if(state.m_IA.Bytecode && !state.m_IA.Bytecode->DebugInfo.entryFunc.empty())
|
||||
layout += QFormatStr(" (%1)").arg(ToQStr(state.m_IA.Bytecode->DebugInfo.entryFunc));
|
||||
if(state.m_IA.Bytecode && !state.m_IA.Bytecode->DebugInfo.files.empty())
|
||||
layout += QFormatStr(" (%1)").arg(ToQStr(state.m_IA.Bytecode->EntryPoint));
|
||||
|
||||
ui->iaBytecode->setText(layout);
|
||||
}
|
||||
@@ -2533,19 +2525,11 @@ void D3D11PipelineStateViewer::exportHTML(QXmlStreamWriter &xml, D3D11Pipe::Shad
|
||||
else
|
||||
shadername = ToQStr(sh.name);
|
||||
|
||||
if(shaderDetails && shaderDetails->DebugInfo.entryFunc.count > 0 &&
|
||||
shaderDetails->DebugInfo.files.count > 0)
|
||||
if(shaderDetails && shaderDetails->DebugInfo.files.count > 0)
|
||||
{
|
||||
QString shaderfn;
|
||||
|
||||
int entryFile = shaderDetails->DebugInfo.entryFile;
|
||||
if(entryFile < 0 || entryFile >= shaderDetails->DebugInfo.files.count)
|
||||
entryFile = 0;
|
||||
|
||||
shaderfn = QFileInfo(ToQStr(shaderDetails->DebugInfo.files[entryFile].first)).fileName();
|
||||
|
||||
shadername =
|
||||
QFormatStr("%1() - %2").arg(ToQStr(shaderDetails->DebugInfo.entryFunc)).arg(shaderfn);
|
||||
shadername = QFormatStr("%1() - %2")
|
||||
.arg(ToQStr(shaderDetails->EntryPoint))
|
||||
.arg(QFileInfo(ToQStr(shaderDetails->DebugInfo.files[0].first)).fileName());
|
||||
}
|
||||
|
||||
xml.writeStartElement(lit("p"));
|
||||
|
||||
@@ -961,19 +961,11 @@ void D3D12PipelineStateViewer::setShaderState(const D3D12Pipe::Shader &stage, QL
|
||||
shader->setText(
|
||||
tr("%1 - %2 Shader").arg(ToQStr(state.name)).arg(ToQStr(stage.stage, GraphicsAPI::D3D12)));
|
||||
|
||||
if(shaderDetails && !shaderDetails->DebugInfo.entryFunc.empty() &&
|
||||
!shaderDetails->DebugInfo.files.empty())
|
||||
if(shaderDetails && !shaderDetails->DebugInfo.files.empty())
|
||||
{
|
||||
QString shaderfn;
|
||||
|
||||
int entryFile = shaderDetails->DebugInfo.entryFile;
|
||||
if(entryFile < 0 || entryFile >= shaderDetails->DebugInfo.files.count)
|
||||
entryFile = 0;
|
||||
|
||||
shaderfn = QFileInfo(ToQStr(shaderDetails->DebugInfo.files[entryFile].first)).fileName();
|
||||
|
||||
shader->setText(
|
||||
QFormatStr("%1() - %2").arg(ToQStr(shaderDetails->DebugInfo.entryFunc)).arg(shaderfn));
|
||||
shader->setText(QFormatStr("%1() - %2")
|
||||
.arg(ToQStr(shaderDetails->EntryPoint))
|
||||
.arg(QFileInfo(ToQStr(shaderDetails->DebugInfo.files[0].first)).fileName()));
|
||||
}
|
||||
|
||||
int vs = 0;
|
||||
@@ -2429,19 +2421,11 @@ void D3D12PipelineStateViewer::exportHTML(QXmlStreamWriter &xml, D3D12Pipe::Shad
|
||||
shadername =
|
||||
tr("%1 - %2 Shader").arg(ToQStr(state.name)).arg(ToQStr(sh.stage, GraphicsAPI::D3D12));
|
||||
|
||||
if(shaderDetails && !shaderDetails->DebugInfo.entryFunc.empty() &&
|
||||
!shaderDetails->DebugInfo.files.empty())
|
||||
if(shaderDetails && !shaderDetails->DebugInfo.files.empty())
|
||||
{
|
||||
QString shaderfn;
|
||||
|
||||
int entryFile = shaderDetails->DebugInfo.entryFile;
|
||||
if(entryFile < 0 || entryFile >= shaderDetails->DebugInfo.files.count)
|
||||
entryFile = 0;
|
||||
|
||||
shaderfn = QFileInfo(ToQStr(shaderDetails->DebugInfo.files[entryFile].first)).fileName();
|
||||
|
||||
shadername =
|
||||
QFormatStr("%1() - %2").arg(ToQStr(shaderDetails->DebugInfo.entryFunc)).arg(shaderfn);
|
||||
shadername = QFormatStr("%1() - %2")
|
||||
.arg(ToQStr(shaderDetails->EntryPoint))
|
||||
.arg(QFileInfo(ToQStr(shaderDetails->DebugInfo.files[0].first)).fileName());
|
||||
}
|
||||
|
||||
xml.writeStartElement(lit("p"));
|
||||
|
||||
@@ -531,9 +531,9 @@ bool PipelineStateViewer::PrepareShaderEditing(const ShaderReflection *shaderDet
|
||||
QString &entryFunc, QStringMap &files,
|
||||
QString &mainfile)
|
||||
{
|
||||
if(!shaderDetails->DebugInfo.entryFunc.empty() && !shaderDetails->DebugInfo.files.empty())
|
||||
if(!shaderDetails->DebugInfo.files.empty())
|
||||
{
|
||||
entryFunc = ToQStr(shaderDetails->DebugInfo.entryFunc);
|
||||
entryFunc = ToQStr(shaderDetails->EntryPoint);
|
||||
|
||||
QStringList uniqueFiles;
|
||||
|
||||
@@ -550,11 +550,7 @@ bool PipelineStateViewer::PrepareShaderEditing(const ShaderReflection *shaderDet
|
||||
files[filename] = ToQStr(s.second);
|
||||
}
|
||||
|
||||
int entryFile = shaderDetails->DebugInfo.entryFile;
|
||||
if(entryFile < 0 || entryFile >= shaderDetails->DebugInfo.files.count)
|
||||
entryFile = 0;
|
||||
|
||||
mainfile = ToQStr(shaderDetails->DebugInfo.files[entryFile].first);
|
||||
mainfile = ToQStr(shaderDetails->DebugInfo.files[0].first);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1251,24 +1251,15 @@ void VulkanPipelineStateViewer::setShaderState(const VKPipe::Shader &stage,
|
||||
else
|
||||
shader->setText(ToQStr(stage.name));
|
||||
|
||||
if(shaderDetails != NULL && shaderDetails->DebugInfo.entryFunc.count > 0)
|
||||
if(shaderDetails != NULL)
|
||||
{
|
||||
QString entryFunc = ToQStr(shaderDetails->DebugInfo.entryFunc);
|
||||
QString entryFunc = ToQStr(shaderDetails->EntryPoint);
|
||||
if(shaderDetails->DebugInfo.files.count > 0 || entryFunc != lit("main"))
|
||||
shader->setText(entryFunc + lit("()"));
|
||||
|
||||
if(shaderDetails->DebugInfo.files.count > 0)
|
||||
{
|
||||
QString shaderfn = QString();
|
||||
|
||||
int entryFile = shaderDetails->DebugInfo.entryFile;
|
||||
if(entryFile < 0 || entryFile >= shaderDetails->DebugInfo.files.count)
|
||||
entryFile = 0;
|
||||
|
||||
shaderfn = QFileInfo(ToQStr(shaderDetails->DebugInfo.files[entryFile].first)).fileName();
|
||||
|
||||
shader->setText(entryFunc + lit("() - ") + shaderfn);
|
||||
}
|
||||
shader->setText(entryFunc + lit("() - ") +
|
||||
QFileInfo(ToQStr(shaderDetails->DebugInfo.files[0].first)).fileName());
|
||||
}
|
||||
|
||||
int vs = 0;
|
||||
@@ -2554,24 +2545,15 @@ void VulkanPipelineStateViewer::exportHTML(QXmlStreamWriter &xml, VKPipe::Shader
|
||||
else
|
||||
shadername = ToQStr(sh.name);
|
||||
|
||||
if(shaderDetails && shaderDetails->DebugInfo.entryFunc.count > 0)
|
||||
if(shaderDetails)
|
||||
{
|
||||
QString entryFunc = ToQStr(shaderDetails->DebugInfo.entryFunc);
|
||||
if(shaderDetails->DebugInfo.files.count > 0 || entryFunc != lit("main"))
|
||||
QString entryFunc = ToQStr(shaderDetails->EntryPoint);
|
||||
if(entryFunc != lit("main"))
|
||||
shadername = QFormatStr("%1()").arg(entryFunc);
|
||||
|
||||
if(shaderDetails->DebugInfo.files.count > 0)
|
||||
{
|
||||
QString shaderfn = QString();
|
||||
|
||||
int entryFile = shaderDetails->DebugInfo.entryFile;
|
||||
if(entryFile < 0 || entryFile >= shaderDetails->DebugInfo.files.count)
|
||||
entryFile = 0;
|
||||
|
||||
shaderfn = QFileInfo(ToQStr(shaderDetails->DebugInfo.files[entryFile].first)).fileName();
|
||||
|
||||
shadername = QFormatStr("%1() - %2").arg(entryFunc).arg(shaderfn);
|
||||
}
|
||||
else if(shaderDetails->DebugInfo.files.count > 0)
|
||||
shadername = QFormatStr("%1() - %2")
|
||||
.arg(entryFunc)
|
||||
.arg(QFileInfo(ToQStr(shaderDetails->DebugInfo.files[0].first)).fileName());
|
||||
}
|
||||
|
||||
xml.writeStartElement(lit("p"));
|
||||
|
||||
@@ -307,17 +307,16 @@ void ShaderViewer::debugShader(const ShaderBindpointMapping *bind, const ShaderR
|
||||
&ShaderViewer::disasm_tooltipHide);
|
||||
}
|
||||
|
||||
if(shader && shader->DebugInfo.entryFunc.count > 0 && shader->DebugInfo.files.count > 0)
|
||||
if(shader && shader->DebugInfo.files.count > 0)
|
||||
{
|
||||
if(trace)
|
||||
setWindowTitle(
|
||||
QFormatStr("Debug %1() - %2").arg(ToQStr(shader->DebugInfo.entryFunc)).arg(debugContext));
|
||||
setWindowTitle(QFormatStr("Debug %1() - %2").arg(ToQStr(shader->EntryPoint)).arg(debugContext));
|
||||
else
|
||||
setWindowTitle(ToQStr(shader->DebugInfo.entryFunc));
|
||||
setWindowTitle(ToQStr(shader->EntryPoint));
|
||||
|
||||
int fileIdx = 0;
|
||||
|
||||
QWidget *sel = m_DisassemblyView;
|
||||
QWidget *sel = NULL;
|
||||
for(auto &f : shader->DebugInfo.files)
|
||||
{
|
||||
QString name = QFileInfo(ToQStr(f.first)).fileName();
|
||||
@@ -325,21 +324,13 @@ void ShaderViewer::debugShader(const ShaderBindpointMapping *bind, const ShaderR
|
||||
|
||||
ScintillaEdit *scintilla = AddFileScintilla(name, text);
|
||||
|
||||
if(shader->DebugInfo.entryFile >= 0 &&
|
||||
shader->DebugInfo.entryFile < shader->DebugInfo.files.count)
|
||||
{
|
||||
if(fileIdx == shader->DebugInfo.entryFile)
|
||||
sel = scintilla;
|
||||
}
|
||||
else if(text.contains(ToQStr(shader->DebugInfo.entryFunc)))
|
||||
{
|
||||
if(sel == NULL)
|
||||
sel = scintilla;
|
||||
}
|
||||
|
||||
fileIdx++;
|
||||
}
|
||||
|
||||
if(trace)
|
||||
if(trace || sel == NULL)
|
||||
sel = m_DisassemblyView;
|
||||
|
||||
if(shader->DebugInfo.files.count > 2)
|
||||
|
||||
Reference in New Issue
Block a user