Commit graph

2492 commits

Author SHA1 Message Date
Bill Currie
4cf1c167bd [vulkan] Start work on a render job system
The jobs will become the core of the renderer, with each job step being
one of a render pass, compute pass, or processor (CPU-only) task. The
steps support dependencies, which will allow for threading the system in
the future.

Currently, just the structures, parse support, and prototype job
specification (render.plist) have been implemented. No conversion to
working data is done yet, and many things, in particular resources, will
need to be reworked, but this gets the basic design in.
2023-03-10 19:47:40 +09:00
Bill Currie
374ca602a7 [vkgen] Use designated init for fixed array data
It seems I hadn't used fixed arrays for a while as the size field (which
really should be count) had moved and its spot taken by a data pointer.
2023-03-09 15:32:52 +09:00
Bill Currie
faef61aab6 [vulkan] Ensure host-visible buffers are big enough to flush
Flushing memory requires nonCoherentAtomSize alignment, but this can
cause the flush range to go out of bounds of an improperly sized buffer.
However, only host-visible (and probably really only cached, but all
three covered) needs flushing, so no rounding up is done for
device-local memory.
2023-03-09 10:19:24 +09:00
Bill Currie
f12b3ea134 [vid] Allow render systems to unload late
This cleans up the tangled mess of attempting to unload the gl driver in
X11: for whatever reason, the display gets tied in to the library.
2023-03-06 21:15:15 +09:00
Bill Currie
5821ef8d1f [model] Reset mod_numknown when clearing models
Vulkan actually needs Mod_ClearAll, and mod_numknown not getting reset
was the actual cause of the segfault.
2023-03-06 21:04:00 +09:00
Bill Currie
488ccdc512 [glsl] Be more null-safe for free/destroy functions 2023-03-06 18:21:13 +09:00
Bill Currie
e079d95cb0 [vkgen] Add header guards to stdint.h
Recent vulkan headers have added at least one more include of stdint.h,
so need to protect against the double-inclusion.
2023-03-06 12:49:02 +09:00
Bill Currie
370c36f6cc [vulkan] Fix some memory leaks
And deal with a shutdown order issue causing cvars to crash on shutdown
(due to the hash links being freed too early).
2023-03-05 18:31:30 +09:00
Bill Currie
9ad4f57348 [glsl] Fix a pile of memory leaks
For the most part harmless, but fixing the leaks has been uncovering
bugs.
2023-03-05 18:31:30 +09:00
Bill Currie
795021e229 [util] Record allocated blocs for ALLOC
Recording the blocks makes it possible to free them later. As a
convenience, ALLOC_STATE declares the freelist and blocks vars needed by
ALLOC.
2023-03-05 18:31:30 +09:00
Bill Currie
c28ffbb766 [vkgen] Plug some memory leaks
Not that they really matter, but it makes checking valgrind easier.
2023-03-04 00:41:38 +09:00
Bill Currie
70aa970c32 [gamecode] Make modules responsible for freeing resources
It should have been this way all along, and it seems I thought they were
when I did rua_gui.c as it already freed its resource block, which would
have been a double free (oops). Fixes an invalid write when shutting
down progs in qwaq-cmd (relevant change not committed).
2023-03-03 20:26:00 +09:00
Bill Currie
d0a3040b26 [vulkan] Fix a missed pure attribute
I don't have a compile pre-push hook on my laptop.
2023-03-03 10:31:54 +09:00
Bill Currie
c0048c14b3 [vulkan] Fix a typo in a comment
Double "the"
2023-03-02 18:34:10 +09:00
Bill Currie
9d63d4901f [vulkan] Create a framebuffer for the first render pass
Currently just the one framebuffer is created, but I want to get things
running soon.
2023-03-02 18:33:16 +09:00
Bill Currie
3b9e0a786e [vkgen] Support renaming of auto fields 2023-02-27 18:44:21 +09:00
Bill Currie
9133c0ea3f [vulkan] Initialize most of render pass and subpass state
Render passes and subpasses are now mostly initialized, just command
buffers and frame buffer related info to go (including view/scissor for
pipelines).
2023-02-27 18:10:09 +09:00
Bill Currie
38c10f9c4f [vulkan] Support chained render pass infos
And thus the cube mapped render pass.
2023-02-27 15:02:48 +09:00
Bill Currie
fdcd972ff9 [vulkan] Use correct index for pl item setup
Due to a typo in the list of extra property list items to add to the
symbol table (corrected), subsequent symbols were pointing to the wrong
memory address.
2023-02-27 15:00:40 +09:00
Bill Currie
3700321c5d [vulkan] Clean up the render objects on shutdown
Not only does this quieten the validation layers, it ensures that all
the object handles are named and where they need to be. Also fixes only
one pipeline being created instead of the 15 or so.
2023-02-27 14:15:28 +09:00
Bill Currie
0dccce6c51 [vulkan] Create render passes and pipelines
There are many issues (in particular, shutdown doesn't clean up
properly), but creation passes validation.
2023-02-27 03:00:14 +09:00
Bill Currie
918237507e [vulkan] Support parsing pipeline layout info
This is for the new system.
2023-02-27 02:54:51 +09:00
Bill Currie
acf828baa3 [vulkan] Allow null extra items and symbols
Don't want to have to pass empty lists.
2023-02-27 02:53:03 +09:00
Bill Currie
b10c8dc1a1 [vulkan] Parse in descriptor set layouts
For now, just their create info is parsed, but they will be created on
demand. Most importantly, they are named for ease of use in pipeline
layouts.
2023-02-26 20:54:11 +09:00
Bill Currie
461bb9f434 [vkgen] Make labeled arrays independent of struct order
It turns out labeled arrays don't work if structs aren't declared in the
right order (no idea what that is, though) as the struct might not have
been processed when the labeled array field is initialized. Thus, do a
pro-processing pass to set up any parse data prior to writing the
tables.
2023-02-26 20:43:52 +09:00
Bill Currie
a907f78143 [vulkan] Create a function for symtab creation
Most importantly, this cleans up creation of self-referencing symbol
tables from property lists, but adds in C-defined symbols as well. While
QFV_ParseRenderInfo is currently the only the function that uses it, it
might be helpful in the future, especially as I clean up the other parse
support code.
2023-02-26 13:51:24 +09:00
Bill Currie
75e553ffa0 [vulkan] Try to create render passes and pipelines
The render passes seem to be created successfully, but pipelines fail
due to not having layout set, resulting in a segfault (bug in validation
layers?).
2023-02-21 11:23:02 +09:00
Bill Currie
f13bc4f4b1 [vkgen] Allow mixed dictionary .type parsing 2023-02-21 00:42:12 +09:00
Bill Currie
421467529f [vulkan] Create the render images and views
And tear them down again on shutdown. The images and views are in a
qfv_resource_t block, making their management much easier.
2023-02-19 13:13:01 +09:00
Bill Currie
1ef658a260 [vulkan] Add a function to config render output
It just moves the already existing code from vulkan_main.c.
2023-02-19 12:38:46 +09:00
Bill Currie
fc06547dd9 [vulkan] move qfv_output_t to render.h
The plan is qf_renderpass.h (and vulkan_renderpass.c) will eventually
disappear as they get absorbed by render.[ch].
2023-02-19 12:31:40 +09:00
Bill Currie
fd36147749 [vulkan] Complete resource image and image view
I don't remember why I kept the abbreviated configs for images and image
views, but it because such that I need to be able to specify them
completely. In addition, image views support external images.

The rest was just cleaning up after the changes to qfv_resobj_t.
2023-02-19 12:25:13 +09:00
Bill Currie
ed74a6420b [vulkan] Set a reasonable default for color blend
Vulkan requires color blend state is only for color attachments (ignored
otherwise), but it shouldn't be necessary to actually specify the blend
state and instead have it default to something reasonable.
Unfortunately, colorWriteMask affects the output even if blending is
disabled, so it must be initialized to something reasonable (r|g|b|a)
for when the default is used.
2023-02-18 17:22:06 +09:00
Bill Currie
868db37461 [vkgen] Improve .type parse spec handling
.dictionary can ask for standard parsing via a .parse key (value is
ignored currently).

Fields can use $auto to use standard parsing for that field.

If either is used, the plist field descriptors are written.
2023-02-18 17:16:31 +09:00
Bill Currie
422aaf4bc6 [vulkan] Register task functions for the pipelines
They're currently just stubs, but this gets the render info loading
working without any errors. The next step is to connect up pipelines and
create the image resources, then implementing the task functions will
have meaning.
2023-02-14 15:29:00 +09:00
Bill Currie
f78aab1cb5 [vulkan] Create a render context
This gets an empty (no tasks or pipelines connected) render context
initialized and available for other subsystems to register their task
functions. Nothing is using it yet, but the test parse of rp_main_def
fails gracefully (needs those tasks).
2023-02-14 15:26:06 +09:00
Bill Currie
91d9d0b251 [vulkan] Implement task parameter parsing
This should fill in the task function's parameters nicely. The parameter
count check is known to work.
2023-02-14 15:25:35 +09:00
Bill Currie
2c3b89f722 [vulkan] Implement task function parsing
This just sets up the memory block and cexpr descriptors for the
parameters, parameter parsing is separate (and next). The parameters are
aligned to their size.
2023-02-14 15:25:04 +09:00
Bill Currie
3fea31875c [vulkan] Get render pass inheritance working
Needed to add the render passes plitem to the cexr symbol table, too.
All that remains is to figure out how to deal with multiview (or really
@next) and get task parsing working.
2023-02-14 15:24:42 +09:00
Bill Currie
728807bd7a [vulkan] Use references for views and pipelines
I'm pretty sure I don't want to require views to be created and
pipelines to be parsed just to parse the render pass info.
2023-02-14 15:24:24 +09:00
Bill Currie
345aa8e094 [vkgen] Add support for directly scripted parsing
It's very early, but it does the job for what I needed (storing the
string item and line number).
2023-02-14 15:23:32 +09:00
Bill Currie
cd1b20dc22 [vulkan] Get render info parsing mostly working
Just frame buffer and pipeline info to clean up before worrying about
tasks.
2023-02-14 15:23:02 +09:00
Bill Currie
2287a3de3f [vulkan] Get render info parsing partially working
A bunch of missed struct members, incorrect parse types, and some logic
errors in the parse setup. Still not working due to problems with
vectors from plist string references and some other errors, but getting
there.
2023-02-14 15:22:35 +09:00
Bill Currie
7235fcb5b9 [vkgen] Support direct parsing of a single struct field
This is most useful when parsing a labeled array where the key/value
pairs go into a simple array:

    key = value;

going to:

    struct foo {
        const char *key;
        enumtype    value;
    };
2023-02-14 15:22:11 +09:00
Bill Currie
3498d8b2ae [vkgen] Add support for labeled array elements
This treats dictionary items as arrays ordered by key creation (ie, the
order of the key/value pairs in the dictionary is preserved). The label
is written to the specified field when parsing the struct. Both actual
arrays and single element "arrays" are supported.
2023-02-14 15:22:09 +09:00
Bill Currie
061f90ab83 [vkgen] Add support for array element data
While I wound up not needing it in the end, it's now possible to specify
extra data for array element parsing.
2023-02-14 15:19:58 +09:00
Bill Currie
9e050ebf9a [vulkan] Attempt to load the render info spec
It fails due to not supporting labeled arrays yet. I'm currently
thinking about the design for vkgen.
2023-02-14 15:17:18 +09:00
Bill Currie
c94e691e7e [vkgen] Fix some whitespace
I thought I'd indented that block, but I guess I'd gotten confused while
doing some before and after checks of the indent.
2023-02-14 15:15:58 +09:00
Bill Currie
c3f8e5bcc5 [vkgen] Support ignored fields
This allows having sections in a spec used for things like `properties`
that have no corresponding fields in the actual struct: the field is
ignored when parsing and no cexpr field symbol is emitted.
2023-02-14 15:15:35 +09:00
Bill Currie
d34e6cffdf [vkgen] Clean up most of the generated header
I'll probably completely remove it as only vkparse.c includes it, but
this tidies things up a bit and even simplifies vkgen's loops a little.
2023-02-14 15:15:14 +09:00