Commit graph

243 commits

Author SHA1 Message Date
Bill Currie
4cb120e878 [vulkan] Implement most of the changes for cube rendering
There are some missing parts from this commit as these are the fairly
clean changes. Missing is building a separate set of pipelines for the
new render pass (might be able to get away from that), OIT heads texture
is flat rather than an array, view matrices aren't set up, and the
fisheye renderer isn't hooked up to the output pass (code exists but is
messy). However, with the missing parts included, testing shows things
mostly working: the cube map is rendered correctly even though it's not
displayed correctly (incorrect view). This has definitely proven to be a
good test for Vulkan's multiview feature (very nice).
2023-02-14 13:24:47 +09:00
Bill Currie
0cf341d1cb [vulkan] Remove brush entity frustum culling
It doesn't gain all that much and gets in the way of efficient
cube-mapping.
2023-02-14 13:24:47 +09:00
Bill Currie
25ac0ff303 [vulkan] Adapt the shaders for multi-view
Multi-view will be used for shadows and fisheye.
2023-02-14 13:24:47 +09:00
Bill Currie
ae0b781818 [vulkan] Implement water warp
The separated output pass made the implementation very easy, as did
having most of the parts already in place.
2023-01-19 23:05:06 +09:00
Bill Currie
4e1ddaa964 [renderer] Add fitted pic rendering
The pic is scaled to fill the specified rect (then clipped to the
screen (effectively)). Done just for the console background for now, but
it will be used for slice-pics as well.

Not implemented for vulkan yet as I'm still thinking about the
descriptor management needed for the instanced rendering.

Making the conback rendering conditional gave an approximately 3% speed
boost to glsl with the GL stub (~12200fps to ~12550fps), for either
conback render method.
2023-01-17 11:33:47 +09:00
Bill Currie
c8afad4d3d [vulkan] Make QFV_PacketCopyBuffer take destination offset
It's useful being able to update a subregion of a buffer (needed for the
quad drawing changes).
2023-01-11 11:34:22 +09:00
Bill Currie
b310ece7bd [vulkan] Clean up draw a little bit
It's just removing some functions that will never be implemented, and an
unnecessary field.
2023-01-09 13:31:53 +09:00
Bill Currie
5668006087 [renderer] Replace Draw_FontString with Draw_Glyph
While Draw_Glyph does draw only one glyph at a time, it doesn't shape
the text every time, so is a major win for performance (especially
coupled with pre-shaped text).
2022-12-10 18:55:08 +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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
20ee47404f Merge branch 'master' into wip-twod 2022-09-22 10:06:00 +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
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
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
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
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
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
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
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
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