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

3 years agoUse samplers in effects and postprocessors
Mikko Rasa [Thu, 11 Feb 2021 23:03:16 +0000 (01:03 +0200)]
Use samplers in effects and postprocessors

3 years agoSupport setting a sampler directly in Renderer
Mikko Rasa [Thu, 11 Feb 2021 22:19:53 +0000 (00:19 +0200)]
Support setting a sampler directly in Renderer

3 years agoBetter lifecycle management of the fullscreen quad in PostProcessor
Mikko Rasa [Mon, 8 Feb 2021 11:51:44 +0000 (13:51 +0200)]
Better lifecycle management of the fullscreen quad in PostProcessor

It's now stored in a WeakPtr and the postprocessor instances hold
a RefPtr to it, so it will be deleted together with the last
postprocessor.

3 years agoAsync load texture data directly into the pixel buffer
Mikko Rasa [Sun, 7 Feb 2021 16:20:52 +0000 (18:20 +0200)]
Async load texture data directly into the pixel buffer

3 years agoFix sampler binding bug
Mikko Rasa [Sun, 7 Feb 2021 16:20:13 +0000 (18:20 +0200)]
Fix sampler binding bug

3 years agoInitialize Texture::use_srgb_format
Mikko Rasa [Sun, 7 Feb 2021 16:20:01 +0000 (18:20 +0200)]
Initialize Texture::use_srgb_format

3 years agoEnsure that mapped memory is unmapped in Texture2D::AsyncLoader
Mikko Rasa [Sun, 7 Feb 2021 13:33:20 +0000 (15:33 +0200)]
Ensure that mapped memory is unmapped in Texture2D::AsyncLoader

3 years agoGraphics::Image::get_data was renamed to get_pixels
Mikko Rasa [Sun, 7 Feb 2021 13:24:59 +0000 (15:24 +0200)]
Graphics::Image::get_data was renamed to get_pixels

3 years agoOnly mark changed fields dirty when unloading a sampler
Mikko Rasa [Sat, 6 Feb 2021 22:14:14 +0000 (00:14 +0200)]
Only mark changed fields dirty when unloading a sampler

3 years agoFix material registry initialization bug
Mikko Rasa [Sat, 6 Feb 2021 22:09:19 +0000 (00:09 +0200)]
Fix material registry initialization bug

3 years agoAdd sampler support to materials
Mikko Rasa [Sat, 6 Feb 2021 21:37:41 +0000 (23:37 +0200)]
Add sampler support to materials

3 years agoRename Material::LoaderBase to PropertyLoader
Mikko Rasa [Sat, 6 Feb 2021 21:36:55 +0000 (23:36 +0200)]
Rename Material::LoaderBase to PropertyLoader

3 years agoAvoid invalid memory access when destroying Mesh
Mikko Rasa [Sat, 6 Feb 2021 17:46:31 +0000 (19:46 +0200)]
Avoid invalid memory access when destroying Mesh

3 years agoAllow samplers to be loaded from datafiles
Mikko Rasa [Sat, 6 Feb 2021 13:28:46 +0000 (15:28 +0200)]
Allow samplers to be loaded from datafiles

3 years agoSupport samplers as independent objects
Mikko Rasa [Sat, 6 Feb 2021 13:27:53 +0000 (15:27 +0200)]
Support samplers as independent objects

3 years agoDepracate the srgb parameter of Texture::image functions
Mikko Rasa [Fri, 5 Feb 2021 22:14:12 +0000 (00:14 +0200)]
Depracate the srgb parameter of Texture::image functions

Now that texture datafiles can be used to specify import settings on a
per-texture basis and the Blender exporter uses them, there's no need
for this anymore.

3 years agoLoad .tex2d format textures with resource manager
Mikko Rasa [Fri, 5 Feb 2021 21:30:45 +0000 (23:30 +0200)]
Load .tex2d format textures with resource manager

This allows universal use of .tex2d to specify texture settings, even
when the actual image data is loaded from an external file.

3 years agoRefactor texture external image loading into a helper function
Mikko Rasa [Wed, 3 Feb 2021 22:58:19 +0000 (00:58 +0200)]
Refactor texture external image loading into a helper function

3 years agoReorder some pixel format values
Mikko Rasa [Mon, 1 Feb 2021 20:22:04 +0000 (22:22 +0200)]
Reorder some pixel format values

They're now rougly in order from most to least used by category

3 years agoRequire texture data to be uploaded in a format matching the storage
Mikko Rasa [Mon, 1 Feb 2021 20:17:35 +0000 (22:17 +0200)]
Require texture data to be uploaded in a format matching the storage

This is almost always the case anyway.  It makes things simpler as I don't
have to figure out what to do if someone tries to upload RGB data into a
LUMINANCE_ALPHA texture, which is really an RG texture in disguise.

There are some potential exceptions, like uploading FLOAT data to a
texture with HALF_FLOAT storage.  I'll write conversion routines if those
become relevant.

3 years agoSupport BGR and BGRA as texture formats through swizzling
Mikko Rasa [Mon, 1 Feb 2021 19:18:29 +0000 (21:18 +0200)]
Support BGR and BGRA as texture formats through swizzling

3 years agoSeparate abstract pixel compositions from concrete pixel formats
Mikko Rasa [Mon, 1 Feb 2021 19:08:29 +0000 (21:08 +0200)]
Separate abstract pixel compositions from concrete pixel formats

Texture and renderbuffer storage must now be specified using a sized
pixel format.  The PixelFormat API has also been refactored.

3 years agoRemove the deprecated form of Texture3D::load_image
Mikko Rasa [Mon, 1 Feb 2021 16:19:36 +0000 (18:19 +0200)]
Remove the deprecated form of Texture3D::load_image

3 years agoAlways use swizzle to implement luminance formats
Mikko Rasa [Mon, 1 Feb 2021 12:52:05 +0000 (14:52 +0200)]
Always use swizzle to implement luminance formats

ARB_texture_swizzle was promoted to core in OpenGL 3.3 and hardware not
supporting that is obsolete.

3 years agoSimplify applying texture swizzling
Mikko Rasa [Sun, 31 Jan 2021 11:11:52 +0000 (13:11 +0200)]
Simplify applying texture swizzling

It's now set once when creating storage for the texture, so tracking its
dirty state is not necessary.

3 years agoMove texture sampler state to a separate object
Mikko Rasa [Sun, 31 Jan 2021 00:55:49 +0000 (02:55 +0200)]
Move texture sampler state to a separate object

First step in supporting sampler objects

3 years agoAllow texture mipmap levels to be specified in datafiles
Mikko Rasa [Sun, 31 Jan 2021 00:24:14 +0000 (02:24 +0200)]
Allow texture mipmap levels to be specified in datafiles

This appears to have been missed in 03d3984 which removed the filtering
heuristic from storage/allocate.

3 years agoMove filter heuristic for mipmap levels to Texture::Loader
Mikko Rasa [Sun, 31 Jan 2021 00:09:16 +0000 (02:09 +0200)]
Move filter heuristic for mipmap levels to Texture::Loader

3 years agoImprove allocation handling in cube map textures
Mikko Rasa [Sat, 30 Jan 2021 18:03:47 +0000 (20:03 +0200)]
Improve allocation handling in cube map textures

While there isn't enough bits to track all face allocations, tracking
the base level per face is possible.  This allows mipmap generation to
work more sensibly.

3 years agoDeprecate the mipmap_levels parameter in Texture
Mikko Rasa [Sat, 30 Jan 2021 17:57:58 +0000 (19:57 +0200)]
Deprecate the mipmap_levels parameter in Texture

Instead specify the desired amount of mipmap levels when loading an
image.  This can be more robustly checked against the defined storage.

3 years agoRemove the usage member from Buffer entirely
Mikko Rasa [Tue, 26 Jan 2021 23:49:00 +0000 (01:49 +0200)]
Remove the usage member from Buffer entirely

3 years agoClear Texture2D's allocation flags when unloading
Mikko Rasa [Mon, 25 Jan 2021 23:47:05 +0000 (01:47 +0200)]
Clear Texture2D's allocation flags when unloading

3 years agoDisallow drawing batches without an index buffer
Mikko Rasa [Mon, 25 Jan 2021 23:41:16 +0000 (01:41 +0200)]
Disallow drawing batches without an index buffer

3 years agoGive a name to the ResourceManager loading thread
Mikko Rasa [Mon, 25 Jan 2021 23:38:57 +0000 (01:38 +0200)]
Give a name to the ResourceManager loading thread

3 years agoDon't try to set parameters for textures which aren't loaded yet
Mikko Rasa [Mon, 25 Jan 2021 23:20:48 +0000 (01:20 +0200)]
Don't try to set parameters for textures which aren't loaded yet

3 years agoUse glCreateTextures also for async loading
Mikko Rasa [Mon, 25 Jan 2021 23:19:33 +0000 (01:19 +0200)]
Use glCreateTextures also for async loading

Otherwise the texture won't be fully created when glTextureStorage2D
is called.

3 years agoBetter way of refreshing VertexSetup
Mikko Rasa [Mon, 25 Jan 2021 23:17:52 +0000 (01:17 +0200)]
Better way of refreshing VertexSetup

It can now disable attribute arrays which are no longer used.

3 years agoRefresh vertex setup when loading vertices for a mesh
Mikko Rasa [Mon, 25 Jan 2021 23:15:18 +0000 (01:15 +0200)]
Refresh vertex setup when loading vertices for a mesh

Also add a better guard against performing OpenGL calls from the loading
thread.

3 years agoTrigger Mesh::check_buffers from MeshBuilder destructor
Mikko Rasa [Mon, 25 Jan 2021 23:01:53 +0000 (01:01 +0200)]
Trigger Mesh::check_buffers from MeshBuilder destructor

Doing it for every vertex wastes performance

3 years agoMinor comment adjustments
Mikko Rasa [Mon, 25 Jan 2021 02:18:50 +0000 (04:18 +0200)]
Minor comment adjustments

3 years agoClear offset of Bufferable when removing from buffer
Mikko Rasa [Mon, 25 Jan 2021 02:15:33 +0000 (04:15 +0200)]
Clear offset of Bufferable when removing from buffer

It shouldn't really matter but just in case.

3 years agoRemove commented out debugging statements
Mikko Rasa [Mon, 25 Jan 2021 02:15:02 +0000 (04:15 +0200)]
Remove commented out debugging statements

3 years agoAdd some hints for older compilers
Mikko Rasa [Mon, 25 Jan 2021 02:14:35 +0000 (04:14 +0200)]
Add some hints for older compilers

3 years agoAdd datafile statement which was apparently forgotten
Mikko Rasa [Mon, 25 Jan 2021 02:13:10 +0000 (04:13 +0200)]
Add datafile statement which was apparently forgotten

3 years agoRefactor setting uniform values in ProgramData
Mikko Rasa [Mon, 25 Jan 2021 02:07:49 +0000 (04:07 +0200)]
Refactor setting uniform values in ProgramData

This eliminates copies when changing values of existing uniforms.

3 years agoThrow an exception if there's too many uniforms in a ProgramData
Mikko Rasa [Mon, 25 Jan 2021 02:04:11 +0000 (04:04 +0200)]
Throw an exception if there's too many uniforms in a ProgramData

I'd rather find out I need to make the mask wider than have a program
unexplainably slow down.

3 years agoAdd another constructor to RenderTarget to resolve an ambiguity
Mikko Rasa [Mon, 25 Jan 2021 01:21:00 +0000 (03:21 +0200)]
Add another constructor to RenderTarget to resolve an ambiguity

RenderOutput looks like an unsigned more than a RenderTargetFormat so
the compiler would resolve it to the multisample overload.

3 years agoRename batch's data_type to index_type
Mikko Rasa [Mon, 25 Jan 2021 01:13:29 +0000 (03:13 +0200)]
Rename batch's data_type to index_type