Commit graph

5979 commits

Author SHA1 Message Date
Bill Currie
b1de1b8747 [util] Fix more ULP issues in the simd tests on arm
This time for debug (unoptimized) builds. While I could just do an
approximate check, I think it's better to document (as such) the
expected errors.
2023-03-28 12:43:05 +09:00
Bill Currie
47bfa23d09 [vulkan] Stub out the basic job execution
Really, a bit more than stub as the basic code is there, but nothing
works properly yet due to missing resources (especially descriptor sets
and pools), and the frame buffer creation is still disabled.
2023-03-28 10:28:44 +09:00
Bill Currie
34ece7ad03 [vulkan] Add buffer and buffer view support
Not fully implemented, but the parsing is done. Needed image view refs
to be renamed.
2023-03-28 00:15:04 +09:00
Bill Currie
a1e15603a3 [vulkan] Implement job initialization
The step dependencies are not handled yet as threading isn't used at
this stage, but since I'll require dependencies to always come earlier,
this shouldn't cause a problem.
2023-03-26 18:22:46 +09:00
Bill Currie
a8efde1dd3 Fix some mxe build issues 2023-03-25 21:36:45 +09:00
Bill Currie
c59840683d [plist] Use correct attribute for pl_error
Because mxe builds need gnu_printf instead of printf, need to use
PRINTF. I had forgotten that.
2023-03-25 21:31:24 +09:00
Bill Currie
86f2df4939 [vulkan] Respect the VULKAN_SDK environment variable
Thanks to Peter for the report and help in getting it working (I hope I
got all the changes right).
2023-03-25 21:21:13 +09:00
Bill Currie
f098bbf48b [util] Clean up some ULP errors in tests
The problem with floating point in unit tests is, well, comparisons are
finicky.
2023-03-25 21:21:13 +09:00
Bill Currie
f18837f195 [gamecode] Fix a pile of UB in the test cases
I always suspected the overflow conversions were UB, but with gcc doing
different things on arm, I thought it was about time to abandon those
particular tests. What I was not expecting was for the return value of
strcmp to be "UB" (in that there's no guarantee of the exact value, just
< = > 0). Fortunately, nothing actually relies on the value of the op
other than the tests, so modify the test to make the behavior well
defined.
2023-03-25 21:21:13 +09:00
Bill Currie
a058cff59f [util] Fix incorrect check for result of Qgetc
Qgetc returns int, not char. Found via arm compile due to sign of bare
char (or lack thereof).
2023-03-25 21:21:13 +09:00
Bill Currie
a1c67ea24b [vulkan] Implement most of the new job system
There's still the actual job objects to create, but all the vulkan bits
have been created and get destroyed on shutdown.
2023-03-22 19:32:49 +09:00
Bill Currie
2fbc27f6a0 [vkgen] Fix ignored field init and dealloc
I had somehow missed vkfieldignore in a consistency pass, or just messed
up its initialization (and thus deallocation) resulting in a double-free
of the strings.
2023-03-21 17:53:55 +09:00
Bill Currie
3fbac33ee8 [gl] Free alias model cache memory when clearing models
Like sw, gl uses the cache for alias models and thus needs to free the
cache memory when unloading the model.
2023-03-21 13:18:16 +09:00
Bill Currie
793525a50a [sw] Free alias model cache memory when clearing models
This fixes a Sys_Error when loading the level for the first demo (and
probably many other times). It was mod_numknown getting set to 0 that
triggered the issue, but that seems to be necessary for the other
renderers. I think the whole model loading and caching system needs an
overhaul as this doesn't feel quite right due to removing part of the
advantage of caching the model data.
2023-03-20 17:45:28 +09:00
Bill Currie
654b208641 [plist] Add functions to extend dictionaries and arrays
The idea is to make it easy (and efficient) to merge property list
items.
2023-03-15 19:47:30 +09:00
Bill Currie
5255c9c7a8 [set] Initialize pool's dynamic arrays
Testing had missed this because qfvis is the main user of set pools.
2023-03-15 10:17:42 +09:00
Bill Currie
68b5cd89d2 [vkgen] Plug a pile of ruamoko memory leaks
While the previous cleanup took care of the C side, it turns out vkgen
was leaking property list items all over the place, but they were
cleaned up by the shutdown code.
2023-03-13 11:26:13 +09:00
Bill Currie
7d4c1d79b1 [plist] Use reference counts for items
This makes it much easier to share items between property lists (eg,
targets and the main entity list in cl_light).
2023-03-13 11:26:13 +09:00
Bill Currie
45bcb31684 [vulkan] Use bare dictionaries for spec files
Every time I created a new file from scratch, I always forgot the
enclosing {}. Now I will probably include them by accident :P
2023-03-12 14:48:14 +09:00
Bill Currie
3cdcc2c62c [vkgen] Switch to bare dictionary for parse spec
This served as a nice test for the bare dictionary parsing (though
quakefs.c did, too), and even found a bug in vkgen's error handling.
2023-03-12 14:36:47 +09:00
Bill Currie
ea77df2daa [plist] Add parsing for bare dictionaries and arrays
Requiring top-level {} or () for (usually) hand-written files is awkward
and even a little error prone, and certainly ugly at times. With this,
loaders that expect a particular format can specify the format a little
more directly.
2023-03-12 14:31:17 +09:00
Bill Currie
e57a06f37b [plist] Refactor the dictionary and array parsing
This makes it easier to reuse the code for parsing bare dictionaries and
arrays.
2023-03-12 12:27:45 +09:00
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
b9106c09cb [plist] Clean up string parsing
I had looked into doing reference counting on the strings, but didn't
like the implementation. However, it did make for better string handling
in the property list parser.
2023-03-09 13:33:49 +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
00d1ae0b91 [ecs] Invalidate entity in hierarchy before removal
I'm not sure just what was going on other than *other* components were
getting double-removed when the hierarchy reference component was
removed when the entity was being deleted. This might even prevent
issues with removing the hierarchy from an entity that's not being
deleted as the pre-invalidation prevents the removal from deleting the
entity.
2023-03-07 02:00:19 +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
d14162eed9 [model] Ensure all models are unloaded
Cleans up not only vulkan (had to remove the clearing from vulkan to
avoid a segfault).
2023-03-06 01:52:57 +09:00
Bill Currie
e19e7cad0c [ecs] Invalidate entity before removing components
It turns out that the fixes for other problems related to removing
hierarchy reference components fixed the problem moving the entity
invalidation fixed, and invalidating the entity late somehow broke the
sprite renderer (at least in glsl).
2023-03-05 23:31:20 +09:00
Bill Currie
8efe8e63d3 [ecs] Plug a bunch of memory leaks
The hierarchy leak was particularly troublesome to fix, but now the
hierarchies get updated (and freed) automatically just by removing the
hierarchy reference component from the entity. I suspect there will be
issues with entities that are on multiple hierarchies, but I'll sort
that out later.
2023-03-05 22:03:01 +09:00
Bill Currie
28226ac75c [ecs] Handle indices beyond the subpools
It turns out that the bsearch bug was hiding incorrect handling of
indices in the subpool beyond the last tracked subpool. In which case, a
correctly working bsearch correctly fails to find the range, but the
search can be skipped entirely.
2023-03-05 18:53:33 +09:00
Bill Currie
76ac446156 [util] Fix an out-by-one in QF_bsearch_r
And rename _bsearch to QF_bsearch_r since that's far less confusing.
Also, update the test to make it possible for valgrind to detect the
out-by-one. The problem was found when trying to remove components from
an entity when using subpools.
2023-03-05 18:31:30 +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
24ac95ef6e [cvar] Ensure enum cvars tables don't get double freed
Currently doesn't happen, but all it takes is for two or more cvars to
use the same enum type.
2023-03-05 18:31:30 +09:00
Bill Currie
004ebd40b8 [ui] Fix more memory leaks
The text passage component was a legitimate leak, but the rest just
shutdown losses (ie, valgrind noise).
2023-03-05 18:31:30 +09:00
Bill Currie
e81c3a6015 [model] Plug more leaks 2023-03-05 18:31:30 +09:00
Bill Currie
b84bf16cab [util] Add a function to reverse delete cbuf stacks
I'm not 100% sure this is the best fix for the issue, but the way the
cbuf interpreter stack works (especially in the console code) meant that
the stack was built in the order opposite to how it could be safely
deleted with the existing function. Yeah, more leaks :P
2023-03-05 18:31:30 +09:00
Bill Currie
340127fff2 [ruamoko] Plug yet more memory leaks
Some of them, especially in rua_obj, were quite legitimate and even a
problem for thread-safety (rua_cmd is currently not thread-safe, but it
needs a lock, which I don't feel like doing at this stage).
2023-03-05 18:31:30 +09:00
Bill Currie
f256ab167d [gamecode] Yet more leaks 2023-03-05 18:31:30 +09:00
Bill Currie
9605de53d7 [audio] Plug yet more leaks
What a sieve QF became.
2023-03-05 18:31:30 +09:00
Bill Currie
3e30b7b9e2 [image] Allow color conversion caches to be cleaned up
More leaks, but only ruamoko takes advantage of it so far.
2023-03-05 18:31:30 +09:00
Bill Currie
3f9873a754 [console] Plug more memory leaks 2023-03-05 18:31:30 +09:00
Bill Currie
3d65376f87 [cvar] Delete enum symbol tables on shutdown
More memory leaks. Might need to make some soup.
2023-03-05 18:31:30 +09:00
Bill Currie
d8466b6cca [util] Fix a linked-list error in segtext
Uncovered by the memory leak cleanup: the nodes were all being "linked"
to the first node, those nodes in between the first and last were
getting lost.
2023-03-05 18:31:30 +09:00
Bill Currie
13f8f2b66b [util] Fix a pile of memory leaks
Some were actually legitimate (in that they'd cause problems in a long
running game).
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
9193a92a81 [util] Make Hash_DelContext null-safe 2023-03-05 18:31:30 +09:00
Bill Currie
f9e442d323 [util] Make sys globals all thread-local
This was mainly for the shutdown functions, thus allowing Sys_Shutdown
(and Sys_RegisterShutdown) to be per-thread, but it seemed like a good
idea to make everything per-thread.
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
161ccc282f [ruamoko] Unlink passage nodes when deleting
Fixes a segfault on shutdown after the memory leak changes.
2023-03-04 02:23:37 +09:00
Bill Currie
be9e6893e5 [util] Free up hash links
Finally, hash links can be freed when the hash context is no longer
relevant. The context is created automatically when needed, and the
owner can delete the context when its done with the relevant hash
tables.
2023-03-04 02:07:31 +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
e57427142b [util] Clean up some memory leaks in cmd 2023-03-04 00:38:32 +09:00
Bill Currie
b8bd83f5cd [gamecode] Clean up a pile of memory leaks
Usually doesn't matter, but it makes it easier to evaluate valgrind's
output.
2023-03-03 22:07:27 +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
9146860f70 [util] Add size limited find and hash functions
Hash_nFind and Hash_nString work like Hash_Find and Hash_String, but
take a maximum string length (like strncmp etc).
2023-03-03 18:50:47 +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
926e3b76b0 [gib] Clean up regex.c in anticipation of c23
I tried out -std=c2x (doesn't work due to typeof (gcc bug?)) and
-sdt=gnu2x (still no #embed) and found that only regex.c was a problem
(nice), and now it no longer is a problem.
2023-02-28 12:37:30 +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
d89ad6b00f [plist] Fix a typo in the type mismatch message 2023-02-18 16:56:38 +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
Bill Currie
7aa5470c68 [vulkan] Add initial render info parser
It doesn't work yet, but I've some otherwise breaking changes I want in
(getting this in now prevents the breakage).
2023-02-14 15:14:50 +09:00
Bill Currie
e10b084d36 [vulkan] Generate parse data for new render pass structs
There's still a lot of work to do, but the basics are in. The spec will
be parsed into info structs that can then be further processed to
generate all the actual structs, generally making things a little less
timing dependent (eg, image view info refers to its image by name).

The new render pass and subpass structs have their names mangled for now
until I can switch over to the new system.
2023-02-14 15:14:45 +09:00
Bill Currie
97b2f2afb0 [vkgen] Support vec4f_t fields
It's currently a bit of a hack via aliases, but it fits in with the
current support for uint32_t and size_t.
2023-02-14 15:10:46 +09:00
Bill Currie
403c6eea73 [vkgen] Recognize char * as a string
Ruamoko currently doesn't support `const`, so that's not relevant, but
recognizing `char *` (via a hack to work around what looks like a bug
with type aliasing) allows strings to be handled without having to use a
custom parser. Things are still a little clunky for custom parsers, but
this seems to be a good start.
2023-02-14 15:10:09 +09:00
Bill Currie
d5cd4f6ede [vkgen] Use typedef name for structs
Using the typedef name makes using structs declared as

    typedef struct foo_s { ... } foo_t;

easier and cleaner. Sure, I could have written the "struct foo_s" for
the output name, but I'm much more likely to look for foo_t than foo_s
when checking the generated code.
2023-02-14 13:42:25 +09:00
Bill Currie
7c1aff6736 [vulkan] Begin work on a new render pass system
While the old system did get things going, it felt clunky to set up,
especially when it came to variations on render passes (eg, flat vs
cube-mapped). Also, much of it felt inside-out, especially the
separation of pipelines and render passes: having to specify the render
pass and subpass in the pipeline spec made the spec feel overly coupled
to the render pass setup. While this is the case in Vulkan, it is not
reflected properly in the pipeline spec. The new system will adjust the
render pass and subpass parameters of the pipeline spec as needed,
making the pipeline specs more reusable, and hopefully less error prone
as the pipelines are directly referenced by the subpasses that use them.

In addition, subpass dependencies should be much easier to set up as
only the dependent subpass specifies the dependency and the subpass
source dependency is mentioned by name. Frame buffer attachments also
get a similar treatment.

The new spec "format" isn't quite finalized (needs to meet the enemy
known as parsing) but it feels like a good starting place.
2023-02-14 13:39:07 +09:00
Bill Currie
b08639fc82 [vulkan] Run sky surfaces through the depth pass
I suspect this is a hold-over from before the bsp thread safety changes,
but with the nicely separated queues, it's easy to pass the sky surfaces
through the depth pass as well as the translucency pass (I think the
reason for that is lighting). This prevents bits of world being seen
through sky surfaces when the sky isn't fully opaque (like skysheet due
to the shortcuts in the shader).
2023-02-14 13:24:47 +09:00
Bill Currie
8601e09569 [vulkan] Use view local dependencies for cube rendering
It doesn't fix the problems on my laptop, but it might improve
performance on my 1080 (but I doubt it will make much difference).
2023-02-14 13:24:47 +09:00
Bill Currie
f78fcec689 [vulkan] Create view matrices for fisheye cube maps
Really any cube maps, but currently the check is for fisheye rendering.
2023-02-14 13:24:47 +09:00
Bill Currie
0ccee3032e [vulkan] Add partial support for cube maps to OIT
Partial because frame buffer creation isn't handled yet (using six
layers), but using layer a layer capable view and shaders doesn't cause
problems (other than maybe slightly slower code).
2023-02-14 13:24:47 +09:00
Bill Currie
6d7a9e2bc2 [vulkan] Prioritize fisheye over waterwarp
Pushing waterwarp's constants into fisheye's buffer resulted in some
rather weird effects when underwater with fisheye active.
2023-02-14 13:24:47 +09:00
Bill Currie
36f1c26ac1 [vulkan] Fix incorrect render pass for shadow pipelines
Noticed while getting fisheye limping.
2023-02-14 13:24:47 +09:00
Bill Currie
759e3455c3 [vulkan] Hook up fisheye rendering in the output pass
It turns out that my laptop doesn't do multiview properly (or I've
misconfigured something, later), but the biggest issue I had on my
desktop seems to be that I had the push constants wrong: fov in aspect,
time in fov, and I had degrees instead of radians (half angle) anyway.
2023-02-14 13:24:47 +09:00
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
e709eceb75 [vulkan] Use matrices header in geometry shaders
I had missed them earlier as I had forgotten about them (looked only at
vertex shaders).
2023-02-14 13:24:47 +09:00
Bill Currie
6f429311c9 [cexpr] Use func instead of result type for end of list
While the cexpr parser itself doesn't support void functions, they have
their uses when used with the system, and mixing them into the list of
function overloads shouldn't break non-void functions.
2023-02-14 12:45:04 +09:00
Bill Currie
2748f1c9f7 [ruamoko] Add support for PL_KeyAtIndex
I'd forgotten to wrap the function when I added it, but didn't need it
until now.
2023-02-14 12:45:04 +09:00
Bill Currie
65e15c2dd0 [cexpr] Keep track of unidentified symbol names
At least with a push-parser, by the time the parser has figured out it
has an identifier, the lexer has forgotten the token, thus the annoying
and uninformative "undefined identifier " error messages. Since
identifiers should always have a value (and functions need a function
type), setting up a dummy symbol with just the identifier name
duplicated seems to do the trick. It is a bit wasteful of memory if
there are a lot of such errors between cmem resets, though.
2023-02-14 12:45:04 +09:00
Bill Currie
cb99c4d907 [cexpr] Support casts from plist to vector
This makes specifying colors in the vulkan parser a lot easier.
2023-02-14 12:45:04 +09:00
Bill Currie
d5b93c20b3 [plist] Pass array index/label to the parse function
I ran into the need to get at the label of labeled array element and the
best way seemed to be by setting the name field of the plfield_t item
passed to the parser function, and then found that PL_ParseSymtab
already does this. I then decided passing the array index would also be
good, and the offset field made sense.
2023-02-14 12:45:04 +09:00
Bill Currie
99d32d5e54 [client] Add a comment on light attenuation
Saves me having to look in the shader every time.
2023-02-14 12:45:04 +09:00
Bill Currie
a561558748 [console] Switch to using a canvas for the console
While the console background is broken in that alpha doesn't work, it's
now rendered correctly in all renderers.
2023-01-22 03:45:50 +09:00
Bill Currie
89afcfcb6d [ui] Add a lateupdate component to canvas
Like update, the function takes just a view, but is useful for updates
that need to run after the other components are run.
2023-01-22 03:43:58 +09:00
Bill Currie
158c45d120 [vulkan] Correct calculation of conback position
The problem with setting con_size to 0.5 and con_speed to 0 is it's
difficult to tell when the console positioning is backwards.
2023-01-22 03:28:32 +09:00
Bill Currie
254fcff8ff [ecs] Find correct correct sub-pool range
Returning -1 for key > value doesn't work too well for bsearch.
2023-01-22 01:04:23 +09:00
Bill Currie
bc041d6291 [vulkan] Zero draw's frame structs
Some of the queues start don't get fully initialized, but rather than go
through everything making sure they do, it's just easier to zero the
whole lot at the beginning.
2023-01-21 16:35:21 +09:00
Bill Currie
d10cfb348e [client] Ensure status char buffers are cleared
Fixes uninitialized values when hud_pl is enabled for overkill in qw (pl
is never updated, so it never gets set).
2023-01-21 16:33:45 +09:00
Bill Currie
3d52caadec [ecs] Avoid shuffling components in empty ranges
When bubbling a component past an empty range, there's no need for any
actual movement other than adjusting the range itself, and doing so
corrupts the sparse/dense array relationship. Fixes a segfault when
hiding the deathmatch overlay (that resulted from the change to using
canvases).
2023-01-21 13:58:43 +09:00
Bill Currie
03e867f0f8 [ui] Remove some extra debug outlines
Forcing hidden views and doing the outlines for the screen canvas were
part of sorting out weirdnesses with canvases and component sub-pools.
2023-01-21 11:20:09 +09:00
Bill Currie
3c8f02c655 [client] Switch to using canvases for screen and hud
Canvases provide layered rendering as for each canvas all components are
rendered in turn.
2023-01-21 03:43:18 +09:00
Bill Currie
f0fab885d4 [ui] Get canvas into a usable state
Canvas_SortComponentPool now takes the raw canvas component id as it is
specialized to the canvas subpools.

Canvas_SetLen resizes the root view and then updates the hierarchy for
every canvas in the system.

Canvas_InitSys sets up the component system with the systems it needs
(canvas, view, text). This is required to ensure view_href is just past
the canvas components as it is needed for retrieving the actual canvas
component (and thus sub-pool range ids) from arbitrary views in the
canvas.

Entities are fetched with the correct offset from the pool entities.
2023-01-21 03:26:02 +09:00
Bill Currie
9384442834 [ecs] Remove a debug print 2023-01-21 03:14:27 +09:00
Bill Currie
4949f52b58 [console] Move gib hud control into hud
I don't know why it was ever in console.
2023-01-21 02:57:05 +09:00
Bill Currie
32cead5f88 [ui] Add a function to create a new canvas entity
The entity has only a canvas component and (root) view component
attached. The plan is to use it for screen-space canvases.
2023-01-20 15:57:29 +09:00
Bill Currie
873d400766 [scene] Remove scene_resources_t struct
It was made unnecessary by the ECS changes.
2023-01-20 15:53:51 +09:00
Bill Currie
68c7003991 [console] Separate loading and initialization
This will make it easy for client code to set up data needed by the
console before the console initializes. It already separates console
cvar setup and initialization, which has generally been a good thing.
2023-01-20 13:27:17 +09:00
Bill Currie
06fdef52e8 Clean up some unneeded console.h includes 2023-01-20 12:59:45 +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
d7b1fceb12 [vulkan] Remove a dead FIXME
The flashing pink around the Q menu cursor was caused by vulkan command
buffer writes and draw queue population being out of phase, which was
fixed by the recent screen update changes (specifically,
42441e87d4).
2023-01-19 21:36:03 +09:00
Bill Currie
cdc5f8a912 [vulkan] Get line rendering working again
Rather important for debugging 2d stuff (draw's lines are 2d-only).
Other than translucent console, this gets the vulkan draw api back to
full operation.
2023-01-19 21:29:39 +09:00
Bill Currie
b91a76cbcc [vulkan] Get Draw_TextBox working again
This needed either more font ids to be supported, or small lump pics (up
to 32 x 32) to be loaded into the atlas. I went with both. The menus
don't use Draw_TextBox, but quakeworld's netgraph does.
2023-01-19 17:56:37 +09:00
Bill Currie
91adb6ad6c [console] Go back to using Draw_ConsoleBackground
Using Draw_FitPic was for testing.
2023-01-19 17:35:30 +09:00
Bill Currie
e332164329 [vulkan] Implement fitted pic rendering
This makes use of slice rendering to achieve the effective scaling, but
the slice data is created only when needed so pics that never use slices
don't waste 16 vertices.
2023-01-19 17:18:51 +09:00
Bill Currie
7785eebe4c [vulkan] Clean up some unnecessary interface functions
Not all the empty stubs have been removed as the core model and skin
code still needs to be cleaned up.
2023-01-19 12:58:02 +09:00
Bill Currie
9349a739db [renderer] Run particle update in renderer update
This has little effect on sw/gl/glsl, but makes it so the particle
system isn't run on the CPU (redundantly) for vulkan.
2023-01-19 12:39:26 +09:00
Bill Currie
42441e87d4 [vulkan] Create a vulkan-specific UpdateScreen
The goal is to get vulkan relying on the "renderpass" abstraction, but
this gets vulkan up and running again, and even fixes the rendering
issues (in the end, getting canvas working wasn't required, but is still
planned).
2023-01-19 11:33:49 +09:00
Bill Currie
93e5c84a20 [gui] Link against freetype and harfbuzz
Ran into the issue while testing the screen update change ("release"
build couldn't run due to broken plugins).
2023-01-19 11:11:05 +09:00
Bill Currie
07d5749a4e [renderer] Make the core of SCR_UpdateScreen dynamic
This is a bit of a hack to allow me to work on vulkan's screen update
"pipeline" without having to mess with the other renderers, since it
turns out they're (currently) fundamentally incompatible.
2023-01-19 11:10:48 +09:00
Bill Currie
d2467f1424 [vulkan] Use dynamic descriptors for dynamic verts
When a pic needs dynamic vertices (eg, for sub-pics), a descriptor set
is allocated and updated if one has not been created for the pic. This
is done each frame: the descriptor sets are recycled (there currently is
rarely a need for more than a small handful of dynamic descriptors, so
64 should be plenty for now).

Unfortunately, due to the order of operations issue between draw items
getting queued and submitting commands to vulkan (the cause of the pics
not rendering correctly per 8fff71ed4b),
the validation layers complain (correctly) about the command buffers
being executed with updated descriptor sets. Getting the canvas system
up and running will fix that.
2023-01-17 20:49:22 +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
96c82106f9 [sw] Remove hand loop unrolling from pic and conback
GCC has done a better job for about twenty years. Readability for the
win :).
2023-01-17 11:31:46 +09:00
Bill Currie
31c1420682 [client] Further decouple screen and console
The wording might seem a little odd, but cl_screen is really the full 2D
client HUD while the console is completely independent of the client and
shouldn't know that the client even exists. Ideally, the resize events
would be handled by the canvas system, to which end this is a small
step.
2023-01-16 13:29:20 +09:00
Bill Currie
8833518826 [ecs] Support sorting subpools
Sorting the whole pool when subpools are in use could break the
subpools (very high probability, depending on the sort criteria and
subpool criteria).
2023-01-16 11:32:12 +09:00
Bill Currie
2383c12a4a [renderer] Move r_framecount update out of render_scene
This fixes the broken dynamic lighting in fisheye rendering. It does
mean that frustum culling of lit surfaces needed to be removed, but if
not doing frustum culling on lit surfaces was good enough for a P90,
it's probably good enough for an i7-6850K.
2023-01-16 00:38:43 +09:00
Bill Currie
73e5ccd0d5 [vulkan] Set transparent color to black
I had forgotten that the draw pipeline expects pre-multiplied alpha,
thus the pink background for the menu pics.
2023-01-13 18:36:14 +09:00
Bill Currie
0953446c3e [vulkan] Load cachepics as separate images
They are usually larger images (eg, the main menu graphic) and thus make
a mess of the atlas (thus, making them separate means a smaller atlas
can be used). All sorts of things are in a mess (descriptor management,
subpic rendering not supported, wrong alpha value for the transparent
pixel), but this gets the basic loader going.
2023-01-13 11:15:44 +09:00
Bill Currie
2f564ca5a6 [vulkan] Use slices to implement fills
Again, not really the most optimal as 8/9 quads are degenerate, but it
went a long way to testing the slice part of the pipeline.
2023-01-12 17:10:43 +09:00
Bill Currie
65005656cb [vulkan] Implement tile clear
This just takes advantage of the dynamic verts for doing subpics. It's
not really the most optimal code as it has to write both the vertices
(64 bytes per quad) and the instances (24 bytes per quad), but that's
still better than the old 128 bytes per quad (and having a single
pipeline is nice).
2023-01-12 17:06:18 +09:00
Bill Currie
89ecde787a [vulkan] Use dynamic quad vertices for subpics
This gets subpics and the crosshairs working again.
2023-01-11 17:16:49 +09:00
Bill Currie
456003f8cb [vulkan] Create static vertex data for pics
This gets full pic rendering working. Subpics and other dynamic quad
rendering doesn't work yet.
2023-01-11 13:34:27 +09:00
Bill Currie
77fc6355cc [vulkan] Use correct descriptor set for core quads
The problem was that I had mixed up the purpose of the per-frame vertex
buffers and used them for the core quad data when they were meant for
subpic and the like, and forgotten about the static vertex buffer.

This gets at least conchars working (pic in general not tested yet).
2023-01-11 12:47:22 +09:00
Bill Currie
8fff71ed4b [vulkan] Rework quad drawing to use a single pipeline
Any performance gains will be utterly swamped by the deferred renderer,
but it will allow better control of quad render order by any client
code (and should be slightly better for simpler renderers when I get
support for them working).

Right now, plenty is broken (much of the higher level draw functions are
disabled, and pics don't render correctly), but this gets at least the
basics in so I'm not bouncing diffs around as much.
2023-01-11 11:34:32 +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
82d0b7ecd5 [vulkan] Use slice pipeline for glyphs
It turns out the slice pipeline is compatible with the glyph pipeline in
that its vertex attribute data is a superset (just the addition of the
offset attributes). While the queues have yet to be merged, this will
eventually get glyphs, sliced sprites, and general (static) quads into
the one pipeline. Although this is slightly slower for glyph rendering
(due to the need to pass an extra 8 bytes per glyph), this should be
faster for quad rendering (when done) as it will be 24 bytes per quad
instead of 32 bytes per vertex (ie, 128 bytes per quad), but this does
serve as a proof of concept for doing quads, glyphs and sprites in the
one pipeline.
2023-01-05 16:34:01 +09:00
Bill Currie
3da90b612f [vulkan] Remove superfluous glyph fragment shader
The main reason I had created in the first place was I hadn't thought of
using image view swizzles to handle coverage-alpha textures (for
monochrome glyphs), and for whatever reason also had the texture in a
different binding slot to the twod fragment shader. With both issues out
of the way, there's no reason to have an almost identical (just some
naming) shader just for glyphs.
2023-01-05 13:34:52 +09:00
Bill Currie
37b6d4da7e [vulkan] Switch glyph vertex and texture data bindings
With an eye towards merging the 2d pipelines as much as possible, I
found that the glyph and basic 2d quad texture descriptors were in
different slots for no reason I can think of. Having them in the same
slot would mean I could use the same fragment shader for all 2d
pipelines (though the plan is to get it down to two: (sliced) quads and
lines).
2023-01-05 13:25:46 +09:00
Bill Currie
70e93bb7e8 [ruamoko] Advance glyphset when working through the pool
It seems to help if the right font data is used when rendering glyphs.
Fixes use of multiple fonts in different passages.
2023-01-03 20:20:02 +09:00
Bill Currie
5477749280 [vulkan] Use correct input assembly for sprite depth
I hadn't noticed the problem until playing with early fragment tests for
the sprite fragment shaders, but passing data that expects triangle
strips to a pipeline that expects triangle lists doesn't work too well
when drawing quads.
2022-12-23 12:47:28 +09:00
Bill Currie
b5912bba9b [ui] Clean up the canvas component
It turns out only the range ids are needed in the canvas component at
this stage, and moving the canvas system base into canvas_system_t makes
sense.
2022-12-21 01:54:10 +09:00
Bill Currie
6decbd18c4 [ui] Add a canvas system
This is the beginning of supporting 2d rendering in 3d space. The idea
is that a canvas can be in 2d orthographic space (not attached to any
entity with a 3d transform), or in 3d perspective space (attached to an
entity with a 3d transform, either as a child of the camera, or of some
object in 3d space).

It will replace the current HUD code when it's working.
2022-12-20 19:45:48 +09:00
Bill Currie
3a2877dd9a [ecs] Adjust subpool range type to return start,end
I found I needed the subrange start as well as the end, but I liked that
the subpools themselves used only the end of the range, so switching to
just a unint32_t for the value and adding a function to return a tuple
made sense. I had kept the struct because I thought I might want to
store additional information (eg, the entity "owning" the subpool), but
found that I didn't need such information as the systems using subpools
that way would have access to the entity by other means.

Interestingly, the change found a bug in subpool creation: I really
don't know why things worked before, but they work better now :)
2022-12-20 17:56:08 +09:00
Bill Currie
34930ba195 [ecs] Fix a bit of white space 2022-12-20 10:59:26 +09:00
Bill Currie
d67b8cdf05 [ecs] Add support for subpools
Subpools are for grouping components by some criterion. Any component
that has a rangeid callback will be grouped with other components that
return the same render id. Note that the ordering of components within a
group will be affected by adding a component into a group that comes
before that group (or removing a component).

Component pools can have multiple groups, added and removed dynamically,
but removing a group should (currently) be done only when empty.
2022-12-18 21:11:21 +09:00
Bill Currie
24a85dbadc [ui] Add a component set for passage hierarchy refs
While "set" is a tad strong (there's just the one component for now), I
had missed the changes when adding ECS systems. Fixes the segfault at
the end of demo1 (ie, when any center text is printed).
2022-12-16 18:12:38 +09:00
Bill Currie
61f61baf48 [client] Remove hud_href component
I had missed this when adapting the ecs system for modular systems.
2022-12-15 12:50:27 +09:00
Bill Currie
41d25df0d2 [ui] Attach text views to passage entities
Instead of creating new entities for the text views. This approximately
halves the number of entities required to display flowed text, but also
tests the ability to have an entity in multiple hierarchies (the goal of
the ECS component and system changes).
2022-12-14 22:38:37 +09:00
Bill Currie
ead5e89165 [renderer] Don't mark made pics as cached
Marking them as cached means that they'll be "uncached" instead of
destroyed when freed, which would not be a particularly good thing. I
have no memory as to how I found this as I found the change in my git
stash.
2022-12-14 12:40:14 +09:00
Bill Currie
b230fe18ce [ecs] Split component registration from pool creation
While this does require an extra call after registering components, it
allows for multiple component sets (ie, sub-systems) to be registered
before the component pools are created. The base id for the registered
component set is returned so it can be passed to the subsystem as
needed.
2022-12-13 22:58:44 +09:00
Bill Currie
3c4dccf801 [ecs] Organize headers and code
There's now a main ecs.h file that includes the sub-system headers,
removing the need to explicitly include several header files, but the
sub-systems are a less cluttered.
2022-12-13 15:31:35 +09:00
Bill Currie
1a56376f98 [scene,ui] Be more consistent with component enum names
Actual registry component counts are *_comp_count while hierarchy type
component counts are *_type_count.
2022-12-12 13:37:01 +09:00
Bill Currie
bb677a1a7c [ecs] Move href_comp into hierarchy_t
This means that the component id used for hierarchy references must be
passed to Hierarchy_New and Hierarchy_Copy, but does all an entity to
have more than one hierarchy, which is useful for canvases (hierarchies
of views) in the 3d world (the canvas root would have a 3d hierarchy
reference and a 2d (view) hierarchy reference).
2022-12-12 00:20:20 +09:00
Bill Currie
cb45fe7034 [x11] Warp the mouse when it touches a barrier
It seems that the mouse escaping the barriers requires some combination
of hitting two at once, and holding your mouth just right (something
about sliding the mouse up and down one barrier near the other).
However, sending the mouse back to the center of the screen when it
touches a barrier makes such sliding impossible.

This seems to fix #38
2022-12-11 19:14:35 +09:00
Bill Currie
203e490be0 [x11] Fix a couple of missed XFixes related blocks
Disabling XFixes but keeping XInput2 wouldn't compile.
2022-12-11 17:28:31 +09:00
Bill Currie
b553c313fe [x11] Don't double-divide for window center
I obviously need a better way to test legacy code because the fix for
unsigned-int behavior with clang broke mouse warping when using
XGrabPointer instead of XInput2's XIGrabEnter.
2022-12-11 16:46:58 +09:00
Bill Currie
65214fb7f8 [ui] Split flowed line separation
The separation now uses height above (right of) the base line, and depth
below (left of) the base line. This puts the text exactly where I want
it, but there's still the problem of uneven line spacing caused by
descenders and ascenders. However, I suspect that's more up to the
text/font handling code to get the boxes right (maybe set spaces to have
the right dimensions?).
2022-12-10 22:07:54 +09:00
Bill Currie
6a9985c8aa [vulkan] Fix an uninitialized field
Yay valgrind. Luckily, there was a very tiny probability for it causing
problems, but 0 is better.
2022-12-10 19:05:39 +09:00
Bill Currie
50d588567b [ui] Fix a pile of errors in text shaping
The main problem was the confusion about the coordinates within a single
glyph, and thus the glyphs position within the view's box. With this,
flowed text works fairly well except for some issues with spacing
between lines (which I think is due to the flow code not having been
tested with offset boxes).
2022-12-10 19:05:39 +09:00
Bill Currie
c316b6b5d1 [ruamoko] Wrap more text and view functions
rua_gui.c is still a horrible mess of hacks, but it does the job for
testing the text code.
2022-12-10 19:05:39 +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
d98eb8abc6 [ui] Add support for setting text attributes
Font cannot be overridden yet, but script attributes (language, script
type, direction) and features can be set at all three levels in a
passage. Attributes on the root level act as defaults for the paragraph
and word levels, and paragraph attributes act as defaults for the word
level.
2022-12-09 18:46:26 +09:00
Bill Currie
c5af5728fe [ui] Fix some passage text shaping bugs
Passage_Delete needs to check if the hierarchy is valid as no text may
have been added, which results in a null pointer for the hierarchy.

Text shaping needs to set language etc every time it resets the buffer.
2022-12-09 15:20:10 +09:00
Bill Currie
b93ab95c47 [ruamoko] Add some builtins for passages and text
Just some basic implementation so I can test shaping of passage text.
2022-12-09 15:18:47 +09:00
Bill Currie
5fd510ade4 [ui] Add font to renderer when loading
This causes some problems with linking if libQFgui is linked with
libQFrenderer (which is necessary in the long run), but it seems
everything gets away with it for now (which, tbh, I don't like).
2022-12-08 16:57:45 +09:00
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