NazaraEngine / ShaderLang

NZSL (Nazara Shading Language) repository - A shader language inspired by Rust and C++ which compiles to GLSL or SPIRV (without any additional dependency)
MIT License
48 stars 12 forks source link

Duplicate AST nodes only when required #12

Open SirLynix opened 2 years ago

SirLynix commented 2 years ago

Currently, the AST is fully duplicated for every compilation step, when only minor changes are required (or even if no change is required at all).

We should prevent this by making every AST shared_ptr const (ex: std::shared_ptr<const Ast::ConstantValueExpression>) and cloning only changing parts.

The end result should be that running constant propagation (or even sanitization) on a already processed AST should return the same AST.

SirLynix commented 2 months ago

This is currently worked on, on the multipass branch.

The approach is to directly update the AST using multiple transformers and clone it only when required (importing)