Mikko Rasa [Thu, 17 Mar 2022 19:55:18 +0000 (21:55 +0200)]
Redesign InstanceArray
It now stores the instances contiguously in memory instead of allocating
them individually. Consequently only one type of instance is allowed in
any particular array.
Mikko Rasa [Wed, 16 Mar 2022 08:44:06 +0000 (10:44 +0200)]
Rewrite descriptor set management
Descriptor sets have been moved from PipelineCache to a dedicated class.
PipelineState refers to descriptor sets using slot indices, allowing the
descriptor pool to be recreated if more space is needed.
Dynamic uniform buffers are no longer used. Instead multiple copies of
the descriptor set are created if it contains dynamic uniform blocks.
Mikko Rasa [Tue, 15 Mar 2022 19:25:18 +0000 (21:25 +0200)]
Make use of the sorted nature of PipelineState resource arrays
Since descriptor set is in the high bits, lower_bound can be used to
find its first resource and then go through elements until the next set
is reached.
Mikko Rasa [Mon, 14 Mar 2022 07:10:12 +0000 (09:10 +0200)]
Use a per-camera cache in ZSortedScene
It's very common to have multiple cameras in a scene due to effects like
shadow and environment maps. Using a single cache for all of them is
detrimental since the order will be different for each.
Mikko Rasa [Sun, 13 Mar 2022 07:34:18 +0000 (09:34 +0200)]
Treat standard and camera shader data specially in Renderer
Don't add them to the generic shdata stack. Some effects apply their own
camera, which led to two overlapping ProgramData objects on the stack.
Although the results were correct, this caused PipelineState to flag the
uniform blocks as dirty every frame and do unnecessary work.
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.