Commit graph

4132 commits

Author SHA1 Message Date
Bill Currie
490217a136 [qfcc] Ensure non-unicode char string is terminated
Once a unicode char (ie, > 127) was used, any ascii chars would get the
tail of the last unicode char resulting in broken utf-8 streams. The
resulting null glyph boxes were not very appealing.
2022-12-10 21:53:45 +09:00
Bill Currie
6fc2dcae20 [qfprogs] Dump hex for non-ascii chars
More useful when dealing with non-quake text (especially broken utf-8
strings).
2022-12-10 21:53:00 +09:00
Bill Currie
99b568c208 [build] Fix distcheck once again
Probably the hardest part of QF to maintain.
2022-12-02 17:10:04 +09:00
Bill Currie
1cada2c931 [qfvis] Remove (mostly) unnecessary vector normalization
Because of the way the plane normal is used (front/on/back checks, and
midpoint calculation), other than possible precision, there is no need
to normalize the normal. Removing the square root and division resulted
in a huge boost: from 34s to 14 seconds. The average clusters visible
hasn't change much, and a quick check in-game didn't show any issues.
2022-11-19 23:16:47 +09:00
Bill Currie
d283f07890 [qfvis] Replace modulo and SISD cross-product
At least modern gcc produces nice code for ?: (cmov), and a SIMD
cross-product uses several fewer instructions. The cross-product shaved
off 0.5-1s, but the modulo -> ?: shaved off about 3-4s, for a total of
about 10% speedup (1.09 insn/cyc vs 1.01 insn/cyc, so even perf agrees).
2022-11-19 20:49:13 +09:00
Bill Currie
de2cc21c7e [qfcc] Add basic support for (u)long expressions
It's woefully incomplete, but sufficient to test initializing
non-scalars from ivec constants.

Fixes #36
2022-11-16 20:48:58 +09:00
Bill Currie
23469029ca [qfcc] Support converting non-scalar values
This fixes the basic vecconst test (extending it to other types breaks
because long and ulong are not properly supported yet). The conversion
is done by the progs VM rather than writing another 256 conversions
(though loops could be used). This works nicely as a test for using the
VM to help with compiling.
2022-11-16 19:44:40 +09:00
Bill Currie
e1d7854af5 [qfcc] Rename G_* macros to Q_*
They clash with those in progs.h, which is needed for using progs code
in the compiler.
2022-11-16 17:53:21 +09:00
Bill Currie
ce64baa92d [qfcc] Add failing test for vector constant init
Raw 'x y z' style vector constants that look like ints (no fractional
parts) used to initialize vector globals/constants don't get converted
to float vectors, resulting in nans for negative values and denormals
for positive values. This tends to make game physics... interesting.
2022-11-16 11:25:27 +09:00
Bill Currie
f323401c10 [qfcc] Add an explicit hadamard operator
While the option to make '*' mean dot product for vectors is important,
it breaks vector scaling in ruamoko progs as the resultant vector op
becomes a dot product instead of the indented hadamard product (ie,
component-wise).
2022-11-16 00:06:21 +09:00
Bill Currie
5b202a1733 [qfcc] Skip over aliases when checking for blocks
This fixes the double call to [super init] as tested by ifsuper.r.
2022-11-13 04:15:26 +09:00
Bill Currie
76740d213e [qfcc] Add link from jump expression to destination
Having a dangling jump with no destination in my dot output wasn't very
informative.
2022-11-12 22:16:57 +09:00
Bill Currie
bfda4e776f [qfcc] Add a failing test case for if-super calls
The common idiom for self init (below) causes a double-call when
compiling with --advanced, resulting in an incorrect retain count.

    if (!(self = [super init])) {
	return nil;
    }
2022-11-12 20:07:30 +09:00
Bill Currie
2d3c2da64d [qfcc] Support advanced progs again
The support for the new vector types broke compiling code using
--advanced. Thus it's necessary to ensure vector constants are
float-type and vec3 and vec4 are treated as vector and quaternion, which
meant resurrecting the old vector expression code for v6p progs.
2022-11-12 20:04:19 +09:00
Bill Currie
71af297a52 [qfcc] Support extend expressions in dot_expr 2022-11-12 18:51:08 +09:00
Bill Currie
ea781c9dcc [qfmap] Fix some blender bit-rot. 2022-09-22 09:35:56 +09:00
Bill Currie
6e8a3b8153 [qfmap] Parse field info from quaked comments
Id's comments are a little inconsistent, but for the most part usable
info can be extracted. While not yet supported, Arcane Dimensions'
comments are extremely consistent (just some issues with hyphen counts
in separators), so parsing out usable info will be fairly easy. The hard
part will be presenting it.
2022-09-22 09:35:56 +09:00
Bill Currie
1fa202608e [qfcc] Don't free duplicate method when merging
The method is still held by known_methods, so freeing it causes grief.
However, it may cause a leak thus the free is only commented out. More
investigation is needed. I'm surprised the problem didn't show on linux,
but cygwin-native hit it and valgrind on linux found the spot :)
2022-09-19 16:39:25 +01:00
Bill Currie
08328f4076 Fix some cygwin portability issues
Cygwin's headers seem to be rather out of date with respect to linux
with regards to signed types, especially ctype.
2022-09-19 16:31:08 +01:00
Bill Currie
feba790348 [qfcc] Use _algined_free when using _aligned_malloc
Windows requires the two to be paired. I think this is the first time I
really tested windows qfcc on windows.
2022-09-19 13:37:08 +01:00
Bill Currie
6d64195a7b [qfcc] Fix incorrect progs source path handling
The cvar rewrite changed how to deal with cvar setting in code and I
messed it up for qfprogs.
2022-09-14 22:10:11 +09:00
Bill Currie
3c797e15e6 [qfcc] Use PR_Debug_ValueString when dumping globals
While it does get a bit cluttered currently, being able to see the
contents of structures makes a huge difference. Also highlights that
vector immediates do not get the correct type encodings.
2022-09-14 19:26:17 +09:00
Bill Currie
a8a8c567a2 [qfcc] Promote types before expanding scalars
This fixes the internal error generated by the likes of
`(sv_gravity * '0 0 1')` where sv_gravity is a float and `'0 0 1'` is an
ivec3: the vector is promoted to vec3 first so that expanding sv_gravity
is expanded to vec3 instead of ivec3 (which is not permitted for a
float: expansion requires the destination base type to be the same as
the source).
2022-09-14 14:43:31 +09:00
Bill Currie
5747ddb77f [qfcc] Skip recording defs for binary expressions
For now, anyway, as the generated code looks good. There might be
problems with actual pointer expressions, but it allows entity.field to
work as expected rather than generate an ICE.
2022-09-14 14:43:31 +09:00
Bill Currie
5ae782bf89 [qfcc] Add support for \uXXXX and \UXXXXXXXX
The resultant unicode is encoded as utf-8, which does conflict with the
quake character map, but right now unicode is useful only with font
text, and those support only standard unicode (currently only as utf-8),
but something will need to be sorted out.
2022-09-09 14:48:03 +09:00
Bill Currie
53d86e2a53 [qfcc] Don't check parameter size for arrays
Arrays are passed as a pointer to the first element, so are always valid
parameters. Fixes a bogus "formal parameter N is too large to be passed
by value" error.
2022-09-09 14:48:03 +09:00
Bill Currie
95b8424ddf [qfcc] Use new extend instruction instead of swizzle
While swizzle does work, it requires the source to be properly aligned
and thus is not really the best choice. The extend instruction has no
alignment requirements (at all) and thus is much better suited to
converting a scalar to a vector type.

Fixes #30
2022-08-18 18:18:19 +09:00
Bill Currie
59b73353dd [qfcc] Fix integer vector constants for clang
It seems clang loses track of the usage of the referenced unions by the
time the code leaves the switch. Due to the misoptimization, "random"
values would get into the vector constants. This puts the usages in the
same blocks as the unions, causing clang to "get it right" (though I
strongly suspect I was running into UB).
2022-08-18 18:18:19 +09:00
Bill Currie
42287f1e0e [qfcc] Allow binary operations between vector and vec3
While I might need to tighten up the rules later, this allows binary
operations between vector (the type) and explicitly typed vec3 constants
(and non-constants, about which I am undecided). The idea is that
explicit constants such as '1 2 3'f should be compatible with either
type.

This applies to quaternions as well.
2022-08-18 18:18:19 +09:00
Bill Currie
0897952a57 Fix windows compile issues
ulong seems to be defined somewhere on Linux, thus I missed that, and of
course there's the fun with aligned memory allocation :/
2022-07-31 17:34:09 +09:00
Bill Currie
6253d775e6 [qfcc] Adjust ivar offsets to preserve alignment
As a class's ivars are built up by inheritance, but with only that
class's ivars in the symbol table, is is necessary to include an offset
based on the super class's ivars in order to ensure alignments are
respected. This is achieved via the new `base` parameter to
build_struct(), which is used to offset the current size while
calculating the aligned offset of the symbols. The parameter is ignored
for unions, as they always start at 0. The ivars for the current class
still have a base offset of 0 until they are actually added to the
class.

Fixes #29
2022-07-31 17:15:47 +09:00
Bill Currie
f4ae24e0e0 [qfcc] Support alignment in qfo spaces
The alignment is specified as a power of 2 (ie, actual alignment = 1 <<
alignment) allowing old object files to be compatible (as their
alignment is 0). This is necessary for (in part for #30) as it turned
out even global vectors were not aligned correctly.

Currently, only data spaces even vaguely respect alignment. This may
need to be fixed in the future.
2022-07-31 17:15:47 +09:00
Bill Currie
732ea3a5fd Fix a bunch of issues for clang
One *actual* error (wrong enum type), and some memory alignment issues.
The rest just clang being lame.
2022-07-31 17:15:40 +09:00
Bill Currie
2c8bec27c7 Fix a pile of warnings for gcc 12
Most were pretty easy and fairly logical, but gib's regex was a bit of a
pain until I figured out the real problem was the conditional
assignments.

However, libs/gamecode/test/test-conv4 fails when optimizing due to gcc
using vcvttps2dq (which is nice, actually) for vector forms, but not the
single equivalent other times. I haven't decided what to do with the
test (I might abandon it as it does seem to be UD).
2022-07-31 17:13:26 +09:00
Bill Currie
8633ffe9d2 Fix some MXE build issues
Just some unused variables when vulkan debug is disabled and some scanf
formats for qfcc vectors (and the safety net).
2022-05-22 11:59:53 +09:00
Bill Currie
34da36e1cf [gl_stub] Add a bunch of new stubs
Gets gl_stub working with recent changes to QF.
2022-05-20 16:27:01 +09:00
Bill Currie
688f17fda3 Correct some typos in comments/docs 2022-05-19 13:26:45 +09:00
Bill Currie
8b425a2740 [tools] Show major file offsets in mdl dumper
Handy for debugging the alias model loader.
2022-05-19 13:26:45 +09:00
Bill Currie
9429539f2f [qfbsp] Print node and leaf info
Maximum tree depth, number of nodes in a model, and max faces per node
and leaf.
2022-05-19 13:26:45 +09:00
Bill Currie
2a0bbfb4e9 [io_mesh_qfmdl] Use an int for NLA start frame
At at some stage blender enforced frames being integers (In the past,
there was support for fractional, I think, but I also seem to remember
it not working) (yes, for anybody looking, this commit message is more
or less copied from io_object_mu).
2022-05-08 02:15:50 +09:00
Bill Currie
9c7c081772 [io_mesh_qfmdl] Skip space after parsing a value
Fixes a bogus error on the likes of offset = { x = 0; y = 0 }; (ie,
between the 0 and } )
2022-05-06 15:08:56 +09:00
Bill Currie
c26c3b2739 [mdl] Show bytes remaining if not enough for unpack
It turns out Abyss of Pandemonium has a truncated mdl file causing
buffer overruns.
2022-05-05 23:49:30 +09:00
Bill Currie
1891c1c302 [qflight] Replace a sprintf with va
While 16 chars is plenty for a 32-bit int, just seeing sprintf is enough
reason to make the change.
2022-05-04 21:01:39 +09:00
Bill Currie
3b926ec154 [io_mesh_qfmdl] Update plist parsing for `
This gets it pretty much in line with the C implementation. Certainly
good enough for validating a render pass spec :)
2022-05-04 14:44:54 +09:00
Bill Currie
b9bd45ad99 [qfcc] Create vector lists only for constants
Defs and symbols benefit from swizzling as that's one instruction vs 2-3
for loading a scalar into a vector component by component. Constants are
ok because the result gets converted to a vector constant.
2022-05-01 14:35:24 +09:00
Bill Currie
be4021f8f4 [qfcc] Actually shrink the unaligned hole
This fixes the duplicate allocation caused by an exact fit aligned alloc
in an unaligned hole where the padding remains free.
2022-05-01 14:35:24 +09:00
Bill Currie
7518ba0a27 [qfcc] Add failing test case for defspace_alloc_aligned_loc
qfcc is putting two temps in the same location due to
defspace_alloc_aligned_loc returning the same address when there was a
hole caused by an earlier aligned alloc: specifically, a size-3 hole and
a size-2 allocation with alignment-2.
2022-05-01 14:35:24 +09:00
Bill Currie
cdd8739577 [qfcc] Improve debug printing of statements and operands
Makes it easier to check operand base indices and temporary variable
addresses when known.
2022-05-01 14:35:24 +09:00
Bill Currie
ef9960c6f9 [qfcc] Implement support for the swizzle operator
The destination operand must be a full four component vector, but the
source can be smaller and small sources do not need to be aligned: the
offset of the source operand and the swizzle indices are adjusted. The
adjustments are done during final statement emission in order to avoid
confusing the data flow analyser (and that's when def offsets are known).
2022-05-01 14:35:24 +09:00
Bill Currie
3c20dd515e Revert "Don't bother creating an alias for a def of the same type."
This reverts commit 2904c619c1.

In order to support swizzle operations, I need to be able to alias defs
to larger types (eg, float to vec4), but alias_def rightly won't allow
this. However, as the plan is to do this in the final steps before
emitting the instruction, I plan on creating an alias to a float then
adjusting the type in the alias, but to do so without extra shenanigans,
I need alias_def to allow aliases to the same type. As a fringe benefit,
it makes the code agree with the comment in def.h :P
2022-05-01 14:35:24 +09:00