Commit Graph

5574 Commits

Author SHA1 Message Date
Bill Currie c8c1d2e642 [console] Add a pile of of comments to Con_BufferAddText
And make tail_line setup a little clearer.
2022-09-17 14:22:28 +09:00
Bill Currie 9a92496662 [console] Don't overwrite tail line if same as current line
This fixes the current line object getting corrupted by the tail line
update when the buffer is filled with a single line. There are probably
more tests to write and bugs to fix :)
2022-09-17 13:56:23 +09:00
Bill Currie d13df6cd37 [console] Add failing unit test for con_buffer
I was looking through the code for Con_BufferAddText trying to figure
out what it was doing (answer: ring buffer for both text and lines) and
got suspicious about its handling of the line objects. I decided an
automated test was in order. It turns out I was right: filling the
buffer with a single long line causes the tail line to trample the
current line, setting its pointer and length to 0 when the final
character is put in the buffer.
2022-09-17 12:59:36 +09:00
Bill Currie 437e447b6b [renderer] Add a buffer print function
It handles basic cursor motion respecting \r \n \f and \t (might be a
problem for id chars), wraps at the right edge, and automatically
scrolls when the cursor tries to pass the bottom of the screen.

Clearing the buffer resets its cursor to the upper left.
2022-09-16 00:58:25 +09:00
Bill Currie c5099d30b1 [renderer] Fix access to freed memory loading fonts
QFS_LoadFile closes its file argument (this is a design error resulting
from changing QFS_LoadFile to take a file instead of a path and not
completing the update), resulting in the call to Qfilesize accessing
freed memory.
2022-09-15 14:32:16 +09:00
Bill Currie 25a14eb232 [renderer] Add a cell-based character buffer
This is intended for the built-in 8x8 bitmap characters and quake's
"conchars", but could potentially be used for any simple (non-composed
characters) mono-spaced font. Currently, the buffers can be created,
destroyed, cleared, scrolled vertically in either direction, and
rendered to the screen in a single blast.

One of the reasons for creating the buffer is to make it so scaling can
be supported in the sw renderer.
2022-09-15 14:24:33 +09:00
Bill Currie 98f773b0ed [gamecode] Expose value_string as PR_Debug_ValueString
PR_Debug_ValueString prints the value at the given offset using the
provided type to format the string. The formatted string is appended to
the provided dstring.
2022-09-15 00:30:21 +09:00
Bill Currie aa41e6c4c6 [gamecode] Expose value_string as PR_Debug_ValueString
PR_Debug_ValueString prints the value at the given offset using the
provided type to format the string. The formatted string is appended to
the provided dstring.
2022-09-14 19:23:59 +09:00
Bill Currie c771bfa58c [renderer] Correct freetype and harfbuzz lib linking
renderer_libs was in both LIBADD and DEPENDENCIES, so make was trying to
build the freetype and harfbuzz libs when building for windows.
2022-09-13 17:38:58 +09:00
Bill Currie 6ed045cd9c [audio] Ensure FLAC doesn't use dll imports
For whatever reason, building under MXE (for windows) causes FLAC to try
to use dll import references, but setting FLAC__NO_DLL before including
FLAC/export.h fixes the issue.
2022-09-13 17:13:57 +09:00
Bill Currie bf7ef354d5 [audio] Ensure FLAC doesn't use dll imports
For whatever reason, building under MXE (for windows) causes FLAC to try
to use dll import references, but setting FLAC__NO_DLL before including
FLAC/export.h fixes the issue.
2022-09-13 17:09:42 +09:00
Bill Currie 99196550d1 [renderer] Move r_font.c to correct library
Fixes the linker error in the standard build.
2022-09-12 08:43:28 +09:00
Bill Currie 71efbba628 [vulkan] Switch draw_pic to take subpic_t instead of qpic_t
While this does pull the grovelling for the subpic out to the callers,
the real problem is the excessive use of qpic_t in the internal code:
qpic_t is really just the image format in wad files, and shouldn't be
used as a generic image handle.

Cleans up more of the icky code in the font drawing functions.
2022-09-09 20:05:31 +09:00
Bill Currie 936f6d91e4 [vulkan] Use vertex queue objects for Draw
This makes working with quads, implied alpha quads, and lines much
cleaner (and gets rid of the bulk of the "eww" fixme), and will probably
make it easier to support multiple scraps and fonts, and potentially
more flexible ordering between pipelines.
2022-09-09 17:06:33 +09:00
Bill Currie a6611fc827 [gamecode] Fix a clang compile issue
Silly clang not being actually compatible :P
2022-09-09 14:59:08 +09:00
Bill Currie a76f6c812c [gamecode] Fix a clang compile issue
Silly clang not being actually compatible :P
2022-09-09 14:57:30 +09:00
Bill Currie 019b40fb81 [ruamoko] Implement %@ handing in the ruamoko runtime
-describe is sent to the object, and the returned string passed back.
There is a worry about the lifetime of the returned string as there's
currently no way of both ensuring it doesn't get freed prematurely and
ensuring it does eventually get freed.
2022-09-09 14:48:03 +09:00
Bill Currie be447fc9d6 [gamecode] Add optional support for %@ strings
If no handler has been registered, then the corresponding parameter is
printed as a pointer but with surrounding brackets (eg, [0xfc48]). This
will allow the ruamoko runtime to implement object printing.
2022-09-09 14:48:03 +09:00
Bill Currie 54bd8f5a02 [ruamoko] Implement %@ handing in the ruamoko runtime
-describe is sent to the object, and the returned string passed back.
There is a worry about the lifetime of the returned string as there's
currently no way of both ensuring it doesn't get freed prematurely and
ensuring it does eventually get freed.
2022-09-09 13:51:42 +09:00
Bill Currie 6db44afedc [gamecode] Add optional support for %@ strings
If no handler has been registered, then the corresponding parameter is
printed as a pointer but with surrounding brackets (eg, [0xfc48]). This
will allow the ruamoko runtime to implement object printing.
2022-09-09 09:27:36 +09:00
Bill Currie 935e883d8d [renderer] Switch to using HarfBuzz for glyph positioning
This means that QF should support more exotic fonts without any issue
(once the rest of the text handling system is up to snuff) as HarfBuzz
does all the hard work of handling OpenType, Graphite, etc text shaping,
including kerning (when enabled).

Also, font loading now loads all the glyphs into the atlas (preload is
gone).
2022-09-04 20:56:38 +09:00
Bill Currie db69f5fd23 [renderer] Use VRect_SubRect for scrap allocation
While the results are a little surprising (tends to alternate between
left side and top for allocations), there is much less wasted space in
the partially allocated regions, and the main free region seems to
always be quite big.
2022-09-02 19:08:58 +09:00
Bill Currie 28e9a0a9ba [ui] Add a specialized function for subrect allocation
While VRect_Difference worked for subrect allocation, it wasn't ideal as
it tended to produce a lot of long, narrow strips that were difficult to
reuse and thus wasted a lot of the super-rectangle's area. This is
because it always does horizontal splits first. However, rewriting
VRect_Difference didn't seem to be the best option.

VRect_SubRect (the new function) takes only width and height, and splits
the given rectangle such that if there are two off-cuts, they will be
both the minimum and maximum possible area. This does seem to make for
much better utilization of the available area. It's also faster as it
does only the two splits, rather than four.
2022-09-02 17:47:27 +09:00
Bill Currie cd66dbfc97 [vulkan] Implement font rendering
It is currently an ugly hack for dealing with the separate quad queue,
and the pipeline handling code needs a lot of cleanup, but it works
quite well, though I do plan on moving to HarfBuzz for text shaping. One
nice development is I got updating of descriptor sets working (just need
to ensure the set is no longer in use by the command queue, which the
multiple frames in flight makes easy).
2022-09-02 14:23:19 +09:00
Bill Currie 73635d84bf [renderer] Add stubs for Draw_FontString
Draw_FontString is for font-based text rendering. Nothing is implemented
at this stage.
2022-09-02 11:38:09 +09:00
Bill Currie 599c09e77e [renderer] Add Draw_AddFont for registering a font
It's implemented only in the Vulkan renderer, partly because there's a
lot of experimenting going on with it, but the glyphs do get transferred
to the GPU (checked in render doc). No rendering is done yet: still
thinking about whether to do a quick-and-dirty test, or to add HarfBuzz
immediately, and the design surrounding that.
2022-08-31 19:23:30 +09:00
Bill Currie 096ecc7710 [vulkan] Fix incorrect image view format
R8G8B8A8 was hard-coded by accident when creating Vulkan_LoadTexArray
(or probably even the original Vulkan_LoadTex). This wasn't a problem
while everything was loaded in that format, but attempting to load an R8
texture didn't go so well. The same format as the image itself is used
now (correctly so).
2022-08-31 18:14:24 +09:00
Bill Currie 8c270a0a9e [vulkan] Switch to pre-multiplied alpha for 2d
I have recently learned that pre-multiplied alpha is the correct way to
do compositing, which is pretty much what the 2d pass does (actually,
all passes, but...). This required ensuring the color factor passed to
the fragment shader is pre-multiplied (a little silly for cshifts as
they used to be pre-multiplied but were un-pre-multiplied early in QF's
history and I don't feel like fixing that right now as it affects all
renderers), and also pre-multiplying alpha when converting from 8-bit
palette to rgba as the palette entry for transparent has that funky pink
(which is used in full-brights).
2022-08-30 14:29:22 +09:00
Bill Currie 4d5b38f0c9 [renderer] Star work on adding FreeType support
Right now, this just initializes the library and loads a font into
memory, preloading a given set of characters (specified by unicode
values).
2022-08-27 17:53:03 +09:00
Bill Currie d39f02ecfc [renderer] Don't round up scrap allocations
I will need to do more work to improve the 2d allocation, but rounding
up the requested sizes to the next power of two proved to be excessively
wasteful: I was able to allocate spots for only half of the sub-pics I
needed (though I did still need to double the number of pixels in the
end).
2022-08-27 17:46:14 +09:00
Bill Currie 630dde6df7 [render] Add basic 2d line drawing
The software renderer uses Bresenham's line slice algorithm as presented
by Michael Abrash in his Graphics Programming Black Book Special Edition
with the serial numbers filed off (as such, more just so *I* can read
the code easily), along with the Chen-Sutherland line clipping
algorithm. The other renderers were more or less trivial in comparison.
2022-08-27 17:29:15 +09:00
Bill Currie f611b0d5a1 [client] Preserve intensity when parsing light color
Due to the mis-initialization of the union used to parse the color
vector, the intensity was incorrectly set to zero and thus the light
dropped, meaning that all lights in ad_tears were lost.
2022-08-19 20:19:43 +09:00
Bill Currie 1e54799f69 [gamecode] Take care of failing uint conversion tests
By not doing the unrepresentable conversions, since they seem to be
undefined behavior and even gcc 12 is inconsistent with them
2022-08-18 18:18:19 +09:00
Bill Currie d9d0a80752 [gamecode] Add an extend instruction
The extend instruction is for loading narrower data types into wider
data types, eg, single element into 2, 3, or 4 element types, with a
small set of extension schemes: 0, 1, -1, copy (for 1->any and 2 -> 4).
Possibly most importantly, it works with unaligned data.

Progress towards #30
2022-08-18 18:18:19 +09:00
Bill Currie 0897952a57 Fix windows compile issues
ulong seems to be defined somewhere on Linux, thus I missed that, and of
course there's the fun with aligned memory allocation :/
2022-07-31 17:34:09 +09:00
Bill Currie 732ea3a5fd Fix a bunch of issues for clang
One *actual* error (wrong enum type), and some memory alignment issues.
The rest just clang being lame.
2022-07-31 17:15:40 +09:00
Bill Currie 2c8bec27c7 Fix a pile of warnings for gcc 12
Most were pretty easy and fairly logical, but gib's regex was a bit of a
pain until I figured out the real problem was the conditional
assignments.

However, libs/gamecode/test/test-conv4 fails when optimizing due to gcc
using vcvttps2dq (which is nice, actually) for vector forms, but not the
single equivalent other times. I haven't decided what to do with the
test (I might abandon it as it does seem to be UD).
2022-07-31 17:13:26 +09:00
Bill Currie 330569a3fb [sound] Add a function to set ambient sounds
This gets ambient sounds (in particular, water and sky) working again
for quakeworld after the recent sound changes, and again for nq after I
don't know how long.
2022-06-06 14:29:14 +09:00
Bill Currie c72b04a522 [cvar] Remove a debug print 2022-06-06 14:28:28 +09:00
Bill Currie 520371a3aa [zone] Fix bad suggested mem calculation
Because the calculation didn't take the hunk header size (which is not
included in the hunk size) into account, the conversion to MB was one
short and thus the rounding up to the next 8 MB boundary was giving the
current total hunk size (ie, the already given size). Most confusing to
a user ("But I already asked for 128MB!").
2022-06-06 14:05:52 +09:00
Bill Currie ef64161835 [zone] Make Hunk_RawAlloc the core hunk allocator
It turns out that copying just "unknown" is a significant performance
hit when doing over 100M allocations. Making Hunk_RawAlloc the core and
initializing the name field with a single 0 shaved about a second off
`qfvis gmsp3v2.bsp` (from about 39s to about 38s).
2022-06-06 13:33:54 +09:00
Bill Currie 5c94c40985 [zone] Revert cache behavior to its original design
My reason for using Hunk_HighAlloc for allocating cache blocks was to
lock them down so they were safe for the sound mixer to access when
running in a real-time thread. However, I had never tested under tight
memory constraints, which proved that the design (or maybe just
implementation) just wasn't robust. However, now that sounds are loaded
into a completely separate region, it's safe to put the cache back to
its original behaviour (still with 64-byte alignment and such, of
course). This will even allow the high hunk to be used again, though it
effectively was anyway with Hunk_TempAlloc.
2022-06-06 13:33:15 +09:00
Bill Currie 5fa73e7ff2 [sound] Rename "cache" to "block" and clean out old code
I never liked "cache" as a name because it said where the sound was
stored rather than how it was loaded/played, but "stream" is ok, since
that's pretty much spot on. I'm not sure "block" is the best, but it at
least makes sense because the sounds are loaded as a single block (as
opposed to being streamed). An now, neither use the cache system.
2022-06-06 12:39:54 +09:00
Bill Currie 79f3f651a4 [sound] Bring QF into the atomic age
Nuclear powered audio ;)

More seriously, use _Atomic on a few fields that very obviously need it.
That is, channel's buffer pointer (used to signal to the mixer that the
channel is ready for use) and "flow control" flags (stop, done and
pause), and head and tail in the buffer itself. Since QF has been
working without _Atomic (admittedly, thanks to luck and x86's strong
memory model), this should do until proven otherwise. I imagine getting
stream reading out of the RT thread will highlight any issues.
2022-06-06 12:39:54 +09:00
Bill Currie 7bbfde03fc [sound] Plug the channel leak
Turned out the channels simply weren't being freed by SND_ScanChannels
when they should have been (probably a good thing, too, as it wasn't
being told to wait for the mixer).
2022-06-06 12:39:54 +09:00
Bill Currie fdd070f6dc [sound] Add a threaded field to snd_t
Care needs to be taken when freeing channels as doing so while an
asynchronous mixer is using them is unlikely to end well. However,
whether the mixer is asynchronous depends on the output driver. This
lets the driver inform the rest of the system that the output and mixer
are running asynchronously.
2022-06-06 12:39:54 +09:00
Bill Currie 48f704c84e [sound] Use SYS_snd for all masked prints
SYS_dev is a holdover from when we had only the one flag and is not
meant to be used for tests (I seem to remember mentioning an audit was
necessary, but obviously forgotten). One step at a time, I guess :)
2022-06-06 12:39:54 +09:00
Bill Currie 91140acfee [sound] Access the buffer directly from the channel
This improves the locality of reference when mixing and removes the
proxy sfx for streamed sounds.

The buffer for streamed sounds is allocated when the stream is opened
(since streamed sounds can't share buffers), and freed when the stream
is closed.

For block sounds, the buffer is reference counted (with the sfx holding
one reference, so currently block buffers never get freed), with their
reference count getting incremented on open and decremented on close.
That the reference counts get to 1 has been confirmed, so all that
should be needed is proper destruction of the sfx instances.

Still need to sort out just why channels leak across level changes.
2022-06-06 12:39:54 +09:00
Bill Currie 11fee8571c [zone] Add functions to get and set the tag
Getting the tag is possibly useful in general and definitely in
debugging. Setting, I'm not so sure as it should be done when allocated,
but that's not always possible.

Also, correct the return type of z_block_size, though it affected only
Z_Print. While an allocation larger than 4GB is... big for zone, the
blocks do support it, so printing should too.
2022-06-06 12:39:54 +09:00
Bill Currie 2298227546 [sound] Check for allocation failures
They're currently treated as non-fatal, those sounds just won't ever
play. This allows ad_tears to at least load with only 32MB of locked
memory (it needs somewhere between 64 and 96).
2022-06-06 12:39:54 +09:00
Bill Currie 4694ee693b [zone] Alight zone allocations to 64 bytes
Since Ruamoko got vector types, zone's 8-byte alignment was no longer
sufficient due to hardware-enforced alignment requirements of the
underlying vector operations.

Fixes #28.
2022-06-06 12:39:54 +09:00
Bill Currie 2bb0f0c104 [zone] Add support for reference counting to Z_*
And use it for Ruamoko object reference counts.

I need reference counts for dealing with block sound buffers since they
can be shared by many channels. I figured I take care of Ruamoko's
reference count location at the same time.

Fixes #27.
2022-06-06 12:39:54 +09:00
Bill Currie 4e550ac9c7 [sound] Move block buffers into locked memory
Sounds no longer use the cache, which is good for multi-threaded, but a
pain for memory management: the buffers are shared between channels that
play back the sounds, but when the sounds were cached, they were
automagically (thus problematically) freed when the space was needed.
That no longer happens, so they leak. I think the solution is to use
reference counting and retain/release in sfx->open() and sfx->close().
2022-06-04 23:55:31 +09:00
Bill Currie 038813e04c [sound] Fix midi config path
I guess wildmidi has been shipping its own config for a while now. Since
QF relies on wildmidi, it should use wildmidi's config by default.
2022-06-04 21:09:01 +09:00
Bill Currie deab21cb4b [sound] Move stream buffers into locked memory
Streams are the easy one as they were never in the cache. As a side
effect, sfxstream_t is much smaller as it no longer has the buffer
embedded in the struct.
2022-06-04 18:45:11 +09:00
Bill Currie 855b9dccc0 [sound] Don't free channels when allocating
SND_AllocChannel is a little too aggressive in freeing channels that
have finished as the channel may be externally owned (eg, by cd_file).
Get bgm looping working again.
2022-06-04 18:29:37 +09:00
Bill Currie 632226dd32 [sound] Rename sfxbuffer_t's length to size
The field is the size of the buffer, while "length" is a bit ambiguous
between buffer length or sfx length.
2022-06-04 17:05:03 +09:00
Bill Currie da90d93135 [sound] Move most spacialization fields out of channel_t
More shrinkage. It turned out the mixer uses the phase fields, so they
couldn't be removed, but even at 192kHz, +/- 127 samples produces
sufficient phase separation for a 21cm head (which is, actually, pretty
big: mine is about 15cm across), but that change can come later.

The ambient sound loading has been removed from snd_channels because 1)
it doesn't work for nq, 2) it should never have been there in the first
place (it belongs in the client, but that needs some more API).
2022-06-04 16:20:19 +09:00
Bill Currie 94db9c8ab1 [quakefs] Add a data parameter to gamedir callbacks
While this didn't fix the problem for which I needed the data pointer,
having data pointers in callbacks is far too useful to throw out the
change.
2022-06-04 16:06:04 +09:00
Bill Currie 18c64f7319 [sound] Fix some spelling errors in the mixer
Triple has only one p, not two :/
2022-06-04 12:28:16 +09:00
Bill Currie 0c65d294ed [sys] Add a function to lock a region of memory
Locked memory is needed for real-time threads (which the sound mixer is
when using JACK).
2022-06-04 12:28:16 +09:00
Bill Currie 5fd9098e05 [sound] Remove the next pointer and entity channel from channel_t
This is part of a process to shrink channel_t so it doesn't waste locked
memory when it gets moved there. Eventually, only the fields the mixer
needs will be in channel_t itself: those needed for spacialization will
be moved into a separate array.

In the process, I found that channels leak across level changes, but
this appears to be due to the cached sounds being removed during loading
and the mixer never marking them as done (it sees the null sfx pointer
and assumes the channel was never in use). Having the mixer mark the
channel as done seems to fix the leak, but cause a free channel list
overflow. Rather than fight with that, I'll leave the leak for now and
fix it at its root cause: the management of the sound samples
themselves.
2022-06-04 12:28:16 +09:00
Bill Currie cbc5654b5e [sound] Initialize snd_alive_time on connection to JACK
Sys_DoubleTime starts at 4Gs in order to keep its precision fixed for a
nice long time (about 120 years, iirc).

This fixes an instant watchdog trigger when first starting up in
testsound. I'm not sure why it didn't happen with nq, but I guess that
doesn't really matter
2022-06-03 20:01:34 +09:00
Bill Currie 56cd0f3f1d [sound] Rename sndbuffer objects from sc to sb
I don't know why I called them sc. Might be a holdover from before the
streamed sound support.
2022-06-03 19:11:25 +09:00
Bill Currie 5b38117689 [sound] Make all volumes 0-1 (float) instead of 0-255 (int)
The scaling up of the volumes when setting a channel's volume bothered
me. The biggest issue being it hasn't been necessary for over a decade
since the conversion to a float-mixer. Now the volume and attenuation
scaling from protocol bytes is entirely in the client's hands.
2022-06-03 16:54:57 +09:00
Bill Currie e1a0bde5ee [sound] Remove a pile of unwanted sound.h includes
This does mean that the gl and sw renderers can no longer call
S_ExtraUpdate, but really, they shouldn't be anyway. And I seem to
remember it not really helping (been way too long since quake ran that
slowly for me).
2022-06-03 15:43:53 +09:00
Bill Currie 1f16f875f6 [sound] Clean up the public API
sfx_t is now private, and cd_file no longer accesses channel_t's
internals. This is necessary for hiding the code needed to make mixing
and channel management *properly* lock-free (I've been getting away with
murder thanks to x86's strong memory model and just plain luck with
gcc).
2022-06-03 15:20:41 +09:00
Bill Currie 0ebb0717b0 [zone] Add failing test cases
The tests fail as they exercise how the cache *SHOULD* work rather than
how it does now.

The tests do currently pass for the pending work I've done on the cache
system, but while working on it, I remembered why I reworked cache
allocation...

The essential problem is that sounds are loaded into the cache, which is
fine for synchronous output targets, but has proven to be a minefield
for asynchronous output targets (JACK, ALSA).

The reason for the minefield is the hunk takes priority over the cache,
and is free to move cache blocks around, and *even dispose of them
entirely* in order to satisfy memory allocations from either end of the
hunk. Doing this in an entirely single-threaded process (as DOS Quake
was) is perfectly safe, as the users of the cache just reload the
pointer each time, and bail if it's null (meaning the block has been
freed), or even cause the data to be reloaded if possible (I'm a little
fuzzy on the details for that as I didn't write that code). However, in
multi-threaded code, especially real-time (JACK, possibly ALSA), it's a
recipe for disaster. The 4cab5b90e6 commit was a (mostly) successful
attempt to mitigate the problem by allocating the cache blocks from the
high-hunk (thus minimizing any movement caused by low-hunk allocations),
it resulted in cache allocates and regular high-hunk allocations somehow
getting intertwined: while investigating just how much memory ad_tears
needs (somewhere between 192MB and 256MB), I got "trashed sentinel"
errors and upon investigation, I found what looks very suspiciously like
audio data written across a hunk control block.

I've decided that the cache allocation *algorithm* should be reverted to
how it was originally designed by Id (details will remain "modern"), but
while working on the tests, I remembered why I had done the changes in
the first place (above story). Thus the work on reverting the cache
allocation can't go in until I get sound memory management independent
of the cache. The tests are going in now so I have a constant reminder :)
2022-06-03 12:52:59 +09:00
Bill Currie 3293fcaab0 [sys] Add some developer flags for cache/hunk/zone
And make Sys_MaskPrintf take the developer enum rather than just a raw
int.

It was actually getting some nasty hunk corruption errors when under
memory pressure that made it clear the sound system needs some work.
2022-06-03 12:04:27 +09:00
Bill Currie 45b3ef79c8 [model] Trim decompressed vis sets
I had been trimming for the solid leaf, but not the empty leafs. I had
assumed the vis tool would trim the bits, but it seems to not be
reliable (though it could be a bug in qfvis, I think the map in question
is one of my test maps).
2022-05-27 12:24:36 +09:00
Bill Currie 61178978be [vulkan] Get bsp texture animations working again
The texture animation data is compacted into a small struct for each
texture, resulting in much less data access when animating the texture.
More importantly, no looping over the list of frames. I plan on
migrating this to at least the other hardware renderers.
2022-05-26 22:31:31 +09:00
Bill Currie 77505abd94 [model] Move ANIM_CYCLE into model.h
Need it in the vulkan renderer to undo the scaling
2022-05-26 22:30:29 +09:00
Bill Currie 4786594f3c [vulkan] Create a "missing" texture for bsps
I found a test map with no texture data. Even after fixing the bsp
loader, vulkan didn't like it. Now vulkan is happy. The "Missing" text
is full-bright magenta on a dim grey background so it should be visible
in any lighting conditions.
2022-05-26 19:14:44 +09:00
Bill Currie 4dc1988af1 [vulkan] Add a function to load texture arrays
I needed to create an array texture and didn't feel like doing all that
boilerplate again :P.
2022-05-26 18:43:15 +09:00
Bill Currie f65a35da88 [gib] Clean up some header dependencies 2022-05-26 16:13:09 +09:00
Bill Currie dcfe0e33a3 [util] Allow zero-sized lumps to be at end of file
This fixes a crash when attempting to load a map with no texture data.
2022-05-26 12:35:50 +09:00
Bill Currie 70ece6d5bb [vulkan] Work around buggy maps with broken brushes
Conflagrant Rodent has a sub-model with 0 faces (double bit error?)
causing simply counting faces to get out of sync with actual model
starts thus breaking *all* brush models that come after it (including
other maps). Thus be a little less lazy in figuring out model start
faces.
2022-05-25 20:08:36 +09:00
Bill Currie 524c1e27c4 [vulkan] Use instanced rendering for brush models
The models are broken up into N sub-(sub-)models, one for each texture,
but all faces using the same texture are drawn as an instance, making
for both reduced draw calls and reduced index buffer use (and thus,
hopefully, reduced bandwidth). While texture animations are broken, this
does mark a significant milestone towards implementing shadows as it
should now be possible to use multiple threads (with multiple index and
entid buffers) to render the depth buffers for all the lights.
2022-05-25 13:29:11 +09:00
Bill Currie a08261c620 [vulkan] Use a buffer for entity transform and color data
This allows the use of an entity id to index into the entity data and
fetch the transform and colormod data in the vertex shader, thus making
instanced rendering possible. Non-world brush entities are still not
rendered, but the world entity is using both the entity data buffer and
entid buffer.
2022-05-25 00:17:57 +09:00
Bill Currie 3900e59f1a [client] Support the wait field on lights
This was the missing piece for a lot of my lighting woes: it scales the
distance when calculating falloff.
2022-05-23 20:22:05 +09:00
Bill Currie 26330d0fcb [scene] Update the empty world for the new mnode_t
This gets my qwaq-x11 test scene working again (and makes use of a plane
at infinity, yay PGA).
2022-05-23 01:33:21 +09:00
Bill Currie 3a2560e4c1 [vulkan] Implement thread-safe rendering for the world model
Sub-models and instance models need an instance data buffer, but this
gets the basics working (and the proof of concept). Using arrays like
this actually simplified a lot of the code, and will make it easy to get
transparency without turbulence (just another queue).
2022-05-23 01:28:43 +09:00
Bill Currie c6f520b743 [model] Clean out some useless surface flags
The gl water warp ones have been useless since very early on due to not
doing water warp in gl (vertex warping just didn't work well), and the
recent water warp implementation doesn't need those hacks. The rest of
the removed flags just aren't needed for anything. SURF_DRAWNOALPHA
might get renamed, but should be useful for translucent bsp surfaces
(eg, vines in ad_tears).
2022-05-22 23:38:18 +09:00
Bill Currie c8472755d1 [model] Move visframe out of msurface_t
One more step towards BSP thread-safety. This one brought with it a very
noticeable speed boost (ie, not lost in the noise) thanks to the face
visframes being in tightly packed groups instead of 128 bytes apart,
though the sw render's boost is lost in the noise (but it's very
fill-rate limited).
2022-05-22 16:38:50 +09:00
Bill Currie d40769c21d [model] Move visframe out of mleaf_t
This is next critical step to making BSP rendering thread-safe.

visframe was replaced with cluster (not used yet) in anticipation of BSP
cluster reconstruction (which will be necessary for dealing with large
maps like ad_tears).
2022-05-22 14:43:07 +09:00
Bill Currie 4e5eec0277 [input] Correct copyright attribution for in_imt.c
Id had nothing to do with imt tables. It was Mercury (Zephaniah) that
created the initial design and code, and I took the design further.
2022-05-22 13:52:34 +09:00
Bill Currie 7a97a72232 [input] Correct some type-setting issues in command help 2022-05-22 13:51:55 +09:00
Bill Currie 7240d2dc80 [model] Move plane info into mnode_t, and visframe out
The main goal was to get visframe out of mnode_t to make it thread-safe
(each thread can have its own visframe array), but moving the plane info
into mnode_t made for better data access patters when traversing the bsp
tree as the plane is right there with the child indices. Nicely, the
size of mnode_t is the same as before (64 bytes due to alignment), with
4 bytes wasted.

Performance-wise, there seems to be very little difference. Maybe
slightly slower.

The unfortunate thing about the change is the plane distance is negated,
possibly leading to some confusion, particularly since the box and
sphere culling functions were affected. However, this is so point-plane
distance calculations can be done with a single 4d dot product.
2022-05-22 12:41:23 +09:00
Bill Currie 8633ffe9d2 Fix some MXE build issues
Just some unused variables when vulkan debug is disabled and some scanf
formats for qfcc vectors (and the safety net).
2022-05-22 11:59:53 +09:00
Bill Currie 0d609efbc6 [vulkan] Implement water alpha
I'm not sure it's working properly, but that compose pass is suspect,
especially with respect to lighting.
2022-05-22 11:59:53 +09:00
Bill Currie 3bb54bc20a [renderer] Up some limits so I can test with ad_tears
The map uses 41% of a 4k light map scrap, and 512 texture descriptors
wasn't enough for vulkan. Ouch. I do need to get cvars on these things,
but this will do for now (decades later...)
2022-05-22 11:59:53 +09:00
Bill Currie e967724196 [audio] Handle multiple cue points in wav files
Sounds in Arcane Dimensions (at least those used by ad_tears) specify
start and end cue points. The code was using only the final point in the
list and thus breaking looped sounds. Now, the first cue point is used
as the loop start, and the second (if present), the sample length. Both
are bounds-checked against the wav's sample count. Fixes sound locking
up during the first seconds in ad_tears.
2022-05-22 11:59:53 +09:00
Bill Currie 5cfbafc176 [audio] Fix some minor issues
Just little niggles I spotted while sorting out cue points.
2022-05-22 11:59:53 +09:00
Bill Currie 78a0075be1 [gamecode] Plug a nasty buffer overflow
This one is ancient: the code was essentially unmodified since release
(just some formatting). Malformed vectors could sneak through due to map
bugs (eg, "angles -90" instead of "angle -90" as in ad_tears) and the
vector parsing code would continue past the end of the string and
writing into unowned memory, potentially messing up the libc allocation
records. Replacing with the obvious sscanf works nicely.

Sometimes, Quake code is brilliant. Other times, it's a real face-palm.
2022-05-21 14:28:47 +09:00
Bill Currie 89f8dfce09 [input] Clear button inputs when IN_ClearStates called
This fixes the annoying persistence of inputs when respawning and
changing levels. Axis input clearing is hooked up but does nothing as of
yet. Active device input clearing has always been hooked up, but also
does nothing in the evdev and x11 drivers.
2022-05-19 16:47:47 +09:00
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 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 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 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 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 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 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 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 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 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 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
Bill Currie 1e65ec22f9 [gl] Use a scrap for lightmaps
This gives a rather significant speed boost to timedemo demo1: from
about 2300-2360fps up to 2520-2600fps, at least when using
multi-texture.

Since it was necessary for testing the scrap, gl got the ability to set
the console background texture, too.
2022-05-11 00:33:47 +09:00
Bill Currie 0f7e6734f7 [model] Make firstmarksurface an int instead of pointer
While it takes one extra step to grab the marksurface pointer,
R_MarkLeaves and R_MarkLights (the two actual users) seem to be either
the same speed or fractionally faster (by a few microseconds). I imagine
the loss gone to the extra fetch is made up for by better bandwidth
while traversing the leafs array (mleaf_t now fits in a single cache
line, so leafs are cache-aligned since hunk allocations are aligned).
2022-05-11 00:33:47 +09:00
Bill Currie 8ce463cbed [gl] Call gl_R_CalcLightmaps after sub-model brushes have been queued
This fixes the sub-models not being dynamically lit.
2022-05-10 17:07:16 +09:00
Bill Currie 600e7ecbea [renderer] Resurrect r_dlightframecount
This fixes dynamic light map updates for gl, glsl, and sw, but gl has
problems with map submodels not being dynamically lit.
2022-05-10 17:07:16 +09:00
Bill Currie be7a7d8bec [renderer] Fix the other renderers for qwaq not loading gfx.wad
The whole draw system needs an overhaul :/
2022-05-09 16:30:05 +09:00
Bill Currie 2ebefd7850 [wad] Return 0 if no wad file is loaded
This allows QF to load without a wad file as it will use the internal
character definition.
2022-05-08 23:56:11 +09:00
Bill Currie b33df8b698 [vulkan] Clean up a pile of unnecessary includes 2022-05-08 17:57:40 +09:00
Bill Currie 09d5c76fe9 [vulkan] Implement IQM animations
Unfortunately, the animations are pre-baked (by the loader) blocking
run-time determined animations (IK etc). However, this at least gets
everything working so the basics can be verified (the shader posed some
issue resulting in horror movies ;).
2022-05-08 14:21:40 +09:00
Bill Currie e62b7d7b05 [vulkan] Allow QFV_ImageFormat to select unorm or srgb
This is definitely something that should be selectable per image and not
hard-coded into the engine.
2022-05-08 14:15:20 +09:00
Bill Currie 1dff24dbd0 [scene] Implement Hierarchy_Copy
It copies an entire hierarchy (minus actual entities, but I'm as yet
unsure how to proceed with them), even across scenes as the source scene
is irrelevant and the destination scene is used for creating the new
transforms.
2022-05-08 11:14:00 +09:00
Bill Currie 08c8b8d51b [vulkan] Add entity labels to command queues
Brush models looked a little too tricky due to the very different style
of command queue, so that's left for now, but alias, iqm and sprite
entities are now labeled. The labels are made up of the lower 5 hex
digits of the entity address, the position, and colored by the
normalized position vector. Not sure that's the best choice as it does
mean the color changes as the entity moves, and can be quite subtle
between nearby entities, but it still helps identify the entities in the
command buffer.

And, as I suspected, I've got multiple draw calls for the one ogre. Now
to find out why.
2022-05-07 15:45:11 +09:00
Bill Currie 18af340160 [vulkan] Normalize iqm normals
Same mistake as for alias, I simply forgot to do it for iqm when I got
it working.
2022-05-07 15:45:11 +09:00
Bill Currie c59ab8882d [vulkan] Label renderpass and subpass sections
This makes finding the relevant commands in render doc much much easier.
2022-05-07 15:45:11 +09:00
Bill Currie 8204e8a8c1 [vulkan] Clear lights when the scene is cleared
Fixes a segfault when shutting down my test program.
2022-05-07 12:12:02 +09:00
Bill Currie 8795b8eb91 [vulkan] Get IQM rendering working
The bones aren't animated yet (and I realized I made the mistake of
thinking the bone buffer was per-model when it's really per-instance (I
think this mistake is in the rest of QF, too)), skin rendering is a
mess, need to default vertex attributes that aren't in the model...
Still, it's quite satisfying seeing Mr Fixit on screen again :)

I wound up moving the pipeline spec in with the rest of the pipelines as
the system isn't really ready for separating them.
2022-05-07 10:14:22 +09:00
Bill Currie 3f7cbae4d0 [vulkan] Rework builtin plist handing
The plists can now be accessed by name and the forward render pass
config is available (but not used, or tested beyond syntax). I was going
to have the IQM pipeline spec separate but ran into limitations in the
system (which needs a lot of polish, really).
2022-05-07 10:08:30 +09:00
Bill Currie ea8f991bf3 [ruamoko] Clear efrags when destroying an entity
This ensures the rendering system won't attempt to draw the entity after
it has been destroyed.
2022-05-07 09:53:26 +09:00
Bill Currie 91c877b1a1 [scene] Zero freshly allocated entity memory
I don't remember why I didn't want to clear it. I hope this doesn't
cause other trouble.
2022-05-07 00:51:44 +09:00
Bill Currie ae9e8f8f4e [plist] Report line-relative character position in errors
Far better than string-relative.
2022-05-06 20:10:41 +09:00
Bill Currie b69b7b6a4a [vulkan] Clean up duplication in qfpipeline
That @inherit is pretty useful :) This makes it much easier to see how
different pipelines differ or how they are the similar. It also makes it
much clearer which sub-pass they're for.
2022-05-06 19:38:14 +09:00
Bill Currie 79add5590b [build] Fix some make distcheck issues
The never ending battle against bit-rot.
2022-05-06 15:50:13 +09:00
Bill Currie 551c6b82cb [vulkan] Tweak spotlight cone edges a little 2022-05-06 08:32:19 +09:00
Bill Currie ed82b5f299 [ruamoko] Clean up lighting data blocks
Don't want to leak memory.
2022-05-06 08:26:55 +09:00
Bill Currie 4abcaff980 [vulkan] Normalize the normal vectors on alias models
I was wondering why scaled-down quake-guy was dimmer than full-size
quake-guy. And the per-fragment normalization gives the illusion of
smoothness if you don't look at his legs (and even then...).
2022-05-05 23:49:31 +09:00
Bill Currie 72cb7d3fdd [scene] Make the empty world work with lights
Needed visibility and a sky surf flag, otherwise no lights were visible
(why does this seem familiar?).
2022-05-05 23:49:31 +09:00
Bill Currie d14b17567e [ruamoko] Add builtins for adding lights to scenes
Pretty much just raw wrappers around the C versions. I'm not sure about
Light_EnableSun (even in C), but it does build the sky surf pvs.
2022-05-05 23:49:31 +09:00
Bill Currie 95264b3a54 [ruamoko] Move emtpy_world into scene
And use it as the default worldmodel for new scenes. Since it's
statically allocated, it shouldn't cause any harm so long as no one
tries to free it.
2022-05-05 23:49:31 +09:00
Bill Currie d850285e3f [ruamoko] Allow scenes to be fetched by C code
Need to clean up that part of the API, though.
2022-05-05 23:49:31 +09:00
Bill Currie 7b275ebab6 [vulkan] Don't update lights that don't exist
However, the lighting pass still needs to be run in order to generate
the solid color image.
2022-05-05 23:49:31 +09:00
Bill Currie 2818fc12a5 [model] Initialize r_notexture_mip in the right places
That being in the renderer. This is why qwaq needed that call to
Mod_ProcessTexture (but no longer does :)
2022-05-05 23:49:31 +09:00
Bill Currie 41a12f066b [client] Clean up light loading
By adding Light_AddLight to scene light management
2022-05-05 23:49:31 +09:00
Bill Currie b2928b5ed7 [client] Reverse the direction of sunlight
Maps specify sunlight as shining in a specific direction, but the
lighting system wants the direction to the sun as it's used directly in
shading calculations. Direction correctness confirmed by disabling other
lights and checking marcher's outside scene (ensuring the flat ground
was lit). As a bonus, I've finally confirmed I actually have the skybox
in the correct orientation (sunlight vector more or less matched the
position of the sun in marcher's sky).
2022-05-05 23:49:31 +09:00
Bill Currie d60602421b [vulkan] Ensure dynamic lights are positional
I'm not sure what's up with the weird lighting that results from dynamic
lights being directional (sunlight works nicely in marcher, but it has a
unit vector for position).
2022-05-05 23:49:31 +09:00
Bill Currie df5b471342 [scene] Support ambient lighting in worldspawn
Abyss of Pandemonium uses global ambient light a lot, but doesn't
specify it in every map (nothing extracting entities and adding a
reasonable value can't fix). I imagine some further tweaking will be
needed.
2022-05-05 23:49:30 +09:00
Bill Currie a31ff3153c [gamecode] Fail gracefully on invalid entity strings
Returning null (and printing some error messages) is far friendlier than
aborting.
2022-05-05 23:49:30 +09:00
Bill Currie 4a4e16399a [client] Clean up world entity parsing a bit
Now the entities are parsed only once and the resulting data reused.
2022-05-05 23:49:30 +09:00
Bill Currie 9ee0eada1f [vulkan] Move non-specific lighting code out of Vulkan
The parsing of light data from maps is now in the client library, and
basic light management is in scene. Putting the light loading code into
the Vulkan renderer was a mistake I've wanted to correct for a while.
The client code still needs a bit of cleanup, but the basics are working
nicely.
2022-05-05 23:49:30 +09:00
Bill Currie e9ad7b748b [renderer] Use scene_t to set the model data
This replaces *_NewMap with *_NewScene and adds SCR_NewScene to handle
loading a new map (for quake) in the renderer, and will eventually be
how any new scene is loaded.
2022-05-05 14:46:02 +09:00
Bill Currie e323fbbbed [vulkan] Rework lighting model to be more algebraic
This leaves only the one conditional in the shader code, that being the
distance check. It doesn't seem to make any noticeable difference to
performance, but other than explosion sprites being blue, lighting
quality seems to have improved. However, I really need to get shadows
working: marcher is just silly-bright without them, and light levels
changing as I move around is a bit disconcerting (but reasonable as
those lights' leaf nodes go in and out of visibility).
2022-05-05 08:40:02 +09:00
Bill Currie fe63d93e8e [build] Remove some csqc dependencies
vkgen and the programs in ruamoko/qwaq just don't need it.
2022-05-04 18:01:50 +09:00
Bill Currie eaaa0f597f [scene] Set the color for new entities
Black doesn't show up too well on black. Really, this isn't the best
fix, but it will do until I can rework entities to use a component
system.
2022-05-04 18:00:35 +09:00
Bill Currie 2493ca71c7 [ruamoko] Allow entity model to be set
And add header and function definitions for scene to libcsqc.
2022-05-04 17:38:38 +09:00
Bill Currie 8e658eac78 [vulkan] Correct a pile of copyright attributions
Id Software had pretty much nothing to do with the vulkan renderer (they
still get credit for code that's heavily based on the original quake
code, of course).
2022-05-04 14:44:54 +09:00
Bill Currie e95d498b97 [vulkan] Resurrect the forward render pass spec
It's not used yet, and thus may have some incorrect settings, but I
decided that I will probably want it at some stage for qwaq. It's
essentially was was in the original spec, but updated for some of the
niceties added to parsing since I removed it back then. It's also in its
own file.
2022-05-04 14:44:54 +09:00
Bill Currie c10e529dfd [vulkan] Clean up alias pipeline layout spec
It didn't really need the extra layer of indirection: now it's much
clearer that the alias pipeline uses matrices and textures.
2022-05-04 14:44:54 +09:00
Bill Currie 0983cc5d8c [scene] Fix a spelling error in a comment 2022-05-04 14:44:54 +09:00
Bill Currie 3de10f32c7 [ruamoko] Add builtins for handling models
Just "loading" and "unloading" (both really just hints due to the
caching system), and an internal function for converting a handle to a
model pointer, but it let me test IQM loading and unloading in Vulkan.
2022-05-04 14:44:54 +09:00
Bill Currie ecf33fe8e3 [model] Add a function to "unload" models
The model system is rather clunky as it is focused around caching, so
unloading is more of a suggestion than anything, but it was good enough
for testing loading and unloading of IQM models in Vulkan.
2022-05-04 14:13:18 +09:00
Bill Currie bbca22c722 [vulkan] Add support for IQM models
Despite the base IQM specification not supporting blend-shapes, I think
IQM will become the basis for QF's generic model representation (at
least for the more advanced renderers). After my experience with .mu
models (KSP) and unity mesh objects (both normal and skinned), and
reviewing the IQM spec, it looks like with the addition of support for
blend-shapes, IQM is actually pretty good.

This is just the preliminary work to get standard IQM models loading in
vulkan (seems to work, along with unloading), and they very basics into
the renderer (most likely not working: not tested yet). The rest of the
renderer seems to be unaffected, though, which is good.
2022-05-04 14:07:27 +09:00
Bill Currie a4f500da3c [vulkan] Add a mini resource subsystem
The resource subsystem creates buffers, images, buffer views and image
views in a single batch operation, using a single memory object to back
all the buffers and images. I had been doing this by hand for a while,
but got tired of jumping through all those vulkan hoops. While it's
still a little tedious to set up the arrays for QFV_CreateResource (and
they need to be kept around for QFV_DestroyResource), it really eases
calculation of memory object size and sub-resource offsets. And
destroying all the objects is just one call to QFV_DestroyResource.
2022-05-04 13:59:38 +09:00
Bill Currie 9d7cad420d [vulkan] Add a function to translate QFFormat to VkFormat
It's not great, but it does produce reasonable results for the formats
supported by QF's image system.
2022-05-04 13:57:02 +09:00
Bill Currie 419d91edc5 [image] Set texture type for no-load tga images
I might need to do similar for other formats, but i ran into the problem
of the texture type being tex_palette instead of the expected tex_rgba
when pre-(no-)loading a tga image resulting in Vulkan not liking my
attempt at generating mipmaps.
2022-05-04 13:50:55 +09:00
Bill Currie fe891dd70b Merge branch 'master' into wip-rua_scene 2022-05-01 14:46:47 +09:00
Bill Currie b87a768c43 [gamecode] Sort debug local defs by address
This allows the fuzzy bsearch used to find a def by address to work
properly (ie, find the actual def instead of giving some other def +
offset). Makes for a much more readable instruction stream.
2022-05-01 14:35:24 +09:00
Bill Currie 4ed9fc6820 [ruamoko] Switch to 64-bit handles for scene objects
The scene id is in the lower 32-bits for all objects (upper 32-bits are
0 for actual scene objects) and entity/transform ids are in the upper
32-bits. Saves having to pass around a second parameter in progs code.
2022-04-29 21:02:08 +09:00
Bill Currie 875c9bde7c [gamecode] Print operand widths when not 1
The widths for all three operands are printed if any is greater than 1.
Makes figuring out which instruction is executing a little easier.
2022-04-29 16:59:15 +09:00
Bill Currie af2dfde37a [gamecode] Support printing 64-bit integer types
The 'l' modifier always means 64-bit, regardless of the underlying
platform. As well, the 32-bit integer types are handled portably too.
2022-04-29 16:59:15 +09:00
Bill Currie 6d62e91ce7 [gamecode] Clean up progs data access
pr_type_t now contains only the one "value" field, and all the access
macros now use their PACKED variant for base access, making access to
larger types more consistent with the smaller types.
2022-04-29 16:59:15 +09:00
Bill Currie c4d56afd33 [vulkan] Cope with an empty world model
Vulkan doesn't appreciate the empty buffers that result from the model
not having any textures or surfaces that can be rendered (rightfully so,
for such a bare-metal api).
2022-04-26 07:26:32 +09:00
Bill Currie 5703df00fd [renderer] Don't try to draw a nonexistent view model
Doing so doesn't end well (segfault). This is a bit of a hack until I
come up with a design for configurable scene rendering.
2022-04-26 07:22:45 +09:00
Bill Currie 98cbacfe9d [renderer] Remove redundant calls to visit_leaf
I doubt the calls were ever actually made in a normal map due to the
node actually being a node when breaking out of the loop, but when I
experimented with an empty world model (no nodes, one infinite empty
leaf) I found that visit_leaf was getting called twice instead of once.
2022-04-26 07:14:03 +09:00
Bill Currie fddff1c24d Merge branch 'master' into wip-rua_scene 2022-04-25 08:13:35 +09:00
Bill Currie 7ef9aab7f3 [vulkan] Use cached memory for the bsp index buffer
Since it is updated every frame, it needs to be as fast as possible for
the cpu code. This seems to make a difference of about 10us (~130 ->
~120) when testing in marcher. Not a huge change, but the timing
calculation was wrapped around the entire base world pass, so there was
a fair bit of overhead from bsp traversal etc.
2022-04-25 07:49:30 +09:00
Bill Currie 0b912795d0 [vulkan] Use host-cached memory for staging buffers
It makes a significant difference to level load times (approximately
halves them for demo1 and demo2). Nicely, it turns out I had implemented
the rest of the staging buffer code (in particular, flushing) correctly
in that it seems there's no corruption any of the data.
2022-04-25 07:49:30 +09:00
Bill Currie f6baa16084 [cvar] Remove the cvar lists
They're really redundant, and removing the next pointer makes for a
slightly smaller cvar struct. Cvar_Select was added to allow finding
lists of matching cvars.

The tab-completion and config saving code was reworked to use the hash
table DO functions. Comments removed since the code was completely
rewritten, but still many thanks to EvilTypeGuy and Fett.
2022-04-25 00:26:45 +09:00
Bill Currie 8bd626a3e4 [hash] Add a couple of data-oriented functions
Hash_Select returns a list of elements that match a given criterion
(select callback returning non-0).

Hash_ForEach simply calls a function for every element.
2022-04-25 00:18:22 +09:00
Bill Currie bafe54b010 [view] Add a cexpr enum for grav_t
And use it for hud_scoreboard_gravity. Putting the enum def in view made
the most sense as view does own the base type and the enum is likely to
be by useful for other settings.
2022-04-24 21:09:58 +09:00
Bill Currie bdb1192c13 [console] Fix missed changes to console line exec control
I think I'd gotten distracted while making the changes to the server,
then simply copied the partial changes to the client. It didn't blow up
thanks to the backing store bing char * and the type sized for int, so
safe on any platform, but useless as it wasn't connected properly.

It's actually pretty neat being able to directly, but safely, control a
function pointer via a cvar :)
2022-04-24 20:46:06 +09:00
Bill Currie bff0847761 [cvar] Clean up most misinterpreted cvar types
The misinterpretations were due to either the cvar not being accessed
directly by the engine, but via only the callback, or the cvars were
accesssed only by progs (in which case, they should be float). The
remainder are a potential enum (hud gravity) and a "too hard basket"
(rcon password: need to figure out how I want to handle secret strings).
2022-04-24 20:04:06 +09:00
Bill Currie 90447a5d3b [quakefs] Ensure fs_sharepath and fs_userpath are never empty
Other parts of quakefs treat an empty path as an error, so fs_sharepath
and fs_userpath must never be empty or they will effectively be
rejected. While the user explicitly setting them to empty strings is one
way for them to become empty, another is QFS_CompressPath compressing
'.' to an empty path, which makes it rather difficult to set up the
traditional quake directory tree (ie, operate from the current
directory).
2022-04-24 19:15:22 +09:00
Bill Currie 9f876390f0 [input] Fix up some mistranslated cvars
My script didn't know what type to make the cvars since they're not used
directly by the code, so they got treated as strings instead of ints or
floats.
2022-04-24 19:15:22 +09:00
Bill Currie 12c84046f3 [cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.

As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.

The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).

While not used yet (partly due to working out the design), cvars can
have a validation function.

Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.

nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-24 19:15:22 +09:00
Bill Currie 87b3c64801 [vulkan] Parse VkPresentModeKHR
And strip the KHR for short names.
2022-04-24 19:15:22 +09:00
Bill Currie a52704e8ca [cexpr] Allow assignment of double to float
I didn't really want this, but it's needed for cvar support.
2022-04-24 19:15:22 +09:00
Bill Currie aad4546c01 [cexpr] Expose cexpr assignment
This makes it much easier for other systems (in particular, cvar) to
copy values safely.
2022-04-24 19:15:22 +09:00
Bill Currie 021ec4962b [cexpr] Add optional error message prefix string
The prefix gives more context to the error messages, making the system a
lot easier to use (it was especially helpful when getting my cvar revamp
into shape).
2022-04-24 19:15:22 +09:00
Bill Currie d68db74049 [cexpr] Add a flags type
Based on the flags type used in vkparse (difference is the lack of
support for plists). Having this will make supporting named flags in
cvars much easier (though setting up the enum type is a bit of a chore).
2022-04-24 19:15:22 +09:00
Bill Currie 392e032ce2 [cexpr] Add a get_string function to exprtype_t
This allows for easy (and safe) printing of cexpr values where the type
supports it. Types that don't support printing would be due to being too
complex or possibly write-only (eg, password strings, when strings are
supported directly).
2022-04-24 19:13:54 +09:00
Bill Currie db5b77c838 [cexpr] Require designated initializers for exprtype_t
This will make expanding it much safer in the future.
2022-04-24 17:31:17 +09:00
Bill Currie 8a411dc120 [joy] Clean up some redundant cvar flags
No need to or CVAR_NONE with other flags.
2022-04-24 17:23:46 +09:00
Bill Currie 001b3eb908 Fix some inconsistent cvar uses
Surprisingly, only two, but they were caught by the different value
fields being used, thus the cvar was checked in multiple places. I
imagine that's not really all that common, so there may be some
inconsistencies between default value and use.
2022-04-24 17:23:46 +09:00
Bill Currie 55f7886607 Remove some long dead cvars
The declarations were still around, but the creation and code using them
was removed long ago.
2022-04-24 17:23:46 +09:00
Bill Currie ef574e67d0 [net] Remove client references from net_main
This is progress towards #23. There are still some references to
host_time and host_client (via nq's server.h), and a lot of references
to sv and svs, but this is definitely a step in the right direction.
2022-04-24 17:21:58 +09:00
Bill Currie b2d4fa0ccf [vulkan] Break render pass parsing away from swapchain
This allows a single render pass description to be used for both
on-screen and off-screen targets. While Vulkan does allow a VkRenderPass
to be used with any compatible frame buffer, and vkparse caches a
VkRenderPass created from the same description, this allows the same
description to be used for a compatible off-screen target without any
dependence on the swapchain. However, there is a problem in the caching
when it comes to targeting outputs with different formats.
2022-04-24 17:04:10 +09:00
Bill Currie bc1fe6aa01 [renderer] Remove some redundant comments
No need for comments when the code says it all.
2022-04-23 10:56:56 +09:00
Bill Currie f15abcea53 [vulkan] Add a FIXME for the flashing Q icon
As I had suspected, it's due to a synchronization problem between the
scrap and drawing. There's actually a double problem in that data
uploaded to the scrap isn't flushed until the first frame is rendered
causing a quick init-shutdown sequence to take at least five seconds due
to the staging buffer waiting (and timing out) on a stuck fence.
Rendering just one frame "fixes" the problem (draw was one of the
earliest subsystems to get going in vulkan).
2022-04-23 10:46:55 +09:00
Bill Currie b649638400 [joy] Clean up some redundant cvar flags
No need to or CVAR_NONE with other flags.
2022-04-13 14:17:58 +09:00
Bill Currie 063c0797d6 Fix some inconsistent cvar uses
Surprisingly, only two, but they were caught by the different value
fields being used, thus the cvar was checked in multiple places. I
imagine that's not really all that common, so there may be some
inconsistencies between default value and use.
2022-04-13 14:17:58 +09:00
Bill Currie e97b96b536 Remove some long dead cvars
The declarations were still around, but the creation and code using them
was removed long ago.
2022-04-13 14:17:58 +09:00
Bill Currie 4d443d3114 [vid] Fix non-utf8 circle-c in fbset
Python didn't like reading the files.
2022-04-13 10:35:40 +09:00
Bill Currie 6b81a4b882 [renderer] Don't try to animate lightstyles that aren't there
Prevents a segfault when running the renderer via qwaq-x11.
2022-04-07 22:30:19 +09:00
Bill Currie f6541dbe3f [net] Remove client references from net_main
This is progress towards #23. There are still some references to
host_time and host_client (via nq's server.h), and a lot of references
to sv and svs, but this is definitely a step in the right direction.
2022-04-06 19:32:55 +09:00
Bill Currie 8f56f28ad7 [net] Use designated initializers for drivers
Not that I expect anything to change any time soon, but nice to have
the initializers explicitly named.
2022-04-06 18:46:28 +09:00
Bill Currie 3f575ab025 [win] Update for moved vulkan viewport
I forgot to do a windows test build.
2022-04-06 18:36:07 +09:00
Bill Currie 2798b5fd58 [vulkan] Use cached memory for the bsp index buffer
Since it is updated every frame, it needs to be as fast as possible for
the cpu code. This seems to make a difference of about 10us (~130 ->
~120) when testing in marcher. Not a huge change, but the timing
calculation was wrapped around the entire base world pass, so there was
a fair bit of overhead from bsp traversal etc.
2022-04-06 14:40:40 +09:00
Bill Currie b011f91018 [model] Clean up alias skin loading a little
The improved allocation overheads have been implemented for gl and sw,
and glsl no longer uses malloc. Using array textures will have to wait
as the current texture loading code doesn't support them.
2022-04-04 17:47:21 +09:00
Bill Currie e40f3f4f93 [model] Make alias skin loading a batch operation
Really, this won't make all that much difference because alias models
with more than one skin are quite rare, and those with animated skin
groups are even rarer. However, for those models that do have more than
one skin, it will allow for reduced allocation overheads, and when
supported (glsl, vulkan, maybe gl), loading all the skins into an array
texture (since all skins are the same size, though external skins may
vary), but that's not implemented yet, this just wraps the old one skin
at a time code.
2022-04-04 15:38:27 +09:00
Bill Currie f66df59c43 [vulkan] Use a template for the attachment desciptions 2022-04-03 13:15:30 +09:00
Bill Currie c8e299ca58 [vulkan] Use a template for the deferred attachment images
It's certainly much easier to read and see what's different between the
attachment.
2022-04-03 12:25:04 +09:00
Bill Currie d3d081ea0a [vulkan] Switch deferred opaque attachment to f16 rgb
While looking at the deferred attachment images with using a template in
mind, I noticed that the opaque attachment was using 8-bit color. The
problem is, it's meant to be HDRI with the compose pass crunching it
down to LDRI. Switching to 16-bit float does seem to have made a subtle
difference (hey, it's still quake data, not much HDRI in there).
2022-04-03 12:02:13 +09:00
Bill Currie 39e7c4a9b2 [vulkan] Use a template for the deferred image views
That certainly makes it nicer to work with large sets, and shows one way
to be careful with allocated resources: don't allocate them in the
inherited data and use a template that needs a few things filled in to
be valid. Also, it seems that overriding values in sub-structures "just
works" :)
2022-04-03 11:47:53 +09:00
Bill Currie eb4d566801 [vkparse] Add support for inheriting objects
It simply parses the referenced plist dictionary (via @inherit =
plist.path;) into the current data block, then allows the data to be
overwritten by the current plist dictionary. This may be a bit iffy for
any allocated resources, so some care must be taken, but it seems to
work nicely.
2022-04-03 11:11:28 +09:00
Bill Currie bbbdc41af3 [vulkan] Break render pass parsing away from swapchain
This allows a single render pass description to be used for both
on-screen and off-screen targets. While Vulkan does allow a VkRenderPass
to be used with any compatible frame buffer, and vkparse caches a
VkRenderPass created from the same description, this allows the same
description to be used for a compatible off-screen target without any
dependence on the swapchain. However, there is a problem in the caching
when it comes to targeting outputs with different formats.
2022-04-02 11:42:36 +09:00
Bill Currie 9892e571ce [vulkan] Move viewport and scissor into qfv_renderpass_t
This makes much more sense as they are intimately tied to the frame
buffer on which a render pass is working. Now, just the window width
and height are stored in vulkan_ctx_t. As a side benefit,
QFV_CreateSwapchain no long references viddef (now just palette and
conview in vulkan_draw.c to go).
2022-04-01 20:34:41 +09:00
Bill Currie 11e30583cf [vulkan] Switch to full screen triangle instead of quad
While I have trouble imagining it making that much performance
difference going from 4 verts to 3 for a whopping 2 polygons, or even
from 2 triangles to 1 for each poly, using only indices for the vertices
does remove a lot of code, and better yet, some memory and buffer
allocations... always a good thing.

That said, I guess freeing up a GPU thread for something else could make
a difference.
2022-04-01 19:50:41 +09:00
Bill Currie 88343d73ea [vulkan] Safely ignore fisheye and water warp
I didn't like the abort (especially having pushed it to master). This
takes care of things until I can get them implemented properly
(hopefully soon).
2022-04-01 16:51:25 +09:00
Bill Currie 03c403610d [vulkan] Safely ignore fisheye and water warp
I didn't like the abort (especially having pushed it to master). This
takes care of things until I can get them implemented properly
(hopefully soon).
2022-04-01 16:49:39 +09:00
Bill Currie 6bbbe4997b [vulkan] Invalidate mapped capture image memory
I think I had gotten lucky with captures not being corrupt due to them
being much bigger than all but the L3 cache (and then they're over 1/2
the size), so the memory was being automatically invalidated by other
activity. Don't want to trust such luck, though.
2022-04-01 16:19:10 +09:00
Bill Currie 42a03758c5 [vulkan] Remove redundant entity queue creation
I'd missed this when cleaning up entity queue creation for the other
renderers.
2022-04-01 15:26:51 +09:00
Bill Currie 6d0abd42bb [vulkan] Use host-cached memory for staging buffers
It makes a significant difference to level load times (approximately
halves them for demo1 and demo2). Nicely, it turns out I had implemented
the rest of the staging buffer code (in particular, flushing) correctly
in that it seems there's no corruption any of the data.
2022-04-01 15:14:56 +09:00
Bill Currie 78119aeb7a [gamecode] Clean up generated swizzle code 2022-04-01 02:14:05 +09:00
Bill Currie ddfacf61ee [qw] Get remote screen shots working again
Probably better than they ever have, really, since I think they were
broken for one renderer or another.
2022-04-01 02:04:24 +09:00
Bill Currie 86e95fc1d0 [vulkan] Use host-cached memory for captures
This takes simply reading the transfer buffer from about 400ms down to
about 3ms (for 1920x1080 rgba). PNG compression is now the bottleneck.
2022-04-01 01:01:53 +09:00
Bill Currie 790f62a209 [image] Make WritePNG take settings from tex_t
This means that a tex_t object is passed in instead of just raw bytes
and width and height, but it means the texture can specify whether it's
flipped or uses BGR instead of RGB. This fixes the upside down
screenshots for vulkan.
2022-04-01 01:01:53 +09:00
Bill Currie acffacc59b [renderer] Make screen capture support asynchronous operation
This fixes (*ahem*) the vulkan renderer segfaulting when attempting to
take a screenshot. However, the image is upside down. Also, remote
snapshots and demo capture are broken for the moment.
2022-04-01 01:01:53 +09:00
Bill Currie a29836cc2c [quakefs] Return QFile pointer from QFS_NextFile(name)
QFS_NextFilename was renamed to QFS_NextFile to reflect the fact it now
returns a QFile pointer for the newly created file (as well as the
name). This necessitated updating WritePNG to take a file pointer
instead of a file name, with the advantage that WritePNGqfs is no longer
necessary and callers have much more control over the creation of the
file.

This makes QFS_NextFile much more secure against file system race
conditions and attacks (at least in theory). If nothing else, it will
make it more robust in a multi-threaded environment.
2022-03-31 17:27:04 +09:00
Bill Currie 8cdabc8905 [quakefs] Reimplement QFS_NextFilename to be more secure
It's not there yet as it promptly closes the file and returns only the
filename (and then only the portion within the user's directory tree).
However, this worked nicely as a test for Sys_UniqueFile.
2022-03-31 16:44:19 +09:00
Bill Currie a35bfef24c [sys] Add a function to safely create a unique file
QF currently uses unique file names for screenshots and server-side
demos (and remote snapshots), but they're generally useful.
QFS_NextFilename has been filling this role, but it is highly insecure
in its current implementation. This is the first step to taking care of
that.
2022-03-31 16:44:19 +09:00
Bill Currie 14ad364e17 [gamecode] Document the tests that fail under clang
The tests fail due to differences in how clang and gcc treat floating
point to unsigned integral type conversions when the values overflow. It
wouldn't be so bad if clang was consistent with conversions to 32-bit
unsigned integers, like it seems to be with conversion to 64-bit
unsigned integers.

With this, the "get QF building with clang" mini-project is done and I
won't have to panic when someone comes to me and asks if it will work.
At worst, there'll be a little bit-rot.
2022-03-31 14:50:49 +09:00
Bill Currie d3afb0da50 [vulkan] Remove a dead function
I guess gcc missed it because it's inline.
2022-03-31 02:59:37 +09:00
Bill Currie dad17162bb [console] Rewrite the download progress indicator
It was a nasty mess of suspicious strncats and the like.
2022-03-31 02:57:38 +09:00