Commit graph

2309 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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