Commit graph

15 commits

Author SHA1 Message Date
Bill Currie
7dc1ab0ea8 [qfcc] Split up shift ops by target
v6 can't do shifts at all, and rua/spir-v can do only integral shifts.
2025-01-18 20:44:55 +09:00
Bill Currie
92727019b5 [qfcc] Split up vector/quaternion compare by target
The v6 and v6p targets don't have horizontal operations, instead they
have direct vector/quaternion equality to float/int scalar result. Fixes
an ice when building game-source/quake.
2025-01-18 14:06:27 +09:00
Bill Currie
a5272d2e05 [qfcc] Hook spir-v operand kinds into intrinsic scopes
The operand kinds form namespaces for their enumerants (only BitEnum and
ValueEnum operand kinds are supported for this). Now `Lod` and `Bias`
use `ImageOperands.Lod` and `ImageOperands.Bias`, which is probably a
big improvement in the long run.

Finally, all of QF's shaders *compile*, though the spir-v is generally
incorrect (capabilities etc), and the code gen may still be full of
bugs.
2025-01-18 13:15:05 +09:00
Bill Currie
213ac2a328 [qfcc] Use a context object to hold current language
Because the glsl front-end uses Ruamoko to compile its builtins, it
needs to switch languages, and the cleanest way to do so is to use a
context object that gets passed around. This removes not only the
current_language global, but also (as a bonus) any real references to
flex's scanner object (there's still a pointer in rua_ctx_t, but it's no
longer a parameter (which caused some pain in the change)).
2024-12-07 23:55:48 +09:00
Bill Currie
c5d77141eb [qfcc] Defer Ruamoko semantics processing
The main goal was to make it possible to give generic functions
definitions (since the code would be very dependent on the actual
parameter types), but will also allow for inline functions. It also
helped move a lot of the back-end dependent code out of semantics
processing and almost completely (if not completely) out of the parser.
Possibly more importantly, it gets the dags flushing out of the parser,
which means such is now shared by all front-ends.

There's probably a lot of dead code in expr.c now, but that can be taken
care of another time.
2024-12-07 02:38:00 +09:00
Bill Currie
9b2240aaf8 [qfcc] Implement vector expressions for spir-v
And fix a little goof with VectorShuffle (c&p coding bites again).
2024-11-18 14:55:32 +09:00
Bill Currie
28e8697ae6 [qfcc] Implement compound initializers for spir-v
They don't yet support designators, and vectors aren't treated the way I
want, but my little test works correctly.
2024-11-17 22:45:18 +09:00
Bill Currie
a7f9d96a02 [qfcc] Implement select (if) constructs
And break/continue too, since my test for them required select.
2024-11-16 23:13:46 +09:00
Bill Currie
bcfd1b7660 [qfcc] Split out the call related expression code
I've long felt build_function_call was getting a bit big, and expr.c
especially so. This should make it easier to rewrite build_function_call
for dealing with target-specific code. As a bonus, the int through ...
warning is already cleaned up.
2024-11-04 20:28:30 +09:00
Bill Currie
6358143795 [qfcc] Clean up the local_expr global
I never liked it and it made things a little difficult for spir-v.
2024-11-04 16:38:07 +09:00
Bill Currie
04560f61a6 [qfcc] Separate out backend variable declaration
This time, rua/v6p/v6 share the code properly, since it's only spirv
that needs something specific at this stage.
2024-11-03 18:06:25 +09:00
Bill Currie
c8fbb93424 [qfcc] Separate out backend function building
It turns out that emit_function should have been (something like)
build_code and had the stack/locals related code taken along with it.
2024-11-03 16:58:10 +09:00
Bill Currie
a22d2a9526 [qfcc] Move guts of emit_function to per-target code
Ruamoko and v6(p) have their own copies despite being (currently) the
same, and spir-v's is currently empty, but now targeting spir-v doesn't
try to emit ruamoko code.
2024-10-26 23:30:37 +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
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