Commit graph

6333 commits

Author SHA1 Message Date
Bill Currie
1266ede2b1 [zone] Make zone_error be like printf
It's so much nicer being able to just print normally.
2023-12-20 18:32:53 +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
2e9e247ca4 [vulkan] Use resource for allocating alias models
So far only the mesh data, so it doesn't make any difference to
allocations, but it's the first step to reducing memory object
allocation.
2023-12-19 03:28:29 +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
Bill Currie
72ef0662f5 [vulkan] Add a level of indirection to shadow matrices
Batching shadow map rendering needs be able to reference matrices for
multiple lights in a single batch, but the only input is the view index,
so use that to look up the matrix index rather than using it to index
the matrices directly (modulo the base index that's still there).
2023-12-17 18:45:02 +09:00
Bill Currie
3a31fa111d [vulkan] Create render passes for up to 32 views
Actually, only 29 are used because nvidia's drivers segfault when there
are more than 29 views (regardless of the exact bit pattern in the view
mask). This will allow rendering shadow maps in large batches, which
should make for better GPU utilization.
2023-12-17 18:45:02 +09:00
Bill Currie
a9ff79a76a [vulkan] Set shadow map size limit to 1024
Even that's getting pretty big, but with the quanta at 128, that's a
maximum of 8 different image sizes (which is nice for my planned
"staging image" idea).
2023-12-17 18:45:02 +09:00
Bill Currie
9ba7207e20 [vulkan] Change shadow quanta to 128 pixels
Interestingly, this caused a reduction in memory use for some maps (but
did increase marcher's again, but not as much as the bogus rounding
did). The idea was to use sparse bindings to remap shadow map layers,
but it turns out sparse bindings are insanely slow (beyond unusable).
However, the reduction in the number of shadow map images seems to be
worth it.
2023-12-17 18:45:02 +09:00
Bill Currie
75ce49b1f0 [vulkan] Switch to vulkan 1.1/1.2 prop/feat structs
Since switching to the 1.2 api as a requirement, might as well use the
relevant structs instead of extension struct (for multiview). Came up
when double-checking the max views property due to running into what
appears to be an nvidia bug where > 29 views (any bit pattern) cause a
segfault when creating the pipeline.
2023-12-17 18:45:02 +09:00
Bill Currie
7506117e43 [vulkan] Increase matrix id bits
I had missed that upping max lights to 2048 meant that up to 12288
matrices are needed for all the possible lights. This made it so the
light type could not be encoded in id_data, but the shaders never used
it anyway. This leaves one bit free.
2023-12-17 18:45:02 +09:00
Bill Currie
39616bc84d [vulkan] Remove old descriptor and pipeline code
Pipeline cache handling is still there for now, but the rest hasn't been
used since the render graph rewrite, if not before (and good riddance).
2023-12-17 18:45:02 +09:00
Bill Currie
694d969c83 [vulkan] Round shadow map sizes correctly
I'd added some developer output to see how the layers were distributed
between images and found the image widths to be... odd. It turns out I
was double-adding the shadow_quanta. Oops. Results in ~164MB less memory
used by marcher (for 32 pixel quanta).
2023-12-13 00:06:33 +09:00
Bill Currie
175e9fd7c9 [vulkan] Add some comments to lighting code 2023-12-12 21:13:14 +09:00
Bill Currie
b86f49fe7c [vulkan] Queue quad and slice vertices for transfer
This allows "large" updates to be done in a single staging buffer packet
instead of one packet per quad (or slice). Currently, they're batched
into groups of 64 (not really enough for conchars, but that's only at
init-time, so not all that bad). Nicely, this seems to simplify the
staging code.

Fixes #65.
2023-12-07 14:59:21 +09:00
Bill Currie
800e984880 [vulkan] Rename size to max_count in draw
When looking at a struct and seeing "count" and "size", I had to hunt to
see what "size" really meant. Cherno is very much right about size vs
count being bytes vs number of objects.
2023-12-07 13:00:32 +09:00
Bill Currie
310acc98f4 [vulkan] Unify static quad creation
load_conchars and load_crosshairs were using create_quad directly (due
to make_static_quad having the wrong parameters), but this spread the
handling of which buffer and index where used through the code. Thus fix
make_static_quad to take the x, y offsets (like make_dyn_quad) and then
use it in load_conchars and load_crosshairs.
2023-12-06 23:29:16 +09:00
Bill Currie
7ff0e95c52 [vulkan] Merge lighting updates into one packet
While QFV_PacketScatterBuffer works on only one destination buffer, it
turns out it's still useful for scattering to multiple buffers, just
with multiple calls. This makes it pretty easy to combine multiple
buffer updates into a single staging buffer packet, resulting in
reducing lighting's packet use from up to 7 to just one, drastically
reducing the pressure on the stating buffer packet pool, and thus
reducing the chances of QFV_PacketAcquire stalling.
2023-12-06 00:15:42 +09:00
Bill Currie
fccd06c5bf [vulkan] Add gpu profiling zones
This relies on my fork of tracy: https://github.com/taniwha/tracy
on the wip-c-vulkan branch. Everything is still rather flaky though.

This necessitated the jump to vulkan 1.2 as a requirement.
2023-12-05 22:55:57 +09:00
Bill Currie
57282702ba [vulkan] Move dynamic draw data into device memory
This gets the dynamic data closer to the gpu, so should make a
difference when there's a lot going on. However, for simple tests, it
made no difference.
2023-12-05 19:10:06 +09:00
Bill Currie
d908016606 [sys] Use a jump buffer to exit to main
This allows tracy to clean up properly. However, Sys_Quit will use the
jump buffer (sys_exit_jmpbuf) only if it has been set, so the use of
Sys_setjmp is optional.
2023-12-05 19:02:51 +09:00
Bill Currie
df51e1a18d [vulkan] Report the memory type used for resources
Needed for verifying the desired heap was used.
2023-12-05 16:45:19 +09:00
Bill Currie
63e66e81c5 [vulkan] Increase ring buffer size to 32 packets
I'm still not happy with it being a compile time constant, but this
takes care of the interlock between frames in flight... for now: it's
fragile and really needs the excessive small-packet use in draw and
lighting to be cleaned up.

After discussion with Darian, I've decided to go with one big staging
buffer (with lots of packets) shared between FiF as the large size will,
in the end, be more flexible.
2023-12-05 16:43:05 +09:00
Bill Currie
e65e80f573 [vulkan] Report long packet acquisition times
Here long is considered to be 500μs. This shows the problem mentioned in
test scene, in lighting updates.
2023-12-04 23:41:46 +09:00
Bill Currie
e30f2cbacc [util] Add a wrapper for libgcc's backtrace functions
Right now, just backtrace_pcinfo is supported, but it's enough for
testing.
2023-12-04 17:53:12 +09:00
Bill Currie
1a83fe21c1 [util] Add Sys_setjmp and Sys_longjmp
Host_Error and Host_EndGame use setjmp/longjmp to implement an exception
of sorts, but this messes with tracy's state even with cleanup
attributes. However, it turns out that those cleanup attributes are
exactly how gcc implements C++ destructors, and so the standard Unwind
api (part of libgcc) respects them (so long as -fexceptions is enabled
for C). Thus... replace longjmp with an implementation that uses Unwind
to unwind the stack and call the cleanup functions as needed. This is
actually important for more than just tracy as the cleanup attributed
vars can be thread locks.
2023-12-01 12:13:26 +09:00
Bill Currie
52210b8c55 [util] Add leb123 signed and unsigned message readers
Needed for parsing dwarf eh_frame data, but I'm sure it will come in
handy for other things.
2023-12-01 02:55:08 +09:00
Bill Currie
514bb30655 [iqm] Make the null texture static
That was a nasty bit of UB that wasn't discovered until Tracy affected
the stack, I guess (maybe because of the cleanup attribute).
2023-11-28 16:02:38 +09:00
Bill Currie
010c658653 [build] Add support for building with Tracy
Tracy is a frame profiler: https://github.com/wolfpld/tracy

This uses Tracy's C API to instrument the code (already added in several
places). It turns out there is something very weird with the fence
behavior between the staging buffers and render commands as the
inter-frame delay occurs in a very strangle place (in the draw code's
packet acquisition rather than the fence waiter that's there for that
purpose). I suspect some tangled dependencies.
2023-11-28 15:54:55 +09:00
Bill Currie
9e43675c8f [vulkan] Add length and int color to graph labels
Tracy wants string lengths and uint32_t colors, so set them up
automatically from provided info.
2023-11-28 14:15:43 +09:00
Bill Currie
2a80614273 [build] Fix some build issues caused by using tracy
Mostly just macro conflicts (and a little white space in passing).
Commits for integrating tracy will come later when I've come up with a
wrapper-api that I like (so non-tracy builds are easy even with tracy
available).
2023-11-28 13:54:18 +09:00
Bill Currie
962043ca59 [build] Remove obsolete targets
Gone: svga, fbdev, sdl, wgl and probably a few more. Now it's just x11
and win.
2023-11-27 18:10:23 +09:00
Bill Currie
8e4f0f3837 [win] Implement borderless fullscreen mode
And rip out all the crufty DIB mode junk.
Fixes #60
2023-11-26 14:18:54 +09:00
Bill Currie
4eef0889ee [win] Communicate application focus to the client
This fixes the weird slug when running nq on windows. It turns out it
was the "friendly neighbor" sleep code activating due to bitrot. In
addition, there are cvars for enabling unfocused sleep (defaults off)
and disabling minimized sleep (defaults on).
2023-11-26 13:40:00 +09:00
Bill Currie
9a01e71f67 [win] Silence some debug
Missed that one.
2023-11-26 01:16:16 +09:00
Bill Currie
d2af58bfa2 [win] Implement mouse grabbing
This seems be behave quite nicely (at least for the standard win32
message pump).

Fixes #63
2023-11-25 22:33:57 +09:00
Bill Currie
7024e4efb1 [win] Hide the mouse in a system-friendly way
ShowCursor is system-wide and thus not suitable for general use. It
turns out hiding the cursor in windows is the same as x11: use a null
cursor.
2023-11-25 22:03:27 +09:00
Bill Currie
0774f70ca2 [win] Remove the close window confirmation dialog
It's annoying and unless there's data to save (not at this stage, at
least), rather unnecessary.
2023-11-25 22:01:03 +09:00
Bill Currie
c110119196 [win] Track mouse leaving the window
This fixes the incorrect mouse deltas experienced when looping the mouse
cursor through and around the window.
2023-11-25 21:05:37 +09:00
Bill Currie
30489e1812 [win] Set window style correctly
This fixes the incorrectly sized window (I think).
2023-11-25 21:03:51 +09:00
Bill Currie
ed3afeed39 [win] Convert extended scan codes to QF keys
This takes care of the separate arrow keys not working. Fixes #62.
2023-11-25 18:33:38 +09:00
Bill Currie
d49c6b0c27 [win] Improve mouse event handling
A lot is broken, especially direct input, but things are working. Better
yet, it seems the X11 and Windows key bindings are at least mostly
compatible.
2023-11-25 15:45:25 +09:00
Bill Currie
866b13b52c [win] Use Windows char events for keys
Fixes #59
2023-11-25 15:44:55 +09:00
Bill Currie
78113919ea [win] Avoid double destroy of window
I suspect it's from the recent event rework, but DestroyWindow seems to
be getting called twice, despite the null protection. Not good.
2023-11-25 10:57:25 +09:00
Bill Currie
43ce0eb3ec [sys] Correct spelling of signals
Is a signlas a girl with a sign?
2023-11-25 09:51:33 +09:00
Bill Currie
5f45c8a0d2 [win] Handle move and size events
Hook up WM_MOVE and WM_SIZE with QF's internal events.

Fixes #61
2023-11-24 22:59:48 +09:00
Bill Currie
250cac6079 [vid] Remove direct draw interface
It has been dead for a long time.
2023-11-24 12:28:55 +09:00
Bill Currie
f721021fec [win] Clean up event handling and a pile of dead code
The event handling changes take care of VagueLobster's segfaults on
startup for all renderers (vulkan will still be iffy depending on his
hardware: it dies on my GTX 965 M, probably due to memory and QF's
shadows). One nice side effect is it takes care of the broken CD audio
event handling (does anyone even care, though?).
2023-11-24 12:28:06 +09:00
Bill Currie
0a89c513b4 [win] Do not call IN_ClearStates when creating the window
The window is created before input is initialized. Fixes a segfault on
startup of nq-win.exe.
2023-11-23 21:13:47 +09:00
Bill Currie
97a9620cb9 Do the distcheck dance 2023-11-23 17:55:33 +09:00
Bill Currie
7a2a61d365 Merge branch 'wip-trails' 2023-11-23 14:00:11 +09:00
Bill Currie
a8ff58baa4 [glsl] Remove a debug print 2023-11-23 13:58:44 +09:00
Bill Currie
43cea64709 [renderer] Get trails looking vaguely acceptable
Still not great, but I like the falloff and the mixing is better. The
path offset seems to be unstable, so that needs work still.
2023-11-23 13:58:44 +09:00
Bill Currie
34daf9032d [renderer] Get trails rendering again
They're not quite working (trail path offset is incorrect) but their
pixels are getting to the screen. Also, lifetimes are off for rocket
trails in that as soon as the entity dies, so does the trail.
2023-11-23 13:58:44 +09:00
Bill Currie
3a38560ceb [libs] Fix some c23 build errors for mxe 2023-10-15 18:22:06 +09:00
Bill Currie
ef6b10afb1 [renderer] Remove dead r_part_comp.c 2023-10-03 21:27:04 +09:00
Bill Currie
a905dcd4f9 [renderer] Update particle scale
It seems I forgot this and didn't notice until now. The glsl renderer's
particles (style 1) look a lot better now.
2023-10-03 18:37:59 +09:00
Bill Currie
4554ea47b0 [glsl] Apply an old debug stash for trails
The code is mostly disabled, but this should prevent too much bitrot.
2023-10-03 15:05:13 +09:00
Bill Currie
5311f9906a [nq,qw] Call Mod_ClearAll in CL_Shutdown
Although the model subsystem does this too, it does it too late relative
to the video shutdown, resulting in segfaults for glsl due to the
drivers having been unloaded.
2023-10-03 14:28:32 +09:00
Bill Currie
7f3fc6d832 [nq,qw] Call Mod_ClearAll in CL_Shutdown
Although the model subsystem does this too, it does it too late relative
to the video shutdown, resulting in segfaults for glsl due to the
drivers having been unloaded.
2023-10-03 14:26:54 +09:00
Bill Currie
1c6986f0ab Merge branch 'master' into wip-trails 2023-10-03 14:11:22 +09:00
Bill Currie
c5731374cd [glsl] Separate out the trails implementation
This gets things *compiling* again, though it's still non-functional and
definitely wrong (don't want trail in renderer_t), but I need to think
about the design for getting trails as components. Also need to think
about integrating trails into the client effects system so trails can be
shared between renderers.
2023-10-03 13:49:25 +09:00
Bill Currie
ba35ce71b3 [qfcc] Support 32-bit and 64-bit handle types
32-bit is nice because it's small, but 64-bit is handy for special
handle encodings.
2023-10-02 23:33:37 +09:00
Bill Currie
6423c13108 Merge branch 'master' into wip-trails 2023-10-02 00:48:14 +09:00
Bill Currie
5c72ce10d2 [input] Delay event system init
I think I had though it using a constructor init was ok, but it turns
out that was problematic. That, or I missed it in my recent audit. Fixes
a sys syserror during shutdown.
2023-09-21 02:02:12 +09:00
Bill Currie
9a081b6809 [input] Fix input shutdown order
This fixes another segfault on shutdown (not sure just which recent
change caused it, but the listener pointer needed clearing) but while
fixing the listener issue, I noticed that binding and imt shutdown were
in the wrong order with respect to buttons and axes.
2023-09-21 01:36:43 +09:00
Bill Currie
84df81bd03 [ruamoko] Clean up buttons and axes
Reloading progs (or shutting down) needs to clean up the buttons
otherwise the input system will have issues when it cleans up because
the buttons and axes have ceased to exist.
2023-09-15 14:04:21 +09:00
Bill Currie
1a36d3786d [input] Allow buttons and axes to be deregistered
This is used by the Ruamoko input bindings so progs can clean up.
2023-09-15 14:04:21 +09:00
Bill Currie
fab5ae9d1f [input] Delay button and axis init
It turns out that initializing them via constructors led to their
shutdowns happening too late which resulted in problems with button and
axis cleanup.
2023-09-15 13:51:59 +09:00
Bill Currie
4eaaf28030 [sys] Ensure dstrings don't get double-freed
Never nice.
2023-09-15 01:15:10 +09:00
Bill Currie
cb72769aa9 [model] Clean up the model struct a little
Mostly just removing some (near) dead fields and making the
flags/effects more clear on what it's for.
2023-09-14 20:35:45 +09:00
Bill Currie
d03637ede8 [gamecode] Dump void data in hex
This makes dealing with assign instructions much easier.
2023-09-12 22:16:35 +09:00
Bill Currie
ea02af57eb [gamecode] Allow stack with no heap
Trying to use stack without a heap allocated would result in some very
bogus stack info.
2023-09-12 22:13:18 +09:00
Bill Currie
bce2b7d767 [ruamoko] Add sincos and sincosh functions
sincos is just a wrapper around the GNU libc sincos. sincosh is the
equivalent for sinh and cosh, but there doesn't seem to be any such
function, so it's just the two wrapped. They both return their results
in a vec2/vec2d as (sih[h], cos[h]).
2023-09-10 14:13:56 +09:00
Bill Currie
2e2dedfd78 [gamecode] Print invalid opcodes correctly
Hex is better for opcodes than octal. Probably copied from one of the
sub-instruction opcode error messages.
2023-09-08 11:12:37 +09:00
Bill Currie
5c32077c2a [iqm] Use type-specified enums
This should make debugging a little easier in the future.
2023-09-04 12:24:40 +09:00
Bill Currie
084ac76f55 [vulkan] Use identity for vertices with no bone weights
Since the identity matrix is mixed in with the other bones, interesting
things will happen if the bone weights don't add up to 1 and are not all
zero.
2023-09-04 11:08:55 +09:00
Bill Currie
2b5b55f416 [iqm] Check frames before freeing its buffer
Fixes a segfault on shutdown when the iqm model has no animation data.
2023-09-04 11:01:46 +09:00
Bill Currie
23b041c2c0 [console] Fix a build failure without ncurses
It seems that I'd gotten some wires crossed when submitting the issue in
that it was the server console, not qwaq-curses, but fixes #54
2023-09-03 22:18:25 +09:00
Bill Currie
e61be2f80f [gamecode] Add 2- and 3-component swizzles
VM side of the work needed for #58. Tests are still only 4-component,
but the geometric algebra tests seem to have 2-component covered at
least a little bit.
2023-08-31 20:08:28 +09:00
Bill Currie
a416e9c060 [gamecode] Add a 2d wedge product
While it could be emulated using a 3d cross-product, it was a hack and
required the use of a swizzle (or alias) to extract the scalar value.
This will make 2d PGA a little nicer when I get to modifying qfcc for it
2023-08-31 17:33:05 +09:00
Bill Currie
a66fb80517 [gamecode] Switch dot products to give a scalar
Making them give a vector was a mistake for Ruamoko. I've probably got a
mess to clean up in game-source, but oh well.
2023-08-31 15:32:52 +09:00
Bill Currie
727b490a0c [gamecode] Improve hops instruction readability 2023-08-27 12:28:16 +09:00
Bill Currie
29a57b7128 [qfcc] Correct handling of 64-bit comparisons
While the progs engine itself implements the instructions correctly, the
opcode specs (and thus qfcc) treated the results as 32-bit (which was,
really, a hidden fixme, it seems).
2023-08-26 23:04:34 +09:00
Bill Currie
8a0246c910 [ruamoko] Add type info for algebra types
And get vector type views working in the debugger.
2023-08-26 23:01:01 +09:00
Bill Currie
a88d17459f [gamecode] Decode hops and extend opcodes 2023-08-26 22:43:15 +09:00
Bill Currie
81b57903fc [gamecode] Support the l flag for %v and %q
This makes it much easier to print double vector types (for 3 and 4
components, at least).
2023-08-26 11:47:04 +09:00
Bill Currie
7338f86c77 [gamecode] Extend extend to support reversal
Using swizzle for some of the geometric product operations was a bit
clunky and has problems with alignment. While I will still need it in
the future, it turns out that the extend instruction almost did what I
needed. However, I'm unsure that reversing components within an extended
vector is the way to go.
2023-08-25 10:30:14 +09:00
Bill Currie
fb6d3f2f86 [gamecode] Decode the swizzle operand
-yx00 is much easier to interpret than some "random" number.
2023-08-24 20:17:17 +09:00
Bill Currie
8ff2c5a747 [util] Support utf-8 strings in Sys_Printf
By default. Conversion of quake strings needs to be requested (which is
done by nq and qw clients and servers, as well as qfprogs via an
option). I got tired of seeing mangled source code in the disassembly.
2023-08-23 21:40:50 +09:00
Bill Currie
30f2abb0ad [gamecode] Correct 64-bit debug views
I had forgotten that value needs to be incremented by 2 for 64-bit
values because it's only 32-bit.
2023-08-23 21:39:06 +09:00
Bill Currie
2e91b29580 [qfcc] Start work on implementing geometric algebra
This gets only some very basics working:
 * Algebra (multi-vector) types: eg @algebra(float(3,0,1)).
 * Algebra scopes (using either the above or @algebra(TYPE_NAME) where
   the above was used in a typedef.
 * Basis blades (eg, e12) done via procedural symbols that evaluate to
   suitable constants based on the basis group for the blade.
 * Addition and subtraction of multi-vectors (only partially tested).
 * Assignment of sub-algebra multi-vectors to full-algebra multi-vectors
   (missing elements zeroed).

There's still much work to be done, but I thought it time to get
something into git.
2023-08-21 17:58:20 +09:00
Bill Currie
b4afaab03c [gamecode] Support wide types in type views
Now the new vector types print properly :)

    0003 scale.F{4,1,4} ([1, 0, 0, 0]), (3), p1
2023-08-21 17:47:55 +09:00
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
a238eac75b [vulkan] Ensure the barriers array is initialized
I'm not sure what's up, but arm gcc thinks the array isn't properly
initialized even though x86_64 gcc does. Maybe something with padding.
At least c23 makes it easy to 0-initialize VLAs.
2023-08-17 12:54:28 +09:00
Bill Currie
ab5f28f743 [vulkan] Allocate map spaces for dynamic lights
I'm actually surprised anything worked, though I guess it was just the
one entry getting corrupted (and not 32, but I figured allocate slots
for all of the dynamic lights just in case). Or none, really, since
larger scenes (ie, those with multiple lights that fit in the same image
size) would result in not all the maps getting used and thus one spare
for dynamic lights.
2023-08-16 10:54:42 +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
efea07f488 [gl,glsl,sw] Skip onlyshadows alias models
While the gl renderer does (or did) have it's attempt at shadows, the
others don't even try, thus the onlyshadows-marked player model doesn't
work so well (looks rather goofy seeing the arms like that).
2023-08-14 14:53:43 +09:00
Bill Currie
70b60456a8 [vulkan] Implement direction shadow lighting
Finally, even suns cast shadows :)
2023-08-14 02:41:38 +09:00
Bill Currie
a3e99435df [vulkan] Clean up lighting shaders a little
Having more than one copy of ShadowMatrices went against my plans, and I
had trouble finding the attachments set (light_attach.h wasn't such a
good idea).
2023-08-13 18:06:28 +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
e00a871824 [util] Clarify the comment for AngleVectors
I found it rather confusing that the matrices were all backwards, and
the existing comments about being "horizontal" didn't really help all
that much. After spending some time with maxima, I was able to verify
that the comments were indeed correct, just transposed (horizontal),
with the final composition reversed to reflect that transposition.
2023-08-13 17:33:46 +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
079e2c055a [vulkan] Add more light debug info
Lines are drawn for a light's leaf, the leafs visible to it, or those in
its efrags chain. Still no idea why lights are drawing when they
shouldn't. Deek suggest holes in the map, but I think if that was the
case, there'd be something visible. My suspicion is I'm doing something
wrong in with efrags.
2023-08-10 09:38:42 +09:00
Bill Currie
0bcfa961b3 [vulkan] Up the size of the bsp index buffers
With three independent passes, it's possible to use up to 3 times the
indices.
2023-08-10 09:37:07 +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
d9c6db8865 [vulkan] Create a window for selected entities
Now the mouse-picking is starting to get useful. The window for an
entity shows its attached components (and their data if a function is
available).
2023-08-08 17:12:39 +09:00
Bill Currie
44c1ef5968 [vulkan] Correct the size of cone splats
I really don't know what I was thinking when I wrote that code. Maybe I
was trying for a half angle. Now the rendered "cone" matches up with a
hard-clipped cone light (soft edges stick out a bit).
2023-08-08 16:00:24 +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
35e2ffb4ab [console] Release the mouse when showing the mouse
This makes mouse grabbing much less painful.
2023-08-06 12:57:22 +09:00
Bill Currie
be5ab7b864 [renderer] Add a comment about the start map issue
I spent way too long tracking down the easy teleporter disappearing only
to realize it might be the watervised map. After moving it out of the
way and using id's maps, it works just fine.
2023-08-06 02:32:11 +09:00
Bill Currie
42ce1f1a86 [renderer] Fix a silly double set test
No wonder the final changes didn't make as much difference as I
expected.
2023-08-06 00:21:54 +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
452459297d [vulkan] Remove hard-coded shadow bias
It didn't really work all that well and isn't necessary with the
front-face culling. One less op per pixel.
2023-08-05 19:59:53 +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
f77ad8a676 [vulkan] Use front-face culling for shadow passes
This clears up the shadow acne, but does cause problems with lights
inside models. However, this can be fixed by setting the models to not
cast shadows.
2023-08-05 13:22:29 +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
0d4ffb02bc [vulkan] Avoid drawing too many dynamic lights
Trying to draw too many dynamic lights results in various crashes due to
the resources being preallocated.
2023-08-05 01:25:26 +09:00