List an encoding for shader debuginfo source. Add HLSL/spvas to enum

This commit is contained in:
baldurk
2018-08-09 16:56:50 +01:00
parent 492a9bf828
commit 7de19f4c35
7 changed files with 39 additions and 3 deletions
+3
View File
@@ -831,9 +831,12 @@ std::string DoStringise(const ShaderEncoding &el)
{
BEGIN_ENUM_STRINGISE(ShaderEncoding)
{
STRINGISE_ENUM_CLASS(Unknown);
STRINGISE_ENUM_CLASS(DXBC);
STRINGISE_ENUM_CLASS(GLSL);
STRINGISE_ENUM_CLASS_NAMED(SPIRV, "SPIR-V");
STRINGISE_ENUM_CLASS_NAMED(SPIRVAsm, "SPIR-V Asm");
STRINGISE_ENUM_CLASS(HLSL);
}
END_ENUM_STRINGISE();
}
+19
View File
@@ -1376,6 +1376,10 @@ constexpr inline bool IsD3D(GraphicsAPI api)
DOCUMENT(R"(Identifies a shader encoding used to pass shader code to an API.
.. data:: Unknown
Unknown or unprocessable format.
.. data:: DXBC
DXBC binary shader, used by D3D11 and D3D12.
@@ -1387,14 +1391,29 @@ DOCUMENT(R"(Identifies a shader encoding used to pass shader code to an API.
.. data:: SPIRV
SPIR-V binary shader, used by Vulkan and with an extension by OpenGL.
.. data:: SPIRVAsm
Canonical SPIR-V assembly form, used (indirectly via :data:`SPIRV`) by Vulkan and with an
extension by OpenGL.
.. data:: HLSL
HLSL in string format, used by D3D11, D3D12, and Vulkan/GL via compilation to SPIR-V.
)");
enum class ShaderEncoding : uint32_t
{
Unknown,
First = Unknown,
DXBC,
GLSL,
SPIRV,
SPIRVAsm,
HLSL,
Count,
};
ITERABLE_OPERATORS(ShaderEncoding);
DECLARE_REFLECTION_ENUM(ShaderEncoding);
DOCUMENT(R"(A primitive topology used for processing vertex data.
+4 -1
View File
@@ -915,11 +915,14 @@ struct ShaderDebugInfo
DOCUMENT("A :class:`ShaderCompileFlags` containing the flags used to compile this shader.");
ShaderCompileFlags compileFlags;
DOCUMENT(R"(A list of :class:`ShaderSourceFile`.
DOCUMENT(R"(A list of :class:`ShaderSourceFile`, encoded in the form denoted by :data:`encoding`.
The first entry in the list is always the file where the entry point is.
)");
rdcarray<ShaderSourceFile> files;
DOCUMENT("The :class:`ShaderEncoding` of the source. See :data:`files`.");
ShaderEncoding encoding = ShaderEncoding::Unknown;
};
DECLARE_REFLECTION_STRUCT(ShaderDebugInfo);
@@ -274,6 +274,8 @@ void WrappedOpenGL::ShaderData::ProcessCompilation(WrappedOpenGL &drv, ResourceI
reflection.stage = MakeShaderStage(type);
reflection.debugInfo.encoding = ShaderEncoding::GLSL;
reflection.debugInfo.files.resize(1);
reflection.debugInfo.files[0].filename = "main.glsl";
reflection.debugInfo.files[0].contents = concatenated;
@@ -226,6 +226,8 @@ void MakeShaderReflection(DXBC::DXBCFile *dxbc, ShaderReflection *refl,
{
refl->entryPoint = dxbc->m_DebugInfo->GetEntryFunction();
refl->debugInfo.encoding = ShaderEncoding::HLSL;
refl->debugInfo.compileFlags = DXBC::EncodeFlags(dxbc->m_DebugInfo);
refl->debugInfo.files.resize(dxbc->m_DebugInfo->Files.size());
@@ -3963,6 +3963,12 @@ void SPVModule::MakeReflection(ShaderStage stage, const string &entryPoint,
// TODO sort these so that the entry point is in the first file
if(!sourceFiles.empty())
{
reflection.debugInfo.encoding = ShaderEncoding::Unknown;
if(sourceLang == spv::SourceLanguageHLSL)
reflection.debugInfo.encoding = ShaderEncoding::HLSL;
else if(sourceLang == spv::SourceLanguageGLSL || sourceLang == spv::SourceLanguageESSL)
reflection.debugInfo.encoding = ShaderEncoding::GLSL;
reflection.debugInfo.files.reserve(sourceFiles.size());
for(size_t i = 0; i < sourceFiles.size(); i++)
+3 -2
View File
@@ -288,8 +288,9 @@ void DoSerialise(SerialiserType &ser, ShaderDebugInfo &el)
{
SERIALISE_MEMBER(compileFlags);
SERIALISE_MEMBER(files);
SERIALISE_MEMBER(encoding);
SIZE_CHECK(32);
SIZE_CHECK(40);
}
template <typename SerialiserType>
@@ -319,7 +320,7 @@ void DoSerialise(SerialiserType &ser, ShaderReflection &el)
SERIALISE_MEMBER(interfaces);
SIZE_CHECK(216);
SIZE_CHECK(224);
}
template <typename SerialiserType>