Commit graph

12498 commits

Author SHA1 Message Date
Bill Currie
bbca22c722 [vulkan] Add support for IQM models
Despite the base IQM specification not supporting blend-shapes, I think
IQM will become the basis for QF's generic model representation (at
least for the more advanced renderers). After my experience with .mu
models (KSP) and unity mesh objects (both normal and skinned), and
reviewing the IQM spec, it looks like with the addition of support for
blend-shapes, IQM is actually pretty good.

This is just the preliminary work to get standard IQM models loading in
vulkan (seems to work, along with unloading), and they very basics into
the renderer (most likely not working: not tested yet). The rest of the
renderer seems to be unaffected, though, which is good.
2022-05-04 14:07:27 +09:00
Bill Currie
a4f500da3c [vulkan] Add a mini resource subsystem
The resource subsystem creates buffers, images, buffer views and image
views in a single batch operation, using a single memory object to back
all the buffers and images. I had been doing this by hand for a while,
but got tired of jumping through all those vulkan hoops. While it's
still a little tedious to set up the arrays for QFV_CreateResource (and
they need to be kept around for QFV_DestroyResource), it really eases
calculation of memory object size and sub-resource offsets. And
destroying all the objects is just one call to QFV_DestroyResource.
2022-05-04 13:59:38 +09:00
Bill Currie
9d7cad420d [vulkan] Add a function to translate QFFormat to VkFormat
It's not great, but it does produce reasonable results for the formats
supported by QF's image system.
2022-05-04 13:57:02 +09:00
Bill Currie
a77aa16318 [vulkan] Make some headers order-indepenedent
In that they don't need Vulkan/qf_vid.h included first.
2022-05-04 13:55:56 +09:00
Bill Currie
419d91edc5 [image] Set texture type for no-load tga images
I might need to do similar for other formats, but i ran into the problem
of the texture type being tex_palette instead of the expected tex_rgba
when pre-(no-)loading a tga image resulting in Vulkan not liking my
attempt at generating mipmaps.
2022-05-04 13:50:55 +09:00
Bill Currie
ef6e4722d5 [simd] Add some comments to mat4fquat
Having to refigure out what values are going into the vectors got old
very fast. The comments don't help with verifying the values, but at
least I can tell at a glance where 2(xy - wz) goes and thus determine
the "orientation" of the matrix.
2022-05-04 13:48:34 +09:00
Bill Currie
fe891dd70b Merge branch 'master' into wip-rua_scene 2022-05-01 14:46:47 +09:00
Bill Currie
b9bd45ad99 [qfcc] Create vector lists only for constants
Defs and symbols benefit from swizzling as that's one instruction vs 2-3
for loading a scalar into a vector component by component. Constants are
ok because the result gets converted to a vector constant.
2022-05-01 14:35:24 +09:00
Bill Currie
be4021f8f4 [qfcc] Actually shrink the unaligned hole
This fixes the duplicate allocation caused by an exact fit aligned alloc
in an unaligned hole where the padding remains free.
2022-05-01 14:35:24 +09:00
Bill Currie
7518ba0a27 [qfcc] Add failing test case for defspace_alloc_aligned_loc
qfcc is putting two temps in the same location due to
defspace_alloc_aligned_loc returning the same address when there was a
hole caused by an earlier aligned alloc: specifically, a size-3 hole and
a size-2 allocation with alignment-2.
2022-05-01 14:35:24 +09:00
Bill Currie
cdd8739577 [qfcc] Improve debug printing of statements and operands
Makes it easier to check operand base indices and temporary variable
addresses when known.
2022-05-01 14:35:24 +09:00
Bill Currie
ef9960c6f9 [qfcc] Implement support for the swizzle operator
The destination operand must be a full four component vector, but the
source can be smaller and small sources do not need to be aligned: the
offset of the source operand and the swizzle indices are adjusted. The
adjustments are done during final statement emission in order to avoid
confusing the data flow analyser (and that's when def offsets are known).
2022-05-01 14:35:24 +09:00
Bill Currie
3c20dd515e Revert "Don't bother creating an alias for a def of the same type."
This reverts commit 2904c619c1.

In order to support swizzle operations, I need to be able to alias defs
to larger types (eg, float to vec4), but alias_def rightly won't allow
this. However, as the plan is to do this in the final steps before
emitting the instruction, I plan on creating an alias to a float then
adjusting the type in the alias, but to do so without extra shenanigans,
I need alias_def to allow aliases to the same type. As a fringe benefit,
it makes the code agree with the comment in def.h :P
2022-05-01 14:35:24 +09:00
Bill Currie
b87a768c43 [gamecode] Sort debug local defs by address
This allows the fuzzy bsearch used to find a def by address to work
properly (ie, find the actual def instead of giving some other def +
offset). Makes for a much more readable instruction stream.
2022-05-01 14:35:24 +09:00
Bill Currie
4ed9fc6820 [ruamoko] Switch to 64-bit handles for scene objects
The scene id is in the lower 32-bits for all objects (upper 32-bits are
0 for actual scene objects) and entity/transform ids are in the upper
32-bits. Saves having to pass around a second parameter in progs code.
2022-04-29 21:02:08 +09:00
Bill Currie
709a0a338d [qfcc] Return properly from copying a block expression
This came up when investigating an internal error from the line above.
It turned out the error was correct (problem with converting scalars to
vectors), but the break was not.
2022-04-29 20:53:59 +09:00
Bill Currie
8021848b5b [qfcc] Support promotions for struct initializers
This allows the various vector types to be used to initialized
structures and arrays.
2022-04-29 20:52:57 +09:00
Bill Currie
69ce0e952d [qfcc] Don't auto-promote vector types through ...
Currently, only vector/vec3 and quaternion/vec4 can be printed anyway,
but I plan on making explicit format strings for the types, so there
should be no need to promote any vector types (and really, any hidden
promotion is a bit of a pain, but standards...).
2022-04-29 20:52:27 +09:00
Bill Currie
719fe5a935 [qfcc] Support dot product for all (float) vector types
While the code would handle int vector types, there aren't any such
instructions, and the expression code shouldn't generate them, but all
float (32 and 64 bit) vector types do have a dot product instruction, so
check width rather than just vector/quaternion.
2022-04-29 20:46:33 +09:00
Bill Currie
547cae03ae [qfcc] Copy parameter types when registering new function type
This fixes an error that's been lurking for over two years (since I made
parameters unlimited internally). The problem was the array was being
allocated on the stack and a simple struct copy was used to store type
type, resulting in a dangling pointer onto the stack. I'm surprised it
didn't cause more problems.
2022-04-29 19:27:27 +09:00
Bill Currie
9cccb7a4d4 [qfcc] Implement ulong, long and uint constants
Finally :P
2022-04-29 18:12:47 +09:00
Bill Currie
9c8e13aa4c [qfcc] Implement automatic casting between same-width vectors
This allows all the tests to build and pass. I'll need to add tests to
ensure warnings happen when they should and that all vec operations are
correct (ouch, that'll be a lot of work), but vectors and quaternions
are working again.
2022-04-29 18:12:47 +09:00
Bill Currie
bf53edf5e3 [qfcc] Use correct vector expression size in test
Vector expressions no longer auto-widen due to the new vector types (I
might add such later, but for now this lets the tests try to build
(minus actual fixes in qfcc)).
2022-04-29 18:12:47 +09:00
Bill Currie
f429777918 [qfcc] Extend vector literal processing
With this, all vector widths and types are supported: 2, 3, 4 and int,
uint, long, ulong, float and double, along with support for suffixes to
make the type explicit: '1 2'd specifies a dvec2 constant, while '1 2 3'u
is a uivec3 constant. Default types are double (dvec2, dvec3, dvec4) for
literals with float-type components, and int (ivec2...) for those with
integer-type components.
2022-04-29 18:12:47 +09:00
Bill Currie
d06185336f [qfcc] Implement component names for the new vector types
And simplify vector and quaternion setup as part of the process. Now
appropriate x, y, z and w can be used with the new vector types.
2022-04-29 16:59:55 +09:00
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
5c67f95edd [qwaq] Set the world model to an empty world
The goal is to have somewhere to put entities so they can be rendered. I
suspect I could have used a bsp tree to partition space for frustum
culling, but it's probably not worth it at this stage (but shouldn't
require any changes to the engine: just the model).
2022-04-26 07:34:53 +09:00
Bill Currie
c4d56afd33 [vulkan] Cope with an empty world model
Vulkan doesn't appreciate the empty buffers that result from the model
not having any textures or surfaces that can be rendered (rightfully so,
for such a bare-metal api).
2022-04-26 07:26:32 +09:00
Bill Currie
5703df00fd [renderer] Don't try to draw a nonexistent view model
Doing so doesn't end well (segfault). This is a bit of a hack until I
come up with a design for configurable scene rendering.
2022-04-26 07:22:45 +09:00
Bill Currie
a9b8241a74 [ruamoko] Fix some misnamed parameters
IN_GetButtonName and IN_GetButtonNumber mentioned axis instead of
button. A tad confusing.
2022-04-26 07:19:35 +09:00
Bill Currie
98cbacfe9d [renderer] Remove redundant calls to visit_leaf
I doubt the calls were ever actually made in a normal map due to the
node actually being a node when breaking out of the loop, but when I
experimented with an empty world model (no nodes, one infinite empty
leaf) I found that visit_leaf was getting called twice instead of once.
2022-04-26 07:14:03 +09:00
Bill Currie
fddff1c24d Merge branch 'master' into wip-rua_scene 2022-04-25 08:13:35 +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