Commit graph

14501 commits

Author SHA1 Message Date
Bill Currie
164c949796 [plist] Add a test mode to get parse timings
It turns out parsing runs at about 40-55MB/s, but that may be down to
allocations.
2024-10-19 02:19:01 +09:00
Bill Currie
d780146be3 [plist] Fix json parsing and test
It turns out my test was backwards: it fed the json text into a string
object then pulled it out, which of course round-tripped correctly. Now
things do round-trip correctly, but I had to ignore white-space
differences and edit the numbers as text->double->text doesn't
necessarily round-trip well (though double->text->double does with 17
digits).
2024-10-19 02:15:27 +09:00
Bill Currie
cb0eeb9366 [vulkan] Remove duplicate descriptor set layout
Don't need two identical descriptor set layouts for particles.
2024-10-19 00:28:27 +09:00
Bill Currie
427d239008 [simd] Fix uninitialized warning hidden by lto
It turns out lto was hiding an uninitialized warning that showed up with
gcc-14.
2024-10-17 11:03:03 +09:00
Bill Currie
6db1942bb1 [qfcc] Make max_params a code option
Rather than relying on progsversion (I think this also fixes a bug with
max params when targeting ruamoko).
2024-10-11 10:01:45 +09:00
Bill Currie
f3181d64d0 [qfcc] Remove strange split in function arg handling
I don't know why the last argument was handled differently. I suspect it
was a hold-over from before I added list handling. Removing it seems to
have made no significant difference (all tests pass still).
2024-10-10 19:17:24 +09:00
Bill Currie
a0e4aa487f [ui] Pass text verticality and font to configure_textview
They're not actually used yet because all the calculations are giving me
a headache, but the improved handling of text direction in
Text_PassageView, along with passing the information, is important
enough, I think.
2024-10-10 14:09:24 +09:00
Bill Currie
d72113f5cb [qfcc] Select correct generic function for references
When the parameter is a reference, implicit casting is not allowed, but
when the parameter is by value and the argument is a reference, the
argument is dereferenced and promotion is allowed.

However, this covers only the selection of generic functions. It doesn't
deal with otherwise overloaded functions, nor does it do the actual
dereferencing or address taking.
2024-10-09 13:33:38 +09:00
Bill Currie
421796b9ea [qfcc] Unalias type before checking for pointer/reference
Before adding references, looking at just type.type was ok whether or
not the type was an alias, but checking the deref flag needs the type to
be basic and not alias.
2024-10-09 11:31:00 +09:00
Bill Currie
a61e20ab20 [qfcc] Add parameters to spir-v function scopes
Simple functions now get to the code-gen phase (where they fail since
it's the wrong for other reasons). Parameter types aren't right for
spir-v yet as non-const params need to be references.
2024-10-08 11:58:24 +09:00
Bill Currie
9cd480640d [qfcc] Defer return expressions 2024-10-08 11:46:52 +09:00
Bill Currie
c3f11ba754 [qfcc] Add basic (type) support for references
I realized that spir-v pointers are essentially references (the way
they're used) since OpVariable requires a pointer type rather than the
base type. Thus, under the hood, references are just pointers with
automatic dereferencing. However, nothing uses references yet, and I
expect to run into issues with is_pointer vs is_reference vs is_ptr
(high-level pointer, reference, low-level pointer, respectively).
2024-10-08 11:45:51 +09:00
Bill Currie
dc878dbb4c [qfcc] Skip scope creation for function bodies
Since begin_function creates the parameter and locals scopes, there's no
need for another scope for the function body. This fixes the detection
of shadowed parameters for Ruamoko and QuakeC.
2024-10-07 09:55:21 +09:00
Bill Currie
3c7bd275f3 [qfcc] Detect shadowed parameters in glsl
Unfortunately, it breaks detection in Ruamoko and QuakeC.
2024-10-07 09:51:03 +09:00
Bill Currie
dae442c91e [qfcc] Move function scope building into target
This nicely separates Ruamoko and V6p function scope creation, and then
makes spir-v's a no-op (for now).
2024-10-07 09:48:44 +09:00
Bill Currie
0bc58246b1 [qfcc] Add a passing test for shadowed params
It's currently passing for Ruamoko, but glsl doesn't catch shadowed
params. There's a bit of a conflict and I want to make sure I don't lose
the checking.
2024-10-07 09:29:14 +09:00
Bill Currie
0cf8e7cb41 [qfcc] Start properly separating target code
I'd gotten tired of all the convoluted progs version checks, and with
the addition of spirv, they're not even always relevant, and adding C
(when I get to it) will make things even worse. However, for now the
first victim is just the parameter/return value size check.
2024-10-06 14:29:02 +09:00
Bill Currie
e7401c5ff4 [vulkan] Regenerate mips for transparent textures
BSP textures have pre-generated mips, including the transparent
textures, but mips don't play nicely with the transparency color (255):
it gets blended to other colors (at least in ad tears). Regenerating the
mips from the rgba texture (using transparent black) produces nice
results.

Also, needed to discard on 0 alpha to avoid weird interactions with fog
(I didn't know ad tears had fog: I guess I had last loaded it before
implementing fog).
2024-10-04 22:10:08 +09:00
Bill Currie
d46620fcf4 [qfcc] Add declaration expressions
Now declarations can be deferred too, thus things like generic/template
and inline functions should be possible. However, the most important
thing is this is a step towards a cleaner middle layer for compilation,
separating front-end language from back-end code-gen.
2024-10-04 11:51:34 +09:00
Bill Currie
8b9333e108 [qfcc] Remove union hack for block expressions
I don't remember why I thought it was a good idea at the time, but I
decided that having the union was a bit iffy and making the list
"official" would be a good idea. In the end, it removed a nice chunk of
code (redundant list manipulations).
2024-10-03 19:11:49 +09:00
Bill Currie
dcd2505bb9 [qfcc] Align cast operands
I'm surprised alignment didn't bite me earlier. Fixes a surprise
segfault in vecconst.r.
2024-10-03 19:11:49 +09:00
Bill Currie
8853d56af3 [qfcc] Ensure only one type def for functions
Only aggregate types are allowed to have duplicate type definitions. It
seems I forgot to do the id check for function types.
2024-10-02 02:12:07 +09:00
Bill Currie
56f8e19f63 [qfcc] Implement specialization constants
And they even pass validation (though it turns out there's a bug in
glslangValidator regarding specialization constants with expressions (or
possibly spirv-val, but it seems to be the former as my bug report shows
signs of activity in that direction)).

https://github.com/KhronosGroup/glslang/issues/3748
2024-10-02 02:11:53 +09:00
Bill Currie
a7639a685e [qfcc] Add field and array expression types
And implement enough AST processing to compile fstrianglest.vert

Plenty of code-gen issues, though.
2024-10-02 02:01:33 +09:00
Bill Currie
feca9bd5cb [qfcc] Rename new_field_expr to new_deffield_expr
I want to use new_field_expr for specialized field expressions instead.
However, I don't particularly like new_deffield_expr as a name, but I
can't think of anything better just yet.
2024-10-02 01:52:34 +09:00
Bill Currie
5a9ef35199 [qfcc] Add constexpr initializers to the ctor list
So far, this affects only glsl (because only glsl marks expressions as
constexpr), but it does get specialization constant initializers for
global variables working.
2024-10-01 17:10:00 +09:00
Bill Currie
f73e1bf353 [qfcc] Move ctor creation out of class_finish_module
Now, ctor expressions are collected and emitted after all other code,
and the ctor function being created outside of class_finish_module means
it's no longer limited to just class related initialization.
2024-10-01 16:51:49 +09:00
Bill Currie
3af078628e [qfcc] Preserve symbol expressions when constexpr
This prevents them from getting folded out of existence and thus
impossible to specialize.
2024-10-01 14:42:30 +09:00
Bill Currie
491b612888 [qfcc] Avoid (null) labels for dot graphs
I got tired of seeing it when looking at debug dumps of expressions.
2024-10-01 14:30:09 +09:00
Bill Currie
fc4e8cb350 [qfcc] Switch to deferred expressions for glsl
I plan to do this eventually for Ruamoko, but I need it to keep working
for now; it's rather nice having multiple languages. I expect this will
open up a lot of options for inlining, generic/template function
instantiation, etc. Right now, it's helping with specialization
constants in glsl.
2024-10-01 14:30:09 +09:00
Bill Currie
a97fc8154a [qfcc] Set all the commutativity flags
Including anti-commutativity. I hadn't set them before because I was
uncertain and got conflicting answers, but when I took a look again, it
seems IEEE 754 does guarantee commutativity for multiplication and
addition, so long as NaN isn't involved (and then it seems to be because
`a==a` is always false when a is a NaN).
2024-09-30 19:23:37 +09:00
Bill Currie
eade7e9a85 [qfcc] Add anti-commutative flags for cross and fp sub
They're still not set, but the commutativity can be adjusted
individually.
2024-09-30 19:23:37 +09:00
Bill Currie
275201afdf [qfcc] Optimize negating anti-commutative operations
Both for geometric algebra and in general (since it's just in
unary_expr). However, it doesn't quite work for float stuff (eg,
`vector × vector`, but that's only because the anti-commutative flag
isn't set.
2024-09-30 19:23:37 +09:00
Bill Currie
9797dcb5de [qfcc] Optimize (a+a)/2 in geometric algebra expressions
Really, I need to look into getting the optimizations more general, but
`a × ⋆a` is now just a single cross product instead off cross, add and
divide.
2024-09-30 19:23:37 +09:00
Bill Currie
b00d4d3b5b [qfcc] Respect parentheses when scattering sums
It may not be ideal at all times, but it does conform better with
general requirements for floating-point math.
2024-09-30 13:51:52 +09:00
Bill Currie
91febd50c6 [win] Fix some bitrot for building
Needed an option to disable LTO, and a couple of errors that crept in
with preprocessor and vulkan improvements.
2024-09-24 19:49:41 +09:00
Bill Currie
46a0be837e [vulkan] Check qfv_matrix_buffer_t size
Instead of forcing it via unnecessary alignment. I didn't feel like
using aligned malloc to silence ubsan when really the alignment was just
to force the size to be aligned.
2024-09-24 11:35:22 +09:00
Bill Currie
83c65e6abd [vulkan] Deal with some ubsan complaints
One is potentially legit (depends on what really happens when allocating
0-length arrays on the stack), but the offset null pointer ones are
dubious as `a` should never be null when `size` is non-zero, and when
`size` is zero, everything gets corrected.
2024-09-24 11:31:36 +09:00
Bill Currie
9713e7764c [input] Plug some potential UB
More "null pointer but zero size", but with library code, who knows?
2024-09-24 11:28:59 +09:00
Bill Currie
f4d8af400e [qfcc] Apply suspenders and a belt to the dimension check
Maybe there's a different trick to making gcc see that the dimension was
already check, but this works nicely size if the two calculations
differ, there are bigger problems.
2024-09-24 11:17:01 +09:00
Bill Currie
5a928581ab [vkgen] Fix parsing of actual bool types
Switching to native ruamoko bool for vkgen resulted in bool getting
incorrectly parsed as a string (which mean getting the string's address
written to the value). Fixes the randomly enabled debug pipelines (and
probably a few randomly disabled normal pipelines, though less likely as
they're usually implicitly initialized). The one bit of actual legit UB
(ie, that which wasn't immediately mitigated one way or another) found
by ubsan, and it was a data error.
2024-09-24 11:09:10 +09:00
Bill Currie
23e2fff44a [cexpr] Correct bool's backing value type
Using int instead of bool probably won't work well if QF ever finds
itself on a big-endian system again.
2024-09-24 11:07:32 +09:00
Bill Currie
c0f4a2143f [net] Always allocate memory for ifaces
Pointing ifaces at myAddr doesn't end well when nq exits (free doesn't
like it).
2024-09-24 11:04:27 +09:00
Bill Currie
6f03b4a65f [console] Use aligned malloc for menu progs
Fixes ubsan's (random!) complaints about memblock not being aligned. I
should probably look into making the progs loader code ensure the memory
is aligned itself.
2024-09-24 10:58:47 +09:00
Bill Currie
399c0ec17f [zone] Use a static_assert for retain's offset
I'd written the old version long before static_assert was available in
C.
2024-09-24 10:57:01 +09:00
Bill Currie
867e49980f Fix some dodgy shifts
While I guess ubsan is right that shifting a 1 bit into the sign of an
int can cause problems, but that's assuming the int is numeric. And it
doesn't help that unsigned char promotes to int instead of unsigned int.
2024-09-24 10:54:17 +09:00
Bill Currie
e3d403cada [vulkan] Mark read-only buffers as such
Recent vulkan validation layers started complaining about vertex
processing stages having read-write buffers without atomics enabled
(fair enough), but I decided to get all the buffers that don't need to
be written.
2024-09-24 10:44:59 +09:00
Bill Currie
594ba86aae [qfcc] Start emitting spir-v expression instructions
They're currently wrong since they're meant to be for specialization
constants (and that whole system is currently broken anyway) but are
instead raw code expressions, but progress is progress.
2024-09-23 18:56:18 +09:00
Bill Currie
5c9ba80d3a [qfcc] Rewrite unary_expr to be more maintainable
Result type and constant handling is now table-driven, resulting in the
removal of seven switch statements (and thus a lot less hassle when
extending types or expressions). Also, (u)long and (u)short are fully
implemented.

In addition, other than result type handing for boolean results, any
back-end specific implementation is now in the back-end.
2024-09-22 16:21:21 +09:00
Bill Currie
f5d3507819 [qfcc] Split out unary_expr to its own file
The plan is to clean up unary_expr like binary_expr.
2024-09-22 12:44:12 +09:00