Commit Graph

12826 Commits

Author SHA1 Message Date
Bill Currie a8a8c567a2 [qfcc] Promote types before expanding scalars
This fixes the internal error generated by the likes of
`(sv_gravity * '0 0 1')` where sv_gravity is a float and `'0 0 1'` is an
ivec3: the vector is promoted to vec3 first so that expanding sv_gravity
is expanded to vec3 instead of ivec3 (which is not permitted for a
float: expansion requires the destination base type to be the same as
the source).
2022-09-14 14:43:31 +09:00
Bill Currie 5747ddb77f [qfcc] Skip recording defs for binary expressions
For now, anyway, as the generated code looks good. There might be
problems with actual pointer expressions, but it allows entity.field to
work as expected rather than generate an ICE.
2022-09-14 14:43:31 +09:00
Bill Currie 942ea22266 [qfcc] Promote types before expanding scalars
This fixes the internal error generated by the likes of
`(sv_gravity * '0 0 1')` where sv_gravity is a float and `'0 0 1'` is an
ivec3: the vector is promoted to vec3 first so that expanding sv_gravity
is expanded to vec3 instead of ivec3 (which is not permitted for a
float: expansion requires the destination base type to be the same as
the source).
2022-09-14 14:39:09 +09:00
Bill Currie 47ac7b924f [qfcc] Skip recording defs for binary expressions
For now, anyway, as the generated code looks good. There might be
problems with actual pointer expressions, but it allows entity.field to
work as expected rather than generate an ICE.
2022-09-13 21:31:54 +09:00
Bill Currie c771bfa58c [renderer] Correct freetype and harfbuzz lib linking
renderer_libs was in both LIBADD and DEPENDENCIES, so make was trying to
build the freetype and harfbuzz libs when building for windows.
2022-09-13 17:38:58 +09:00
Bill Currie 6ed045cd9c [audio] Ensure FLAC doesn't use dll imports
For whatever reason, building under MXE (for windows) causes FLAC to try
to use dll import references, but setting FLAC__NO_DLL before including
FLAC/export.h fixes the issue.
2022-09-13 17:13:57 +09:00
Bill Currie bf7ef354d5 [audio] Ensure FLAC doesn't use dll imports
For whatever reason, building under MXE (for windows) causes FLAC to try
to use dll import references, but setting FLAC__NO_DLL before including
FLAC/export.h fixes the issue.
2022-09-13 17:09:42 +09:00
Bill Currie 99196550d1 [renderer] Move r_font.c to correct library
Fixes the linker error in the standard build.
2022-09-12 08:43:28 +09:00
Bill Currie 71efbba628 [vulkan] Switch draw_pic to take subpic_t instead of qpic_t
While this does pull the grovelling for the subpic out to the callers,
the real problem is the excessive use of qpic_t in the internal code:
qpic_t is really just the image format in wad files, and shouldn't be
used as a generic image handle.

Cleans up more of the icky code in the font drawing functions.
2022-09-09 20:05:31 +09:00
Bill Currie 936f6d91e4 [vulkan] Use vertex queue objects for Draw
This makes working with quads, implied alpha quads, and lines much
cleaner (and gets rid of the bulk of the "eww" fixme), and will probably
make it easier to support multiple scraps and fonts, and potentially
more flexible ordering between pipelines.
2022-09-09 17:06:33 +09:00
Bill Currie a6611fc827 [gamecode] Fix a clang compile issue
Silly clang not being actually compatible :P
2022-09-09 14:59:08 +09:00
Bill Currie a76f6c812c [gamecode] Fix a clang compile issue
Silly clang not being actually compatible :P
2022-09-09 14:57:30 +09:00
Bill Currie ee5e38b46c [ruamoko] Implement default -describe method on Object
It returns [classname@address], which is probably a reasonable default.
2022-09-09 14:48:03 +09:00
Bill Currie 019b40fb81 [ruamoko] Implement %@ handing in the ruamoko runtime
-describe is sent to the object, and the returned string passed back.
There is a worry about the lifetime of the returned string as there's
currently no way of both ensuring it doesn't get freed prematurely and
ensuring it does eventually get freed.
2022-09-09 14:48:03 +09:00
Bill Currie be447fc9d6 [gamecode] Add optional support for %@ strings
If no handler has been registered, then the corresponding parameter is
printed as a pointer but with surrounding brackets (eg, [0xfc48]). This
will allow the ruamoko runtime to implement object printing.
2022-09-09 14:48:03 +09:00
Bill Currie 5ae782bf89 [qfcc] Add support for \uXXXX and \UXXXXXXXX
The resultant unicode is encoded as utf-8, which does conflict with the
quake character map, but right now unicode is useful only with font
text, and those support only standard unicode (currently only as utf-8),
but something will need to be sorted out.
2022-09-09 14:48:03 +09:00
Bill Currie 53d86e2a53 [qfcc] Don't check parameter size for arrays
Arrays are passed as a pointer to the first element, so are always valid
parameters. Fixes a bogus "formal parameter N is too large to be passed
by value" error.
2022-09-09 14:48:03 +09:00
Bill Currie b298bf6dcb [ruamoko] Implement default -describe method on Object
It returns [classname@address], which is probably a reasonable default.
2022-09-09 14:03:30 +09:00
Bill Currie 54bd8f5a02 [ruamoko] Implement %@ handing in the ruamoko runtime
-describe is sent to the object, and the returned string passed back.
There is a worry about the lifetime of the returned string as there's
currently no way of both ensuring it doesn't get freed prematurely and
ensuring it does eventually get freed.
2022-09-09 13:51:42 +09:00
Bill Currie 6db44afedc [gamecode] Add optional support for %@ strings
If no handler has been registered, then the corresponding parameter is
printed as a pointer but with surrounding brackets (eg, [0xfc48]). This
will allow the ruamoko runtime to implement object printing.
2022-09-09 09:27:36 +09:00
Bill Currie 1f9553d13e [qfcc] Add support for \uXXXX and \UXXXXXXXX
The resultant unicode is encoded as utf-8, which does conflict with the
quake character map, but right now unicode is useful only with font
text, and those support only standard unicode (currently only as utf-8),
but something will need to be sorted out.
2022-09-05 00:30:33 +09:00
Bill Currie 935e883d8d [renderer] Switch to using HarfBuzz for glyph positioning
This means that QF should support more exotic fonts without any issue
(once the rest of the text handling system is up to snuff) as HarfBuzz
does all the hard work of handling OpenType, Graphite, etc text shaping,
including kerning (when enabled).

Also, font loading now loads all the glyphs into the atlas (preload is
gone).
2022-09-04 20:56:38 +09:00
Bill Currie db69f5fd23 [renderer] Use VRect_SubRect for scrap allocation
While the results are a little surprising (tends to alternate between
left side and top for allocations), there is much less wasted space in
the partially allocated regions, and the main free region seems to
always be quite big.
2022-09-02 19:08:58 +09:00
Bill Currie 28e9a0a9ba [ui] Add a specialized function for subrect allocation
While VRect_Difference worked for subrect allocation, it wasn't ideal as
it tended to produce a lot of long, narrow strips that were difficult to
reuse and thus wasted a lot of the super-rectangle's area. This is
because it always does horizontal splits first. However, rewriting
VRect_Difference didn't seem to be the best option.

VRect_SubRect (the new function) takes only width and height, and splits
the given rectangle such that if there are two off-cuts, they will be
both the minimum and maximum possible area. This does seem to make for
much better utilization of the available area. It's also faster as it
does only the two splits, rather than four.
2022-09-02 17:47:27 +09:00
Bill Currie cd66dbfc97 [vulkan] Implement font rendering
It is currently an ugly hack for dealing with the separate quad queue,
and the pipeline handling code needs a lot of cleanup, but it works
quite well, though I do plan on moving to HarfBuzz for text shaping. One
nice development is I got updating of descriptor sets working (just need
to ensure the set is no longer in use by the command queue, which the
multiple frames in flight makes easy).
2022-09-02 14:23:19 +09:00
Bill Currie 73635d84bf [renderer] Add stubs for Draw_FontString
Draw_FontString is for font-based text rendering. Nothing is implemented
at this stage.
2022-09-02 11:38:09 +09:00
Bill Currie 599c09e77e [renderer] Add Draw_AddFont for registering a font
It's implemented only in the Vulkan renderer, partly because there's a
lot of experimenting going on with it, but the glyphs do get transferred
to the GPU (checked in render doc). No rendering is done yet: still
thinking about whether to do a quick-and-dirty test, or to add HarfBuzz
immediately, and the design surrounding that.
2022-08-31 19:23:30 +09:00
Bill Currie 096ecc7710 [vulkan] Fix incorrect image view format
R8G8B8A8 was hard-coded by accident when creating Vulkan_LoadTexArray
(or probably even the original Vulkan_LoadTex). This wasn't a problem
while everything was loaded in that format, but attempting to load an R8
texture didn't go so well. The same format as the image itself is used
now (correctly so).
2022-08-31 18:14:24 +09:00
Bill Currie 8c270a0a9e [vulkan] Switch to pre-multiplied alpha for 2d
I have recently learned that pre-multiplied alpha is the correct way to
do compositing, which is pretty much what the 2d pass does (actually,
all passes, but...). This required ensuring the color factor passed to
the fragment shader is pre-multiplied (a little silly for cshifts as
they used to be pre-multiplied but were un-pre-multiplied early in QF's
history and I don't feel like fixing that right now as it affects all
renderers), and also pre-multiplying alpha when converting from 8-bit
palette to rgba as the palette entry for transparent has that funky pink
(which is used in full-brights).
2022-08-30 14:29:22 +09:00
Bill Currie 4d5b38f0c9 [renderer] Star work on adding FreeType support
Right now, this just initializes the library and loads a font into
memory, preloading a given set of characters (specified by unicode
values).
2022-08-27 17:53:03 +09:00
Bill Currie d39f02ecfc [renderer] Don't round up scrap allocations
I will need to do more work to improve the 2d allocation, but rounding
up the requested sizes to the next power of two proved to be excessively
wasteful: I was able to allocate spots for only half of the sub-pics I
needed (though I did still need to double the number of pixels in the
end).
2022-08-27 17:46:14 +09:00
Bill Currie af4c120d3d [qfcc] Don't check parameter size for arrays
Arrays are passed as a pointer to the first element, so are always valid
parameters. Fixes a bogus "formal parameter N is too large to be passed
by value" error.
2022-08-27 17:42:08 +09:00
Bill Currie 630dde6df7 [render] Add basic 2d line drawing
The software renderer uses Bresenham's line slice algorithm as presented
by Michael Abrash in his Graphics Programming Black Book Special Edition
with the serial numbers filed off (as such, more just so *I* can read
the code easily), along with the Chen-Sutherland line clipping
algorithm. The other renderers were more or less trivial in comparison.
2022-08-27 17:29:15 +09:00
Bill Currie f611b0d5a1 [client] Preserve intensity when parsing light color
Due to the mis-initialization of the union used to parse the color
vector, the intensity was incorrectly set to zero and thus the light
dropped, meaning that all lights in ad_tears were lost.
2022-08-19 20:19:43 +09:00
Bill Currie 1e54799f69 [gamecode] Take care of failing uint conversion tests
By not doing the unrepresentable conversions, since they seem to be
undefined behavior and even gcc 12 is inconsistent with them
2022-08-18 18:18:19 +09:00
Bill Currie 95b8424ddf [qfcc] Use new extend instruction instead of swizzle
While swizzle does work, it requires the source to be properly aligned
and thus is not really the best choice. The extend instruction has no
alignment requirements (at all) and thus is much better suited to
converting a scalar to a vector type.

Fixes #30
2022-08-18 18:18:19 +09:00
Bill Currie d9d0a80752 [gamecode] Add an extend instruction
The extend instruction is for loading narrower data types into wider
data types, eg, single element into 2, 3, or 4 element types, with a
small set of extension schemes: 0, 1, -1, copy (for 1->any and 2 -> 4).
Possibly most importantly, it works with unaligned data.

Progress towards #30
2022-08-18 18:18:19 +09:00
Bill Currie 59b73353dd [qfcc] Fix integer vector constants for clang
It seems clang loses track of the usage of the referenced unions by the
time the code leaves the switch. Due to the misoptimization, "random"
values would get into the vector constants. This puts the usages in the
same blocks as the unions, causing clang to "get it right" (though I
strongly suspect I was running into UB).
2022-08-18 18:18:19 +09:00
Bill Currie 42287f1e0e [qfcc] Allow binary operations between vector and vec3
While I might need to tighten up the rules later, this allows binary
operations between vector (the type) and explicitly typed vec3 constants
(and non-constants, about which I am undecided). The idea is that
explicit constants such as '1 2 3'f should be compatible with either
type.

This applies to quaternions as well.
2022-08-18 18:18:19 +09:00
Bill Currie 0897952a57 Fix windows compile issues
ulong seems to be defined somewhere on Linux, thus I missed that, and of
course there's the fun with aligned memory allocation :/
2022-07-31 17:34:09 +09:00
Bill Currie 6253d775e6 [qfcc] Adjust ivar offsets to preserve alignment
As a class's ivars are built up by inheritance, but with only that
class's ivars in the symbol table, is is necessary to include an offset
based on the super class's ivars in order to ensure alignments are
respected. This is achieved via the new `base` parameter to
build_struct(), which is used to offset the current size while
calculating the aligned offset of the symbols. The parameter is ignored
for unions, as they always start at 0. The ivars for the current class
still have a base offset of 0 until they are actually added to the
class.

Fixes #29
2022-07-31 17:15:47 +09:00
Bill Currie f4ae24e0e0 [qfcc] Support alignment in qfo spaces
The alignment is specified as a power of 2 (ie, actual alignment = 1 <<
alignment) allowing old object files to be compatible (as their
alignment is 0). This is necessary for (in part for #30) as it turned
out even global vectors were not aligned correctly.

Currently, only data spaces even vaguely respect alignment. This may
need to be fixed in the future.
2022-07-31 17:15:47 +09:00
Bill Currie 732ea3a5fd Fix a bunch of issues for clang
One *actual* error (wrong enum type), and some memory alignment issues.
The rest just clang being lame.
2022-07-31 17:15:40 +09:00
Bill Currie 2c8bec27c7 Fix a pile of warnings for gcc 12
Most were pretty easy and fairly logical, but gib's regex was a bit of a
pain until I figured out the real problem was the conditional
assignments.

However, libs/gamecode/test/test-conv4 fails when optimizing due to gcc
using vcvttps2dq (which is nice, actually) for vector forms, but not the
single equivalent other times. I haven't decided what to do with the
test (I might abandon it as it does seem to be UD).
2022-07-31 17:13:26 +09:00
Bill Currie 330569a3fb [sound] Add a function to set ambient sounds
This gets ambient sounds (in particular, water and sky) working again
for quakeworld after the recent sound changes, and again for nq after I
don't know how long.
2022-06-06 14:29:14 +09:00
Bill Currie c72b04a522 [cvar] Remove a debug print 2022-06-06 14:28:28 +09:00
Bill Currie 520371a3aa [zone] Fix bad suggested mem calculation
Because the calculation didn't take the hunk header size (which is not
included in the hunk size) into account, the conversion to MB was one
short and thus the rounding up to the next 8 MB boundary was giving the
current total hunk size (ie, the already given size). Most confusing to
a user ("But I already asked for 128MB!").
2022-06-06 14:05:52 +09:00
Bill Currie ef64161835 [zone] Make Hunk_RawAlloc the core hunk allocator
It turns out that copying just "unknown" is a significant performance
hit when doing over 100M allocations. Making Hunk_RawAlloc the core and
initializing the name field with a single 0 shaved about a second off
`qfvis gmsp3v2.bsp` (from about 39s to about 38s).
2022-06-06 13:33:54 +09:00
Bill Currie 5c94c40985 [zone] Revert cache behavior to its original design
My reason for using Hunk_HighAlloc for allocating cache blocks was to
lock them down so they were safe for the sound mixer to access when
running in a real-time thread. However, I had never tested under tight
memory constraints, which proved that the design (or maybe just
implementation) just wasn't robust. However, now that sounds are loaded
into a completely separate region, it's safe to put the cache back to
its original behaviour (still with 64-byte alignment and such, of
course). This will even allow the high hunk to be used again, though it
effectively was anyway with Hunk_TempAlloc.
2022-06-06 13:33:15 +09:00
Bill Currie 5fa73e7ff2 [sound] Rename "cache" to "block" and clean out old code
I never liked "cache" as a name because it said where the sound was
stored rather than how it was loaded/played, but "stream" is ok, since
that's pretty much spot on. I'm not sure "block" is the best, but it at
least makes sense because the sounds are loaded as a single block (as
opposed to being streamed). An now, neither use the cache system.
2022-06-06 12:39:54 +09:00