Commit graph

6083 commits

Author SHA1 Message Date
Bill Currie
3b0dcd2cdc [vulkan] Connect the shadow pass to the renderers
It's only partially complete, but R_VisitWorldNodes is now run for both
the main pass and the shadow auxiliary pass.
2023-07-27 16:09:33 +09:00
Bill Currie
123bf14784 [scene] Add a leaf component to lights
Regular leaf number for positional lights, 0 for directional, and ~0 for
ambient.
2023-07-27 15:50:53 +09:00
Bill Currie
2790972cb0 [renderer] Separate core of R_MarkLeaves
I needed to mark leaves based on an arbitrary PVS (for lighting) that is
independent of the camera position. Also cleaned up some const
correctness.
2023-07-27 15:43:47 +09:00
Bill Currie
f7fce957e8 [renderer] Boost R_MarkLeaves very slightly
Using set iterators can be quite a lot faster for sparse sets due to the
function call overhead in testing each element. Times for ad_tears
dropped from about 1200us to about 670us (hard to say due to there being
only 3 data points and a lot of noise in the time).
2023-07-25 15:22:45 +09:00
Bill Currie
1f99f89a4a Fix some printf portability issues 2023-07-25 15:07:17 +09:00
Bill Currie
6c631693bd [vulkan] Clean out old command buffers from bsp
Missed from the render job cleanup.
2023-07-24 19:13:43 +09:00
Bill Currie
f4d6a41901 [vulkan] Hook up a shadow render job step
It doesn't do much yet, but did help in getting light ids working.
2023-07-24 19:13:43 +09:00
Bill Currie
05f0fe9204 [scene] Add a render-internal lightid component
The vulkan shadow code needs to associate extra information with the
lights, but I don't want such renderer-specific data in the scene.
2023-07-24 19:11:18 +09:00
Bill Currie
faa2245220 [vulkan] Correct dummy field name for labeledsingle
I didn't realize why labeledsingle had problems because most of the uses
where where the names were the same.
2023-07-24 19:11:18 +09:00
Bill Currie
2fa44c03a6 [vulkan] Allow process steps to have render or compute
If a step has process tasks, any render or compute
pipelines/renderpasses are **not** run automatically: the idea is the
process tasks need to run the relevant pipelines in a custom manner but
needs the objects to be created.
2023-07-24 19:11:18 +09:00
Bill Currie
31cf3ed248 [vulkan] Register external attachments
This is along the lines of what I originally intended, but now I need
more than just the swapchain (which is now registered by vulkan_output).
2023-07-24 19:11:18 +09:00
Bill Currie
35540dfc79 [vulkan] Correct bsp stage/pass parameters
While it doesn't affect the operation, it does affect the readability of
the code because pass is meant for mainpass vs the multiple shadow
passes.
2023-07-24 19:11:18 +09:00
Bill Currie
07d9749b53 [renderer] Don't clear efrags in SCR_NewScene
The recent light changes highlighted that the renderer does not own the
efrags (segfault in qwaq when shutting down my test scene). After
digging through the history of efrag clearing, it turns out that the
renderer never owned them, I just didn't understand the concept of
scenes at the time that I moved efrags into the renderer.
2023-07-23 00:55:31 +09:00
Bill Currie
9e1810a2a9 [vulkan] Get shadow map image creation working again
The switch to using the ECS for lights temporarily broke the generation
of the images, but getting things going again was fairly easy.
2023-07-22 22:41:05 +09:00
Bill Currie
7280e1d042 [scene] Limit light efrags to leafs within range
This makes a pretty significant difference: 8-25% for demo1, demo2,
demo3 and bigass1. Many thanks to Nick Alger
(https://stackoverflow.com/questions/5122228/box-to-sphere-collision).
It took me a moment to recognize that it's the Minkowski difference (and
maybe GJK?). Of course, I adapted it for simd.
2023-07-22 20:08:15 +09:00
Bill Currie
72f6048a20 [scene] Put lights into the bsp tree via efrags
This eliminates the O(N^2) (N = map leaf count) operation of finding
visible lights and will later allow for finer culling of the lights as
they can be tested against the leaf volume (which they currently are
not as this was just getting things going). However, this has severely
hurt ad_tears' performance (I suspect due to the extreme number of
leafs), but the speed seems to be very steady. Hopefully, reconstructing
the vis clusters will help (I imagine it will help in many places, not
just lights).
2023-07-22 17:53:07 +09:00
Bill Currie
c0f8d102ad [scene] Implement Scene_FreeAllEntities (and use it)
I guess I wasn't sure how to find all the allocated entities from within
the registry, but it turned out to be trivial. This takes care of leaked
static entities (and, in a later commit, leaked light entities, which is
how I found the problem).
2023-07-22 16:50:18 +09:00
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