Commit graph

14310 commits

Author SHA1 Message Date
Bill Currie
b935540d19 [qfcc] Remove qc special function symbol functions
It turns out they're not needed as the difficulty of quakec function
declarations (function fields) is taken care of by qc_function_spec.
Also, they made it difficult to think about function declarations.
2024-05-04 22:08:38 +09:00
Bill Currie
28bba12e87 [qfcc] Rename some functions
One a typo, the other for better consistency.
2024-05-04 10:50:08 +09:00
Bill Currie
1567f29668 [qfcc] Handle type expressions when merging specifiers
The type expressions no longer get lost along the way to the function
return type and parameter types.
2024-05-03 19:43:58 +09:00
Bill Currie
aff70aa243 [qfcc] Support static type expressions in declarations
This allows types in declarations to be based on other types:

    int foo[3];
    @vector(float,sizeof(foo)) bar;
2024-05-03 19:37:11 +09:00
Bill Currie
fed1bce12a [qfcc] Add a function to check for error expressions
I haven't gone through and replaced all the existing tests, but hiding
the details makes sense and fits with many of the other check functions.
2024-04-30 11:16:27 +09:00
Bill Currie
f7bf77c2b7 [qfcc] Support type expressions in dot output
The graph isn't great, but it's better than invalid expression nodes.
2024-04-30 11:16:27 +09:00
Bill Currie
60730a5b12 [qfcc] Prevent dags in type expressions
While they might be ok, I expect them to cause some issues when doing
compile-time evaluations of type expressions, so use of dags seems to be
a premature optimization. However, as the "no dags" flag is propagated
to parent expression nodes, it may prove useful in other contexts.
2024-04-30 10:58:51 +09:00
Bill Currie
966275c294 [qfcc] Remove symbol field from param_t
I have no idea what it was for as nothing actually uses it.
2024-04-26 23:24:32 +09:00
Bill Currie
e8da9924c0 [qfcc] Rework type expression handling
The expression grammar has been tidied up and some basic checks are made
of parameters to the type functions. Also, type parameters are looked up
so parsing now works properly. However, the type parameters are not used
correctly, so function generation doesn't work.
2024-04-26 23:24:32 +09:00
Bill Currie
f7ed55d317 [qfcc] Use type expressions for generic types
This gets type lists and generic name references semi-implemented.
2024-04-26 07:59:21 +09:00
Bill Currie
434bcdebbb [qfcc] Add an expression type for types
No support functions yet, but this should make it easy to manipulate
type "expressions" in the parser for building generic functions.
2024-04-25 23:19:24 +09:00
Bill Currie
45d4b12e7a [qfcc] Implement generic type parsing
The semantics are only partially implemented (generic types not yet
generated), but the generic scope for function declarations seems to be
working as intended in that it gets inserted in the scope chain and
removed at the end of the declaration.
2024-04-25 16:10:43 +09:00
Bill Currie
029b8b1667 [qfcc] Implement vector_type via matrix_type
Since vectors are column matrices, this makes perfect sense and means
matrix_type always gets at least some testing.
2024-04-25 12:41:29 +09:00
Bill Currie
c70da4fc76 [qfcc] Chain matrix and bool types
Ruamoko doesn't really use either yet, but GLSL needs them and this
ironed out a lot of the issues related to adding the types.
2024-04-25 11:22:35 +09:00
Bill Currie
86b3d0db7b [qfcc] Add parameterized types to Ruamoko
The end goal is to allow generic and/or template functions, but this
allows types to be specified parametrically, eg vectors of specific type
and width, with widths of one becoming scalars.

Matrices are currently completely broken as I haven't decided on how to
represent the columns (rows is represented by width (column-major
storage)), and bools are only partially supported (need to sort out
32-bit vs 64-bit bools).
2024-04-24 15:51:29 +09:00
Bill Currie
bdac574e69 [console] Avoid reliance on signedness of char
It turns out char defaults to unsigned on arm (using gcc, at least).
Avoid the issue completely by checking the bit rather than the sign.
2024-04-24 08:30:37 +09:00
Bill Currie
f3d3bc8ec1 [qfcc] Implement glsl field and swizzle expressions
Ruamoko should have swizzles as well since the same underlying code is
used.
2024-04-22 11:28:13 +09:00
Bill Currie
953be00a72 [qfcc] Use appropriate result type for swizzles
Swizzles now result in a vector of the same width as the swizzle itself
rather than the source vector.
2024-04-22 11:25:10 +09:00
Bill Currie
2bc7cc3d22 [qfcc] Implement a lot of glsl's semantics
Not everything yet, but enough to get type errors in expressions (due to
swizzles not working).
2024-04-22 09:42:02 +09:00
Bill Currie
c62d14da60 [qfcc] Fix some white space 2024-04-22 09:36:47 +09:00
Bill Currie
2dd23f429a [qfcc] Implement glsl syntax
No semantics yet, but qfcc can parse some of QF's shaders. The grammar
mostly follows that in the OpenGL Shading Language, Version 4.60.7 spec,
but with a few less tokens.
2024-04-19 13:54:03 +09:00
Bill Currie
b798cb2603 [qfcc] Move qc/ruamoko keywords into qc-parse.y
This seems to be the right way to go for sharing tokenisation between
Ruamoko and GLSL, while supporting preprocessing for both.
2024-04-19 00:49:47 +09:00
Bill Currie
d1c4c59a57 [qfcc] Handle floats starting with .
eg, .25

My test scene has such a value. Obviously, I'd never compiled it on this
branch since adding PGA physics.
2024-04-18 23:52:52 +09:00
Bill Currie
75e293789a [vulkan] Fix yet another sync validation error
*sigh*
2024-04-18 23:22:26 +09:00
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