Add shader type

This commit is contained in:
Jérôme Leclercq
2020-07-27 18:52:58 +02:00
parent 6d0a59caab
commit 59add283cf
15 changed files with 224 additions and 12 deletions

View File

@@ -31,6 +31,9 @@ namespace Nz
ByteStream byteStream(source, sourceSize);
auto shader = Nz::UnserializeShader(byteStream);
if (shader.GetStage() != type)
throw std::runtime_error("incompatible shader stage");
const auto& context = device.GetReferenceContext();
const auto& contextParams = context.GetParams();

View File

@@ -261,6 +261,8 @@ namespace Nz
{
m_stream << s_magicNumber << s_currentVersion;
m_stream << UInt32(shader.GetStage());
auto SerializeType = [&](const ShaderExpressionType& type)
{
std::visit([&](auto&& arg)
@@ -454,7 +456,10 @@ namespace Nz
if (version > s_currentVersion)
throw std::runtime_error("unsupported version");
ShaderAst shader;
UInt32 shaderStage;
m_stream >> shaderStage;
ShaderAst shader(static_cast<ShaderStageType>(shaderStage));
UInt32 structCount;
m_stream >> structCount;