Commit graph

14336 commits

Author SHA1 Message Date
Bill Currie
95a50fefa2 [qfcc] Aggressively cancel terms
While it currently doesn't have any effect on generated code, it proved
to be necessary when experimenting with optimizing the operand of extend
expressions (which proved to produce worse code).

Along with some 0 -> nullptr changes.
2024-04-18 22:46:13 +09:00
Bill Currie
4daa84ed2a [qfcc] Force @return to be live
The change to not split basic blocks on function calls resulted in the
@return def not being live and thus getting dropped when optimizing.
Marking the def as not local forces flow and dags to treat it as global
and thus forced it to be live.
2024-04-18 22:46:13 +09:00
Bill Currie
e7930305cc [qfcc] Add a failing test case for forward return
ProxyView in qwaq's ui stopped working because of the basic block
changes for function calls.
2024-04-18 22:46:13 +09:00
Bill Currie
f390089e66 [qfcc] Treat invalid initialization as just an error
I'm not sure why I treated it as an internal error.
2024-04-18 22:46:13 +09:00
Bill Currie
2471147488 [gamecode] Save return pointer when saving params
And point the return pointer at the return buffer. And, of course,
restore it. This fixes a really subtle (ie, difficult to find) bug
caused by the recent optimization improvements in qfcc: the optimizer
had decided to set the return value of a message call to the parameter
for the next call, but because the message was to the receiver class for
the first time, the class's +initialize was called. The +initialize
method returned self, which of course when into the parameter for the
*next* call, but the first call hadn't been made, so its parameter got
corrupted.
2024-04-18 22:46:13 +09:00
Bill Currie
5191fc26a3 [qfcc] Unify much of the qc and glsl parser interface
This gets the types such that either there is only one definition, or C
sees the same name for what is essentially the same type despite there
being multiple local definitions.
2024-04-18 12:41:24 +09:00
Bill Currie
6266ac4d94 [qfcc] Fix some debian flex incompatibilities
I need upstream flex for its line handling and nicer interface, but
debian's flex is ancient and stuck with the legacy interface, and I want
QF to be buildable on at least sid.
2024-04-18 10:34:18 +09:00
Bill Currie
4e2d713400 [vulkan] Optionally include vertex shader in tex update
The particle renderer uses the palette texture in the vertex shader, so
updating the palette needs the vertex shader stage included in the
barrier, but I imagine not all texture updates will need it, so add a
parameter to Vulkan_UpdateTex to select inclusion.
2024-04-18 10:16:44 +09:00
Bill Currie
b632d1dc52 [vulkan] Fix some more sync validation errors
These were a little harder to find, especially the lighting ones.
2024-04-18 10:03:26 +09:00
Bill Currie
61e6332473 [vulkan] Fix a pile of synchronization issues
Recent changes to the validation layers got more aggressive in their
checks and found a bunch of incorrect barriers (and some missing ones).
2024-04-18 10:03:26 +09:00
Bill Currie
e0d9410469 [vulkan] Add support for external subpasses
However, they're really for specifying external destination subpass
dependencies in order to ensure subpass transitions happen at the right
time.
2024-04-18 10:03:26 +09:00
Bill Currie
ceece02aa4 [vulkan] Reduce max shadow views to 17
Recent nvidia drivers now crash with more than 17 views when building
pipelines. Still no idea if it's me or the drivers. However, I really
need to come up with a way to use the render graph render passes as a
template so things aren't so hard-coded.
2024-04-18 10:03:26 +09:00
Bill Currie
2f8ffc4862 Merge branch 'master' into wip-ruaspirv 2024-04-18 09:46:10 +09:00
Bill Currie
2d362c445c [qfcc] Move keyword and directive structs
The end goal is to share the tokenisation between the C-like languages,
and maybe even Pascal.
2024-04-17 18:17:08 +09:00
Bill Currie
56f0c3f821 [qfcc] Create a parser file for GLSL
The syntax is not at all correct at this stage (really, just a copy of
Ruamoko), but the keyword table exists (in the wrong place) and the
additional basic types (bool, bvecN and (d)matNxM) have been added.
Boolean base type is currently just int, and matrices have 0 width while
I think about what to use, but finally some progress after several
months' hiatus.
2024-04-17 16:25:43 +09:00
Bill Currie
ea77bed623 [skin] Fix weird fullbrights on gl models
All due to uninitialized data.
2024-02-25 14:45:46 +09:00
Bill Currie
44bb24bbaf [glsl] Add support for debug callback
It's disabled at compile time for now, but everything needed is there.
2024-02-25 11:12:10 +09:00
Bill Currie
e89afafc8f [util] Use uint16_t for crc16 2024-02-25 11:06:39 +09:00
Bill Currie
925dba732c [build] Add an option to enable ubsan
It's disabled by default because it's a runtime thing and I'm not sure I
want to keep it enabled, but it did find some issues (which I've cleaned
up), although it didn't find the problem I was looking for :P
2024-02-21 22:41:08 +09:00
Bill Currie
073c93eebf [qfcc] Don't split basic blocks on function calls
This allows the dags code to optimize the return values, and when I make
the node killing by function calls less aggressive, should make for many
more potential CSE optimizations.
2024-02-21 22:41:08 +09:00
Bill Currie
e298771d50 [ruamoko] Set the va_list parameter for error:
I'm not sure this is quite right, but at least now I get the right
runtime error (doesn't recognize instead of argc/format mismatch).
2024-02-21 22:41:08 +09:00
Bill Currie
03b2ee2a25 [qfcc] Delay creation of leaf nodes
Creating leaf nodes early gets in the way of supporting multi-call basic
blocks, and never really seemed right anyway.
2024-02-21 22:41:08 +09:00
Bill Currie
6d6a387a81 [qfcc] Treat move the same as assign in dags
This goes a long way towards allowing basic blocks to include multiple
function calls instead of always ending on a call.
2024-02-21 22:41:08 +09:00
Bill Currie
277feaeb03 [qfcc] Support multivector expression to/from functions
The multivector is first assigned to a temporary then passed or returned
as usual.
2024-02-21 22:41:08 +09:00
Bill Currie
389571cbbe [qfcc] Handle pointer dereferences in offset casts
Offset casts are used heavily in geometric algebra, but doing an offset
cast on a dereferenced pointer (array index) doesn't work well for
assignments. Fixes yet another bug in my test scene :)
2024-02-21 22:41:08 +09:00
Bill Currie
62221b2735 [qfcc] Set the source location for compound init elements
Finally, less bouncing to the compound initializer's closing brace line.
2024-02-21 22:41:08 +09:00
Bill Currie
2be9821a59 [qfcc] Use statement aux def if def not in operands
This takes care of ptrmove instructions, fixing the printf problem in
ptrstructinit. It might even make it possible to not break basic blocks
on function calls, which should make for some more optimization
opportunities, but that can come later.

For this to work properly, it was necessary to avoid converting alias
defs to st_alias nodes.

It also fixes ptrstructinit itself (at first, I hadn't noticed that the
test passed entirely).
2024-02-21 22:41:08 +09:00
Bill Currie
07ef862c52 [qfcc] Put problematic printf into ptrstructinit
It turns out the bug I was chasing in set_poses was not the data getting
lost or incorrect data being read, but the arguments to printf being set
from the parent pose `p` before `p` had actually been set.
2024-02-21 22:41:08 +09:00
Bill Currie
00781160e2 [qfcc] Remove the node from its own edges
This gets rid of the funny little self-loop edge in dags dot files that
has bothered me for a while. It was just because the node to which an
identifier was attached happened to be the parent of the identifier's
leaf node.
2024-02-21 22:41:08 +09:00
Bill Currie
b842913ca9 [qfcc] Remove special treatment for flow/func statements
The fix in bdafdad0d5 for
`while (count--)` never did appeal to me. I think I understood the core
problem at the time, but I hadn't figured out how to use a var's
use/define sets to detect the write-before-read. Using them allows the
special handling for flow control to be removed, making things more
robust. The function call handling has been superfluous since the
Ruamoko instruction set required the auxiliary operands on the call
statements.
2024-02-21 22:41:08 +09:00
Bill Currie
1fb4a556d7 [qfcc] Remove old ptrmove code from dag creation
It doesn't seem to help any, and removing it doesn't break anything
(that is tested), and I'm working on better handling of ptrmove support.
2024-02-21 22:41:08 +09:00
Bill Currie
9a38cdfd78 [qfcc] Clean up dag item counting and init
Not by much really, but using one "aux" count instead of different
types, and using functions to iterate through the statement's aux
operands makes the code easier to read.
2024-02-21 22:41:08 +09:00
Bill Currie
768113d37b [qfcc] Replace expr_file_line with a scoped version
Two birds with one stone: eliminates most of the problems with going
const-correct with expr_t, and it make dealing with internally generated
expressions at random locations much easier as the set source location
affects all new expressions created within that scope, to any depth.
Debug output is much easier to read now.
2024-02-21 22:41:08 +09:00
Bill Currie
a6b59d4a42 [util] Make FREE a little more macro-correct
That is, use ()s around uses of p
2024-02-21 22:41:08 +09:00
Bill Currie
6e8c98433a [qfcc] Fix a missed const type_t 2024-02-21 22:41:08 +09:00
Bill Currie
b9aad99381 [qfcc] Clean up warning and notice return types
They never needed to return expr.
2024-02-21 22:41:08 +09:00
Bill Currie
1df7674c65 [gamecode] Add a handle view
Handle type encodings aren't actually compatible with basic type
encodings as their width is always one and thus the tag field collides
with the basic type encoding's width field.
2024-02-21 22:41:08 +09:00
Bill Currie
d7a1bb5a01 [gamecode] Use designated initializer syntax for structs
Mostly for consistency with arrays, but also it may be useful for
cutting and pasting data.
2024-02-21 22:41:08 +09:00
Bill Currie
4576de816d [gamecode] Print array contents in pr_debug_array_view
This makes it much easier to check data in progs files.
2024-02-21 22:41:08 +09:00
Bill Currie
131ad9013c [qfcc] Tidy up expr_assign_copy a little
It proved that expr_assign_copy wasn't the cause of any problems, but I
cleaned up some of its types a little.
2024-02-21 22:41:08 +09:00
Bill Currie
35e2044bfa [qfcc] Fix nested compound initializers
Add static array indexing. This gets the compoundinit test working.
2024-02-21 22:41:08 +09:00
Bill Currie
19965e7cbd [qfcc] Add a failing test case for compound initializers
It turns out that compound intializers break on when the nesting level
increases (eg, initializing vectors in structs in arrays).
2024-02-21 22:41:08 +09:00
Bill Currie
1b4db639af [qfcc] Handle quaternion (in)equality tests
I'm surprised this didn't come up earlier.
2024-02-21 22:41:08 +09:00
Bill Currie
0e7c80e9fe [qfcc] Use ud-chains for ptrmove pointer analysis
ptrmove was not treating its indirect source operand as used because the
pointer wasn't checked for its source.

This fixes part of ptrstructinit, but there's a lot more breakage in
that test: it looks like all sorts of fun with arrays.
2024-02-21 22:41:08 +09:00
Bill Currie
ab69e65e02 [qfcc] Add failing test case for pointer struct initialization 2024-02-21 22:41:08 +09:00
Bill Currie
3a22091455 [qfcc] add pointer validity check function to test-harness 2024-02-21 22:41:08 +09:00
Bill Currie
192eb11235 [qfcc] Dereference most array types properly
This should prevent some fun bugs in the future (it's what necessitated
the const-correct patch).
2024-02-20 16:47:06 +09:00
Bill Currie
f0dfe47a32 [qfcc] Make type_t mostly const-correct
There were a few places where some const-casts were needed, but they're
localized to code that's supposed to manipulate types (but I do want to
come up with something to clean that up).
2024-02-20 16:47:04 +09:00
Bill Currie
6e71aadfa4 [qfcc] Use dereference_type for initialized arrays
In particular, when the size is inferred from the compound initializer.
Fixes a fun "incomplete type" error.
2024-02-20 16:46:02 +09:00
Bill Currie
fa5c3ab12e [qfcc] Support arrays in dereference_type
This is needed to get the correct type from arrays of typedefed
elements.
2024-02-20 16:46:02 +09:00