This fixes a crash with `lightbulb -m`.
- During VkImage creation, the subresource depth should be 1 since it is
meant for 3D textures.
- Render targets should select a single level from an array texture, not
all of them.
- Add debug_trap to validation errors to make them easier to debug.
This fixes dynamic lighting and SSAO when a viewport is not in 0,0.
In practice this currently happens only when all post-processing is
disabled.
Instead of using gl_FragCoord we introduce a new API,
getNormalizedViewportCoord(), which as the name implies returns
normalized [0, 1] viewport coordinates with origin at the bottom-left,
on all platforms.
This is implemented in this PR by interpolating gl_Position.
We keep very the same (or very close) quality by exploiting h/w
filtering. On the flip side, this is not compatible with dithering,
which is removed here.
In OpenGL with use glInvalidateFramebuffer() for hinting controlling
the load/store of tiles. However, glInvalidateFramebuffer() conceptually
destroys the content of the framebuffer attachment.
This causes a problem when we want for instance to use a buffer for
reading only (e.g. a depth buffer) in multiple passes. In such
scenario, the attachment will be marked as "discard" (which is a
misnomer for storeOp==DONT_CARE in vulkan parlance), without the
intention of making the buffer invalid.
We fix this by ignoring the discardEnd flags entirely if a buffer
has not been written. In this case, we relying on the driver to not
write the tiles out -- but we don't have any other way to express
this in GL.
This issue cannot be encountered currently because the framegraph
is not aggressive enough setting the discardEnd flags.
As per the spec:
```
vkCmdWriteTimestamp latches the value of the timer when all previous
commands have completed executing as far as the specified pipeline
stage, and writes the timestamp value to memory.
```
the Instance id was off-by-one and didn't match the
given entity.
in gltf_viewer this caused contact shadows to not work
when there was only a single directional light
- Added an extra README file detailing what the scripts are for
- The scripts now display a warning and a prompt before requiring user confirmation to continue
- The system install commands are only executed in CI environments (ninja and cmake being installed as root without checking for the environment was a leftover from a previous non-GitHub based CI setup)
instead of storing two counters for point and spot lights, we now
only have a single counter for both, and the light data structure
has a type, the shader can use to decide what to do -- instead of
using two loops. In practice spot and point light code is very similar
anyways.
This simplify a lot the CPU side (as in make it less complex) and frees
up 8-bits in the per-froxel GPU data structure.
In Vulkan, the arrayness of a texture is an aspect of the "image view",
not the image itself.
In my earlier attempt I used VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT on
the image, which MoltenVK does not support. Confusingly, that flag is
actually meant for rendering into a slice of a 3D texture, which we are
not doing.
Vulkan is hard.
we can calculate each plane direction from its clip-space equation
(which is trivial), instead of back-projecting 2 points and computing
the cross-product