Commit graph

2265 commits

Author SHA1 Message Date
Bill Currie
c59ab8882d [vulkan] Label renderpass and subpass sections
This makes finding the relevant commands in render doc much much easier.
2022-05-07 15:45:11 +09:00
Bill Currie
8204e8a8c1 [vulkan] Clear lights when the scene is cleared
Fixes a segfault when shutting down my test program.
2022-05-07 12:12:02 +09:00
Bill Currie
8795b8eb91 [vulkan] Get IQM rendering working
The bones aren't animated yet (and I realized I made the mistake of
thinking the bone buffer was per-model when it's really per-instance (I
think this mistake is in the rest of QF, too)), skin rendering is a
mess, need to default vertex attributes that aren't in the model...
Still, it's quite satisfying seeing Mr Fixit on screen again :)

I wound up moving the pipeline spec in with the rest of the pipelines as
the system isn't really ready for separating them.
2022-05-07 10:14:22 +09:00
Bill Currie
3f7cbae4d0 [vulkan] Rework builtin plist handing
The plists can now be accessed by name and the forward render pass
config is available (but not used, or tested beyond syntax). I was going
to have the IQM pipeline spec separate but ran into limitations in the
system (which needs a lot of polish, really).
2022-05-07 10:08:30 +09:00
Bill Currie
b69b7b6a4a [vulkan] Clean up duplication in qfpipeline
That @inherit is pretty useful :) This makes it much easier to see how
different pipelines differ or how they are the similar. It also makes it
much clearer which sub-pass they're for.
2022-05-06 19:38:14 +09:00
Bill Currie
79add5590b [build] Fix some make distcheck issues
The never ending battle against bit-rot.
2022-05-06 15:50:13 +09:00
Bill Currie
551c6b82cb [vulkan] Tweak spotlight cone edges a little 2022-05-06 08:32:19 +09:00
Bill Currie
4abcaff980 [vulkan] Normalize the normal vectors on alias models
I was wondering why scaled-down quake-guy was dimmer than full-size
quake-guy. And the per-fragment normalization gives the illusion of
smoothness if you don't look at his legs (and even then...).
2022-05-05 23:49:31 +09:00
Bill Currie
7b275ebab6 [vulkan] Don't update lights that don't exist
However, the lighting pass still needs to be run in order to generate
the solid color image.
2022-05-05 23:49:31 +09:00
Bill Currie
2818fc12a5 [model] Initialize r_notexture_mip in the right places
That being in the renderer. This is why qwaq needed that call to
Mod_ProcessTexture (but no longer does :)
2022-05-05 23:49:31 +09:00
Bill Currie
d60602421b [vulkan] Ensure dynamic lights are positional
I'm not sure what's up with the weird lighting that results from dynamic
lights being directional (sunlight works nicely in marcher, but it has a
unit vector for position).
2022-05-05 23:49:31 +09:00
Bill Currie
9ee0eada1f [vulkan] Move non-specific lighting code out of Vulkan
The parsing of light data from maps is now in the client library, and
basic light management is in scene. Putting the light loading code into
the Vulkan renderer was a mistake I've wanted to correct for a while.
The client code still needs a bit of cleanup, but the basics are working
nicely.
2022-05-05 23:49:30 +09:00
Bill Currie
e9ad7b748b [renderer] Use scene_t to set the model data
This replaces *_NewMap with *_NewScene and adds SCR_NewScene to handle
loading a new map (for quake) in the renderer, and will eventually be
how any new scene is loaded.
2022-05-05 14:46:02 +09:00
Bill Currie
e323fbbbed [vulkan] Rework lighting model to be more algebraic
This leaves only the one conditional in the shader code, that being the
distance check. It doesn't seem to make any noticeable difference to
performance, but other than explosion sprites being blue, lighting
quality seems to have improved. However, I really need to get shadows
working: marcher is just silly-bright without them, and light levels
changing as I move around is a bit disconcerting (but reasonable as
those lights' leaf nodes go in and out of visibility).
2022-05-05 08:40:02 +09:00
Bill Currie
fe63d93e8e [build] Remove some csqc dependencies
vkgen and the programs in ruamoko/qwaq just don't need it.
2022-05-04 18:01:50 +09:00
Bill Currie
8e658eac78 [vulkan] Correct a pile of copyright attributions
Id Software had pretty much nothing to do with the vulkan renderer (they
still get credit for code that's heavily based on the original quake
code, of course).
2022-05-04 14:44:54 +09:00
Bill Currie
e95d498b97 [vulkan] Resurrect the forward render pass spec
It's not used yet, and thus may have some incorrect settings, but I
decided that I will probably want it at some stage for qwaq. It's
essentially was was in the original spec, but updated for some of the
niceties added to parsing since I removed it back then. It's also in its
own file.
2022-05-04 14:44:54 +09:00
Bill Currie
c10e529dfd [vulkan] Clean up alias pipeline layout spec
It didn't really need the extra layer of indirection: now it's much
clearer that the alias pipeline uses matrices and textures.
2022-05-04 14:44:54 +09:00
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
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
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
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
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
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
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
bc1fe6aa01 [renderer] Remove some redundant comments
No need for comments when the code says it all.
2022-04-23 10:56:56 +09:00
Bill Currie
f15abcea53 [vulkan] Add a FIXME for the flashing Q icon
As I had suspected, it's due to a synchronization problem between the
scrap and drawing. There's actually a double problem in that data
uploaded to the scrap isn't flushed until the first frame is rendered
causing a quick init-shutdown sequence to take at least five seconds due
to the staging buffer waiting (and timing out) on a stuck fence.
Rendering just one frame "fixes" the problem (draw was one of the
earliest subsystems to get going in vulkan).
2022-04-23 10:46:55 +09:00
Bill Currie
b649638400 [joy] Clean up some redundant cvar flags
No need to or CVAR_NONE with other flags.
2022-04-13 14:17:58 +09:00
Bill Currie
063c0797d6 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-13 14:17:58 +09:00
Bill Currie
e97b96b536 Remove some long dead cvars
The declarations were still around, but the creation and code using them
was removed long ago.
2022-04-13 14:17:58 +09:00
Bill Currie
4d443d3114 [vid] Fix non-utf8 circle-c in fbset
Python didn't like reading the files.
2022-04-13 10:35:40 +09:00
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
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
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
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
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
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
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
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
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
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
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
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
Bill Currie
75d7f4cecb [renderer] Clean up particles a little
The quake-specific enums are now in the client header, and the particle
system now has a gravity field rather than getting it from
vid_render_data (which I hope to eventually get rid of entirely).
2022-03-29 14:43:38 +09:00
Bill Currie
ca9e18b9d6 [renderer] Use initializer labels for vid_render_data
Got tired of figuring out which initializers to remove when editing
vid_render_data_t.
2022-03-29 14:43:38 +09:00
Bill Currie
d53b0b0064 [sw] Clean up use of vid.colormap8
The main goal was to not update the colormap pointers when only the
viewport or fov changed.
2022-03-29 14:43:38 +09:00
Bill Currie
3103f400fd [sw] Clean up r_refdef and R_ViewChanged
r_refdef is really meant for holding the various screen "constants" for
the software renderer rather than the more generic scene stuff. All the
fields referenced by the low level rendering code (especially assembly)
have been moved to the beginning of the struct (and nicely fit within 64
bytes). The other fields should be moved elsewhere, but not this commit.

On top of that, R_ViewChanged is much easier to read, and there are
fewer static globals.
2022-03-27 15:32:00 +09:00
Bill Currie
aafd5c3d81 [gl] Make perspective matrix setup consistent
Now GL perspective matrix setup matches that of GLSL and Vulkan, and
GL's z_up matrix matches GLSL's (as it should, since they're really
going through the same API). GL also needs the depth adjustmet matrix
now. Other than having to google the docs for glFrustum, there's nothing
wrong with the function itself, but it's nice to have direct control
over the matrices.

In the process, I discovered how horribly confused I've been at times
with respect to the handedness of GL and Quake: GL is right-handed
(y-up, z-out, x-right), as is Quake itself (but z-up, y-left, x-in), but
as the perspective matrix used in the three renderers expects z-in,
having x-right and y-up makes the matrix effectively left-handed (not
for Vulkan though, because there it's y-down, x-right, z-up, so
right-handed again).
2022-03-27 13:23:44 +09:00
Bill Currie
12776e487a [gl] Implement screen warping for liquids
It's not the most efficient code (uses sin() directly), but at least it
works (and with about 75% cpu headroom at 72fps on my machine).
2022-03-26 18:13:37 +09:00
Bill Currie
a0adca011f [gl] Get fisheye working with frame buffers
Of course, it's not as correct as glsl or sw due to using polygons and
uvs rather than a fragment shader (not that such is out of the question
since GL 3.0 is requested, but I don't feel like getting shaders going
just for a couple of post-processing effects in an obsolete renderer).
2022-03-26 12:51:31 +09:00
Bill Currie
aa41259008 [gl] Clean out the last of the mirror code
Stragglers...
2022-03-26 10:27:16 +09:00
Bill Currie
303756b41b [gl] Remove the envmap command
It has never worked, but it should be easy enough to implement for all
renderers since fisheye does the same thing.
2022-03-26 10:27:16 +09:00
Bill Currie
77a797d04b [renderer] Clean up viewport setting
Software is still a mess, and vulkan never supported viewsize, but
otherwise everything seems fine.
2022-03-26 10:27:16 +09:00
Bill Currie
f2bc5b560f [renderer] Clean up post processing
While it's not where I want it to be, it at least now no longer messes
with frame buffer binding or the view ports. This involved switching
around buffers in D_WarpScreen so that the main buffer could be bound
before post-processing.
2022-03-26 00:42:43 +09:00
Bill Currie
25e6865fa5 [glsl] Update particle arrays when maximum changes
The cvar setup for particles is a bit wonky in that the arrays get
initialized using the default max particle count but never updated.
Though things could be improved some more, this solution works (and has
been more or less copied to gl, but I couldn't reproduce the crash
there, or even the valgrind error).
2022-03-25 14:48:01 +09:00
Bill Currie
286344c7b6 [glsl] Implement fisheye rendering
The code dealing with state is a bit of a mess, but everything is
working nicely. Get around 400fps when all 6 faces need to be rendered
(no surprise: it should be about 1/6 of that for normal rendering). The
messy state handling code did not come as a surprise as I suspected
there were various mistakes in my scene rendering "recipe", and fisheye
highlighted them nicely (I'm sure getting this stuff working in Vulkan
will highlight even more issues).
2022-03-25 12:22:16 +09:00
Bill Currie
18aae8205e [glsl] Implement screen warp when in liquids
Finally, after a decade :P Looks pretty good, too, and is (almost)
properly scaled to the resolution (almost because the effect is a little
squashed, but I think the sw renderer does the same).
2022-03-25 09:01:27 +09:00
Bill Currie
e263521330 [glsl] Put #line after any #version lines in the chunks
The GLSL compiler requires any #version lines to be the first (real)
line of the program, even #line causes an error, so if the first line of
the chunk starts with #version, insert the #line directive as the second
line.
2022-03-25 09:01:27 +09:00
Bill Currie
00362e9f4e [gl] Explicitly request compatibility profile
And core profile for glsl
2022-03-25 09:01:11 +09:00
Bill Currie
7ca3b56620 [glsl] Fix a silly typo in a comment 2022-03-24 15:54:23 +09:00
Bill Currie
20a2e7e06f [renderer] Get sw fisheye working again
Again, gl/vulkan not working yet (on the assumption that sw would be
trickier).

Fisheye overrides water warp because updating the projection map every
frame is far too expensive.

I've added a post-process pass to the interface in order to hide the
implementation details, but I'm not sure I'm happy about how the
multi-pass rendering for cube maps is handled (or having the frame
buffers as exposed as they are), but mainly because Vulkan will make
implementation interesting.
2022-03-24 15:50:41 +09:00
Bill Currie
0c437492b4 [renderer] Move to using dynamic frame buffers
For now, OpenGL and Vulkan renderers are broken as I focused on getting
the software renderer working (which was quite tricky to get right).

This fixes a couple of issues: the segfault when warping the screen (due
to the scene rendering move invalidating the warp buffer), and warp
always having 320x200 resolution. There's still the problem of the
effect being too subtle at high resolution, but that's just a matter of
updating the tables and tweaking the code in D_WarpScreen.

Another issue is the Draw functions should probably write directly to
the main frame buffer or even one passed in as a parameter. This would
remove the need for binding the main buffer at the beginning and end of
the frame.
2022-03-24 12:56:29 +09:00
Bill Currie
4a917449b7 [sw] Clean up a bunch of unnecessary casts
They won't affect performance, but they cluttered the code making it
harder to read.
2022-03-21 23:15:14 +09:00
Bill Currie
8ee776e8fb [sw] Rename d_pzbuffer to d_zbuffer 2022-03-21 23:12:22 +09:00
Bill Currie
376a173e66 [sw] Set FP precision in R_DrawEntitiesOnList
This used to be handled by R_RenderView (encompassing all of the
rendering) before the scene rendering was moved out to r_screen. This
fixes the stuck time in 32-bit nq-win.
2022-03-21 21:59:07 +09:00
Bill Currie
2e1ddfed0d [sw] Fix some missed symbol renames
Missed due to assembly language :P
2022-03-21 19:24:43 +09:00
Bill Currie
4c90c3c4bb [sw] Remove pixbytes from sw_ctx_t
It's no longer needed as the sw renderer is 8-bit only.
2022-03-21 14:37:28 +09:00
Bill Currie
b82a353a20 [vid] Remove VID_InitBuffers
Its guts have been moved to D_Init temporarily while I work on the
frame buffer design. This is actually a big part of that work as it
moves most of the frame buffer creation into the one place, making it
easier to ensure I get all the sub-buffers and caches created.
2022-03-21 14:35:11 +09:00
Bill Currie
3b4608a0cd [vid] Update glx handling to ensure GL 3.0
With what I have planned for frame buffers etc, GL 3.0 will be needed
even for the fixed-function GL renderer, and then I might even take the
GLSL renderer to 4.6 (dunno yet). This means that wgl will need to be
updated too, and I've found the info I need for that, but it's a bit
much to take on just yet.
2022-03-20 12:52:20 +09:00
Bill Currie
65af7fb4a4 [mathlib] Remove frustum global
It should never have been there and is now in the refdef (not its final
home: it should probably be part of the camera).
2022-03-19 12:33:12 +09:00
Bill Currie
b912c2a667 [renderer] Clean up R_SetFrustum
The only global it touches now is frustum, and that needs fixing in
mathlib (good grief, we (probably I) did some weird things when merging
the code).
2022-03-19 10:06:38 +09:00
Bill Currie
c3f38e1c79 [renderer] Remove player_entity field
This was a hold-over from the gl mirror code.
2022-03-19 09:46:53 +09:00
Bill Currie
ee51d06aa3 [renderer] Clean up a lot of recalc_refdef use
I think the widespread use of recalc_refdef (and force_fullscreen) was
the result of a rushed merge of the renderer and video code (I do seem
to remember sprinkling them around). This cleans the two out of the
client code.
2022-03-19 00:56:30 +09:00
Bill Currie
c8c742b240 [renderer] Use a better calculation for fov_y
This avoids the possibility of a singularity (and thus the temptation to
use Sys_Error). While the rendering is rubbish, 0 degrees is allowed
because values less than 1 should be allowed, but where does one stop?
170 is the maximum in order to avoid any issues with (near) parallel or
inverted frustum planes (or other fun things) in the low level code.
2022-03-18 11:14:24 +09:00
Bill Currie
2b72506868 [renderer] Handle transparent surfaces
Other than the view model (undecided on the approach) this has
R_RenderView pretty much pulled out of the low level renderers. With
this, I'll be able to focus on scene handling for a bit then getting
shadows and fisheye working (again for fisheye).
2022-03-18 01:08:19 +09:00
Bill Currie
c05476f94b [renderer] Move most of the scene rendering into r_screen
r_screen isn't really the right place, but it gets the scene rendering
out of the low-level renderers and will make it easier to sort out
later, and hopefully easier to figure out a good design for vulkan.
2022-03-17 17:57:50 +09:00
Bill Currie
961e6d9e6c [gl] Remove unnecessary light map update code
gl_overbright_f shouldn't need to run through any entity queues to
update the light maps as only the world model has light maps, and
hitting the world model should hit all its sub-models.
2022-03-17 17:46:25 +09:00
Bill Currie
833fb2f4f8 [sw] Make alight_t lightvec an actual vector
The change to using separate per-model-type entity queues resulted in
the lighting vector used for alias and iqm models being in an ephemeral
location (in the shared setup_lighting function's stack frame). This
resulted in the model rendering code getting a garbage vector due to it
being overwritten by another stack frame. What I don't get is why the
garbage varied from run to run for the same demo (demo2, the first scrag
behind the start door showed the bad lighting nicely), which made
tracking down the offending commit (and thus the code) rather
troublesome, though once I found it, it was a bit of a face-palm moment.
2022-03-17 15:38:22 +09:00
Bill Currie
6c29904b1d [sw] Clean up R_SetSkyFrame a little
Move the constant data into R_InitSky so it doesn't get calculated every
frame (doesn't make much difference of course, but...)
2022-03-17 13:37:21 +09:00
Bill Currie
d8a4c8dbe9 [renderer] Clean up r_bsp a little
Move r_pcurrentvertbase into the sw renderer, cleaning up gl's use of
(not really needed there). Not ready to move r_bsp into the main bin yet
as there are linking issues since only the low-level code references any
of its symbols.
2022-03-17 13:09:20 +09:00
Bill Currie
7ee9159638 [renderer] Move common R_SetupFrame code to r_screen
The code is really part of scene (not a typo wrt r_screen: that is
misnamed as such, or at least SCR_UpdateScreen needs to be split into
screen (2d overlay, really) and scene updates).

This breaks fisheye rendering as the fisheye code calls the actual scene
render code multiple times, but the fisheye code is called by said scene
render code via a diversion. The fisheye needs to be moved out to the
high level scene render, but that will takes some extra work for frame
buffer setup.
2022-03-17 12:00:43 +09:00
Bill Currie
335d387ba8 [renderer] Clean up some stray vup etc
Now vup, vfwd, vright names are restricted to only the software renderer
(the only one that has such global variables).
2022-03-17 11:55:58 +09:00
Bill Currie
0e58f96d37 [renderer] Fix more plugin linking errors 2022-03-17 11:21:38 +09:00
Bill Currie
1458f61a48 [renderer] Fix non-static linking of graph code
Obviously forgot to test the changes I made to graph rendering in
non-static builds. Oops :P
2022-03-17 10:51:29 +09:00
Bill Currie
d3bfc54a68 [sw] Disable water warp when doing fisheye
The two aren't compatible (but warping might be doable in the fisheye
code). The whole frame setup code needs a rework, and really, even the
buffer handling.
2022-03-17 09:42:09 +09:00
Bill Currie
9241efaf1e [sw] Use a smaller size for the fish eye cube map
This speeds up sw rendering of the fish eye effect.
2022-03-16 13:55:44 +09:00
Bill Currie
ab78e9d2ff [sw] Make worldent local static
It being on the stack was a bad idea as R_RenderWorld returns before the
scans are rendered and thus the entity pointer winds up pointing to
abandoned stack space.
2022-03-15 16:54:59 +09:00
Bill Currie
91d7a80dff [renderer] Get timegraph and zgraph working
Only for sw and gl right now, but this sorts out the issues that
prevented the graphs working at all.
2022-03-15 15:42:43 +09:00
Bill Currie
5a57280aa9 [gl] Use glGenTextures to allocate texture numbers
While the scheme of using our own allocated did work just fine, fisheye
rendering uses glGenTextures which caused a texture id clash and thus
invalid operations (the cube map texture happened to be the same as the
console background texture). Sure, I could have just "fixed" the fisheye
init code, but this brings gl closer in line with glsl (which makes
extensive use of glGenTextures and glDeleteTextures). This doesn't fix
any texture leaks gl has (plenty, I imagine), but it's a step in the
right direction.
2022-03-15 13:29:05 +09:00
Bill Currie
fb4fd979ec [gl] Move error check support into a better place
This makes it a little easier to spam checks everywhere and thus narrow
down the location of the error.
2022-03-15 12:33:25 +09:00
Bill Currie
1d93bcfc34 [gl] Clean out some missed mirror code 2022-03-15 00:09:37 +09:00
Bill Currie
fd805886f7 [renderer] Get fisheye working again
Only for gl and sw at the moment (want to merge things further before I
do anything for glsl or vulkan). However, with with I've learned getting
gl and sw to work, glsl and vulkan will be trivial.
2022-03-14 23:51:30 +09:00
Bill Currie
7402fcfd0c [renderer] move r_worldentity and r_viewleaf into refdef
More cleanup of globals that seem to be quake specific.
2022-03-14 15:27:43 +09:00
Bill Currie
2641fe3241 [gl] Remove some dead code
R_RecursiveLightUpdate has been obsolete for a very long time, and
R_Mirror is just wrong (needs envmaps etc, wonder if it can be done in
the fixed function code using skyclip?)
2022-03-14 15:12:33 +09:00
Bill Currie
56c39c34ba [renderer] Remove namehack.h
Finally. I never liked it (felt bad adding it in the first place), and
it has caused confusion with function and global variable names, but it
did let me get the render plugins working.
2022-03-14 14:31:23 +09:00
Bill Currie
04ba724382 [sw] Clean up alias and iqm matrix setup
This removes some FIXMEs and might even speed things up ever so
slightly.
2022-03-14 11:56:10 +09:00
Bill Currie
bce7d5b832 [renderer] Clean up use of vup/vright/vpn
This moves the common camera setup code out of the individual drivers,
and completely removes vup/vright/vpn from the non-software renderers.
This has highlighted the craziness around AngleVectors with it putting
+X forward, -Y right and +Z up. The main issue with this is it requires
a 90 degree pre-rotation about the Z axis to get the camera pointing in
the right direction, and that's for the native sw renderer (vulkan needs
a 90 degree pre-rotation about X, and gl and glsl need to invert an
axis, too), though at least it's just a matrix swizzle and vector
negation. However, it does mean the camera matrices can't be used
directly.

Also rename vpn to vfwd (still abbreviated, but fwd is much clearer in
meaning (to me, at least) than pn (plane normal, I guess, but which
way?)).
2022-03-14 09:45:27 +09:00
Bill Currie
f3768e3dfb [renderer] Remove currententity
One more global in the trash :)
2022-03-11 16:39:08 +09:00
Bill Currie
64666cfa5b [renderer] Clean up most uses of currententity
Just some brush model related code in the software renderer remaining.
2022-03-11 15:07:38 +09:00
Bill Currie
3bdec49587 [sw] Remove r_origin entirely
And clean up a lot of modelorg (a little trickier than it was for gl due
to messy usage).
2022-03-11 13:10:20 +09:00
Bill Currie
2606564955 [sw] Remove some dead code 2022-03-10 11:37:19 +09:00
Bill Currie
0cfff27cd0 [sw] Move surf and edge stats printing to begin_frame
Part of cleaning up SetupFrame
2022-03-09 22:53:15 +09:00
Bill Currie
3414eb12a3 [renderer] Move r_ambient and r_drawflat to client code
It makes more sense for these cvars to be under client control via
r_refdef. Completely disabled in qw, and currently ignored in nq.
2022-03-09 22:51:21 +09:00
Bill Currie
5477352e93 [renderer] Abandon sw32 altogether
I'd been considering it for a while, but in the end, all the issues it
presented made me decide it wasn't worth merging and was never really
worth keeping: it was a neat proof of concept but of little actual use,
especially now everyone either has an OK GPU or would want to stick to
8-bit rendering anyway (sorry L-Havoc).

However, both it and my merge work are preserved in git history :)
2022-03-09 21:36:15 +09:00
Bill Currie
19348f678f [win] Get the software renderer hobbling
16 and 32 bit rendering are disabled at the moment because there's a
weird segfault I need to fix, but the 8-bit dynamic lights are doing
weird things (for x11, too) when updating the light maps.
2022-03-09 20:00:59 +09:00
Bill Currie
747494c03a [sw] Fix 16 and 32 bit alias model rendering
Intel asm needs testing still, but C is working nicely.
2022-03-09 16:56:36 +09:00
Bill Currie
6377734e32 [renderer] Merge the two software renderers
I got tired of having to maintain two separate software renderers, but
didn't want to just nuke sw32, so its core changes are merged into sw.

Alias model rendering is broken, but I know exactly what's wrong and how
to fix it, just need to take care due to asm.
2022-03-09 15:56:19 +09:00
Bill Currie
5c8f3ec3ac [renderer] Fix some non-static linking issues
Well, hopefully I'll get the root cause sorted eventually. I really hate
globals.
2022-03-09 06:55:31 +09:00
Bill Currie
1fef0e50e0 [particles] Use read data instead of written data
I'm not sure this makes any difference (at 2500fps, the noise is crazy),
but fewer instructions can't hurt.
2022-03-09 06:47:43 +09:00
Bill Currie
a9cc51b22c [particles] Use correct index for source ramp
This fixes both the weird colors and a segfault in the 32-bit software
renderer.
2022-03-08 20:16:18 +09:00
Bill Currie
20536d83eb [vulkan] Clean up r_origin and modelorg
Same deal as for GL and GLSL.
2022-03-08 18:41:09 +09:00
Bill Currie
075a0fe326 [renderer] Clean up r_origin and modelorg
So far, in gl and glsl, but viewposition is much clearer than r_origin
(despite being the same thing), and modelorg is just confusing (I think
it's the view position relative to the current model).
2022-03-08 03:47:36 +09:00
Bill Currie
48c225da89 [renderer] Merge the fog support code
GL still has its own functions for enabling and disabling fog while
rendering, but GLSL doesn't need such (thanks to the shaders), nor will
vulkan (and the software renderers don't support fog).
2022-03-08 02:28:19 +09:00
Bill Currie
af0c66dff9 [renderer] Move frame rendering out a layer.
This is a step towards high-level unification of the renderers, as far
as possible keeping only actual low-level implementation details in the
individual renderers (some higher level stuff, eg shadows, is expected
to be per-renderer as some things are just not feasible to implement in
all renderers). However, the idea is to move the high-level
functionality into scene rendering.
2022-03-08 01:04:40 +09:00
Bill Currie
e1d38a9373 [renderer] Force-link r_efrag.o for static qwaq
As qwaq doesn't yet do any 3d rendering, it doesn't use efrags and thus
wasn't pulling in the object file, but the various renderers were trying
to access it. And I thought plugin builds were more difficult (I had
forgotten).
2022-03-07 16:59:01 +09:00
Bill Currie
ea223f6312 [sw] Clean up use of r_rectdesc
I have no idea why the struct even had a local vrect that was used for
temporary storage.
2022-03-07 16:57:22 +09:00