Commit graph

6125 commits

Author SHA1 Message Date
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