Shader: Handle type as expressions

This commit is contained in:
Jérôme Leclercq
2022-02-08 17:03:34 +01:00
parent 5ce8120a0c
commit 402e16bd2b
53 changed files with 1746 additions and 1141 deletions

View File

@@ -184,8 +184,8 @@ namespace Nz
if (!uberShader->HasOption(optionName, &optionPtr))
return InvalidOption;
if (optionPtr->type != ShaderAst::ExpressionType{ ShaderAst::PrimitiveType::Int32 })
throw std::runtime_error("Location options must be of type i32");
//if (optionPtr->type != ShaderAst::ExpressionType{ ShaderAst::PrimitiveType::Int32 })
// throw std::runtime_error("Location options must be of type i32");
return optionPtr->index;
};

View File

@@ -251,8 +251,8 @@ namespace Nz
if (!uberShader->HasOption(optionName, &optionPtr))
return InvalidOption;
if (optionPtr->type != ShaderAst::ExpressionType{ ShaderAst::PrimitiveType::Int32 })
throw std::runtime_error("Location options must be of type i32");
//if (optionPtr->type != ShaderAst::ExpressionType{ ShaderAst::PrimitiveType::Int32 })
// throw std::runtime_error("Location options must be of type i32");
return optionPtr->index;
};

View File

@@ -10,7 +10,7 @@ option BillboardSizeRotLocation: i32 = -1;
// Vertex declaration related options
option ColorLocation: i32 = -1;
option PosLocation: i32 = -1;
option PosLocation: i32;
option UvLocation: i32 = -1;
const HasVertexColor = (ColorLocation >= 0);

View File

@@ -20,7 +20,7 @@ option BillboardSizeRotLocation: i32 = -1;
// Vertex declaration related options
option ColorLocation: i32 = -1;
option NormalLocation: i32 = -1;
option PosLocation: i32 = -1;
option PosLocation: i32;
option TangentLocation: i32 = -1;
option UvLocation: i32 = -1;

View File

@@ -31,11 +31,10 @@ namespace Nz
supportedStageType |= stageType;
};
callbacks.onOptionDeclaration = [&](const std::string& optionName, const ShaderAst::ExpressionType& optionType)
callbacks.onOptionDeclaration = [&](const std::string& optionName, const ShaderAst::ExpressionValue<ShaderAst::ExpressionType>& optionType)
{
m_optionIndexByName[optionName] = Option{
optionCount,
optionType
optionCount
};
optionCount++;