Commit graph

12614 commits

Author SHA1 Message Date
Bill Currie
925300716b [mode] Go back to using dclipnode_t everywhere
It was added only because FitzQuake used it in its pre-bsp2 large-map
support. That support has been hidden in bspfile.c for some time now.
This doesn't gain much other than having one less type to worry about.

Well tested on Conflagrant Rodent (the map that caused the need for
mclipnode_t in the first place).
2022-05-19 15:16:53 +09:00
Bill Currie
688f17fda3 Correct some typos in comments/docs 2022-05-19 13:26:45 +09:00
Bill Currie
0bf903afd0 [bspfile] Document the bsp file data structures
While I still have a couple of questions unanswered, this takes care of
what I needed to know for now (and then some).
2022-05-19 13:26:45 +09:00
Bill Currie
ee19a928a0 [model] Make the miptex toupper clearer
That bit of code got me every time I looked at it.
2022-05-19 13:26:45 +09:00
Bill Currie
0ba8d44654 More doxygen tweaks 2022-05-19 13:26:45 +09:00
Bill Currie
495e71193e [input] Fix some doxygen breakage 2022-05-19 13:26:45 +09:00
Bill Currie
765b61d133 [vulkan] Remove elements_t type
This was one of the biggest reasons I had trouble understanding the bsp
display list code, but it turns out it was for dealing with GLES's
16-bit limit on vertex indices. Since vulkan uses 32-bit indices,
there's no need for the extra layer of indirection. I'm pretty sure it
was that lack of understanding that prevented me from removing it when I
first converted the glsl bsp code to vulkan (ie, that 16-bit indices
were the only reason for elements_t).

It's hard to tell whether the change makes much difference to
performance, though it seems it might (noisy stats even over 50 timedemo
loops) and the better data localization indicate it should at least be
just as good if not better. However, the reason for the change is
simplifying the data structures so I can make bsp rendering thread-safe
in preparation for rendering shadow maps.
2022-05-19 13:26:45 +09:00
Bill Currie
beb05f28ff [glsl,vulkan] More comments in the bsp code
And maybe a nano-optimization. Switching from (~side + 1) to (-side)
seems to give glsl a very tiny speed boost, but certainly doesn't hurt.
Looking at some assembly output for the three cases, the two hacks seem
to generate the same code as each other, but 3 instructions vs 6 for ?:.
While ?: is more generically robust, the hacks are tuned for the
knowledge side is either 0 or 1. The later xor might alter things, but
at least I now know that the hack (either version) is worthwhile.
2022-05-19 13:26:45 +09:00
Bill Currie
bc82241e1c [client] Pre-cache temp entity data after clearing memory
This is a particularly ancient bug, sort of introduced by rhamph when he
optimized temp entity model handling and later exacerbated by me.
However, I suspect the actual problem is limited to nq as qw's gamedir
handling would have caused the models to be reloaded, but nq doesn't
ever change game directories once running.
2022-05-19 13:26:45 +09:00
Bill Currie
3639ee3d2d [vulkan] Just simply exit for validation errors
With experience, I have found that trying to continue after a validation
error tends to result in a segfault or some other nastiness, and
Sys_Shutdown (and the full shutdown sequence) is triggered for any error
signal (segfault, abort, etc) so just exit(1).
2022-05-19 13:26:45 +09:00
Bill Currie
f97fb90d90 [model] Fix alias skin group loading
Although the skin pointer was being advanced after recording the
information in for the batch array, it was being reset the next time
around the loop (due to a mistranslation of the previous code). This
fixes the segfault while loading (gl, glsl, vulkan) or rendering (sw)
the sphere model from Rogue.
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
be635804d1 [vulkan] Clean up display list building and add some comments
Some very much needed comments :P Still, nicely, I now have a much
better understanding of how the display lists are created (10 years
is a long time to remember how intricate code works (I do remember
fighting to get it working back then))
2022-05-19 13:26:45 +09:00
Bill Currie
249feb1ae8 [glsl] Clean up build_surf_displist
This makes it much easier to see just what is being done to build a
polygon to be passed to the GPU, and it served as a test for the
lightmap st changes since Vulkan currently never used them.
2022-05-19 13:26:45 +09:00
Bill Currie
45431a0bcc [vulkan] Use absolute light intensity/radius for size
Many modders use negative lights for interesting effects, but vulkan
doesn't like the result of a negative int treated as unsigned when it
comes to texture sizes.
2022-05-19 13:26:45 +09:00
Bill Currie
27de599ac4 [vulkan] Resurrect the shadow map resource creation
However, this time it doesn't modify the light array when it sorts the
lights by size since the lights are now located before the renderer gets
to see them, and having the fix up the light leafs array would be too
painful (and probably the completely wrong thing to do anyway: the light
array should be treated as constant by the renderer). 1.6GB of memory
for gmsp3v2's lights (a little better than marcher: more smaller lights?).

For reference:
gmsp3v2: shadow maps: 8330 layers in 29 images: 1647706112
marcher: shadow maps: 2440 layers in 11 images: 2358575104
2022-05-19 13:26:45 +09:00
Bill Currie
d3965af2ae [scene] Improve directional light handling
While it wasn't the root cause of the disappearing lights (even after
sorting out the light limit issue), because the cause of that was
everything working as designed, I suspect sunlight wasn't reaching as
far as it should. Even it it was, this should be slightly faster
(especially for larger maps) as leafs can be tested 32 or 64 at a time
rather than individually.
2022-05-19 13:26:45 +09:00
Bill Currie
775f3b87a8 [bsp] Add a comment about leaf marksurfaces
They should probably be cause leafsurfaces since they are the actual
surfaces of the leaf: ie, the faces of the leaf mesh if each leaf was
sub-sub-model.
2022-05-19 13:26:45 +09:00
Bill Currie
e1e4bf5659 [vulkan] Up the light limit to 768
For now, at least (I have some ideas to possibly reduce the numbers and
also to avoid the need for actual limits). I've seen gmsp3v2 use over
500 lights at once (it has over 1300), and I spent too long figuring out
that weird light behavior was due to  the limit being hit and lights
getting dropped (and even longer figuring out that more weird behavior
was due to the lack of shadows and the world being too bright in the
first place).
2022-05-19 13:26:45 +09:00
Bill Currie
9237d83b56 [vulkan] Fix some comments and developer output 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
54b6573470 [client] Change location of sun vector negation
Moving the negation into the calculation of the sun angle prevents -0
getting into the vector (not that it makes much difference other than
minor confusion when reading the light data).
2022-05-19 13:26:45 +09:00
Bill Currie
cfe7064708 [nq] Update weapon model for SU_WEAPON2
This fixes the missing view weapon in vulkan and crashes in other
renderers when playing Conflagrant Rodent.
2022-05-19 13:26:19 +09:00
Bill Currie
7abdfc421e [nq] Enable blue and red lights for quad and invulnerability
I got tired of being disappointed that nq didn't have colored lights for
the power-ups (especially when I'd waste time thinking it was a bug).
The problem is that the server (progs code) specifies only DIMLIGHT (qw
adds in the colors). Another problem is that the server tells us only
our own stats, so the colors are disabled for multiplayer otherwise it
might be confusing.
2022-05-18 11:06:39 +09:00
Bill Currie
a2d50395d6 [qw] Correct client shutdown order
This is similar to the change in nq (and for the same reason), making
sure that client shutdown (and thus config writing) happens before input
system shutdown.
2022-05-18 09:46:05 +09:00
Bill Currie
0b9d36b08d [nq] Fix some level change segfaults
I really need to play more while working on the code.

Anyway, ca_active works nicely for the status bar in general, and
CL_ClearMemory needs to be called before Host_ClearMemory when doing
single-player.
2022-05-17 10:28:57 +09:00
Bill Currie
ceaac00453 [vulkan] Free the staging buffer's command buffers
Since the staging buffer allocates the command buffers it uses, it
needs to free them when it is freed. I think I was confused by the
validation layers not complaining about unfreed buffers when shutting
down, but that's because destroying the pool (during program shutdown,
when the validation layers would complain) frees all the buffers. Thus,
due to staging buffers being created and destroyed during the level load
process, (rather large) command buffers were piling up like imps in a
Doom level.

In the process, it was necessary to rearrange some of the shutdown code
because vulkan_vid_render_shutdown destroys the shared command pool, but
the pool is required for freeing the command buffers, but there was a
minor mess of long-lived staging buffers being freed afterwards. That
didn't end particularly well.
2022-05-13 10:19:08 +09:00
Bill Currie
0dca1e1124 [plugin] Pull plugin from list before calling its shutdown
This ensures that the plugin's shutdown function won't get called twice
in the event of an error in the plugin's unload sequence triggering a
second Sys_Shutdown, especially if the plugin is being unloaded as a
part of another sub-system's shutdown sequence (which is probably in
itself a design mistake, need to look into that).
2022-05-13 09:50:24 +09:00
Bill Currie
3823ea1858 [vulkan] Plug some memory leaks
I still can't find the run-time leak. I suspect something that
accumulates but gets freed on exit.
2022-05-13 00:55:37 +09:00
Bill Currie
ef87baf339 [model] Undo brush texture changes in 4f58429137
While gcc was quite correct in its warning, all I needed was to
explicitly truncate the string. I don't remember why I didn't do that
back when I made the changes in 4f58429137, but it works now, and the
surrounding code does expect the string to be no more than 15 chars
long. This fixes yet another memory leak (but timedemo over multiple
runs still leaks like a sieve).
2022-05-13 00:46:27 +09:00
Bill Currie
1f811e6310 [nq] Fix a particularly nasty memory leak
Nasty because it was caused by spaghetti (normally, I like the stuff).
Drinking-age spaghetti at that. Nicely, this removes the need for one
function in sv_ded.c (which is what I think I was trying to achieve).
2022-05-12 22:49:48 +09:00
Bill Currie
a17deb3ef2 [nq] Don't double-allocate timedemo data buffer
Looks like a copy/paste error (wild guess: got my fingers tangled in
vim).
2022-05-12 22:48:31 +09:00
Bill Currie
50226a64c3 [ruamoko] Free buffer used for loading plists
That's definitely a leak.
2022-05-12 22:47:55 +09:00
Bill Currie
aabf3e14f8 [model] Support freeing of skin data
I doubt it's enough, but it does seem to cover what's needed for glsl
(maybe not the actual textures, unsure there, but I think they're
recycled).
2022-05-12 22:46:31 +09:00
Bill Currie
4e526702dd [nq] Plug some memory leaks and fix a shutdown error
The error was introduced by the input memory leak fixes, but the
solution is to ensure CL_Shutdown is called before IN_Shutdown.

Some of the memory leaks were quite legitimate this time.
2022-05-12 20:58:39 +09:00
Bill Currie
bc674657cb [plugin] Ensure plugins get unloaded during shutdown
This included pre-registered (static) plugins.

Surprisingly, PI_Shutdown was never called.
2022-05-12 20:58:39 +09:00
Bill Currie
4562e1ea6c [qw] Plug a pile of memory leaks.
Whee.
2022-05-12 19:58:18 +09:00
Bill Currie
ccb56c93e6 [client] Free default input config plist
Yet another memory leak.
2022-05-12 19:58:18 +09:00
Bill Currie
4defba8251 [ui] Free the view's children array
This would have leaked memory if views were being created and destroyed
dynamically instead of just the once-off in the current code.
2022-05-12 19:58:18 +09:00
Bill Currie
a1d8319b48 [sound] Don't free realname in the vorbis loader
Luckily, it was almost never hit (error condition), but the code doesn't
own the pointer.
2022-05-12 19:58:18 +09:00
Bill Currie
826d66efaf [gib] Plug some memory leaks
Builtins seem to leak a little on shutdown. Not sure how they are in a
long running app.
2022-05-12 19:58:18 +09:00
Bill Currie
edf5c66321 [cvar] Plug a pile of memory leaks
Mostly in user cvars, but also any string vars.
2022-05-12 19:58:18 +09:00
Bill Currie
8db8f91e7d [input] Plug a pile of memory leaks
While most were "harmless" in that they were held pointers at shutdown,
a few bugs were exposed in the imt code.
2022-05-12 19:58:18 +09:00
Bill Currie
973ae0ad54 [gamecode] Add PR_Shutdown for tearing down a VM
This is meant for a "permanent" tear-down before freeing the memory
holding the VM state or at program shutdown. As a consequence, builtin
sub-systems registering resources are now required to pass a "destroy"
function pointer that will be called just before the memory holding
those resources is freed by the VM resource manager (ie, the manager
owns the resource memory block, but each subsystem is responsible for
cleaning up any resources held within that block).

This even enhances thread-safety in rua_obj (there are some problems
with cmd, cvar, and gib).
2022-05-12 19:58:18 +09:00
Bill Currie
b7b6d4ad12 [hash] Clean up some duplicate code
Hash_Add and Hash_AddElement differed by only one line: the hash
calculation.
2022-05-12 18:52:36 +09:00
Bill Currie
f91167d74a [hash] Use uintptr_t for all hashes
This fixes the inconsistent hash types and removes all references to
"long", making for better portability.
2022-05-12 18:52:36 +09:00
Bill Currie
978d0306c0 [hash] Rename the publicly visible hashlink_t to hashctx_t
I think my biggest problem with the hashlink freelist parameter was how
much implementation it exposed in just the name.
2022-05-12 18:02:01 +09:00
Bill Currie
ad8599574a [qw] Use SCR_NewScene instead of R_ClearState
This is the same issue as in nq, but I'd entirely forgotten to do qw. I
imagine similar segfaults would have occurred.
2022-05-11 14:47:01 +09:00
Bill Currie
4515b0d7f0 [nq] Use SCR_NewScene in CL_SetState
This was missed when changing CL_ClearState. Fixes segfault on respawn.
2022-05-11 14:47:01 +09:00
Bill Currie
86faeba31a [vulkan] Plug some leaking sprite descriptors
I'd forgotten to free them when unloading a model, thus the segfault
after about 31 timedemo runs.
2022-05-11 01:52:22 +09:00