Shader: Add support for exported functions
This commit is contained in:
@@ -498,6 +498,9 @@ namespace Nz::ShaderAst
|
||||
if (!Compare(lhs.entryStage, rhs.entryStage))
|
||||
return false;
|
||||
|
||||
if (!Compare(lhs.isExported, rhs.isExported))
|
||||
return false;
|
||||
|
||||
if (!Compare(lhs.name, rhs.name))
|
||||
return false;
|
||||
|
||||
|
||||
@@ -31,10 +31,12 @@ namespace Nz::ShaderAst
|
||||
|
||||
struct Callbacks
|
||||
{
|
||||
std::function<void(DeclareFunctionStatement& funcNode)> onExportedFunc;
|
||||
std::function<void(DeclareStructStatement& structNode)> onExportedStruct;
|
||||
};
|
||||
|
||||
private:
|
||||
void Visit(DeclareFunctionStatement& node) override;
|
||||
void Visit(DeclareStructStatement& node) override;
|
||||
|
||||
const Callbacks* m_callbacks;
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace Nz::ShaderAst
|
||||
|
||||
inline const UsageSet& GetUsage() const;
|
||||
|
||||
inline void MarkFunctionAsUsed(std::size_t funcIndex);
|
||||
inline void MarkStructAsUsed(std::size_t structIndex);
|
||||
|
||||
inline void Process(Statement& statement);
|
||||
|
||||
@@ -12,6 +12,11 @@ namespace Nz::ShaderAst
|
||||
return m_resolvedUsage;
|
||||
}
|
||||
|
||||
inline void DependencyCheckerVisitor::MarkFunctionAsUsed(std::size_t funcIndex)
|
||||
{
|
||||
m_globalUsage.usedFunctions.UnboundedSet(funcIndex);
|
||||
}
|
||||
|
||||
inline void DependencyCheckerVisitor::MarkStructAsUsed(std::size_t structIndex)
|
||||
{
|
||||
m_globalUsage.usedStructs.UnboundedSet(structIndex);
|
||||
|
||||
@@ -335,6 +335,7 @@ namespace Nz::ShaderAst
|
||||
ExpressionValue<ShaderStageType> entryStage;
|
||||
ExpressionValue<ExpressionType> returnType;
|
||||
ExpressionValue<bool> earlyFragmentTests;
|
||||
ExpressionValue<bool> isExported;
|
||||
};
|
||||
|
||||
struct NAZARA_SHADER_API DeclareOptionStatement : Statement
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace Nz
|
||||
template<typename T1, typename T2, typename... Args> void Append(const T1& firstParam, const T2& secondParam, Args&&... params);
|
||||
void AppendComment(const std::string& section);
|
||||
void AppendCommentSection(const std::string& section);
|
||||
void AppendFunctionDeclaration(const ShaderAst::DeclareFunctionStatement& node, bool forward = false);
|
||||
void AppendFunctionDeclaration(const ShaderAst::DeclareFunctionStatement& node, const std::string& nameOverride, bool forward = false);
|
||||
void AppendHeader();
|
||||
void AppendLine(const std::string& txt = {});
|
||||
template<typename... Args> void AppendLine(Args&&... params);
|
||||
|
||||
Reference in New Issue
Block a user