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

3 years agoRemove the using declarations from visitors
Mikko Rasa [Tue, 23 Feb 2021 21:35:59 +0000 (23:35 +0200)]
Remove the using declarations from visitors

Instead always invoke visit through the node

3 years agoSome tweaks to GLSL debug output
Mikko Rasa [Mon, 22 Feb 2021 15:06:02 +0000 (17:06 +0200)]
Some tweaks to GLSL debug output

3 years agoOutput the passthrough statement in both GLSL and debug modes
Mikko Rasa [Mon, 22 Feb 2021 00:34:12 +0000 (02:34 +0200)]
Output the passthrough statement in both GLSL and debug modes

3 years agoSlightly refactor layout qualifiers in the GLSL parser
Mikko Rasa [Sun, 21 Feb 2021 23:52:29 +0000 (01:52 +0200)]
Slightly refactor layout qualifiers in the GLSL parser

Their values are now stored as integers, since no qualifier takes a
value of any other type.

3 years agoCheck that requested shader stages are supported
Mikko Rasa [Sun, 21 Feb 2021 23:50:19 +0000 (01:50 +0200)]
Check that requested shader stages are supported

3 years agoThrow an exception if a feature required by a shader is missing
Mikko Rasa [Sun, 21 Feb 2021 23:39:30 +0000 (01:39 +0200)]
Throw an exception if a feature required by a shader is missing

Workarounds are not always available.

3 years agoAdd a standalone GLSL compiler frontend
Mikko Rasa [Sun, 21 Feb 2021 23:12:25 +0000 (01:12 +0200)]
Add a standalone GLSL compiler frontend

This makes debugging the compiler easier and will eventually allow
shaders to be compiled into SPIR-V during build.

3 years agoReduce coupling between the GLSL compiler and the graphics engine
Mikko Rasa [Sun, 21 Feb 2021 22:58:57 +0000 (00:58 +0200)]
Reduce coupling between the GLSL compiler and the graphics engine

Feature states are now recorded in a struct.

3 years agoHeader fixes in the GLSL compiler
Mikko Rasa [Sun, 21 Feb 2021 23:02:14 +0000 (01:02 +0200)]
Header fixes in the GLSL compiler

3 years agoFix environment map uniform name
Mikko Rasa [Sun, 21 Feb 2021 21:35:13 +0000 (23:35 +0200)]
Fix environment map uniform name

3 years agoUpdate the desertpillars demo
Mikko Rasa [Sun, 21 Feb 2021 21:33:32 +0000 (23:33 +0200)]
Update the desertpillars demo

3 years agoImplement an unlit material type
Mikko Rasa [Sun, 21 Feb 2021 21:30:55 +0000 (23:30 +0200)]
Implement an unlit material type

3 years agoSupport addint datafile statements for uniform material properties
Mikko Rasa [Sun, 21 Feb 2021 21:29:37 +0000 (23:29 +0200)]
Support addint datafile statements for uniform material properties

3 years agoAdd sampler parameter to RenderPass::set_texture
Mikko Rasa [Sun, 21 Feb 2021 21:28:02 +0000 (23:28 +0200)]
Add sampler parameter to RenderPass::set_texture

3 years agoAdd missing keyword to set sampler compare mode from datafile
Mikko Rasa [Sun, 21 Feb 2021 21:26:05 +0000 (23:26 +0200)]
Add missing keyword to set sampler compare mode from datafile

3 years agoRedesign the way shader programs are loaded
Mikko Rasa [Sun, 21 Feb 2021 14:23:07 +0000 (16:23 +0200)]
Redesign the way shader programs are loaded

Vulkan uses SPIR-V modules which can be specialized so there has to be a
way to keep the module around.  A module can also contain multiple shader
stages.  The abstraction for individual stages with the Shader class is
outdated and has been replaced with Module.

GLSL code is stored in the Module in combined form and split into stages
when loaded to a Program.

3 years agoAllow using SL::Formatter on single nodes
Mikko Rasa [Sun, 21 Feb 2021 10:19:52 +0000 (12:19 +0200)]
Allow using SL::Formatter on single nodes

This is occasionally useful for debugging.

3 years agoFurther refactor block and scope management
Mikko Rasa [Sun, 21 Feb 2021 03:12:28 +0000 (05:12 +0200)]
Further refactor block and scope management

TraversingVisitor now provides a current_block variable and block know
their parent block so checking if we're in the toplevel block is easy.

3 years agoTweaks to the AST debug output
Mikko Rasa [Sun, 21 Feb 2021 02:39:57 +0000 (04:39 +0200)]
Tweaks to the AST debug output

3 years agoFix scoping of GLSL loop variables and function parameters
Mikko Rasa [Sun, 21 Feb 2021 02:31:35 +0000 (04:31 +0200)]
Fix scoping of GLSL loop variables and function parameters

TraversingVisitor visits those before the body, so they were being
inserted into the enclosing scope's variables map.

3 years agoRewrite syntax tree modifications
Mikko Rasa [Sun, 21 Feb 2021 02:20:32 +0000 (04:20 +0200)]
Rewrite syntax tree modifications

BlockModifier left dangling pointers in various variable maps, which
started causing trouble when I wanted to print out the entire AST.
NodeRemover is now used for all removal operations and it properly
handles the maps.

3 years agoAvoid copying raw pointers in the syntax tree
Mikko Rasa [Sat, 20 Feb 2021 22:59:07 +0000 (00:59 +0200)]
Avoid copying raw pointers in the syntax tree

They will potentially point to incorrect nodes and must be resolved
again.

3 years agoAdd a visitor to dump the AST for debugging purposes
Mikko Rasa [Sat, 20 Feb 2021 22:47:44 +0000 (00:47 +0200)]
Add a visitor to dump the AST for debugging purposes

3 years agoRearrange secondary operations in GLSL compiler
Mikko Rasa [Sat, 20 Feb 2021 18:20:47 +0000 (20:20 +0200)]
Rearrange secondary operations in GLSL compiler

These are now performed internally by the main operation visitor.

3 years agoTweaks to visitor classes in the GLSL compiler
Mikko Rasa [Sat, 20 Feb 2021 18:10:30 +0000 (20:10 +0200)]
Tweaks to visitor classes in the GLSL compiler

3 years agoMake RenderTargetFormat generation more robust
Mikko Rasa [Sat, 20 Feb 2021 13:12:29 +0000 (15:12 +0200)]
Make RenderTargetFormat generation more robust

The functions here had accidentally gotten out of sync in 9087cc0.

3 years agoRecognize the #line directive in the GLSL parser
Mikko Rasa [Sat, 20 Feb 2021 12:59:44 +0000 (14:59 +0200)]
Recognize the #line directive in the GLSL parser

Also add a new pragma to specify source names.

3 years agoTrack source names in SL::Module
Mikko Rasa [Sat, 20 Feb 2021 12:42:19 +0000 (14:42 +0200)]
Track source names in SL::Module

Error translation has also been moved to a separate class.  This will
allow moving the creation of shaders to Program.

3 years agoRemove support for the legacy stage change syntax
Mikko Rasa [Sat, 20 Feb 2021 11:54:24 +0000 (13:54 +0200)]
Remove support for the legacy stage change syntax

3 years agoLoad various built-in things through Resources
Mikko Rasa [Fri, 19 Feb 2021 16:40:30 +0000 (18:40 +0200)]
Load various built-in things through Resources

There's so many of them that managing them manually is becoming too
tedious.  Especially with some planned shader changes.

3 years agoRefactor the interface of SL::Compiler
Mikko Rasa [Thu, 18 Feb 2021 11:31:48 +0000 (13:31 +0200)]
Refactor the interface of SL::Compiler

3 years agoReport incorrect shader stages by name
Mikko Rasa [Tue, 16 Feb 2021 08:47:14 +0000 (10:47 +0200)]
Report incorrect shader stages by name

3 years agoRemove unused constructors
Mikko Rasa [Mon, 15 Feb 2021 16:05:46 +0000 (18:05 +0200)]
Remove unused constructors

3 years agoAdjust member access of the various visitors in the GLSL compiler
Mikko Rasa [Mon, 15 Feb 2021 16:04:53 +0000 (18:04 +0200)]
Adjust member access of the various visitors in the GLSL compiler

Most of them don't work properly if given some random node to start with.

3 years agoRefactor creation of the shader builtin module
Mikko Rasa [Mon, 15 Feb 2021 15:50:03 +0000 (17:50 +0200)]
Refactor creation of the shader builtin module

It can now use VariableResolver::apply like everything else.

3 years agoRefactor the way of applying visitors to stages
Mikko Rasa [Mon, 15 Feb 2021 14:01:55 +0000 (16:01 +0200)]
Refactor the way of applying visitors to stages

3 years agoRefactor handling of texture sampling functions in LegacyConverter
Mikko Rasa [Mon, 15 Feb 2021 11:25:37 +0000 (13:25 +0200)]
Refactor handling of texture sampling functions in LegacyConverter

This structure allows to check support for sampler types which don't
have legacy variants for the texture function.

3 years agoMove the StageType enum inside the Stage struct
Mikko Rasa [Mon, 15 Feb 2021 10:12:44 +0000 (12:12 +0200)]
Move the StageType enum inside the Stage struct

3 years agoSplit SL::Compiler into several files
Mikko Rasa [Mon, 15 Feb 2021 09:13:07 +0000 (11:13 +0200)]
Split SL::Compiler into several files

It was getting rather unwieldy at over 2000 lines, but now that this
subsystem has its own directory and namespace I can organize it better
without interfering with the other parts.

3 years agoFollow the GLSL syntax rules more closely
Mikko Rasa [Sun, 14 Feb 2021 17:56:15 +0000 (19:56 +0200)]
Follow the GLSL syntax rules more closely

Fix a bug which allowed preprocessor directives anywhere on a line,
reject characters which are not allowed in GLSL, and parse numeric
literals more robustly.

3 years agoSplit tokenizer and preprocessor out of the GLSL parser
Mikko Rasa [Sun, 14 Feb 2021 15:42:04 +0000 (17:42 +0200)]
Split tokenizer and preprocessor out of the GLSL parser

3 years agoRefactor error reporting in SL::Parser
Mikko Rasa [Sun, 14 Feb 2021 14:57:32 +0000 (16:57 +0200)]
Refactor error reporting in SL::Parser

There's now dedicated exception classes which take care of the
formatting.

3 years agoMove the GLSL compiler entirely in its own namespace
Mikko Rasa [Sun, 14 Feb 2021 12:13:56 +0000 (14:13 +0200)]
Move the GLSL compiler entirely in its own namespace

3 years agoRearrange soucre files into subdirectories
Mikko Rasa [Sun, 14 Feb 2021 00:52:21 +0000 (02:52 +0200)]
Rearrange soucre files into subdirectories

3 years agoRemove the deprecated ProgramBuilder class
Mikko Rasa [Sun, 14 Feb 2021 00:28:43 +0000 (02:28 +0200)]
Remove the deprecated ProgramBuilder class

3 years agoFix filename handling in the Blender exporter on Windows
Mikko Rasa [Sat, 13 Feb 2021 20:08:01 +0000 (22:08 +0200)]
Fix filename handling in the Blender exporter on Windows

os.path.basename seems to consider the // prefix to indicate a UNC
path and will return an empty string if the path contains exactly
two components.

3 years agoSupport exporting "empty" materials with only a technique or shader
Mikko Rasa [Sat, 13 Feb 2021 18:53:41 +0000 (20:53 +0200)]
Support exporting "empty" materials with only a technique or shader

3 years agoRefactor material property handling in the Blender exporter
Mikko Rasa [Sat, 13 Feb 2021 18:41:33 +0000 (20:41 +0200)]
Refactor material property handling in the Blender exporter

3 years agoDon't export plain values for texture-only material properties
Mikko Rasa [Sat, 13 Feb 2021 16:45:25 +0000 (18:45 +0200)]
Don't export plain values for texture-only material properties

3 years agoMinor fixes
Mikko Rasa [Sat, 13 Feb 2021 16:22:39 +0000 (18:22 +0200)]
Minor fixes

3 years agoAdd description fields to the export operators
Mikko Rasa [Sat, 13 Feb 2021 16:05:34 +0000 (18:05 +0200)]
Add description fields to the export operators

3 years agoAdd an exporter setting to export all selected objects or meshes at once
Mikko Rasa [Sat, 13 Feb 2021 15:39:45 +0000 (17:39 +0200)]
Add an exporter setting to export all selected objects or meshes at once

3 years agoFix typos in custom property UI layout
Mikko Rasa [Sat, 13 Feb 2021 15:35:17 +0000 (17:35 +0200)]
Fix typos in custom property UI layout

3 years agoUse the right property when collecting materials for a material map
Mikko Rasa [Sat, 13 Feb 2021 15:34:47 +0000 (17:34 +0200)]
Use the right property when collecting materials for a material map

3 years agoExport texture sampling settings as sampler objects
Mikko Rasa [Sat, 13 Feb 2021 15:34:12 +0000 (17:34 +0200)]
Export texture sampling settings as sampler objects

3 years agoAdjust texture datafile statements in Blender exporter
Mikko Rasa [Sat, 13 Feb 2021 13:53:55 +0000 (15:53 +0200)]
Adjust texture datafile statements in Blender exporter

Sized pixel formats are now used for storage and it's only specified if
data is exported inline.

3 years agoUse min_retain_frames to decide when to clear the resource load queue
Mikko Rasa [Sat, 13 Feb 2021 11:57:23 +0000 (13:57 +0200)]
Use min_retain_frames to decide when to clear the resource load queue

3 years agoAdd some files which got forgotten in earlier commits
Mikko Rasa [Sat, 13 Feb 2021 09:42:20 +0000 (11:42 +0200)]
Add some files which got forgotten in earlier commits