Add an enum listing how a shader's bytes are encoded.

This commit is contained in:
baldurk
2017-12-22 16:52:09 +00:00
parent 98c267cee6
commit 184c7be0b8
7 changed files with 46 additions and 2 deletions
+12
View File
@@ -781,6 +781,18 @@ std::string DoStringise(const GraphicsAPI &el)
END_ENUM_STRINGISE();
}
template <>
std::string DoStringise(const ShaderEncoding &el)
{
BEGIN_ENUM_STRINGISE(ShaderEncoding)
{
STRINGISE_ENUM_CLASS(DXBC);
STRINGISE_ENUM_CLASS(GLSL);
STRINGISE_ENUM_CLASS_NAMED(SPIRV, "SPIR-V");
}
END_ENUM_STRINGISE();
}
template <>
std::string DoStringise(const SectionType &el)
{
+23
View File
@@ -1239,6 +1239,29 @@ constexpr inline bool IsD3D(GraphicsAPI api)
return api == GraphicsAPI::D3D11 || api == GraphicsAPI::D3D12;
}
DOCUMENT(R"(Identifies a shader encoding used to pass shader code to an API.
.. data:: DXBC
DXBC binary shader, used by D3D11 and D3D12.
.. data:: GLSL
GLSL in string format, used by OpenGL.
.. data:: SPIRV
SPIR-V binary shader, used by Vulkan and with an extension by OpenGL.
)");
enum class ShaderEncoding : uint32_t
{
DXBC,
GLSL,
SPIRV,
};
DECLARE_REFLECTION_ENUM(ShaderEncoding);
DOCUMENT(R"(A primitive topology used for processing vertex data.
.. data:: Unknown
+6 -1
View File
@@ -766,7 +766,12 @@ struct ShaderReflection
"A :class:`ShaderDebugInfo` containing any embedded debugging information in this shader.");
ShaderDebugInfo debugInfo;
DOCUMENT("A raw ``bytes`` dump of the original shader, encoded in API specific binary form.");
DOCUMENT("The :class:`ShaderEncoding` of this shader. See :data:`rawBytes`.");
ShaderEncoding encoding;
DOCUMENT(R"(A raw ``bytes`` dump of the original shader, encoded in the form denoted by
:data:`encoding`.
)");
bytebuf rawBytes;
DOCUMENT("The 3D dimensions of a compute workgroup, for compute shaders.");
@@ -78,6 +78,7 @@ void WrappedOpenGL::ShaderData::Compile(WrappedOpenGL &gl, ResourceId id, GLuint
concatenated += sources[i];
}
reflection.encoding = ShaderEncoding::GLSL;
reflection.rawBytes.assign((byte *)concatenated.c_str(), concatenated.size());
}
@@ -289,6 +289,7 @@ void MakeShaderReflection(DXBC::DXBCFile *dxbc, ShaderReflection *refl,
}
}
refl->encoding = ShaderEncoding::DXBC;
refl->rawBytes = dxbc->m_ShaderBlob;
refl->dispatchThreadsDimension[0] = dxbc->DispatchThreadsDimension[0];
+2
View File
@@ -151,6 +151,7 @@ void VulkanCreationInfo::Pipeline::Init(VulkanResourceManager *resourceMan, Vulk
if(!spv.spirv.empty())
{
const std::vector<uint32_t> &spirv = spv.spirv;
reflData.refl.encoding = ShaderEncoding::SPIRV;
reflData.refl.rawBytes.assign((byte *)spirv.data(), spirv.size() * sizeof(uint32_t));
}
}
@@ -375,6 +376,7 @@ void VulkanCreationInfo::Pipeline::Init(VulkanResourceManager *resourceMan, Vulk
if(!spv.spirv.empty())
{
const vector<uint32_t> &spirv = spv.spirv;
reflData.refl.encoding = ShaderEncoding::SPIRV;
reflData.refl.rawBytes.assign((byte *)spirv.data(), spirv.size() * sizeof(uint32_t));
}
}
+1 -1
View File
@@ -310,7 +310,7 @@ void DoSerialise(SerialiserType &ser, ShaderReflection &el)
SERIALISE_MEMBER(interfaces);
SIZE_CHECK(208);
SIZE_CHECK(216);
}
template <typename SerialiserType>