Commit graph

13773 commits

Author SHA1 Message Date
Bill Currie
1cad355366 [qfcc] Write tests for 3d PGA geometric products
And fix the flood of errors.
2023-08-30 15:00:27 +09:00
Bill Currie
9bce0f8e4f [qfcc] Calculate multi-vector size correctly
The struct for multi-group multi-vectors cleans up that code and makes
the "calculation" much easier (since it's handled by the struct building
code).
2023-08-30 14:58:22 +09:00
Bill Currie
4c808fd254 [qfcc] Allow assignment to superset multi-vectors
If the destination multi-vector fully contains the source multi-vector,
then the assignment is ok (any missing values are zeroed).
2023-08-30 14:56:12 +09:00
Bill Currie
52eaa2fee7 [qfcc] Handle more vector type tests
That new_zero_expr is coming in handy. I should clean up expr_bool.c.
2023-08-30 14:52:38 +09:00
Bill Currie
719cf055a5 [qfcc] Check validity of field expressions
Even though I plan on making multi-vector types easier to use with field
accesses, getting segfaults doesn't help with debugging.
2023-08-29 21:37:41 +09:00
Bill Currie
a01cbd56fd [qfcc] Write tests for 3d PGA dot products
And fix the bugs that were uncovered.
2023-08-29 21:30:18 +09:00
Bill Currie
c42aaea060 [qfcc] Write tests for 3d PGA wedge products
And fix the discovered bugs.
2023-08-29 19:42:00 +09:00
Bill Currie
33295a8ad9 [qfcc] Use structs for multi-vector type layouts
Simple k-vectors don't use structs for their layout since they're just
an array of scalars, but having the structs for group sets or full
multi-vectors makes the system alignment agnostic.
2023-08-29 17:10:29 +09:00
Bill Currie
09cdf87f67 [qfcc] Used aligned type sizes for sizeof
And geometric algebra vectors. This does break things a little in GA,
but it does bring qfcc's C closer to standard C in that sizeof respects
the alignment of the type (very important for arrays).
2023-08-29 13:59:12 +09:00
Bill Currie
ad6b4057f9 [qfcc] Apply member alignment to union size
Seeing a union of size 7 when its members need an alignment of 4 was
rather a concern.
2023-08-29 08:25:19 +09:00
Bill Currie
e4391992cb [qfcc] Remove the internal error for null bool lists
It turns out that both lists can be null when applying short circuit
logic to constants.
2023-08-29 08:06:28 +09:00
Bill Currie
d6ec250897 [qfcc] Fix vector int tests
These too needed a horizontal or.
2023-08-29 08:04:32 +09:00
Bill Currie
327cb88af3 [qfcc] Demote implicit double vector literals correctly
The code for demoting the literals wasn't taking the width into account.
2023-08-29 08:02:11 +09:00
Bill Currie
8de722bfc7 [qfcc] Mark large products as unimplemented
Before I forget and wonder why they're not working.
2023-08-28 20:35:03 +09:00
Bill Currie
58a1758363 [qfcc] Implement the regressive product
That went surprisingly well (but it is built up from other ops, so
pretty easy, really).
2023-08-28 20:35:03 +09:00
Bill Currie
e2d812ab6a [qfcc] Implement multi-vector dual
It's implemented as the Hodge dual, which is probably reasonable until
people complain. Both ⋆ and ! are supported, though the former is a
little hard to see in Consola.
2023-08-28 20:35:03 +09:00
Bill Currie
1329a1c43a [qfcc] Implement multi-vector negation
That was surprisingly harder than expected due to recursion and a
not-so-good implementation in expr_negate (it went too high-level thus
resulting in multivec expressions getting to the code generator).
2023-08-28 17:00:14 +09:00
Bill Currie
6b1684b711 [qfcc] Implement mutli-vector division
But only for scalar divisors. The simple method of AB†/(BB†) works only
if B is a versor and there's also the problem of left and right
division. Thanks to sudgy for making me stop and think before I actually
implemented anything (though he mentioned only that it doesn't work for
general mutli-vector divisors).
2023-08-28 12:17:59 +09:00
Bill Currie
41e0483102 [qfcc] Read float/double vector literals correctly
Wow, I thought that had been tested. I guess that not vary many vector
literals used fractional values.
2023-08-28 12:06:25 +09:00
Bill Currie
5b1ce309ef [qfcc] Implement multi-vector reversion
For a change, something that's actually general rather than specific to
PGA.
2023-08-28 11:56:35 +09:00
Bill Currie
717b09f33e [qfcc] Fix vector long tests
And the discovered typos (yes, I double-checked the values) in the PGA
tests.
2023-08-27 18:40:40 +09:00
Bill Currie
55b7547451 [qfcc] Get the rest of the main 2d PGA products working
That was tedious. I can't say I'm looking forward to writing the tests
for 3d. And even though trivector . bivector and bivector . trivector
give the same answer, they're not really commutative when it comes to
the code.
2023-08-27 15:24:35 +09:00
Bill Currie
5aea74de7e [qfcc] Show algebra signature for bad basis blades
Clear error messages are always more helpful than opaque ones.
2023-08-27 15:17:22 +09:00
Bill Currie
c7d6e80d69 [qfcc] Use GPU-style alignment for algebra types
Meaning vec3 is aligned to 4 components instead of 1. 2-component ops
use vec2 in the VM thus requiring alignment to boundaries of 2, but 4
seems better as it conforms with OpenGL and Vulkan (and, I imagine,
DirectX, but I doubt QF will ever use DirectX).
2023-08-27 15:13:49 +09:00
Bill Currie
727b490a0c [gamecode] Improve hops instruction readability 2023-08-27 12:28:16 +09:00
Bill Currie
74b7e0a35b [qfcc] Get some of 2d PGA mostly working
Better yet, some tests :)
2023-08-27 00:24:23 +09:00
Bill Currie
0939979d84 [qfcc] Allow #pragma to control warning options
I probably need to make a decision about vararg integer constants, but
the ability to control warnings is never a bad thing.
2023-08-26 23:47:00 +09:00
Bill Currie
a5304461dd [qfcc] Fix adjusted swizzles for the same def
The singleton alias resulted in the adjusted swizzles being corrupted
when for the same def. Other than adding properly sized swizzles
(planned), the simplest solution is to (separately) allow alias that
stick out from from the def.
2023-08-26 23:08:55 +09:00
Bill Currie
29a57b7128 [qfcc] Correct handling of 64-bit comparisons
While the progs engine itself implements the instructions correctly, the
opcode specs (and thus qfcc) treated the results as 32-bit (which was,
really, a hidden fixme, it seems).
2023-08-26 23:04:34 +09:00
Bill Currie
8a0246c910 [ruamoko] Add type info for algebra types
And get vector type views working in the debugger.
2023-08-26 23:01:01 +09:00
Bill Currie
a88d17459f [gamecode] Decode hops and extend opcodes 2023-08-26 22:43:15 +09:00
Bill Currie
91edc5d177 [qfcc] Unalias expressions when checking for math values
Fixes some ICEs when trying to fold constants in geometric algebra.
2023-08-26 11:48:23 +09:00
Bill Currie
81b57903fc [gamecode] Support the l flag for %v and %q
This makes it much easier to print double vector types (for 3 and 4
components, at least).
2023-08-26 11:47:04 +09:00
Bill Currie
77c1b584ea [qfcc] Clean up the blade scaling
I didn't particularly like that solution due to the implied extra
bandwidth (probably should profile such sometime), but I think the
extend operations could be merged into simple assignments by the
optimizer at some stage (or further cleaned up when this stuff gets
moved to actual code gen where it should be).
2023-08-25 22:34:41 +09:00
Bill Currie
60ce4ba8fb [qfcc] Give direct access to algebra subtypes
Currently via only the group mask (which is really horrible to work
with: requires too much knowledge of implementation details, but does
the job for testing), but it got some basics working.
2023-08-25 22:13:54 +09:00
Bill Currie
d2e134cc22 [qfcc] Support multiple parameters for attributes
I have no idea why I threw away all but the *last* parameter (especially
considering nothing used parameters until now).
2023-08-25 22:13:54 +09:00
Bill Currie
b2301c8bad [qfcc] Implement 3d PGA geometric algebra
No clue whether anything is actually correct. Time to start creating
real tests.
2023-08-25 22:13:54 +09:00
Bill Currie
e888f71f8a [qfcc] Fetch sum operand type early
Because component_sum works in-place, using a[i]'s type after setting
c[i] resulting in a null type and thus a segfault.
2023-08-25 22:13:54 +09:00
Bill Currie
a46f9a63d2 [qfcc] Clean up GA sum and scale expressions
Scale was inconsistent and sum was error prone due to using
new_binary_expression raw.
2023-08-25 17:24:47 +09:00
Bill Currie
53d9fee586 [qfcc] Support the extended extend instruction
That... feels odd :)
2023-08-25 17:20:28 +09:00
Bill Currie
7338f86c77 [gamecode] Extend extend to support reversal
Using swizzle for some of the geometric product operations was a bit
clunky and has problems with alignment. While I will still need it in
the future, it turns out that the extend instruction almost did what I
needed. However, I'm unsure that reversing components within an extended
vector is the way to go.
2023-08-25 10:30:14 +09:00
Bill Currie
55bdcbe4c5 [qfcc] Implement 2d PGA geometric product
This is definitely showing the need for better vector instructions
(mostly a 2d wedge and width dependent swizzles).
2023-08-24 22:07:04 +09:00
Bill Currie
e66ae0aad6 [qfcc] Correct swizzle expressions
It turned out they were always using floats for the source type (meaning
doubles were broken), and not shifting the component in the final sizzle
code meaning all swizzles were ?xxx (neglecting minus or 0). I'd make
tests, but I plan on modifying the instruction set a little bit.
2023-08-24 21:43:09 +09:00
Bill Currie
fb6d3f2f86 [gamecode] Decode the swizzle operand
-yx00 is much easier to interpret than some "random" number.
2023-08-24 20:17:17 +09:00
Bill Currie
5f22fd07d9 [qfcc] Implement 3d PGA dot products
Also, correct the handling of scalars in dot and wedge products: it
turns out s.v and s^v both scale. However, it seems the CSE code loses
things sometimes.
2023-08-24 15:49:52 +09:00
Bill Currie
6d75d91de2 [qfcc] Implement 2d PGA dot (inner) product
This has shown the need for more instructions, such as a 2d wedge
product and narrower swizzles. Also, making dot product produce a vector
instead of a scalar was a big mistake (works nicely in C, but not so
well in Ruamoko).
2023-08-24 00:19:58 +09:00
Bill Currie
469fdea0a1 [qfcc] Implement 2d PGA outer products
The specialization is really just in the layout.
2023-08-23 21:52:33 +09:00
Bill Currie
da1b797cb7 [qfcc] Get scalar promotion working again
The cleanup of the scalar expressions lost the type promotion so using
ints in expressions didn't always work.
2023-08-23 21:51:01 +09:00
Bill Currie
d7bab4e222 [qfcc] Avoid constant folding for vector types
The current code is pretty broken when it comes to vector types (losing
the vector and bogus errors among other issues). The whole thing needs a
rework or even just to be tossed in favor of better DAG processing.
2023-08-23 21:48:25 +09:00
Bill Currie
c550ab6b86 [qfcc] Switch 2d PGA groups to be easily implemented
I guess Hamish's suggestion made sense at the time, but I found that
with the current instructions, the reversed bivector wasn't so nice to
implement it would need a swizzle as well as the cross-product.
2023-08-23 21:43:14 +09:00