Commit Graph

5154 Commits

Author SHA1 Message Date
Bill Currie 6b81a4b882 [renderer] Don't try to animate lightstyles that aren't there
Prevents a segfault when running the renderer via qwaq-x11.
2022-04-07 22:30:19 +09:00
Bill Currie f6541dbe3f [net] Remove client references from net_main
This is progress towards #23. There are still some references to
host_time and host_client (via nq's server.h), and a lot of references
to sv and svs, but this is definitely a step in the right direction.
2022-04-06 19:32:55 +09:00
Bill Currie 8f56f28ad7 [net] Use designated initializers for drivers
Not that I expect anything to change any time soon, but nice to have
the initializers explicitly named.
2022-04-06 18:46:28 +09:00
Bill Currie 3f575ab025 [win] Update for moved vulkan viewport
I forgot to do a windows test build.
2022-04-06 18:36:07 +09:00
Bill Currie 2798b5fd58 [vulkan] Use cached memory for the bsp index buffer
Since it is updated every frame, it needs to be as fast as possible for
the cpu code. This seems to make a difference of about 10us (~130 ->
~120) when testing in marcher. Not a huge change, but the timing
calculation was wrapped around the entire base world pass, so there was
a fair bit of overhead from bsp traversal etc.
2022-04-06 14:40:40 +09:00
Bill Currie b011f91018 [model] Clean up alias skin loading a little
The improved allocation overheads have been implemented for gl and sw,
and glsl no longer uses malloc. Using array textures will have to wait
as the current texture loading code doesn't support them.
2022-04-04 17:47:21 +09:00
Bill Currie e40f3f4f93 [model] Make alias skin loading a batch operation
Really, this won't make all that much difference because alias models
with more than one skin are quite rare, and those with animated skin
groups are even rarer. However, for those models that do have more than
one skin, it will allow for reduced allocation overheads, and when
supported (glsl, vulkan, maybe gl), loading all the skins into an array
texture (since all skins are the same size, though external skins may
vary), but that's not implemented yet, this just wraps the old one skin
at a time code.
2022-04-04 15:38:27 +09:00
Bill Currie f66df59c43 [vulkan] Use a template for the attachment desciptions 2022-04-03 13:15:30 +09:00
Bill Currie c8e299ca58 [vulkan] Use a template for the deferred attachment images
It's certainly much easier to read and see what's different between the
attachment.
2022-04-03 12:25:04 +09:00
Bill Currie d3d081ea0a [vulkan] Switch deferred opaque attachment to f16 rgb
While looking at the deferred attachment images with using a template in
mind, I noticed that the opaque attachment was using 8-bit color. The
problem is, it's meant to be HDRI with the compose pass crunching it
down to LDRI. Switching to 16-bit float does seem to have made a subtle
difference (hey, it's still quake data, not much HDRI in there).
2022-04-03 12:02:13 +09:00
Bill Currie 39e7c4a9b2 [vulkan] Use a template for the deferred image views
That certainly makes it nicer to work with large sets, and shows one way
to be careful with allocated resources: don't allocate them in the
inherited data and use a template that needs a few things filled in to
be valid. Also, it seems that overriding values in sub-structures "just
works" :)
2022-04-03 11:47:53 +09:00
Bill Currie eb4d566801 [vkparse] Add support for inheriting objects
It simply parses the referenced plist dictionary (via @inherit =
plist.path;) into the current data block, then allows the data to be
overwritten by the current plist dictionary. This may be a bit iffy for
any allocated resources, so some care must be taken, but it seems to
work nicely.
2022-04-03 11:11:28 +09:00
Bill Currie bbbdc41af3 [vulkan] Break render pass parsing away from swapchain
This allows a single render pass description to be used for both
on-screen and off-screen targets. While Vulkan does allow a VkRenderPass
to be used with any compatible frame buffer, and vkparse caches a
VkRenderPass created from the same description, this allows the same
description to be used for a compatible off-screen target without any
dependence on the swapchain. However, there is a problem in the caching
when it comes to targeting outputs with different formats.
2022-04-02 11:42:36 +09:00
Bill Currie 9892e571ce [vulkan] Move viewport and scissor into qfv_renderpass_t
This makes much more sense as they are intimately tied to the frame
buffer on which a render pass is working. Now, just the window width
and height are stored in vulkan_ctx_t. As a side benefit,
QFV_CreateSwapchain no long references viddef (now just palette and
conview in vulkan_draw.c to go).
2022-04-01 20:34:41 +09:00
Bill Currie 11e30583cf [vulkan] Switch to full screen triangle instead of quad
While I have trouble imagining it making that much performance
difference going from 4 verts to 3 for a whopping 2 polygons, or even
from 2 triangles to 1 for each poly, using only indices for the vertices
does remove a lot of code, and better yet, some memory and buffer
allocations... always a good thing.

That said, I guess freeing up a GPU thread for something else could make
a difference.
2022-04-01 19:50:41 +09:00
Bill Currie 03c403610d [vulkan] Safely ignore fisheye and water warp
I didn't like the abort (especially having pushed it to master). This
takes care of things until I can get them implemented properly
(hopefully soon).
2022-04-01 16:49:39 +09:00
Bill Currie 6bbbe4997b [vulkan] Invalidate mapped capture image memory
I think I had gotten lucky with captures not being corrupt due to them
being much bigger than all but the L3 cache (and then they're over 1/2
the size), so the memory was being automatically invalidated by other
activity. Don't want to trust such luck, though.
2022-04-01 16:19:10 +09:00
Bill Currie 42a03758c5 [vulkan] Remove redundant entity queue creation
I'd missed this when cleaning up entity queue creation for the other
renderers.
2022-04-01 15:26:51 +09:00
Bill Currie 6d0abd42bb [vulkan] Use host-cached memory for staging buffers
It makes a significant difference to level load times (approximately
halves them for demo1 and demo2). Nicely, it turns out I had implemented
the rest of the staging buffer code (in particular, flushing) correctly
in that it seems there's no corruption any of the data.
2022-04-01 15:14:56 +09:00
Bill Currie 78119aeb7a [gamecode] Clean up generated swizzle code 2022-04-01 02:14:05 +09:00
Bill Currie ddfacf61ee [qw] Get remote screen shots working again
Probably better than they ever have, really, since I think they were
broken for one renderer or another.
2022-04-01 02:04:24 +09:00
Bill Currie 86e95fc1d0 [vulkan] Use host-cached memory for captures
This takes simply reading the transfer buffer from about 400ms down to
about 3ms (for 1920x1080 rgba). PNG compression is now the bottleneck.
2022-04-01 01:01:53 +09:00
Bill Currie 790f62a209 [image] Make WritePNG take settings from tex_t
This means that a tex_t object is passed in instead of just raw bytes
and width and height, but it means the texture can specify whether it's
flipped or uses BGR instead of RGB. This fixes the upside down
screenshots for vulkan.
2022-04-01 01:01:53 +09:00
Bill Currie acffacc59b [renderer] Make screen capture support asynchronous operation
This fixes (*ahem*) the vulkan renderer segfaulting when attempting to
take a screenshot. However, the image is upside down. Also, remote
snapshots and demo capture are broken for the moment.
2022-04-01 01:01:53 +09:00
Bill Currie a29836cc2c [quakefs] Return QFile pointer from QFS_NextFile(name)
QFS_NextFilename was renamed to QFS_NextFile to reflect the fact it now
returns a QFile pointer for the newly created file (as well as the
name). This necessitated updating WritePNG to take a file pointer
instead of a file name, with the advantage that WritePNGqfs is no longer
necessary and callers have much more control over the creation of the
file.

This makes QFS_NextFile much more secure against file system race
conditions and attacks (at least in theory). If nothing else, it will
make it more robust in a multi-threaded environment.
2022-03-31 17:27:04 +09:00
Bill Currie 8cdabc8905 [quakefs] Reimplement QFS_NextFilename to be more secure
It's not there yet as it promptly closes the file and returns only the
filename (and then only the portion within the user's directory tree).
However, this worked nicely as a test for Sys_UniqueFile.
2022-03-31 16:44:19 +09:00
Bill Currie a35bfef24c [sys] Add a function to safely create a unique file
QF currently uses unique file names for screenshots and server-side
demos (and remote snapshots), but they're generally useful.
QFS_NextFilename has been filling this role, but it is highly insecure
in its current implementation. This is the first step to taking care of
that.
2022-03-31 16:44:19 +09:00
Bill Currie 14ad364e17 [gamecode] Document the tests that fail under clang
The tests fail due to differences in how clang and gcc treat floating
point to unsigned integral type conversions when the values overflow. It
wouldn't be so bad if clang was consistent with conversions to 32-bit
unsigned integers, like it seems to be with conversion to 64-bit
unsigned integers.

With this, the "get QF building with clang" mini-project is done and I
won't have to panic when someone comes to me and asks if it will work.
At worst, there'll be a little bit-rot.
2022-03-31 14:50:49 +09:00
Bill Currie d3afb0da50 [vulkan] Remove a dead function
I guess gcc missed it because it's inline.
2022-03-31 02:59:37 +09:00
Bill Currie dad17162bb [console] Rewrite the download progress indicator
It was a nasty mess of suspicious strncats and the like.
2022-03-31 02:57:38 +09:00
Bill Currie 8f6ee4f5ac [gl] Work aground clang not liking variable structs with followers
Really, it's an ugly hack made uglier, but I don't feel like dealing
with it right now.
2022-03-31 02:56:14 +09:00
Bill Currie d109571994 [gamecode] Use 64 byte alignment for most of progs memory
Only edicts themselves get a smaller alignment (4, 8 or 32 bytes,
depending on hardware and progs version). I didn't want to waste too
much memory on edict alignment for progs that don't need any better than
void *, but the zone really wants 64 bytes, and the stack might as well
have 64 bytes as well. Fixes a segfault when running v6 progs in a clang
build (clang got really agressive with simd in zone.c).
2022-03-31 02:51:05 +09:00
Bill Currie f601606ad7 [gamecode] Fix an enum cast warning
Harmless, but it doesn't hurt to make it explicit.
2022-03-31 02:50:03 +09:00
Bill Currie cdcf1a71ea [gamecode] use correct void for global_string
It seems gcc is a little fast and loose with 0 as a null vector.
2022-03-31 02:48:01 +09:00
Bill Currie 2f9df0f05b Work around some clang parsing issues
clang has no problem with labels crossing declarations, but it can't
cope with a declaration (or end of block) just after a label.
2022-03-31 02:44:58 +09:00
Bill Currie 5b3cd93fa3 [gamecode] Implement with more portably
clang doesn't support taking the address of a vector component. I was
just being lazy when I used a pointer when setting the base register.
2022-03-31 02:38:26 +09:00
Bill Currie 7a6ca0ebcb [simd] Use portable swizzles
gcc and clang have rather different swizzle builtins, but both do a nice
job of optimizing the intuitive initializer swizzle (I think gcc 8(?)
didn't do such a good job thus my use of __builtin_shuffle).
2022-03-31 02:25:33 +09:00
Bill Currie 7305406f46 [vulkan] Update labeled struct inits
I had used some legacy gcc extensions rather than standard C (clang
wasn't too happy about that).
2022-03-31 01:26:57 +09:00
Bill Currie b02e29ea89 [x11] Clear up some signed/unsigned ambiguity
I don't remember what gcc does with unsigned-int, but obviously clang
produces another unsigned, which is most definitely not wanted.
2022-03-31 00:34:40 +09:00
Bill Currie 68b133417b [net] Fix some logic precedence errors 2022-03-31 00:31:15 +09:00
Bill Currie 78089a0e99 [mode] Fix a sizeof error
I'm surprised that got past gcc, but it's nice clang caught it.
2022-03-31 00:30:00 +09:00
Bill Currie 38319d01b2 Fix some null pointer shenanigans
clang doesn't like anything but a bare 0 as null (and in some of the
cases, it was quite right: '\0' should not be treated as a null
pointer). And the crashers were just for paranoia and probably aren't
needed any more (kept for now, though).
2022-03-31 00:25:22 +09:00
Bill Currie 63e5655f68 Clean up some enum sanity checks
It seems clang defaults to unsigned for enums. Interestingly, gcc was ok
with the checks being either way. I guess gcc treats enums that *can* be
unsigned as DWIM.
2022-03-31 00:18:53 +09:00
Bill Currie db01650dac Update vec3_t/vec4f_t hacks to work with clang
Still work with gcc, of course, and I still need to fix them properly,
but now they're actually slightly easier to find as they all have vec_t
and FIXME on the same line.
2022-03-31 00:08:26 +09:00
Bill Currie a6df8ab995 [renderer] Move a couple functions to using vec4f_t
Makes for a few less FIXMEs and better consistency with vectors.
2022-03-30 23:53:30 +09:00
Bill Currie da42aaf423 [sound] Use vec4f_t for api functions
Fixes a few vec3_t/vec4f_t FIXMEs.
2022-03-30 23:42:38 +09:00
Bill Currie d35154ecf1 [vulkan] Clean up a lot of unnecessary includes
Too much copying of base files.
2022-03-30 15:54:07 +09:00
Bill Currie 495dd759f0 [renderer] Clean up FOV and viewport handling
Viewport and FOV updates are now separate so updating one doesn't cause
recalculations of the other. Also, perspective setup is now done
directly from the tangents of the half angles for fov_x and fov_y making
the renderers independent of fov/aspect mode. I imagine things are a bit
of a mess with view size changes, and especially screen size changes
(not supported yet anyway), and vulkan winds up updating its projection
matrices every frame, but everything that's expected to work does
(vulkan errors out for fisheye or warp due to frame buffer creation not
being supported yet).
2022-03-30 14:55:32 +09:00
Bill Currie 9fbd16be05 [renderer] Avoid infinite loop
If the entity didn't have a known model type, R_StoreEfrags would get
stuck in an infinite loop (fortunately, never actually happened. The
result of making it not call Sys_Error for unknown models)).
2022-03-30 11:06:46 +09:00
Bill Currie 3c86764eb2 [scene] Move entity_t etc into scene headers
I meant to do this a while ago but forgot about it. Things are a bit of
a mess in that the renderer knows too much about entities, but
eventually the renderer will know about only things to render (meshes,
particles, etc).
2022-03-29 14:43:38 +09:00