libs/gl.git
6 weeks agoDon't remove individual mipmap levels from Synchronizer master
Mikko Rasa [Thu, 9 Dec 2021 13:23:21 +0000 (15:23 +0200)]
Don't remove individual mipmap levels from Synchronizer

Keep them around until all levels have been transitioned to shader read
only optimal, to ensure that changing the layout of a split image as a
whole works correctly.

6 weeks agoTrack different kinds of bindings separately
Mikko Rasa [Thu, 9 Dec 2021 11:43:16 +0000 (13:43 +0200)]
Track different kinds of bindings separately

6 weeks agoPopulate used bindings in ReflectData
Mikko Rasa [Thu, 9 Dec 2021 10:23:04 +0000 (12:23 +0200)]
Populate used bindings in ReflectData

6 weeks agoDon't try to bind descriptor sets if there aren't any
Mikko Rasa [Thu, 9 Dec 2021 10:02:41 +0000 (12:02 +0200)]
Don't try to bind descriptor sets if there aren't any

6 weeks agoRefresh vertex setup in VulkanPipelineState::update
Mikko Rasa [Thu, 9 Dec 2021 09:50:42 +0000 (11:50 +0200)]
Refresh vertex setup in VulkanPipelineState::update

The buffers and offsets must be filled even if another vertex setup with
the same format has been used before.

6 weeks agoInitialize members of VulkanVertexSetup
Mikko Rasa [Thu, 9 Dec 2021 09:48:25 +0000 (11:48 +0200)]
Initialize members of VulkanVertexSetup

7 weeks agoUse an RGBA environment map in desertpillars
Mikko Rasa [Sun, 5 Dec 2021 08:53:38 +0000 (10:53 +0200)]
Use an RGBA environment map in desertpillars

7 weeks agoStore the number of mipmap levels in the Texture base class
Mikko Rasa [Sat, 4 Dec 2021 00:25:14 +0000 (02:25 +0200)]
Store the number of mipmap levels in the Texture base class

7 weeks agoUse default member initializers in Texture
Mikko Rasa [Sat, 4 Dec 2021 00:22:39 +0000 (02:22 +0200)]
Use default member initializers in Texture

7 weeks agoAvoid collisions with members of nameless interface blocks when inlining
Mikko Rasa [Sat, 4 Dec 2021 00:12:14 +0000 (02:12 +0200)]
Avoid collisions with members of nameless interface blocks when inlining

8 weeks agoUse RGBA as the default format for effect render targets
Mikko Rasa [Wed, 1 Dec 2021 08:55:04 +0000 (10:55 +0200)]
Use RGBA as the default format for effect render targets

8 weeks agoConvert RGB pixel data to RGBA when staging
Mikko Rasa [Wed, 1 Dec 2021 08:54:07 +0000 (10:54 +0200)]
Convert RGB pixel data to RGBA when staging

8 weeks agoUse the correct aspect mask for uploading texture data
Mikko Rasa [Wed, 1 Dec 2021 08:52:10 +0000 (10:52 +0200)]
Use the correct aspect mask for uploading texture data

8 weeks agoSubmit commands for isolated offscreen rendering
Mikko Rasa [Wed, 1 Dec 2021 08:35:23 +0000 (10:35 +0200)]
Submit commands for isolated offscreen rendering

8 weeks agoClear the begin semaphore if Renderer::begin() is called without one
Mikko Rasa [Wed, 1 Dec 2021 08:34:54 +0000 (10:34 +0200)]
Clear the begin semaphore if Renderer::begin() is called without one

8 weeks agoRemove the exception from Texture2DMultisample constructor
Mikko Rasa [Wed, 1 Dec 2021 08:32:13 +0000 (10:32 +0200)]
Remove the exception from Texture2DMultisample constructor

8 weeks agoImplement mipmap generation for the Vulkan backend
Mikko Rasa [Wed, 1 Dec 2021 08:31:43 +0000 (10:31 +0200)]
Implement mipmap generation for the Vulkan backend

8 weeks agoSupport transfers with no staged data
Mikko Rasa [Wed, 1 Dec 2021 07:53:10 +0000 (09:53 +0200)]
Support transfers with no staged data

This can be used to transfer data within VRAM, such as for mipmap
generation.

8 weeks agoTrack the order of transfers involving the same objects
Mikko Rasa [Wed, 1 Dec 2021 07:45:38 +0000 (09:45 +0200)]
Track the order of transfers involving the same objects

Mipmap generation requires barriers between the steps, since each level
is generated using the previous one.

8 weeks agoUse another callback for pre-transfer synchronization
Mikko Rasa [Tue, 30 Nov 2021 22:17:53 +0000 (00:17 +0200)]
Use another callback for pre-transfer synchronization

8 weeks agoTweaks and fixes to OpNames in SPIR-V
Mikko Rasa [Tue, 30 Nov 2021 21:46:59 +0000 (23:46 +0200)]
Tweaks and fixes to OpNames in SPIR-V

Interface blocks without an instance name must not have a non-empty
OpName or the reflection code gets confused.

8 weeks agoRefactor Synchronizer to deal with individual mipmap levels
Mikko Rasa [Tue, 30 Nov 2021 21:30:27 +0000 (23:30 +0200)]
Refactor Synchronizer to deal with individual mipmap levels

Some algorithms read from one mipmap level and write to another.  On the
other hand, there's currently no need for layer granularity.

8 weeks agoDon't create no-op barriers
Mikko Rasa [Tue, 30 Nov 2021 21:24:04 +0000 (23:24 +0200)]
Don't create no-op barriers

8 weeks agoApply implicit conversions to function arguments
Mikko Rasa [Sun, 28 Nov 2021 23:02:54 +0000 (01:02 +0200)]
Apply implicit conversions to function arguments

8 weeks agoAutomatically determine array sizes in GLSL if possible
Mikko Rasa [Sun, 28 Nov 2021 23:01:01 +0000 (01:01 +0200)]
Automatically determine array sizes in GLSL if possible

Consequently the SPIR-V backend no longer needs to deal with missing
array sizes.

8 weeks agoVulkan doesn't support uniform locations
Mikko Rasa [Sat, 27 Nov 2021 20:17:17 +0000 (22:17 +0200)]
Vulkan doesn't support uniform locations

8 weeks agoUnify handling of variables and interface blocks in the GLSL compiler
Mikko Rasa [Sat, 27 Nov 2021 19:25:03 +0000 (21:25 +0200)]
Unify handling of variables and interface blocks in the GLSL compiler

In SPIR-V interface blocks are just variables with a struct type marked
as block.  Treating them this way in the AST reduces duplcation a fair
bit.

8 weeks agoFixes for handling extended alignment in GLSL
Mikko Rasa [Sat, 27 Nov 2021 18:00:27 +0000 (20:00 +0200)]
Fixes for handling extended alignment in GLSL

8 weeks agoUse correct variable to access values
Mikko Rasa [Sat, 27 Nov 2021 10:58:18 +0000 (12:58 +0200)]
Use correct variable to access values

8 weeks agoConsider arrays to have matching size if both are unsized
Mikko Rasa [Sat, 27 Nov 2021 10:19:53 +0000 (12:19 +0200)]
Consider arrays to have matching size if both are unsized

8 weeks agoRefactor adding types in SL::Parser
Mikko Rasa [Sat, 27 Nov 2021 00:49:14 +0000 (02:49 +0200)]
Refactor adding types in SL::Parser

2 months agoFix a GLSL testcase
Mikko Rasa [Wed, 24 Nov 2021 22:22:08 +0000 (00:22 +0200)]
Fix a GLSL testcase

The constant IDs got perturbed in 8c379c40.

2 months agoAdd missing includes
Mikko Rasa [Wed, 24 Nov 2021 22:21:19 +0000 (00:21 +0200)]
Add missing includes

2 months agoReuse previously allocated command buffers
Mikko Rasa [Mon, 22 Nov 2021 11:34:00 +0000 (13:34 +0200)]
Reuse previously allocated command buffers

2 months agoSet push constants only for enabled shader stages
Mikko Rasa [Mon, 22 Nov 2021 11:33:14 +0000 (13:33 +0200)]
Set push constants only for enabled shader stages

2 months agoImplement textures and samplers for Vulkan
Mikko Rasa [Sun, 21 Nov 2021 23:41:45 +0000 (01:41 +0200)]
Implement textures and samplers for Vulkan

Currently render target textures get a useless layout transition to
SHADER_READ_ONLY_OPTIMAL if there's any transfers on the same frame.

Mipmap generation and asynchronous uploading of textures does not work
yet.

2 months agoMove PipelineState refresh to just before draw call
Mikko Rasa [Sun, 21 Nov 2021 23:29:09 +0000 (01:29 +0200)]
Move PipelineState refresh to just before draw call

Shouldn't matter much, but it makes more sense here

2 months agoAlways apply push constants
Mikko Rasa [Sun, 21 Nov 2021 23:23:13 +0000 (01:23 +0200)]
Always apply push constants

The changed flag is no longer valid at this point.  This could in theory
result in unnecessary CmdPushConstants calls, but in practice they change
for every draw call (if they're used in the first place).

2 months agoTrack the in-use state of resource bindings in PipelineState
Mikko Rasa [Sun, 21 Nov 2021 13:26:22 +0000 (15:26 +0200)]
Track the in-use state of resource bindings in PipelineState

2 months agoUpdate all descriptor sets when the used shader changes
Mikko Rasa [Sun, 21 Nov 2021 12:59:38 +0000 (14:59 +0200)]
Update all descriptor sets when the used shader changes

2 months agoSet color write mask if no blending is used
Mikko Rasa [Sun, 21 Nov 2021 12:57:45 +0000 (14:57 +0200)]
Set color write mask if no blending is used

2 months agoAdd a subpass dependency to ensure the rendering result is available
Mikko Rasa [Sun, 21 Nov 2021 12:52:38 +0000 (14:52 +0200)]
Add a subpass dependency to ensure the rendering result is available

2 months agoOnly do layout transitions in render pass for swapchain images
Mikko Rasa [Sun, 21 Nov 2021 12:41:29 +0000 (14:41 +0200)]
Only do layout transitions in render pass for swapchain images

Transitions for other images will be handles through Synchronizer.

2 months agoMake framebuffer attachment accessors public
Mikko Rasa [Sun, 21 Nov 2021 10:10:11 +0000 (12:10 +0200)]
Make framebuffer attachment accessors public

2 months agoAdd a synchronization helper class to the Vulkan backend
Mikko Rasa [Sun, 21 Nov 2021 10:09:40 +0000 (12:09 +0200)]
Add a synchronization helper class to the Vulkan backend

2 months agoUse PRESENT_SRC as the initial layout for swapchain images
Mikko Rasa [Sat, 20 Nov 2021 22:42:26 +0000 (00:42 +0200)]
Use PRESENT_SRC as the initial layout for swapchain images

This makes the layout transition work if for some reason a clear command
is not used for the swapchain.

2 months agoConvert some constructors to default member initializers
Mikko Rasa [Sat, 20 Nov 2021 22:11:26 +0000 (00:11 +0200)]
Convert some constructors to default member initializers

2 months agoUse RGBA format render target for Bloom
Mikko Rasa [Sat, 20 Nov 2021 22:06:59 +0000 (00:06 +0200)]
Use RGBA format render target for Bloom

2 months agoDon't generate warnings about internal types with duplicate names
Mikko Rasa [Sat, 20 Nov 2021 22:06:00 +0000 (00:06 +0200)]
Don't generate warnings about internal types with duplicate names

2 months agoUse extended alignment in SPIR-V struct layout when necessary
Mikko Rasa [Sat, 20 Nov 2021 21:59:16 +0000 (23:59 +0200)]
Use extended alignment in SPIR-V struct layout when necessary

2 months agoDo discard-clears in individual postprocessors, not the sequence
Mikko Rasa [Sat, 20 Nov 2021 21:43:33 +0000 (23:43 +0200)]
Do discard-clears in individual postprocessors, not the sequence

It should be done just before rendering into the target starts.

2 months agoCache framebuffer and viewport in VulkanCommands
Mikko Rasa [Fri, 19 Nov 2021 22:42:00 +0000 (00:42 +0200)]
Cache framebuffer and viewport in VulkanCommands

Since PipelineState is not immutable, this is necessary to detect when
they have changed.

2 months agoCheck if render target is swapchain and set to_present accordingly
Mikko Rasa [Fri, 19 Nov 2021 22:39:53 +0000 (00:39 +0200)]
Check if render target is swapchain and set to_present accordingly

2 months agoTreat clear() with null parameter as invalidate
Mikko Rasa [Fri, 19 Nov 2021 22:36:52 +0000 (00:36 +0200)]
Treat clear() with null parameter as invalidate

Also use it in Sequence for postprocessor render targets, since
postprocessors are supposed to render the entire screen.

2 months agoCreate specialized copies of SPIR-V modules
Mikko Rasa [Fri, 19 Nov 2021 19:00:52 +0000 (21:00 +0200)]
Create specialized copies of SPIR-V modules

It turns out Vulkan does want all declared resources in the descriptor
sets, even if they're unused.  Manual specialization avoids the need to
deal with them when binding stuff.

2 months agoInitial implementation of Vulkan backend
Mikko Rasa [Thu, 18 Nov 2021 15:13:13 +0000 (17:13 +0200)]
Initial implementation of Vulkan backend

Some functionalities are still missing, in particular textures and
samplers.  Drawing simple geometry works.

2 months agoAdd checks for invalid state in OpenGLCommands
Mikko Rasa [Thu, 18 Nov 2021 10:48:08 +0000 (12:48 +0200)]
Add checks for invalid state in OpenGLCommands

2 months agoRefactor low-level state management
Mikko Rasa [Thu, 18 Nov 2021 10:09:57 +0000 (12:09 +0200)]
Refactor low-level state management

The global context state is now held in Device.

The changes mask in PipelineState was also moved to the backend class,
because pipeline state is applied very differently in Vulkan.

2 months agoColorize the debug output of the GLSL compiler
Mikko Rasa [Wed, 17 Nov 2021 20:27:08 +0000 (22:27 +0200)]
Colorize the debug output of the GLSL compiler

2 months agoStore primitive type in PipelineState
Mikko Rasa [Wed, 17 Nov 2021 19:51:26 +0000 (21:51 +0200)]
Store primitive type in PipelineState

Vulkan needs it to be here

2 months agoCreate default context options in the device backend
Mikko Rasa [Wed, 17 Nov 2021 19:31:30 +0000 (21:31 +0200)]
Create default context options in the device backend

2 months agoUse emplace_back when a new object is being constructed
Mikko Rasa [Wed, 17 Nov 2021 15:12:19 +0000 (17:12 +0200)]
Use emplace_back when a new object is being constructed

2 months agoDon't try to apply push constants as uniforms in OpenGL
Mikko Rasa [Wed, 17 Nov 2021 14:56:50 +0000 (16:56 +0200)]
Don't try to apply push constants as uniforms in OpenGL

They shouldn't exist anyway.

2 months agoAdjust access to main class members from backend classes
Mikko Rasa [Wed, 17 Nov 2021 14:49:52 +0000 (16:49 +0200)]
Adjust access to main class members from backend classes

2 months agoRename some stencil test constants
Mikko Rasa [Wed, 17 Nov 2021 13:49:00 +0000 (15:49 +0200)]
Rename some stencil test constants

This makes it more apparent what the difference between these and the
_WRAP variants is.

2 months agoDon't assume vertex arrays start from the beginning of the buffer
Mikko Rasa [Wed, 17 Nov 2021 13:47:32 +0000 (15:47 +0200)]
Don't assume vertex arrays start from the beginning of the buffer

2 months agoHide the use of the tangent variable in common.glsl behind an if
Mikko Rasa [Wed, 17 Nov 2021 13:46:19 +0000 (15:46 +0200)]
Hide the use of the tangent variable in common.glsl behind an if

2 months agoAdjust attribute order in mesh exporter and add padding if necessary
Mikko Rasa [Wed, 17 Nov 2021 13:45:25 +0000 (15:45 +0200)]
Adjust attribute order in mesh exporter and add padding if necessary

2 months 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 months 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 months 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 months agoComment fixes
Mikko Rasa [Wed, 17 Nov 2021 13:34:21 +0000 (15:34 +0200)]
Comment fixes

2 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months agoAdd missing destructor to OpenGLSampler
Mikko Rasa [Sat, 13 Nov 2021 14:14:23 +0000 (16:14 +0200)]
Add missing destructor to OpenGLSampler

2 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months agoRemove deprecated functions from Renderer
Mikko Rasa [Fri, 12 Nov 2021 16:52:44 +0000 (18:52 +0200)]
Remove deprecated functions from Renderer