libs/gl.git
10 months agoAllow creating sequences without size
Mikko Rasa [Fri, 24 Sep 2021 22:38:59 +0000 (01:38 +0300)]
Allow creating sequences without size

Also require a frame format when a size is specified.  Sequences used as
content renderables of effects commonly have no postprocessors, in which
case internal render targets are not needed either and the size is not
meaningful.

10 months agoRemove the View and Framebuffer constructors from Sequence
Mikko Rasa [Fri, 24 Sep 2021 21:41:51 +0000 (00:41 +0300)]
Remove the View and Framebuffer constructors from Sequence

They had no other purpose than to take the size from the other object,
and that fits better in SequenceBuilder.

10 months agoQuery the attachments of the default framebuffer
Mikko Rasa [Sun, 19 Sep 2021 11:04:02 +0000 (14:04 +0300)]
Query the attachments of the default framebuffer

The exact pixel formats are unimportant for now and would be somewhat
convoluted to query.

10 months agoCheck supported attachment formats in Framebuffer::set_format
Mikko Rasa [Sun, 19 Sep 2021 10:37:13 +0000 (13:37 +0300)]
Check supported attachment formats in Framebuffer::set_format

10 months agoRemove the FramebufferStatus enum
Mikko Rasa [Sun, 19 Sep 2021 10:36:23 +0000 (13:36 +0300)]
Remove the FramebufferStatus enum

It's not easily supportable on Vulkan.

10 months agoInitialize Texture's format to an invalid value
Mikko Rasa [Sun, 19 Sep 2021 10:33:18 +0000 (13:33 +0300)]
Initialize Texture's format to an invalid value

This makes it possible to determine if a texture has storage defined or
not.

10 months agoUse friend declarations to access OpenGL IDs of objects
Mikko Rasa [Sat, 18 Sep 2021 12:57:24 +0000 (15:57 +0300)]
Use friend declarations to access OpenGL IDs of objects

This seems neater than exposing get_id() methods to the public.

Texture2D::AsyncLoader still uses get_id() on the PBO for now, since
it's not reasonably possible to name that class as a friend.

10 months agoAdd missing Require to Commands::resolve_multisample
Mikko Rasa [Sat, 18 Sep 2021 12:54:11 +0000 (15:54 +0300)]
Add missing Require to Commands::resolve_multisample

10 months agoMake the sampler-related enums independent of OpenGL constants
Mikko Rasa [Sat, 18 Sep 2021 12:40:30 +0000 (15:40 +0300)]
Make the sampler-related enums independent of OpenGL constants

10 months agoMake the TextureCubeFace enum independent of OpenGL constants
Mikko Rasa [Sat, 18 Sep 2021 12:21:09 +0000 (15:21 +0300)]
Make the TextureCubeFace enum independent of OpenGL constants

10 months agoMark constant data as const
Mikko Rasa [Sat, 18 Sep 2021 12:15:32 +0000 (15:15 +0300)]
Mark constant data as const

10 months agoOnly enable seamless cube map once
Mikko Rasa [Sat, 18 Sep 2021 11:54:48 +0000 (14:54 +0300)]
Only enable seamless cube map once

10 months agoRemove the separate allocation step from textures and buffers
Mikko Rasa [Sat, 18 Sep 2021 09:56:18 +0000 (12:56 +0300)]
Remove the separate allocation step from textures and buffers

It was conceived as a way to avoid unnecessary OpenGL calls if the object
is initialized by uploading full contents.  However the storage extensions
are almost universally supported now and data uploads are not something
that usually happens every frame, so this optimization is no longer
relevant.

10 months agoRemove remaining deprecated things from the core classes
Mikko Rasa [Sat, 18 Sep 2021 09:07:54 +0000 (12:07 +0300)]
Remove remaining deprecated things from the core classes

10 months agoRemove unnecessary std:: qualifiers
Mikko Rasa [Sat, 18 Sep 2021 00:30:23 +0000 (03:30 +0300)]
Remove unnecessary std:: qualifiers

10 months agoSpecify underlying type for format descriptor enums
Mikko Rasa [Fri, 17 Sep 2021 23:56:23 +0000 (02:56 +0300)]
Specify underlying type for format descriptor enums

This makes it possible to use them directory in the associated format
structs without increasing their size.

10 months agoUse standard fixed-size integer types
Mikko Rasa [Fri, 17 Sep 2021 23:31:16 +0000 (02:31 +0300)]
Use standard fixed-size integer types

10 months agoFix an apparent logic bug in ProgramData
Mikko Rasa [Fri, 17 Sep 2021 23:18:53 +0000 (02:18 +0300)]
Fix an apparent logic bug in ProgramData

Deleting the blocks but leaving the pointers seems like a recipe for
disaster.  This hails from all the way back in 5ae4b00.

10 months agoImprove exceptions in armature lookups
Mikko Rasa [Fri, 17 Sep 2021 23:12:48 +0000 (02:12 +0300)]
Improve exceptions in armature lookups

10 months agoPrefer more compact containers
Mikko Rasa [Fri, 17 Sep 2021 23:09:33 +0000 (02:09 +0300)]
Prefer more compact containers

10 months agoUse C++11 features with containers
Mikko Rasa [Fri, 17 Sep 2021 22:57:58 +0000 (01:57 +0300)]
Use C++11 features with containers

10 months agoRequire C++11 for building
Mikko Rasa [Fri, 17 Sep 2021 21:59:20 +0000 (00:59 +0300)]
Require C++11 for building

10 months agoChange ManagedResource::load_priority to int
Mikko Rasa [Fri, 17 Sep 2021 17:31:48 +0000 (20:31 +0300)]
Change ManagedResource::load_priority to int

For unknown reasons it was made bool in 574abfb even though
Resource::get_load_priority returns an int.

10 months agoRemove automatic mipmap generation from the public interface of Texture
Mikko Rasa [Thu, 16 Sep 2021 22:00:07 +0000 (01:00 +0300)]
Remove automatic mipmap generation from the public interface of Texture

The flag is now only used in conjunction of textures loaded from
datafiles.  Mipmap generation can still be manually triggered.

This causes some lossage with the allocation flags if the texture storage
extension is not supported.  I'll likely refactor the allocation system
soon.

10 months agoUse a scratch binding to modify textures and buffers
Mikko Rasa [Thu, 16 Sep 2021 18:52:22 +0000 (21:52 +0300)]
Use a scratch binding to modify textures and buffers

This simplifies the code quite a bit.  It's assumed that textures are
not modified during rendering, as that would potentially interfere with
the rendering pipeline state.

10 months agoRemove some obsolete things
Mikko Rasa [Thu, 16 Sep 2021 16:14:06 +0000 (19:14 +0300)]
Remove some obsolete things

10 months agoChange the vertex group attribute to be an integer vector
Mikko Rasa [Wed, 15 Sep 2021 18:52:13 +0000 (21:52 +0300)]
Change the vertex group attribute to be an integer vector

10 months agoAdd support for integer vertex attributes
Mikko Rasa [Wed, 15 Sep 2021 18:51:59 +0000 (21:51 +0300)]
Add support for integer vertex attributes

10 months agoNudge the FrameFormat floating-point flag one bit to the left
Mikko Rasa [Wed, 15 Sep 2021 17:17:38 +0000 (20:17 +0300)]
Nudge the FrameFormat floating-point flag one bit to the left

This puts it in the same position as the corresponding flag in
VertexAttribute.

10 months agoRe-export desert pillars data with attribute types
Mikko Rasa [Wed, 15 Sep 2021 17:16:57 +0000 (20:16 +0300)]
Re-export desert pillars data with attribute types

10 months agoUse more compact data types when exporting meshes
Mikko Rasa [Wed, 15 Sep 2021 14:58:23 +0000 (17:58 +0300)]
Use more compact data types when exporting meshes

10 months agoMake VertexFormat capable of storing type information
Mikko Rasa [Wed, 15 Sep 2021 11:11:54 +0000 (14:11 +0300)]
Make VertexFormat capable of storing type information

10 months agoRemove deprecated things related to vertex formats and arrays
Mikko Rasa [Wed, 15 Sep 2021 10:55:08 +0000 (13:55 +0300)]
Remove deprecated things related to vertex formats and arrays

10 months agoExplicitly specify the target format of Sequence
Mikko Rasa [Tue, 14 Sep 2021 22:24:36 +0000 (01:24 +0300)]
Explicitly specify the target format of Sequence

10 months agoFix a logic error in Sequence
Mikko Rasa [Tue, 14 Sep 2021 21:22:59 +0000 (00:22 +0300)]
Fix a logic error in Sequence

This condition accidentally got flipped in 3ac3a51.

10 months agoFix valgrind warnings
Mikko Rasa [Tue, 14 Sep 2021 21:14:34 +0000 (00:14 +0300)]
Fix valgrind warnings

10 months agoRemove obsolete stuff from Sequence
Mikko Rasa [Tue, 14 Sep 2021 21:00:31 +0000 (00:00 +0300)]
Remove obsolete stuff from Sequence

10 months agoSimplify pipeline state management
Mikko Rasa [Mon, 13 Sep 2021 21:17:12 +0000 (00:17 +0300)]
Simplify pipeline state management

Instead of unbinding things immediately, defer it to when the state is
cleared.  This results in less binding calls overall.  The only reason
to unbind anything is to allow those objects to be destroyed, and that
shouldn't happen in the middle of rendering anyway.

10 months agoRemove deprecated constructors from effects
Mikko Rasa [Mon, 13 Sep 2021 17:13:36 +0000 (20:13 +0300)]
Remove deprecated constructors from effects

10 months agoTweak the comma operator between VertexAttribute and unsigned
Mikko Rasa [Mon, 13 Sep 2021 17:03:12 +0000 (20:03 +0300)]
Tweak the comma operator between VertexAttribute and unsigned

It now returns VertexAttribute instead of VertexFormat, avoiding the need
to call make_indexed_attribute in some cases.

10 months agoConsider all attachments when determining Framebuffer's size
Mikko Rasa [Mon, 13 Sep 2021 17:01:53 +0000 (20:01 +0300)]
Consider all attachments when determining Framebuffer's size

10 months agoTweak some texture allocation checks
Mikko Rasa [Mon, 13 Sep 2021 16:59:07 +0000 (19:59 +0300)]
Tweak some texture allocation checks

Sub_image calls allocate_ internally, so it should avoid doing
unnecessary work.

10 months agoFix a bug in Renderer::resolve_multisample
Mikko Rasa [Mon, 13 Sep 2021 16:57:48 +0000 (19:57 +0300)]
Fix a bug in Renderer::resolve_multisample

Apply_state requires a shader program to be set, but it's not actually
needed here.

10 months agoRedesign framebuffer attachment management
Mikko Rasa [Mon, 13 Sep 2021 16:42:24 +0000 (19:42 +0300)]
Redesign framebuffer attachment management

Framebuffers now have an immutable format to which attachments must
conform.

10 months agoRemove RenderBuffer and always use textures as framebuffer attachments
Mikko Rasa [Sun, 12 Sep 2021 22:01:51 +0000 (01:01 +0300)]
Remove RenderBuffer and always use textures as framebuffer attachments

Originally textures could not have multiple samples, but now they can.
Vulkan only has images which are used for both purposes.

10 months agoFix incorrect render target buffer names
Mikko Rasa [Sat, 11 Sep 2021 14:24:16 +0000 (17:24 +0300)]
Fix incorrect render target buffer names

10 months agoRework PixelComponents and PixelFormat to use custom values
Mikko Rasa [Sat, 11 Sep 2021 14:23:56 +0000 (17:23 +0300)]
Rework PixelComponents and PixelFormat to use custom values

10 months agoDisconnect the PrimitiveType enum from OpenGL constants
Mikko Rasa [Sat, 11 Sep 2021 10:54:43 +0000 (13:54 +0300)]
Disconnect the PrimitiveType enum from OpenGL constants

10 months agoCreate a class for issuing drawing commands
Mikko Rasa [Sat, 11 Sep 2021 10:40:18 +0000 (13:40 +0300)]
Create a class for issuing drawing commands

This is a precursor to command buffers in Vulkan.

11 months agoRemove outdated includes
Mikko Rasa [Sun, 5 Sep 2021 11:35:05 +0000 (14:35 +0300)]
Remove outdated includes

11 months agoStore index type in VertexSetup
Mikko Rasa [Sun, 5 Sep 2021 11:34:04 +0000 (14:34 +0300)]
Store index type in VertexSetup

11 months agoUse the same index type for all of a Mesh's batches
Mikko Rasa [Sun, 5 Sep 2021 11:10:32 +0000 (14:10 +0300)]
Use the same index type for all of a Mesh's batches

In Vulkan the index type goes in the pipeline state object.

11 months agoMiscellaneous cleanup
Mikko Rasa [Sat, 28 Aug 2021 08:52:28 +0000 (11:52 +0300)]
Miscellaneous cleanup

11 months agoRemove the Bindable class
Mikko Rasa [Sat, 28 Aug 2021 08:41:08 +0000 (11:41 +0300)]
Remove the Bindable class

It's no longer used anywere

11 months agoRemove the PixelStore class
Mikko Rasa [Sat, 28 Aug 2021 08:26:02 +0000 (11:26 +0300)]
Remove the PixelStore class

Instead just permanently set unpack alignment to 1.  This seems to
match Vulkan.

11 months agoRemove public binding APIs from Renderbuffer and Clipping
Mikko Rasa [Fri, 27 Aug 2021 14:17:10 +0000 (17:17 +0300)]
Remove public binding APIs from Renderbuffer and Clipping

11 months agoConvert framebuffers and related functionality to new state management
Mikko Rasa [Fri, 27 Aug 2021 13:26:26 +0000 (16:26 +0300)]
Convert framebuffers and related functionality to new state management

11 months agoRedesign depth and stencil test and blend state management
Mikko Rasa [Wed, 18 Aug 2021 14:33:59 +0000 (17:33 +0300)]
Redesign depth and stencil test and blend state management

11 months agoDecouple the Predicate enum from OpenGL constants
Mikko Rasa [Wed, 18 Aug 2021 14:13:25 +0000 (17:13 +0300)]
Decouple the Predicate enum from OpenGL constants

11 months agoSome fixes to applying pipeline state
Mikko Rasa [Wed, 18 Aug 2021 14:00:01 +0000 (17:00 +0300)]
Some fixes to applying pipeline state

11 months agoAdd a helper function to set variables and flags in PipelineState
Mikko Rasa [Wed, 18 Aug 2021 13:59:26 +0000 (16:59 +0300)]
Add a helper function to set variables and flags in PipelineState

11 months agoRefactor winding-based culling
Mikko Rasa [Tue, 17 Aug 2021 21:39:41 +0000 (00:39 +0300)]
Refactor winding-based culling

11 months agoRewrite state management
Mikko Rasa [Mon, 16 Aug 2021 16:11:25 +0000 (19:11 +0300)]
Rewrite state management

Global bindings have been removed from the central classes (and will be
removed from others soon) since those would translate poorly to Vulkan.
Instead a new PipelineState class is used to tie all of the state
together and apply it at once.

11 months agoAllow materials to return per-texture samplers
Mikko Rasa [Fri, 13 Aug 2021 10:54:33 +0000 (13:54 +0300)]
Allow materials to return per-texture samplers

11 months agoRefactor get_level_size in various texture classes
Mikko Rasa [Fri, 13 Aug 2021 09:59:20 +0000 (12:59 +0300)]
Refactor get_level_size in various texture classes

Also add a few argument validity checks to functions

11 months agoUse DSA for TextureCube if available
Mikko Rasa [Thu, 12 Aug 2021 13:03:25 +0000 (16:03 +0300)]
Use DSA for TextureCube if available

11 months agoRemove some deprecated stuff that's getting in the way
Mikko Rasa [Thu, 12 Aug 2021 11:35:45 +0000 (14:35 +0300)]
Remove some deprecated stuff that's getting in the way

11 months agoRemove default sampler from Texture
Mikko Rasa [Thu, 12 Aug 2021 09:35:16 +0000 (12:35 +0300)]
Remove default sampler from Texture

It was a bad idea and would not translate well to Vulkan.

11 months agoRemove the notion of default binding point from Buffer
Mikko Rasa [Wed, 11 Aug 2021 21:09:01 +0000 (00:09 +0300)]
Remove the notion of default binding point from Buffer

It's more robust to always specify the binding point when using the
buffer.

ARRAY_BUFFER is used for buffer operations because it's always available
and is only used transiently by other code so there's no interference.

11 months agoAlways use ARB_map_buffer_range for mapping buffers
Mikko Rasa [Wed, 11 Aug 2021 15:02:28 +0000 (18:02 +0300)]
Always use ARB_map_buffer_range for mapping buffers

11 months agoHandle all shader data in Renderer through the generic mechanism
Mikko Rasa [Mon, 9 Aug 2021 12:10:11 +0000 (15:10 +0300)]
Handle all shader data in Renderer through the generic mechanism

11 months agoStore implementation limits in a central struct
Mikko Rasa [Mon, 9 Aug 2021 09:12:06 +0000 (12:12 +0300)]
Store implementation limits in a central struct

12 months agoDeprecate external access to Renderer::flush_shader_data
Mikko Rasa [Sun, 8 Aug 2021 22:52:31 +0000 (01:52 +0300)]
Deprecate external access to Renderer::flush_shader_data

It's no longer needed since changes in ProgramData are tracked with a
generation number.

12 months agoDeprecated setting Material or Lighting on Renderer
Mikko Rasa [Sat, 7 Aug 2021 12:07:44 +0000 (15:07 +0300)]
Deprecated setting Material or Lighting on Renderer

Those no longer have any special state of their own and can be set as
ProgramData instead.

12 months agoOnly allow VertexArray's format to be set once
Mikko Rasa [Wed, 4 Aug 2021 17:58:42 +0000 (20:58 +0300)]
Only allow VertexArray's format to be set once

Also affects related classes like VertexSetup and Mesh.  This will make
state management with Vulkan easier.

14 months agoAdd a window size option to viewer
Mikko Rasa [Thu, 13 May 2021 13:19:50 +0000 (16:19 +0300)]
Add a window size option to viewer

14 months agoSet debug names for dynamically created objects in desert pillars
Mikko Rasa [Thu, 13 May 2021 12:02:58 +0000 (15:02 +0300)]
Set debug names for dynamically created objects in desert pillars

14 months agoAdd ambient occlusion to the desert pillars demo
Mikko Rasa [Thu, 13 May 2021 12:02:36 +0000 (15:02 +0300)]
Add ambient occlusion to the desert pillars demo

14 months agoSupport exporting ambient occlusion postprocessor from Blender
Mikko Rasa [Thu, 13 May 2021 12:01:48 +0000 (15:01 +0300)]
Support exporting ambient occlusion postprocessor from Blender

14 months agoMove the HDR flag in Blender to render settings
Mikko Rasa [Thu, 13 May 2021 11:56:19 +0000 (14:56 +0300)]
Move the HDR flag in Blender to render settings

14 months agoClear VertexSetup state when a Mesh is unloaded
Mikko Rasa [Thu, 13 May 2021 11:16:33 +0000 (14:16 +0300)]
Clear VertexSetup state when a Mesh is unloaded

14 months agoAlways assume Technique has shaders
Mikko Rasa [Thu, 13 May 2021 11:04:41 +0000 (14:04 +0300)]
Always assume Technique has shaders

15 months agoRemove the Renderer-less render function from PostProcessor
Mikko Rasa [Sun, 9 May 2021 16:16:00 +0000 (19:16 +0300)]
Remove the Renderer-less render function from PostProcessor

15 months agoAdd debug name capability to more classes
Mikko Rasa [Sun, 9 May 2021 12:31:32 +0000 (15:31 +0300)]
Add debug name capability to more classes

15 months agoAdd inline data items to the collection
Mikko Rasa [Sun, 9 May 2021 10:53:13 +0000 (13:53 +0300)]
Add inline data items to the collection

This simplifies the internals of various objects and does away with
the special keep() semantic of RefPtr.

Blend and DepthTest will be handled separately as part of rendering
state rework.

15 months agoAdd OccludedScene to the registered scene types
Mikko Rasa [Sun, 9 May 2021 08:22:19 +0000 (11:22 +0300)]
Add OccludedScene to the registered scene types

15 months agoDeprecate the old skylight properties in Lighting
Mikko Rasa [Sat, 8 May 2021 19:43:43 +0000 (22:43 +0300)]
Deprecate the old skylight properties in Lighting

It's no longer supported by the standard shaders, and IBL is a superior
solution.

15 months agoFix the name of the PBR fresnel lookup texture
Mikko Rasa [Sat, 8 May 2021 18:44:15 +0000 (21:44 +0300)]
Fix the name of the PBR fresnel lookup texture

15 months agoIncrease ambient occlusion max samples to 128
Mikko Rasa [Sat, 8 May 2021 17:37:50 +0000 (20:37 +0300)]
Increase ambient occlusion max samples to 128

15 months agoTake ambient occlusion samples only from the forward hemisphere
Mikko Rasa [Sat, 8 May 2021 17:33:57 +0000 (20:33 +0300)]
Take ambient occlusion samples only from the forward hemisphere

This requires a few more samples from the depth buffer to determine the
normal, but that should not be an issue with today's GPUs.

Also generate the sample points for cosine-weighted importance sampling
to obtain physically correct occlusion values.

15 months agoUse non-random sequences to initialize ambient occlusion data
Mikko Rasa [Sat, 8 May 2021 17:31:42 +0000 (20:31 +0300)]
Use non-random sequences to initialize ambient occlusion data

This allows selecting the formulas to obtain a better distribution of
values.

15 months agoStore the ambient occlusion rotate lookup texture in resources
Mikko Rasa [Sat, 8 May 2021 15:41:28 +0000 (18:41 +0300)]
Store the ambient occlusion rotate lookup texture in resources

15 months agoUse correct sampler for the ambient occlusion rotate lookup
Mikko Rasa [Sat, 8 May 2021 15:36:40 +0000 (18:36 +0300)]
Use correct sampler for the ambient occlusion rotate lookup

15 months agoFix use of camera matrices in the ambient occlusion effect
Mikko Rasa [Sat, 8 May 2021 15:10:53 +0000 (18:10 +0300)]
Fix use of camera matrices in the ambient occlusion effect

15 months agoAdd inverse view and projection matrices to camera transform uniforms
Mikko Rasa [Sat, 8 May 2021 15:09:31 +0000 (18:09 +0300)]
Add inverse view and projection matrices to camera transform uniforms

15 months agoUse persistent uniform blocks for Camera, Lighting and Clipping
Mikko Rasa [Sat, 8 May 2021 14:58:11 +0000 (17:58 +0300)]
Use persistent uniform blocks for Camera, Lighting and Clipping

Now that the relevant calculations are done in world space, the values
of these uniforms don't need to be calculated on a per-frame basis.

15 months agoChange Clipping to use index-less attaching
Mikko Rasa [Sat, 8 May 2021 13:40:23 +0000 (16:40 +0300)]
Change Clipping to use index-less attaching

15 months agoUse PBR with IBL for the sphere in desert pillars
Mikko Rasa [Sat, 8 May 2021 11:45:28 +0000 (14:45 +0300)]
Use PBR with IBL for the sphere in desert pillars

15 months agoAdd a property in Blender for a custom shadow shader
Mikko Rasa [Thu, 6 May 2021 10:20:24 +0000 (13:20 +0300)]
Add a property in Blender for a custom shadow shader

Since a shadow map doesn't have color output, it's useful to specify a
cheaper shader which only does vertex transformations.

15 months agoPut the PI constant in builtins
Mikko Rasa [Thu, 6 May 2021 10:15:40 +0000 (13:15 +0300)]
Put the PI constant in builtins

It's needed in several places so this is easier than defining it
separately everywhere.