Commit graph

5685 commits

Author SHA1 Message Date
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