mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-12 01:30:57 +00:00
Improve handling of compilers & command line for edited shaders
* We store the compiler used (when known) in shader debug info and use that to select the compiler for editing as even higher priority than the default for a given language/encoding combination. * We also ensure that for known tools we add the input and output parameters last, after any custom parameters, so that they are always present regardless of what the user puts in.
This commit is contained in:
@@ -191,8 +191,8 @@ ShaderViewer::ShaderViewer(ICaptureContext &ctx, QWidget *parent)
|
||||
}
|
||||
|
||||
void ShaderViewer::editShader(ResourceId id, ShaderStage stage, const QString &entryPoint,
|
||||
const rdcstrpairs &files, ShaderEncoding shaderEncoding,
|
||||
ShaderCompileFlags flags)
|
||||
const rdcstrpairs &files, KnownShaderTool knownTool,
|
||||
ShaderEncoding shaderEncoding, ShaderCompileFlags flags)
|
||||
{
|
||||
m_Scintillas.removeOne(m_DisassemblyView);
|
||||
ui->docking->removeToolWindow(m_DisassemblyFrame);
|
||||
@@ -236,6 +236,28 @@ void ShaderViewer::editShader(ResourceId id, ShaderStage stage, const QString &e
|
||||
MarkModification();
|
||||
});
|
||||
|
||||
// if we know the shader was originally compiled with a specific tool, pick the first matching
|
||||
// tool we have configured.
|
||||
if(knownTool != KnownShaderTool::Unknown)
|
||||
{
|
||||
for(const ShaderProcessingTool &tool : m_Ctx.Config().ShaderProcessors)
|
||||
{
|
||||
// skip tools that can't accept our inputs, or doesn't produce a supported output
|
||||
if(tool.tool == knownTool)
|
||||
{
|
||||
for(int i = 0; i < ui->compileTool->count(); i++)
|
||||
{
|
||||
if(ui->compileTool->itemText(i) == tool.name)
|
||||
{
|
||||
ui->compileTool->setCurrentIndex(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if it's a custom shader, hide the group entirely (don't allow customisation of compile
|
||||
// parameters). We can still use it to store the parameters passed in. When visible we collapse it
|
||||
// by default.
|
||||
@@ -1248,8 +1270,9 @@ ShaderViewer *ShaderViewer::LoadEditor(ICaptureContext &ctx, QVariantMap data,
|
||||
encoding = ShaderEncoding::HLSL;
|
||||
}
|
||||
|
||||
ShaderViewer *view = EditShader(ctx, id, stage, entryPoint, files, encoding, flags, saveCallback,
|
||||
revertCallback, modifyCallback, parent);
|
||||
ShaderViewer *view =
|
||||
EditShader(ctx, id, stage, entryPoint, files, KnownShaderTool::Unknown, encoding, flags,
|
||||
saveCallback, revertCallback, modifyCallback, parent);
|
||||
|
||||
int toolIndex = -1;
|
||||
|
||||
@@ -5775,7 +5798,8 @@ void ShaderViewer::PopulateCompileToolParameters()
|
||||
ShaderCompileFlag &flag = m_Flags.flags[i];
|
||||
if(flag.name == "@cmdline")
|
||||
{
|
||||
// append command line from saved flags
|
||||
// append command line from saved flags, so any specified options override the defaults if
|
||||
// they're specified twice
|
||||
ui->toolCommandLine->setPlainText(ui->toolCommandLine->toPlainText() +
|
||||
lit(" %1").arg(flag.value));
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user