]> git.tdb.fi Git - libs/gl.git/log
libs/gl.git
3 years agoSome rearranging and comments
Mikko Rasa [Wed, 10 Mar 2021 11:14:48 +0000 (13:14 +0200)]
Some rearranging and comments

3 years agoCount EmitVertex as referencing all active outputs
Mikko Rasa [Wed, 10 Mar 2021 11:05:41 +0000 (13:05 +0200)]
Count EmitVertex as referencing all active outputs

3 years agoRewrite UnusedVariableRemover
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.

3 years agoDon't omit builtins when formatting a single node
Mikko Rasa [Wed, 10 Mar 2021 10:18:23 +0000 (12:18 +0200)]
Don't omit builtins when formatting a single node

This produces more useful output for debugging.

3 years agoMake ConstantConditionEliminator less trigger-happy
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.

3 years agoCheck for existence of required version in Formatter
Mikko Rasa [Wed, 10 Mar 2021 10:03:24 +0000 (12:03 +0200)]
Check for existence of required version in Formatter

This way it doesn't depend on whether get_combined_glsl or get_stage_glsl
was called.

3 years agoSupport compile modes and specialization constants in the test harness
Mikko Rasa [Wed, 10 Mar 2021 10:01:33 +0000 (12:01 +0200)]
Support compile modes and specialization constants in the test harness

3 years agoAvoid removing outputs which are referenced but not assigned
Mikko Rasa [Tue, 9 Mar 2021 20:27:04 +0000 (22:27 +0200)]
Avoid removing outputs which are referenced but not assigned

The values from such reads are undefined but the variables should be
kept nevertheless.

3 years agoRename and rearrange a few things
Mikko Rasa [Tue, 9 Mar 2021 17:27:58 +0000 (19:27 +0200)]
Rename and rearrange a few things

3 years agoRequire GLSL functions to be declared before use
Mikko Rasa [Tue, 9 Mar 2021 17:17:36 +0000 (19:17 +0200)]
Require GLSL functions to be declared before use

3 years agoAdd declarations for most of the builtin functions in GLSL
Mikko Rasa [Tue, 9 Mar 2021 17:16:42 +0000 (19:16 +0200)]
Add declarations for most of the builtin functions in GLSL

3 years agoValidate return types of overloaded functions
Mikko Rasa [Tue, 9 Mar 2021 14:00:19 +0000 (16:00 +0200)]
Validate return types of overloaded functions

3 years agoAdd support for function overloading
Mikko Rasa [Tue, 9 Mar 2021 13:08:43 +0000 (15:08 +0200)]
Add support for function overloading

3 years agoResolve functions after inlining functions
Mikko Rasa [Tue, 9 Mar 2021 12:34:09 +0000 (14:34 +0200)]
Resolve functions after inlining functions

Inlining clones expressions, and the clones FunctionCall nodes don't have
a declaration pointer.

3 years agoProperly use r_any_resolved in FunctionResolver
Mikko Rasa [Tue, 9 Mar 2021 12:31:22 +0000 (14:31 +0200)]
Properly use r_any_resolved in FunctionResolver

Apparently lacking this has not caused any trouble so far, but it would
soon.

3 years agoHandle expression replacement through TraversingVisitor
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.

3 years agoUse accurate assignment targets in ExpressionInliner
Mikko Rasa [Tue, 9 Mar 2021 08:39:58 +0000 (10:39 +0200)]
Use accurate assignment targets in ExpressionInliner

This fixes an issue where it inline an assignment to a subfield in place
of a reference to the whole variable.

3 years agoRefactor UnusedVariableRemover
Mikko Rasa [Tue, 9 Mar 2021 08:21:18 +0000 (10:21 +0200)]
Refactor UnusedVariableRemover

It can now track and remove named interface blocks.

3 years agoRecord assignment targets more precisely
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).

3 years agoSort diagnostics according to their provoking location
Mikko Rasa [Mon, 8 Mar 2021 20:14:41 +0000 (22:14 +0200)]
Sort diagnostics according to their provoking location

3 years agoRecord information of the provoking location of a diagnostic
Mikko Rasa [Mon, 8 Mar 2021 20:13:55 +0000 (22:13 +0200)]
Record information of the provoking location of a diagnostic

In case of diagnostics providing extra information to a previous one,
this can be different from the direct location.

3 years agoValidate member names
Mikko Rasa [Mon, 8 Mar 2021 17:18:22 +0000 (19:18 +0200)]
Validate member names

3 years agoFix some errors in test cases
Mikko Rasa [Mon, 8 Mar 2021 15:37:06 +0000 (17:37 +0200)]
Fix some errors in test cases

3 years agoRecognize swizzles in GLSL
Mikko Rasa [Mon, 8 Mar 2021 14:59:12 +0000 (16:59 +0200)]
Recognize swizzles in GLSL

3 years agoResolve functions after inlining expressions
Mikko Rasa [Mon, 8 Mar 2021 14:05:57 +0000 (16:05 +0200)]
Resolve functions after inlining expressions

This fixes a bug introduced in c1d3a1d.

3 years agoTransform interface block contents into structs
Mikko Rasa [Mon, 8 Mar 2021 13:06:01 +0000 (15:06 +0200)]
Transform interface block contents into structs

This allows handling them in expression trees like everything else.  It
also helps with SPIR-V, which requires interface blocks to have struct
types.

3 years agoRemove the NodeGatherer visitor
Mikko Rasa [Mon, 8 Mar 2021 11:49:03 +0000 (13:49 +0200)]
Remove the NodeGatherer visitor

It was somewhat poorly thought out since it's unable to gather nodes of
a base class type.

3 years agoPopulate the builtin module's type maps directly
Mikko Rasa [Mon, 8 Mar 2021 11:47:30 +0000 (13:47 +0200)]
Populate the builtin module's type maps directly

TypeResolver may do other, potentially disruptive things.  The contents
will be copied into the compiled module and properly resolved there.

3 years agoImprove reporting of function name conflicts
Mikko Rasa [Mon, 8 Mar 2021 00:49:40 +0000 (02:49 +0200)]
Improve reporting of function name conflicts

Prototype declarations were not being recorded, and definitions were
causing multiple definition errors to be reported in double.

3 years agoCheck for extra error lines in compiler output
Mikko Rasa [Mon, 8 Mar 2021 00:49:03 +0000 (02:49 +0200)]
Check for extra error lines in compiler output

Somehow I thought this was handled already

3 years agoApply replacement to variable declaration components in VariableResolver
Mikko Rasa [Sun, 7 Mar 2021 22:24:30 +0000 (00:24 +0200)]
Apply replacement to variable declaration components in VariableResolver

This got missed on cb8ee1f.

3 years agoComplain about named interface blocks if not supported
Mikko Rasa [Sun, 7 Mar 2021 22:16:15 +0000 (00:16 +0200)]
Complain about named interface blocks if not supported

3 years agoReport unsupported shader errors through the diagnostic mechanism
Mikko Rasa [Sun, 7 Mar 2021 22:14:55 +0000 (00:14 +0200)]
Report unsupported shader errors through the diagnostic mechanism

3 years agoEasier way of adding complex subtrees to GLSL debug dump
Mikko Rasa [Sun, 7 Mar 2021 22:03:25 +0000 (00:03 +0200)]
Easier way of adding complex subtrees to GLSL debug dump

3 years agoAdd another variation of a partially unused interface block
Mikko Rasa [Sun, 7 Mar 2021 16:32:04 +0000 (18:32 +0200)]
Add another variation of a partially unused interface block

I discovered a case where the compiler behaves incorrectly so recording
it here.

3 years agoFurther refactor the resolving process in SL::Compiler
Mikko Rasa [Sun, 7 Mar 2021 10:58:23 +0000 (12:58 +0200)]
Further refactor the resolving process in SL::Compiler

There's now five different types of resolve operations, many of which
depend on some others.  Better put the logic in one place to keep it
straight.

This also includes some rearrangements to the resolver classes to have
all of them return a boolean indicating if anything was done.

3 years agoAdditional rules for bit shift operators
Mikko Rasa [Sun, 7 Mar 2021 09:36:17 +0000 (11:36 +0200)]
Additional rules for bit shift operators

3 years agoProperly resolve arithmetic assignment operators
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.

3 years agoRearrange expression node replacement
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.

3 years agoRefactor resolution of declarations for MemberAccess
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.

3 years agoRemove fallback from Assignment to BinaryExpression in TraversingVisitor
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.

3 years agoRemove an unnecessary loop over block hierarchy
Mikko Rasa [Sat, 6 Mar 2021 01:05:01 +0000 (03:05 +0200)]
Remove an unnecessary loop over block hierarchy

3 years agoAdd some test cases for unused interface blocks
Mikko Rasa [Sat, 6 Mar 2021 00:51:04 +0000 (02:51 +0200)]
Add some test cases for unused interface blocks

3 years agoFix a type error in a test case
Mikko Rasa [Fri, 5 Mar 2021 23:04:58 +0000 (01:04 +0200)]
Fix a type error in a test case

3 years agoAssign a result type to all expressions
Mikko Rasa [Fri, 5 Mar 2021 22:46:43 +0000 (00:46 +0200)]
Assign a result type to all expressions

This requires some additional work for function overloads and swizzles.

3 years agoRemove a debug thing
Mikko Rasa [Fri, 5 Mar 2021 22:45:54 +0000 (00:45 +0200)]
Remove a debug thing

3 years agoIgnore precedence for prefix operators
Mikko Rasa [Fri, 5 Mar 2021 22:33:44 +0000 (00:33 +0200)]
Ignore precedence for prefix operators

Since the operator appears at the start of an expression or after another
operator, there's no way for it to bind to anything but whatever follows.
This fixes a bug where chained prefix operators were not recognized.

3 years agoCreate array type declarations as necessary
Mikko Rasa [Fri, 5 Mar 2021 21:08:41 +0000 (23:08 +0200)]
Create array type declarations as necessary

3 years agoTweak the builtin type generation
Mikko Rasa [Fri, 5 Mar 2021 21:06:45 +0000 (23:06 +0200)]
Tweak the builtin type generation

Give bool a size and insert the types in the order they're defined in.

3 years agoStore actual values for literals
Mikko Rasa [Fri, 5 Mar 2021 20:09:31 +0000 (22:09 +0200)]
Store actual values for literals

3 years agoVisit structs during unused type removal
Mikko Rasa [Fri, 5 Mar 2021 19:04:54 +0000 (21:04 +0200)]
Visit structs during unused type removal

Otherwise types which are only used by struct member declarations would
be removed.

3 years agoMark function return types as used
Mikko Rasa [Fri, 5 Mar 2021 19:03:48 +0000 (21:03 +0200)]
Mark function return types as used

3 years agoActually call the type validator
Mikko Rasa [Fri, 5 Mar 2021 18:40:09 +0000 (20:40 +0200)]
Actually call the type validator

3 years agoCheck that errors were generated as expected
Mikko Rasa [Fri, 5 Mar 2021 18:37:21 +0000 (20:37 +0200)]
Check that errors were generated as expected

3 years agoFollow type aliases in TypeResolver
Mikko Rasa [Fri, 5 Mar 2021 11:28:22 +0000 (13:28 +0200)]
Follow type aliases in TypeResolver

3 years agoUse resolved type names for output
Mikko Rasa [Fri, 5 Mar 2021 11:23:13 +0000 (13:23 +0200)]
Use resolved type names for output

3 years agoResolve the return types of functions
Mikko Rasa [Fri, 5 Mar 2021 11:22:47 +0000 (13:22 +0200)]
Resolve the return types of functions

3 years agoValidate some aspects of type declarations
Mikko Rasa [Fri, 5 Mar 2021 11:09:55 +0000 (13:09 +0200)]
Validate some aspects of type declarations

3 years agoCatch exceptions from parsing while testing the compiler
Mikko Rasa [Fri, 5 Mar 2021 10:59:27 +0000 (12:59 +0200)]
Catch exceptions from parsing while testing the compiler

3 years agoFix a bug with resolving member declarations
Mikko Rasa [Fri, 5 Mar 2021 00:17:23 +0000 (02:17 +0200)]
Fix a bug with resolving member declarations

The logic changes in 7daccf2 caused members of variables declared within
anonymous interface blocks to not be resolved correctly.

3 years agoFix a memory error with interface blocks
Mikko Rasa [Thu, 4 Mar 2021 23:50:31 +0000 (01:50 +0200)]
Fix a memory error with interface blocks

The changes in d72d8a9 were not applied to the interfaces map of the
stage, but because those interfaces were unused anyway it only showed
up when doing an AST dump.

3 years agoRemove unused type declarations from GLSL during optimization
Mikko Rasa [Thu, 4 Mar 2021 23:27:52 +0000 (01:27 +0200)]
Remove unused type declarations from GLSL during optimization

The biggest impact of this right now is keeping the AST dump manageable.

3 years agoCopy location when creating an interface block reference
Mikko Rasa [Thu, 4 Mar 2021 23:23:52 +0000 (01:23 +0200)]
Copy location when creating an interface block reference

3 years agoAllow AST to be dumped even if compilation fails
Mikko Rasa [Thu, 4 Mar 2021 23:21:29 +0000 (01:21 +0200)]
Allow AST to be dumped even if compilation fails

3 years agoCheck that variable references refer do declared variables
Mikko Rasa [Thu, 4 Mar 2021 23:18:15 +0000 (01:18 +0200)]
Check that variable references refer do declared variables

3 years agoGive declaration nodes to all GLSL types.
Mikko Rasa [Thu, 4 Mar 2021 23:06:46 +0000 (01:06 +0200)]
Give declaration nodes to all GLSL types.

Even the builtin ones.  This makes various operations with expressions
easier and helps with SPIR-V.

3 years agoRecord location information in all syntax nodes
Mikko Rasa [Thu, 4 Mar 2021 22:27:31 +0000 (00:27 +0200)]
Record location information in all syntax nodes

3 years agoValidate struct name uniqueness
Mikko Rasa [Thu, 4 Mar 2021 21:41:45 +0000 (23:41 +0200)]
Validate struct name uniqueness

3 years agoMake builtins const
Mikko Rasa [Thu, 4 Mar 2021 21:32:28 +0000 (23:32 +0200)]
Make builtins const

3 years agoLoad builtin GLSL declarations from a file
Mikko Rasa [Thu, 4 Mar 2021 21:30:13 +0000 (23:30 +0200)]
Load builtin GLSL declarations from a file

I'm going to add a lot more stuff into it so having it in the C++ source
would be inconvenient.

3 years agoUse a different method of adding builtins to stages
Mikko Rasa [Thu, 4 Mar 2021 21:26:19 +0000 (23:26 +0200)]
Use a different method of adding builtins to stages

This gets them in the correct order with the module's shared stage, and
also allows builtins to have shared declarations.

3 years agoAdd a missing symmetry to linking variables
Mikko Rasa [Thu, 4 Mar 2021 21:25:03 +0000 (23:25 +0200)]
Add a missing symmetry to linking variables

This caused invalid memory accesses when destroying syntax trees.

3 years agoOnly set assign_to_subfield when in assignment target
Mikko Rasa [Thu, 4 Mar 2021 19:24:59 +0000 (21:24 +0200)]
Only set assign_to_subfield when in assignment target

3 years agoCheck for function declaration conflicting with something else
Mikko Rasa [Thu, 4 Mar 2021 15:57:00 +0000 (17:57 +0200)]
Check for function declaration conflicting with something else

Functions are allowed to have multiple declarations but only one
definition.

3 years agoImprove rules for interface blocks
Mikko Rasa [Thu, 4 Mar 2021 15:52:11 +0000 (17:52 +0200)]
Improve rules for interface blocks

The GLSL specification says that using the same block name in different
interfaces is allowed, so we must separate blocks by interface.

3 years agoCheck for missing lines in error output
Mikko Rasa [Thu, 4 Mar 2021 14:50:57 +0000 (16:50 +0200)]
Check for missing lines in error output

3 years agoUse insert instead of [] to retain the first item with the same name
Mikko Rasa [Thu, 4 Mar 2021 13:39:08 +0000 (15:39 +0200)]
Use insert instead of [] to retain the first item with the same name

3 years agoAdd some test cases to test shader validation
Mikko Rasa [Thu, 4 Mar 2021 12:50:46 +0000 (14:50 +0200)]
Add some test cases to test shader validation

3 years agoMake the GLSL compiler tester able to verify errors
Mikko Rasa [Thu, 4 Mar 2021 12:49:59 +0000 (14:49 +0200)]
Make the GLSL compiler tester able to verify errors

3 years agoUse the new append utility function to build GLSL compile errors
Mikko Rasa [Thu, 4 Mar 2021 12:30:02 +0000 (14:30 +0200)]
Use the new append utility function to build GLSL compile errors

3 years agoFlip the parameters of Tokenizer::begin
Mikko Rasa [Thu, 4 Mar 2021 12:17:04 +0000 (14:17 +0200)]
Flip the parameters of Tokenizer::begin

Everything else has the filename as the last parameter, so let's be
consistent here.

3 years agoRemove a redundant declaration of shadow_coord
Mikko Rasa [Thu, 4 Mar 2021 11:20:53 +0000 (13:20 +0200)]
Remove a redundant declaration of shadow_coord

This is declared in shadow.glsl

3 years agoCopy the location when moving output declarations out of functions
Mikko Rasa [Thu, 4 Mar 2021 11:16:26 +0000 (13:16 +0200)]
Copy the location when moving output declarations out of functions

3 years agoHave generate_interface return the generated statement
Mikko Rasa [Thu, 4 Mar 2021 11:16:04 +0000 (13:16 +0200)]
Have generate_interface return the generated statement

3 years agoAdd basic validation to the GLSL compiler
Mikko Rasa [Thu, 4 Mar 2021 10:50:52 +0000 (12:50 +0200)]
Add basic validation to the GLSL compiler

Currently the only thing validated is multiple definitions.

3 years agoRemove unnecessary includes
Mikko Rasa [Thu, 4 Mar 2021 09:45:55 +0000 (11:45 +0200)]
Remove unnecessary includes

3 years agoFix function inlining in iteration init statement
Mikko Rasa [Wed, 3 Mar 2021 23:56:26 +0000 (01:56 +0200)]
Fix function inlining in iteration init statement

Also reword the other related comment to be more accurate.

3 years agoUpdate .gitignore
Mikko Rasa [Wed, 3 Mar 2021 23:54:47 +0000 (01:54 +0200)]
Update .gitignore

Remove some old build products and add glslcompiler.

3 years agoAdd the shader for UnlitMaterial
Mikko Rasa [Wed, 3 Mar 2021 23:50:31 +0000 (01:50 +0200)]
Add the shader for UnlitMaterial

This was supposed to be in 2f198e3

3 years agoAdd extension file for NV_half_float
Mikko Rasa [Wed, 3 Mar 2021 23:47:11 +0000 (01:47 +0200)]
Add extension file for NV_half_float

This should have been in 9087cc0 but went unnoticed for a month due to
how the extension headers are handled.

3 years agoAdd a unit test framework and some tests for the GLSL compiler
Mikko Rasa [Wed, 3 Mar 2021 23:44:59 +0000 (01:44 +0200)]
Add a unit test framework and some tests for the GLSL compiler

Some of the tests fail due to bugs in the compiler.

3 years agoAdd expression inlining
Mikko Rasa [Wed, 3 Mar 2021 23:05:22 +0000 (01:05 +0200)]
Add expression inlining

3 years agoMake the iteration init statement a Statement instead of Node
Mikko Rasa [Wed, 3 Mar 2021 18:17:13 +0000 (20:17 +0200)]
Make the iteration init statement a Statement instead of Node

3 years agoAdd a new associativity type for fully associative operators
Mikko Rasa [Wed, 3 Mar 2021 18:06:12 +0000 (20:06 +0200)]
Add a new associativity type for fully associative operators

3 years agoAdd some comments to the more complex parts of the GLSL compiler
Mikko Rasa [Wed, 3 Mar 2021 18:05:28 +0000 (20:05 +0200)]
Add some comments to the more complex parts of the GLSL compiler

3 years agoVisit iteration statement components in semantically correct order
Mikko Rasa [Wed, 3 Mar 2021 18:01:35 +0000 (20:01 +0200)]
Visit iteration statement components in semantically correct order

3 years agoMinor, largely cosmetic tweaks
Mikko Rasa [Wed, 3 Mar 2021 17:55:55 +0000 (19:55 +0200)]
Minor, largely cosmetic tweaks

3 years agoRemove some unnecessary bits
Mikko Rasa [Wed, 3 Mar 2021 17:47:53 +0000 (19:47 +0200)]
Remove some unnecessary bits

3 years agoFix an issue where member assignments were incorrectly optimized away
Mikko Rasa [Wed, 3 Mar 2021 16:48:34 +0000 (18:48 +0200)]
Fix an issue where member assignments were incorrectly optimized away

They are now treated as subfield assignments, same as array subscripts.

3 years agoDon't copy type declaration of a generated interface variable
Mikko Rasa [Wed, 3 Mar 2021 15:14:12 +0000 (17:14 +0200)]
Don't copy type declaration of a generated interface variable

It's better to let it be resolved again.