Commit graph

5892 commits

Author SHA1 Message Date
Bill Currie
f2d2db9ef3 [vulkan] Integrate screen capture in the new system
This gets screenshots working again. As the implementation is now a
(trivial) state machine, the pause when grabbing a screenshot is
significantly reduced (it can be reduced even further by doing the png
compression in a separate thread).
2023-06-25 23:41:21 +09:00
Bill Currie
eb176c37e2 [vulkan] Get brush models rendering again
The new system seems to work quite nicely with brush models, which was
the intent, but it's nice to see. Hopefully, it works well when it comes
to shadows. There's still water warp and screen shots to fix, and
fisheye to get working, as well.
2023-06-25 00:22:03 +09:00
Bill Currie
65a63e7423 [vulkan] Fix a silly typo
Sprites seem to be rather slow to draw, so "sprint" makes even less
sense.
2023-06-25 00:20:19 +09:00
Bill Currie
b9bb841744 [vulkan] Use the descriptor set manager
This cleans up a lot of ugly code that I always thought was rather dumb.
2023-06-24 21:42:46 +09:00
Bill Currie
6ce42fd347 [vulkan] Document the texture sets
I got tired of wondering what they were for.
2023-06-24 17:23:34 +09:00
Bill Currie
8470ae5a28 [vulkan] Create a descriptor set manager
The manager allows recycling of descriptor sets and takes care of
creating pools as needed.
2023-06-24 17:23:34 +09:00
Bill Currie
92368eafb2 [vulkan] Clean out old pipeline and layout refs
It's not perfect as some subsystems still create resources from the old
system (necessarily), but this cleans up a lot of the mess.
2023-06-24 11:53:00 +09:00
Bill Currie
5140346c22 [vulkan] Nuke the old render pass code from orbit
Gotta be sure :)

With the new system mostly up and running (just bsp rendering and
descriptor sets/layout handling to go, and they're independent of the
old render pass system), the old system can finally be cleared out.
2023-06-24 10:42:27 +09:00
Bill Currie
4abf316f6c [vulkan] Update curFrame at end of render job
This fixes the insta-death of particles. Interestingly, other than
particles (due to the ring of buffers not being used correctly),
everything else worked nicely, so I guess 1-frame rendering got tested.
2023-06-24 03:32:21 +09:00
Bill Currie
41d69586d2 [vulkan] Get particles mostly working in the new system
The particles die instantly due to curFrame not updating (next commit),
but otherwise work nicely, especially sync is better (many thanks to
Darian for his help with understanding sync scope).
2023-06-24 03:26:22 +09:00
Bill Currie
87356a5211 [vulkan] Hook up sprite rendering in the new system
That one went smoothly for a change.
2023-06-23 20:37:06 +09:00
Bill Currie
dbe00c3dfa [vulkan] Clear the entity queues
bsp_draw_queue isn't the right place, but it's just place-holder code to
help get the rest of the renderers up and running before I tackle bsp
rendering. Fixes the segfault in demo1 when the zombies get gibbed,
resulting in zombie entities.
2023-06-23 18:15:01 +09:00
Bill Currie
e4df35ac48 [vulkan] Move scr_funcs handling into vulkan_draw
This was necessary to get the 2d elements drawn after the fence had been
fired (thus indicating descriptors could be updated) but before actual
rendering of the 2d elements (which is how it was done before the switch
to the new system).
2023-06-23 18:07:40 +09:00
Bill Currie
6baab91863 [scene] Correct some mangled types
It was harmless because memory was being over allocated, but it did
cause a little confusion.
2023-06-23 17:58:44 +09:00
Bill Currie
0ec2aa2bf7 [vulkan] Get iqm rendering working again
It turns out there was a bug in the old iqm push constants spec (I still
need to figure out how to use layouts in the new system so I can
completely delete the old).
2023-06-23 09:38:41 +09:00
Bill Currie
54712be41b [vulkan] Enable alpha blend for the compose step
Now the text looks good when over the player model.
2023-06-23 02:30:58 +09:00
Bill Currie
a2a237b854 [vulkan] Correct depth and winding issues
Quake data needs clockwise winding, and both min and max depth of 0
makes for some very strange results.
2023-06-23 02:30:58 +09:00
Bill Currie
a186df90f3 [vulkan] Connect the main and output render steps
The output system's update_input takes a parameter specifying the render
step from which it is to get the output view of that step and updates
its descriptors as necessary.

With this, the full render job is working for alias models (minus a few
glitches).
2023-06-23 02:30:58 +09:00
Bill Currie
7eb14b0a32 [vulkan] Get the compose subpass working
That seems to be the main render pass working. Next is to get the output
render pass to use the main render pass's output.
2023-06-23 02:30:58 +09:00
Bill Currie
942b503486 [vulkan] Get lighting mostly working
Lights seem to be good in renderdoc, but still need to get the compose
subpass working.
2023-06-23 02:30:58 +09:00
Bill Currie
2122d923d9 [vulkan] Move the subpass command labels out a layer
Just for easier debugging in renderdoc.
2023-06-23 02:30:58 +09:00
Bill Currie
d2e85f775d [vulkan] Get alias model rendering mostly working
Mostly because no lighting or compositing to the output buffer is done,
but the model is there in renderdoc's image viewer.
2023-06-23 02:30:58 +09:00
Bill Currie
854b612597 [vulkan] Name the managed command buffer pool
Not that it mattered in the end, but it helps with debugging (found the
bug while doing the edits).
2023-06-22 20:06:46 +09:00
Bill Currie
836290aa74 [vulkan] Update the active command buffer indices
When creating a new command buffer and appending it to a queue, the
active buffer count needs to be incremented too otherwise the new
command buffer will be accidentally reused prematurely. Not noticed
earlier because only one buffer was being created.
2023-06-22 20:05:52 +09:00
Bill Currie
3c9bd77346 [vulkan] Port line rendering to the new system
I'd already done the programming side when doing slice rendering, but
hadn't hooked up line rendering in the render spec.
2023-06-22 20:05:52 +09:00
Bill Currie
12f1b31701 [vulkan] Use a command buffer pool manager
Many thanks to Peter and Darian for clearing up my misunderstanding of
how vkResetCommandPool works. The manager creates command buffers from
the command pool on an as-needed basis (when the queue of available
buffers is empty), and keeps track of those buffers in a queue. When the
pool is reset, the queues (one each for primary and secondary command
buffers) are reset such that the tracked buffers are available again.
2023-06-22 20:05:36 +09:00
Bill Currie
bba82d3da1 [vulkan] Move frames from vulkan_ctx to renderctx
Part of the command buffer fix, but also a step towards cleaning up
vulkan_ctx.
2023-06-22 16:47:15 +09:00
Bill Currie
6deeed1829 [vulkan] Get the output step working for draw
It leaks command buffers (due to a misunderstanding of
vkResetCommandPool), but it seems 2d draw (sliced quads) is working
nicely.
2023-06-22 11:17:03 +09:00
Bill Currie
3de39f5408 [vulkan] Destroy frame buffers on shutdown
With this, the new render system, though not doing anything useful, at
least passes validation.
2023-06-22 11:17:03 +09:00
Bill Currie
25cfef18d6 [vulkan] Use per-swapchain images for output framebuffers
Imageless framebuffers would probably be easier and cleaner, but this
takes care of the validation error attempting to present the second
frame (because rendering was being done to the first frame's swapchain
image instead of the second frame's).
2023-06-21 14:47:19 +09:00
Bill Currie
503013dd38 [vulkan] Use per-frame command buffer pools
Command buffer pools can't be reset until the commands have all been
executed. Having per-frame pools makes keeping track of pool lifetime
fairly easy.
2023-06-21 13:46:29 +09:00
Bill Currie
f0d32ba956 [vulkan] Rearrange allocations for alignment
Interleaving Vulkan objects with stucts containing vec4f_t results in
the vectors becoming unaligned when there is an odd number of objects in
a set, thus producing a segfault. Putting all the structs first prevents
any such issue.
2023-06-21 13:43:04 +09:00
Bill Currie
7da8399220 [vulkan] Pass validation for the first frame
The new render system now passes validation for the first frame (but
no drawing is done by the various subsystems yet). Something is wrong
with how swap chain semaphores are handled thus the second frame fails.

Frame buffer attachments can now be defined externally, with
"$swapchain" supported for now (in which case, the swap chain defines
the size of the frame buffer).

Also, render pass render areas and pipeline viewport and scissor rects
are updated when necessary.
2023-06-20 15:18:58 +09:00
Bill Currie
38453f3d2f [vulkan] Increment render pass index one at a time
This fixes the bogus render pass objects.
2023-06-18 19:58:10 +09:00
Bill Currie
2cadf040d3 [vulkan] Add a step and task to create a framebuffer
I don't like the current name (update_framebuffer), but if the
referenced render pass doesn't have a framebuffer, one is created. The
renderpass is referenced via the active renderpass of the named render
step. Unfortunately, this has uncovered a bug in the setup of renderpass
objects: main.deferred has output's renderpass, and main.deferred_cube
and output have bogus renderpass objects.
2023-06-18 18:42:07 +09:00
Bill Currie
8e25fb13d1 [cexpr] Add string and voidptr types
The string type is useful for passing around strings (the only thing
that they can do, currently), particularly as arguments to functions.
The voidptr type is (currently) never generated by the core cexpr
system, but is useful for storing pointers via cexpr (probably a bit of
a hack, but it seems to work well in my current use).
2023-06-18 17:20:38 +09:00
Bill Currie
3235bb70c8 [vulkan] Move attachement specs into frambuffer
This does a better job of keeping related data together.
2023-06-17 12:13:38 +09:00
Bill Currie
14b24e5b75 [vulkan] Clean up job allocation size calculation
It does the same thing, but it's just nicer to read (thanks for the
idea, HomelikeBrick42).
2023-06-16 23:15:31 +09:00
Bill Currie
b33a897ae4 [vulkan] Submit particle physics push constants directly
Trying to do it in the task system meant copying pointers in a larger
buffer, which rarely ends well.
2023-06-16 22:37:27 +09:00
Bill Currie
274e821c06 [vulkan] Pass the current command buffer to tasks
Compute and render tasks need to be able to submit commands.
2023-06-16 22:34:08 +09:00
Bill Currie
b0d1c0e75b [vulkan] Make push constant ranges structured
Being able to specify the types in the push constant ranges makes it a
lot easier to get the specification correct. I never did like having to
do the offsets and sizes by hand as it was quite error prone. Right now,
float, int, uint, vec3, vec4 and mat4 are supported, and adheres to
layout std430.
2023-06-16 19:05:53 +09:00
Bill Currie
c1b85a3db7 [vkgen] Support custom parsing in multi-type fields
This allows the likes of:

    qfv_pushconstantrangeinfo_s = {
	.name = qfv_pushconstantrangeinfo_t;
	.type = (QFDictionary);
	.dictionary = {
	    .parse = {
		type = (labeledarray, qfv_pushconstantinfo_t, name);
		size = num_pushconstants;
		values = pushconstants;
	    };
	    stageFlags = $name.auto;
	};
	stageFlags = auto;
    };

Leading to:

    pushConstants = {
	vertex   = { Model = mat4; blend = float; };
	fragment = { colors = uint; base_color = vec4; fog = vec4; };
    };

Where the label of the labeled array (which pushConstants is) is
actually an enum flag and the dictionary value is another labeled array.
2023-06-16 18:53:37 +09:00
Bill Currie
bcfb2ad182 [vkgen] Shorten "qfv_*" enum names
The up-coming changes to push constant handling has qfv_float etc type
enum values and using "float" instead of "qfv_float" is highly desirable
as the names match the glsl type names.
2023-06-16 18:49:58 +09:00
Bill Currie
57da924c1b [plist] Put quotes around the unknown field name
I got rather confused by "unknown field type" when "type" was the field
name.
2023-06-16 18:47:24 +09:00
Bill Currie
387051fedf [vulkan] Split up render job loading and running
The creation of the render jobs doesn't really belong with the running
of those jobs. This makes the code a little easier to navigate as it was
too easy to lost between load-time and run-time code.
2023-06-15 17:29:41 +09:00
Bill Currie
3c65f1494b [vulkan] Get some subsystems passing validation
This is with the new render job scheme. I very much doubt it actually
works (can't start testing until everything passes, and it's disabled
for the moment (define in vid_render_vulkan.c)), but it's helping iron
out what more is needed in the render system.
2023-06-15 15:17:39 +09:00
Bill Currie
97f9fd81d6 [vulkan] Switch around renderpass and subpass names
The old structs will go away eventually, and I'm tired of seeing that _
tail.
2023-06-15 13:13:52 +09:00
Bill Currie
9d1c07d2ac Fix a few strict aliasing warnings
gcc 13 got a little stricter on those (at least with gnu2x/c2x).
2023-06-13 18:13:54 +09:00
Bill Currie
db889e5e54 [util] Fix a local variable address warning
Despite mdfour claiming not to be fast, it tried to avoid passing a
pointer around via a global instead of parameters. Long obsolete and
iffy to boot.
2023-06-13 18:11:11 +09:00
Bill Currie
dbd3d6502a Nuke qboolean from orbit
I never liked it, but with C2x coming out, it's best to handle bools
properly. I haven't gone through all the uses of int as bool (I'll leave
that for fixing when I encounter them), but this gets QF working with
both c2x (really, gnu2x because of raw strings).
2023-06-13 18:06:11 +09:00