mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-04 17:10:47 +00:00
Add identified support for slang (the language and the tool)
This commit is contained in:
@@ -724,6 +724,11 @@ rdcstr ShaderProcessingTool::DefaultArguments() const
|
||||
return "-T {hlsl_stage2}_6_0 -E {entry_point}";
|
||||
else if(tool == KnownShaderTool::fxc)
|
||||
return "/T {hlsl_stage2}_5_0 /E {entry_point}";
|
||||
else if(tool == KnownShaderTool::slangSPIRV)
|
||||
return "-lang slang -target spirv -emit-spirv-directly -g2 -entry {entry_point} -stage "
|
||||
"{full_stage}";
|
||||
else if(tool == KnownShaderTool::slangDXIL)
|
||||
return "-lang slang -target dxil -g2 -entry {entry_point} -stage {full_stage}";
|
||||
|
||||
return args;
|
||||
}
|
||||
@@ -747,6 +752,8 @@ rdcstr ShaderProcessingTool::IOArguments() const
|
||||
return "-Fo {output_file} {input_file}";
|
||||
else if(tool == KnownShaderTool::fxc)
|
||||
return "/Fo {output_file} {input_file}";
|
||||
else if(tool == KnownShaderTool::slangSPIRV || tool == KnownShaderTool::slangDXIL)
|
||||
return "-o {output_file} {input_file}";
|
||||
|
||||
return rdcstr();
|
||||
}
|
||||
|
||||
@@ -33,6 +33,11 @@ static const QString glsl_stage4[arraydim<ShaderStage>()] = {
|
||||
lit("frag"), lit("comp"), lit("task"), lit("mesh"),
|
||||
};
|
||||
|
||||
static const QString full_stage[arraydim<ShaderStage>()] = {
|
||||
lit("vertex"), lit("hull"), lit("domain"), lit("geometry"),
|
||||
lit("pixel"), lit("compute"), lit("amplification"), lit("mesh"),
|
||||
};
|
||||
|
||||
static const QString hlsl_stage2[arraydim<ShaderStage>()] = {
|
||||
lit("vs"), lit("hs"), lit("ds"), lit("gs"), lit("ps"), lit("cs"), lit("as"), lit("ms"),
|
||||
};
|
||||
@@ -284,6 +289,8 @@ ShaderToolOutput ShaderProcessingTool::DisassembleShader(QWidget *window,
|
||||
arg.replace(0, 13, glsl_stage4[int(shaderDetails->stage)]);
|
||||
if(arg.left(13) == lit("{hlsl_stage2}"))
|
||||
arg.replace(0, 13, hlsl_stage2[int(shaderDetails->stage)]);
|
||||
if(arg.left(12) == lit("{full_stage}"))
|
||||
arg.replace(0, 12, full_stage[int(stage)]);
|
||||
if(arg.left(11) == lit("{spirv_ver}"))
|
||||
arg.replace(0, 11, spirvVer);
|
||||
if(arg.left(12) == lit("{vulkan_ver}"))
|
||||
@@ -342,6 +349,8 @@ ShaderToolOutput ShaderProcessingTool::CompileShader(QWidget *window, rdcstr sou
|
||||
arg.replace(0, 13, glsl_stage4[int(stage)]);
|
||||
if(arg.left(13) == lit("{hlsl_stage2}"))
|
||||
arg.replace(0, 13, hlsl_stage2[int(stage)]);
|
||||
if(arg.left(12) == lit("{full_stage}"))
|
||||
arg.replace(0, 12, full_stage[int(stage)]);
|
||||
if(arg.left(11) == lit("{spirv_ver}"))
|
||||
arg.replace(0, 11, spirvVer);
|
||||
if(arg.left(12) == lit("{vulkan_ver}"))
|
||||
|
||||
@@ -1529,6 +1529,7 @@ bool PipelineStateViewer::SaveShaderFile(const ShaderReflection *shader)
|
||||
case ShaderEncoding::SPIRVAsm:
|
||||
case ShaderEncoding::OpenGLSPIRVAsm: filter = tr("SPIR-V assembly files (*.spvasm)"); break;
|
||||
case ShaderEncoding::DXIL: filter = tr("DXIL Shader files (*.dxbc)"); break;
|
||||
case ShaderEncoding::Slang: filter = tr("Slang Shader files (*.slang)"); break;
|
||||
case ShaderEncoding::Unknown:
|
||||
case ShaderEncoding::Count: filter = tr("All files (*.*)"); break;
|
||||
}
|
||||
|
||||
@@ -1394,8 +1394,10 @@ void ShaderViewer::OnEventChanged(uint32_t eventId)
|
||||
ScintillaEdit *ShaderViewer::AddFileScintilla(const QString &name, const QString &text,
|
||||
ShaderEncoding encoding)
|
||||
{
|
||||
ScintillaEdit *scintilla = MakeEditor(lit("scintilla") + name, text,
|
||||
encoding == ShaderEncoding::HLSL ? SCLEX_HLSL : SCLEX_GLSL);
|
||||
ScintillaEdit *scintilla =
|
||||
MakeEditor(lit("scintilla") + name, text,
|
||||
encoding == ShaderEncoding::HLSL || encoding == ShaderEncoding::Slang ? SCLEX_HLSL
|
||||
: SCLEX_GLSL);
|
||||
scintilla->setReadOnly(true);
|
||||
scintilla->setWindowTitle(name);
|
||||
((QWidget *)scintilla)->setProperty("name", name);
|
||||
@@ -5379,7 +5381,7 @@ vec2 RD_SelectedRange();
|
||||
|
||||
)");
|
||||
}
|
||||
else if(encoding == ShaderEncoding::HLSL)
|
||||
else if(encoding == ShaderEncoding::HLSL || encoding == ShaderEncoding::Slang)
|
||||
{
|
||||
text = lit(R"(
|
||||
/////////////////////////////////////
|
||||
@@ -5441,7 +5443,7 @@ void ShaderViewer::snippet_samplers()
|
||||
{
|
||||
ShaderEncoding encoding = currentEncoding();
|
||||
|
||||
if(encoding == ShaderEncoding::HLSL)
|
||||
if(encoding == ShaderEncoding::HLSL || encoding == ShaderEncoding::Slang)
|
||||
{
|
||||
insertSnippet(lit(R"(
|
||||
/////////////////////////////////////
|
||||
@@ -5484,7 +5486,7 @@ void ShaderViewer::snippet_resources()
|
||||
ShaderEncoding encoding = currentEncoding();
|
||||
GraphicsAPI api = m_Ctx.APIProps().localRenderer;
|
||||
|
||||
if(encoding == ShaderEncoding::HLSL)
|
||||
if(encoding == ShaderEncoding::HLSL || encoding == ShaderEncoding::Slang)
|
||||
{
|
||||
insertSnippet(lit(R"(
|
||||
/////////////////////////////////////
|
||||
@@ -6048,7 +6050,8 @@ void ShaderViewer::on_refresh_clicked()
|
||||
|
||||
QString source = files[0].second;
|
||||
|
||||
if(encoding == ShaderEncoding::HLSL || encoding == ShaderEncoding::GLSL)
|
||||
if(encoding == ShaderEncoding::HLSL || encoding == ShaderEncoding::Slang ||
|
||||
encoding == ShaderEncoding::GLSL)
|
||||
{
|
||||
bool success = ProcessIncludeDirectives(source, files);
|
||||
if(!success)
|
||||
|
||||
@@ -93,6 +93,7 @@ static QMap<QString, ShaderEncoding> encodingExtensions = {
|
||||
{lit("frag"), ShaderEncoding::GLSL},
|
||||
{lit("spvasm"), ShaderEncoding::SPIRVAsm},
|
||||
{lit("spvasm"), ShaderEncoding::OpenGLSPIRVAsm},
|
||||
{lit("slang"), ShaderEncoding::Slang},
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(Following);
|
||||
@@ -4586,7 +4587,7 @@ void TextureViewer::on_customCreate_clicked()
|
||||
|
||||
QString src;
|
||||
|
||||
if(enc == ShaderEncoding::HLSL)
|
||||
if(enc == ShaderEncoding::HLSL || enc == ShaderEncoding::Slang)
|
||||
{
|
||||
src =
|
||||
lit("float4 main(float4 pos : SV_Position, float4 uv : TEXCOORD0) : SV_Target0\n"
|
||||
|
||||
@@ -1043,6 +1043,7 @@ rdcstr DoStringise(const ShaderEncoding &el)
|
||||
STRINGISE_ENUM_CLASS(DXIL);
|
||||
STRINGISE_ENUM_CLASS_NAMED(OpenGLSPIRV, "SPIR-V (OpenGL)");
|
||||
STRINGISE_ENUM_CLASS_NAMED(OpenGLSPIRVAsm, "SPIR-V Asm (OpenGL)");
|
||||
STRINGISE_ENUM_CLASS(Slang);
|
||||
}
|
||||
END_ENUM_STRINGISE();
|
||||
}
|
||||
@@ -1065,6 +1066,8 @@ rdcstr DoStringise(const KnownShaderTool &el)
|
||||
STRINGISE_ENUM_CLASS_NAMED(SPIRV_Cross_OpenGL, "SPIRV-Cross (OpenGL SPIR-V)");
|
||||
STRINGISE_ENUM_CLASS_NAMED(spirv_as_OpenGL, "spirv-as (OpenGL SPIR-V)");
|
||||
STRINGISE_ENUM_CLASS_NAMED(spirv_dis_OpenGL, "spirv-dis (OpenGL SPIR-V)");
|
||||
STRINGISE_ENUM_CLASS_NAMED(slangSPIRV, "slang (Vulkan SPIR-V)");
|
||||
STRINGISE_ENUM_CLASS_NAMED(slangDXIL, "slang (DXIL)");
|
||||
}
|
||||
END_ENUM_STRINGISE();
|
||||
}
|
||||
|
||||
@@ -1862,6 +1862,10 @@ DOCUMENT(R"(Identifies a shader encoding used to pass shader code to an API.
|
||||
DXIL binary shader, used by D3D12. Note that although the container is still DXBC format this is
|
||||
used to distinguish from :data:`DXBC` for compiler I/O matching.
|
||||
|
||||
.. data:: Slang
|
||||
|
||||
Slang in string format, used by the slang compiler for compilation to multiple backend formats.
|
||||
|
||||
)");
|
||||
enum class ShaderEncoding : uint32_t
|
||||
{
|
||||
@@ -1875,6 +1879,7 @@ enum class ShaderEncoding : uint32_t
|
||||
DXIL,
|
||||
OpenGLSPIRV,
|
||||
OpenGLSPIRVAsm,
|
||||
Slang,
|
||||
Count,
|
||||
};
|
||||
|
||||
@@ -1944,6 +1949,14 @@ DOCUMENT(R"(Identifies a particular known tool used for shader processing.
|
||||
|
||||
fxc Shader Compiler with DXBC output.
|
||||
|
||||
.. data:: slangSPIRV
|
||||
|
||||
`Slang Shader Compiler <https://github.com/shader-slang/slang>`_ with Vulkan SPIR-V output.
|
||||
|
||||
.. data:: slangDXIL
|
||||
|
||||
`Slang Shader Compiler <https://github.com/shader-slang/slang>`_ with DXIL output.
|
||||
|
||||
)");
|
||||
enum class KnownShaderTool : uint32_t
|
||||
{
|
||||
@@ -1961,6 +1974,8 @@ enum class KnownShaderTool : uint32_t
|
||||
SPIRV_Cross_OpenGL,
|
||||
spirv_as_OpenGL,
|
||||
spirv_dis_OpenGL,
|
||||
slangSPIRV,
|
||||
slangDXIL,
|
||||
Count,
|
||||
};
|
||||
|
||||
@@ -1991,6 +2006,8 @@ constexpr inline const char *ToolExecutable(KnownShaderTool tool)
|
||||
: tool == KnownShaderTool::dxcSPIRV ? "dxc"
|
||||
: tool == KnownShaderTool::dxcDXIL ? "dxc"
|
||||
: tool == KnownShaderTool::fxc ? "fxc"
|
||||
: tool == KnownShaderTool::slangSPIRV ? "slangc"
|
||||
: tool == KnownShaderTool::slangDXIL ? "slangc"
|
||||
: "";
|
||||
}
|
||||
|
||||
@@ -2016,6 +2033,8 @@ constexpr inline ShaderEncoding ToolInput(KnownShaderTool tool)
|
||||
: tool == KnownShaderTool::dxcSPIRV ? ShaderEncoding::HLSL
|
||||
: tool == KnownShaderTool::dxcDXIL ? ShaderEncoding::HLSL
|
||||
: tool == KnownShaderTool::fxc ? ShaderEncoding::HLSL
|
||||
: tool == KnownShaderTool::slangSPIRV ? ShaderEncoding::Slang
|
||||
: tool == KnownShaderTool::slangDXIL ? ShaderEncoding::Slang
|
||||
: ShaderEncoding::Unknown;
|
||||
}
|
||||
|
||||
@@ -2041,6 +2060,8 @@ constexpr inline ShaderEncoding ToolOutput(KnownShaderTool tool)
|
||||
: tool == KnownShaderTool::dxcSPIRV ? ShaderEncoding::SPIRV
|
||||
: tool == KnownShaderTool::dxcDXIL ? ShaderEncoding::DXIL
|
||||
: tool == KnownShaderTool::fxc ? ShaderEncoding::DXBC
|
||||
: tool == KnownShaderTool::slangSPIRV ? ShaderEncoding::SPIRV
|
||||
: tool == KnownShaderTool::slangDXIL ? ShaderEncoding::DXIL
|
||||
: ShaderEncoding::Unknown;
|
||||
}
|
||||
|
||||
@@ -2053,7 +2074,8 @@ DOCUMENT(R"(Check whether or not this is a human readable text representation.
|
||||
constexpr inline bool IsTextRepresentation(ShaderEncoding encoding)
|
||||
{
|
||||
return encoding == ShaderEncoding::HLSL || encoding == ShaderEncoding::GLSL ||
|
||||
encoding == ShaderEncoding::SPIRVAsm || encoding == ShaderEncoding::OpenGLSPIRVAsm;
|
||||
encoding == ShaderEncoding::SPIRVAsm || encoding == ShaderEncoding::OpenGLSPIRVAsm ||
|
||||
encoding == ShaderEncoding::Slang;
|
||||
}
|
||||
|
||||
DOCUMENT(R"(A primitive topology used for processing vertex data.
|
||||
|
||||
@@ -4184,6 +4184,7 @@ rdcarray<ShaderSourcePrefix> D3D12Replay::GetCustomShaderSourcePrefixes()
|
||||
{
|
||||
return {
|
||||
{ShaderEncoding::HLSL, HLSL_CUSTOM_PREFIX},
|
||||
{ShaderEncoding::Slang, HLSL_CUSTOM_PREFIX},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -954,7 +954,7 @@ void Reflector::MakeReflection(const GraphicsAPI sourceAPI, const ShaderStage st
|
||||
case SourceLanguage::ESSL:
|
||||
case SourceLanguage::GLSL: reflection.debugInfo.encoding = ShaderEncoding::GLSL; break;
|
||||
case SourceLanguage::HLSL: reflection.debugInfo.encoding = ShaderEncoding::HLSL; break;
|
||||
case SourceLanguage::Slang: reflection.debugInfo.encoding = ShaderEncoding::HLSL; break;
|
||||
case SourceLanguage::Slang: reflection.debugInfo.encoding = ShaderEncoding::Slang; break;
|
||||
case SourceLanguage::OpenCL_C:
|
||||
case SourceLanguage::OpenCL_CPP:
|
||||
case SourceLanguage::CPP_for_OpenCL:
|
||||
@@ -990,6 +990,9 @@ void Reflector::MakeReflection(const GraphicsAPI sourceAPI, const ShaderStage st
|
||||
: KnownShaderTool::spirv_as;
|
||||
break;
|
||||
case Generator::spiregg: reflection.debugInfo.compiler = KnownShaderTool::dxcSPIRV; break;
|
||||
case Generator::SlangCompiler:
|
||||
reflection.debugInfo.compiler = KnownShaderTool::slangSPIRV;
|
||||
break;
|
||||
default: reflection.debugInfo.compiler = KnownShaderTool::Unknown; break;
|
||||
}
|
||||
|
||||
|
||||
@@ -4383,6 +4383,7 @@ rdcarray<ShaderSourcePrefix> VulkanReplay::GetCustomShaderSourcePrefixes()
|
||||
// right binding and helper definitions
|
||||
return {
|
||||
{ShaderEncoding::HLSL, HLSL_CUSTOM_PREFIX},
|
||||
{ShaderEncoding::Slang, HLSL_CUSTOM_PREFIX},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user