Commit graph

2729 commits

Author SHA1 Message Date
Bill Currie
74405ee31b [gamecode] Switch dstatement ops to signed
I realized recently that I had made a huge mistake making Ruamoko's
based addressing use unsigned offsets as it makes stack-relative
addressing more awkward when it comes to runtime-determined stack frames
(eg, using alloca). This does put a bit of an extra limit on directly
addressable globals, but that's what the based addressing is meant to
help with anyway.
2023-08-21 17:47:55 +09:00
Bill Currie
c46e15af9b [vulkan] Up max lights to 2048 and quantize sizes
This seems excessive, but gmsp3v2 map has 1399 lights. Worse, it has a
lot of different light sizes that go up by small increments (generally
around 10) resulting in 33 shadow map images (1 too many). Quantizing
the sizes to 32 drops this nicely to 20, and reduces memory consumption
slightly too (image buffer overhead, I guess).
2023-08-15 14:44:38 +09:00
Bill Currie
5abe467f7d [gamecode] Specify underlying type for opcode enums
And remove the bitfield from dstatement_t. I have wanted this for over
twenty years :)
2023-08-13 23:51:53 +09:00
Bill Currie
77842bdeb4 [build] Require C23 (gnu2x)
Now that gcc-13 is default on Debian sid, I'm happy to switch to
requiring it for building QF. As a celebration, I removed the bool and
auto hacks.
2023-08-13 23:51:53 +09:00
Bill Currie
618740663b [vulkan] Implement CSM rendering
This covers only the rendering of the shadow maps (actual use still
needs to be implemented). Working with orthographic projection matrices
is surprisingly difficult, partly because creating one includes the
translations needed to get the scene into the view (and depth range),
which means care needs to be taken with the view (camera) matrix in
order to avoid double-translating depending on just how the orthographic
matrix is set up (if it's set up to focus on the origin, then the camera
matrix will need translation, otherwise the camera matrix needs to avoid
translation).
2023-08-13 17:36:32 +09:00
Bill Currie
f3ca2f158b [vulkan] Add a scatter buffer copy function
Updating directional light CSM matrices made me realize I needed to be
able to send the contents of a packet to multiple locations in a buffer
(I may need to extend it to multiple buffers). Seems to work, but I have
only the one directional light with which to test.
2023-08-13 17:30:59 +09:00
Bill Currie
558e11e9b7 [vulkan] Make near and far clip explicit parameters
This improves the projection API in that near clip is a parameter rather
than being taken directly from the cvar, and a far clip (ie, finite far
plane) version is available (necessary for cascaded shadow maps as it's
rather hard to fit a box to an infinite frustum).

Also, the orthographic projection matrix is now reversed as per the
perspective matrix (and the code tidied up a little), and a version that
takes min and max vectors is available.
2023-08-13 17:30:24 +09:00
Bill Currie
2b879af3e1 Fix most of the hacks for clang
gcc didn't like a couple of the changes (rightly so: one was actually
incorrect), and the fix for qfcc I didn't think to suggest while working
with Emily.

The general CFLAGS etc fixes mostly required just getting the order of
operations right: check for attributes after setting the warnings flags,
though those needed some care for gcc as it began warning about main
wanting the const attribute.

Fixing the imui link errors required moving the ui functions and setup
to vulkan_lighting.c, which is really the only place they're used.
2023-08-11 18:29:30 +09:00
Th3T3chn0G1t
3098b5d3f7 Implement clang support
Fixing a load of issues related to autoconf and some small source-level issues to re-add clang support.
autoconf feature detection probably needs some addressing - partially as -Werror is applied late.
2023-08-11 14:25:01 +09:00
Bill Currie
481c12468e [vulkan] Show surfaces for selected light leaf
This has resulted in some rather interesting information: it seems the
surfaces (and thus, presumably bounding boxes) for leafs have little to
do with the actual leaf node's volume.
2023-08-09 02:01:47 +09:00
Bill Currie
5bc1924a25 [vulkan] Clean up some bsp pass name confusion
I had gotten stage and pass confused at some stage. Also, name the
passes in C (enum).
2023-08-08 19:23:30 +09:00
Bill Currie
a5fcc41d08 [vulkan] Rename bsp aux pass to shadow
Much better name.
2023-08-08 18:04:58 +09:00
Bill Currie
1319ed0e94 [scene] Implement simple UI functions for lights
Both dynamic lights and "static" lights display their values, but
currently no interaction.
2023-08-08 17:25:53 +09:00
Bill Currie
102a0d591b [ecs] Add a ui function pointer to components
This allows components to display themselves in the UI. Because the
component meta-data is copied into the registry, the function pointer
can be updated by systems (eg, the renderers) to display system-specific
interpretations of the component.
2023-08-08 17:02:53 +09:00
Bill Currie
c99a49a958 [vulkan] Save the current scene in the scene context
Now this I really don't know why I didn't do when I first created the
context.
2023-08-08 12:00:03 +09:00
Bill Currie
ff5d4d8de1 [vulkan] Move Vulkan_NewScene into vulkan_scene
It probably should have been there all along, and with this
vulkan_main/qf_main goes away.
2023-08-08 11:52:31 +09:00
Bill Currie
9ede227da4 [ui] Edge detect all mouse buttons
And return mouse button info in the io struct.
2023-08-07 22:20:34 +09:00
Bill Currie
1745d3bccc [vulkan] Implement mouse-picking for light entities
Currently, only light entities get drawn to the entid buffer, and the
ids are simply displayed in a window for now (not very useful yet).
2023-08-07 17:47:49 +09:00
Bill Currie
95b660d7fd [ui] Add a function to get current mouse position
And hot/active ids.
2023-08-07 17:42:59 +09:00
Bill Currie
bf951c3ba2 [vulkan] Get debug light objects working again
And also get them working for infinite radius lights.
2023-08-06 00:20:25 +09:00
Bill Currie
6892dc1422 [scene] Add flags for finer rendering control
This takes care of rockets and lava balls casting shadows when they
shouldn't (rockets more because the shadow doesn't look that nice, lava
balls because they glow and thus shouldn't cast shadows). Same for
flames, though the small torches lost their cool sconce shadows (need to
split up the model into flame and sconce parts and mark each
separately).
2023-08-05 18:09:20 +09:00
Bill Currie
f436806006 [scene] Remove full_transform from renderer_t
I've wanted to do this for a long while, but I finally got the
motivation to clean up the two uses in gl and glsl. Removes 64 bytes
from the struct.
2023-08-05 15:56:01 +09:00
Bill Currie
15d7222ebb [model] Remove Mod_LeafPVS in favor of mix/set
The use of a static set makes Mod_LeafPVS not thread safe and also means
that the set is not usable with the set iterators after going to a
smaller map from a larger map.
2023-08-05 11:51:01 +09:00
Bill Currie
7294a77356 [client] Put dynamic lights on separate entities
Dynamic lights can't go directly on visible entities as one or the other
will fail to be queued. In addition, the number of lights on an entity
needs to be limited. For now, one general purpose light for various
effects (eg, quad damage etc) and one for the muzzle flash.
2023-08-05 01:42:15 +09:00
Bill Currie
fb818d15d9 [scene] Support extra component systems
I've finally come across the need for "client" (hah) code to have
additional components on scene entities.
2023-08-05 01:35:09 +09:00
Bill Currie
9328c90a74 [vulkan] Implement shadows for dynamic lights
This also fixes the segfault in the previous commit.

Dynamic light shadow sizes are fixed, but can be controlled via the
dynlight_size cvar (defaults to 250).
2023-08-04 15:44:07 +09:00
Bill Currie
35ec2ebb4c [scene] Move dynamic lights into the scene ECS
While the insertion of dlights into the BSP might wind up being overly
expensive, the automatic management of the component pool cleans up the
various loops in the renderers.

Unfortunately, (current bug) lights on entities cause the entity to
disappear due to how the entity queue system works, and the doubled
efrag chain causes crashes when changing maps, meaning lights should be
on their own entities, not additional components on entities with
visible models.

Also, the vulkan renderer segfaults on dlights (fix incoming, along with
shadows for dlights).
2023-08-04 15:08:56 +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
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
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
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
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
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
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
a9fb1e5720 [ui] Remove IMUI_FlexibleSpace prototype
The function doesn't exist and likely never will.
2023-07-21 12:35:56 +09:00