Commit Graph

2051 Commits

Author SHA1 Message Date
Bill Currie 372c89b479 [particles] Merge physics code
The particle physics is called by the renderer.
2021-12-24 06:45:13 +09:00
Bill Currie 8d2791752e [particles] Merge particle spawning into client
After yesterday's crazy marathon editing all the particles files, and
starting to do another big change to them today, I realized that I
really do need to merge them down. All the actual spawning is now in the
client library (though particle insertion will need to be moved). GLSL
particle rendering is semi-broken in that it now does only points (until
I come up with a way to select between points and quads (probably a
context object, which I need anyway for Vulkan)).
2021-12-24 06:45:13 +09:00
Bill Currie ce4bb1d56c [renderer] Move particles over to simd
This has the advantage of getting entity_t out of the particle system,
and much easier to read math. Also, it served as a nice test for my
particle physics shaders (implemented the ideas in C). There's a lot of
code that needs merging down: all but the actual drawing can be merged.

There's some weirdness with color ramps, but I'll look into that later.
2021-12-24 06:45:13 +09:00
Bill Currie 83ec2be2a6 [vid] Add a listener set for palette changes
This was needed to get crosshaircolor working correctly, but is likely
another step towards resizable windows (the listener set types are
generic for any viddef event, not just palette changes).
2021-12-24 06:45:13 +09:00
Bill Currie 8b1eec08cf [scene] Provide direct access to the world matrix
Holding onto the pointer is not a good idea, and it is read-only as
direct manipulation of the world matrix is not supported. However, this
is useful for passing the matrix to the GPU.
2021-12-24 06:45:13 +09:00
Bill Currie 869cc4050c [vulkan] Flush bsp vertex indices after all drawing 2021-12-24 06:45:13 +09:00
Bill Currie 36e98f013e [vulkan] Clean up bsp push-constants. 2021-12-24 06:45:13 +09:00
Bill Currie b9bc3fa132 [vulkan] Split out the push constants helper
It proved to work well in the sprite pipeline, and should be useful for
cleaning up the magic numbers in bsp and alias.
2021-12-24 06:45:13 +09:00
Bill Currie db6c76d583 [vulkan] Abandon bindless rendering
At least for now, it is more trouble than it is worth as it (or my
implementation of it) breaks lavapipe and renderdoc.
2021-12-24 06:45:13 +09:00
Bill Currie 6aaf5c3722 [vulkan] Start work on particles for Vulkan
This gets the pipelines loaded (and unloaded on shutdown). Probably the
easy part :P. Still need to sort out the command buffers,
synchronization, and particle generation (and probably a bunch else
that's not coming to mind).
2021-12-24 06:45:13 +09:00
Bill Currie 9dcaa98205 [vulkan] Clean up a pile of C&P fluff 2021-12-24 06:45:13 +09:00
Bill Currie e0af6541e6 [vulkan] And a bunch of buffer barrier transitions
These seem to be the most likely ones for compute shaders (some based on
my ideas for particles).
2021-12-24 06:45:13 +09:00
Bill Currie 7901f87960 [vulkan] Add support for compute shaders
This needed changing Vulkan_CreatePipeline to
Vulkan_CreateGraphicsPipeline for consistency (and parsing the
difference from a plist seemed... not worth thinking about).
2021-12-24 06:45:13 +09:00
Bill Currie 93f806ccfb [vulkan] Make device.h more include-order independent 2021-12-24 06:45:13 +09:00
Bill Currie 0d4ece875d [vulkan] Use indexed initializers for barriers
This will make maintaining the arrays much easier: no worries about
getting things out of sync.
2021-12-24 06:45:13 +09:00
Bill Currie c366b1b7bb [vulkan] Implement the sprite render passes
It turned out the bindless approach wouldn't work too well for my design
of the sprite objects, but I don't think that's a big issue at this
stage (and it seems bindless is causing problems for brush/alias
rendering via renderdoc and on my versa pro). However, I have figured
out how to make effective use of descriptor sets (finally :P).

The actual normal still needs checking, but the sprites are currently
unlit so not an issue at this stage.
2021-12-24 06:45:13 +09:00
Bill Currie dafe591446 [renderer] Start merging sprite frame calculation
This covers gl and sw. sw32 should be trivial (just haven't done it),
but glsl will take a little. Vulkan will use it.
2021-12-24 06:45:13 +09:00
Bill Currie 743a732bd7 [vulkan] Correct the semantics of QFV_NextOffset
I'm not at all sure what I was thinking when I designed it, but I
certainly designed it wrong (to the point of being fairly useless). It
turns out memory requirements are already aligned in size (so just
multiplying is fine), and what I really wanted was to get the next
offset aligned to the given requirements.
2021-12-24 06:45:13 +09:00
Bill Currie 0eb556b8f9 [vulkan] Load sprite model data
The vertices and frame images are loaded into the one memory object,
with the vertices first followed by the images.

The vertices are 2D xy+uv sets meant to be applied to the model
transform frame, and are pre-computed for the sprite size (this part
does support sprites with varying frame image sizes).

The frame images are loaded into one image with each frame on its own
layer. This will cause some problems if any sprites with varying frame
image sizes are found, but the three sprites in quake are all uniform
size.
2021-12-24 06:45:13 +09:00
Bill Currie c5cfcc7bfd [sprite] Separate model and texture loading
As much as it can be since the texture data is interleaved with the
model data in the files (I guess not that bad a design for 25 years ago
with the tight memory constraints), but this paves the way for
supporting sprites in Vulkan.
2021-12-24 06:45:13 +09:00
Bill Currie 6eed89151c [vulkan] Fix a function doc typo 2021-12-24 06:45:13 +09:00
Bill Currie ad5415a860 [zone] Make zone.h stand-alone
ie, including just it from QF will compile.
2021-12-24 06:45:13 +09:00
Bill Currie e7e6dd87e8 [glsl] Fix some const-correct issues for textures 2021-12-24 06:45:13 +09:00
Bill Currie d857bdea77 [vulkan] Fix a typo and gcc purity warning 2021-12-24 06:45:13 +09:00
Bill Currie 2086125e0b [quakefs] Take in the pointer to the global hunk
This is needed for cleaning up excess memsets when loading files because
Hunk_RawAllocName has nonnull on its hunk pointer (as the rest of the
hunk functions really should, but not just yet).
2021-12-24 06:45:13 +09:00
Bill Currie 39c020908c [zone] Return the pointer to the global hunk
In trying to reduce unnecessary memsets when loading files, I found that
Hunk_RawAllocName already had nonnull on it, so quakefs needed to know
the hunk it was to use. It seemed much better to to go this way (first
step in what is likely to be a lengthy process) than backtracking a
little and removing the nonnull attribute.
2021-12-24 06:45:13 +09:00
Bill Currie 0a5981878b [sprite] Clean up field names and casting
No wonder I hated the sprite code: I couldn't see the code for all the
casts (and hungarian warts).
2021-12-24 06:45:13 +09:00
Bill Currie 3a17e062da [renderer] Merge sprite billboarding code
As the sw renderer's implementation was the closest to id's, it was used
as the model (thus a fair bit of cleanup is still needed). This fixes
some incorrect implementations in glsl and gl.
2021-12-24 06:45:13 +09:00
Bill Currie d5b824a47c [vulkan] Switch alias pipeline to multi-texture
This gets the alias pipeline in line with the bsp pipeline, and thus
everything is about as functional as it was before the rework (minus
dealing with large texture sets).
2021-12-24 06:45:13 +09:00
Bill Currie 11492d77ce [vulkan] Switch bsp renderer to multi-texture
I guess it's not quite bindless as the texture index is a push constant,
but it seems to work well (and I may have fixed some full-bright issues
by accident, though I suspect that's just my imagination, but they do
look good).
2021-12-24 06:45:13 +09:00
Bill Currie 6fbce335bb [vulkan] Add an array view for default_magenta
The validation layers get very picky about image view types (rightfully
so, I imagine).
2021-12-24 06:45:13 +09:00
Bill Currie 8422732505 [vulkan] Move matrices into per-frame buffers
This should fix the horrid frame rate dependent behavior of the view
model.

They are also in their own descriptor set so they can be easily shared
between pipelines. This has been verified to work for Draw.
2021-12-24 06:45:13 +09:00
Bill Currie e8961342d5 [vulkan] Fix some mostly harmless typos 2021-12-24 06:45:13 +09:00
Bill Currie d7f588ecfe [vulkan] Rework bsp texture loader
BSP textures are now two-layered with the albedo and emission in the two
layers rather than two separate images. While this does increase memory
usage for the textures themselves (most do not have fullbright pixels),
it cuts down on image and image view handles (and shader resources).
2021-12-24 06:45:13 +09:00
Bill Currie ea4ac894d8 [model] Swap fullbright/top/bottom color func params
This makes them semantically compatible with memcpy.
2021-12-24 06:45:13 +09:00
Bill Currie d2eb928210 [cexpr] Add a small library with some useful functions
For now, just dot product, trig, and min/max/bound, but it works well as
a proof of concept. The main goal was actually min. Only the list of
symbols is provided, it is the user's responsibility to set up the
symbol table and context.
2021-12-24 06:45:12 +09:00
Bill Currie 44102f2639 [cexpr] Support chained contexts for scoping
cexpr's symbol tables currently aren't readily extended, and dynamic
scoping is usually a good thing anyway. The chain of contexts is walked
when a symbol is not found in the current context's symtab, but minor
efforts are made to avoid checking the same symtab twice (usually cased
by cloning a context but not updating the symtab).
2021-12-24 06:45:12 +09:00
Bill Currie c8846f8007 [cexpr] Support array indexing
The index is currently limited to ints, and is bounds checked (the array
type has a size field indicating the number of elements).
2021-12-24 06:45:12 +09:00
Bill Currie 928408bad9 [vulkan] Support multiple render passes
Multiple render passes are needed for supporting shadow mapping, and
this is a huge step towards breaking the Vulkan render free of Quake,
and hopefully will lead the way for breaking the GL renderers free as
well.
2021-12-24 06:45:12 +09:00
Bill Currie 84a24dbb34 [renderer] Make R_RenderView private
This is actually a better solution to the renderer directly accessing
client code than provided by 7e078c7f9c.

Essentially, V_RenderView should not have been calling R_RenderView, and
CL_UpdateScreen should have been calling V_RenderView directly. The
issue was that the renderers expected the world entity model to be valid
at all times. Now, R_RenderView checks the world entity model's validity
and immediately bails if it is not, and R_ClearState (which is called
whenever the client disconnects and thus no longer has a world to
render) clears the world entity model. Thus R_RenderView can (and is)
now called unconditionally from within the renderer, simplifying
renderer-specific variants.
2021-12-24 06:45:12 +09:00
Bill Currie 25559243ae [vulkan] Add function to compute next offset
When allocating memory for multiple objects that have alignment
requirements, it gets tedious keeping track of the offset and the
alignment. This is a simple function for walking the offset respecting
size and alignment requirements, and doubles as a size calculator.
2021-12-24 06:45:12 +09:00
Bill Currie 032f9971ed [plist] Remove incorrect const from PL_RemoveObjectForKey
I'm not sure what I was thinking when I made PL_RemoveObjectForKey take
a const plitem. One of those times where C could do with being a little
more strict.
2021-12-17 08:30:00 +09:00
Bill Currie 8b85e422d7 [vulkan] Add a debug stack to the vulkan instance
The stack is arbitrary strings that the validation layer debug callback
prints in reverse order after each message. This makes it easy to work
out what nodes in a pipeline/render pass plist are causing validation
errors. Still have to narrow down the actual line, but the messages seem
to help with that.
Putting qfvPushDebug/qfvPopDebug around other calls to vulkan should
help out a lot, tool.
As a bonus, the stack is printed before debug_breakpoint is called, so
it's immediately visible in gdb.
2021-11-30 18:10:48 +09:00
Bill Currie a961111b2e [vulkan] Fetch vkCmdPushDescriptorSetKHR as extension
Which it is. This allows QF to continue even if the function is not
available.
2021-11-30 18:10:48 +09:00
Bill Currie b0447c1cf1 [console] Get message modes and menus working again
I'm not at all happy with con_message and con_menu, but fixing them
properly will take a rework of the menus (planned, though). Also, the
Menu_ console command implementations are a bit iffy and could also do
with a rewrite (probably part of the rest of the menu rework) or just
nuking (they were part of Johnny on Flame's work, so I suspect had
something to do with joystick bindings).
2021-11-28 23:21:55 +09:00
Bill Currie 652546a4fb [input] Clean out a lot of obsolete stuff from keys
The new binding system makes much of keys.[ch] obsolete leaving only the
key name translations.
2021-11-27 12:31:24 +09:00
Bill Currie fe9241e573 [input] Move some IMT documentation
And update to reflect some of the changed concepts (context vs keydest)
2021-11-27 12:06:11 +09:00
Bill Currie b01c38903d [x11] Clamp barriers to the screen
It seems X11 does not like creating barriers entirely off the screen,
though the error seems to be a little unreliable (however, off the left
edge was definitely bad).
2021-11-25 20:23:18 +09:00
Bill Currie 62f592b92c [input] Create an automatic imt switcher
An imt switcher automatically changes the context's active imt based on
a user specified list of binary inputs. The inputs may be either buttons
(indicated as +button) or cvars (bare name). For buttons, the
pressed/not pressed state is used, and cvars are interpreted as ints
being 0 or not 0. The order of the inputs determines the bit number of
the input, with the first input being bit 0, second bit 1, third bit 2
etc. A default imt is given so large switchers do not need to be fully
configured (the default imt is written to all states).

A context can have any number of switchers attached. The switchers can
wind up fighting over the active imt, but this seems to be something for
the "user" (eg, configuration system) to sort out rather than the
switcher code enforcing anything.

As a result of the inputs being treated as bits, a switcher with N
inputs will have 2**N states, thus there's a maximum of 16 inputs for
now as 65536 states is a lot of configuration.

Using a switcher, setting up a standard strafe/mouse look configuration
is fairly easy.

    imt_create key_game imt_mod
    imt_create key_game imt_mod_strafe imt_mod
    imt_create key_game imt_mod_freelook
    imt_create key_game imt_mod_lookstrafe imt_mod_freelook
    imt_switcher_create mouse key_game imt_mod_strafe +strafe lookstrafe +mlook freelook
    imt_switcher 0 imt_mod 2 imt_mod 4 imt_mod_freelook 8 imt_mod_freelook 12 imt_mod_freelook
    imt_switcher 6 imt_mod_lookstrafe 10 imt_mod_lookstrafe 14 imt_mod_lookstrafe
    in_bind imt_mod mouse axis 0 move.yaw
    in_bind imt_mod mouse axis 1 move.forward
    in_bind imt_mod_strafe mouse axis 0 move.side
    in_bind imt_mod_lookstrafe mouse axis 0 move.side
    in_bind imt_mod_freelook mouse axis 1 move.pitch

This takes advantage of imt chaining and the default imt for the
switcher (there are 8 states that use imt_mod_strafe).

The switcher name must be unique across all contexts, and every imt used
in a switcher must be in the switcher's context.
2021-11-25 20:23:18 +09:00
Bill Currie 1a79915d22 [input] Add axis listeners
The listener is invoked when the axis value changes due to IN_UpdateAxis
or IN_ClampAxis updating the axis. This does mean the listener
invocation make be somewhat delayed. I am a tad uncertain about this
design thus it being a separate commit.
2021-11-25 20:04:08 +09:00