]> git.tdb.fi Git - libs/gl.git/log
libs/gl.git
2 years agoAdd support for padding in vertex formats
Mikko Rasa [Wed, 17 Nov 2021 13:39:01 +0000 (15:39 +0200)]
Add support for padding in vertex formats

Vulkan requires attributes to be correctly aligned, so depending on the
combination of types padding may be necessary.  It's better to make it
explicit so support for raw mesh data files can be added in the future.

2 years agoOnly use location-based offsets for the default uniform block
Mikko Rasa [Wed, 17 Nov 2021 13:37:00 +0000 (15:37 +0200)]
Only use location-based offsets for the default uniform block

The push constant block must follow the layout specified in the shader.

2 years agoUse OriginUpperLeft execution mode on Vulkan as required by the spec
Mikko Rasa [Wed, 17 Nov 2021 13:34:53 +0000 (15:34 +0200)]
Use OriginUpperLeft execution mode on Vulkan as required by the spec

2 years agoComment fixes
Mikko Rasa [Wed, 17 Nov 2021 13:34:21 +0000 (15:34 +0200)]
Comment fixes

2 years agoAvoid emitting duplicate specialization constants in SPIR-V
Mikko Rasa [Wed, 17 Nov 2021 13:34:06 +0000 (15:34 +0200)]
Avoid emitting duplicate specialization constants in SPIR-V

2 years agoCollect uniforms which have a binding, even if they have no location
Mikko Rasa [Wed, 17 Nov 2021 13:30:35 +0000 (15:30 +0200)]
Collect uniforms which have a binding, even if they have no location

2 years agoReflect the control flow graph from SPIR-V and check variable accesses
Mikko Rasa [Wed, 17 Nov 2021 13:25:15 +0000 (15:25 +0200)]
Reflect the control flow graph from SPIR-V and check variable accesses

Specialization constants may cause some declared variables to become
unused, and those shouldn't appear in Vulkan descriptor set layouts.

2 years agoFix handling of constants in Spir-V reflection
Mikko Rasa [Wed, 17 Nov 2021 13:21:53 +0000 (15:21 +0200)]
Fix handling of constants in Spir-V reflection

2 years agoFix reflection of image types from Spir-V modules
Mikko Rasa [Wed, 17 Nov 2021 13:21:35 +0000 (15:21 +0200)]
Fix reflection of image types from Spir-V modules

2 years agoAdd a backend for SpirVModule and make it non-copyable
Mikko Rasa [Wed, 17 Nov 2021 13:19:39 +0000 (15:19 +0200)]
Add a backend for SpirVModule and make it non-copyable

In Vulkan shader modules are objects of their own.

2 years agoPack descriptor set and binding in a single variable
Mikko Rasa [Wed, 17 Nov 2021 12:53:30 +0000 (14:53 +0200)]
Pack descriptor set and binding in a single variable

This makes them easier to pass around and there's plenty of bits
available.  Also add a variable for descriptor set count.

2 years agoRemove empty default block before adding uniforms to blocks
Mikko Rasa [Wed, 17 Nov 2021 12:52:06 +0000 (14:52 +0200)]
Remove empty default block before adding uniforms to blocks

Otherwise the block pointers of the uniforms will be incorrect

2 years agoAdd validation for mapping buffers
Mikko Rasa [Wed, 17 Nov 2021 12:49:56 +0000 (14:49 +0200)]
Add validation for mapping buffers

On Vulkan static buffers will be stored on non-host-visible memory and
can't be mapped.  Already-mapped buffers also can't be mapped.

2 years agoAdd a usage parameter to Buffer
Mikko Rasa [Wed, 17 Nov 2021 12:48:58 +0000 (14:48 +0200)]
Add a usage parameter to Buffer

It has no real meaning on OpenGL but is needed on Vulkan

2 years agoUpdate usage of hash functions
Mikko Rasa [Wed, 17 Nov 2021 12:45:15 +0000 (14:45 +0200)]
Update usage of hash functions

Calculating hashes directly from the binary values is faster than first
creating a string.

2 years agoEnable clearing in the viewer's default sequence
Mikko Rasa [Sat, 13 Nov 2021 15:39:15 +0000 (17:39 +0200)]
Enable clearing in the viewer's default sequence

2 years agoMake WindowView override the parameterless render function
Mikko Rasa [Sat, 13 Nov 2021 15:10:11 +0000 (17:10 +0200)]
Make WindowView override the parameterless render function

This works better with the new begin/end sequence of Renderer.

2 years agoExpose the maximum number of attributes and attachments
Mikko Rasa [Sat, 13 Nov 2021 15:01:36 +0000 (17:01 +0200)]
Expose the maximum number of attributes and attachments

2 years agoMake FrameAttachment capable of distinguishing RGB and BGR formats
Mikko Rasa [Sat, 13 Nov 2021 15:00:49 +0000 (17:00 +0200)]
Make FrameAttachment capable of distinguishing RGB and BGR formats

2 years agoBuild sequence without target format if there's no postprocessors
Mikko Rasa [Sat, 13 Nov 2021 14:59:22 +0000 (16:59 +0200)]
Build sequence without target format if there's no postprocessors

2 years agoReplace ProgramData copy constructor with a more explicit copy function
Mikko Rasa [Sat, 13 Nov 2021 14:56:32 +0000 (16:56 +0200)]
Replace ProgramData copy constructor with a more explicit copy function

The copy constructor left so many members uncopied that it was rather
questionable as copy constructor.  This makes it more clear that only
uniform values are being copied.

2 years agoAdd correct copy and move semantics to most classes
Mikko Rasa [Sat, 13 Nov 2021 14:54:53 +0000 (16:54 +0200)]
Add correct copy and move semantics to most classes

2 years agoAdd a safeguard into ResourceManager::add_resource
Mikko Rasa [Sat, 13 Nov 2021 14:17:20 +0000 (16:17 +0200)]
Add a safeguard into ResourceManager::add_resource

2 years agoAdd missing destructor to OpenGLSampler
Mikko Rasa [Sat, 13 Nov 2021 14:14:23 +0000 (16:14 +0200)]
Add missing destructor to OpenGLSampler

2 years agoResolve variables after eliminating constant conditions
Mikko Rasa [Sat, 13 Nov 2021 12:16:46 +0000 (14:16 +0200)]
Resolve variables after eliminating constant conditions

2 years agoFix a name conflict in certain inlining scenarios
Mikko Rasa [Sat, 13 Nov 2021 12:15:04 +0000 (14:15 +0200)]
Fix a name conflict in certain inlining scenarios

2 years agoMove the bloom shader's delta uniform into a block
Mikko Rasa [Fri, 12 Nov 2021 19:55:43 +0000 (21:55 +0200)]
Move the bloom shader's delta uniform into a block

2 years agoMove a few bits of Renderer into a backend class
Mikko Rasa [Fri, 12 Nov 2021 19:36:05 +0000 (21:36 +0200)]
Move a few bits of Renderer into a backend class

This allows the upcoming Vulkan backend to take care of submitting
command buffers.

2 years agoRemove the transform function from Renderer
Mikko Rasa [Fri, 12 Nov 2021 19:30:21 +0000 (21:30 +0200)]
Remove the transform function from Renderer

Renderables are encouraged to set a world-space model matrix directly, as
some scenes and effects won't work properly with incremental matrices.

2 years agoRequire explicit begin() and end() calls in Renderer
Mikko Rasa [Fri, 12 Nov 2021 19:16:55 +0000 (21:16 +0200)]
Require explicit begin() and end() calls in Renderer

2 years agoReorder members of Renderer and PipelineState
Mikko Rasa [Fri, 12 Nov 2021 16:55:36 +0000 (18:55 +0200)]
Reorder members of Renderer and PipelineState

2 years agoRemove deprecated functions from Renderer
Mikko Rasa [Fri, 12 Nov 2021 16:52:44 +0000 (18:52 +0200)]
Remove deprecated functions from Renderer

2 years agoAlways use RGBA color format when building Sequences
Mikko Rasa [Fri, 12 Nov 2021 16:24:23 +0000 (18:24 +0200)]
Always use RGBA color format when building Sequences

2 years agoAdd a swizzle mode for presenting an RGBA texture as RGB
Mikko Rasa [Fri, 12 Nov 2021 16:23:21 +0000 (18:23 +0200)]
Add a swizzle mode for presenting an RGBA texture as RGB

Not many Vulkan implementations support RGB textures

2 years agoAllow BGR format in FrameAttachment, but disallow swizzled formats
Mikko Rasa [Fri, 12 Nov 2021 16:22:16 +0000 (18:22 +0200)]
Allow BGR format in FrameAttachment, but disallow swizzled formats

Vulkan likes to use BGR for swapchain images, at least on my machine

2 years agoMove swizzling modes to pixelformat.h
Mikko Rasa [Fri, 12 Nov 2021 16:21:18 +0000 (18:21 +0200)]
Move swizzling modes to pixelformat.h

2 years agoFix an incorrect check for existence of value
Mikko Rasa [Thu, 11 Nov 2021 11:46:08 +0000 (13:46 +0200)]
Fix an incorrect check for existence of value

2 years agoDon't check the address of an inline array
Mikko Rasa [Thu, 11 Nov 2021 11:41:22 +0000 (13:41 +0200)]
Don't check the address of an inline array

It always evaluates as true, not that it matters greatly in this case.

2 years agoSome more default member initializers
Mikko Rasa [Thu, 11 Nov 2021 11:37:09 +0000 (13:37 +0200)]
Some more default member initializers

2 years agoRemove default uniform block if it has no uniforms
Mikko Rasa [Thu, 11 Nov 2021 11:34:59 +0000 (13:34 +0200)]
Remove default uniform block if it has no uniforms

2 years agoRecognize push constant blocks when reflecting SPIR-V modules
Mikko Rasa [Thu, 11 Nov 2021 11:34:40 +0000 (13:34 +0200)]
Recognize push constant blocks when reflecting SPIR-V modules

2 years agoStore descriptor set in program reflection data
Mikko Rasa [Thu, 11 Nov 2021 11:24:29 +0000 (13:24 +0200)]
Store descriptor set in program reflection data

2 years agoHandle descriptor sets when allocating uniform locations
Mikko Rasa [Thu, 11 Nov 2021 10:56:28 +0000 (12:56 +0200)]
Handle descriptor sets when allocating uniform locations

2 years agoPropagate locations from existing variables before optimization
Mikko Rasa [Thu, 11 Nov 2021 10:49:08 +0000 (12:49 +0200)]
Propagate locations from existing variables before optimization

Uniform location and binding qualifiers should apply to all copies of the
variable even if the one originally containing them is optimized out.

2 years agoImprove layout qualifier handling with some more utility functions
Mikko Rasa [Thu, 11 Nov 2021 10:00:07 +0000 (12:00 +0200)]
Improve layout qualifier handling with some more utility functions

2 years agoAdd a utility function for following a chain of base types
Mikko Rasa [Wed, 10 Nov 2021 23:31:47 +0000 (01:31 +0200)]
Add a utility function for following a chain of base types

2 years agoRefactor a common part in LocationAllocator into a function
Mikko Rasa [Wed, 10 Nov 2021 22:59:22 +0000 (00:59 +0200)]
Refactor a common part in LocationAllocator into a function

2 years agoAssign the same specialization constant IDs in all stages
Mikko Rasa [Wed, 10 Nov 2021 22:35:45 +0000 (00:35 +0200)]
Assign the same specialization constant IDs in all stages

2 years agoEmit descriptor set decorations for interface blocks
Mikko Rasa [Wed, 10 Nov 2021 20:09:38 +0000 (22:09 +0200)]
Emit descriptor set decorations for interface blocks

2 years agoAdd basic Vulkan support to the shader compiler
Mikko Rasa [Wed, 10 Nov 2021 20:09:17 +0000 (22:09 +0200)]
Add basic Vulkan support to the shader compiler

2 years agoAdd a constant for Vulkan backend
Mikko Rasa [Wed, 10 Nov 2021 20:01:47 +0000 (22:01 +0200)]
Add a constant for Vulkan backend

2 years agoAccount for mipmap levels when computing texture data sizes
Mikko Rasa [Wed, 10 Nov 2021 18:31:17 +0000 (20:31 +0200)]
Account for mipmap levels when computing texture data sizes

This isn't 100% accurate, but good enough for resource management.

2 years agoPerform range checks in UniformBlock in debug builds
Mikko Rasa [Wed, 10 Nov 2021 18:10:18 +0000 (20:10 +0200)]
Perform range checks in UniformBlock in debug builds

2 years agoMove the Resource function override of Texture classes into backend
Mikko Rasa [Wed, 10 Nov 2021 18:08:34 +0000 (20:08 +0200)]
Move the Resource function override of Texture classes into backend

There's enough differences between APIs that these can't be sensibly kept
in the common classes.

2 years agoMove WindowView::render to the backend
Mikko Rasa [Wed, 10 Nov 2021 14:16:18 +0000 (16:16 +0200)]
Move WindowView::render to the backend

Presenting images work very differently in Vulkan so the swap_buffers
call can't be in the common part.

2 years agoRemove the LINE_LOOP primitive type
Mikko Rasa [Wed, 10 Nov 2021 14:13:09 +0000 (16:13 +0200)]
Remove the LINE_LOOP primitive type

It's not supported on Vulkan and can be replaced by LINE_STRIP by adding
one extra index at the end.

2 years agoMinor tweaks
Mikko Rasa [Wed, 10 Nov 2021 14:12:42 +0000 (16:12 +0200)]
Minor tweaks

2 years agoRemove some stray includes and add a missing one
Mikko Rasa [Wed, 10 Nov 2021 14:12:05 +0000 (16:12 +0200)]
Remove some stray includes and add a missing one

2 years agoEnsure that creating the system framebuffer doesn't change the binding
Mikko Rasa [Tue, 9 Nov 2021 23:52:27 +0000 (01:52 +0200)]
Ensure that creating the system framebuffer doesn't change the binding

Just in case it's for some reason created at an odd time.

2 years agoRestructure system framebuffer and make WindowView own it
Mikko Rasa [Tue, 9 Nov 2021 23:50:19 +0000 (01:50 +0200)]
Restructure system framebuffer and make WindowView own it

This works very differently on Vulkan, so the system framebuffer can't
be exposed from the Framebuffer class.

2 years agoCheck for empty attachments array instead of zero id in Framebuffer
Mikko Rasa [Tue, 9 Nov 2021 23:43:06 +0000 (01:43 +0200)]
Check for empty attachments array instead of zero id in Framebuffer

The id is an OpenGL implementation detail and shouldn't be used in the
common part.

2 years agoDon't store a View's target framebuffer in the base class
Mikko Rasa [Tue, 9 Nov 2021 12:53:34 +0000 (14:53 +0200)]
Don't store a View's target framebuffer in the base class

Instead access it through a virtual function.  Vulkan requires a separate
framebuffer per swapchain image.

2 years agoMove backend information into Device
Mikko Rasa [Tue, 9 Nov 2021 12:07:01 +0000 (14:07 +0200)]
Move backend information into Device

2 years agoRemove obsolete includes
Mikko Rasa [Tue, 9 Nov 2021 11:18:17 +0000 (13:18 +0200)]
Remove obsolete includes

2 years agoCreate a Device class to hold the graphics context
Mikko Rasa [Tue, 9 Nov 2021 10:37:15 +0000 (12:37 +0200)]
Create a Device class to hold the graphics context

This is necessary to make the selected backend transparent to
applications, and also because Vulkan needs access to the VkDevice.

2 years agoAlways apply feature conversion in the GLSL compiler
Mikko Rasa [Mon, 8 Nov 2021 21:10:34 +0000 (23:10 +0200)]
Always apply feature conversion in the GLSL compiler

Also convert structural features before allocating locations.  This
gives flattened push constant uniforms locations too.

2 years agoUse specially created features when compiling modules from GLSL
Mikko Rasa [Mon, 8 Nov 2021 20:18:38 +0000 (22:18 +0200)]
Use specially created features when compiling modules from GLSL

Set the latest version so all language features are retained, but limit
bindings to what the implementation actually supports.

2 years agoRequire passing features to SL::Compiler constructor
Mikko Rasa [Mon, 8 Nov 2021 19:50:00 +0000 (21:50 +0200)]
Require passing features to SL::Compiler constructor

Using the current context's features by default seems like it could lead
to some surprises down the road.

2 years agoMake the SL::Features factory functions more flexible
Mikko Rasa [Mon, 8 Nov 2021 19:19:15 +0000 (21:19 +0200)]
Make the SL::Features factory functions more flexible

Passing the backend API as an argument is much better than having
separate functions for each backend.

2 years agoSplit FeatureConverter into two parts
Mikko Rasa [Mon, 8 Nov 2021 17:56:45 +0000 (19:56 +0200)]
Split FeatureConverter into two parts

2 years agoRename LegacyConverter to FeatureConverter
Mikko Rasa [Mon, 8 Nov 2021 17:21:41 +0000 (19:21 +0200)]
Rename LegacyConverter to FeatureConverter

2 years agoStore object transform in a push constant block
Mikko Rasa [Mon, 8 Nov 2021 16:19:12 +0000 (18:19 +0200)]
Store object transform in a push constant block

2 years agoAllow a push constant block to be specified, but flatten it for now
Mikko Rasa [Mon, 8 Nov 2021 16:17:51 +0000 (18:17 +0200)]
Allow a push constant block to be specified, but flatten it for now

It's needed for Vulkan, but OpenGL does not have push constants.

2 years agoFix flattening of GLSL interface blocks
Mikko Rasa [Mon, 8 Nov 2021 16:15:39 +0000 (18:15 +0200)]
Fix flattening of GLSL interface blocks

Anonymous interface blocks are treated as nameless variables since
dfcf8eb, so the member accesses need to be converted to plain variable
references when the block is flattened.

2 years agoCopy layout of InterfaceBlock
Mikko Rasa [Mon, 8 Nov 2021 13:49:29 +0000 (15:49 +0200)]
Copy layout of InterfaceBlock

2 years agoTweak eye position calculation in shaders
Mikko Rasa [Mon, 8 Nov 2021 13:31:07 +0000 (15:31 +0200)]
Tweak eye position calculation in shaders

2 years agoActually call the collect_builtins function in Program
Mikko Rasa [Mon, 8 Nov 2021 13:28:43 +0000 (15:28 +0200)]
Actually call the collect_builtins function in Program

This was forgotten from f82ef71.

2 years agoWrite access can't get into an unary operator from outside
Mikko Rasa [Mon, 8 Nov 2021 13:27:43 +0000 (15:27 +0200)]
Write access can't get into an unary operator from outside

2 years agoCache texture bindings when the shader program does not change
Mikko Rasa [Mon, 8 Nov 2021 13:23:54 +0000 (15:23 +0200)]
Cache texture bindings when the shader program does not change

2 years agoRestore variable load IDs for the else branch of a conditional
Mikko Rasa [Mon, 8 Nov 2021 13:23:23 +0000 (15:23 +0200)]
Restore variable load IDs for the else branch of a conditional

2 years agoIsolate expressions from surrounding composite access
Mikko Rasa [Mon, 8 Nov 2021 13:23:02 +0000 (15:23 +0200)]
Isolate expressions from surrounding composite access

2 years agoRecognize increment/decrement operators as modifying the target variable
Mikko Rasa [Mon, 8 Nov 2021 13:21:18 +0000 (15:21 +0200)]
Recognize increment/decrement operators as modifying the target variable

2 years agoBlock further inlining of a variable after component assignment
Mikko Rasa [Mon, 8 Nov 2021 00:09:11 +0000 (02:09 +0200)]
Block further inlining of a variable after component assignment

2 years agoRefactor assignment target overlap check into a function
Mikko Rasa [Mon, 8 Nov 2021 00:03:54 +0000 (02:03 +0200)]
Refactor assignment target overlap check into a function

2 years agoProcess loop initialization outside the body in UnusedVariableRemover
Mikko Rasa [Mon, 8 Nov 2021 00:01:26 +0000 (02:01 +0200)]
Process loop initialization outside the body in UnusedVariableRemover

If it's processed inside the scope of the loop, assignments to the
iteration variable may get discarded.

2 years agoMark the start of a SPIR-V function as reachable
Mikko Rasa [Sun, 7 Nov 2021 17:17:09 +0000 (19:17 +0200)]
Mark the start of a SPIR-V function as reachable

This fixes erroneously generated OpUnreachable instructions which
appeared at the end of some functions.

2 years agoCompute correct size for SPIR-V structs if the last member is an array
Mikko Rasa [Sun, 7 Nov 2021 17:15:14 +0000 (19:15 +0200)]
Compute correct size for SPIR-V structs if the last member is an array

2 years agoRemove support for array size specialization from the engine as well
Mikko Rasa [Sun, 7 Nov 2021 17:14:36 +0000 (19:14 +0200)]
Remove support for array size specialization from the engine as well

2 years agoAlways set uniform array size to at least one
Mikko Rasa [Sun, 7 Nov 2021 17:12:14 +0000 (19:12 +0200)]
Always set uniform array size to at least one

This makes it consistent between GLSL and SPIR-V.

2 years agoMove default uniform block sizing to OpenGL backend
Mikko Rasa [Sun, 7 Nov 2021 17:11:59 +0000 (19:11 +0200)]
Move default uniform block sizing to OpenGL backend

2 years agoBuild the list of glUniform* calls even for SPIR-V modules
Mikko Rasa [Sun, 7 Nov 2021 17:09:42 +0000 (19:09 +0200)]
Build the list of glUniform* calls even for SPIR-V modules

This is relevant since SPIR-V supports default block uniforms when
targeting OpenGL.

2 years agoRearrange shader reflection calls
Mikko Rasa [Sun, 7 Nov 2021 17:07:34 +0000 (19:07 +0200)]
Rearrange shader reflection calls

The OpenGL-specific query calls are now done from the OpenGL backend.

2 years agoFix reflection of vector and matrix types from SPIR-V
Mikko Rasa [Sun, 7 Nov 2021 16:56:07 +0000 (18:56 +0200)]
Fix reflection of vector and matrix types from SPIR-V

2 years agoFix GLSL matrix construction from individual elements
Mikko Rasa [Sun, 7 Nov 2021 14:12:11 +0000 (16:12 +0200)]
Fix GLSL matrix construction from individual elements

2 years agoGenerate correct OpPhi instructions for nested ternary expressions
Mikko Rasa [Sun, 7 Nov 2021 14:06:09 +0000 (16:06 +0200)]
Generate correct OpPhi instructions for nested ternary expressions

The parent blocks must be immediate predecessors of the block containing
the OpPhi instruction.

2 years agoDon't try to access parameters with a pointer access instructior
Mikko Rasa [Sun, 7 Nov 2021 14:01:06 +0000 (16:01 +0200)]
Don't try to access parameters with a pointer access instructior

2 years agoPadding is required at the end of certain SPIR-V struct members
Mikko Rasa [Sun, 7 Nov 2021 13:59:13 +0000 (15:59 +0200)]
Padding is required at the end of certain SPIR-V struct members

If the member is is itself a struct or an array, the next member must not
begin before the next alignment boundary.

2 years agoChange max_lights to a fixed constant
Mikko Rasa [Sun, 7 Nov 2021 12:38:49 +0000 (14:38 +0200)]
Change max_lights to a fixed constant

2 years agoDisallow specialization constants in certain contexts
Mikko Rasa [Sun, 7 Nov 2021 12:32:33 +0000 (14:32 +0200)]
Disallow specialization constants in certain contexts

The initialization of a specialization constant must not use other
specialization constants.

Arrays sized by a specialization constant inside structures are broken
by design because member offsets in SPIR-V are required to be literals.
Changing the size through specialization would at best leave empty space
in the struct and at worst overlap other members.

2 years agoFix size calculation for GLSL arrays
Mikko Rasa [Sun, 7 Nov 2021 12:31:38 +0000 (14:31 +0200)]
Fix size calculation for GLSL arrays