Mikko Rasa [Sat, 20 Mar 2021 15:33:40 +0000 (17:33 +0200)]
Support exporting unlit materials
These use the emission surface type in Blender. While that may seem
strange at first, it's actually a good match to how unlit materials
behave in a realtime scene.
Mikko Rasa [Sat, 20 Mar 2021 13:37:12 +0000 (15:37 +0200)]
Adjust uniform organization for UnlitMaterial
Its only property are now stored in a struct to match other material
types. This allows using the name "color" without conflicting with the
vertex attribute. The texture uniform was also renamed in order to
avoid clashing with the texture() function.
Mikko Rasa [Sat, 20 Mar 2021 11:44:09 +0000 (13:44 +0200)]
Decouple DataType from the OpenGL constants
This allows defining the values so that manipulation of related types is
easier. And I can't keep relying on the GL values anyway, with the goal
of adding a Vulkan backend.
Mikko Rasa [Tue, 16 Mar 2021 09:38:55 +0000 (11:38 +0200)]
Don't modify the target block's variable map from InlineContentInjector
This felt hacky, and also seemed wrong since the variable map contains
the original names of the variables, not new ones. Instead avoid
inlining more than one function per pass into any given function.
Mikko Rasa [Mon, 15 Mar 2021 09:05:12 +0000 (11:05 +0200)]
Implement constant folding in the GLSL compiler
This replaces the old expression evaluator with a more comprehensive
solution. Folding constant expressions may open up further possibilities
for inlining.
Mikko Rasa [Sat, 13 Mar 2021 11:38:26 +0000 (13:38 +0200)]
Make it deprecated to redeclare non-builtin variables
This is no longer necessary now that specialization constants are
supported. There's some additional rules for declaring builtins too,
but I'll get back to those later.
Mikko Rasa [Fri, 12 Mar 2021 09:53:11 +0000 (11:53 +0200)]
Limit GLSL passthrough statement to variables declared by that point
This fixes an issue where a base module's passthrough statement would
generate references to inputs declared in an importing module, resulting
in a compile error.
Mikko Rasa [Wed, 10 Mar 2021 11:01:12 +0000 (13:01 +0200)]
Rewrite UnusedVariableRemover
The old implementation was getting too complex with its multitude of
flags. The new one is based on the idea of reaching definition analysis
and is much more straightforward.
Mikko Rasa [Wed, 10 Mar 2021 10:12:26 +0000 (12:12 +0200)]
Make ConstantConditionEliminator less trigger-happy
Since I removed the variable value tracking in 1cd0ea7 it started
optimizing conditions on specialization constants, even when they
had not been specialized yet.
Mikko Rasa [Tue, 9 Mar 2021 10:05:29 +0000 (12:05 +0200)]
Handle expression replacement through TraversingVisitor
There were several cases missing, like VariableResolver not handling
replacement of swizzles in return statements. This way each of the
visitors can just concentrate on what they're actually doing.
Mikko Rasa [Tue, 9 Mar 2021 07:43:08 +0000 (09:43 +0200)]
Record assignment targets more precisely
If the assignment is to a structure or vector field or an array element,
it's recorded to the node so optimizers can better match assignments and
references (they don't do that yet).
Mikko Rasa [Sun, 7 Mar 2021 09:13:23 +0000 (11:13 +0200)]
Properly resolve arithmetic assignment operators
After 50ab5ca operations like vec3 *= float were failing because the
validator required both operands to be of the same type. Conversions
also need to be resolved for the right-hand operand.
Mikko Rasa [Sat, 6 Mar 2021 12:27:16 +0000 (14:27 +0200)]
Rearrange expression node replacement
Rather than every expression visiting function clearing the replacement
result, clear it in the replacement function both before and after. This
is more compact and less prone to forgetting it from somewhere.
Mikko Rasa [Sat, 6 Mar 2021 12:04:24 +0000 (14:04 +0200)]
Refactor resolution of declarations for MemberAccess
Now that expressions have types, there's no need to "return" the members
from deeper in the hierarchy anymore.
Since member type resolution now depends on the type of the left-hand
expression of MemberAccess, variables and expressions need to be resolved
in a loop until there's nothing more to resolve.
Mikko Rasa [Sat, 6 Mar 2021 11:39:20 +0000 (13:39 +0200)]
Remove fallback from Assignment to BinaryExpression in TraversingVisitor
It's causing some trouble when the base class version is called for an
assignment and it gets handled as a binary expression. Almost all classes
are handling the two separately anyway.