Commit Graph

12436 Commits

Author SHA1 Message Date
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 020ada9fb1 [util] Clean up nested macro temp var names a little
clang doesn't like the same variable name being used in nested
expression statements, so give the "safety" variables in reused macros
semi-meaningful (based on macro name) tails to keep them separate.
2022-03-31 14:44:51 +09:00
Bill Currie aed5cdee8e [sbar] Disable some unused functions
I don't know why draw_altstring is there at all, but draw_nstring being
in nq is likely due to minimising the diffs between nq and qw.
2022-03-31 03:02:55 +09:00
Bill Currie 2abd4a5e79 [qw] Clean up some int-char warnings
More harmlessness, but no harm telling the compiler to sit in the
corner.
2022-03-31 03:00:24 +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 73c65749fc [qfvis] Fix a vector type error
I suspect I wasn't getting nan like I wanted.
2022-03-31 01:17:47 +09:00
Bill Currie 12300d9a98 [qfcc] Remove alias offset from initialize_def
I'm not sure which is mysterious: why it's there, or why it did nothing.
Since it does nothing and things are working, it should be safe to
remove.
2022-03-31 01:15:59 +09:00
Bill Currie 3479897224 [qfcc] Fix some not uninitialized warnings
The "not" because I'm pretty sure they're false positives due to when
the function is called, but clang doesn't know that (wonder why gcc was
ok with it).
2022-03-31 00:37:53 +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 0bb562f93f Fix a bunch of float vs int bugs
Just those made me glad I tried compiling with clang: running into those
bugs would have lead to some serious headaches, I imagine.
2022-03-31 00:28:26 +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 1d1a59ac94 [build] Ensure va_copy def comes after HAVE_VA_COPY
and HAVE__VA_COPY as well. Fixes clang's complaint about va_copy being
redefined.
2022-03-30 23:29:17 +09:00
Bill Currie d8a7706e58 [build] Test for gcc optimization options
While clang accepts gcc's optimization options, it produces a warning
when it ignores them, so need to set -Werror before checking for those
options when building with -Werror otherwise the build will fail.
2022-03-30 23:23:34 +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 f21c2178fa [renderer] Move cshift defs into client
Definitely not something for the renderer to care about directly (ie, at
most, a post-process filter setting or palette update, which is how it
actually is currently).
2022-03-29 14:46: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