Commit graph

6066 commits

Author SHA1 Message Date
Bill Currie
befb3ca31b [vulkan] Clamp composed values to >= 0
This takes care of the nans that got into the output buffer resulting is
weird holes in any overlays.
2023-07-22 00:43:05 +09:00
Bill Currie
99c6c58e25 [vulkan] Expose pipeline disable controls
Finally, runtime control of the debug pipelines (and all the rest, but
that might come in handy at some stage).
2023-07-21 19:45:54 +09:00
Bill Currie
4b86a0376d [console] Reset minimum time too
Not sure what happened to it, I thought I'd done that before.
2023-07-21 19:31:20 +09:00
Bill Currie
ef322b968a [ui] Skip checkbox label if zero length
I seem to remember doing this for radio buttons, I guess I forgot about
checkboxes (really need to unify the code, though).
2023-07-21 19:28:30 +09:00
Bill Currie
8ae150cb9e [vulkan] Use correct name for pipelines
Using the subpass name instead of the pipeline name makes for a
confusing mess of duplicated names when subpasses have multiple
pipelines.
2023-07-21 12:37:04 +09:00
Bill Currie
fde1ef0159 [vulkan] Add infinite plane rendering
The grid calculations are modified from those of Inigo Quilez
(https://iquilezles.org/articles/filterableprocedurals/), but give very
nice results: when thin enough, the lines fade out nicely instead of
producing crazy moire patterns. Though currently disabled, the default
planes are the xy, yz and zx planes with colored axes.
2023-07-21 11:59:25 +09:00
Bill Currie
72f7fcea47 [vulkan] Switch to reversed depth, infinite far plane
Based on the article
(https://developer.nvidia.com/content/depth-precision-visualized), this
should give nice precision behavior, and removes the need to worry about
large maps getting clipped. If I'm doing my math correctly, despite
being reversed, near precision is still crazy high. And (thanks to the
reversed depth) about a quarter of a unit (for near clip of 4) out at 1M
unit distance.
2023-07-21 11:36:10 +09:00
Bill Currie
6e9f50ffe4 [vid] Ensure window size gets sent after init
This fixes a pile of window size related issues I've seen for a while,
but most importantly, some nastiness with division by 0 and segfaults.
2023-07-14 11:57:36 +09:00
Bill Currie
8e0bfb1a7b [console] Implement mouse trackball camera control
I've always wanted this in QF :)
2023-07-14 11:28:04 +09:00
Bill Currie
bf3d57cdbf [ui] Return whether events to imui were consumed
Needed for non-ui handling of events (eg, mouse interaction with the
main screen).
2023-07-14 11:25:50 +09:00
Bill Currie
8068233fb2 [x11] Don't force grab or mouse warp in fullscreen
This seems to be more for legacy X11 (ie, without fixes etc), but
fullscreen really shouldn't affect grabbing directly (rather, it should
be up to the client whether grabbing (and thus warping) is enabled at
all.
2023-07-14 07:11:53 +09:00
Bill Currie
fa1d8ff552 [client] Use correct width for input lines
con_linewidt starts out as 0, which leads to bad results for the initial
widths of input lines and later calculations. However, really, they
probably shouldn't be using size_t for the width, but this is a nice
quick fix.
2023-07-14 07:04:57 +09:00
Bill Currie
cc57d2bc5b [vulkan] Remove double-draw of skies
Due to doing most of my testing using the demos, I hadn't noticed the
double-draw until flying around with the debug camera (and it showed as
a weird shimmer behind the sky layers).
2023-07-14 00:44:09 +09:00
Bill Currie
12b4cd8aba [console] Clean up the debug camera window
Now that I have menus, I can close the window.
2023-07-13 23:36:12 +09:00
Bill Currie
21a9cbc61b [ui] Implement a basic menu system
Menus within menu contexts automatically create menu items for the
sub-menu, and menus collapse when leaf menus are select.
2023-07-13 23:16:26 +09:00
Bill Currie
a6fa10b24d [vulkan] Show timings for the job and steps
No real surprises anywhere other than how long things can take at random
times.
2023-07-13 18:33:31 +09:00
Bill Currie
9289e26211 [vulkan] Add a very simple job window
It shows the list of steps in the render job, but acts as something for
testing.
2023-07-13 15:41:49 +09:00
Bill Currie
3944cab95f [console] Start work on a main menu
It's rather clunky at the moment, especially with menus still in
development, but it gets the basics going for testing.
2023-07-13 14:25:08 +09:00
Bill Currie
6d7e1064ec [ui] Support anchoring and extending panels
Panels can be anchored to a widget in another hierarchy, allowing for
things like cascading menus. They can also be extended via referencing
them by name, allowing for subsystems to add items to an already panel
(eg, extending a menu).
2023-07-13 14:22:31 +09:00
Bill Currie
f5fd649dde [ui] Mark the text view as free-floating
This prevent the layout system from repositioning the text view and thus
breaking text-shaping. Now Tengwar Telcontar looks much more balanced in
the widgets.
2023-07-13 14:22:31 +09:00
Bill Currie
7642ef5758 [vulkan] Add debug displays for lights and bsp
The lights debug is from the light splat experiment (this is why I kept
the code), and the bsp debug is based on that. Both currently disabled
for now until I get UI controls in.
2023-07-13 14:22:31 +09:00
Bill Currie
0a260129a8 [console] Add a screenshot button to the debug ui
Saves me having to bind a key.
2023-07-12 23:23:57 +09:00
Bill Currie
1404b85846 [ui] Give panels/windows a group offset
This allows for finer control of render order and thus layering (will be
important for menus).
2023-07-12 10:17:43 +09:00
Bill Currie
313aa116f8 [console] Get a debug camera working
It's now possible to move around the world separate from the player. The
debug ui has its own set of button and axis bindings for navigation.
2023-07-12 00:55:44 +09:00
Bill Currie
d0d39ecee0 [renderer] Allow the camera to be overridden
Necessary for a debug camera.
2023-07-12 00:47:40 +09:00
Bill Currie
706995f6b3 [client] Correct the description of move.up axis
My 3d mouse has +Z as down (makes sense, really), which is what I set
the code to, but I guess I forgot to correct the description.
2023-07-12 00:40:37 +09:00
Bill Currie
1b89598b28 [renderer] Clean up SCR_UpdateScreen a little
SCR_UpdateScreen_Legacy now takes only the screen functions pointer (it
didn't need camera or realtime), and the camera sizzle code has been
moved into one place to make cleaning it up easier (when I get around to
auditing AngleVectors etc).
2023-07-11 11:41:14 +09:00
Bill Currie
d848a73aee [ui] Layout the entire hierarchy
Skipping the root view (widget) sort of made sense before windows became
separate canvases as there was only the one hierarchy, but doing so
prevented windows (panels) from fitting themselves to their children.
However, now I need to think of a good way of specifying a minimum size
for panels.
2023-07-11 10:04:07 +09:00
Bill Currie
d8b59656aa [ui] Reset active widget when UI context is hidden
WIdgets can't possibly be active when the entire UI is hidden, and
resetting the active widget when hiding the UI helps when the state gets
broken due to widget id conflicts.
2023-07-11 10:04:07 +09:00
Bill Currie
24b5066760 [ui] Implement panel widgets and use for windows
The intent is to use them for menus, tooltips and anything else along
those lines, but windows was a good starting point (and puts a border
along the top of the window too).
2023-07-11 10:04:07 +09:00
Bill Currie
698ce157b3 [ecs] Move correct number of subpool ranges
Fixes yet another segfault when deleting the last range in the subpool.
Also, initialize the subpool's next index.
2023-07-11 00:06:21 +09:00
Bill Currie
5ad6ec2757 [ui] Distribute remaining space over expand children
It's not perfect as the first N expanding children get grown by 1 pixel
regarless of weight, but it's much better than leaving a (possibly quite
large) gap at the edge of the layout.
2023-07-10 22:13:58 +09:00
Bill Currie
c18e432e0f [ui] Make windows fit to children
I'm not sure this is what I want, especially in the long run, but it
does make simple windows much easier to create (and not look broken due
to being specified too small).
2023-07-10 22:12:45 +09:00
Bill Currie
48cc4db45d [ui] Give windows a small border
It's currently hard-coded to black, but it makes the windows much easier
to see when overlapping.
2023-07-10 22:10:04 +09:00
Bill Currie
7e758327f6 [glsl] Use a unified queue for batched quads
This makes the glsl renderer compatible with canvases, and thus imui. It
also makes for much saner draw call counts.
2023-07-10 19:12:41 +09:00
Bill Currie
4e7bd11415 [build] Clean up make distcheck issues 2023-07-10 11:12:22 +09:00
Bill Currie
ac625830c8 [ui] Raise a window when its title bar is clicked
Getting to have a real UI here.
2023-07-10 00:11:24 +09:00
Bill Currie
79e4a5f6a8 [ui] Add the concept of draw order to canvases
Canvas draw order is sorted by group then order within the group. As a
fallback, the canvas entity id is used to keep the sort stable, but
that's only as stable as the ids themselves (if the canvases are
destroyed and recreated, the ids may switch around).
2023-07-09 23:27:26 +09:00
Bill Currie
c2d68f5495 [ui] Avoid creating a subpool for the canvas component
It's never used and just not needed.
2023-07-09 22:22:05 +09:00
Bill Currie
9f737000a8 [ui] Put windows on separate canvases
This fixes the draw order issues shown by overlapping windows.
2023-07-09 22:22:05 +09:00
Bill Currie
f359f47e54 [ui] Add a formatted label (like printf)
Formatted printing is just too handy, and having to use va all the time
is a bit of a pain.
2023-07-09 12:10:28 +09:00
Bill Currie
a8b80c4be5 [ui] Delete subpools when a canvas is deleted
Yet another finger in the memory dyke.
2023-07-09 12:06:08 +09:00
Bill Currie
76b6d3141b [ecs] Use correct index when deleting subpool ranges
Coming up with tests is hard. Breaking code with real code is easy.
2023-07-09 11:52:11 +09:00
Bill Currie
bf05da26cc [ui] Make Canvas_SetLen operate on only one canvas
I plan on using sub-canvases to fix the imui window overlap issue and
don't want the windows being affected by (eg) hud canvas size changes.
2023-07-08 20:56:40 +09:00
Bill Currie
c32ffce886 [ecs] Add a function to move a subpool to be the last
This has use when the order of components in the pool affects draw order
(or has other significance), especially at the subpool level. I plan to
use it for fixing overlapping windows in imui.
2023-07-08 19:55:37 +09:00
Bill Currie
9ff38418d3 [client] Move cshift into client screen canvas
This fixes cshifts affecting the console and debug canvases. The
crosshair and center print have also been moved for the same reason.
2023-07-08 14:32:02 +09:00
Bill Currie
3138c7ae3b [client] Clean up screen view creation 2023-07-08 14:04:29 +09:00
Bill Currie
8bb5d2e1c9 [vulkan] Plug a memory leak in capture
I probably need to do this for other subsystems as well, but it stood
out when chasing down another memory leak.
2023-07-08 11:15:51 +09:00
Bill Currie
79ab2f7ba7 [ui] Add a shaped text cache system
Shaped text is cached using all the shaping parameters as well as the
text itself as a key. This makes text shaping a non-issue for imui when
the text is stable, taking my simple test from 120fps to 1000fps
(optimized build).
2023-07-08 11:15:51 +09:00
Bill Currie
0360e33a00 [ecs] Add "tree mode" to hierarchies
As I had long suspected, building large hierarchies is fiendishly
expensive (at least O(N^2)). However, this is because the hierarchies
are structured such that adding high-level nodes results in a lot of
copying due to the flattened (breadth-first) layout (which does make for
excellent breadth-first performance when working with a hierarchy).

Using tree mode allows adding new nodes to be O(1) (I guess O(N) for the
size of the sub-tree being added, but that's not supported yet) and
costs only an additional 8 bytes per node. Switching from flat mode to
tree mode is very cheap as only the additional tree-related indices need
to be fixed up (they're almost entirely ignored in flat mode). Switching
from tree to flat mode is a little more expensive as the entire tree
needs to be copied, but it seems to be an O(N) (size of the tree).

With this, building the style editor window went from about 25% to about
5% (and most of that is realloc!), with a 1.3% cost for switching from
tree mode to flat mode.

There's still a lot of work to do (supporting removal and tree inserts).
2023-07-07 14:42:49 +09:00
Bill Currie
008aebf344 [console] Implement a very lame style editor
Lame partly because the color selection is not nice. However, it has
shown how slow hierarchy creation can be (it swamps font layout even).
2023-07-06 19:39:26 +09:00
Bill Currie
d8eef0be34 [ui] Avoid adding empty labels for radio buttons
More places will need it, but this fixes a problem with a large array of
just buttons.
2023-07-06 19:36:03 +09:00
Bill Currie
d4b11923b9 [ui] Add inactive labels and a style api
Labels are always good and the style api allows pushing/popping and
modifying the current style.
2023-07-06 19:34:48 +09:00
Bill Currie
b58c373f3e [ui] Use correct type for expansion calculations
Using unsigned in the calculations makes for some very large views.
2023-07-06 19:31:18 +09:00
Bill Currie
08cd03e632 [ui] Allow the parent layout rules to be modified
This makes it easy to control whether a window is a fixed size or fits
its children (or any other scheme, though those are the two most
likely).
2023-07-06 19:24:23 +09:00
Bill Currie
9b81ac1d38 [ui] Use macros for component ids
Saves me having to write the calculation every time they're needed.
2023-07-06 19:06:09 +09:00
Bill Currie
df40a50b91 [ui] Implement dragable collapsible windows
And of course, closable.
2023-07-06 12:21:14 +09:00
Bill Currie
300badc96a Fix a couple of windows build issues
There's still the problem with unused variables when building for
windows because of vulkan debug stuff, but this fixes the important
errors. It actually still works (at least under wine).
2023-07-06 02:04:47 +09:00
Bill Currie
a6e75b7617 [ui] Add a very basic style system
Nothing can be changed at the moment, but it actually looks a little
like a UI.
2023-07-06 01:27:46 +09:00
Bill Currie
b34d3cae91 [ui] Rename the imui size control enumerators
I didn't particularly like the "kind" in the name. I'm not super happy
with percent, but it will do for now.
2023-07-06 00:15:34 +09:00
Bill Currie
0fab830be6 [ui] Implement auto-expand layout
By default, horizontal and vertical layouts expand to fill their parent
in their on-axis direction (horizontally for horizontal layouts), but
fit to their child views in their off-axis.

Flexible space views take advantage of auto-expansion, pushing sibling
views such that the grandparent view is filled on the parent view's
on-axis, and the parent view is filled by the space in the parent view's
off-axis. Flexible views currently have a background fill, allowing them
to provide background filling of the overall view with minimal overdraw
(ancestor views don't need to have any fill at all).
2023-07-05 19:33:00 +09:00
Bill Currie
a92754caf1 [ui] Free the label when freeing the state
Plugs a memory leak.
2023-07-04 17:24:45 +09:00
Bill Currie
104fba13a6 [ui] Add a text color component
Despite the current rendering API taking only byte color, the component
holds a uint32_t to allow for rgba color when I figure out a suitable
API.
2023-07-04 17:17:16 +09:00
Bill Currie
7e338b7e29 [ecs] Delay calculation of last index
Removing a hierarchy from an entity can result in a large number of
component removes in the same pool, thus changing index of the lest
element of the pool. This *seems* to fix the memory corruption I've been
experiencing with the debug UI.
2023-07-04 16:37:09 +09:00
Bill Currie
71bc708030 [ecs] Use nullindex for hierarchy indices
Even though nullindex and nulent have the same value, they have very
different meanings (and I might shift to 0 for nulent).
2023-07-04 14:43:20 +09:00
Bill Currie
5000004f7d [util] Integrate sys_mem into the build
Nicely, all that was needed was a couple of includes and renaming the
functions.
2023-07-04 14:39:36 +09:00
Bill Currie
d9362e81ae [util] Add functions to get the memory usage
Found on stackexchange
(https://stackoverflow.com/questions/669438/how-to-get-memory-usage-at-runtime-using-c)
but written by David Robert Nadeau. Currently unmodified (so changes
can be tracked properly).
2023-07-04 12:49:05 +09:00
Bill Currie
403cf72f52 [ui] Implement a layout stack and radio buttons
Also, remove an intermittent double free caused by deleting views that
have already been deleted.
2023-07-04 01:31:04 +09:00
Bill Currie
6fa016e23b [vulkan] Delay main render resizes by 2s
This makes window resizing a little more responsive (though it could be
better yet (maybe, could be an X11 limitation)).
2023-07-03 23:38:57 +09:00
Bill Currie
e37b477739 [ui] Implement checkbox
Simplistic, but it works. Also cleaned up some of the repetitive code.
2023-07-03 23:33:15 +09:00
Bill Currie
cd4791c5d3 [vulkan] Get window resize working again
The biggest change was splitting up the job resources into
per-render-pass resources, allowing individual render passes to
reallocate their resources without affecting any others. After that, it
was just getting translucency and capture working after a window resize.
2023-07-03 20:05:27 +09:00
Bill Currie
45e09673c7 [vulkan] Increase (and unify) va context count
The increase wasn't really necessary, but I noticed that windows was
still at 4... not so good.
2023-07-03 19:53:53 +09:00
Bill Currie
76b110bf0b [ui] Fix use of an uninitialized pointer
I had forgotten that Hash_NewTable checked the hashctx parameter, so
calling Hash_NewTable in the struct initializer meant the hasctx was
uninitialized.
2023-07-03 16:35:51 +09:00
Bill Currie
6d823cca84 [ui] Rebuild the hierarchy every frame
This takes care of element order stability. It did need reworking the
mouse tracking code (including adding an active flag to views), but now
buttons seem to work correctly.
2023-07-03 03:52:07 +09:00
Bill Currie
0b6e8b60bd [ecs] Add a component rotation function
This allows rotation of components within the array. I'm not sure if
it's what I want, but it was an interesting exercise anyway.
2023-07-03 01:40:26 +09:00
Bill Currie
4471a40494 [vulkan] Get the forward renderer passing validation
It looks horrible due to the lack of lighting etc, but it's good enough
for basic testing, especially of my render job design (that passed with
flying colors).
2023-07-02 19:58:56 +09:00
Bill Currie
260a10d75c [vulkan] Add a very basic forward rendering pass
It's not fully compliant yet, but it sorta kinda maybe worked on my
pinebook (still slow, but no hardware vulkan :( )
2023-07-02 18:31:22 +09:00
Bill Currie
a6a0b6cb63 [ui] Use View_Delete to delete the view
It's there for a reason :P. Fixes most of the really bad behavior after
disabling some widgets (re-layout isn't working at all, though, and
adding the widgets back again puts them in the wrong place).
2023-07-02 16:40:05 +09:00
Bill Currie
7c17921277 [ui] Remove view from hash table when pruning
Fixes a segfault after removing some widgets. Otherwise, it seems
pruning is working.
2023-07-02 16:10:27 +09:00
Bill Currie
3aceccf4aa [ui] Use the same key algorithm for Hash_Find
Using label + key_offset in both imui_state_getkey and the call to
Hash_Find greatly simplifies the logic of using the correct key. Fixes
an ever-growing set of buttons when using separators (hmm, I think this
means pruning isn't working correctly).
2023-07-02 15:14:21 +09:00
Bill Currie
68e155448d [ui] Position text correctly in its view
It turns out text positioning was a little more complicated than I
remembered. The Y offset is relative to the baseline with Y going down.
2023-07-02 15:11:11 +09:00
Bill Currie
e98cd1355d [ui] Implement auto-layout
TextContent seems redundant at this stage since a text view is always
sized to its content, and PercentOfParent doesn't work yet. Pixels
definitely works and Null seems to work in that it does no sizing or
positioning. Vertical layout is supported but not yet tested, similar
for ChildrenSum, but I can have two buttons side by side.
2023-07-02 15:04:22 +09:00
Bill Currie
153958a51f [ui] Clean up unused view states before drawing
Used states are tracked by simply updating their last-used frame count
and any that don't match the current frame count when drawing are
deleted.
2023-07-02 12:12:03 +09:00
Bill Currie
85fd3c34cc [ui] Set text view height to font height
Text_StringView sets the view bounds to the bounds of the glyphs in the
view. This has its advantages, but is not suitable for automatic UI
sizing. However, the view is positioned correctly, so nothing needs to
be done there. Now full height glyphs (eg, C) look balanced in the view,
and glyphs with descenders (g) brush the bottom of the view.
2023-07-02 03:02:13 +09:00
Bill Currie
ed5ef3a5fb [ui] Implement event handling in imui
Button presses work nicely thanks to both Casey Muratori and Darian (for
clearing up some of Casey's comments about `hot`).
2023-07-02 01:25:27 +09:00
Bill Currie
5099633bc8 [console] Start work on a debug UI
It does almost nothing (just puts a non-function button on the screen),
but it will help develop the IMUI code and, of course, come to help with
debugging in general.
2023-07-01 20:00:26 +09:00
Bill Currie
0257165b7d [ui] Add the beginnings of an immediate mode UI
Based on the articles on Hidden Grove
(https://www.rfleury.com/archive?sort=new). So far, I can get a
non-functional button on the screen :)
2023-07-01 19:55:19 +09:00
Bill Currie
4eef11c329 [ui] Add visibility control to canvases 2023-07-01 19:53:26 +09:00
Bill Currie
c1cd81222d [ui] Add font text drawing to canvas
Both passage and simple text are supported, but only simple text has
been tested at this stage. However, as passage text was taken directly
from rua_gui.c and formed the basis for simple text rendering, I expect
it's at least close to working.
2023-07-01 19:49:49 +09:00
Bill Currie
32346b6123 [ui] Add support for simple text strings
The same underlying mechanism is used for both simple text strings and
passages, but without the intervening hierarchy of paragraphs etc.
Results in only the one view for a simple text string.
2023-07-01 19:42:02 +09:00
Bill Currie
5fcc743d1a [ui] Use fontconfig to find system fonts
I'm not sure I like fontconfig (docs are...), but it is pretty standard,
and I was able to find some reasonable examples on stackexchange
(https://stackoverflow.com/questions/10542832/how-to-use-fontconfig-to-get-font-list-c-c).
Currently, only the one font is handled, no font sets for fall backs
etc. It's meant for the debug UI I'm working on, so that shouldn't be a
big deal.
2023-07-01 19:15:22 +09:00
Bill Currie
31151ec5d5 [ui] Rename Text_View to Text_PassageView
It works with passages but I want to be able to create simple text views
from strings, so Text_View was kind of polluting the namespace.
2023-07-01 14:40:20 +09:00
Bill Currie
09f257cdcb [cexpr] Fix bool printing and support int casts
Strangely, valid pointers are always true. Also, bool now accepts 0 for
false and non-0 for true (doing a proper conversion to bool).
2023-06-30 21:48:22 +09:00
Bill Currie
0b0271ee76 [console] Provide control of cursor visibility
It's usually desirable to hide the cursor when playing quake, but when
using the console, or in various other states, being able to see the
cursor can be quite important.
2023-06-30 14:57:04 +09:00
Bill Currie
759e67bb7c [x11] Implement mouse visibility control
That was nicely easy.
2023-06-30 14:53:47 +09:00
Bill Currie
ec0c6ad906 [vid] Add an api function to control mouse visibility
It's currently very simplistic (visible, not visible), but it gets
things started for making QF more usable in a windowed environment (not
having a visible cursor was fine in DOS, or when full screen, but not
when windowed (and not actively playing).
2023-06-30 14:50:47 +09:00
Bill Currie
c834516c3c [vulkan] Drop the id buffer for now
I've decided to just get things working the usual way for now, and I
wasn't too happy about mixing the id writing into irrelevant shaders.
2023-06-30 12:19:46 +09:00
Bill Currie
e2b6e0728e [vulkan] Render object id to a buffer
Currently the instance id is written (with the idea that it can be
mapped back to entity in C). The plan is to use it for mouse picking.
2023-06-30 03:34:16 +09:00
Bill Currie
d45b76313c [vulkan] Use correct type for parsing int32
Using size_t doesn't work too well for -1.
2023-06-30 03:31:52 +09:00
Bill Currie
665d88c353 [vulkan] Default a view's format to that of its image
Just one less thing to duplicate.
2023-06-30 03:03:21 +09:00