Commit graph

13604 commits

Author SHA1 Message Date
Bill Currie
e4ed868023 [vulkan] Simplify cubemap frame conversion
Don't need a whole matrix multiply when a swizzle and single vector
multiply will do.
2023-08-03 11:56:01 +09:00
Bill Currie
71934b15f4 [vulkan] Avoid alias depth hack in shadow pass
This protects the view model from incorrect self-shadowing.
2023-08-03 09:55:53 +09:00
Bill Currie
19a5cb562c [vulkan] Avoid bsp back-face cull in shadow pass
When rendering shadow maps, all the faces are needed, not just those
facing the pseudo-camera (due to the null-point of the shadow pass
view).
2023-08-03 09:22:54 +09:00
Bill Currie
2fbe44a72e [vulkan] Get point light shadows working
Other than the rather bad shadow acne, this is actually quake itself
working nicely. Still need to get directional lights working for
community maps, and all sorts of other little things (hide view model,
show player, fix brush backfaces, etc).
2023-08-03 00:15:42 +09:00
Bill Currie
1fe0f5ffd5 [vulkan] Get spotlight shadows working
They currently have a hard-coded bias of 0.5 pixels (if I'm doing my
math correctly) to combat the shadow acne, but look pretty good.
2023-08-02 19:34:37 +09:00
Bill Currie
a626dc7ca8 [vulkan] Split the lighting pass into per-type passes
This takes care of the type punning issue by each pass using the correct
sampler type with the correct view types bound. Also, point light and
spot light shadow maps are now guaranteed to be separated (it was just
luck that they were before) and spot light maps may be significantly
smaller as their cone angle is taken into account. Lighting is quite
borked, but at least the engine is running again.
2023-08-02 19:34:26 +09:00
Bill Currie
39bb433498 [vulkan] Add an undefined to shader-ro barrier
I guess it's kind of UB, but it's handy for images that will be
conditionally written by the GPU but need to be in shader-read-only for
draw calls and the validation layers can't tell that the layers won't be
used.
2023-08-02 17:51:04 +09:00
Bill Currie
00040c8900 [vulkan] Hook up all the shadow resources
This gets everything but the actual shadow map bindings working: the
validation layers don't like my type punning (which may well be the
right thing) and specialization constants don't help (yet, anyway) but I
want to get things into git.
2023-08-01 23:34:08 +09:00
Bill Currie
7487a00b36 [renderer] Return number of nearby dynamic lights
It allows for a minor optimization when allocating resources for those
lights.
2023-08-01 23:28:24 +09:00
Bill Currie
a50bc1c6ef [scene] Make light style unsigned
Not that it really matters for only 64 styles, but it feels more
consistent.
2023-08-01 23:26:26 +09:00
Bill Currie
2d7f671da8 [vulkan] Remove depth buffer from lighting pass
It's not needed and exceeds the minimum maximum input attachments.
2023-08-01 14:35:23 +09:00
Bill Currie
4ccd4ba3c7 [vulkan] Clean up some bitrot int the forward renderer
The recent changes for planes and shadows broke the forward renderer
pipeline spec.
2023-07-30 13:47:47 +09:00
Bill Currie
ffb113fa65 [vulkan] Fix some typos 2023-07-30 13:06:37 +09:00
Bill Currie
14c94711fd [vulkan] Compute correct matrices for spots and points
Directional lights don't get correct matrices yet as I need to study the
math involved for cascaded shadow maps (and id maps don't have
directional lights).

Getting spotlights working correctly was insanely frustrating: I just
couldn't get the entities into the view of the spotlight with any
sensible combination of inverses and the z_up matrix. It turned out it
was all due to an incorrect reference vector: it was +Z instead of +X.
2023-07-30 11:59:47 +09:00
Bill Currie
ff27da4a05 [vulkan] Use the shadow matrices when rendering maps
It turns out bsp faces are still back-face culled despite the null point
being on the front of every possible plane... or really, because it's on
the front of every possible plane: sometimes the back face is the front
face, and this breaks the face selection code (a separate traversal
function will be needed for non-culling rendering).

Despite that, other than having to deal with different pipelines,
getting the model renderers working went better than expected.
2023-07-30 11:52:13 +09:00
Bill Currie
aed1e7e077 [vulkan] Upload light matrices for shadow maps
This involved rewriting the descriptor update code too, but that now
feels cleaner.

The matrices are loaded into a storage buffer as it can get quite big at
6 matrices per light (and the current max lights is 768).
2023-07-30 11:35:07 +09:00
Bill Currie
aac6fca2c5 [vulkan] Pass a data parameter to QFV_RunRenderPass
The parameter will be passed on to the pipeline tasks in their task
context, allowing for communication between the subsystem calling
QFV_RunRenderPass and the pipeline tasks (for the case of lighting,
passing the current matrix base index).
2023-07-30 11:25:08 +09:00
Bill Currie
e83854a760 [vulkan] Make z_up and box_rotations public
They're now qfv_* and shared within the vulkan renderer. qfv_z_up cannot
be shared across renderers as they have their own ideas for the world
frame. qfv_box_rotations currently can't be shared across renderers
because if the Y-axis flip and the way it's handled, but sharing should
be achievable by modifying the other renderers to handle the sides
correctly (glsl and gl need to do lookups for the side enums, sw just
needs to be shown which way is up).
2023-07-30 11:13:48 +09:00
Bill Currie
931175b21d [vulkan] Run the shadow render passes
The shadow maps are rendered incorrectly because the matrices aren't set
correctly yet, but the dual-pass bsp rendering is working.
2023-07-29 01:17:53 +09:00
Bill Currie
3d4cca4393 [vulkan] Allow render passes to be run by processes
This lets the shadow step run its passes as needed.
2023-07-29 01:10:26 +09:00
Bill Currie
ad1b2d00d4 [nq,qw] Add a debug_debug cvar
Setting the cvar to > 0 causes demo playback to stop (via demo_speed 0)
when the read packet count reaches the specified value. Very useful for
debugging rendering glitches that are easily reproduced in a demo.
2023-07-28 19:19:13 +09:00
Bill Currie
fc946a604d [vulkan] Set default frames in flight to 2
Having 3 frames doesn't gain much of anything and costs 50% extra memory
as well as another frame of latency.
2023-07-27 16:16:33 +09:00
Bill Currie
3b0dcd2cdc [vulkan] Connect the shadow pass to the renderers
It's only partially complete, but R_VisitWorldNodes is now run for both
the main pass and the shadow auxiliary pass.
2023-07-27 16:09:33 +09:00
Bill Currie
123bf14784 [scene] Add a leaf component to lights
Regular leaf number for positional lights, 0 for directional, and ~0 for
ambient.
2023-07-27 15:50:53 +09:00
Bill Currie
2790972cb0 [renderer] Separate core of R_MarkLeaves
I needed to mark leaves based on an arbitrary PVS (for lighting) that is
independent of the camera position. Also cleaned up some const
correctness.
2023-07-27 15:43:47 +09:00
Bill Currie
f7fce957e8 [renderer] Boost R_MarkLeaves very slightly
Using set iterators can be quite a lot faster for sparse sets due to the
function call overhead in testing each element. Times for ad_tears
dropped from about 1200us to about 670us (hard to say due to there being
only 3 data points and a lot of noise in the time).
2023-07-25 15:22:45 +09:00
Bill Currie
1f99f89a4a Fix some printf portability issues 2023-07-25 15:07:17 +09:00
Bill Currie
6c631693bd [vulkan] Clean out old command buffers from bsp
Missed from the render job cleanup.
2023-07-24 19:13:43 +09:00
Bill Currie
f4d6a41901 [vulkan] Hook up a shadow render job step
It doesn't do much yet, but did help in getting light ids working.
2023-07-24 19:13:43 +09:00
Bill Currie
05f0fe9204 [scene] Add a render-internal lightid component
The vulkan shadow code needs to associate extra information with the
lights, but I don't want such renderer-specific data in the scene.
2023-07-24 19:11:18 +09:00
Bill Currie
faa2245220 [vulkan] Correct dummy field name for labeledsingle
I didn't realize why labeledsingle had problems because most of the uses
where where the names were the same.
2023-07-24 19:11:18 +09:00
Bill Currie
2fa44c03a6 [vulkan] Allow process steps to have render or compute
If a step has process tasks, any render or compute
pipelines/renderpasses are **not** run automatically: the idea is the
process tasks need to run the relevant pipelines in a custom manner but
needs the objects to be created.
2023-07-24 19:11:18 +09:00
Bill Currie
31cf3ed248 [vulkan] Register external attachments
This is along the lines of what I originally intended, but now I need
more than just the swapchain (which is now registered by vulkan_output).
2023-07-24 19:11:18 +09:00
Bill Currie
35540dfc79 [vulkan] Correct bsp stage/pass parameters
While it doesn't affect the operation, it does affect the readability of
the code because pass is meant for mainpass vs the multiple shadow
passes.
2023-07-24 19:11:18 +09:00
Bill Currie
07d9749b53 [renderer] Don't clear efrags in SCR_NewScene
The recent light changes highlighted that the renderer does not own the
efrags (segfault in qwaq when shutting down my test scene). After
digging through the history of efrag clearing, it turns out that the
renderer never owned them, I just didn't understand the concept of
scenes at the time that I moved efrags into the renderer.
2023-07-23 00:55:31 +09:00
Bill Currie
9e1810a2a9 [vulkan] Get shadow map image creation working again
The switch to using the ECS for lights temporarily broke the generation
of the images, but getting things going again was fairly easy.
2023-07-22 22:41:05 +09:00
Bill Currie
7280e1d042 [scene] Limit light efrags to leafs within range
This makes a pretty significant difference: 8-25% for demo1, demo2,
demo3 and bigass1. Many thanks to Nick Alger
(https://stackoverflow.com/questions/5122228/box-to-sphere-collision).
It took me a moment to recognize that it's the Minkowski difference (and
maybe GJK?). Of course, I adapted it for simd.
2023-07-22 20:08:15 +09:00
Bill Currie
72f6048a20 [scene] Put lights into the bsp tree via efrags
This eliminates the O(N^2) (N = map leaf count) operation of finding
visible lights and will later allow for finer culling of the lights as
they can be tested against the leaf volume (which they currently are
not as this was just getting things going). However, this has severely
hurt ad_tears' performance (I suspect due to the extreme number of
leafs), but the speed seems to be very steady. Hopefully, reconstructing
the vis clusters will help (I imagine it will help in many places, not
just lights).
2023-07-22 17:53:07 +09:00
Bill Currie
c0f8d102ad [scene] Implement Scene_FreeAllEntities (and use it)
I guess I wasn't sure how to find all the allocated entities from within
the registry, but it turned out to be trivial. This takes care of leaked
static entities (and, in a later commit, leaked light entities, which is
how I found the problem).
2023-07-22 16:50:18 +09:00
Bill Currie
befb3ca31b [vulkan] Clamp composed values to >= 0
This takes care of the nans that got into the output buffer resulting is
weird holes in any overlays.
2023-07-22 00:43:05 +09:00
Bill Currie
99c6c58e25 [vulkan] Expose pipeline disable controls
Finally, runtime control of the debug pipelines (and all the rest, but
that might come in handy at some stage).
2023-07-21 19:45:54 +09:00
Bill Currie
4b86a0376d [console] Reset minimum time too
Not sure what happened to it, I thought I'd done that before.
2023-07-21 19:31:20 +09:00
Bill Currie
ef322b968a [ui] Skip checkbox label if zero length
I seem to remember doing this for radio buttons, I guess I forgot about
checkboxes (really need to unify the code, though).
2023-07-21 19:28:30 +09:00
Bill Currie
8ae150cb9e [vulkan] Use correct name for pipelines
Using the subpass name instead of the pipeline name makes for a
confusing mess of duplicated names when subpasses have multiple
pipelines.
2023-07-21 12:37:04 +09:00
Bill Currie
a9fb1e5720 [ui] Remove IMUI_FlexibleSpace prototype
The function doesn't exist and likely never will.
2023-07-21 12:35:56 +09:00
Bill Currie
fde1ef0159 [vulkan] Add infinite plane rendering
The grid calculations are modified from those of Inigo Quilez
(https://iquilezles.org/articles/filterableprocedurals/), but give very
nice results: when thin enough, the lines fade out nicely instead of
producing crazy moire patterns. Though currently disabled, the default
planes are the xy, yz and zx planes with colored axes.
2023-07-21 11:59:25 +09:00
Bill Currie
72f7fcea47 [vulkan] Switch to reversed depth, infinite far plane
Based on the article
(https://developer.nvidia.com/content/depth-precision-visualized), this
should give nice precision behavior, and removes the need to worry about
large maps getting clipped. If I'm doing my math correctly, despite
being reversed, near precision is still crazy high. And (thanks to the
reversed depth) about a quarter of a unit (for near clip of 4) out at 1M
unit distance.
2023-07-21 11:36:10 +09:00
Bill Currie
9f8a6f5d62 [qfvis] Initialize set pool arrays
The relatively recent changes to ALLOC missed the set pools used in fat
pvs calculations.
2023-07-18 11:27:06 +09:00
Bill Currie
f2cb62f2c8 [qwaq] Use VID_SendSize
Takes care of a FIXME I'd forgotten about, but was rather relevant to
this morning's changes.
2023-07-14 15:38:55 +09:00
Bill Currie
6e9f50ffe4 [vid] Ensure window size gets sent after init
This fixes a pile of window size related issues I've seen for a while,
but most importantly, some nastiness with division by 0 and segfaults.
2023-07-14 11:57:36 +09:00