Bill Currie
db8c9b6a03
[qfcc] Handle non-generic inlined functions
...
They too need a new function descriptor every time.
2025-01-21 14:46:32 +09:00
Bill Currie
60faf7c4b2
[qfcc] Solve the mysterious missing not
...
I'd goofed and made the identifier `NOT`. Oops.
2025-01-21 13:35:47 +09:00
Bill Currie
9e3e826338
[qfcc] "Implement" a pile more GLSL functions
...
`not` isn't working for some reason.
2025-01-21 13:26:15 +09:00
Bill Currie
bfed441045
[qfcc] Handle list expressions in spirv codegen
...
It seems they get there in declarations in inline functions. I decided
it's not worth worrying about for now.
2025-01-21 13:25:02 +09:00
Bill Currie
b25e64591f
[qfcc] Print auto
for auto type declarations
...
Better than an ICE :P
2025-01-21 13:24:32 +09:00
Bill Currie
f4cbe3f220
[qfcc] Ensure compute shaders set all local_size elements
...
The default value is 1, and the assumption in target_spirv is that if
the first one is set, all are set, but the source code doesn't need to
set any explicitly.
2025-01-21 12:14:06 +09:00
Bill Currie
622be33e4b
[qfcc] Fix a complete brainfart with strcmp
...
Doing <= when I wanted != caused some very strange behavior with
valgrind and bsearch. Also, going with negative logic rather than
positive logic is probably the cause of the brainfart.
2025-01-21 11:50:49 +09:00
Bill Currie
809cffa3a8
[qfcc] Quieten ubsan
...
0-length arrays certainly would be UB if I tried using them, but I guess
ubsan isn't smart enough for that.
2025-01-21 11:09:00 +09:00
Bill Currie
74f973cddc
[qfcc] Mark is_auto as const
...
All it checks is the addres, so yeah. (I guess it's lto vs no lto)
2025-01-21 11:08:35 +09:00
Bill Currie
fb7025dbd3
[qfcc] Handle execution modes for spir-v/glsl
...
This means that `layout(triangles)` etc now work, though there are
issues with frag shaders missing functions (since getting function calls
working) and compute shaders silently failing.
2025-01-21 10:42:56 +09:00
Bill Currie
105edc5126
[qfcc] Don't allow overloading of main for glsl
...
It's supposed to always be void(void), so...
2025-01-20 22:10:27 +09:00
Bill Currie
21cf636875
[qtypes] Remove field_offset macro
...
And use offsetof instead: it has been standard (enough) in C for a
while.
2025-01-20 20:57:54 +09:00
Bill Currie
9beb0093e6
[qfcc] Skip res type/id for void intrinsics
...
But only for non-extension. I'm not sure it's quite right (as I don't
know if all void intrinsics should not have res type/id (all extension
instructions *do*)).
2025-01-20 15:44:47 +09:00
Bill Currie
5248e5a4ed
[qfcc] Emit base vulkan capabilities
...
I probably missed some, and I should make the emission more selective,
but my vertex shaders all pass spirv-val (probably don't work, though).
2025-01-20 15:03:27 +09:00
Bill Currie
1f0d7f249c
[qfcc] Move countof macro to qtypes
...
It makes it more accessible and easy to remove when it (or equivalent)
becomes standard in C.
2025-01-20 15:02:21 +09:00
Bill Currie
0ecd8f06bd
[cexpr] Add support for long and ulong types
...
As int64_t and uint64_t. This gets everything building again.
2025-01-20 14:22:44 +09:00
Bill Currie
ea1c0a012b
[cexpr] Correct size_t op types
...
I probably missed changing those unsigned types to size_t. Yay
case&paste programming :P
2025-01-20 14:18:31 +09:00
Bill Currie
1e052ad0dc
[vkgen] Use correct types for 64-bit types
...
When I wrote vkgen's stdint.h, qfcc didn't support long or ulong, and
with the common init check, it now matters that the correct types are
used. It turns out some of my structs may not have been initialized
correctly, but with the next commits (long and ulong for cexpr), they
should be but do seem to be working at least.
2025-01-20 14:18:15 +09:00
Bill Currie
97a0763766
[qfcc] Do initializer type checking in declare_symbol
...
This is a nice common place (all languages and targets use it) for the
warning and any conversions, though those are still spread in various
places (and need to be cleaned up), so it doesn't do all that much yet.
2025-01-20 14:08:36 +09:00
Bill Currie
133156fdc7
[qfcc] Use OpBitcast for alias exprs in spirv
...
Really, just implementing it properly.
2025-01-20 14:04:19 +09:00
Bill Currie
54231b21ed
[qfcc] Add an is_auto helper function
...
It's cleaner than type == &type_auto and will allow me to check that
`auto` hasn't been aliased or something like that.
2025-01-20 12:26:57 +09:00
Bill Currie
a922088c1c
[qfcc] Correct explicit lod's 0
...
It needs to be a float, not an int.
2025-01-20 11:42:25 +09:00
Bill Currie
16b04512cb
[qfcc] Support marking expression for the back-end
...
The spir-v back-end needs to emit literal values in some places and
supporting that in explicit intrinsics required marking the expression
as special. Unary = seems a little odd at first, but at the same time
seems to make sense, especially for marking expressions as "use literal
value" (eg =ImageOperands.Lod will result in a literal 2 instead of an
op id that points to the 2).
2025-01-20 11:26:20 +09:00
Bill Currie
3a521ebe16
[qfcc] Support uint and enum in expr_int
...
Signed or unsigned isn't that important for internal errors.
2025-01-20 11:25:22 +09:00
Bill Currie
332c991064
[qfcc] Do type promotions for conditional expressions
...
Where possible of course, but the two results need to have the same
type. When not possible, an error is generated.
2025-01-20 10:17:01 +09:00
Bill Currie
b1389ddb79
[qfcc] Emit all called functions for spir-v
...
The functions get queued up if they haven't already been assigned an id.
2025-01-20 10:15:42 +09:00
Bill Currie
d10da51a1f
[qfcc] Put unary expressions into the dag
...
Missed optimization opportunities.
2025-01-20 09:56:44 +09:00
Bill Currie
495a1c7994
[qfcc] Dereference explicit intrinsic arg references
...
The dereferencing was done for implicit intrinsic args, but I had
forgotten about it for explicit intrinsics. Now the scalar `a` version
of `mix` works.
2025-01-20 09:06:38 +09:00
Bill Currie
498288b630
[build] Fix some distcheck issues
...
Let's do the distcheck again...
2025-01-20 08:33:57 +09:00
Bill Currie
96a6c91747
Merge branch 'wip-ruaspirv'
...
This is more a check-point merge to get the more general qfcc
improvements onto master, as well as several vulkan fixes.
2025-01-20 01:41:33 +09:00
Bill Currie
93991ce30d
[qfcc] Use the ruamoko test_expr for spirv
...
The two back-ends are mostly compatible for bools (just lbool is a minor
problem) so reusing the code makes sense.
2025-01-20 01:34:27 +09:00
Bill Currie
1e88fec72c
[qfcc] Promote enums so they can be used in math
2025-01-20 01:33:18 +09:00
Bill Currie
f92ab4f64b
[qfcc] Make pointer-function casts two-way
...
This fixes the cast for the think function in game-source/fbxa.
2025-01-20 00:57:54 +09:00
Bill Currie
c88820c31e
[qfcc] Split test_expr per target
...
While there's a bit of code duplication, it very much cleans things up
for the various targets, especially v6 progs. However, spirv is not
implemented yet, so that's broken again.
2025-01-20 00:55:01 +09:00
Bill Currie
0143a2410c
[qfcc] Use const type_t * for new_horizontal_expr
...
It was missed in the type_t const-correctness pass.
2025-01-20 00:51:38 +09:00
Bill Currie
f511bb31c5
[qfcc] Fix a typo in a comment
2025-01-20 00:50:09 +09:00
Bill Currie
21868d4a38
[qfcc] Don't try to vectorize vector/quaternion unary results
...
matrix_type doesn't like it and it's wrong anyway.
2025-01-18 23:15:29 +09:00
Bill Currie
1ec97632e6
[qfcc] Handle general types in boolean expressions
...
Probably need language-specific checks (eg, glsl doesn't accept anything
but bool for && etc).
2025-01-18 23:13:55 +09:00
Bill Currie
d3bcd0c3a3
[qfcc] Dump message expression dots
2025-01-18 23:12:47 +09:00
Bill Currie
f713d53fb6
[qfcc] Allow local/param function variables
...
I thought that was needed, but wasn't sure. It is :P.
2025-01-18 20:51:47 +09:00
Bill Currie
d05fcecae4
[qfcc] Handle storage blocks for parameters
...
Klik is the only code base that uses them, so the param storage class
check got confused by them.
2025-01-18 20:48:40 +09:00
Bill Currie
df04a37a8c
[qfcc] Count terms correctly
...
Parentheses confused the term counting because they weren't taken into
account for the "neither expression can be split" check, resulting in a
later segfault due to walking off the end of the array.
2025-01-18 20:47:06 +09:00
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
77158130ca
[qfcc] Flush dags aggressively for if statements
...
I'm sure there are more places that need flushing, but this gets
game-code/quakeworld building.
2025-01-18 20:36:23 +09:00
Bill Currie
fd52c055e0
[qfcc] Default math.vector_mult correctly
...
The check was bogus in that it had `!val == 0` for non-traditional, and
was checking the wrong spot for traditional.
2025-01-18 20:36:23 +09:00
Bill Currie
974306fa12
[gamesource] Correct columns for bitops
...
bitnot doesn't use operand b so its columns needs to be 0, not 1.
2025-01-18 20:36:23 +09:00
Bill Currie
2c204d40b2
[qfcc] Check const_initializers option for constexpr
...
This is probably not right for spir-v, but it fixes initialized defs in
switch case labels (qc legacy with the defs).
2025-01-18 20:36:23 +09:00
Bill Currie
2cf14e13ec
[qfcc] Process state frame and step expressions
...
Just a victim of the deferred processing. `think` can't be processed
because it can act as a forward declaration (qc legacy).
2025-01-18 15:24:46 +09:00
Bill Currie
3881147210
[qfcc] Check return value for null in has_function_call
...
Avoids a segfault when dagging. I'm not sure how a switch statement got
into the dags, but still don't want a segfault there.
2025-01-18 15:23:37 +09:00
Bill Currie
8d69dd85eb
[qfcc] Allow some mixing of vector/quaternion types
...
That is, vector ops with 3-component general vectors and quaternion ops
with 3 and 4 component general vectors "promote" the general vectors to
vector or quaternion as appropriate. Needed for operations with
vector and quaternion literals.
2025-01-18 15:20:59 +09:00