Commit Graph

12436 Commits

Author SHA1 Message Date
Bill Currie b480590d90 [qfcc] Treat long, ulong and ushort as math types
Not so sure about the value of treating ushort (and short) as a math
type, but long and ulong are definitely necessary.
2022-04-29 16:59:55 +09:00
Bill Currie 1da9fff3ae [qfcc] Simplify immediate value emission
This gets immediate values working for the new vector types.
2022-04-29 16:59:55 +09:00
Bill Currie 14545c37cf [qfcc] Merge printing of values into the one place
Having three very similar sets of code for outputting values (just for
debug purposes even) got to be a tad annoying. Now there's only one, and
in the right place, too (with the other value code).
2022-04-29 16:59:55 +09:00
Bill Currie 8ac53664d7 [simd] Rename VEC_TYPE to QF_VEC_TYPE
Makes it less likely to clash with anything (like qfcc's VEC_TYPE :P)
2022-04-29 16:59:55 +09:00
Bill Currie 1eb8b61b83 [qfcc] Clean up handling of value expressions
I'd created new_value_expr some time ago, but never used it...
Also, replace convert_* with cast_expr to the appropriate type (removes
a pile of value check and create code).
2022-04-29 16:59:55 +09:00
Bill Currie 04f60e5ff1 [qfcc] Rework vector expression handling
Use with quaternions and vectors is a little broken in that
vec4/quaternion and vec3/vector are not the same types (by design) and
thus a cast is needed (not what I want, though). However, creating
vectors (that happen to be int due to int constants) does seem to be
working nicely otherwise.
2022-04-29 16:59:55 +09:00
Bill Currie 85d851572f [qfcc] Implement constant casts for the new vector types
Nicely, I was able to reuse the generated conversion code used by the
progs engine to do the work in qfcc, just needed appropriate definitions
for the operand macros, and to set up the conversion code. Helped
greatly by the new value load/store functions.
2022-04-29 16:59:55 +09:00
Bill Currie ae0b3a5870 [qfcc] Add some utility functions for working with vector types
Finding vector types from base type and width, and getting the base type
for a vector type, as well as basic promotion rules for math types.
2022-04-29 16:59:15 +09:00
Bill Currie c120bf2940 [qfcc] Add functions to store and load values
This makes working with constant expressions much less tedious,
especially when the relevant code needs to work with many types.
2022-04-29 16:59:15 +09:00
Bill Currie 875c9bde7c [gamecode] Print operand widths when not 1
The widths for all three operands are printed if any is greater than 1.
Makes figuring out which instruction is executing a little easier.
2022-04-29 16:59:15 +09:00
Bill Currie 73d6e97e7b [qwaq] Ensure PR_Init_Cvars is called only once
Registering the same cvar more than once is currently a fatal error, but
qwaq was calling PR_Init_Cvars for each thread. Oops.
2022-04-29 16:59:15 +09:00
Bill Currie 67bdbc6f7a [qfcc] Split out vector expression code
I plan on extending it for the new vector types and expr.c is just too
big to work in nicely.
2022-04-29 16:59:15 +09:00
Bill Currie 8912c65029 [qfcc] Indicate type width in type strings
Makes for much more informative error messages for type mismatches
(confusing when both sides look the same).
2022-04-29 16:59:15 +09:00
Bill Currie af2dfde37a [gamecode] Support printing 64-bit integer types
The 'l' modifier always means 64-bit, regardless of the underlying
platform. As well, the 32-bit integer types are handled portably too.
2022-04-29 16:59:15 +09:00
Bill Currie 71ae7aac4a [gamecode] Add macros for long and ulong 2022-04-29 16:59:15 +09:00
Bill Currie 6d62e91ce7 [gamecode] Clean up progs data access
pr_type_t now contains only the one "value" field, and all the access
macros now use their PACKED variant for base access, making access to
larger types more consistent with the smaller types.
2022-04-29 16:59:15 +09:00
Bill Currie 7ef9aab7f3 [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-25 07:49:30 +09:00
Bill Currie 0b912795d0 [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-25 07:49:30 +09:00
Bill Currie f6baa16084 [cvar] Remove the cvar lists
They're really redundant, and removing the next pointer makes for a
slightly smaller cvar struct. Cvar_Select was added to allow finding
lists of matching cvars.

The tab-completion and config saving code was reworked to use the hash
table DO functions. Comments removed since the code was completely
rewritten, but still many thanks to EvilTypeGuy and Fett.
2022-04-25 00:26:45 +09:00
Bill Currie 8bd626a3e4 [hash] Add a couple of data-oriented functions
Hash_Select returns a list of elements that match a given criterion
(select callback returning non-0).

Hash_ForEach simply calls a function for every element.
2022-04-25 00:18:22 +09:00
Bill Currie df4116a55d [qw] Add a FIXE for rcon_password 2022-04-24 21:13:46 +09:00
Bill Currie bafe54b010 [view] Add a cexpr enum for grav_t
And use it for hud_scoreboard_gravity. Putting the enum def in view made
the most sense as view does own the base type and the enum is likely to
be by useful for other settings.
2022-04-24 21:09:58 +09:00
Bill Currie bdb1192c13 [console] Fix missed changes to console line exec control
I think I'd gotten distracted while making the changes to the server,
then simply copied the partial changes to the client. It didn't blow up
thanks to the backing store bing char * and the type sized for int, so
safe on any platform, but useless as it wasn't connected properly.

It's actually pretty neat being able to directly, but safely, control a
function pointer via a cvar :)
2022-04-24 20:46:06 +09:00
Bill Currie bff0847761 [cvar] Clean up most misinterpreted cvar types
The misinterpretations were due to either the cvar not being accessed
directly by the engine, but via only the callback, or the cvars were
accesssed only by progs (in which case, they should be float). The
remainder are a potential enum (hud gravity) and a "too hard basket"
(rcon password: need to figure out how I want to handle secret strings).
2022-04-24 20:04:06 +09:00
Bill Currie 90447a5d3b [quakefs] Ensure fs_sharepath and fs_userpath are never empty
Other parts of quakefs treat an empty path as an error, so fs_sharepath
and fs_userpath must never be empty or they will effectively be
rejected. While the user explicitly setting them to empty strings is one
way for them to become empty, another is QFS_CompressPath compressing
'.' to an empty path, which makes it rather difficult to set up the
traditional quake directory tree (ie, operate from the current
directory).
2022-04-24 19:15:22 +09:00
Bill Currie 9f876390f0 [input] Fix up some mistranslated cvars
My script didn't know what type to make the cvars since they're not used
directly by the code, so they got treated as strings instead of ints or
floats.
2022-04-24 19:15:22 +09:00
Bill Currie 12c84046f3 [cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.

As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.

The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).

While not used yet (partly due to working out the design), cvars can
have a validation function.

Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.

nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-24 19:15:22 +09:00
Bill Currie 87b3c64801 [vulkan] Parse VkPresentModeKHR
And strip the KHR for short names.
2022-04-24 19:15:22 +09:00
Bill Currie a52704e8ca [cexpr] Allow assignment of double to float
I didn't really want this, but it's needed for cvar support.
2022-04-24 19:15:22 +09:00
Bill Currie aad4546c01 [cexpr] Expose cexpr assignment
This makes it much easier for other systems (in particular, cvar) to
copy values safely.
2022-04-24 19:15:22 +09:00
Bill Currie 021ec4962b [cexpr] Add optional error message prefix string
The prefix gives more context to the error messages, making the system a
lot easier to use (it was especially helpful when getting my cvar revamp
into shape).
2022-04-24 19:15:22 +09:00
Bill Currie d68db74049 [cexpr] Add a flags type
Based on the flags type used in vkparse (difference is the lack of
support for plists). Having this will make supporting named flags in
cvars much easier (though setting up the enum type is a bit of a chore).
2022-04-24 19:15:22 +09:00
Bill Currie 392e032ce2 [cexpr] Add a get_string function to exprtype_t
This allows for easy (and safe) printing of cexpr values where the type
supports it. Types that don't support printing would be due to being too
complex or possibly write-only (eg, password strings, when strings are
supported directly).
2022-04-24 19:13:54 +09:00
Bill Currie db5b77c838 [cexpr] Require designated initializers for exprtype_t
This will make expanding it much safer in the future.
2022-04-24 17:31:17 +09:00
Bill Currie 8a411dc120 [joy] Clean up some redundant cvar flags
No need to or CVAR_NONE with other flags.
2022-04-24 17:23:46 +09:00
Bill Currie 001b3eb908 Fix some inconsistent cvar uses
Surprisingly, only two, but they were caught by the different value
fields being used, thus the cvar was checked in multiple places. I
imagine that's not really all that common, so there may be some
inconsistencies between default value and use.
2022-04-24 17:23:46 +09:00
Bill Currie 55f7886607 Remove some long dead cvars
The declarations were still around, but the creation and code using them
was removed long ago.
2022-04-24 17:23:46 +09:00
Bill Currie d987cef32e [qw] Fix an extern in a C file
Rather worrying finding one. I guess I didn't feel like finding a header
for the declaration at time time.
2022-04-24 17:23:46 +09:00
Bill Currie ef574e67d0 [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-24 17:21:58 +09:00
Bill Currie b2d4fa0ccf [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-24 17:04:10 +09:00
Bill Currie 88343d73ea [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:51:25 +09:00
Bill Currie c2119f0e24 Fix a typo 2022-04-01 02:35:03 +09:00
Bill Currie 849558903d Merge branch 'wip-rua_scene'
rua_scene is still in progress, but I felt it time to merge the work
that has been done as it is an improvement on what was there.
2022-04-01 02:17:24 +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 0880fab909 [nq,qw] Get demo capture working again
It turns it it had been broken for some time: it was attempting to write
the files to the wrong place.
2022-04-01 01:01:53 +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