Commit graph

11772 commits

Author SHA1 Message Date
Bill Currie
349f8067c3 [gamecode] Conform with libc malloc for pr zone
Allocating 0 bytes returns null and freeing a null pointer is safe.
2021-09-26 12:03:44 +09:00
Bill Currie
ac25d9f1c1 [qwaq] Fix window closure
Now the device windows close properly when an input device is removed.
2021-09-26 10:35:24 +09:00
Bill Currie
192b76ddc6 [input] Remove closed device in correct place
Removing the device from the devices list after closing the device
could cause the device to be double-freed if something went wrong in the
device removal callback resulting in system shutdown which would then
close all open devices.

The device is removed from the list before the callback is called.

There's still a small opportunity for such in a multi-threaded
environment, but that would take device removal occurring at the same
time as the input system is shut down. Probably the responsibility of
the threaded environment rather than inputlib.
2021-09-25 16:43:03 +09:00
Bill Currie
13bc38a55b [input,ruamoko,qwaq] Fix incorrect use of PR_RESMAP
I had forgotten that _size was the number of rows in the map, not the
number of objects (1024 objects per row). This fixes the missed device
removal messages. And probably a slew of other bugs I'd yet to encounter
:P
2021-09-25 15:50:16 +09:00
Bill Currie
4057500acc [qwaq] Implement device management for input-app
Currently shows only the axes (along with dev "path" and name), but it
has done a good job of pushing dev of other bits of code :)
2021-09-25 14:22:19 +09:00
Bill Currie
1a5cce4374 [qwaq] Set table cell size in the correct place
I have no idea why I made LocalsData set the size instead of TableView,
but now the cells are correctly sized automatically.
2021-09-25 13:27:55 +09:00
Bill Currie
2119688b48 [gamecode] Use a flag for format width
This ensures caller specified width always gets through to libc's
printf, even if the caller specifies 0. More importantly, * works
correctly.
2021-09-25 13:24:48 +09:00
Bill Currie
0df16fb210 [qwaq] Fix TableView's scrolling 2021-09-25 10:53:39 +09:00
Bill Currie
0a60f46a64 [qwaq] Implement more debugger def views
Structs and arrays now work (though could be better, eg collapsible).
2021-09-25 01:42:36 +09:00
Bill Currie
7ed12e2f37 [qfcc] Fix static function declarations
I'm surprised it took this long for static not working to cause a
problem.
2021-09-24 19:49:55 +09:00
Bill Currie
6144100d9b [qfcc] Check init exists before checking compound
Fixes a segfault that occurred during a parse error in a def
initializer.
2021-09-24 19:44:14 +09:00
Bill Currie
6f71ef6657 [qwaq] Separate out mouse (de)init code
This is the simplest fix for the curses/input initialization order
issue. The terminal io code should still be moved to its own file,
really, but I think it can wait.
2021-09-23 13:14:42 +09:00
Bill Currie
72900fd16b [qwaq] Move input handling to its own thread
As it is now a completely separate sub-system, there is a bit of trouble
with mouse handling in that curses must be initialized before input for
the mouse to work properly, but the basic scheme seems to be working
nicely. I suspect the solution to the init order issue is to make have
the curses sub-system initialize the terminal input driver, at least for
mouse input (ie, maybe just enable/disable mouse handing).
2021-09-22 16:22:11 +09:00
Bill Currie
e942fe6528 [qwaq] Add input test app
The queues in the curses resources struct have been cleaned up and the
threading support code (including for the queues (pipes, really)) has
been moved to its own file.

The input test app currently just prints the devices and the events as
they come in, but demonstrates the new input system working in a
separate thread (though it is currently in with the curses thread).
2021-09-21 12:58:10 +09:00
Bill Currie
106ab86c3e [qwaq] Move the ui code into a library 2021-09-20 15:31:50 +09:00
Bill Currie
cc730c90b4 [input] Rework device registration
And provide functions for collecting axis and button information from a
device id.
2021-09-20 15:21:11 +09:00
Bill Currie
70812b3c49 [input] Hook up low level input to events
This includes device add and remove events, and axis and buttons for
evdev. Will need to sort out X11 input later, but next is getting qwaq
responding.
2021-08-30 14:40:19 +09:00
Bill Currie
065d0f3818 [gamecode] Make PR_RESMAP macros usable in void functions 2021-08-30 13:07:50 +09:00
Bill Currie
5d1e515e9e [qwaq] Hook up input to a certain extent
Really, just enough to show that the initialization process and hotplug
are working. The qwaq input driver is not yet properly integrated.
2021-08-30 09:59:30 +09:00
Bill Currie
b39b6031e8 [input] Give input drivers a private data pointer
The pointer can be updated at any time using the driver handle (returned
by IN_RegisterData).
2021-08-30 09:54:36 +09:00
Bill Currie
05215e0295 [util] Add functions to help convert external times 2021-08-27 12:10:05 +09:00
Bill Currie
5d4013b485 [util] Use clock_gettime for Sys_LongTime
While QF doesn't currently use nanoseconds, having access to a clock
that is not affected by setting system time is nice, and as a bonus, can
handle suspends should the need arise.
2021-08-27 11:22:57 +09:00
Bill Currie
a91dac60d9 [input] Start work on improved input system
The common input code (input outer loop and event handling) has been
moved into libQFinput, and modified to have the concept of input drivers
that are registered by the appropriate system-level code (x11, win,
etc).

As well, my evdev input library code (with hotplug support) has been
added, but is not yet fully functional. However, the idea is that it
will be available on all systems that support evdev (Linux, and from
what I've read, FreeBSD).
2021-08-27 09:10:21 +09:00
Bill Currie
8a5c3c1ac1 [util] Add sys function to get cpu count
And use it in qfvis.
2021-08-13 21:26:48 +09:00
Bill Currie
d88bd96390 [qfvis] Use cmem for portal flow stack node allocation
The portal flow stack nodes contain a simd vector, which requires
16-byte alignment. However, on 32-bit Windows, malloc returns 8-byte
aligned memory, leading to eventual segfaults. Since pstack_t is 48
bytes on 32-bit systems, it fits nicely into a 64-byte aligned cache
line (or two on 64-bit systems due to being 80 bytes).
2021-08-13 11:33:03 +09:00
Bill Currie
6fb6885b88 [qfvis] Allocate only 128MB for the main hunk
Even ad_tears didn't really need 1GB, and 32-bit machines can't really
handle 1GB (at least on windows).
2021-08-13 11:33:03 +09:00
Bill Currie
a01cafe972 [util] Minimize set growth
At the low level, only unions can cause a set to grow. Of course, things
get interesting at the higher level when infinite (inverted) sets are
mixed in.
2021-08-11 12:31:03 +09:00
Bill Currie
37a5b475c0 [util] Minimize the string for infinite sets
Instead of printing every representable member of an infinite set (ie,
up to element 63 in a set that can hold 64 elements), only those
elements up to one after the last non-member are listed. For example,

    {...} - {2 3} -> {0 1 4 ...}

This makes reading (and testing!) infinite sets much easier.
2021-08-11 12:31:03 +09:00
Bill Currie
a6a273bb07 [vulkan] Fix up test function api
Whil I can't automatically run the tests in windows builds, at least I
can make sure they build (and run individual ones by hand as necessary).
2021-08-11 12:31:03 +09:00
Bill Currie
aa72f1dc31 [util] Fix reversed finite-infinite set union ops
It looks like I tried to test it, but my tests weren't so good This
seems to cover everything for the three main set ops.
2021-08-11 12:31:03 +09:00
Bill Currie
c81f2d4b52 [video] Mark dga funcs as const when dga not available
Fixes a compile issue (warning about attribute const) when dga is not
available, thanks to spiritiit for finding it :)
2021-08-11 12:09:07 +09:00
Bill Currie
2828500f04 [qfvis] Delay freeing of winding memory
If anything, this is probably a nano-optimization, depending on how
often portals are vis-rejected. I couldn't see any actual difference.
2021-08-08 12:34:18 +09:00
Bill Currie
9a93bf8d4a [qfvis] Make cluster reconstruction O(N)
For most (if not all) maps. The heapsort is needed only if the clustered
leafs are not contiguous, but most bsp compilers output contiguous leaf
clusters, so is just a bit of protection. The difference isn't really
noticeable on a fast machine, but no point in doing more work than
necessary.
2021-08-08 12:34:18 +09:00
Bill Currie
b320c3352f [util] Make set_t endian-agnostic
Most of the set ops were always endian-agnostic since they were simply
operating on multiple bits in parallel, but individual element
add/remove/test was very endian-dependent. For the most part, this
didn't matter, but it does matter very much when loading external data
into a set or writing the data out (eg, for PVS).
2021-08-08 12:34:18 +09:00
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
42dc30ec29 [vulkan] Increase main staging buffer to 32MB
1k 32bpp sky textures need 24MB to load. Though there's always better
handling of running out of stating buffer (ie, flushing and trying
again).
2021-08-02 23:17:55 +09:00
Bill Currie
421047328a [qfvis] Catch a missed winding mark stat 2021-08-02 23:17:55 +09:00
Bill Currie
d56d8ac707 [util] Loosen up the epsilon on simd seb tests
It seems my eeepc's SSE units don't get quite the same answers as does
my i7's (maybe due to lack of hadd?).
2021-08-02 23:15:20 +09:00
Bill Currie
80b17623b1 [util] Fix an out-by-one in pqueue tests
Showed up only when the data arrays were packed.
2021-08-02 23:08:14 +09:00
Bill Currie
ec54c54226 [build] Fix some windows bitrot 2021-08-02 14:02:41 +09:00
Bill Currie
d99fb01b65 [build] Fix some distcheck bitrot 2021-08-02 13:47:00 +09:00
Bill Currie
f76964b86b [util] Add an priority queue implementation
Done via macros (like darray and ringbuffer). Might prove useful for
qfvis and maybe dynamic lights.
2021-08-02 13:29:55 +09:00
Bill Currie
4f2113bc05 [util] Enable accidentally disabled seb tests 2021-08-02 12:44:08 +09:00
Bill Currie
e4984aad17 [util] Add functions for binary heaps
Sink, swim, build and sort, both "simple" and with a data parameter for
the compare function.
2021-08-02 12:44:08 +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