Commit Graph

3851 Commits

Author SHA1 Message Date
Bill Currie 648ae3f877 [qfvis] Clean up the code and output a little
Dead code removed, and the job progress lines are now consistent and
have a job completion time when done.
2021-08-03 21:52:24 +09:00
Bill Currie fe998f41b4 [qfvis] Convert leaf vis to cluster vis
Now that only 3852 clusters need to be checked for each cluster, fat-pvs
construction for ad_tears completes in about 0.7s, most of which seems
to be loading, conversion, compression and writing. O(N^3) cuts both
ways (hurts like crazy when N increases, does wonders when N decreases,
especially by a factor of 25). And then throw in improved cache
performance...

I suspect having an off-line compiler is still useful, but even if
qfvis's implementation never actually gets used, if cluster
reconstruction is put in the engine, large maps will be feasible even
for quakeworld. Just the reduced memory requirements alone will be a
huge benefit (~3GB down to 1.8MB).
2021-08-03 15:48:45 +09:00
Bill Currie 8da019e31c [qfvis] Reconstruct the leaf clusters in a bsp
This is only the first half (vertical) in that the vis bits are still
for the leafs rather than the clusters, but ad_tears goes from 500s to
7s for calculating the fat pvs (3852 clusters).
2021-08-03 11:37:24 +09:00
Bill Currie 421047328a [qfvis] Catch a missed winding mark stat 2021-08-02 23:17:55 +09:00
Bill Currie ec54c54226 [build] Fix some windows bitrot 2021-08-02 14:02:41 +09:00
Bill Currie f514345d77 [qfbsp] Show correct object counts for bsp29 files
Yes, this was the goal of that size_t change, but it made sense anyway.
2021-08-01 22:05:31 +09:00
Bill Currie 674ffa0941 [util] Make bsp_t counts size_t
and other bsp data counts unsigned, and clean up the resulting mess.
2021-08-01 21:54:05 +09:00
Bill Currie 40367e5bca [qfvis] Thread the ambient sounds computation 2021-08-01 18:14:28 +09:00
Bill Currie e671b3f230 [qfvis] Thread the portal vis compaction
The compaction deals with merging all the portal visibility into cluster
visibility, expanding out to leafs, and final compression.
2021-08-01 17:06:13 +09:00
Bill Currie 523ab007d6 [qfvis] Produce more details base-vis stats
And nicely, things add up (after fixing 32-bit overflows :P)
2021-07-30 23:07:12 +09:00
Bill Currie ca8dcf3fa9 [qfvis] Use cluster sphere culling for base vis
While this doesn't give as much of a boost as does basic sphere culling
(since it's just culling sphere tests), it took ad_tears' base vis from
1000s to 720s on my machine.
2021-07-30 18:52:47 +09:00
Bill Currie 9461779ba7 [qfvis] Remove the cluster portals limit
This removes the last of the arbitrary limits from qfvis. The goal is
not so much supporting crazy maps, but more about better data usage
(cluster_t is now 24 (or 16) bytes instead of 1048 (or 528). And
passages isn't used (yet?)...
2021-07-29 21:03:07 +09:00
Bill Currie 756214ca8e [qfvis] Use unsigned for the plane side tests
Doesn't make any difference to the number of instructions, but seeing
sar instead of shr bothers me when working with bit patterns.
2021-07-29 15:25:37 +09:00
Bill Currie 72a1fef714 [qfvis] Use hunk to manage winding memory
It turns out cmem is not so good for many large allocations (probably a
bug in handling the blocks), but was really meant for lots of little
churning allocations anyway. After an analysis of winding lifetimes, it
became clear that the hunk allocator would work very well. The base
windings are allocated from a global hunk (currently 1GB, plenty for
even ad_tears), and ephemeral windings are allocated from a per-thread
hunk of 1MB (seems to be way more than enough: gmsp3v2 uses a maximum of
only 56064 bytes, and ad_tears got through 30% before I gave up on it).
Any speed difference (for gmsp3v2) seems to be lost in the noise: still
completing in 38.4s on my machine.
2021-07-29 11:49:18 +09:00
Bill Currie e39bc83a6a [qfvis] Optionally use utf8 to encode run lengths
Adds 50 bytes to marcher's fat-pvs, but removes about 4.7MB from
ad_tear's fat-pvs.
2021-07-27 23:29:14 +09:00
Bill Currie b9d2882e02 [qfvis] Write out the fat-pvs file
The output fat-pvs data is the *difference* between the base pvs and fat
pvs. This currently makes for about 64kB savings for marcher.bsp, and
about 233MB savings for ad_tears.bsp (or about 50% (470.7MB->237.1MB)).
I expect using utf-8 encoding for the run lengths to make for even
bigger savings (the second output fat-pvs leaf of marcher.bsp is all 0s,
or 6 bytes in the file, which would reduce to 3 bytes using utf-8).
2021-07-27 20:04:19 +09:00
Bill Currie 49c3dacbbc [util] Rename set_size to set_count
After seeing set_size and thinking it redundant (thought it returned the
capacity of the set until I checked), I realized set_count would be a
much better name (set_count (node->successors) in qfcc does make much
more sense).
2021-07-27 11:52:21 +09:00
Bill Currie 946867c82e [qfvis] Start work on an off-line fat pvs compiler
Extremely large maps take a very long time to process their PVS sets for
PHS or shadows, so having an off-line compiler seems like a good idea.
The data isn't written out yet, and the fat pvs code may not be optimal
for cache access, but it gets through ad_tears in about 500s (12
threads, compared to 2100s single-threaded in the qw server).
2021-07-26 22:42:03 +09:00
Bill Currie 60d23bdc8f [qfbsp] Remove all arbitrary bsp limits
Planes, verts, etc can now all get crazy big.
2021-07-26 13:10:06 +09:00
Bill Currie 13e1682f5e [qfbsp] Add an option to dump info about a bsp file
Just the header plus some basics of model info.
2021-07-25 12:14:04 +09:00
Bill Currie 342ba65f57 [qfcc] Handle aliased field types
Fixes use of structs as entity fields. The test is currently
compile-only.
2021-07-24 18:09:54 +09:00
Bill Currie 8369a2206a [glstub] Add functions needed to get glsl working
Pity vulkan won't be so easy.
2021-07-22 10:12:41 +09:00
Bill Currie 6b38a17cf1 [gamecode] Clean up state imlementations
This makes the code easier to read. Also, yay for automated tests:
caught a mistyped time :)
2021-07-15 16:55:02 +09:00
Bill Currie 0a847f92f1 [util] Use mmap/munmap for cmem internal alloc/free
This reduces the overhead needed to manage the memory blocks as the
blocks are guaranteed to be page-aligned. Also, the superblock is now
alllocated from within one of the memory blocks it manages. While this
does slightly reduce the available cachelines within the first block (by
one or two depending on 32 vs 64 bit pointers), it removes the need for
an extra memory allocation (probably via malloc) for the superblock.
2021-07-12 16:33:47 +09:00
Bill Currie 6db6f8f0e2 [win] Fix a pile of bitrot
Man, those bits rot quickly. Must be stored with a rotfish.
2021-07-11 13:30:52 +09:00
Bill Currie ef6dd422e5 [qfcc] Add source line number to statement blocks
For statement dot blocks.
2021-07-06 18:06:47 +09:00
Bill Currie ddc6f6bcb0 [qfcc] Un-dereference src expression early for movep
The VM has no pointer to direct reference move instruction.

Fixes #9
2021-06-30 20:05:27 +09:00
Bill Currie 9d140d1d15 [qfcc] Use {>...} for unnamed alias types
The ... is the encoding of the aliased type. Avoids (null) in the
encoding. Fixes #10.
2021-06-30 11:00:05 +09:00
Bill Currie a3aebc983b [qfcc] Add dependency edges for moved labels
When moving an identifier label from one node to another, the first node
must be evaluated before the second node, which the edge guarantees.
However, code for swapping two variables

    t = a; a = b; b = t;

creates a dependency cycle. The solution is to create a new leaf node
for the source operand of the assignment. This fixes the swap.r test
without pessimizing postop code.

This takes care of the core problem in #3, but there is still room for
improvement in that the load/store can be combined into a move.
2021-06-29 14:42:16 +09:00
Bill Currie 76b3bedb72 [qfcc] Revert "Kill dag leaf nodes on assignment."
This reverts commit 2fcda44ab0.

Killing the node is not the correcgt answer as it blocks many
optimization opportunities. The correct answer is adding edges to
describe the temporal dependencies. Of course, this breaks the swap.r
test.
2021-06-29 12:09:35 +09:00
Bill Currie 5291cfb03d [qfcc] Keep track of reachable dag nodes
In order to correctly handle swap-style code

    { t = a; a = b; b = t; }

edges need to be created for each of the assignments moving an
identifier lable, but the dag must remain acyclic (the above example
wants to create a cycle). Having the reachable nodes recorded makes
checking for potential loops a quick operation.
2021-06-29 09:41:03 +09:00
Bill Currie 0d1fad12f0 [qfcc] Add some comments 2021-06-29 09:12:57 +09:00
Bill Currie d50f2c3145 [qfcc] Correctly check for constant op
Identifiers can be constants. I don't remember quite what it fixed other
than some bogus kill relations in the dags (which might have caused
issues later).
2021-06-28 20:25:26 +09:00
Bill Currie 38a6ccdc85 [qfcc] Use indexed initializers for expr functions
This will make adding new expression types easier (though the current
reason for doing so has been abandoned for now).
2021-06-28 18:12:15 +09:00
Bill Currie 365e298908 [qfcc] Make internal_error const correct
This way it can be used with const expr objects.
2021-06-28 18:12:15 +09:00
Bill Currie 93167279fc Fix a bunch of issues found by gcc-11 2021-06-13 14:30:59 +09:00
Bill Currie 13b4b44e35 [qfcc] Handle l and ll integer suffixes
They're ignored, but allow recent vulkan headers to compile.
Fixes #13
2021-06-13 13:25:18 +09:00
Bill Currie 927a446bd3 [qfcc] Ensure type src type is a class
If the src type is not a class, there is no inheritance chain to walk.
Fixes a segfault when returning self after a syntax error in the
following:

    +(EditStatus *)withRect:(Rect)rect
    {
	return [[[self alloc] initWithRect:rect]:
    }

    -setCursorMode:(CursorMode)mode
    {
	cursorMode = mode;
	return self;
    }
2021-06-09 12:08:13 +09:00
Bill Currie 88c9517629 [qfprogs] Dump class ivars when dumping modules 2021-06-04 14:59:15 +09:00
Bill Currie 778c07e91f [util] Get vectors working for non-SSE archs
GCC does a fairly nice job of producing code for vector types when the
hardware doesn't support SIMD, but it seems to break certain math
optimization rules due to excess precision (?). Still, it works well
enough for the core engine, but may not be well suited to the tools.
However, so far, only qfvis uses vector types (and it's not tested yet),
and tools should probably be used on suitable machines anyway (not
forces, of course).
2021-06-01 18:53:53 +09:00
Bill Currie 18247a8c8e [tools] Fix up 32-bit cross-compile scripts 2021-04-02 08:55:16 +09:00
Bill Currie 574a123716 [qfvis] Remove obsolete notes file
While some of it is still correct, I'd rather start afresh next time I
need to sort that stuff out.
2021-03-28 21:14:17 +09:00
Bill Currie 634219ea06 [qfvis] Add set debug prints (disabled)
They were useful for narrowing down why mightsee wasn't being updated.
2021-03-28 21:11:13 +09:00
Bill Currie 9f42943589 [qfvis] Reset portal status after base vis
This fixes the mightsee updates never occurring, but it doesn't make a
huge difference (though I suppose it might have back in the 90s, or with
a different map).
2021-03-28 21:06:50 +09:00
Bill Currie 0fa65be106 [qfvis] Fix stats collection for mightseeupdate
The stats were being updated before UpdateMightsee was getting called,
and it was incrementing the wrong value (so it would not have been
thread-safe).
2021-03-28 21:06:50 +09:00
Bill Currie ff4cd84891 [qfvis] Use simd vector code
While whether it's any faster is debatable (it's slightly slower, but
many more portals are being tested due to different rounding in the base
vis stage), it's certainly easier to read.
2021-03-28 19:55:47 +09:00
Bill Currie eb325376b1 [qfvis] Collect base vis culling stats
Specifically, just how many are culled by sphere and winding tests.
2021-03-28 12:17:15 +09:00
Bill Currie d072a7b99c [qfvis] Add stats for memory usage
Verbosity levels probably need more tweaking, but -v is at least a
little more usable.
2021-03-27 23:04:13 +09:00
Bill Currie 3ef38188ce [qfvis] Add an option to limit the processed portals
It's not documented as I needed it for debugging memory allocations and
it causes qfvis to error out due to unprocessed portals.
2021-03-27 20:59:56 +09:00
Bill Currie f2b6b23acc [qfvis] Switch to unsigned for various counts 2021-03-27 20:55:15 +09:00