16 months agoRename SequenceTemplate::Pass::renderable_name to slot_name
Mikko Rasa [Wed, 14 Apr 2021 15:25:03 +0000 (18:25 +0300)]
Rename SequenceTemplate::Pass::renderable_name to slot_name

16 months agoAvoid NaN issues in rare cases in the Cook-Torrance shader
Mikko Rasa [Wed, 14 Apr 2021 15:09:36 +0000 (18:09 +0300)]
Avoid NaN issues in rare cases in the Cook-Torrance shader

The dot product may sometimes be very slightly over 1.0, making the
first argument to pow negative and giving undefined results.

16 months agoFix loading sRGB external images for textures
Mikko Rasa [Wed, 14 Apr 2021 15:07:50 +0000 (18:07 +0300)]
Fix loading sRGB external images for textures

This fixes bugs introduced in 9087cc0 (sRGB state ignored when setting
internal format) and 635e5dc (external_image_srgb handled incorrectly).

16 months agoRemove some vestigial code from Sequence
Mikko Rasa [Wed, 14 Apr 2021 12:04:24 +0000 (15:04 +0300)]
Remove some vestigial code from Sequence

Apparently a few internal parts were left behind when I removed the
related interfaces.

16 months agoUse a vector instead of a list for Sequence's steps
Mikko Rasa [Wed, 14 Apr 2021 11:46:05 +0000 (14:46 +0300)]
Use a vector instead of a list for Sequence's steps

They're not large or numerous enough to warrant a list.

16 months agoAdd compatibility typedefs for the pipeline classes
Mikko Rasa [Wed, 14 Apr 2021 11:45:15 +0000 (14:45 +0300)]
Add compatibility typedefs for the pipeline classes

Must be in a separate commit for git to pick up on the renames in the
previous one.

16 months agoRename Pipeline to Sequence
Mikko Rasa [Wed, 14 Apr 2021 11:42:11 +0000 (14:42 +0300)]
Rename Pipeline to Sequence

Pipeline::Pass is now Sequence::Step.  These better match what the
classes do.

16 months agoNew way of loading scenes in the viewer
Mikko Rasa [Tue, 13 Apr 2021 21:26:24 +0000 (00:26 +0300)]
New way of loading scenes in the viewer

16 months agoAdd a scene type property to the Blender exporter
Mikko Rasa [Tue, 13 Apr 2021 21:04:13 +0000 (00:04 +0300)]
Add a scene type property to the Blender exporter

16 months agoSupport loading scenes from Resources
Mikko Rasa [Tue, 13 Apr 2021 21:03:43 +0000 (00:03 +0300)]
Support loading scenes from Resources

16 months agoAdd a registry-based generic loader to Scene
Mikko Rasa [Tue, 13 Apr 2021 20:53:43 +0000 (23:53 +0300)]
Add a registry-based generic loader to Scene

This is rather similar to the one in Material, but there's just enough
differences and template complications that it isn't trivial to abstract.

16 months agoUse latest OpenGL version in viewer
Mikko Rasa [Tue, 13 Apr 2021 19:17:01 +0000 (22:17 +0300)]
Use latest OpenGL version in viewer

16 months agoUse an Options struct to process command line options in viewer
Mikko Rasa [Tue, 13 Apr 2021 18:39:00 +0000 (21:39 +0300)]
Use an Options struct to process command line options in viewer

16 months agoImprove logic for exporting material sampler references
Mikko Rasa [Tue, 13 Apr 2021 11:07:58 +0000 (14:07 +0300)]
Improve logic for exporting material sampler references

16 months agoAdd an option to automatically detect if tangents need to be exported
Mikko Rasa [Tue, 13 Apr 2021 11:06:36 +0000 (14:06 +0300)]
Add an option to automatically detect if tangents need to be exported

It's enabled by default, which should reduce hassle when authoring

16 months agoAdd the group and weight attributes to msp_interface.glsl
Mikko Rasa [Tue, 13 Apr 2021 10:22:54 +0000 (13:22 +0300)]
Add the group and weight attributes to msp_interface.glsl

This got forgotten in e1d0738.

16 months agoInclude only tangent in mesh data and calculate binormal on the fly
Mikko Rasa [Tue, 13 Apr 2021 10:22:02 +0000 (13:22 +0300)]
Include only tangent in mesh data and calculate binormal on the fly

This saves one vertex attribute.

16 months agoFix incorrect definition of the builtin cross function in GLSL
Mikko Rasa [Tue, 13 Apr 2021 10:10:56 +0000 (13:10 +0300)]
Fix incorrect definition of the builtin cross function in GLSL

16 months agoUse unit 0 UVs for exporting TBNs if no UV layer is specified
Mikko Rasa [Tue, 13 Apr 2021 09:43:56 +0000 (12:43 +0300)]
Use unit 0 UVs for exporting TBNs if no UV layer is specified

16 months agoEnsure that objects have unique names while exporting a scene
Mikko Rasa [Tue, 13 Apr 2021 09:02:24 +0000 (12:02 +0300)]
Ensure that objects have unique names while exporting a scene

16 months agoCompare materials when looking for object clones while exporting a scene
Mikko Rasa [Tue, 13 Apr 2021 08:49:38 +0000 (11:49 +0300)]
Compare materials when looking for object clones while exporting a scene

16 months agoRecognize a certain configuration of nodes as inverting Y for normals
Mikko Rasa [Tue, 13 Apr 2021 08:33:13 +0000 (11:33 +0300)]
Recognize a certain configuration of nodes as inverting Y for normals

Models made for DirectX treat the normal map values as having positive
Y pointing toward the bottom of the image, which is opposite to what my
engine and Blender expect.  This allows fixing that without modifying
the original texture.

16 months agoForce the usage of normalmap as RGB data
Mikko Rasa [Mon, 12 Apr 2021 22:27:00 +0000 (01:27 +0300)]
Force the usage of normalmap as RGB data

16 months agoUse more efficient methods to manipulate and store texture data
Mikko Rasa [Mon, 12 Apr 2021 22:25:22 +0000 (01:25 +0300)]
Use more efficient methods to manipulate and store texture data

16 months agoRemove deprecated things from the maketex script
Mikko Rasa [Mon, 12 Apr 2021 21:40:10 +0000 (00:40 +0300)]
Remove deprecated things from the maketex script

16 months agoFix a bug in if no ranges are given
Mikko Rasa [Mon, 12 Apr 2021 21:18:07 +0000 (00:18 +0300)]
Fix a bug in if no ranges are given

16 months agoConvert the texture and font creation scripts to python3
Mikko Rasa [Mon, 12 Apr 2021 21:17:23 +0000 (00:17 +0300)]
Convert the texture and font creation scripts to python3

16 months agoDon't ignore structs entirely in UnusedVariableRemover
Mikko Rasa [Mon, 12 Apr 2021 15:00:34 +0000 (18:00 +0300)]
Don't ignore structs entirely in UnusedVariableRemover

Structs may have arrays in them, and array sizes may have references to
specialization constants which must be kept.

16 months agoAdjust specular calculation in the Phong shader
Mikko Rasa [Mon, 12 Apr 2021 14:40:04 +0000 (17:40 +0300)]
Adjust specular calculation in the Phong shader

Since the look vector points towards the surface, it makes more sense
to calculate the reflected vector towards the light.  The calculation
is symmetric so the result is the same.

16 months agoRefactor vertex transformations in the common shader
Mikko Rasa [Mon, 12 Apr 2021 14:32:06 +0000 (17:32 +0300)]
Refactor vertex transformations in the common shader

It makes more sense to have virtual accessors for the transformation
matrices so the returned matrix can be used multiple times.

16 months agoRearrange type specification in material datafiles
Mikko Rasa [Mon, 12 Apr 2021 12:38:54 +0000 (15:38 +0300)]
Rearrange type specification in material datafiles

The type is now specified as a separate statement with no substatements.
This is what I wanted to do originally but couldn't figure out a clean
way to do it.

No legacy support because the new material system as a whole is still
fairly new and hasn't been used in many places.

16 months agoMigrate from LoadableTypeRegistry to TypeRegistry
Mikko Rasa [Mon, 12 Apr 2021 12:01:48 +0000 (15:01 +0300)]
Migrate from LoadableTypeRegistry to TypeRegistry

16 months agoFix normal map property name in material exporter
Mikko Rasa [Mon, 12 Apr 2021 01:18:39 +0000 (04:18 +0300)]
Fix normal map property name in material exporter

16 months agoFix incorrect plurals in exporter scripts
Mikko Rasa [Mon, 12 Apr 2021 00:34:10 +0000 (03:34 +0300)]
Fix incorrect plurals in exporter scripts

Replacing "map" with "atlas" was not correct in the plural case

16 months agoFix refactoring errors in scene exporter
Mikko Rasa [Mon, 12 Apr 2021 00:33:37 +0000 (03:33 +0300)]
Fix refactoring errors in scene exporter

16 months agoRecognize textures through an RGB to BW node in Blender
Mikko Rasa [Sun, 11 Apr 2021 20:39:16 +0000 (23:39 +0300)]
Recognize textures through an RGB to BW node in Blender

16 months agoDeprecated InstanceScene and Renderable::get_instance_key
Mikko Rasa [Sun, 11 Apr 2021 20:38:31 +0000 (23:38 +0300)]
Deprecated InstanceScene and Renderable::get_instance_key

InstanceArray is a superior way of rendering multiple instances of an

16 months agoRedesign Text as an ObjectInstance
Mikko Rasa [Sun, 11 Apr 2021 20:35:26 +0000 (23:35 +0300)]
Redesign Text as an ObjectInstance

It's rare to need several copies of the same text, but positioning texts
is useful.

Text no longer copies the Technique but instead sets the texture in

16 months agoOverhaul texture management in rendering classes
Mikko Rasa [Sun, 11 Apr 2021 20:25:18 +0000 (23:25 +0300)]
Overhaul texture management in rendering classes

Textures are now set based on the uniform name (tag) rather than texture
unit.  The Texturing class has been deprecated because it was making
things difficult when textures come from multiple sources, such as with
effects or decals.  RenderPass and Renderer now handle multiple textures

There's some compatibility code but things are likely to break.

16 months agoUse a vector for storage in DefaultUniformBlock
Mikko Rasa [Sat, 10 Apr 2021 20:07:19 +0000 (23:07 +0300)]
Use a vector for storage in DefaultUniformBlock

Uniform locations are normally spaced no more than 4 apart, so even with
a few empty spots a vector is going to be more efficient than a map.

16 months agoSplit UniformBlock into two classes
Mikko Rasa [Sat, 10 Apr 2021 20:00:39 +0000 (23:00 +0300)]
Split UniformBlock into two classes

There's basically no overlap between default and buffer-backed blocks,
so no point in having them in the same class.

16 months agoRefactor ProgramData to store blocks in vectors
Mikko Rasa [Sat, 10 Apr 2021 18:42:58 +0000 (21:42 +0300)]
Refactor ProgramData to store blocks in vectors

16 months agoSort uniform blocks from SPIR-V modules
Mikko Rasa [Sat, 10 Apr 2021 18:20:44 +0000 (21:20 +0300)]
Sort uniform blocks from SPIR-V modules

16 months agoUse the new _member utility functions to search and sort things
Mikko Rasa [Sat, 10 Apr 2021 18:17:00 +0000 (21:17 +0300)]
Use the new _member utility functions to search and sort things

16 months agoRemove unnecessary std:: qualifiers from .cpp files
Mikko Rasa [Sat, 10 Apr 2021 12:15:59 +0000 (15:15 +0300)]
Remove unnecessary std:: qualifiers from .cpp files

16 months agoUse Tag to identify uniforms in Program and ProgramData
Mikko Rasa [Sat, 10 Apr 2021 12:04:26 +0000 (15:04 +0300)]
Use Tag to identify uniforms in Program and ProgramData

Setting uniforms is a common operation and this should be faster than
using strings.

16 months agoMake Tags convertible back to the original string in debug builds
Mikko Rasa [Sat, 10 Apr 2021 09:45:50 +0000 (12:45 +0300)]
Make Tags convertible back to the original string in debug builds

This helps in producing more readable error messages

16 months agoClear the empty name flag after emitting a member access
Mikko Rasa [Sat, 10 Apr 2021 00:46:29 +0000 (03:46 +0300)]
Clear the empty name flag after emitting a member access

16 months agoPass Tag by value, not by reference
Mikko Rasa [Fri, 9 Apr 2021 21:40:39 +0000 (00:40 +0300)]
Pass Tag by value, not by reference

Since the tag object is small, it can be passed in a register.

Keeping a deprecated version would make it hard to tell which version
is being called.

16 months agoAdd an option to compile SPIR-V in the command-line GLSL compiler
Mikko Rasa [Fri, 9 Apr 2021 15:22:00 +0000 (18:22 +0300)]
Add an option to compile SPIR-V in the command-line GLSL compiler

16 months agoAdd a couple more test cases
Mikko Rasa [Fri, 9 Apr 2021 14:44:53 +0000 (17:44 +0300)]
Add a couple more test cases

16 months agoTest the SPIR-V backend using libspirv
Mikko Rasa [Fri, 9 Apr 2021 14:36:22 +0000 (17:36 +0300)]
Test the SPIR-V backend using libspirv

16 months agoAdd a SPIR-V backend to the GLSL compiler
Mikko Rasa [Fri, 9 Apr 2021 14:31:47 +0000 (17:31 +0300)]
Add a SPIR-V backend to the GLSL compiler

16 months agoFix a signedness warning
Mikko Rasa [Fri, 9 Apr 2021 14:08:16 +0000 (17:08 +0300)]
Fix a signedness warning

16 months agoDisallow specializing when compiling a module
Mikko Rasa [Fri, 9 Apr 2021 14:05:47 +0000 (17:05 +0300)]
Disallow specializing when compiling a module

The specialization constants would be ignored anyway, so better be
explicit about it.

16 months agoAdd an output file option to the command-line GLSL compiler
Mikko Rasa [Fri, 9 Apr 2021 13:45:34 +0000 (16:45 +0300)]
Add an output file option to the command-line GLSL compiler

16 months agoVisit the entire call graph in DependencyCollector
Mikko Rasa [Thu, 8 Apr 2021 21:52:06 +0000 (00:52 +0300)]
Visit the entire call graph in DependencyCollector

16 months agoConvert operands of shift operators to the same vector size
Mikko Rasa [Thu, 8 Apr 2021 21:46:53 +0000 (00:46 +0300)]
Convert operands of shift operators to the same vector size

16 months agoAdd a separate constant to enable clipping in standard shaders
Mikko Rasa [Wed, 7 Apr 2021 23:00:51 +0000 (02:00 +0300)]
Add a separate constant to enable clipping in standard shaders

Declaring an array with zero size is not allowed, so using zero for
max_clip_planes doesn't work.

16 months agoValidate GLSL flow control
Mikko Rasa [Wed, 7 Apr 2021 20:49:31 +0000 (23:49 +0300)]
Validate GLSL flow control

In particular, it's an error to reach the end of a non-void function
without a return statement.

16 months agoMake the GLSL compiler test runner able to verify non-error diagnostics
Mikko Rasa [Wed, 7 Apr 2021 20:48:04 +0000 (23:48 +0300)]
Make the GLSL compiler test runner able to verify non-error diagnostics

16 months agoRemove unreachable code after a jump statement
Mikko Rasa [Wed, 7 Apr 2021 20:35:12 +0000 (23:35 +0300)]
Remove unreachable code after a jump statement

16 months agoCheck that non-constant data is not accessed from constant expressions
Mikko Rasa [Wed, 7 Apr 2021 12:28:24 +0000 (15:28 +0300)]
Check that non-constant data is not accessed from constant expressions

16 months agoCompare array sizes in TypeComparer
Mikko Rasa [Tue, 6 Apr 2021 23:02:40 +0000 (02:02 +0300)]
Compare array sizes in TypeComparer

16 months agoRewrite type comparisons as a visitor
Mikko Rasa [Tue, 6 Apr 2021 22:42:49 +0000 (01:42 +0300)]
Rewrite type comparisons as a visitor

16 months agoRequire conditions to be booleans
Mikko Rasa [Tue, 6 Apr 2021 21:21:23 +0000 (00:21 +0300)]
Require conditions to be booleans

16 months agoDisallow certain types from appearing on variables
Mikko Rasa [Tue, 6 Apr 2021 21:17:02 +0000 (00:17 +0300)]
Disallow certain types from appearing on variables

16 months agoAdjust GLSL builtins
Mikko Rasa [Tue, 6 Apr 2021 09:54:06 +0000 (12:54 +0300)]
Adjust GLSL builtins

Remove some functions which are complicated to implement in SPIR-V due
to the use of ad-hoc struct types or pointers.  I may add them back
later if there turns out to be some use for them.

Add inline definitions for some overloads taking mixed vector and scalar
arguments.  SPIR-V operations require all operands to have the same
number of elements.  Builtin functions are always inlined even if used
more than once.

16 months agoLeave no-op constructors as they are
Mikko Rasa [Tue, 6 Apr 2021 09:48:44 +0000 (12:48 +0300)]
Leave no-op constructors as they are

In particular, don't break a matrix down into columns and construct
it again.  These could just be removed from the AST entirely, but the
expression resolver currently does not do node replacement and it's
easier to just skip this in the backend.

16 months agoFix GLSL member access index calculation
Mikko Rasa [Tue, 6 Apr 2021 09:46:48 +0000 (12:46 +0300)]
Fix GLSL member access index calculation

Also show it in debug output

16 months agoRefactor layout qualifier creation with constructors
Mikko Rasa [Mon, 5 Apr 2021 13:54:49 +0000 (16:54 +0300)]
Refactor layout qualifier creation with constructors

16 months agoShow label for all interface blocks in GLSL debug output
Mikko Rasa [Mon, 5 Apr 2021 13:47:07 +0000 (16:47 +0300)]
Show label for all interface blocks in GLSL debug output

16 months agoTrack composite assignments and references in UnusedVariableRemover
Mikko Rasa [Mon, 5 Apr 2021 13:46:11 +0000 (16:46 +0300)]
Track composite assignments and references in UnusedVariableRemover

16 months agoRefactor add_to_chain as a common utility function
Mikko Rasa [Mon, 5 Apr 2021 13:44:16 +0000 (16:44 +0300)]
Refactor add_to_chain as a common utility function

16 months agoMark all expression result types as used
Mikko Rasa [Mon, 5 Apr 2021 12:59:36 +0000 (15:59 +0300)]
Mark all expression result types as used

UnusedTypeRemover was missing several expression node types.  Now it
handles expressions through the general expression mechanism.

16 months agoMake DumpTree able to dump arbitrary nodes
Mikko Rasa [Mon, 5 Apr 2021 12:43:02 +0000 (15:43 +0300)]
Make DumpTree able to dump arbitrary nodes

Remove that ability from Formatter since it makes assumptions about the
state of the nodes, like certain references existing.

16 months agoDon't return references from apply functions
Mikko Rasa [Mon, 5 Apr 2021 12:22:40 +0000 (15:22 +0300)]
Don't return references from apply functions

It's somewhat error prone, even though it hasn't caused any problems

16 months agoAlways use member access for interface blocks, even anonymous ones
Mikko Rasa [Mon, 5 Apr 2021 11:49:41 +0000 (14:49 +0300)]
Always use member access for interface blocks, even anonymous ones

Having variable references magically refer to variables inside interface
blocks causes trouble when generating SPIR-V.

This currently breaks one test case because UnusedVariableRemover can't
track access chains.

16 months agoOutput the interface block as is in the AST dump
Mikko Rasa [Mon, 5 Apr 2021 11:13:36 +0000 (14:13 +0300)]
Output the interface block as is in the AST dump

This is more useful for debugging

16 months agoChange the naming scheme for the interface block map
Mikko Rasa [Mon, 5 Apr 2021 11:08:21 +0000 (14:08 +0300)]
Change the naming scheme for the interface block map

Adding a space in the keys for block name makes it impossible for them to
conflict with identifiers and allows instance names to be used directly.

16 months agoRecognize matrix data order qualifiers and add one if missing
Mikko Rasa [Mon, 5 Apr 2021 09:28:11 +0000 (12:28 +0300)]
Recognize matrix data order qualifiers and add one if missing

16 months agoRequire initializers on constant variables
Mikko Rasa [Mon, 5 Apr 2021 09:25:49 +0000 (12:25 +0300)]
Require initializers on constant variables

16 months agoOffset layout qualifiers are only allowed on uniform block members
Mikko Rasa [Mon, 5 Apr 2021 09:25:12 +0000 (12:25 +0300)]
Offset layout qualifiers are only allowed on uniform block members

Same goes for the alignment qualifier.

16 months agoAdd visitors to calculate offsets of struct members
Mikko Rasa [Sun, 4 Apr 2021 09:35:00 +0000 (12:35 +0300)]
Add visitors to calculate offsets of struct members

It's not used yet, but will be required for creating SPIR-V modules.

16 months agoMake function dependency collection its own visitor class
Mikko Rasa [Sun, 4 Apr 2021 08:38:42 +0000 (11:38 +0300)]
Make function dependency collection its own visitor class

I need it for creating SPIR-V entry points too.

16 months agoStore the index of the member in MemberAccess
Mikko Rasa [Sun, 4 Apr 2021 08:32:31 +0000 (11:32 +0300)]
Store the index of the member in MemberAccess

16 months agoFix mismatched new[]/delete
Mikko Rasa [Sat, 3 Apr 2021 20:01:12 +0000 (23:01 +0300)]
Fix mismatched new[]/delete

16 months agoRearrange some utility struct constructors
Mikko Rasa [Sat, 3 Apr 2021 20:00:55 +0000 (23:00 +0300)]
Rearrange some utility struct constructors

16 months agoGuard against hitting the end of the array in get_gl_type
Mikko Rasa [Sat, 3 Apr 2021 19:58:51 +0000 (22:58 +0300)]
Guard against hitting the end of the array in get_gl_type

16 months agoComments and cosmetic cleanups
Mikko Rasa [Sat, 3 Apr 2021 19:56:09 +0000 (22:56 +0300)]
Comments and cosmetic cleanups

16 months agoDo an early return from Mesh::draw if there's no data
Mikko Rasa [Sat, 3 Apr 2021 18:55:58 +0000 (21:55 +0300)]
Do an early return from Mesh::draw if there's no data

Otherwise if would try to set zero-sized storage for the buffers, which
is not allowed.

Also guard against empty batches in resize_buffers just in case.

16 months agoUse uniform block and texture bindings from GLSL
Mikko Rasa [Sat, 3 Apr 2021 18:17:27 +0000 (21:17 +0300)]
Use uniform block and texture bindings from GLSL

16 months agoAdd a target version option to the command-line GLSL compiler
Mikko Rasa [Sat, 3 Apr 2021 16:54:26 +0000 (19:54 +0300)]
Add a target version option to the command-line GLSL compiler

16 months agoBetter way to request features for different GLSL versions
Mikko Rasa [Sat, 3 Apr 2021 16:53:55 +0000 (19:53 +0300)]
Better way to request features for different GLSL versions

16 months agoAssign bindings to all uniform blocks and sampler uniforms
Mikko Rasa [Sat, 3 Apr 2021 16:40:34 +0000 (19:40 +0300)]
Assign bindings to all uniform blocks and sampler uniforms

16 months agoAdd legacy conversion for binding layout qualifiers
Mikko Rasa [Sat, 3 Apr 2021 16:33:29 +0000 (19:33 +0300)]
Add legacy conversion for binding layout qualifiers

These are not yet used by Program because there's no good way to detect
which uniforms had bindings in case the implementation does support the
qualifiers.  Anything missing a binding gets assigned binding 0, which
is also a valid manually specified binding.  Upcoming commits will move
bindings entirely to GLSL side.

16 months agoStore constant id limit as range, not max value
Mikko Rasa [Sat, 3 Apr 2021 15:39:26 +0000 (18:39 +0300)]
Store constant id limit as range, not max value

16 months agoBetter checking of where the binding qualifier is allowed
Mikko Rasa [Sat, 3 Apr 2021 14:12:50 +0000 (17:12 +0300)]
Better checking of where the binding qualifier is allowed

16 months agoDisallow the descriptor set qualifier for now
Mikko Rasa [Sat, 3 Apr 2021 14:11:34 +0000 (17:11 +0300)]
Disallow the descriptor set qualifier for now

It's only meaningful for Vulkan, which isn't implemented yet

16 months agoAllocate locations to interface variables
Mikko Rasa [Sat, 3 Apr 2021 10:56:16 +0000 (13:56 +0300)]
Allocate locations to interface variables