Commit graph

2795 commits

Author SHA1 Message Date
Bill Currie
52f012cc11 [console] Flush any pending draw data
This takes care of a 5s hang when the engine aborts before the first
frame is rendered (for vulkan).
2024-01-19 15:45:04 +09:00
Bill Currie
87357f98d3 [vulkan] Correct line vertex input spec (again)
This time for the forward renderer.
2024-01-19 15:45:04 +09:00
Bill Currie
5055860c1b [vulkan] Do lightmap flush after all lightmaps uploaded
This fixes the 5s hang on shutdown.
2024-01-19 15:45:04 +09:00
Bill Currie
4a99ef5723 [vulkan] Add a function to explicitly wait on a packet
It's not currently used, but it was very handy for finding where the
cause of the 5s hang was ***not***.
2024-01-19 15:45:04 +09:00
Bill Currie
bf0d1b4f6e [vulkan] Add tracy zones to most shutdown functions
This helped find the 5s hang on exit.
2024-01-19 15:45:04 +09:00
Bill Currie
3168550935 [vulkan] Upload lightmap data to the gpu and use it
The lightmaps aren't updated at all yet, so everything is static.
Figuring out how lightmap data gets to the gpu was a chore thanks to the
spaghetti in the bsp data, and then I'd forgotten that I was
pre-expanding the light data to rgb so wound up with weird lightmaps,
but without water or particles, demo1 is getting 5000fps at 800x450, and
it seems to be CPU limited.
2024-01-19 15:45:04 +09:00
Bill Currie
329c08b934 [vulkan] Use only a single subpass for forward main
Output is still a second pass for now.
2024-01-19 15:45:04 +09:00
Bill Currie
7ce94cde14 [vulkan] Fix some bitrot in the forward render graph
Many issues, but this fixes the validation errors.
2024-01-19 15:45:04 +09:00
Bill Currie
ec9e2c12b8 [vulkan] Implement skin support
Finally, quakeworld gets its *ahem* fancy skins. I'm not happy with how
skin loading is handled, but the whole model and skin support needs a
redesign.

Closes #74.
2024-01-15 19:07:33 +09:00
Bill Currie
fcd094ef04 [skin] Fix up dynamic library issues
And further clean up skin api.

It turns out that skin functions must all be in the render libs, and
this results in Skin_Set (was Skin_SetSkin) needs to be accessed via a
function pointer rather than directly :(
2024-01-15 15:26:09 +09:00
Bill Currie
d39630580e [skin] Get team colors working for model skins
This should actually get team colors working for all models, not just
player.mdl.
2024-01-15 14:59:11 +09:00
Bill Currie
346ed29f49 [skin] Implement top/bottom colors for gl
They don't work yet if the entity does not have an external skin.
2024-01-15 14:59:06 +09:00
Bill Currie
0539f07c1a [skin] Use an ECS registry to manage skins
This takes care of the double free and also cleans up a lot of the skin
api. However, the gl renderer lost top/bottom colors (for now). Vulkan
skins still don't work yet.
2024-01-15 14:56:37 +09:00
Bill Currie
739adad3d5 [skin] Clean up the API a little
Only the renderer-specific functions are in the plugin functions struct,
and only the client functions are global.
2024-01-13 13:42:03 +09:00
Bill Currie
c01c4180f3 [glsl] Handle verts with no bones
Same issue as in vulkan (surprise surprise, considering the glsl code
came first).
2024-01-09 20:42:18 +09:00
Bill Currie
119e9766b9 [iqm] Use 32-bit indices for large models
That is, those with more than 65520 vertices. Not properly supported for
sw or gl, and glsl isn't rendering properly for some reason (renderdoc
does see the meshes, though, so maybe depth or winding issues).
2024-01-09 13:36:46 +09:00
Bill Currie
1ab68ca5fd [vulkan] Correct line vertex input spec
I suspect I may have done the incorrect offset for color to get a
gradient for some testing, but forgot to put it back. Or, of course, I
just completely and utterly brain-farted when writing the attribute.
2024-01-05 22:44:09 +09:00
Bill Currie
860f48d541 Clean up about 12000 allocations
Some of them were actual leaks, but tracking memory should be a lot
easier now. However, there's a lot of room for optimization of
allocations (eg, recylcling of hierarchies. There is now 1 active
allocation (according to tracy) when nq exits: Qgetline's string buffer
(I think an api change is in order).
2024-01-05 11:50:48 +09:00
Bill Currie
bfa7c1722a [build] Implement tracy memory zones
This proved to be quite the challenge, and is probably rather fragile,
but it does seem to work, and might help with tracking down memory
leaks.
2024-01-05 11:50:48 +09:00
Bill Currie
f5ebc1083f [ecs] Pass the registry in to the component destroy function
This makes it possible for hierarchies to clean themselves up (by
deleting their entities (though that will cause other problems later
when the hierarchy doesn't own the entities)), thus plugging a memory
leak when parsing passage text.
2024-01-03 12:39:54 +09:00
Bill Currie
35eec0b2e5 [ecs] Implement hierarchies as components
The main goal of this change was to make it easier to tell when a
hierarchy has been deleted, but as a side benefit, it got rid of the use
of PR_RESMAP. Also, it's easy to track the number of hierarchies.

Unfortunately, it showed how brittle the component side of the ECS is
(scene and canvas registries assumed their components were the first (no
long the case), thus the sweeping changes).

Centerprint doesn't work (but it hasn't for a while).
2024-01-02 16:38:01 +09:00
Bill Currie
4c704e9a2e [ecs] Give registries a name
This makes debugging a little easier when there are multiple ECS
registries. Currently, the name parameter must be a stable pointer.
2023-12-28 16:08:40 +09:00
Bill Currie
dd11a7b378 [vulkan] Apply 2d scale to clipping bounds
It was a little off-putting getting an incorrectly clipped console when
using non-unitary scale (especially since I was trying to show abbator
something).
2023-12-24 02:14:24 +09:00
Bill Currie
00d9f039fc [vulkan] Set debug windows to auto_fit
I'd missed this earlier, thus the vulkan debug windows wound up a tad
small.
2023-12-22 18:25:04 +09:00
Bill Currie
650ea052ea [vulkan] Support clipping rectangles via scissor
Seems to work well. The other renderers have stubs because I don't feel
like implementing clipping for them. The gl and glsl wouldn't be too
difficult (need to handle the draw queues), but sw needs a fair bit of
work and I'm not sure it's worth the effort.
2023-12-22 18:17:09 +09:00
Bill Currie
f3eebae9bc [vulkan] Destroy the tracy GPU contexts
I had forgotten about doing so because I was doing my profiling without
validation layers.
2023-12-22 13:44:31 +09:00
Bill Currie
dc0b4880e3 [vulkan] Use VkValidationFeatureEnableEXT
It's currently unused as it does flag a pile of things I need to fix,
but I don't want to deal with them right now (though I have fixed a
few).
2023-12-22 12:29:59 +09:00
Bill Currie
866cdcf068 [renderer] Reset fov when fisheye disabled
This fixes the badly stretched view after disabling fisheye.
2023-12-21 13:28:52 +09:00
Bill Currie
0f24f10bb9 [vulkan] Handle spotlights pointing -X
The problem didn't show up until the switch to float depth buffers
(because they can store the resulting nan).
2023-12-19 17:56:13 +09:00
Bill Currie
4ed1ef3353 [vulkan] Switch to float depth buffers
This takes full advantage of the reversed (infinite far plane) depth
buffers, and seems to have no performance cost.
2023-12-18 23:15:21 +09:00
Bill Currie
bf4eedc1c6 [vulkan] Apply light cull info to light pvs
This makes a possible improvement to e1m3, only barely affects ad_tears,
but makes about 30% difference to gmsp3v2 (21fps to 27, and from 3300
leafs to 2700).
2023-12-18 21:07:57 +09:00
Bill Currie
443f825d19 [vulkan] Support fisheye for light culling
Nicely, the people who created multiview thought of queries and how they
need to interact.
2023-12-18 03:07:29 +09:00
Bill Currie
d6e6d5b28b [vulkan] Clean up shadow map render passes a little
The cascade_shadow and cube_shadow names are no longer relevant thanks
to the staging images, and the output field for render passes is
optional in general and irrelevant for shadow maps.
2023-12-18 03:05:10 +09:00
Bill Currie
394eae2284 [vulkan] Fix missing debug utils for 64-bit windows
My wordsize check was probably for 686 builds.
2023-12-17 22:41:18 +09:00
Bill Currie
69af6a6234 [vulkan] Bail if all lights have been culled
When all lights have been culled, the updates wind up being 0 bytes and
vulkan validation doesn't particularly like that.
2023-12-17 20:05:17 +09:00
Bill Currie
2dd8eea0d9 [vulkan] Let's do the distcheck again 2023-12-17 18:45:02 +09:00
Bill Currie
b02da2c0a6 [vulkan] Implement shadow map culling
The rendering of the shadow maps now takes the culling information into
account resulting in a drastic reduction of work. There's still more
work to be done, but demo1 peaks at over 1000fps at 640x480, gmsp3v2 now
gets 14fps (1920x1080) near the front gate (used to be 3, then 6),
ad_tears is up to 3fps, but marcher is still unhappy, but it has
infinite radius lights, so needs more culling work (clipped light
volumes will help, I think). Also, culling lights for which nothing has
moved within their volumes will help somewhat (though not as much for
most id maps, I suspect).
2023-12-17 18:45:02 +09:00
Bill Currie
245d4a8d9a [vulkan] Clean up make_id()
Passing the control struct and a flag for style/nostyle makes the calls
much easier to read.
2023-12-17 18:45:02 +09:00
Bill Currie
1511aa7120 [vulkan] Show light style and id in the debug UI
Style includes the resulting scalar for the light value.
2023-12-17 18:45:02 +09:00
Bill Currie
8890e14208 [vulkan] Use OIT to visualize the light hulls
Using the translucency pass made it easy to have depth-tested
translucent "solid" light volumes instead of always visible lines (which
are still an option as that's useful too). Most importantly, being able
to see the surfaces helped no end in figuring out that my hulls were
created with counter-clockwise windings instead of quake's usual
clockwise windings and thus my hulls were being rendered inside-out in
the occlusion pass.
2023-12-17 18:45:02 +09:00
Bill Currie
187c48bde3 [vulkan] Apply the light culling information
The results of the occlusion queries give the lights that don't have a
visible hull, but unfortunately that includes any lights which the
camera is inside, but simple distance checks sort that out (with a
fudge-factor for the icosahedron vertices (1.583 (3(2+p)/(2+3p), p is
golden ratio)).
2023-12-17 18:45:02 +09:00
Bill Currie
f08b8dc3c7 [vulkan] Move light radius calcs to the CPU
No point in calculating them for every vertex, especially when I forgot
to update the calculations for the entid vertex shader.
2023-12-17 18:45:02 +09:00
Bill Currie
00ecb7d71a [vulkan] Use separate tracy GPU context for light culling
My efforts (especially the collect zone (what was I thinking)) got
tracy's knickers in a twist resulting in vanishing zones in the server.
It looks like there are some synchronisation issues between cpu and gpu,
but I'm not *too* worried about it at this stage.
2023-12-17 18:45:02 +09:00
Bill Currie
f282bfc045 [vulkan] Use occlusion queries for culling lights
The info isn't used yet, but this shows that vulkan's occlusion queries
are at least somewhat useful. However, the technique isn't perfect:
infinite radius lights (1/r and 1/r^2) are difficult to cull, and all
lights can poke through thin enough walls, and then lights containing
the camera get culled incorrectly (will need a separate test). Still, it
looks like it will help once everything is tied together.
2023-12-17 18:45:02 +09:00
Bill Currie
1c13879fb9 [vulkan] Split out the render pass core
And make it callable directly (needed to be able to submit the command
buffer separately from the main commands (though this does mess with
tracy a little).
2023-12-17 18:45:02 +09:00
Bill Currie
24aa81e085 [vulkan] Fix some out-by-one errors
I don't know why I thought <= was useful in those loops. Fixes some
segfaults for incorrect references.
2023-12-17 18:45:02 +09:00
Bill Currie
fa6598c389 [vulkan] Fix broken dynamic light shadows
They weren't rendering properly at all due to the matrix updates getting
overwritten by the light data (I'd forgotten to advance the packet data
pointer).
2023-12-17 18:45:02 +09:00
Bill Currie
8e7c21e36a [vulkan] Implement staged shadow maps
This doesn't make much of a difference on the GPU, but it drastically
cuts down CPU usage, especially for ad_tears: shadow map drawing is down
from 16.3ms to 3.7ms thanks to no having to run the alias model queues
as often.
2023-12-17 18:45:02 +09:00
Bill Currie
5637bae20c [vulkan] Move on to vulkan api 1.3
I decided there's little point in hanging onto old API versions when the
newer ones have some nice things like vkCmdCopyImage2.
2023-12-17 18:45:02 +09:00
Bill Currie
c36c2dc8b2 [vulkan] Apply normal light rules to dynamic lights
ie, enforce shadow quanta and max light size.
2023-12-17 18:45:02 +09:00