Commit Graph

3196 Commits

Author SHA1 Message Date
Bill Currie cef2136050 Implement "not" logic for while and do-while.
This goes towards complementing the "if not" logic extension. I need to
check if fteqcc supports "not" with "while" (the version I have access to
at the moment does not), and also whether it would be good  to support
"not" with "for", and if so, what form the syntax should take.
2013-06-26 23:04:35 +09:00
Bill Currie 45a09e195e Add more TODO items (strings stuff) 2013-06-26 23:04:35 +09:00
Bill Currie 6fa63f6c54 Implement the basics of fteqcc's -Fifstring.
It's -Cifstring in qfcc, but otherwise the intent is the same. More testing
and investigation into what fteqcc does is required.
2013-06-26 23:02:55 +09:00
Bill Currie 8d34d33055 Implement "if not (foo)" syntax.
It is syntactic sugar for if (!(foo)), but is useful for avoiding
inconsistencies between such things as if (string) and if (!string), even
though qcc can't parse if not (string). It also makes for easier to read
code when the logic in the condition is complex.
2013-06-26 23:02:55 +09:00
Bill Currie 77337e2402 Separate "" and nil.
It turns out this is required for compatibility with qcc (and C, really).
Once string to boolean conversions are sorted out completely (not that
simple as qcc is inconsistent with if (string) vs if (!string)), Qgets can
be implemented :)
2013-06-26 23:02:55 +09:00
Bill Currie fd1ea9e00e Add an option to control the enum switch warning. 2013-06-26 09:29:37 +09:00
Bill Currie 29df4ac7ee Fix case label lookup.
It looks like I had forgotten that the compare function is supposed to
return true/false (unlike memcmp's sorting ability). Also, avoid the
pointers in the value struct as they can change without notice.

Using enums in switches now works nicely, including warnings for unused
enum values.
2013-06-26 09:29:31 +09:00
Bill Currie 8ac2c3a04d Check for unused enum values in switch statements.
Unfortunately, it turns out the value lookup is broken (including for
duplicate cases).
2013-06-26 09:25:45 +09:00
Bill Currie 35bc981402 Allow use of a jump table when switching on an enum. 2013-06-26 09:25:45 +09:00
Bill Currie 64f76bd762 Use the right value when getting a function's defref.
Either I had gotten confused while writing the code and mixed up line and
offset, or I had changed offset to line at one stage but missed a place.
This fixes the segfault when compiling chewed-alias.r and return-ivar.r
2013-06-24 09:16:55 +09:00
Bill Currie 125ef1f0ff Move the whole separator test/creation into a function.
This will make the next stage easier. (except that seems to be slower)
2013-03-19 20:39:01 +09:00
Bill Currie f2452eb3c3 Rewrite the inner-loop of FindSeparators.
For the most part, it's just refactoring the code so the plane creation and
testing are in separate functions, but there is one important difference:
the plane test now checks only the two points on either side of the point
used to create the plane.

Because the portal winding is guaranteed to be convex and planar, if both
points are on the plane, all points are, and if neither point is behind the
plane, no points are.a

This shaved about 5 seconds off the level 4 run using 4 threads (~198s to
~193s) and about 12s from the single threaded run (~682s to ~670s (hmm,
gained some time in recent changes)).
2013-03-19 17:00:00 +09:00
Bill Currie d7c1bc8d02 Correct a comment.
I had gotten confused between figuring out the windings and writing the
comments, I guess.
2013-03-19 16:23:47 +09:00
Bill Currie 8938870e46 Make the default output a little nicer. 2013-03-19 13:07:44 +09:00
Bill Currie dff0b89a6c Detect the number of CPUs available.
Now qfvis will default to multi-threaded on multi-core machines.
2013-03-19 12:05:50 +09:00
Bill Currie 88e5adcec6 Make the base vis multi-threaded.
Now multi-threaded qfvis is on par with tyrutils vis (differences usually
<1s, sometimes more, sometimes less).
2013-03-19 11:42:09 +09:00
Bill Currie 32b6d15931 Use a sorted queue for portals.
qsort is used to sort the queue by nummightsee. At ~4ms for 20k portals, I
think it's affordable. Using a queue rather than scanning the portal list
each time loses the dynamic sorting when mightsee gets updated, but it
seemed to shave off 4s anyway (~207s to ~203s (maybe, yay random times)).

Another step towards threaded base-vis.
2013-03-18 21:14:12 +09:00
Bill Currie 7e40981dcd Move the LeafThread setup to its own generic function.
This is for threading base-vis.
2013-03-18 21:11:46 +09:00
Bill Currie cb096c601d Use a per-portal rwlock for portal updates.
This should make qfvis scale a little better with cpu count.
2013-03-18 15:03:11 +09:00
Bill Currie c824e668ed Rework some of the pthread stuff.
Init/uninit is now separate from portal vising.
The global lock has a better name and is now a rwlock.
Use a separate lock for the stats.
2013-03-18 14:26:52 +09:00
Bill Currie 134381f79b Reduce the locking in the portal completion code.
It doesn't seem to make much difference, but the less room for contention,
the better.
2013-03-18 13:45:19 +09:00
Bill Currie ffb6d628bd Simplify the pthreads detection macros. 2013-03-18 13:31:35 +09:00
Bill Currie 1c20a49dba Use the recursive set allocator for mightsee.
This completely removes the lock used to protect the set allocation code
while keeping the use of the set api clean.
2013-03-18 13:30:50 +09:00
Bill Currie a28ec8aa82 Revert "Allocate stack blocks and mightsee in one block."
This reverts commit 1ea79e8626.

Conflicts:
	tools/qfvis/include/vis.h
	tools/qfvis/source/flow.c

I've decided to do reentrant versions of the set allocators and I didn't
particularly like the invasiveness of allocating sets this way.
2013-03-18 12:47:59 +09:00
Bill Currie ad247fa12d Rename some variables and remove some comments.
The old variable names were confusing ("target" winding comes from
"portal"?), and the comments were from when I really didn't understand
concepts like separating planes. While they weren't wrong, they were quite
inadequate and I want to write new ones.
2013-03-17 21:52:08 +09:00
Bill Currie ccc432a7ea Give the fields of pstack_t clearer names.
And some comments.
2013-03-17 19:18:38 +09:00
Bill Currie 1ea79e8626 Allocate stack blocks and mightsee in one block.
This bypasses set_new, but completely removes the use of the global lock
from within RecursiveClusterFlow. This seems to give a small speedup: 203
seconds threaded.
2013-03-17 16:37:27 +09:00
Bill Currie 1d262f7dea Clean up FindSeparators a little bit.
This was testing an idea I had to remove the plane flips. It seems to have
been good for the initial plane orientation, but was a slight slowdown for
the pass-portal test. However, this makes the code a little easier to work
with for my idea on improving the algorithm itself.
2013-03-17 10:16:47 +09:00
Bill Currie 5dba419233 Cache stack blocks and working mightsee sets.
Since the stack structure in the thread data is a linked list, move the
stack blocks off the program stack and into malloced memory. More
importantly, when the stack block is allocated, the mightsee working set is
allocated too, and as neither are freed, this greatly reduces contention
for the lock. Also, because the memory is kept, single threaded time for
gmsp3v2 dropped from 695s to 670s. Threaded is now about 207s (down from
350).
2013-03-16 22:58:59 +09:00
Bill Currie 2ea143283c Rewrite mightsee_more to manipulate the sets directly.
While using set operators was clearer, it was rather expensive (about 25s
for gmsp3v2). qfvis now completes the map in about 695s (single threaded).
About 15s faster than tyr for the same conditions (1 thread, level 4).
2013-03-16 21:51:41 +09:00
Bill Currie 195bdcb92f Rework FindSeparators to make use of the winding direction.
This is the second part of the separator search optimization from tyrutils
vis. With this, qfvis is getting close to tyrutils vis when
running single threaded (qfvis is suffering some nasty thread contention
and thus can't get below about 350 seconds with 4 threads). 808s vs 707s.
2013-03-15 22:05:01 +09:00
Bill Currie 9b10304c2f Make CopyWinding const-correct. 2013-03-15 19:25:24 +09:00
Bill Currie 5a2ee06787 Reverse the winding for backside portals.
This is part 1 of another optimization from tyrutils vis. It seems that
just reversing the winding gives a tiny speedup.
2013-03-15 19:22:57 +09:00
Bill Currie 46d41ad9ac Split up separator finding and winding clipping.
Interesting, it makes very little (maybe faster) difference to find all the
separators for levels 3 and 4. This might be due to the higher levels using
most of the planes to fully clip source away. Anyway, it makes the code a
little clearer (one function, one task).
2013-03-15 16:00:39 +09:00
Bill Currie f80ae52828 Make vis's ClipWinding const-correct. 2013-03-15 15:28:25 +09:00
Bill Currie 77c858060d Add a bunch more statistics.
Now I know why sphere culling was a loss: 78% of all tested target portals
were trimmed by ClipToSeparators (50% eventually clipped away entirely).
2013-03-14 19:43:46 +09:00
Bill Currie 97da7fe31d Document some fields. 2013-03-14 19:43:46 +09:00
Bill Currie 8032d1d4d1 Split out the mightsee intersection/subset tests.
Having the code in separate functions makes the flow in the main loop a
little easier to follow.
2013-03-14 19:43:46 +09:00
Bill Currie eec87bd61b Remove thread from stack_t.
It really wasn't gaining anything and made reading the code a little
harder.
2013-03-14 19:43:46 +09:00
Bill Currie 057a5cc624 Make BasePortalVis another 17% faster.
I had forgotten to skip the refined tests when the sphere was entirely on
the relevant side of the plane. Now BasePortalVis for gmsp3v2 takes 11s on
my machine (it was 13 with the previous optimization and 15.9 before that).

Also, write some comments describing how BasePortalVis works.
2013-03-14 14:01:26 +09:00
Bill Currie 5d6df082f2 Move the vis stats vars into thread data.
This should make the stats more reliable when running multi-threaded
(chains is still random, but it seems there are set access issues).
2013-03-14 12:52:40 +09:00
Bill Currie 0cae04d71a Alter test_sphere to return -1, 0 or 1.
Representing the side of the plane on which the sphere lies is much more
useful as more complicated tests can be done using just the one call.
-1: the sphere is entirely on the back side of the plane
 0: the sphere is intersecting the plane
 1: the sphere is entirely on the front side of the plane
2013-03-14 09:05:26 +09:00
Bill Currie b9d71218f6 Use sphere culling in the base vis.
Base vis was done first for testing. Optimized base vis is down to ~12.4s
from ~16s (29% faster?).
2013-03-13 21:32:18 +09:00
Bill Currie fe55bb678e Set the default level to 4.
It was supposed to be 2, but for some reason I neglected to set it when I
set up the options parsing. However, level 4 is the standard for production
maps, and it happens to be faster than level 2 (at least for gmsp3v2.bsp)
2013-03-09 15:01:54 +09:00
Bill Currie 3232c22795 Implement mightsee updates from tyrutils.
It doesn't seem to make much difference, but I suspect that's my set code
not being optimal for the job.
2013-03-09 14:32:51 +09:00
Bill Currie d1e65257b6 Implement the cached separators idea from tyrutils.
I think the reason I didn't think of that when I tried to improve qfvis's
performance many years ago is I just simply did not understand
ClipToSeparators. However, the difference caching the separators makes is
phenomenal. Before the change, single threaded qfvis would get stuck on one
particular portal for at least a day (I gave up waiting), but now even a
debug build will complete gmsp3v2.bsp in less than 12 minutes (4 threads on
my quad-core). And that's at level 2! Getting stuck for a day was at level
0.
2013-03-08 22:20:29 +09:00
Bill Currie ca0b03687f Change the naming of ALLOC's free-list.
Rather than prefixing free_ to the supplied name, suffix _freelist to the
supplied name. The biggest advantage of this is it allows the free-list to
be a structure member. It also cleans up the name-space a little.
2013-03-08 22:16:31 +09:00
Bill Currie dbdfdb6d28 Add support for PRT2 portal files.
These seem to be identical to PRT1-AM but with a different count order in
the header. Taken from tyrutils-0.5.
2013-03-07 18:51:32 +09:00
Bill Currie 0649fd7022 Correct some verbosity levels. 2013-03-07 18:51:23 +09:00
Bill Currie 4e87072d93 Fix a bunch of whitespace. 2013-03-07 14:31:00 +09:00