Commit Graph

4520 Commits

Author SHA1 Message Date
Bill Currie 45aa8e6504 [util] Loosen affine test epsilon for SEB
Scaling the checks by 1e-6 was a little too tight for very small
triangles, but 1e-5 seems to work well. This fixes SEB getting stuck for
a ridiculously small (for quake) triangle in ad_tears (probably resulted
from some bad math in qfbsp when generating the portal file from the
bsp).
2021-07-29 15:03:54 +09:00
Bill Currie 4f51a3b406 [utils] Fix set tests for 32-bit machines 2021-07-29 14:10:18 +09:00
Bill Currie 8f376a48f8 [util] Add raw versions of hunk alloc and free
They do not clear memory and thus are good for situations where speed is
more critical.
2021-07-29 11:44:10 +09:00
Bill Currie ca63c0360a Do an audit of hunk mark usage
I realized that after making the hunk 64-bit clean, I had forgotten to
go through and convert all the saved marks to size_t.
2021-07-29 11:43:27 +09:00
Bill Currie 54604d9aa2 [util] Make hunk (optionally) thread-safe
For now, the functions check for a null hunk pointer and use the global
hunk (initialized via Memory_Init) if necessary. However, Hunk_Init is
available (and used by Memory_Init) to create a hunk from any arbitrary
memory block. So long as that block is 64-byte aligned, allocations
within the hunk will remain 64-byte aligned.
2021-07-29 11:43:27 +09:00
Bill Currie 8fdd9c1f5a [util] Write some tests for utf8 r/w
And fix some errors with 5-byte encodings.
2021-07-27 23:29:14 +09:00
Bill Currie 5b4428420e [utils] Get utf-8 writing working for up to 11 bits
I need to write some automated tests for this, and reading of course,
but 1 and two byte outputs look correct. Kind of sad it took sixteen
years to get around to attempting to use the code :(
2021-07-27 23:29:02 +09:00
Bill Currie 9e2c474d38 [model] Ensure the pvs is not inverted
Mod_DecompressVis_set (via Mod_LeafPVS_set) can be used to recycle pvs
sets, but the set may have been set to everything at some stage, which
is implemented by inverting the set (making the set infinite) and having
1-bits remove elements from the set. This is most definitely not wanted
for pvs :)

Currently undecided what to do about Mod_DecompressVis_mix, thus the
fixme.

Fixes the flickering lights in any map where the camera is out of the
map for a single frame (eg, start.bsp, The Catacombs (hipnotic, hip2m3)).
2021-07-27 17:54:50 +09:00
Bill Currie 163d147044 [util] Give set_count a >8x speed boost
I knew counting bits individually was slow, but it never really mattered
until now. However, I didn't expect such a dramatic boost just by going
to mapping bytes to bit counts. 16-bit words would be faster still, but
the 64kB lookup table would probably start hurting cache performance,
and 32-bit words (4GB table) definitely would ruin the cache. The
universe isn't big enough for 64-bits :)
2021-07-27 13:54:22 +09:00
Bill Currie 50740c1014 [model] Remove the confusion about numleafs
The fact that numleafs did not include leaf 0 actually caused in many
places due to never being sure whether to add 1. Hopefully this fixes
some of the confusion. (and that comment in sv_init didn't last long :P)
2021-07-27 12:38:08 +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 cf96f340df [util] Use same distance calc in simd CC test
The test started failing when optimizing (not sure why). Using the same
code to calculate the squared distance "fixes" the test.
2021-07-26 15:46:12 +09:00
Bill Currie c02fcee58a [util] Make zone functions 64-bit clean
This allows nq and qw clients/servers to use over 2GB of memory if
necessary.
2021-07-26 15:43:57 +09:00
Bill Currie 5fc1a36d92 [gamecode] Be more forgiving of unresolved builtins
If the progs code never calls the functions, then there is no problem.
Thus unresolved builtin references get pointed to the bad function
builtin.
2021-07-26 13:35:35 +09:00
Bill Currie 2e33503c4c [vulkan] Fix a missed array index edit
Caused by the view model implementation, and missed because gcc needs
optimization to cache such errors (and my own error, of course).
2021-07-26 11:43:31 +09:00
Bill Currie f47e03e606 [model] Remove 64k limit on visible leafs
Modern maps can have many more leafs (eg, ad_tears has 98983 leafs).
Using set_t makes dynamic leaf counts easy to support and the code much
easier to read (though set_is_member and the iterators are a little
slower). The main thing to watch out for is the novis set and the set
returned by Mod_LeafPVS never shrink, and may have excess elements (ie,
indicate that nonexistent leafs are visible).
2021-07-26 11:32:05 +09:00
Bill Currie 03921c03c5 [util] Expose set_expand and fix an out-by-one bug
Having set_expand exposed is useful for loading data into a set.

However, it turns out there was a bug in its size calculation in that
when the requested set size was a multiple of SET_BITS (and greater than
the current set size), the new set size one be SET_BITS larger than
requested. There's now some tests for this :)
2021-07-26 09:54:03 +09:00
Bill Currie 7995f59a90 [vulkan] Set the 2d near distance to 0
-999999 seems to be a hold-over from the software renderer passed
through both gl renderers. I guess it didn't matter in the gl renderers
due to various draw hacks, but it made quite a difference in vulkan.
Fixes the view model covering the hud.
2021-07-25 14:21:37 +09:00
Bill Currie 56c2fa380b [vulkan] Implement view model rendering
Quake just looked wrong without the view model. I can't say I like the
way the depth range is hacked, but it was necessary because the view
model needs to be processed along with the rest of the alias models
(didn't feel like adding more command buffers, which I imagine would be
expensive with the pipeline switching).
2021-07-25 14:03:25 +09:00
Bill Currie 81f73e4524 [gamecode] Support printing a single edict field 2021-07-25 09:54:08 +09:00
Bill Currie 86cf7fbecd [gamecode] Check for null edict before printing number
Avoids segfault during double-verbose disassembly of progs code that
uses entities.
2021-07-24 18:04:57 +09:00
Bill Currie 7868936b96 [vulkan] Correct the skysheet scaling
Dunno where that 8 came from, but it's quite a bit different from 189/64
(2.953125). Fixes the excessively high skies in vulkan.
2021-07-24 14:23:06 +09:00
Bill Currie 1300cfb14e [console] Clean up key_menu input handling
Missed this little change in the menu/console untangling.
2021-07-24 14:21:54 +09:00
Bill Currie 40a26e4bc8 [scene] Rename libQFentity to libQFscene
And start working on scene management.
2021-07-24 14:20:59 +09:00
Bill Currie 435009e2cd [entity] Update local rotation and scale caches
When setting local rotation/scale/transform, need to cache the rotation and
scale, otherwise they can't be fetched easily later on (position is easy as
it's just the fourth column of the matrix).
2021-07-24 11:31:00 +09:00
Bill Currie 632d2cb79c [console] Plug another escape handler leak 2021-07-24 00:28:49 +09:00
Bill Currie fbbf83e696 [console] Pop menu escape in forced close menu
Fixes loss of access to the menu after selecting a new game via the menu.
2021-07-23 21:15:01 +09:00
Bill Currie c134e9d348 [renderer] Remove R_EnqueueEntity from the plugin funcs
Forgot about this when fixing the ctf flags.
2021-07-23 12:46:53 +09:00
Bill Currie 3b586fc0a6 [console] Untangle console and menu toggling
The recent changes to key handling broke using escape to get out of the
console (escape would toggle between console and menu). Thus take care
of the menu (escape) part of the coupling FIXME by implementing a
callback for the escape key (and removing key_togglemenu) and sorting
out the escape key handling in console. Seems to work nicely
2021-07-23 02:28:37 +09:00
Bill Currie e089234f38 [console] Link against libQFruamoko_console
Fixes shared plugin not loading due to missing symbol.
2021-07-22 18:01:18 +09:00
Bill Currie 49afdde77f [vulkan] Add some comments and clean some code
Figuring out bsp rendering for shadows is a fair bit harder than
expected :P
2021-07-22 16:15:14 +09:00
Bill Currie f1ac8f2460 [renderer] Remove currententity from non-sw renderers
Really needed only for vulkan, but removing currententity from gl and
glsl made testing easier.
2021-07-22 16:15:14 +09:00
Bill Currie 41de8c9187 [util] Cast swapped signed shorts in bspfile
This fixes a bug when loading bsp29 files that resulted in leaf nodes
having bogus bounding boxes if any coordinates were negative (and thus
dynamic lights, and probably all sorts of other things) being broken.
And it took me only 9 years to notice :P
2021-07-22 14:25:51 +09:00
Bill Currie 3351b62318 [renderer] Move driver specific texture chain defs
The GL/GLSL/Vulklan texture chaining defs never should have been in
r_internal.h in the first place. They still need a better name, though.
2021-07-21 16:36:51 +09:00
Bill Currie 0f259c647b [vulkan] Clean out some dead code
While I might want to support lightmaps in the future (eg, for ambient
occlusion), the commented out code is confusing.
2021-07-21 14:54:07 +09:00
Bill Currie 5864406f4d [vulkan] Enable all lights when camera out of map
Without shadows, this is quite the cheat, but noclip is a cheat anyway,
so probably not that big a deal. It does, however, make noclip usable
for debugging.
2021-07-21 14:15:56 +09:00
Bill Currie 6962c5948a [vulkan] Clean up some more unused bsp data
Since vulkan supports 32-bit indexes, there's no need for the
shenanigans the EGL-based glsl renderer had to go through to render bsp
models (maps often had quite a bit more than 65536 vertices), though the
reduced GPU memory requirements of 16-bit indices does have its
advantages.
2021-07-19 23:38:09 +09:00
Bill Currie 924c970868 [vulkan] Pre-compute the sun's PVS
Any sun (a directional light) is in the outside node, which due to not
having its own PVS data is visible to all nodes, but that's a tad
excessive. However, any leaf node with sky surfaces will potentially see
any suns, and leaf nodes with no sky surfaces will see the sun only if
they can see a leaf that does have sky surfaces. This can be quite
expensive to calculate (already known to be moderately expensive for
just the camera leaf node (singular!) when checking for in-map lights)
2021-07-19 22:36:51 +09:00
Bill Currie 3ef89583af [gamecode] Correct pop implementations
Had src and dst swapped (yay for not testing :P (boo for not having an
easy way to test (yay for working on it))).
2021-07-19 22:31:22 +09:00
Bill Currie 87dc35e2fd [renderer] Be more consistent with msurface_t names
Use "surf" everywhere in gl, glsl and vulkan. Not worried about sw/sw32
at this stage (I don't poke around in there anywhere near as much).
2021-07-19 06:55:36 +09:00
Bill Currie 3c93d555e3 [gl] Correct calculation of screen aspect
vrect_t's fields are ints, and it was vid.aspect that prevented the
quotient being truncated. Fixes the rather squashed looking world.
2021-07-19 06:55:36 +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 f7efcde7ab [vulkan] Clean up and document some of the bsp code
Getting close to understanding (again) how it all works. I only just
barely understood when I got vulkan's renderer running, but I really
need to understand for when I modify things for shadows. The main thing
hurdle was tinst, but that was dealt with in the previous commit, and
now it's just sorting out the mess of elechains and elementss.
2021-07-13 22:59:51 +09:00
Bill Currie c8e6f71a30 [renderer] Remove tinst from msurface_t
Its sole purpose was to pass the newly allocated instsurf when chaining
an instance model (ammo box, etc) surface, but using expresion
statements removes the need for such shenanigans, and even makes
msurface_t that little bit smaller (though a separate array would be
much better for cache coherence).

More importantly, the relevant code is actually easier to understand: I
spent way too long working out what tinst was for and why it was never
cleared.
2021-07-13 16:02:47 +09:00
Bill Currie 1078bd9efa [util] Implement Sys_Free for windows
And get the tests so they can (sort of) be run.
2021-07-12 18:55:16 +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 12450fe6b8 [vid] Remove redundant direct, conbuffer and conrowbytes 2021-07-11 13:44:00 +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 91eeae5186 [qw] Clean up netgraph somewhat
The renderer's LineGraph now takes a height parameter, and netgraph now
uses cl_* cvars instead of r_* (which never really made sense),
including it's own height cvar (the render graphs still use
r_graphheight).
2021-07-11 10:59:27 +09:00
Bill Currie 3c0ad2ca71 [qw] Fix some server status output issues
The uptime display had not been updated for the offset Sys_DoubleTime,
so add Sys_DoubleTimeBase to make it easy to use Sys_DoubleTime as
uptime.

Line up the layout of the client list was not consistent for drop and
qport.
2021-07-11 08:18:02 +09:00