Commit graph

14088 commits

Author SHA1 Message Date
Bill Currie
2e00fd1165 [ui] Pass a data pointer to update functions 2024-01-07 11:58:01 +09:00
Bill Currie
32c65294ba [ui] Use a view-relative anchor position for drags
With this, the mouse no longer stays disconnected from the dragged item
when the item can't move any further. It does show some interesting
behavior when window resizes don't behave, but it's still an
improvement.
2024-01-06 19:39:42 +09:00
Bill Currie
aa5dc657fd [ui] Add some basic math ops for view_pos_t
Just add and subtract, but I got tired of having to write two lines of
code for such.
2024-01-06 19:38:20 +09:00
Bill Currie
082d00b6c3 [ui] Use the shaped text cache for passage text
This makes a pretty significant difference (~520us down to 80us) for
simple text passage, and even the first time is fast due to word
repetition.
2024-01-06 02:59:31 +09:00
Bill Currie
ce7c2183d3 [ecs] Delay component destruction
Copy the component out of the pool so that it can be overwritten now,
thus removing it from the pool, before actually destroying the component
so that any recursive removals of the same component don't mess up the
indices, and also don't try to remove the component from the same
entity.

This fixes a rather sneaky component leak caused by said recursion.
2024-01-06 02:11:31 +09:00
Bill Currie
0307e9d165 [ui] Set all glyph views to be free-floating
This gets passage text working mostly nicely in IMUI: just some
ascender/descender issues.
2024-01-06 00:13:22 +09:00
Bill Currie
1ab68ca5fd [vulkan] Correct line vertex input spec
I suspect I may have done the incorrect offset for color to get a
gradient for some testing, but forgot to put it back. Or, of course, I
just completely and utterly brain-farted when writing the attribute.
2024-01-05 22:44:09 +09:00
Bill Currie
969678d53c [ui] Update passage paragraph vertical offsets
Descenders still cause problems for layout, but now the paragraphs are
no longer on top of each other. Also, the paragraph spacing is currently
hard-coded (but should be part of a style).
2024-01-05 17:30:44 +09:00
Bill Currie
4d0c1c66b3 [ui] Refresh hierarchy pointers
With the change to hierarchies being components, any pointers to the
hierarchy component are not stable and must be refreshed after the
possibility of adding or removing a hierarchy.
2024-01-05 16:34:18 +09:00
Bill Currie
c2316a4173 [ui] Add support for passage views to imui
It was a right cow to get working at all due to the tangled mess of
dependencies between different hierarchies (switching to hierarchies as
components helpt), but other that some vertical positioning (paragraphs
and descenders), it's working fairly well now (and fairly quick other
than I think I need to ensure the shaping cache is used).
2024-01-05 16:34:18 +09:00
Bill Currie
871d8729f5 [ruamoko] Free fonts on shutdown
I guess I had figured out how to free fonts sometime after writing
rua_gui.c.
2024-01-05 11:50:48 +09:00
Bill Currie
9b0589f7e5 [ruamoko] Add tracy zones
Mostly for tracking memory issues, but handy for seeing where time is
spent, of course.
2024-01-05 11:50:48 +09:00
Bill Currie
0ed4df3fb9 [quakeio] Rework Qgetline to use dstring
This clears up its stray memory allocation, and incidentally makes it
thread-safe.
2024-01-05 11:50:48 +09:00
Bill Currie
860f48d541 Clean up about 12000 allocations
Some of them were actual leaks, but tracking memory should be a lot
easier now. However, there's a lot of room for optimization of
allocations (eg, recylcling of hierarchies. There is now 1 active
allocation (according to tracy) when nq exits: Qgetline's string buffer
(I think an api change is in order).
2024-01-05 11:50:48 +09:00
Bill Currie
929b1f0662 [ui] Plug a memory leak and use-after-free in imui
The leak was due to forgetting to reset the links array, and
use-after-free needed running through the imui_reference pool to reset
any owning links.
2024-01-05 11:50:48 +09:00
Bill Currie
bfa7c1722a [build] Implement tracy memory zones
This proved to be quite the challenge, and is probably rather fragile,
but it does seem to work, and might help with tracking down memory
leaks.
2024-01-05 11:50:48 +09:00
Bill Currie
60c22e8fda [ecs] Make hierarchy ownership of entities optional
I'm not sure this is what I want.
2024-01-05 11:50:48 +09:00
Bill Currie
292e4ca132 [ecs] Pass the registry in to the component destroy function
This makes it possible for hierarchies to clean themselves up (by
deleting their entities (though that will cause other problems later
when the hierarchy doesn't own the entities)), thus plugging a memory
leak when parsing passage text.
2024-01-03 12:40:56 +09:00
Bill Currie
91dd9d3dfa [console] Clamp min charbuf size to 1x1
Prevents a segfault when the window is ultra-tiny (eg, 80x45 pixels)
2024-01-03 12:39:54 +09:00
Bill Currie
dfcad353fb [vulkan] Free the alias model resource block
I forgot to do so when switching to using resource (plugs a leak).
2024-01-03 12:39:54 +09:00
Bill Currie
f5ebc1083f [ecs] Pass the registry in to the component destroy function
This makes it possible for hierarchies to clean themselves up (by
deleting their entities (though that will cause other problems later
when the hierarchy doesn't own the entities)), thus plugging a memory
leak when parsing passage text.
2024-01-03 12:39:54 +09:00
Bill Currie
35eec0b2e5 [ecs] Implement hierarchies as components
The main goal of this change was to make it easier to tell when a
hierarchy has been deleted, but as a side benefit, it got rid of the use
of PR_RESMAP. Also, it's easy to track the number of hierarchies.

Unfortunately, it showed how brittle the component side of the ECS is
(scene and canvas registries assumed their components were the first (no
long the case), thus the sweeping changes).

Centerprint doesn't work (but it hasn't for a while).
2024-01-02 16:38:01 +09:00
Bill Currie
fc9c2fa544 [ui] Add a function to get root view from any view
This proved useful with canvas references.
2023-12-31 14:39:14 +09:00
Bill Currie
6b2bd02b14 [ui] Add a canvas reference component
It's used for finding the entity that has the actual canvas component
attached. Useful for sharing a single canvas between multiple view
hierarchies, and worked as a proof of concept for doing similar with
hierarchy references, and might work for properly destroying canvas
items (fills etc) when a view entity is deleted (if attached to every
view).
2023-12-31 14:15:05 +09:00
Bill Currie
9a74fb0a14 [ecs] Add basic entity and registry printing
Entities print their status and attached component names, registries
print their component counts for each pool.
2023-12-31 14:08:01 +09:00
Bill Currie
f5de553949 [ui] Take passage view parent parameter
I'm not sure this will be useful in imui, but it might in a retained
mode UI.
2023-12-28 16:43:31 +09:00
Bill Currie
f4f81db440 [ui] Free any preexisting passage glyphs
This plugs a memory leak in Text_PassageView.
2023-12-28 16:40:26 +09:00
Bill Currie
dc8ee14f50 [ruamoko] Use a single dstring for (v)sprintf
Rather than creating and destroying one every call. Didn't make any real
difference to the memory leaks, but it should make the calls
fractionally faster and reduce fragmentation.
2023-12-28 16:31:00 +09:00
Bill Currie
0a7042f318 [sys] Don't use va_copy in Sys_Error
It shouldn't be necessary since Sys_Error can restart args itself.
2023-12-28 16:11:06 +09:00
Bill Currie
4c704e9a2e [ecs] Give registries a name
This makes debugging a little easier when there are multiple ECS
registries. Currently, the name parameter must be a stable pointer.
2023-12-28 16:08:40 +09:00
Bill Currie
1a5b421933 [ruamoko] Share registry between gui and imui
I can't say I like there being a hard-coded registry, but gui and imui
need to agree on all aspects of the ECS registry they use.
2023-12-28 16:06:47 +09:00
Bill Currie
6b6c91e993 [alsa] Fix a missing \n in a message
I guess I had thought it was Sys_Error instead of Sys_Printf (or maybe I
changed it).
2023-12-27 16:05:24 +09:00
Bill Currie
d5b0a51b6e [dstring] Use va_copy correctly
Every use of va_copy needs a corresponding call to va_end. I had somehow
missed that when getting _dvsprintf to work properly. This seems to plug
a memory leak (certainly doesn't make things worse).
2023-12-27 16:03:05 +09:00
Bill Currie
75171743a4 [ecs] Destroy component pools in reverse order
This seems to be the best solution for interlinked entities/components,
the idea being that components with higher indices can "own" those with
lower (eg, imui_reference can "own" a view_href, but not the other way)
and makes it relatively easy to manage (components that can own others
get added to the registry later), and might even allow validation at a
later stage.
2023-12-26 11:10:07 +09:00
Bill Currie
767f4ff02e [ui] Plug a hierarchy reference leak
I'm not entirely sure what's going on yet, but deleting the referenced
view via its entity rather than the view results in a corrupted href in
the component pool (with a null entity id in the dense array) and then
an href component leak (as well as some very weird numbers when dumping
canvas bounds). I suspect Hierref_DestroyComponent is missing a few
steps (though I do need to verify that it's getting called in this
particular case).
2023-12-24 02:22:46 +09:00
Bill Currie
dd11a7b378 [vulkan] Apply 2d scale to clipping bounds
It was a little off-putting getting an incorrectly clipped console when
using non-unitary scale (especially since I was trying to show abbator
something).
2023-12-24 02:14:24 +09:00
Bill Currie
101c50e3e1 [ui] Sort out most of the nested canvas layout issues
Draw order is now stable and sizing is mostly correct.
2023-12-23 19:25:30 +09:00
Bill Currie
a50c1d0f81 [ui] Implement nested canvases
This is for scroll boxes (the nesting of canvases is for the clipping
they provide). There are some issues with automatic layout, but this
gets things mostly working, in particular the management of the link
between hierarchies as a canvas is always the root of its hierarchy.
2023-12-23 14:36:57 +09:00
Bill Currie
6faa78eaa1 [ui] Change draw order from 16-bit to 32-bit
With the scroll box work I'm doing, I realized 16 bits is a little
cramped. Although I doubt it would be that much of a problem, switching
to 32 bits turned out to be free because of alignment.
2023-12-23 14:31:58 +09:00
Bill Currie
34f16e10e4 [ui] Correct the spelling of imui_size_t
Really, just a stale comment from when I first started down the imui
path.
2023-12-23 14:26:50 +09:00
Bill Currie
86326c8179 [ui] Clip rendering to canvas bounds
This causes minor problems when the window gets too small, but it will
allow for scrollable regions.
2023-12-22 18:27:23 +09:00
Bill Currie
00d9f039fc [vulkan] Set debug windows to auto_fit
I'd missed this earlier, thus the vulkan debug windows wound up a tad
small.
2023-12-22 18:25:04 +09:00
Bill Currie
7f1c20afa9 [ui] Implement window resizing
There are some rather iffy parts (windows can get too small), and the
drag bars are a little odd, but the concepts are working.
2023-12-22 18:22:21 +09:00
Bill Currie
650ea052ea [vulkan] Support clipping rectangles via scissor
Seems to work well. The other renderers have stubs because I don't feel
like implementing clipping for them. The gl and glsl wouldn't be too
difficult (need to handle the draw queues), but sw needs a fair bit of
work and I'm not sure it's worth the effort.
2023-12-22 18:17:09 +09:00
Bill Currie
f3eebae9bc [vulkan] Destroy the tracy GPU contexts
I had forgotten about doing so because I was doing my profiling without
validation layers.
2023-12-22 13:44:31 +09:00
Bill Currie
dc0b4880e3 [vulkan] Use VkValidationFeatureEnableEXT
It's currently unused as it does flag a pile of things I need to fix,
but I don't want to deal with them right now (though I have fixed a
few).
2023-12-22 12:29:59 +09:00
Bill Currie
1ca655c0d8 [ui] Clean up a lot of duplicate code
Much of the state handling was highly redundant (in particular, handling
entity and old_entity). This should make it easier to get dragable items
for window resizing.
2023-12-21 19:59:40 +09:00
Bill Currie
a300e2330d [ui] Make windows respect their size fields
If auto_fit is true, then the old behavior is retained.

This is actually better than the set size thing, but that's probably
still useful.
2023-12-21 19:57:02 +09:00
Bill Currie
f80f265a07 [ui] Support pixel sizing of im views
This will allow for user-controllable window sizes.
2023-12-21 17:02:59 +09:00
Bill Currie
4483368319 [ruamoko] Add bindings for imui
Things are a little clunky, but I've got a little window I can
manipulate in my test scene :)
2023-12-21 16:11:30 +09:00