mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-12 21:10:42 +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:
@@ -2450,8 +2450,8 @@ void CaptureContext::ShowResourceInspector()
|
||||
m_MainWindow->showResourceInspector();
|
||||
}
|
||||
|
||||
IShaderViewer *CaptureContext::EditShader(ResourceId id, ShaderStage stage,
|
||||
const rdcstr &entryPoint, const rdcstrpairs &files,
|
||||
IShaderViewer *CaptureContext::EditShader(ResourceId id, ShaderStage stage, const rdcstr &entryPoint,
|
||||
const rdcstrpairs &files, KnownShaderTool knownTool,
|
||||
ShaderEncoding shaderEncoding, ShaderCompileFlags flags,
|
||||
IShaderViewer::SaveCallback saveCallback,
|
||||
IShaderViewer::RevertCallback revertCallback)
|
||||
@@ -2479,8 +2479,8 @@ IShaderViewer *CaptureContext::EditShader(ResourceId id, ShaderStage stage,
|
||||
revertCallback(ctx, view, id);
|
||||
};
|
||||
|
||||
viewer = ShaderViewer::EditShader(*this, id, stage, entryPoint, files, shaderEncoding, flags,
|
||||
replaceSaveCallback, replaceRevertCallback,
|
||||
viewer = ShaderViewer::EditShader(*this, id, stage, entryPoint, files, knownTool, shaderEncoding,
|
||||
flags, replaceSaveCallback, replaceRevertCallback,
|
||||
[this](ShaderViewer *view, bool closed) {
|
||||
SetModification(CaptureModifications::EditedShaders);
|
||||
if(closed)
|
||||
@@ -2493,8 +2493,9 @@ IShaderViewer *CaptureContext::EditShader(ResourceId id, ShaderStage stage,
|
||||
}
|
||||
else
|
||||
{
|
||||
viewer = ShaderViewer::EditShader(*this, id, stage, entryPoint, files, shaderEncoding, flags,
|
||||
saveCallback, revertCallback, NULL, m_MainWindow->Widget());
|
||||
viewer =
|
||||
ShaderViewer::EditShader(*this, id, stage, entryPoint, files, knownTool, shaderEncoding,
|
||||
flags, saveCallback, revertCallback, NULL, m_MainWindow->Widget());
|
||||
}
|
||||
|
||||
return viewer;
|
||||
|
||||
@@ -245,8 +245,9 @@ public:
|
||||
void ShowResourceInspector() override;
|
||||
|
||||
IShaderViewer *EditShader(ResourceId id, ShaderStage stage, const rdcstr &entryPoint,
|
||||
const rdcstrpairs &files, ShaderEncoding shaderEncoding,
|
||||
ShaderCompileFlags flags, IShaderViewer::SaveCallback saveCallback,
|
||||
const rdcstrpairs &files, KnownShaderTool knownTool,
|
||||
ShaderEncoding shaderEncoding, ShaderCompileFlags flags,
|
||||
IShaderViewer::SaveCallback saveCallback,
|
||||
IShaderViewer::RevertCallback revertCallback) override;
|
||||
|
||||
void ApplyShaderEdit(IShaderViewer *viewer, ResourceId id, ShaderStage stage,
|
||||
|
||||
@@ -511,12 +511,6 @@ bool PersistantConfig::Load(const rdcstr &filename)
|
||||
// if it's declared
|
||||
if(dis.tool != KnownShaderTool::Unknown)
|
||||
tools[(size_t)dis.tool] = true;
|
||||
|
||||
for(KnownShaderTool tool : values<KnownShaderTool>())
|
||||
{
|
||||
if(QString(dis.executable).contains(ToolExecutable(tool)))
|
||||
tools[(size_t)tool] = true;
|
||||
}
|
||||
}
|
||||
|
||||
for(KnownShaderTool tool : values<KnownShaderTool>())
|
||||
@@ -524,7 +518,7 @@ bool PersistantConfig::Load(const rdcstr &filename)
|
||||
if(tool == KnownShaderTool::Unknown || tools[(size_t)tool])
|
||||
continue;
|
||||
|
||||
QString exe = ToolExecutable(tool);
|
||||
rdcstr exe = ToolExecutable(tool);
|
||||
|
||||
if(exe.isEmpty())
|
||||
continue;
|
||||
@@ -588,6 +582,7 @@ bool PersistantConfig::Load(const rdcstr &filename)
|
||||
{
|
||||
if(dis.tool != KnownShaderTool::Unknown)
|
||||
{
|
||||
dis.name = ToQStr(dis.tool);
|
||||
dis.input = ToolInput(dis.tool);
|
||||
dis.output = ToolOutput(dis.tool);
|
||||
}
|
||||
@@ -698,22 +693,47 @@ ShaderProcessingTool::ShaderProcessingTool(const QVariant &var)
|
||||
rdcstr ShaderProcessingTool::DefaultArguments() const
|
||||
{
|
||||
if(tool == KnownShaderTool::SPIRV_Cross)
|
||||
return "--output {output_file} {input_file} --vulkan-semantics --entry {entry_point} --stage "
|
||||
"{glsl_stage4}";
|
||||
return "--vulkan-semantics --entry {entry_point} --stage {glsl_stage4}";
|
||||
else if(tool == KnownShaderTool::spirv_dis)
|
||||
return "--no-color -o {output_file} {input_file}";
|
||||
return "--no-color";
|
||||
else if(tool == KnownShaderTool::glslangValidatorGLSL)
|
||||
return "-g -V -o {output_file} {input_file} -S {glsl_stage4}";
|
||||
return "-g -V -S {glsl_stage4}";
|
||||
else if(tool == KnownShaderTool::glslangValidatorHLSL)
|
||||
return "-D -g -V -o {output_file} {input_file} -S {glsl_stage4} -e {entry_point}";
|
||||
return "-D -g -V -S {glsl_stage4} -e {entry_point}";
|
||||
else if(tool == KnownShaderTool::spirv_as)
|
||||
return "-o {output_file} {input_file}";
|
||||
else if(tool == KnownShaderTool::dxc)
|
||||
return "-T {hlsl_stage2}_6_0 -E {entry_point} -Fo {output_file} {input_file} -spirv";
|
||||
return "";
|
||||
else if(tool == KnownShaderTool::dxcSPIRV)
|
||||
return "-T {hlsl_stage2}_6_0 -E {entry_point} -spirv";
|
||||
else if(tool == KnownShaderTool::dxcDXIL)
|
||||
return "-T {hlsl_stage2}_6_0 -E {entry_point}";
|
||||
else if(tool == KnownShaderTool::fxc)
|
||||
return "/T {hlsl_stage2}_5_0 /E {entry_point}";
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
rdcstr ShaderProcessingTool::IOArguments() const
|
||||
{
|
||||
if(tool == KnownShaderTool::SPIRV_Cross)
|
||||
return "--output {output_file} {input_file}";
|
||||
else if(tool == KnownShaderTool::spirv_dis)
|
||||
return "-o {output_file} {input_file}";
|
||||
else if(tool == KnownShaderTool::glslangValidatorGLSL)
|
||||
return "-o {output_file} {input_file}";
|
||||
else if(tool == KnownShaderTool::glslangValidatorHLSL)
|
||||
return "-o {output_file} {input_file}";
|
||||
else if(tool == KnownShaderTool::spirv_as)
|
||||
return "-o {output_file} {input_file}";
|
||||
else if(tool == KnownShaderTool::dxcSPIRV)
|
||||
return "-Fo {output_file} {input_file}";
|
||||
else if(tool == KnownShaderTool::dxcDXIL)
|
||||
return "-Fo {output_file} {input_file}";
|
||||
else if(tool == KnownShaderTool::fxc)
|
||||
return "/Fo {output_file} {input_file}";
|
||||
|
||||
return rdcstr();
|
||||
}
|
||||
|
||||
ShaderProcessingTool::operator QVariant() const
|
||||
{
|
||||
QVariantMap map;
|
||||
|
||||
@@ -30,126 +30,6 @@
|
||||
|
||||
class QMutex;
|
||||
|
||||
DOCUMENT(R"(Identifies a particular known tool used for shader processing.
|
||||
|
||||
.. data:: Unknown
|
||||
|
||||
Corresponds to no known tool.
|
||||
|
||||
.. data:: SPIRV_Cross
|
||||
|
||||
`SPIRV-Cross <https://github.com/KhronosGroup/SPIRV-Cross>`_.
|
||||
|
||||
.. data:: spirv_dis
|
||||
|
||||
`spirv-dis from SPIRV-Tools <https://github.com/KhronosGroup/SPIRV-Tools>`_.
|
||||
|
||||
.. data:: glslangValidatorGLSL
|
||||
|
||||
`glslang compiler (GLSL) <https://github.com/KhronosGroup/glslang>`_.
|
||||
|
||||
.. data:: glslangValidatorHLSL
|
||||
|
||||
`glslang compiler (HLSL) <https://github.com/KhronosGroup/glslang>`_.
|
||||
|
||||
.. data:: spirv_as
|
||||
|
||||
`spirv-as from SPIRV-Tools <https://github.com/KhronosGroup/SPIRV-Tools>`_.
|
||||
|
||||
.. data:: dxc
|
||||
|
||||
`DirectX Shader Compiler <https://github.com/microsoft/DirectXShaderCompiler>`_.
|
||||
|
||||
)");
|
||||
enum class KnownShaderTool : uint32_t
|
||||
{
|
||||
Unknown,
|
||||
First = Unknown,
|
||||
SPIRV_Cross,
|
||||
spirv_dis,
|
||||
glslangValidatorGLSL,
|
||||
glslangValidatorHLSL,
|
||||
spirv_as,
|
||||
dxc,
|
||||
Count,
|
||||
};
|
||||
|
||||
ITERABLE_OPERATORS(KnownShaderTool);
|
||||
|
||||
DOCUMENT(R"(Returns the default executable name with no suffix for a given :class:`KnownShaderTool`.
|
||||
|
||||
.. note::
|
||||
The executable name is returned with no suffix, e.g. ``foobar`` which may need a platform specific
|
||||
suffix like ``.exe`` appended.
|
||||
|
||||
:param KnownShaderTool tool: The tool to get the executable name for.
|
||||
:return: The default executable name for this tool, or an empty string if the tool is unrecognised.
|
||||
:rtype: str
|
||||
)");
|
||||
inline rdcstr ToolExecutable(KnownShaderTool tool)
|
||||
{
|
||||
if(tool == KnownShaderTool::SPIRV_Cross)
|
||||
return "spirv-cross";
|
||||
else if(tool == KnownShaderTool::spirv_dis)
|
||||
return "spirv-dis";
|
||||
else if(tool == KnownShaderTool::glslangValidatorGLSL)
|
||||
return "glslangValidator";
|
||||
else if(tool == KnownShaderTool::glslangValidatorHLSL)
|
||||
return "glslangValidator";
|
||||
else if(tool == KnownShaderTool::spirv_as)
|
||||
return "spirv-as";
|
||||
else if(tool == KnownShaderTool::dxc)
|
||||
return "dxc";
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
DOCUMENT(R"(Returns the expected default input :class:`~renderdoc.ShaderEncoding` that a
|
||||
:class:`KnownShaderTool` expects. This may not be accurate and may be configurable depending on the
|
||||
tool.
|
||||
|
||||
:param KnownShaderTool tool: The tool to get the input encoding for.
|
||||
:return: The encoding that this tool expects as an input by default.
|
||||
:rtype: renderdoc.ShaderEncoding
|
||||
)");
|
||||
inline ShaderEncoding ToolInput(KnownShaderTool tool)
|
||||
{
|
||||
if(tool == KnownShaderTool::SPIRV_Cross || tool == KnownShaderTool::spirv_dis)
|
||||
return ShaderEncoding::SPIRV;
|
||||
else if(tool == KnownShaderTool::glslangValidatorGLSL)
|
||||
return ShaderEncoding::GLSL;
|
||||
else if(tool == KnownShaderTool::glslangValidatorHLSL)
|
||||
return ShaderEncoding::HLSL;
|
||||
else if(tool == KnownShaderTool::spirv_as)
|
||||
return ShaderEncoding::SPIRVAsm;
|
||||
else if(tool == KnownShaderTool::dxc)
|
||||
return ShaderEncoding::HLSL;
|
||||
|
||||
return ShaderEncoding::Unknown;
|
||||
}
|
||||
|
||||
DOCUMENT(R"(Returns the expected default output :class:`~renderdoc.ShaderEncoding` that a
|
||||
:class:`KnownShaderTool` produces. This may not be accurate and may be configurable depending on the
|
||||
tool.
|
||||
|
||||
:param KnownShaderTool tool: The tool to get the output encoding for.
|
||||
:return: The encoding that this tool produces as an output by default.
|
||||
:rtype: renderdoc.ShaderEncoding
|
||||
)");
|
||||
inline ShaderEncoding ToolOutput(KnownShaderTool tool)
|
||||
{
|
||||
if(tool == KnownShaderTool::SPIRV_Cross)
|
||||
return ShaderEncoding::GLSL;
|
||||
else if(tool == KnownShaderTool::spirv_dis)
|
||||
return ShaderEncoding::SPIRVAsm;
|
||||
else if(tool == KnownShaderTool::glslangValidatorGLSL ||
|
||||
tool == KnownShaderTool::glslangValidatorHLSL || tool == KnownShaderTool::spirv_as ||
|
||||
tool == KnownShaderTool::dxc)
|
||||
return ShaderEncoding::SPIRV;
|
||||
|
||||
return ShaderEncoding::Unknown;
|
||||
}
|
||||
|
||||
DOCUMENT(R"(Contains the output from invoking a :class:`ShaderProcessingTool`, including both the
|
||||
actual output data desired as well as any stdout/stderr messages.
|
||||
)");
|
||||
@@ -241,6 +121,10 @@ struct ShaderProcessingTool
|
||||
)");
|
||||
ShaderToolOutput CompileShader(QWidget *window, rdcstr source, rdcstr entryPoint,
|
||||
ShaderStage stage, rdcstr args) const;
|
||||
|
||||
private:
|
||||
DOCUMENT("Internal function");
|
||||
rdcstr IOArguments() const;
|
||||
};
|
||||
|
||||
DECLARE_REFLECTION_STRUCT(ShaderProcessingTool);
|
||||
|
||||
@@ -2515,6 +2515,7 @@ place if needed.
|
||||
:param str entryPoint: The entry point to be used when compiling the edited shader.
|
||||
:param List[Tuple[str,str]] files: The source files, with each tuple being a pair of the filename
|
||||
and the file contents.
|
||||
:param renderdoc.KnownShaderTool knownTool: The preferred tool to use to compile, if known.
|
||||
:param renderdoc.ShaderEncoding shaderEncoding: The encoding of the input files.
|
||||
:param renderdoc.ShaderCompileFlags flags: The flags originally used to compile the shader.
|
||||
:param ShaderViewer.SaveCallback saveCallback: The callback function to call when a save/update is
|
||||
@@ -2525,8 +2526,8 @@ place if needed.
|
||||
:rtype: ShaderViewer
|
||||
)");
|
||||
virtual IShaderViewer *EditShader(ResourceId id, ShaderStage stage, const rdcstr &entryPoint,
|
||||
const rdcstrpairs &files, ShaderEncoding shaderEncoding,
|
||||
ShaderCompileFlags flags,
|
||||
const rdcstrpairs &files, KnownShaderTool knownTool,
|
||||
ShaderEncoding shaderEncoding, ShaderCompileFlags flags,
|
||||
IShaderViewer::SaveCallback saveCallback,
|
||||
IShaderViewer::RevertCallback revertCallback) = 0;
|
||||
|
||||
|
||||
@@ -36,22 +36,6 @@ static const QString hlsl_stage2[arraydim<ShaderStage>()] = {
|
||||
lit("vs"), lit("hs"), lit("ds"), lit("gs"), lit("ps"), lit("cs"),
|
||||
};
|
||||
|
||||
template <>
|
||||
rdcstr DoStringise(const KnownShaderTool &el)
|
||||
{
|
||||
BEGIN_ENUM_STRINGISE(KnownShaderTool);
|
||||
{
|
||||
STRINGISE_ENUM_CLASS_NAMED(Unknown, "Custom Tool");
|
||||
STRINGISE_ENUM_CLASS_NAMED(SPIRV_Cross, "SPIRV-Cross");
|
||||
STRINGISE_ENUM_CLASS_NAMED(spirv_dis, "spirv-dis");
|
||||
STRINGISE_ENUM_CLASS_NAMED(glslangValidatorGLSL, "glslang (GLSL)");
|
||||
STRINGISE_ENUM_CLASS_NAMED(glslangValidatorHLSL, "glslang (HLSL)");
|
||||
STRINGISE_ENUM_CLASS_NAMED(spirv_as, "spirv-as");
|
||||
STRINGISE_ENUM_CLASS_NAMED(dxc, "dxc");
|
||||
}
|
||||
END_ENUM_STRINGISE();
|
||||
}
|
||||
|
||||
static QString tmpPath(const QString &filename)
|
||||
{
|
||||
return QDir(QDir::tempPath()).absoluteFilePath(filename);
|
||||
@@ -201,6 +185,9 @@ ShaderToolOutput ShaderProcessingTool::DisassembleShader(QWidget *window,
|
||||
rdcstr arguments) const
|
||||
{
|
||||
QStringList argList = ParseArgsList(arguments.isEmpty() ? DefaultArguments() : arguments);
|
||||
// always append IO arguments for known tools, so we read/write to our own files and override any
|
||||
// dangling output specified file in the embedded command line
|
||||
argList.append(ParseArgsList(IOArguments()));
|
||||
|
||||
QString input_file, output_file;
|
||||
|
||||
@@ -253,6 +240,9 @@ ShaderToolOutput ShaderProcessingTool::CompileShader(QWidget *window, rdcstr sou
|
||||
rdcstr arguments) const
|
||||
{
|
||||
QStringList argList = ParseArgsList(arguments.isEmpty() ? DefaultArguments() : arguments);
|
||||
// always append IO arguments for known tools, so we read/write to our own files and override any
|
||||
// dangling output specified file in the embedded command line
|
||||
argList.append(ParseArgsList(IOArguments()));
|
||||
|
||||
QString input_file, output_file;
|
||||
|
||||
|
||||
@@ -74,6 +74,11 @@ rdcstr ShaderProcessingTool::DefaultArguments() const
|
||||
return "";
|
||||
}
|
||||
|
||||
rdcstr ShaderProcessingTool::IOArguments() const
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
ShaderToolOutput ShaderProcessingTool::DisassembleShader(QWidget *window,
|
||||
const ShaderReflection *shaderDetails,
|
||||
rdcstr arguments) const
|
||||
|
||||
@@ -978,10 +978,12 @@ void PipelineStateViewer::shaderEdit_clicked()
|
||||
|
||||
IShaderViewer *PipelineStateViewer::EditShader(ResourceId id, ShaderStage shaderType,
|
||||
const rdcstr &entry, ShaderCompileFlags compileFlags,
|
||||
ShaderEncoding encoding, const rdcstrpairs &files)
|
||||
KnownShaderTool knownTool,
|
||||
ShaderEncoding shaderEncoding,
|
||||
const rdcstrpairs &files)
|
||||
{
|
||||
IShaderViewer *sv =
|
||||
m_Ctx.EditShader(id, shaderType, entry, files, encoding, compileFlags, NULL, NULL);
|
||||
IShaderViewer *sv = m_Ctx.EditShader(id, shaderType, entry, files, knownTool, shaderEncoding,
|
||||
compileFlags, NULL, NULL);
|
||||
|
||||
m_Ctx.AddDockWindow(sv->Widget(), DockReference::AddTo, this);
|
||||
|
||||
@@ -1025,7 +1027,8 @@ IShaderViewer *PipelineStateViewer::EditOriginalShaderSource(ResourceId id,
|
||||
}
|
||||
|
||||
return EditShader(id, shaderDetails->stage, shaderDetails->entryPoint,
|
||||
shaderDetails->debugInfo.compileFlags, shaderDetails->debugInfo.encoding, files);
|
||||
shaderDetails->debugInfo.compileFlags, shaderDetails->debugInfo.compiler,
|
||||
shaderDetails->debugInfo.encoding, files);
|
||||
}
|
||||
|
||||
IShaderViewer *PipelineStateViewer::EditDecompiledSource(const ShaderProcessingTool &tool,
|
||||
@@ -1040,8 +1043,8 @@ IShaderViewer *PipelineStateViewer::EditDecompiledSource(const ShaderProcessingT
|
||||
rdcstrpairs files;
|
||||
files.push_back(rdcpair<rdcstr, rdcstr>("decompiled", source));
|
||||
|
||||
IShaderViewer *sv =
|
||||
EditShader(id, shaderDetails->stage, shaderDetails->entryPoint, {}, tool.output, files);
|
||||
IShaderViewer *sv = EditShader(id, shaderDetails->stage, shaderDetails->entryPoint, {},
|
||||
KnownShaderTool::Unknown, tool.output, files);
|
||||
|
||||
sv->ShowErrors(out.log);
|
||||
|
||||
@@ -1133,7 +1136,8 @@ void PipelineStateViewer::SetupShaderEditButton(QToolButton *button, ResourceId
|
||||
files.push_back(rdcpair<rdcstr, rdcstr>("pseudocode", editeddisasm));
|
||||
|
||||
EditShader(shaderId, shaderDetails->stage, shaderDetails->entryPoint,
|
||||
shaderDetails->debugInfo.compileFlags, ShaderEncoding::Unknown, files);
|
||||
shaderDetails->debugInfo.compileFlags, KnownShaderTool::Unknown,
|
||||
ShaderEncoding::Unknown, files);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -1147,7 +1151,7 @@ void PipelineStateViewer::SetupShaderEditButton(QToolButton *button, ResourceId
|
||||
"decompiled_stub.hlsl", GenerateHLSLStub(bindpointMapping, shaderDetails, entry)));
|
||||
|
||||
EditShader(shaderId, shaderDetails->stage, entry, shaderDetails->debugInfo.compileFlags,
|
||||
ShaderEncoding::HLSL, files);
|
||||
KnownShaderTool::Unknown, ShaderEncoding::HLSL, files);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -146,8 +146,8 @@ private:
|
||||
QString GenerateHLSLStub(const ShaderBindpointMapping &bindpointMapping,
|
||||
const ShaderReflection *shaderDetails, const QString &entryFunc);
|
||||
IShaderViewer *EditShader(ResourceId id, ShaderStage shaderType, const rdcstr &entry,
|
||||
ShaderCompileFlags compileFlags, ShaderEncoding encoding,
|
||||
const rdcstrpairs &files);
|
||||
ShaderCompileFlags compileFlags, KnownShaderTool knownTool,
|
||||
ShaderEncoding shaderEncoding, const rdcstrpairs &files);
|
||||
IShaderViewer *EditOriginalShaderSource(ResourceId id, const ShaderReflection *shaderDetails);
|
||||
IShaderViewer *EditDecompiledSource(const ShaderProcessingTool &tool, ResourceId id,
|
||||
const ShaderReflection *shaderDetails);
|
||||
|
||||
@@ -754,13 +754,13 @@ struct CaptureContextInvoker : ObjectForwarder<ICaptureContext>
|
||||
InvokeVoidFunction(&ICaptureContext::ShowResourceInspector);
|
||||
}
|
||||
virtual IShaderViewer *EditShader(ResourceId id, ShaderStage stage, const rdcstr &entryPoint,
|
||||
const rdcstrpairs &files, ShaderEncoding shaderEncoding,
|
||||
ShaderCompileFlags flags,
|
||||
const rdcstrpairs &files, KnownShaderTool knownTool,
|
||||
ShaderEncoding shaderEncoding, ShaderCompileFlags flags,
|
||||
IShaderViewer::SaveCallback saveCallback,
|
||||
IShaderViewer::RevertCallback revertCallback) override
|
||||
{
|
||||
return InvokeRetFunction<IShaderViewer *>(&ICaptureContext::EditShader, id, stage, entryPoint,
|
||||
files, shaderEncoding, flags, saveCallback,
|
||||
files, knownTool, shaderEncoding, flags, saveCallback,
|
||||
revertCallback);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -116,8 +116,8 @@ public:
|
||||
|
||||
static ShaderViewer *EditShader(ICaptureContext &ctx, ResourceId id, ShaderStage stage,
|
||||
const QString &entryPoint, const rdcstrpairs &files,
|
||||
ShaderEncoding shaderEncoding, ShaderCompileFlags flags,
|
||||
IShaderViewer::SaveCallback saveCallback,
|
||||
KnownShaderTool knownTool, ShaderEncoding shaderEncoding,
|
||||
ShaderCompileFlags flags, IShaderViewer::SaveCallback saveCallback,
|
||||
IShaderViewer::RevertCallback revertCallback,
|
||||
ModifyCallback modifyCallback, QWidget *parent)
|
||||
{
|
||||
@@ -125,7 +125,7 @@ public:
|
||||
ret->m_SaveCallback = saveCallback;
|
||||
ret->m_RevertCallback = revertCallback;
|
||||
ret->m_ModifyCallback = modifyCallback;
|
||||
ret->editShader(id, stage, entryPoint, files, shaderEncoding, flags);
|
||||
ret->editShader(id, stage, entryPoint, files, knownTool, shaderEncoding, flags);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -208,7 +208,8 @@ private slots:
|
||||
private:
|
||||
explicit ShaderViewer(ICaptureContext &ctx, QWidget *parent = 0);
|
||||
void editShader(ResourceId id, ShaderStage stage, const QString &entryPoint,
|
||||
const rdcstrpairs &files, ShaderEncoding shaderEncoding, ShaderCompileFlags flags);
|
||||
const rdcstrpairs &files, KnownShaderTool knownTool,
|
||||
ShaderEncoding shaderEncoding, ShaderCompileFlags flags);
|
||||
void debugShader(const ShaderBindpointMapping *bind, const ShaderReflection *shader,
|
||||
ResourceId pipeline, ShaderDebugTrace *trace, const QString &debugContext);
|
||||
|
||||
|
||||
@@ -4574,7 +4574,7 @@ void TextureViewer::on_customEdit_clicked()
|
||||
QPointer<TextureViewer> thisPointer(this);
|
||||
|
||||
IShaderViewer *s = m_Ctx.EditShader(
|
||||
ResourceId(), ShaderStage::Fragment, lit("main"), files,
|
||||
ResourceId(), ShaderStage::Fragment, lit("main"), files, KnownShaderTool::Unknown,
|
||||
encodingExtensions[QFileInfo(filename).completeSuffix()], ShaderCompileFlags(),
|
||||
// Save Callback
|
||||
[thisPointer, key, filename, path](ICaptureContext *ctx, IShaderViewer *viewer, ResourceId,
|
||||
|
||||
Reference in New Issue
Block a user