Commit Graph

2412 Commits

Author SHA1 Message Date
Bill Currie d6d45bf07c [console] Add a function to clear the scroll-back buffer
Needed for when the console display is cleared.
2022-09-20 12:14:01 +09:00
Bill Currie 474f01d321 [renderer] Return count of lines printed to char buffer
This allows users to know the number of terminated lines in the printed
text without having to redundantly count the lines.
2022-09-20 10:27:24 +09:00
Bill Currie 48e5848a41 [console] Rework con_buffer ring buffers to have gaps
I really don't know why I tried to do ring-buffers without gaps, the
code complication is just not worth the tiny savings in memory. In fact,
just the switch from pointers to 32-bit offsets saves more memory than
not having gaps (on 64-bit systems, no change on 32-bit).
2022-09-18 11:35:09 +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 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 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 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 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 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 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 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 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 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 5ab88b0137 [sound] Clean up white space in snd_internal.h 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 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 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 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 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 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 76c62b49e0 [set] Add a macro to initialize with a static array
Nicer than trying to hack one one every time (and it looks like my
previous attempt was wrong anyway)
2022-06-04 12:06:34 +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 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 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 9166b08b06 [sound] Move sfx_t definition into snd_internal.h
I always wanted it there, there were dependency issues at the time. I
guess they got cleaned up for the most part since then (other than
cd_file, but it's on my hit-list).
2022-06-03 11:54:53 +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 847b3199d3 [bsp] Correct documentation about texture frame rate
It turns out BSP textures are animated at only five frames per second.
2022-05-26 22:25:18 +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 c86cb0ac54 [renderer] Clean up some unwanted dependencies
Nothing outside of the renderer should be including d_iface.h (locs.c
does still for particle defines), and plugin/vid_render.h is more
independent.
2022-05-26 14:41:08 +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 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 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 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 87f3c206f1 [simd] Remove some intrinsics uses
GCC does a nice enough job compiling the more readable form (though
admittedly, hadd is possibly more readable than what's there for
dot[fd], hadd is supposedly slower than the shuffles and adds, and qfvis
seems to support that).
2022-05-20 11:09:15 +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 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 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 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 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 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 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 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 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 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 7ed452027c [model] Rearrange msurface_t for better efficiency
It's down to 128 bytes from 184, which fits nicely in two cache lines.
This made a nice difference to glsl, unknown to vulkan (it crashed after
about 31/51 timedemo loops), and was a was for sw and gl.
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 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 b33df8b698 [vulkan] Clean up a pile of unnecessary includes 2022-05-08 17:57: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 c924329843 [scene] Use same id for entity queue test and add
This fixes the multiple draws of the same entity. Should be a small
speedup for all renderers :)
2022-05-07 15:45:11 +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 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 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 79add5590b [build] Fix some make distcheck issues
The never ending battle against bit-rot.
2022-05-06 15:50:13 +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 41a12f066b [client] Clean up light loading
By adding Light_AddLight to scene light management
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 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 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 2d75a652f1 [vulkan] Remove a dead file
I guess I forgot to delete draw.h when I added qf_draw.h.
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 a77aa16318 [vulkan] Make some headers order-indepenedent
In that they don't need Vulkan/qf_vid.h included first.
2022-05-04 13:55:56 +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 ef6e4722d5 [simd] Add some comments to mat4fquat
Having to refigure out what values are going into the vectors got old
very fast. The comments don't help with verifying the values, but at
least I can tell at a glance where 2(xy - wz) goes and thus determine
the "orientation" of the matrix.
2022-05-04 13:48:34 +09:00