Commit graph

5833 commits

Author SHA1 Message Date
Bill Currie
95f55dfc34 [ui] Move text handling into gui lib
And add a function to process a passage into a set of views with glyphs.
The views can be flowed: they have flow gravity and their sizes set to
contain all the glyphs within each view (nominally, words). Nothing is
tested yet, and font rendering is currently broken completely.
2022-12-08 15:33:50 +09:00
Bill Currie
136bf882f6 [ui] Move font loading into new gui library
Font and text handling is very much part of user interface and at least
partially independent of rendering, but does fit it better with GUI than
genera UI (ie, both graphics and text mode), thus libQFgui as well as
libQFui are built in the ui directory.

The existing font related builtins have been moved into the ruamoko
client library.
2022-12-07 17:38:38 +09:00
Bill Currie
46967dbc05 [glsl] Implement font rendering
It's not the best code, but it does the job of getting the basics
working.
2022-12-06 01:18:01 +09:00
Bill Currie
1f5ec68b4a [sw] Convert built in 8x8 font transparent pixels
I had done the loader for the GPU renderers, so the CPU renderer didn't
draw the characters transparently. Fixes the pink block in my ruamoko
test scene (due to the notify text area).
2022-12-05 21:06:42 +09:00
Bill Currie
a9745d0540 [vulkan] Use tex_a instead of tex_l for glyphs
While it doesn't really make any difference to the texture upload (8-bit
is 8-bit), and the sampler is in control of the interpretation, this
makes vulkan more consistent with the specification of the glyph
texture.
2022-12-05 17:13:32 +09:00
Bill Currie
113e4d5cf0 [sw] Implement font rendering
That looks better than expected.
2022-12-05 15:24:14 +09:00
Bill Currie
022c49035f [gl] Add a function to load a tex_t image
In theory, it supports all the non-palette formats, but only luminance
and alpha (tex_l and tex_a) have been tested. Fixes the rather broken
glyph rendering.
2022-12-05 13:35:44 +09:00
Bill Currie
b987414c1d [gl] Implement font rendering
It doesn't quite work properly due to the alpha-coverage texture being
uploaded as normal quake data, but all the basics are working nicely.
2022-12-05 11:28:48 +09:00
Bill Currie
8e1bf69d5d [scene] Correct the calculation of world scale
World scale can only be approximate if non-uniform scales and
non-orthogonal rotations are involved, but it is still useful
information sometimes.

However, the calculation is expensive (needs a square root), so remove
world scale as a component and instead calculate it on an as-needed
basis because it is quite expensive to do for every transform when it is
used only by the legacy-GL alias model renderer.
2022-12-05 09:45:13 +09:00
Bill Currie
7c4ee70d9e [build] Fix windows builds
More bitrot.
2022-12-02 17:33:26 +09:00
Bill Currie
99b568c208 [build] Fix distcheck once again
Probably the hardest part of QF to maintain.
2022-12-02 17:10:04 +09:00
Bill Currie
17c3f12ba2 [vulkan] Add a cvar for oit fragment buffer size
My laptop can't have a buffer larger than 128MB, but 16M fragments wants
512MB. Also, someone running at 4k will probably want a larger buffer.
2022-12-02 13:34:33 +09:00
Bill Currie
1d84d54509 [vulkan] Add cvars to control vulkan 3d frame buffer size
Thanks to the 3d frame buffer output being separate from the swap chain,
it's possible to have a different frame buffer size from the window
size, allowing for a smaller buffer and thus my laptop can cope (mostly)
with the vulkan renderer.
2022-12-02 13:17:07 +09:00
Bill Currie
9b609469ed [vulkan] Prevent particle update buffers escaping the staging buffer
The escape was actually harmless as the buffers would not be read due to
the particle count being 0 (thus why the buffers were at the end of the
staging buffer: no space was allocated for them, only for the system
buffer, but their offsets were just past the system buffer). However,
the validation layers quite rightly did not like that. Thus, the two
buffers are pointed to the system buffer so all three descriptors are
always valid.
2022-12-02 12:46:45 +09:00
Bill Currie
b35854c706 [renderer] Improve time graph display
It now shows 200 frames and markings for 0, 1, 2, 2.5, 3.3, 5 and 10ms.
2022-12-02 10:52:16 +09:00
Bill Currie
958b6ff1d8 [glsl] Implement line graph drawing
Finally :/
2022-12-02 10:51:41 +09:00
Bill Currie
baed4bb160 [gl] Skip lights that are too far from the surface
Where too far is 1024 units as that is the maximum supported, or the
radius. The change to using unsigned for the distances meant the simple
checks missed the effective max dist going negative, thus leading to a
segfault.
2022-12-02 10:12:54 +09:00
Bill Currie
966ef949c5 [vulkan] Move oit blending into compose subpass
I had debated putting the blending in the compose subpass or a separate
pass but went with the separate pass originally, but it turns out that
removing the separate pass gains 1-3% (5-15/545 fps in a timedemo of
demo1).
2022-12-01 23:03:55 +09:00
Bill Currie
7a64bb1149 [client] Use realtime for net icon check
viewstate's time is from cl.time which is not what's used to set
last_servermessage (that uses realtime). After careful investigation, I
found that cl.time is not at all suitable and that the original id code
used realtime (I think it was just me being lazy when I merged the
code). Fixes the stuck net icon.
2022-12-01 17:52:40 +09:00
Bill Currie
07fd93a56f [client] Use a separate explosion type for nq
quake changes rocket and grenade models to explosion models, but
quakeworld does not. This resulted in nq drawing two explosion sprites
instead of one. Separating the types allows nq to skip adding a sprite
for the explosion.
2022-12-01 15:59:14 +09:00
Bill Currie
9ba2d26542 [client] Move sbar.h into client
Where it belongs :P
2022-12-01 15:00:09 +09:00
Bill Currie
00cade072c [vulkan] Implement order implement transparency
It's a bit flaky for particles, especially at higher frame rates, but
that's due to supporting only 64 overlapping pixels. A reasonable
solution is probably switching to a priority heap for the "sort" and
upping the limit.
2022-12-01 03:00:47 +09:00
Bill Currie
ecd5e1de9f [vulkan] Ensure render passes have at least one subpass
Non-graphics render passes don't normally specify render pass info, but
still want frames and command buffers.
2022-12-01 02:50:07 +09:00
Bill Currie
b81a77c3f7 [vulkan] Get particle colors working for id style
This required making the texture set accessible to the vertex shader
(instead of using a dedicated palette set), which I don't particularly
like, but I don't feel like dealing with the texture code's hard-coded
use of the texture set. QF style particles need something mostly for the
smoke puffs as they expect a texture.
2022-11-28 22:57:22 +09:00
Bill Currie
76258906f9 [vulkan] Skip use of the physics event
It doesn't want to work on my nvidia (or more recent sid?) and doesn't
seem to be necessary. The problem may be multiple event sets before the
first wait, but investigation can wait for now.
2022-11-28 21:35:46 +09:00
Bill Currie
38b56b4ce8 [vulkan] Use correct offsets for new particle descriptors
This is probably the biggest reason I had problems with particles not
updating correctly: the descriptors were generally point pointing to
where the data actually was in the staging buffer.
2022-11-28 15:24:40 +09:00
Bill Currie
24c08a8dc4 [vulkan] Wait on physics event before drawing particles
This should be more correct. At least it passes validation on my laptop
(intel/llvm): I had trouble with it on nvidia.
2022-11-28 15:16:52 +09:00
Bill Currie
51f3d9b777 [vulkan] Fix particle local and dispatch sizes
This gets particles working in renderdoc, but they're quite broken
stand-alone, which I think means that synchronization is a problem.
2022-11-28 11:09:20 +09:00
Bill Currie
30b38d7f3f [vulkan] Implement particle rendering
They sort of kind of maybe try to work, but there's plenty wrong. I
suspect synchronization and probably other factors.
2022-11-28 10:21:20 +09:00
Bill Currie
d9b0ee22e6 [vulkan] Get particle compute pipelines running
I don't yet know whether they actually work (not rendering yet), but the
system isn't locking up, and shutdown is clean, so at least resources
are handled correctly.
2022-11-28 00:52:07 +09:00
Bill Currie
dd1b15c92f [vulkan] Give staging buffers storage usage
Really, additional usage flags should be a parameter. Needed for
particles as the particle updates are read directly from the staging
buffer.
2022-11-28 00:49:32 +09:00
Bill Currie
efc3443c61 [vulkan] Create a water warp output pipeline
Although it works as intended (tested via hacking), it's not hooked up
as the current frame buffer handling in r_screen is not readily
compatible with how vulkan output is handled. This will need some
thought to get working.
2022-11-27 12:48:51 +09:00
Bill Currie
22615f25ab [vulkan] Move 2d to the output render pass
This separates 2d UI rendering from 3d world rendering, making way for
various post-processing effects on the 3d render.
2022-11-27 09:51:01 +09:00
Bill Currie
85d40123e7 [vulkan] Remove depth pass from 2d rendering
I realized afterwards it wasn't really want I want as it would mess with
things like water warp and other effects.
2022-11-27 00:35:38 +09:00
Bill Currie
3360578875 [vulkan] Rework render pass setup
This splits up render pass creation so that the creation of the various
resources can be tailored to the needs of the actual render pass
sub-system. In addition, it gets window resizing mostly working (just
some problems with incorrect rendering).
2022-11-26 23:26:35 +09:00
Bill Currie
2cb3083f97 [vulkan] Support parsing qfv_output_t
This will be needed by the revamped render pass code.
2022-11-26 22:22:22 +09:00
Bill Currie
7829ec3adb [vkgen] Add support for read-only values
This makes it possible to use the parser to read in certain fields, but
skip over others. The read-only is for cexpr parsing of the read-only
fields.
2022-11-26 22:15:15 +09:00
Bill Currie
0dab26ce8f [cexpr] Allow untyped result values
If the result object type pointer is null, then the parsed result type
and value pointers are written directly to the result object rather than
testing the parsed result type against the object type and copying the
parsed result value data to the location of the object value. It is then
up to the caller to check the type and copy the value data.
2022-11-26 22:10:29 +09:00
Bill Currie
7e16822f21 [vulkan] Recreate image available semaphore
It turns out the semaphore used for vkAcquireNextImageKHR may be left in
a signaled state for VK_ERROR_OUT_OF_DATE_KHR. While it seems to be
possible to clear the semaphore using an empty queue submission,
destroying and recreating the semaphore works well.

Still have problems with the frame buffer after window resize, though.
2022-11-25 18:18:41 +09:00
Bill Currie
0fdba75a6e [vulkan] Move swap chain image acquisition to the output module
Swap chain acquisition is part of final output handling. However, as the
correct frame buffers are required for the render passes, the
acquisition needs to be performed during the preoutput render pass.
Window resize is still broken, but this is a big step towards fixing it.
2022-11-25 16:08:15 +09:00
Bill Currie
92b36582ca [vulkan] Change curFrame from size_t to uint32_t
I very much doubt that even 4294967295 frames will be needed, let alone
more. Saves me having to use %zd or %zu all over the place.
2022-11-25 16:02:39 +09:00
Bill Currie
87f99f9081 [vulkan] Limit shadow textures to 32
This is the minimum maximum count for sampled images, and with layered
shadow maps (with a minimum of 2048 layers supported), that's really way
more than enough.
2022-11-25 13:35:07 +09:00
Bill Currie
edc1326736 [vulkan] Search for BGRA8 instead of RGBA8
I guess nvidia gives a non-srgb format as the first in the list, but my
laptop gives an srgb format first, thus the unexpected difference in
rendering brightness. Hard-coding BGRA isn't any better, but it will do
for now.
2022-11-25 12:57:56 +09:00
Bill Currie
7a91c905e0 [vulkan] Fix broken line drawing
Line drawing was broken with the 2d depth pass (which will go away in
the end, but I like the organization of the draw code).
2022-11-25 11:12:05 +09:00
Bill Currie
d673887bf1 [vulkan] Get two render pass rendering working
Things are a bit of a mess with interdependence between sub-module
initialization and render pass initialization, and window resizing is
broken, but the main render pass rendering to an image that is then
post-processed (currently just blitted) is working. This will make it
possible to implement fisheye and water warp (and other effects, of
course).
2022-11-25 11:07:08 +09:00
Bill Currie
7f25c43472 [vulkan] Make script support objects more private
This will help keep changes to the scripting system localized once
things are further cleaned up.
2022-11-24 23:44:07 +09:00
Bill Currie
f9e45aec4c [vulkan] Be more consistent with parse context naming 2022-11-23 11:34:20 +09:00
Bill Currie
8842db082f [vulkan] Add ScreenSize to shader def
This had somehow gotten lost from the previous commit.
2022-11-22 21:06:12 +09:00
Bill Currie
2cee2f2ab8 [vulkan] Add a module to handle output
When working, this will handle the output to the swap-chain images and
any final post-processing effects (gamma correction, screen scaling,
etc). However, currently the screen is just black because the image
for getting the main render pass output isn't hooked up yet.
2022-11-22 17:47:36 +09:00
Bill Currie
7b15caee04 [vulkan] Adjust shutdown order slightly
It makes more sense to shutdown the render passes before textures.
2022-11-22 13:30:29 +09:00
Bill Currie
a886b9432c [render] Tidy up Makemodule ever so slightly
I really need to find a good way to handle all the non-standard files.
2022-11-22 13:29:11 +09:00
Bill Currie
0a3417d38e [vulkan] Add support for code-only render passes
Still very preliminary, but it allows for CPU-only passes to be added to
the tasks run for each frame.
2022-11-22 13:25:09 +09:00
Bill Currie
b7947b48a5 [vulkan] Move matrices uniform def to a header file
Too many places to keep up to date.
2022-11-21 20:02:18 +09:00
Bill Currie
5df9b506e0 [vulkan] Rename the pipeline file
The pl_prefix helps with organization, and the rest of the name makes it
clear it's for the quake deferred renderer.
2022-11-21 17:41:39 +09:00
Bill Currie
7a50cdd7a8 [vulkan] Correct the render pass order comparison
Since pointers are being sorted, need to use double pointer (I often
make this mistake).
2022-11-21 17:29:26 +09:00
Bill Currie
aac4c6ef7a [vulkan] Get multiple frame buffers working
Now each (high level) render pass can have its own frame buffer. The
current goal is to get the final output render pass to just transfer the
composed output to the swap chain image, potentially with scaling (my
laptop might be able to cope).
2022-11-21 17:25:55 +09:00
Bill Currie
e50be73501 [vulkan] Rename the render pass files
Prefixing them with "rp_" helps a little with organization.
2022-11-21 13:11:50 +09:00
Bill Currie
82d1a6e6cd [vulkan] Do a depth pass for 2d objects
While the HUD and status bar don't cut out a lot of screen (normally),
they might start to make a difference when I get transparency working
properly. The main thing is this is a step towards pulling the 2d
rendering into another render pass so the main deferred pass is
world-only.
2022-11-21 02:29:03 +09:00
Bill Currie
2828a4ce0c [vulkan] Use a swizzle view for coverage-alpha
And thus a single pipeline for either colored glyphs or coverage-alpha
glyphs, making for better batching when I get to that.
2022-11-20 15:46:16 +09:00
Bill Currie
40b319bf42 [vulkan] Support swizzles in resource image views
Using swizzles in an image view allows the same shader to be used with
different image "types" (eg, color vs coverage).

Of course, this needed to abandon QFV_CreateImageView, but that is
likely for the best.
2022-11-20 15:31:23 +09:00
Bill Currie
534d5367de [vulkan] Use linear sampling for glyphs
This requires having padding around the glyphs to avoid texel leak, but
as the atlas is created at runtime, it's possible to get the padding in.
2022-11-20 03:59:01 +09:00
Bill Currie
4cbacc1149 [vulkan] Remove the pic texel offsets
It turns out that nearest filtering doesn't need any offsets to avoid
texel leaks so long as the screen isn't also offset. With this, the 2d
rendering looks good at any scale (minus the inherent blockiness).
2022-11-20 01:26:14 +09:00
Bill Currie
4ff3ca104d [gl] Make conchars use nearest sampling
Linear sampling in a texture atlas (which is what conchars is) requires
the use of border pixels to avoid pixel leakage.
2022-11-20 01:21:45 +09:00
Bill Currie
e0b9e118a0 [renderer] Remove the 1/2 pixel shift of the 2d screen
It seemed like a good idea at the time, but it exacerbates pixel leakage
in atlas textures that have no border pixels (even in nearest sampling
modes).
2022-11-20 01:17:09 +09:00
Bill Currie
7e442a9019 [renderer] Correct crosshair sizes
I'm pretty sure they're meant to be 8x8 and not 16x16. Certainly they're
a tad large at 16x16 when using scaled 2d.
2022-11-20 00:50:59 +09:00
Bill Currie
2a8c12426d [sw] Ensure the view model has a visibility component
The rest of the system won't add one automatically (since entity
creation no longer does), but the alias and iqm rendering code expect
there to be one. Fixes a segfault when starting a scene (demo etc).
2022-11-19 14:06:24 +09:00
Bill Currie
b59505b7c1 [glsl] Remove glpic_t struct
It hasn't been necessary for a long time and is a tad misleading as all
it does is wrap a pointer to subpic_t.
2022-11-19 00:41:52 +09:00
Bill Currie
ae200e4e40 [renderer] Compensate for scale in cross-hair placement
I was wondering where it had gone (south east, actually).
2022-11-18 11:23:32 +09:00
Bill Currie
2a1255de59 [renderer] Make cross hair data easier to see in code
It is rather hard to pick out an image from a mass of 0xff and 0xfe.
2022-11-18 11:11:38 +09:00
Bill Currie
bffe9413b7 [vulkan] Add support for 9-slice rendering
There's no API yet as I need to look into the handling of qpic_t before
I can get any of this into the other renderers (or even vulkan, for that
matter).

However, the current design for slice rendering is based on glyphs (ie,
using instances and vertex pulling), with 3 strips of 3 quads, 16 verts,
and 26 indices (2 reset). Hacky testing seems to work, but real tests
need the API.
2022-11-18 09:44:01 +09:00
Bill Currie
b1d7bad2e3 [renderer] Move call to R_ClearEfrags to SCR_NewScene
Probably more such should be moved, but efrags is on my mind. There's no
need for the call to be spread through all the renderers.
2022-11-17 22:12:41 +09:00
Bill Currie
06f410b0b6 [renderer] Clear the visibility components on scene reset
I don't know why it didn't happen during the demo loop, but going from
the start map to e1m1 caused a segfault due to the efrags for a lava
ball getting double freed (however, I do think it might be because the
ball passed through at least two leafs, while entities in the demos did
not). The double free was because SCR_NewScene (indirectly) freed all
the efrags without removing them from entities, and then the client code
deleting the entities caused the visibility components to get deleted
and thus the efrags freed a second time. Using ECS_RemoveEntities on the
visibility component ensures the entities don't have a visibility
component to remove when they are later deleted.
2022-11-17 22:12:41 +09:00
Bill Currie
ac0079f872 [ecs] Add a function to remove a component from all entities
While simple component pools can be cleared simply by zeroing their
counts, ones that have a delete function need that function to be called
for all the components in the pool otherwise leaks can happen.
2022-11-17 21:49:38 +09:00
Bill Currie
387f17dc0c [scene] Add a color map component
It's currently used only by the vulkan renderer, as it's the only
renderer that can make good use of it for alias models, but now vulkan
show shirt/pants colors (finally).
2022-11-15 15:30:35 +09:00
Bill Currie
a28488d2e1 [vulkan] Move both alias color maps into the one layer
This cuts down on the memory requirements for skins by 25%, and
simplifies the shader a bit more, too. While at it, I made alias skins
nominally compatible with bsp textures: layer 0 is color, 1 is emissive,
and 2 is the color map (emissive was on 3).
2022-11-15 13:09:41 +09:00
Bill Currie
668f7f2cd2 [vulkan] Use palette lookups for top/bottom colors
As the RGB curves for many of the color rows are not linearly related,
my idea of scaling the brightest color in the row just didn't work.
Using a masked palette lookup works much better as it allows any curves.
Also, because the palette is uploaded as a grid and the coordinates are
calculated on the CPU, the system is extendable beyond 8-bit palettes.

This isn't quite complete as the top and bottom colors are still in
separate layers but their indices and masks can fit in just one, but
this requires reworking the texture setup (for another commit).
2022-11-15 11:53:07 +09:00
Bill Currie
4d7f72948d [vulkan] Correct alias g-buffer push-constants
For whatever reason, I had added an extra 4 bytes to the fragment
shader's push-constants. It took me a while to figure out why renderdoc
wouldn't stop complaining about me not writing enough data.
2022-11-15 09:28:34 +09:00
Bill Currie
2e21ca4b9a [vulkan] Upload palette as a 16x16 image
It turns out my approach to alias skin coloring just doesn't work for
the quake data due to the color curves not having a linear relationship,
especially the bottom colors.
2022-11-15 09:26:17 +09:00
Bill Currie
251e47f4d6 [vulkan] Add a function to update texture contents
It works on only one layer and one mip, and assumes the provided texture
data is compatible with the image, but does support sub-image updates
(x, y location as parameters, width and height in the texture data).
2022-11-15 09:18:26 +09:00
Bill Currie
8fa6167a57 [vid] Add a function to set the palette and colormap
Mostly for qwaq as it uses the default VGA palette but I need to do some
testing with the quake palette.
2022-11-14 19:39:55 +09:00
Bill Currie
7c53a68ad7 [scene] Move efrag code from renderer to scene
While culling is very much part of rendering, it's more scene related
than renderer related.

Fixes the transform test failing to link.
2022-11-14 12:43:33 +09:00
Bill Currie
053c2c47db [vulkan] Double alias top/bottom color values
The bright end of the color map is actually twice the palette value, but
I didn't understand this when I came up with the shirt/pants color
scheme for vulkan. However, the skin texture can store only 0..1, so the
mapping to 0..2 needs to be done in the shader. It looks like it works
at least better: the gold key at the end of demo1 doesn't look as bleh,
though I do get some weird colors still on ogres etc.
2022-11-14 11:35:26 +09:00
Bill Currie
9f6c367fce [console] Resurrect console scaling
Currently only for gl/glsl/vulkan. However, rather than futzing with
con_width and con_height (and trying to guess good values), con_scale
(currently an integer) gives consistent pixel scaling regardless of
window size.
2022-11-14 09:49:13 +09:00
Bill Currie
0e64f959e2 [scene] Move visibility management into scene code
Well, sort of: it's still really in the renderer, but now calling
R_AddEfrags automatically updates the visibility structure as necessary,
and deleting an entity cleans up the efrags automatically. I wanted this
over twenty years ago.
2022-11-13 15:08:18 +09:00
Bill Currie
767b39b7bd [client] Implement the scoreboards and spectator
This gets the status bar/hud back into function state.
2022-11-13 04:15:26 +09:00
Bill Currie
47fb887724 [vulkan] Implement Draw_TileClear
The status bar doesn't look right without it when it's supposed to be
there.
2022-11-13 04:15:26 +09:00
Bill Currie
2d3c2da64d [qfcc] Support advanced progs again
The support for the new vector types broke compiling code using
--advanced. Thus it's necessary to ensure vector constants are
float-type and vec3 and vec4 are treated as vector and quaternion, which
meant resurrecting the old vector expression code for v6p progs.
2022-11-12 20:04:19 +09:00
Bill Currie
bbd2cdb8c8 [console] Check for curses before calling updaters
If curses isn't being used, then there are no entities and thus no
components to run. Fixes a segfault when running a server without curses
enabled.
2022-11-12 14:37:42 +09:00
Bill Currie
1a9ec15a41 [client] Include hud overlay in hud_debug 2022-11-12 01:50:31 +09:00
Bill Currie
0d9b475759 [client] Implement finale overlay and death-solo
Deathmatch overlay isn't working properly for end of level or death in
qw.
2022-11-12 01:47:17 +09:00
Bill Currie
749a110b76 [util] Check share path too when filling file lists
This fixes maplist showing only those maps in the user directory.
However, no checking is done for duplicate files due to earlier search
paths overriding later paths.
2022-11-11 22:05:10 +09:00
Bill Currie
5333c78f7a [client] Implement rogue's team (ctf) face
I don't like that teamplay is just a local cvar that doesn't get set by
the server.
2022-11-11 19:41:47 +09:00
Bill Currie
7b167b2f35 [client] Implement rogue inventory bar switching
And fix rogue ammo icons.
2022-11-11 18:27:51 +09:00
Bill Currie
acedc906dd [client] Implement hipnotic and rogue items
This involved disabling sigils for hipnotic and rogue (not used),
adjusting the number of items views, and moving the two keys views for
hipnotic. Rogue is not yet using the correct status bar pics.
2022-11-11 15:18:31 +09:00
Bill Currie
a91ae7aeb9 [client] Implement hipnotic and rogue weapon views
The functionality of the hipnotic and rogue weapon power-ups is now done
by a various mappings instead of separate functions. In theory, this
should make things more flexible, but most importantly, there's a lot
less code duplication.
2022-11-11 13:00:40 +09:00
Bill Currie
017bba8869 [client] Fix some view placement and buffer sizes 2022-11-10 21:27:49 +09:00
Bill Currie
c6b79d49a4 [client] Fix incorrect function component setup
Need to pass the address of the pointer :/
2022-11-10 21:23:04 +09:00
Bill Currie
2fb5b67012 [vulkan] Implement line graph rendering
I should probably just use the line rendering for all renderers and pull
the graph drawing out to the client code.
2022-11-10 21:19:01 +09:00
Bill Currie
74e64d7228 [client] Implement sbar flashes for items
Sigils can't be flashed as they don't have any animations provided, and
they're not normally as critical. I don't know why items weren't
flashed, but since the pics are there, might as well use them (and the
flashing keys do look pretty good).
2022-11-10 15:35:14 +09:00
Bill Currie
39074ba3c1 [qw] Implement hud ping and pl indicators
As well as the periodic update of pings when the scoreboard or hud ping
are shown.
2022-11-10 15:34:31 +09:00
Bill Currie
d9b231e2aa [util] Return null for missing wad lumps
Segfaults are not good when a lump can't be found as it makes error
checking difficult.
2022-11-10 14:44:08 +09:00
Bill Currie
e0fa853f47 [client] Implement the update functions
nq's frags don't update properly yet, and there's still a lot of
optimization to sort out, but it seems to be fairly usable again.
2022-11-10 01:35:33 +09:00
Bill Currie
1b90f2320e [client] Extend sbar's api
I think this makes the purpose of the functions more clear and makes the
protocol logic less dependent on the meaning of some of the updates.
Most of the update functions are not fully implemented yet.
2022-11-09 19:41:59 +09:00
Bill Currie
73e62de2fb [client] Clean up sbar's globals access
I had forgotten that the cl structs in nq and qw were different layouts,
which resulted in qw's sbar/hud being quite broken. Rather than messing
with the structs, I decided it would be far better in the long run to
clean up sbar's access to the cl struct and the few other nq/qw specific
globals it used. There are still plenty of bugs to fix, but now almost
everything is in the one place.
2022-11-09 19:38:54 +09:00
Bill Currie
34f0a59441 [client] Merge sbar
At long last, the status bar code is now shared between nq and qw. There
are many bugs to fix, but at least now they're all in the one place.
2022-11-08 17:42:27 +09:00
Bill Currie
24d8d864a2 [ecs] Optionally delete entities on hierarchy removal
Useful for deleting an entire sub-hierarchy of entities.
2022-11-08 00:16:29 +09:00
Bill Currie
ddd6c958a9 [ecs] Fix parent index updates when removing sub-hierarchies
In the end, it was removal of the old entries that corrupted the parent
indices. Very nicely, most of the fixes involved removing code. Taking
advantage of the ECS to debug the hierarchies was fun, and the resulting
colorized entity names helped no end.
2022-11-06 23:04:40 +09:00
Bill Currie
1130919049 [ecs] Add a simplified test of the sbar hierarchy
Even 37 objects is a lot, but it's a whole lot better than 180. Most
importantly, it reproduces the problem, which seems to be not all parent
indices getting updated. The child indices seem to be working nice, as
do the reference object indices (ie, the entity components). I suspect
its the parent indices getting corrupted that cause problems on the
second switch of the hud/sbar cvar as the parent indices are used to
find the child indices that need to be updated.
2022-11-06 20:04:34 +09:00
Bill Currie
cf6b4efe5d [ecs] Colorize hierarchy test output
Just the tiniest bit of color goes a long way to spotting issues.
2022-11-06 20:03:29 +09:00
Bill Currie
97a6ce833e [ecs] Adjust the source root during self insertions
This improves the behavior of hierarchies when self-inserting, but nq's
sbar still crashes when trying to do so. However, its tree is a fair bit
more complex than the test case (that does pass now), so I need to try
to replicate the important parts of the tree with fewer objects (180 is
too many to work with).
2022-11-06 17:36:49 +09:00
Bill Currie
ecf59c8141 [ecs] Add failing same-hierarchy parenting test
As expected, reparenting a sub-hierarchy such that it (and possibly its
children) move up the arrays fails (this is why sbar needs to first
remove the sub-hierarchy then insert it).
2022-11-06 17:36:33 +09:00
Bill Currie
05947c8ac4 [ecs] Rework new hierarchy test for same-hierarchy
Since test_build_hierarchy2 already tested removal of a sub-hierarchy
(once fixed), it seems test_build_hierarchy3 testing parenting within
the same hierarchy would be a good idea. Reparenting such that
everything moves to later in the arrays works nicely (not very
surprising).
2022-11-06 08:36:43 +09:00
Bill Currie
b91568d234 [ecs] Improve the behavior of Hierarchy_RemoveHierarchy
Its updates to the various indices were out, but this was missed due to
the tests being wrong. I wonder if I got interrupted while working on
them last and just assumed the removals were correct. This improves
sbar's behavior, but it's still wrong when pulling the armory view out
of the inventory. Very unsure what's going on, but the various indices
look ok, as do the view positions.
2022-11-06 02:38:59 +09:00
Bill Currie
01c67a345f [ecs] Fix some more hierarchy tests
Ugh, things were quite bad, it turns out. It seems a lot of trouble
would have been saved if these tests had worked (however, something is
still not quite right as views are out of place).
2022-11-06 00:30:55 +09:00
Bill Currie
f89fbf9724 [ecs] Fix a child miscount in the test case
Heh, that was a bit funny, actually, but it makes me wonder just how
broken sub-hierarchy deletion was.
2022-11-05 23:44:01 +09:00
Bill Currie
26438848ce [ecs] Add a failing hierarchy test
This is the bug that sbar found when pulling a sub-hierarchy out of a
larger hierarchy: child indices not getting updated correctly for later
siblings and any niece objects.
2022-11-05 22:23:46 +09:00
Bill Currie
10037927ea [ecs] Add hierarchy-only tests
The hierarchy-specific tests from the transform tests have been moved
into the ecs tests and the transform tests renamed appropriately. As
part of the process, hierarchies can now have a null type (ie, no
additional components maintained by the hierarchy). This should make
sorting out the issues highlighted by sbar a bit easier.
2022-11-05 21:29:38 +09:00
Bill Currie
57cd30fca3 [ecs] Move parent setting logic into hierarchy
It should have always been here, but when I first created the hierarchy
and transform objects, I didn't know where things would go. Having two
chunks of code for setting an entity's parent was too already too much,
and I expect to have other hierarchy types. Doesn't fix the issues
encountered with sbar, of course.
2022-11-05 17:54:49 +09:00
Bill Currie
42963f97c0 [client] Clean up some hud redundancies
hud_view is set up by sbar, and the other views are no longer used.
2022-11-05 16:47:52 +09:00
Bill Currie
3d30e78da9 [client] Add hud_debug cvar to draw view outlines
It's much easier to debug the hud when even otherwise invisible views
can be seen.
2022-11-05 16:38:07 +09:00
Bill Currie
5f98dac214 [client] Add a hud outline component for debug
Very handy for verifying views are placed correctly. Also fix some type
issues with the func and update components.
2022-11-05 10:55:45 +09:00
Bill Currie
472b6995b7 [ui] Set passage text object start and size
The text object covering the whole passage was not being initialized,
thus center print tried to print rubbish when (incorrectly) printing the
entire message.
2022-11-04 15:26:01 +09:00
Bill Currie
1d51c05f90 [ui] Make passage objects reusable
I had intended to do this for a while, but now that I want it for center
print strings, it was time to make the change.
2022-11-04 13:06:20 +09:00
Bill Currie
5f01dc9fb5 [client] Make the hud update function type explicit 2022-11-04 11:10:56 +09:00
Bill Currie
99e12872e5 [console] Get menu rendering working again
For certain values of working. The whole thing needs a rewrite but it's
nice that using an ECS doesn't force everything to conform to that
model.
2022-11-04 10:38:07 +09:00
Bill Currie
6b99697e82 [ui] Get flowed views working with ECS
I'm not particularly happy with the way onresize is handled, but at this
stage a better way of dealing with resizing views and getting the child
views to flow correctly hasn't come to mind. However, the system should
at least be usable.
2022-11-04 00:29:13 +09:00
Bill Currie
bdbb8f1e0b [nq] Get intermission view working again
This is currently just the basic intermission view (not the finale view
or the deathmatch intermission view).
2022-11-03 17:49:05 +09:00
Bill Currie
a07eccd5c7 [glsl] Fix some GLSL conformance issues
I'm not sure when things broke on my laptop (I thought I got warp and
fisheye working on my laptop), but it turns out things weren't quite
right, thus warp (and presumably fisheye) weren't working properly due
to GLSL errors that I only just noticed. This fixes water warp (and
probably fisheye).
2022-11-03 16:42:49 +09:00
Bill Currie
82d407e3c2 [nq] Get hud time and fps displays working
This includes moving the related cvars from botn nq and qw into the
client hud code. In addition, the hud code supports update and
update-once function components. The update component is for updates
that occur every frame, but update-once components (not used yet) are
for one-shot updates (eg, when a value updates very infrequently).
2022-11-03 14:46:44 +09:00
Bill Currie
4491ce213b [client] Merge cl_screen.c
The client state that was accessed by cl_screen is now put in viewstate
and maintained by the client before calling CL_UpdateScreen.
2022-11-02 15:11:09 +09:00
Bill Currie
708978eea9 [client] Clean up some entity component accesses 2022-11-02 09:53:52 +09:00
Bill Currie
9c6c59b370 [qw] Move view hight adjustment out of screen update
cl_screen.c is that little bit closer to being merged.
2022-11-02 09:52:35 +09:00
Bill Currie
e67b374fd4 [ui] Propagate resize deltas in view hierarchies
While it hasn't been a problem yet (no multi-level resizing), I'm sure
it will be before too long.
2022-11-01 10:59:28 +09:00
Bill Currie
036afba23d [ui] Propagate motion modifications for views
With this, the status bar now stays in the correct location as the
window is resized. Rather nice that it was just a simple omission.
2022-11-01 10:15:23 +09:00
Bill Currie
81e23b2e52 [console] Remove a debug print 2022-11-01 10:14:50 +09:00
Bill Currie
817aeb334e [ui] Convert view_t to an ECS entity
Much of the nq/qw HUD system is quite broken, but the basic status bar
seems to be working nicely. As is the console (both client and server).
Possibly the biggest benefit is separating the rendering of HUD elements
from the updating of them, and much less traversing of invisible views
whose only purpose is to control the positioning of the visible views.

The view flow tests are currently disabled until I adapt the flow code
to ECS.

There seems to be a problem with view resizing in that some gravities
don't follow resizing correctly.
2022-11-01 00:40:52 +09:00
Bill Currie
cf911884c6 [ecs] Add support for sorting component pools
As the bookkeeping data is spread between three arrays, sorting a
component pool is not trivial and thus not something to duplicate around
the codebase.
2022-10-31 13:10:53 +09:00
Bill Currie
7c06012383 [util] Support custom swap function for heapsort
Sorting ECS component pools needs to swap multiple chunks of data for
each element being swapped, so the standard swap function isn't enough.
2022-10-31 10:52:03 +09:00
Bill Currie
7106411bc0 [ui] Link with the ECS library
Who thought dynamic libs was a good idea...
2022-10-28 11:45:30 +09:00
Bill Currie
9e57d5cb77 [ui] Create entities for passage text objects
At least, I think I want to do that :)
2022-10-28 11:43:03 +09:00
Bill Currie
f6820c59e7 [ecs] Initialize registry href_comp to nullent
This indicates that no hierarchy reference component has been
registered, which must be done by the user when hierarchies are used.
2022-10-28 11:39:59 +09:00
Bill Currie
45e47a6df0 [ui] Update passage code to use an ECS hierarchy
It's not quite complete in that entities need to be created for the
objects, and passage text object might get additional components in the
hierarchy, but the direct use of views has been replaced by the use of a
hierarchy object with the same tree structure, and now has text objects
for paragraphs and the entire passage.
2022-10-27 19:47:10 +09:00
Bill Currie
80c0beff89 [ecs] Support adding null hierarchies to non-root
As an implementation detail, inserting null hierarchies (src hierarchy
is null) is supported for ease of hierarchy construction from data. No
component data is copied, only the child and parent indices and counts
are updated.
2022-10-27 19:46:28 +09:00
Bill Currie
52b09e81cd [ecs,scene] Update tests for move to separate ecs lib
And fix an issue spotted in hierarchy.c: incorrect move of objects and
lack of check for valid entity when updating hierarchy reference
indices.
2022-10-27 15:35:29 +09:00
Bill Currie
d8cdaa7237 [vulkan] Fix some errors in shadow map setup
I had forgotten to test with nq, so I had missed that I'd messed up cube
map requests and the image map. This gets nq working again.
2022-10-27 13:29:14 +09:00
Bill Currie
0a3c7b5b76 [vulkan] Don't use QFV_CreateImage for resource images
The resource functions assume the requested layers is correct (really,
the lighting code assumes that the resource functions assume such), but
QFV_CreateImage multiplies the layer count by 6 for cube maps (really,
the issue is in QFV_CreateImage, but I want to move away from it
anyway).
2022-10-27 13:26:00 +09:00
Bill Currie
c605e50d52 [renderer] Check view_model entity is valid
It usually is in quake, but my test scene does not have a view model.
2022-10-27 12:55:01 +09:00
Bill Currie
fa057cb121 [vulkan] Record resource memory size
It's useful mainly for information reports, but might be useful
elsewhere.
2022-10-27 11:32:00 +09:00
Bill Currie
1f27622309 [vulkan] Free shadow map resource block
I forgot I had to free the memory too. Oops.
2022-10-27 11:23:49 +09:00
Bill Currie
169c282187 [vulkan] "Fix" view model check in rendering loop
The check for the entity being the view model was checking only the
view model id, which is not sufficient when the view model is invalid by
never being set to other than 0s. A better system for dealing with the
view model is needed.
2022-10-27 11:11:38 +09:00
Bill Currie
6952f6860d [vulkan] Use the resource functions for shadow maps
Another step towards moving all resource creation into the one place.
The motivation for doing the change was getting my test scene to work
with only ambient lights or no lights at all.
2022-10-27 11:02:45 +09:00
Bill Currie
5d19936387 [gl,sw] Don't clear world's efrags on new scene
It seems this isn't needed any more (not sure why) as both glsl and
vulkan are happy without it. Also unsure why moving to ECS made gl and
sw change behavior regarding rendering the test models in my scene.
2022-10-27 00:22:15 +09:00
Bill Currie
600a342200 [ruamoko] Fix missing entity registry pointer 2022-10-26 17:45:45 +09:00
Bill Currie
db7f8a461e [ecs] Move ECS core into its own library
While the libraries are probably getting a little out of hand, the
separation into its own directory is probably a good thing as an ECS
should not be tied to scenes. This should make the ECS more generally
useful.
2022-10-26 17:24:03 +09:00
Bill Currie
52b7f7f308 [renderer] Fix a comment typo and add a fixme 2022-10-26 12:32:09 +09:00
Bill Currie
20c861027e [sw] Take advantage of the ECS for edge rendering
This fixes the segfault due to the world entity not actually existing,
without adding a world entity. It takes advantage of the ECS in that the
edge renderer needs only the world matrix, brush model pointer, and the
animation frame number (which is just 0/1 for brush models), thus the
inherent SOA of ECS helps out, though benchmarking is needed to see if
it made any real difference.

With this, all 4 renderers are working again.
2022-10-25 19:36:09 +09:00
Bill Currie
2a9fcf4f5f [renderer] Tidy up entity component access
Since entity_t has a pointer to the registry owning the entity, there's
no need to access a global to get at the registry. Also move component
getting closer to where it's used.
2022-10-25 12:53:30 +09:00
Bill Currie
5b0810f4c2 [scene] Make Ent_AddComponent more raw
It no longer initializes the new component. For that, use
Ent_SetComponent which will copy in the provided data or call the
component's create function if the data pointer is null (in which case,
Ent_SetComponent acts as Ent_SetComponent used to).
2022-10-25 11:41:14 +09:00
Bill Currie
4759be449f [scene] Ensure entity owns component before removing
I realized I should check that the entity owns the component before
treating it as existing when adding an existing component, then noticed
that Ent_RemoveComponent didn't check before removing the component. I
imagine that would have been a fun debug session :P
2022-10-25 09:55:08 +09:00
Bill Currie
9e83ded0ac [scene] Return existing component instead of null
While checking on how Ent_AddComponent behaved (I don't remember what I
was looking for, though), I realized that instead of treating adding the
same component to an entity as an error, Ent_AddComponent should just
return the existing component.
2022-10-25 09:54:49 +09:00
Bill Currie
f37c31a2dc [vulkan] Set entity render id correctly
It was being set to -1 unconditionally due to forgetting to use id.
However, I decided I didn't like reusing the id var and did some
renaming while I was at it.
2022-10-23 23:38:21 +09:00
Bill Currie
8acd5c558b [scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).

While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 22:24:36 +09:00
Bill Currie
de786ce197 [scene] Use hierref_t instead of transform_t in hierarchy
Hierarchies are now much closer to being more general in that they are
not tied to 3d transforms. This is a major step to moving the whole
entity/transform system into an ECS.
2022-10-22 13:04:07 +09:00
Bill Currie
ac8c6b631e [vulkan] Skip ambient lights for shadow maps
Not that anything is actually rendered yet, but the validation layers
don't like the null render pass. Came up now because ctf1 seems to make
the first light an ambient light.
2022-10-22 13:00:12 +09:00
Bill Currie
b607fe0878 [scene] Add has/get component functions
And define nullent as 0 is a valid entity.
2022-10-21 19:12:20 +09:00
Bill Currie
6189142c60 [renderer] Remove rglyph_t struct
It didn't really add anything of value as the glyph bitmap rects and the
bearings were never used together, and the rest of the fields were
entirely redundant. A small step towards using a component system for
text.
2022-10-20 15:50:53 +09:00
Bill Currie
06ccc3023b [scene] Start work on a full-on ECS system
That does feel a little redundant, but I think the System in ECS is
referring to the systems that run on the components, while the other
system is the support code for the ECS. Anyway...

This is based heavily on the information provided by @skipjack in his
github blog about EnTT. Currently, entity recycling and sparse arrays
for component pools have been implemented, and adding components to an
entity has been tested.
2022-10-16 18:29:25 +09:00
Bill Currie
0c54b0652b Abandon support for clang
The inconsistencies in clang's handling of casts was bad enough, and its
silliness with certain extensions, but discovering that it doesn't
support raw strings was just too much. Yes, it gives a 3s boost to qfvis
on gmsp3v2.bsp, but it's not worth the hassle.
2022-10-16 18:02:25 +09:00
Bill Currie
31dd419fde [util] Reject non-shortest encoded utf-8 sequences
While chatting about utf-8, I noticed that QF doesn't ensure the input
sequences are the shortest possible encodings. It turns out that the
check is easy in that only the second byte needs to be checked if the
first byte's data bits are 0, and the second byte must have a data value
larger than that representable by the next lower leading byte.
2022-10-15 22:54:24 +09:00
Bill Currie
8868a5facf [renderer] Clean up a weird default case
I don't know why I used the void 0 instead of a break when clang
complained (probably rightly) about the default case hitting the end of
the switch.
2022-10-15 14:46:49 +09:00
Bill Currie
87dd4ee33d [gamecode] Remove some rather strange code
As indicated, I have no idea why the code was like that, but removing it
seems to have no effect as it seems to copy the data in the wrong
direction.
2022-10-15 14:44:54 +09:00
Bill Currie
2c9da25e17 Clean up some FIXMEs and XXXs
They seemed to be generally unnecessary. Also fixes some typos in
related comments.
2022-10-15 14:40:29 +09:00
Bill Currie
2c59a400e4 [vulkan] Ensure memory size is aligned
While the base of a memory object was aligned when calculating the
memory block size, the top end was not, which could result in the memory
block not getting enough bytes allocated to satisfy alignment
requirements (eg, for flushing).

While fixing that, I noticed the offsets of objects were not being
aligned when binding, so that is fixed as well.

Fixes Mr Fixit on my VersaPro.
2022-10-14 19:36:21 +09:00
Bill Currie
8464d71264 [scene] Move hierarchies to an ECS-based system
This is the beginning of adding ECS to QF. While the previous iteration
of hierarchies was a start in the direction towards ECS, this pulls most
of the 3d-specific transform stuff out of the hierarchy "objects",
making all the matrices and vectors/quaternions actual components (in
the ECS sense). There's more work to be done with respect to the
transform and entity members of hierarchy_t (entity should probably go
away entirely, and transform should become hierref_t (or whatever its
final name becomes), but I wanted to get things working sooner than
later.

The motivation for the effort was to allow views to use hierarchy_t,
which should be possible once I get entity and transform sorted out.

I am really glad I already had automated tests for hierarchies, as
things proved to be a little tricky to get working due to forgetting why
certain things were there.
2022-10-10 02:00:33 +09:00
Bill Currie
8120adb455 [renderer] Reduce glyph pixel area padding from 2x to 1.2x
With the improved atlas allocation, 2x is no longer needed and 1.2x
seems to be sufficient. Most importantly, it reduced the texture for
amiri-regular.ttf at 72 pix height from 8x to 4x (the staging buffer
isn't big enough for 8k textures).
2022-10-07 16:58:04 +09:00
Bill Currie
4feffd2de5 [vulkan] Support multiple loaded fonts
Currently, only 16 fonts can be loaded (I need to sort out descriptor
set pools), but glyphs are grouped into batches of the same font. While
not quite optimal as it can result in bouncing between descriptor sets a
lot, it's still reasonably efficient.
2022-10-07 16:53:13 +09:00
Bill Currie
f477f2b96e [vullkan] Rework Draw implementation
Line rendering now has its own pipeline (removing the texture issue).

Glyph rendering (for fonts) has been reworked to use instanced quad
rendering, with the geometry (position and texture coords) in a static
buffer (uniform texture buffer), and each instance has a glyph index,
color, and 2d base position.

Multiple fonts can be loaded, but aren't used yet: still just the one
(work needs to be done on the queues to support multiple
textures/fonts).

Quads haven't changed much, but buffer creation and destruction has been
cleaned up to use the resource functions.
2022-10-03 10:29:49 +09:00
Bill Currie
c9e7810864 [vulkan] Add resource memory offset to qfv_resobj_s
Its value on input is ignored. QFV_CreateResource writes the resource
object's offset relative to the beginning of the shared memory block.
Needed for the Draw overhaul.
2022-10-03 09:14:29 +09:00
Bill Currie
c028e15943 [vulkan] Add a couple of staging helper functions
I got tired of writing the same 13 or so lines of code over and over (it
actually put me off experimenting with Vulkan). Thus...

QFV_PacketCopyBuffer does the work of handling barriers and a (full
packet) copy from the staging buffer to a GPU buffer.

QFV_PacketCopyImage does a similar job, but for images. However, it
still needs a lot of work, but it does make getting a basic texture onto
the GPU much less of a hassle.

Both functions should make staging data much less error-prone.
2022-10-03 09:09:34 +09:00
Bill Currie
51b73eee73 [renderer] Add fontid to Draw_AddFont and Draw_FontString
It's not used yet, but the vulkan draw implementation will eventually
support multiple fonts being loaded (and rendered at a time).
2022-10-03 09:01:54 +09:00
Bill Currie
0352af4542 [vulkan] Initialize resource image from tex_t
This moves the qfv_resobj_t image initialization code from the IQM
loader into the resource management code. This will allow me to reuse
the code for setting up glyph data. As a bonus, it cleans up the IQM
code nicely.
2022-10-02 20:45:20 +09:00
Bill Currie
ac8d71733e [vulkan] Clean up QFV_duSetObjectName usage a little
Moving the param calculations into QFV_duSetObjectName params prevents
warnings when debug is disabled without having to use (void) hacks.
2022-10-02 15:07:04 +09:00
Bill Currie
9798400cfb [ui] Add a sub-system for parsing text passages
A passage object has a list of all the text objects in the given string,
where the objects represent either white space or "words", as well as a
view_t object representing the entire passage, with paragraphs split
into child views of the passage view, and each paragraph has a child
view for every text/space object in the paragraph.

Paragraphs are split by '\n' (not included in any object).

White space is grouped into clumps such that multiple adjacent spaces
form a single object. The standard ASCII space (0x20) and all of the
Unicode characters marked "WS;<compat> 0020" are counted as white space.
Unless a white space object is the first in the paragraph, its view is
marked for suppression by the view flow code.

Contiguous non-white space characters are grouped into single objects,
and their views are not suppressed.

All text object views (both white space and "word") have their data
pointer set to the psg_text_t object representing the text for that
view. This should be suitable for simple text-mode unattributed display.
More advanced rendering would probably want to create suitable objects
and set the view data pointers to those objects.

No assumption is made about text direction.

Passage and paragraph views need to have their primary axis sizes set
appropriately, as well as their resize flags. Their xlen and ylen are
both set to 10, and xpos,ypos is 0,0. Paragraph views need their
setgeometry pointer set to the appropriate view_flow_* function.
However, they are set up to have their secondary axis set automatically
when flowed.

Text object views are set up for automatic flowing: grav_flow, 0,0 for
xpos,ypos. However, xlen and ylen are also both 0, so need to be set by
the renderer before attempting to flow the text.
2022-09-30 19:51:14 +09:00
Bill Currie
a24fb0ff6a [ui] Add option to auto-fit container to flowed views
Adjusting the size of the parent (container) view to the views it
contains will be useful for automatic layout and knowing how large the
view is for scrolling. New tests added so testing both with and without
the option is still possible.
2022-09-30 11:59:21 +09:00
Bill Currie
378584f41d [ui] Add functions for flow-based automatic layout
This should be suitable for laying out text objects with word-wrap,
where each view is a "word" or break between "words". This should be
useful for any other objects that could benefit from similar layout
rules. All eight flows are supported left-right-top-down (English and
most European languages), right-left-top-down (Arabic and similar),
top-down-right-left (Chinese, Japanese, Korean), top-down-left-right,
as well as bottom-up variants of those four.

More work is needed for support of things like views being centered on
the flow line rather than on one edge (depends on flow direction),
offset views, and others. Suppression of "spaces" at the beginning of a
line is supported but not tested.
2022-09-29 23:54:12 +09:00
Bill Currie
c0e3821fa6 [gl/glsl] Shift the 2d view by 0.5 pixels in X and Y
Fixes top and left edge lines not being visible (same story as vulkan).
2022-09-28 22:50:44 +09:00
Bill Currie
2d634b7cf7 [vulkan] Shift the 2d view by 0.5 pixels in X and Y
Lines drawn along the top and left edges were not displayed because
they were just off screen.
2022-09-28 22:24:22 +09:00
Bill Currie
ba9a071b1c [console] Fix console sliding and resize
Due to the changes related to console views, the console was either
fully visible or not at all visible, so it took several seconds to
disappear whenever closed.

Taking the screen data from the event fixes the console size being out
due to screen_view updating after the app_window event fires. Really,
this makes it independent of the order.
2022-09-28 21:57:10 +09:00
Bill Currie
60e712f224 [vulkan] Use the right uvs for lines
UVs being 0 meant that lines were picking up the upper left pixel of
char 0 of conchars. With quake data, this meant a transparent pixel.
Fixes invisible debug lines :P.
2022-09-28 21:53:22 +09:00
Bill Currie
49acf7035d [vulkaan] Fix incorrect conback drawing
Putting the console background image in the scrap needed different
calculations for the sliding console, but I rather messed things up.
2022-09-28 18:29:53 +09:00
Bill Currie
df6f51b891 [glsl] Fix some mangled whitespace 2022-09-28 18:29:13 +09:00
Bill Currie
10f85edb21 [vulkan] Calculate the size of the capture buffer
It turns out that using the swapchain image for the size requirements is
unreliable: when running under renderdoc, vkGetImageMemoryRequirements
sets the memory requirements fields to 0, leading eventually to a null
memory object being passed to vkMapMemory, which does not end well.
2022-09-28 02:46:09 +09:00
Bill Currie
71e07e6454 [vulkan] Use vkCmdCopyImageToBuffer for screenshot capture
I had missed that vkCmdCopyImage requires the source and destination
images to have exactly the same size, and I guess assumed that the
swapchain images would always be the size they said they were, but this
is not the case for tiled-optimal images. However,
vkCmdCopyImageToBuffer does the right thing regardless of the source
image size.

This fixes the skewed screenshots when the window size is not a multiple
of 8 (for me, might differ for others).
2022-09-26 15:54:20 +09:00
Bill Currie
950d6d1472 [vulkan] Name the default magenta array view
It hasn't caused any problems, but the more objects I can name, the
better.
2022-09-26 13:08:02 +09:00
Bill Currie
1d50940c2a [vulkan] Implement window resize support
There's a problem with screenshot capture in that the image is sheared
after window resize, but the screen view looks good, and vulkan is happy
with the state changes.
2022-09-26 13:04:56 +09:00
Bill Currie
22276ad356 [vulkan] Remove double destroy of the old swapchain
I had forgotten that QFV_CreateSwapchain destroys the old swapchain when
I wrote Vulkan_CreateSwapchain.
2022-09-26 11:49:11 +09:00
Bill Currie
d5586730a4 [vulkan] Remove redundant pipeline dynamic setting
As gbuf_base derives from the base pipeline, it inherits base's dynamic
setting, and thus doesn't need its own. I had a FIXME there as I wasn't
sure why I had a redundant setting, but I really can't see why I'd want
it different from any of the other main renderpass pipelines.
2022-09-26 10:07:12 +09:00
Bill Currie
0ecdd0e86b [vulkan] Rearrange init code in preparation for resizing
I've found and mostly isolated the parts of the code that will be
affected by window resizing, minus pipelines but they use dynamic
viewport and scissor settings and thus shouldn't be affected so long as
the swapchain format doesn't change (how does that happen?)
2022-09-26 09:52:14 +09:00
Bill Currie
9e440ff330 [renderer] Use designated inits on more structs
Finally, the model_funcs and render_funcs struts use designated
initializers. Not only are they good for ensuring correct
initialization, they're great for the programmer finding the right
initializer.
2022-09-25 10:37:07 +09:00
Bill Currie
5e154bf1b7 [cvar] Remove reliance on line number for developer parsing
I must have forgotten about the SYS_DeveloperID_... enum values, when I
wrote that code, because relying on the line number is not really for
the best.
2022-09-24 18:26:25 +09:00
Bill Currie
c580fb9ec7 [console] Add a comment about console resizing
Due to design issues in the console API that I don't feel like
addressing at this stage, the console view is not a child of the
client's screen view (not even sure it should be in the first place), so
it won't get resized automatically when the client's screen view
resizes. However, ie_app_window is sent when the screen size changes,
and the console has to process input events anyway, so it's quite
reasonable to handle the event.
2022-09-22 16:18:53 +09:00
Bill Currie
7e03f23146 [renderer] Link plugins against external libraries
With the addition of dependencies on freetype and harfbuzz, it became
clear that the renderer plugins need to be explicitly linked against
external dependencies (and that I need to do more installed testing,
rather than just my static local builds). This fixes the unresolved
symbols when attempting to load any of the plugins.
2022-09-22 15:10:10 +09:00
Bill Currie
7c09f86d8d [models] Include fullbright in vulkan lib
I'm not sure why the other renderers are ok with Mod_CalcFullbright, but
the vulkan plugin couldn't find it.
2022-09-22 13:04:26 +09:00
Bill Currie
d1f6945747 [renderer] Avoid gl/glsl segfault when resizing qwaq
qwaq doesn't supply a backtile pic, so Draw_TileClear in the gl and glsl
renderers would segfault when qwaq's window width changed due to some
back-tile being drawn.
2022-09-22 10:39:03 +09:00
Bill Currie
d7be237af9 [vulkan] Fix a merge dropping that missed a conview change 2022-09-22 10:38:26 +09:00
Bill Currie
20ee47404f Merge branch 'master' into wip-twod 2022-09-22 10:06:00 +09:00
Bill Currie
41a6ea3534 [gamecode] Use adjusted vector string for sscanf
There's not much point in converting commas to spaces if the result
isn't used. Fixes several malformed vector errors in ad_tears.
2022-09-22 09:38:39 +09:00
Bill Currie
784af2bab2 [vulkan] Enable the multiview feature
As of a recent nvidia driver update, it became necessary to enable the
feature. I guess older drivers (or vulkan validation layers?) were a bit
slack in their checking (or perhaps I didn't actually get those lighting
changes working at the time despite having committed them).
2022-09-22 09:38:39 +09:00
Bill Currie
4b38d75f2c [input] Initialize the axis/button callback fields
Found these while trying to use the new code in my KSP addon.
2022-09-22 09:35:57 +09:00
Bill Currie
aafb3c1d98 [vulkan] Partially document bsp rendering
This did involve changing some field names and a little bit of cleanup,
but I've got a better handle on what's going on (I think I was in one of
those coding trances where I quickly forget how things work).
2022-09-22 09:35:57 +09:00
Bill Currie
ed209c3aa4 [util] Add a comment to darray test
Linux libc has its own "remove" (POSIX, even).
2022-09-22 09:35:57 +09:00
Bill Currie
2a47a61bc3 [util] Add atomic ring buffer and automated tests
Just head and tail are atomic, but it seems to work nicely (at least on
intel). I actually had more trouble with gcc (due to accidentally
testing lock-free with the wrong ring buffer... oops, but yup, gcc will
happily optimize your loop to spin really really fast). Also served as a
nice test for C11 threading.
2022-09-22 09:35:57 +09:00
Bill Currie
be4978dc16 [vulkan] Update staging test for properties2 2022-09-22 09:35:57 +09:00
Bill Currie
035595dd7e [vulkan] Clean up bsp global access
This makes bsp traversal even more re-entrant (needed for shadows).
Everything needed for a "pass" is taken from bsp_pass_t (or indirectly
through bspctx_t (though that too might need some revising)).
2022-09-22 09:35:57 +09:00
Bill Currie
b8070e0141 [vulkan] Check for ambient lights
Ambient lights are represented by a point at infinity and a zero
direction vector (spherical lights have a non-zero direction vector but
the cone angle is 360 degrees). This fixes what appeared to be mangled
light renderers (it was actually just an ambient light being treated as
a directional light (point at infinity, but non-zero direction vector).
2022-09-22 09:35:57 +09:00
Bill Currie
8e7474f614 [vulkan] Hook up the shadow map render pass
There are some issues with the light renderers getting mangled, and only
the first light is even touched (just begin and end of render pass), but
this gets a lot of the framework into place.
2022-09-22 09:35:57 +09:00
Bill Currie
c58a2e5f54 [vulkan] Remove unused command buffer and fence 2022-09-22 09:35:57 +09:00
Bill Currie
71813af090 [vulkan] Support creating render passes with no render pass
Sounds odd, but it's part of the problem with calling two different
things with essentially the same name. The "high level" render pass in
question may be a compute pass, or a complex series of (Vulkan) render
passes and so won't create a Vulkan render pass for the "high level"
render pass (I do need to come up with a better name for it).
2022-09-22 09:35:57 +09:00
Bill Currie
3058a5103f [renderer] Move entity drawing in with view rendering
I really don't remember why I made it separate, though it may have been
to do with r_ent_queue. However, putting it together with the rest is
needed for the "render pass" rework.
2022-09-22 09:35:57 +09:00
Bill Currie
5e1ce5b46e [vulkan] Move main render pass setup to Vulkan_Main
And support sorting of render passes by an order index.
2022-09-22 09:35:57 +09:00
Bill Currie
e45867d335 [vulkan] Fix some segfaults for render passes with no framebuffer specs 2022-09-22 09:35:57 +09:00
Bill Currie
3b72c9847a [vulkan] Add list of views to qfv_output_t
I'm not sure I like it, but it was an easy solution to dealing with
per-frame views when setting up a renderpass that has a framebuffer
spec.
2022-09-22 09:35:57 +09:00
Bill Currie
e1c4428c8e [vulkan] Set source item for cexpr errors
It's always nice getting at least line numbers from an error message
(even if I still have to hunt for the right source "file").
2022-09-22 09:35:56 +09:00
Bill Currie
3603fa75cd [vulkan] Make Vulkan_CreateRenderPass more generally useful
It now lives in vulkan_renderpass.c and takes most of its parameters
from plist configs (just the name (which is used to find the config),
output spec, and draw function from C). Even the debug colors and names
are taken from the config.
2022-09-22 09:35:56 +09:00
Bill Currie
e14e8050dc [vulkan] Remove vkparse.hinc from vkparse.h
Kind of silly having the vkparse_internal define when it was just
bypassed anyway.
2022-09-22 09:35:56 +09:00
Bill Currie
08f33d2f3a [vulkan] Rename the renderpass files
I plan on moving the current hard-coded render pass creation from
vulkan_vid_common and this maintains the (possibly silly) naming
convention).
2022-09-22 09:35:56 +09:00
Bill Currie
6a7c2cb2a1 [vulkan] Clean out the old render pass creation code
QFV_CreateRenderPass is no longer used, and QFV_CreateFramebuffer hasn't
been used for a long time. The C file is still there for now but is
basically empty.
2022-09-22 09:35:56 +09:00
Bill Currie
78437c2c90 [vulkan] Parse VkRenderPass directly
QFV_CreateRenderPass doesn't support pNext and I don't particularly feel
like making it do so at this stage (tempted to remove it).
2022-09-22 09:35:56 +09:00
Bill Currie
f04108ae3e [vulkan] Switch to using vkGetPhysicalDeviceProperties2
Necessary for getting VkPhysicalDeviceMultiviewProperties (and others,
but not at this time).
2022-09-22 09:35:56 +09:00
Bill Currie
e5932d1f92 [vulkan] Support Vulkan's pNext in vkparse/vkgen
The real reason for the delay in implementing support for pNext is I
didn't know how to approach it at the time, but with the experience I've
gained using and modifying vkparse, the solution turned out to be fairly
simple. This allows for the use of various extensions (eg, multiview,
which was used for testing, though none of the hookup is in this
commit). No checking is done on the struct type being valid other than
it must be of a chainable type (ie, have its own pNext).
2022-09-22 09:35:56 +09:00
Bill Currie
125821fcdd [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-09-22 09:35:56 +09:00
Bill Currie
2e14300a11 [client] Auto-detect light color range
Some mappers use 0-255 and others use 0-1. Detection method adapted from
ericw light (seems to be a good bet as it seems to be popular).
2022-09-22 09:35:44 +09:00
Bill Currie
c6d73eaf64 [vulkan] Add light count display
Enabled by 'developer lighting'. It was good for confirming that the
lights in ad_e1m1 (Doom Hangar 16) were actually being output (over 600
of them sometimes, ouch). Turned out to be the color scale ambiguity.
2022-09-22 09:31:04 +09:00
Bill Currie
fb4bb22048 [client] Add cl_(min|max)(pitch|roll) cvars
The pitch cvars are taken from quakespasm because I ran into a button I
couldn't shoot with the 80 degree limit, but I figured I'd add roll
limits while I was at it.
2022-09-22 09:31:04 +09:00
Bill Currie
3603f90718 [vulkan] Implement BSP surface transparency
Surfaces marked with SURF_DRAWALPHA but not SURF_DRAWTURB are put in a
separate queue for the water shader and run with a turb scale of 0.
Also, entities with colormod alpha < 1 are marked to go in the same
queue as SURF_DRAWALPHA surfaces (ie, no SURF_DRAWTURB unless the
model's texture indicated such).
2022-09-22 09:31:04 +09:00
Bill Currie
a936336e84 [model] Support the transparent texture marker
Textures whose names start with a { are meant to be rendered with
transparency. Surfaces using those textures are marked with
SURF_DRAWALPHA.

Unfortunately, the mip levels of ad_tears' transparent textures use the
wrong color so only the highest LOD works properly, but those textures
are meant to be loaded from external files anyway, it seems.
2022-09-22 09:31:04 +09:00
Bill Currie
3a03cc9fda [sw] Use vid instead of dev for a debug print 2022-09-22 01:49:18 +09:00
Bill Currie
f758f5fb70 [renderer] Respond to window size changes
Currently, only gl, glsl and sw are working, vulkan needs its swapchain
to be rebuilt, and there are minor issues with the hud and console
resizing.
2022-09-22 01:15:06 +09:00
Bill Currie
ef8b267826 [x11] Allow the window to be resized
There's no maximum size, but the minimum size is currently 32x20.
2022-09-22 01:09:27 +09:00
Bill Currie
d149457241 [vid] Add a listener for window size changes
A listener is used instead of (really, as well as) ie_app_window events
because systems that need to know about windows sizes may not have
anything to do with input and the event system.
2022-09-22 01:07:54 +09:00
Bill Currie
fdfdf9056a [renderer] Add function to destroy frame buffers
Needed for window resizing for fisheye and warp buffers (main buffers
will be taken care of by the drivers).
2022-09-21 23:47:14 +09:00
Bill Currie
4578b1af0d [vid] Remove console view from viddef_t
This breaks console scaling for now (con_width and con_height are gone),
but is a major step towards window resize support as console stuff
should never have been in viddef_t in the first place.

The client screen init code now sets up a screen view (actually the
renderer's scr_view) that is passed to the client console so it can know
the size of the screen. The same view is used by the status bar code.

Also, the ram/cache/paused icon drawing is moved into the client screen
update code. A bit of duplication, but I do plan on merging that
eventually.
2022-09-21 17:31:18 +09:00
Bill Currie
2473584759 [vid] Clean out an unused variable from context_win
It's dead, Jim.
2022-09-21 12:37:55 +09:00
Bill Currie
0921235aa6 [console] Fix a lot of the console view placement issues
Things seem to be at least close to the right place now.

Input line handling has been made more object-oriented in that the
collection of objects required for a single input line (command, say,
say_team) are bundled into one object with just one set of handlers for
resize and draw. Much tidier.
2022-09-21 12:37:55 +09:00
Bill Currie
230e23db5d [console] Update a little for event handling
Con_CheckResize is no longer necessary thanks to the ie_app_window
event, and the client doesn't need C_ProcessInput so that is now
optional.
2022-09-21 12:13:06 +09:00
Bill Currie
8be5d35b0d [ui] Add support for setting view data early
view_new sets the geometry, but any setgeometry that need a valid data
pointer would get null. It might be better to always have the data
pointer, but I didn't feel like doing such a change at this stage as
there are quite a lot of calls to view_new. Thus view_new_data which
sets the data pointer before calling setgeometry.
2022-09-21 11:53:49 +09:00
Bill Currie
058e919273 [renderer] Use better heuristics for scrap allocation
More tuning is needed on the actual splits as it falls over when the
lower rect gets too low for the subrects being allocated. However, the
scrap allocator itself will prefer exact width/height fits with larger
cutoff over inexact cuts with smaller cutoff. Many thanks to tdb for the
suggestions.

Fixes the fps dropping from ~3700fps down to ~450fps (cumulative due to
loss of POT rounding and very poor splitting layout), with a bonus boost
to about 4900fps (all speeds at 800x450). The 2d sprites were mostly ok,
but the lightmaps forming a capital gamma shape in a 4k texture really
hurt. Now the lightmaps are a nice dense bar at the top of the texture,
and 2d sprites are pretty good (slight improvement coming next).
2022-09-20 19:32:49 +09:00
Bill Currie
1fdedbaf33 [renderer] Report scrap rectangle counts
Stats are good. More stats even better :) I wanted to see just how many
lightmaps were being created in e1m3.
2022-09-20 19:32:41 +09:00
Bill Currie
398405c8d6 [console] Remove old_console_t struct
This replaces old_console_t with con_buffer_t for managing scrollback,
and draw_charbuffer_t for actual character drawing, reducing the number
of calls into the renderer. There are numerous issues with placement and
sizing, but the basics are working nicely.
2022-09-20 16:14:55 +09:00
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