Commit Graph

2409 Commits

Author SHA1 Message Date
Bill Currie de786ce197 [scene] Use hierref_t instead of transform_t in hierarchy
Hierarchies are now much closer to being more general in that they are
not tied to 3d transforms. This is a major step to moving the whole
entity/transform system into an ECS.
2022-10-22 13:04:07 +09:00
Bill Currie b607fe0878 [scene] Add has/get component functions
And define nullent as 0 is a valid entity.
2022-10-21 19:12:20 +09:00
Bill Currie 6189142c60 [renderer] Remove rglyph_t struct
It didn't really add anything of value as the glyph bitmap rects and the
bearings were never used together, and the rest of the fields were
entirely redundant. A small step towards using a component system for
text.
2022-10-20 15:50:53 +09:00
Bill Currie 06ccc3023b [scene] Start work on a full-on ECS system
That does feel a little redundant, but I think the System in ECS is
referring to the systems that run on the components, while the other
system is the support code for the ECS. Anyway...

This is based heavily on the information provided by @skipjack in his
github blog about EnTT. Currently, entity recycling and sparse arrays
for component pools have been implemented, and adding components to an
entity has been tested.
2022-10-16 18:29:25 +09:00
Bill Currie 0c54b0652b Abandon support for clang
The inconsistencies in clang's handling of casts was bad enough, and its
silliness with certain extensions, but discovering that it doesn't
support raw strings was just too much. Yes, it gives a 3s boost to qfvis
on gmsp3v2.bsp, but it's not worth the hassle.
2022-10-16 18:02:25 +09:00
Bill Currie 8ec4a18f5d [scene] Swtich from - to ~ for entity id index
It saves only 1 bit in the set, but it could save on allocations. Also
takes care of a FIXME :P
2022-10-15 14:48:39 +09:00
Bill Currie 6552d76a5f Clarify FIXME on qdefs.h include 2022-10-15 14:42:04 +09:00
Bill Currie 2c9da25e17 Clean up some FIXMEs and XXXs
They seemed to be generally unnecessary. Also fixes some typos in
related comments.
2022-10-15 14:40:29 +09:00
Bill Currie 8464d71264 [scene] Move hierarchies to an ECS-based system
This is the beginning of adding ECS to QF. While the previous iteration
of hierarchies was a start in the direction towards ECS, this pulls most
of the 3d-specific transform stuff out of the hierarchy "objects",
making all the matrices and vectors/quaternions actual components (in
the ECS sense). There's more work to be done with respect to the
transform and entity members of hierarchy_t (entity should probably go
away entirely, and transform should become hierref_t (or whatever its
final name becomes), but I wanted to get things working sooner than
later.

The motivation for the effort was to allow views to use hierarchy_t,
which should be possible once I get entity and transform sorted out.

I am really glad I already had automated tests for hierarchies, as
things proved to be a little tricky to get working due to forgetting why
certain things were there.
2022-10-10 02:00:33 +09:00
Bill Currie f16fc15605 [scene] Correct some typos in hierarchy.h
Lost the y somewhere
2022-10-09 01:08:48 +09:00
Bill Currie c9e7810864 [vulkan] Add resource memory offset to qfv_resobj_s
Its value on input is ignored. QFV_CreateResource writes the resource
object's offset relative to the beginning of the shared memory block.
Needed for the Draw overhaul.
2022-10-03 09:14:29 +09:00
Bill Currie c028e15943 [vulkan] Add a couple of staging helper functions
I got tired of writing the same 13 or so lines of code over and over (it
actually put me off experimenting with Vulkan). Thus...

QFV_PacketCopyBuffer does the work of handling barriers and a (full
packet) copy from the staging buffer to a GPU buffer.

QFV_PacketCopyImage does a similar job, but for images. However, it
still needs a lot of work, but it does make getting a basic texture onto
the GPU much less of a hassle.

Both functions should make staging data much less error-prone.
2022-10-03 09:09:34 +09:00
Bill Currie 51b73eee73 [renderer] Add fontid to Draw_AddFont and Draw_FontString
It's not used yet, but the vulkan draw implementation will eventually
support multiple fonts being loaded (and rendered at a time).
2022-10-03 09:01:54 +09:00
Bill Currie 0352af4542 [vulkan] Initialize resource image from tex_t
This moves the qfv_resobj_t image initialization code from the IQM
loader into the resource management code. This will allow me to reuse
the code for setting up glyph data. As a bonus, it cleans up the IQM
code nicely.
2022-10-02 20:45:20 +09:00
Bill Currie 9798400cfb [ui] Add a sub-system for parsing text passages
A passage object has a list of all the text objects in the given string,
where the objects represent either white space or "words", as well as a
view_t object representing the entire passage, with paragraphs split
into child views of the passage view, and each paragraph has a child
view for every text/space object in the paragraph.

Paragraphs are split by '\n' (not included in any object).

White space is grouped into clumps such that multiple adjacent spaces
form a single object. The standard ASCII space (0x20) and all of the
Unicode characters marked "WS;<compat> 0020" are counted as white space.
Unless a white space object is the first in the paragraph, its view is
marked for suppression by the view flow code.

Contiguous non-white space characters are grouped into single objects,
and their views are not suppressed.

All text object views (both white space and "word") have their data
pointer set to the psg_text_t object representing the text for that
view. This should be suitable for simple text-mode unattributed display.
More advanced rendering would probably want to create suitable objects
and set the view data pointers to those objects.

No assumption is made about text direction.

Passage and paragraph views need to have their primary axis sizes set
appropriately, as well as their resize flags. Their xlen and ylen are
both set to 10, and xpos,ypos is 0,0. Paragraph views need their
setgeometry pointer set to the appropriate view_flow_* function.
However, they are set up to have their secondary axis set automatically
when flowed.

Text object views are set up for automatic flowing: grav_flow, 0,0 for
xpos,ypos. However, xlen and ylen are also both 0, so need to be set by
the renderer before attempting to flow the text.
2022-09-30 19:51:14 +09:00
Bill Currie a24fb0ff6a [ui] Add option to auto-fit container to flowed views
Adjusting the size of the parent (container) view to the views it
contains will be useful for automatic layout and knowing how large the
view is for scrolling. New tests added so testing both with and without
the option is still possible.
2022-09-30 11:59:21 +09:00
Bill Currie ec64bd8e20 [ui] Add documentation for the flow functions 2022-09-30 11:28:54 +09:00
Bill Currie 378584f41d [ui] Add functions for flow-based automatic layout
This should be suitable for laying out text objects with word-wrap,
where each view is a "word" or break between "words". This should be
useful for any other objects that could benefit from similar layout
rules. All eight flows are supported left-right-top-down (English and
most European languages), right-left-top-down (Arabic and similar),
top-down-right-left (Chinese, Japanese, Korean), top-down-left-right,
as well as bottom-up variants of those four.

More work is needed for support of things like views being centered on
the flow line rather than on one edge (depends on flow direction),
offset views, and others. Suppression of "spaces" at the beginning of a
line is supported but not tested.
2022-09-29 23:54:12 +09:00
Bill Currie 31945c6e01 [ui] Rearrange fields in view_t slightly
Moving the flags bitfields up with the gravity field makes for better
packing in 64-bit builds.
2022-09-29 15:48:23 +09:00
Bill Currie 71e07e6454 [vulkan] Use vkCmdCopyImageToBuffer for screenshot capture
I had missed that vkCmdCopyImage requires the source and destination
images to have exactly the same size, and I guess assumed that the
swapchain images would always be the size they said they were, but this
is not the case for tiled-optimal images. However,
vkCmdCopyImageToBuffer does the right thing regardless of the source
image size.

This fixes the skewed screenshots when the window size is not a multiple
of 8 (for me, might differ for others).
2022-09-26 15:54:20 +09:00
Bill Currie 1d50940c2a [vulkan] Implement window resize support
There's a problem with screenshot capture in that the image is sheared
after window resize, but the screen view looks good, and vulkan is happy
with the state changes.
2022-09-26 13:04:56 +09:00
Bill Currie 0ecdd0e86b [vulkan] Rearrange init code in preparation for resizing
I've found and mostly isolated the parts of the code that will be
affected by window resizing, minus pipelines but they use dynamic
viewport and scissor settings and thus shouldn't be affected so long as
the swapchain format doesn't change (how does that happen?)
2022-09-26 09:52:14 +09:00
Bill Currie 20ee47404f Merge branch 'master' into wip-twod 2022-09-22 10:06:00 +09:00
Bill Currie aafb3c1d98 [vulkan] Partially document bsp rendering
This did involve changing some field names and a little bit of cleanup,
but I've got a better handle on what's going on (I think I was in one of
those coding trances where I quickly forget how things work).
2022-09-22 09:35:57 +09:00
Bill Currie 3e7f2f0578 Fix some doxygen issues
Updating parameter names for renamed parameters and adding docs for new
parameters.
2022-09-22 09:35:57 +09:00
Bill Currie 2a47a61bc3 [util] Add atomic ring buffer and automated tests
Just head and tail are atomic, but it seems to work nicely (at least on
intel). I actually had more trouble with gcc (due to accidentally
testing lock-free with the wrong ring buffer... oops, but yup, gcc will
happily optimize your loop to spin really really fast). Also served as a
nice test for C11 threading.
2022-09-22 09:35:57 +09:00
Bill Currie 035595dd7e [vulkan] Clean up bsp global access
This makes bsp traversal even more re-entrant (needed for shadows).
Everything needed for a "pass" is taken from bsp_pass_t (or indirectly
through bspctx_t (though that too might need some revising)).
2022-09-22 09:35:57 +09:00
Bill Currie 8e7474f614 [vulkan] Hook up the shadow map render pass
There are some issues with the light renderers getting mangled, and only
the first light is even touched (just begin and end of render pass), but
this gets a lot of the framework into place.
2022-09-22 09:35:57 +09:00
Bill Currie c58a2e5f54 [vulkan] Remove unused command buffer and fence 2022-09-22 09:35:57 +09:00
Bill Currie 71813af090 [vulkan] Support creating render passes with no render pass
Sounds odd, but it's part of the problem with calling two different
things with essentially the same name. The "high level" render pass in
question may be a compute pass, or a complex series of (Vulkan) render
passes and so won't create a Vulkan render pass for the "high level"
render pass (I do need to come up with a better name for it).
2022-09-22 09:35:57 +09:00
Bill Currie 3058a5103f [renderer] Move entity drawing in with view rendering
I really don't remember why I made it separate, though it may have been
to do with r_ent_queue. However, putting it together with the rest is
needed for the "render pass" rework.
2022-09-22 09:35:57 +09:00
Bill Currie 5e1ce5b46e [vulkan] Move main render pass setup to Vulkan_Main
And support sorting of render passes by an order index.
2022-09-22 09:35:57 +09:00
Bill Currie 3b72c9847a [vulkan] Add list of views to qfv_output_t
I'm not sure I like it, but it was an easy solution to dealing with
per-frame views when setting up a renderpass that has a framebuffer
spec.
2022-09-22 09:35:57 +09:00
Bill Currie 3603fa75cd [vulkan] Make Vulkan_CreateRenderPass more generally useful
It now lives in vulkan_renderpass.c and takes most of its parameters
from plist configs (just the name (which is used to find the config),
output spec, and draw function from C). Even the debug colors and names
are taken from the config.
2022-09-22 09:35:56 +09:00
Bill Currie 08f33d2f3a [vulkan] Rename the renderpass files
I plan on moving the current hard-coded render pass creation from
vulkan_vid_common and this maintains the (possibly silly) naming
convention).
2022-09-22 09:35:56 +09:00
Bill Currie 6a7c2cb2a1 [vulkan] Clean out the old render pass creation code
QFV_CreateRenderPass is no longer used, and QFV_CreateFramebuffer hasn't
been used for a long time. The C file is still there for now but is
basically empty.
2022-09-22 09:35:56 +09:00
Bill Currie f04108ae3e [vulkan] Switch to using vkGetPhysicalDeviceProperties2
Necessary for getting VkPhysicalDeviceMultiviewProperties (and others,
but not at this time).
2022-09-22 09:35:56 +09:00
Bill Currie 125821fcdd [render] Add basic 2d line drawing
The software renderer uses Bresenham's line slice algorithm as presented
by Michael Abrash in his Graphics Programming Black Book Special Edition
with the serial numbers filed off (as such, more just so *I* can read
the code easily), along with the Chen-Sutherland line clipping
algorithm. The other renderers were more or less trivial in comparison.
2022-09-22 09:35:56 +09:00
Bill Currie 3603f90718 [vulkan] Implement BSP surface transparency
Surfaces marked with SURF_DRAWALPHA but not SURF_DRAWTURB are put in a
separate queue for the water shader and run with a turb scale of 0.
Also, entities with colormod alpha < 1 are marked to go in the same
queue as SURF_DRAWALPHA surfaces (ie, no SURF_DRAWTURB unless the
model's texture indicated such).
2022-09-22 09:31:04 +09:00
Bill Currie a936336e84 [model] Support the transparent texture marker
Textures whose names start with a { are meant to be rendered with
transparency. Surfaces using those textures are marked with
SURF_DRAWALPHA.

Unfortunately, the mip levels of ad_tears' transparent textures use the
wrong color so only the highest LOD works properly, but those textures
are meant to be loaded from external files anyway, it seems.
2022-09-22 09:31:04 +09:00
Bill Currie d149457241 [vid] Add a listener for window size changes
A listener is used instead of (really, as well as) ie_app_window events
because systems that need to know about windows sizes may not have
anything to do with input and the event system.
2022-09-22 01:07:54 +09:00
Bill Currie fdfdf9056a [renderer] Add function to destroy frame buffers
Needed for window resizing for fisheye and warp buffers (main buffers
will be taken care of by the drivers).
2022-09-21 23:47:14 +09:00
Bill Currie 4578b1af0d [vid] Remove console view from viddef_t
This breaks console scaling for now (con_width and con_height are gone),
but is a major step towards window resize support as console stuff
should never have been in viddef_t in the first place.

The client screen init code now sets up a screen view (actually the
renderer's scr_view) that is passed to the client console so it can know
the size of the screen. The same view is used by the status bar code.

Also, the ram/cache/paused icon drawing is moved into the client screen
update code. A bit of duplication, but I do plan on merging that
eventually.
2022-09-21 17:31:18 +09:00
Bill Currie 230e23db5d [console] Update a little for event handling
Con_CheckResize is no longer necessary thanks to the ie_app_window
event, and the client doesn't need C_ProcessInput so that is now
optional.
2022-09-21 12:13:06 +09:00
Bill Currie 8be5d35b0d [ui] Add support for setting view data early
view_new sets the geometry, but any setgeometry that need a valid data
pointer would get null. It might be better to always have the data
pointer, but I didn't feel like doing such a change at this stage as
there are quite a lot of calls to view_new. Thus view_new_data which
sets the data pointer before calling setgeometry.
2022-09-21 11:53:49 +09:00
Bill Currie 1fdedbaf33 [renderer] Report scrap rectangle counts
Stats are good. More stats even better :) I wanted to see just how many
lightmaps were being created in e1m3.
2022-09-20 19:32:41 +09:00
Bill Currie 398405c8d6 [console] Remove old_console_t struct
This replaces old_console_t with con_buffer_t for managing scrollback,
and draw_charbuffer_t for actual character drawing, reducing the number
of calls into the renderer. There are numerous issues with placement and
sizing, but the basics are working nicely.
2022-09-20 16:14:55 +09:00
Bill Currie d6d45bf07c [console] Add a function to clear the scroll-back buffer
Needed for when the console display is cleared.
2022-09-20 12:14:01 +09:00
Bill Currie 474f01d321 [renderer] Return count of lines printed to char buffer
This allows users to know the number of terminated lines in the printed
text without having to redundantly count the lines.
2022-09-20 10:27:24 +09:00
Bill Currie 48e5848a41 [console] Rework con_buffer ring buffers to have gaps
I really don't know why I tried to do ring-buffers without gaps, the
code complication is just not worth the tiny savings in memory. In fact,
just the switch from pointers to 32-bit offsets saves more memory than
not having gaps (on 64-bit systems, no change on 32-bit).
2022-09-18 11:35:09 +09:00