]> git.tdb.fi Git - libs/gl.git/log
libs/gl.git
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.

3 years agoFix VariableResolver doing bogus things on certain invalid constructs
Mikko Rasa [Wed, 3 Mar 2021 15:13:22 +0000 (17:13 +0200)]
Fix VariableResolver doing bogus things on certain invalid constructs

3 years agoFix passthroughs being generated for non-output variables
Mikko Rasa [Wed, 3 Mar 2021 15:10:03 +0000 (17:10 +0200)]
Fix passthroughs being generated for non-output variables

3 years agoRename members of visitors to indicate which are "return values"
Mikko Rasa [Wed, 3 Mar 2021 12:59:19 +0000 (14:59 +0200)]
Rename members of visitors to indicate which are "return values"

3 years agoHandle all constructs when inlining GLSL functions
Mikko Rasa [Wed, 3 Mar 2021 11:02:55 +0000 (13:02 +0200)]
Handle all constructs when inlining GLSL functions

We need to look for function calls inside conditional and iteration
statements too, and inline calls within condition expressions.

3 years agoFix a block management error in FunctionInliner
Mikko Rasa [Wed, 3 Mar 2021 10:41:15 +0000 (12:41 +0200)]
Fix a block management error in FunctionInliner

3 years agoAdd a missing #include
Mikko Rasa [Wed, 3 Mar 2021 09:32:28 +0000 (11:32 +0200)]
Add a missing #include

This was left out from d5c7c7f

3 years agoStore a pointer to operator info rather than the token in expressions
Mikko Rasa [Wed, 3 Mar 2021 09:28:14 +0000 (11:28 +0200)]
Store a pointer to operator info rather than the token in expressions

Also make it a property of Expression rather than the subtypes.

3 years agoFurther improve inlining of GLSL functions
Mikko Rasa [Mon, 1 Mar 2021 23:25:30 +0000 (01:25 +0200)]
Further improve inlining of GLSL functions

Functions of any lenght can now be inlined, as long as they have linear
control flow.

3 years agoClear previous state when resolving functions
Mikko Rasa [Mon, 1 Mar 2021 23:17:01 +0000 (01:17 +0200)]
Clear previous state when resolving functions

3 years agoRemove expression statements without side effects
Mikko Rasa [Mon, 1 Mar 2021 23:13:23 +0000 (01:13 +0200)]
Remove expression statements without side effects

3 years agoFix another case of future features leaking
Mikko Rasa [Mon, 1 Mar 2021 19:03:52 +0000 (21:03 +0200)]
Fix another case of future features leaking

3 years agoFix an issue with line numbers after #line being off-by-one
Mikko Rasa [Mon, 1 Mar 2021 15:39:07 +0000 (17:39 +0200)]
Fix an issue with line numbers after #line being off-by-one

I had added the flag for this back in 1083ad1 but forgot to use it.

3 years agoExplicitly call base class copy constructor for expressions
Mikko Rasa [Mon, 1 Mar 2021 15:37:31 +0000 (17:37 +0200)]
Explicitly call base class copy constructor for expressions

3 years agoRefactor FunctionInliner to do any necessary declaration reordering
Mikko Rasa [Mon, 1 Mar 2021 15:36:19 +0000 (17:36 +0200)]
Refactor FunctionInliner to do any necessary declaration reordering

3 years agoClarify SL::Compiler::optimize return values by using an enum
Mikko Rasa [Mon, 1 Mar 2021 14:19:09 +0000 (16:19 +0200)]
Clarify SL::Compiler::optimize return values by using an enum

3 years agoInject builtins into the module
Mikko Rasa [Sun, 28 Feb 2021 19:37:05 +0000 (21:37 +0200)]
Inject builtins into the module

This makes identifier resolution easier to manage and also helps an
eventual SPIR-V implementation.

3 years agoDebug output tweaks
Mikko Rasa [Sun, 28 Feb 2021 14:10:09 +0000 (16:10 +0200)]
Debug output tweaks

3 years agoClear the stage map at the beginning if a resolving pass
Mikko Rasa [Sun, 28 Feb 2021 12:02:55 +0000 (14:02 +0200)]
Clear the stage map at the beginning if a resolving pass

This avoids accidentally resolving things to a declarations which is not
visible to the reference.

3 years agoRemove things that weren't supposed to go in yet
Mikko Rasa [Sun, 28 Feb 2021 11:25:56 +0000 (13:25 +0200)]
Remove things that weren't supposed to go in yet

3 years agoStore functions definitions in Stage
Mikko Rasa [Sun, 28 Feb 2021 11:19:25 +0000 (13:19 +0200)]
Store functions definitions in Stage

3 years agoMove function override processing to FunctionResolver
Mikko Rasa [Sun, 28 Feb 2021 11:16:23 +0000 (13:16 +0200)]
Move function override processing to FunctionResolver

3 years agoMake the GLSL parser resilient against common errors
Mikko Rasa [Sun, 28 Feb 2021 00:12:48 +0000 (02:12 +0200)]
Make the GLSL parser resilient against common errors

It will now attempt to continue parsing the source, with the intent of
reporting all syntax errors at once.

3 years agoAdd some documentation to the GLSL compiler
Mikko Rasa [Sat, 27 Feb 2021 14:32:33 +0000 (16:32 +0200)]
Add some documentation to the GLSL compiler

3 years agoFixes for compatibility with legacy unsized PixelFormats
Mikko Rasa [Fri, 26 Feb 2021 23:46:34 +0000 (01:46 +0200)]
Fixes for compatibility with legacy unsized PixelFormats

3 years agoDon't copy layouts to generated out interfaces
Mikko Rasa [Fri, 26 Feb 2021 23:28:46 +0000 (01:28 +0200)]
Don't copy layouts to generated out interfaces

3 years agoUse specialization constants in the builtin material shaders
Mikko Rasa [Fri, 26 Feb 2021 23:27:16 +0000 (01:27 +0200)]
Use specialization constants in the builtin material shaders

This has the side effect that RenderPass now requires a collection
to use the builtin shaders.

3 years agoAdd interfaces for using specialization constants with Programs
Mikko Rasa [Fri, 26 Feb 2021 23:21:11 +0000 (01:21 +0200)]
Add interfaces for using specialization constants with Programs

This replaces the old way of redefining variables withing the GLSL
source, and as such the Program constructor from string is now
deprecated.

3 years agoSupport specialization constants in the GLSL compiler
Mikko Rasa [Fri, 26 Feb 2021 21:10:17 +0000 (23:10 +0200)]
Support specialization constants in the GLSL compiler

3 years agoMostly cosmetic tweaks
Mikko Rasa [Fri, 26 Feb 2021 18:26:27 +0000 (20:26 +0200)]
Mostly cosmetic tweaks

3 years agoCopy layouts when generating interfaces
Mikko Rasa [Thu, 25 Feb 2021 23:20:02 +0000 (01:20 +0200)]
Copy layouts when generating interfaces

3 years agoDon't allow arbitrary statements in structs or interface blocks
Mikko Rasa [Thu, 25 Feb 2021 23:09:21 +0000 (01:09 +0200)]
Don't allow arbitrary statements in structs or interface blocks

3 years agoStore types and interface blocks in Stage
Mikko Rasa [Thu, 25 Feb 2021 23:03:36 +0000 (01:03 +0200)]
Store types and interface blocks in Stage

They're only allowed at top level so it seems pointless for every block
to have the maps.

3 years agoPopulate the interface block map in VariableResolver
Mikko Rasa [Thu, 25 Feb 2021 22:50:52 +0000 (00:50 +0200)]
Populate the interface block map in VariableResolver

They're more variable-y than block-y.

3 years agoUnlink declarations on destruction
Mikko Rasa [Thu, 25 Feb 2021 22:38:43 +0000 (00:38 +0200)]
Unlink declarations on destruction

Just in case

3 years agoSupport automatic generation of interface blocks
Mikko Rasa [Thu, 25 Feb 2021 22:38:10 +0000 (00:38 +0200)]
Support automatic generation of interface blocks

3 years agoImprove support for interface blocks
Mikko Rasa [Thu, 25 Feb 2021 19:30:36 +0000 (21:30 +0200)]
Improve support for interface blocks

Blocks with instance names are now properly supported in the syntax tree.

3 years agoTweak debug output
Mikko Rasa [Thu, 25 Feb 2021 19:16:54 +0000 (21:16 +0200)]
Tweak debug output

3 years agoOnly generate or link interfaces in the correct scope
Mikko Rasa [Thu, 25 Feb 2021 19:15:08 +0000 (21:15 +0200)]
Only generate or link interfaces in the correct scope

3 years agoDon't add null entries to variable values
Mikko Rasa [Thu, 25 Feb 2021 10:24:41 +0000 (12:24 +0200)]
Don't add null entries to variable values

This triggered a bug now that function parameters are processed within
the function's scope.

3 years agoRefactor interface management
Mikko Rasa [Wed, 24 Feb 2021 13:51:30 +0000 (15:51 +0200)]
Refactor interface management

Rather than having separate maps in Stage, pull the variables from the
content block's map.

3 years agoRefactor block management in NodeRemover
Mikko Rasa [Tue, 23 Feb 2021 23:15:33 +0000 (01:15 +0200)]
Refactor block management in NodeRemover

This was supposed to go in 9971979 but I forgot.

3 years agoIgnore function parameters in InterfaceGenerator
Mikko Rasa [Tue, 23 Feb 2021 22:37:04 +0000 (00:37 +0200)]
Ignore function parameters in InterfaceGenerator

3 years agoRefactor scope management
Mikko Rasa [Tue, 23 Feb 2021 22:11:43 +0000 (00:11 +0200)]
Refactor scope management

TraversingVisitor now takes care of maintaining current_block correctly
for functions and loops.  This fixes an issue where InterfaceGenerator
was treating function in/out parameters as global interface variables.
Now there's a different bug where it generates global interface variables
for them.

3 years agoAvoid incorrectly matching interfaces in certain cases
Mikko Rasa [Tue, 23 Feb 2021 22:03:31 +0000 (00:03 +0200)]
Avoid incorrectly matching interfaces in certain cases

I removed this in ab5f2e6, thinking it was unnecessary.  But if a stage
declares a local output variable of the same name as an output variable
in the previous stage, this is needed to avoid a mismatch.