Mikko Rasa [Fri, 11 Mar 2022 22:11:49 +0000 (00:11 +0200)]
Remove unused stages from shader programs
A stage is deemed unused if it has no main function after optimization,
or if a SPIR-V entry point's interface variables all become unused during
specialization.
Mikko Rasa [Fri, 11 Mar 2022 21:37:05 +0000 (23:37 +0200)]
Refactor face cull settings in Blender
Meshes no longer have a winding test toggle. Instead mesh winding is
always set and material's backface culling flag is exported. The default
in RenderMethod has been changed to NO_CULL.
Mikko Rasa [Fri, 11 Mar 2022 12:53:32 +0000 (14:53 +0200)]
Change front face logic on Vulkan to match the OpenGL backend
Front face is always set, not only when face cull is enabled. Since we
pretend that NDC has the same orientation as on OpenGL, face winding gets
inverted.
This will probably produce incorrect results if anything rendering to a
swapchain image relies on winding.
Mikko Rasa [Fri, 11 Mar 2022 09:55:49 +0000 (11:55 +0200)]
Implement alpha cutoff for materials
Having to implement it separately in each material's shader is not
optimal, but since they each define their own uniform block, no better
solution is readily apparent.
The occluder shader also supports alpha cutoff so that objects with
such materials can cast proper shadows.
Mikko Rasa [Sat, 5 Mar 2022 08:50:04 +0000 (10:50 +0200)]
Redesign progress and error reporting in the Blender exporter
Progress is now tracked in a context object, which also holds the Blender
context. Tasks are represented by independent objects instead of a stack
structure.
The context/task objects also track which data object that task is about,
so the object path can be reported in errors.
Mikko Rasa [Mon, 17 Jan 2022 20:41:24 +0000 (22:41 +0200)]
Support multiple PipelineStates in Renderer
In the Vulkan backend it can be beneficial to keep separate pipeline
states and avoid having to repeatedly compute hashes and look them up
from the cache. The downside is that every time the used state object
changes, shader data has to be reapplied. But it's likely this would
be necessary anyway due to different shader or data being used.
Mikko Rasa [Wed, 12 Jan 2022 20:24:54 +0000 (22:24 +0200)]
Store simpler states by value in PipelineState
Since these are also stored by value in various objects, a pointer
comparison is not enough to tell if state needs to be changed. There's
no guarantee that the object behind the pointer stays alive, so comparing
values through the pointer is hazardous.
Mikko Rasa [Sun, 9 Jan 2022 13:38:54 +0000 (15:38 +0200)]
Only set pipeline resources as used when the resource changes
This avoids an issue on Vulkan where invalid descriptor set writes were
generated if a resource unused by the current shader was set to the same
value it already had and the shader wasn't changed.
I'm not really sure if the flags should be set in the common part at all,
since the OpenGL bckend barely uses them. But other approaches are not
clearly superior either.
Mikko Rasa [Sat, 18 Dec 2021 22:00:32 +0000 (00:00 +0200)]
Keep track of the buffers of bound uniform blocks
ProgramData may recreate the buffer when creating new blocks, but existing
block objects will be retained. As such, the block object alone isn't
enough to determine whether the binding has changed.
Mikko Rasa [Tue, 14 Dec 2021 11:21:25 +0000 (13:21 +0200)]
Refactor projection matrix handling
Projection matrices in C++ side now always produce a depth range of 0 to
1 for the NDC Z coordinate. Shaders will convert it to -1 to 1 when
targeting OpenGL.
Incidentally, the AmbientOcclusion effect's shaders were already written
as if the depth range was 0 to 1, so the effect was actually slightly
incorrect before this.
Mikko Rasa [Fri, 10 Dec 2021 13:51:09 +0000 (15:51 +0200)]
Support binding individual mipmap levels of textures
Vulkan requires different layouts for sampling a texture and rendering
into, so reading from one mip level and rendering into another requires
separate views.
The OpenGL backend only allows binding level 0, since nothing currently
needs binding higher levels. Full support requires the ARB_texture_view
extension.
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.