Commit Graph

11855 Commits

Author SHA1 Message Date
Bill Currie 920c5fd99b [gamecode] Add debug event name strings
Makes it easier to print nice debug event messages.
2022-01-03 23:26:50 +09:00
Bill Currie 8a2788c267 [gamecode] Add PROG_V6P_VERSION and bump PROG_VERSION
This allows the VM to select the right execution loop and qfcc currently
still produces only the old IS (it doesn't know how to deal with the new
IS yet)
2022-01-03 13:56:43 +09:00
Bill Currie 925797b1d4 [gamecode] Add a new Ruamoko instruction set
When it's finalized (most of the conversion operations will go, probably
the float bit ops, maybe (very undecided) the 3-component vector ops,
and likely the CALLN ops), this will be the actual instruction set for
Ruamoko.

Main features:
 - Significant reduction in redundant instructions: no more multiple
   opcodes to move the one operand size.
 - load, store, push, and pop share unified addressing mode encoding
   (with the exception of mode 0 for load as that is redundant with mode
   0 for store, thus load mode 0 gives quick access to entity.field).
 - Full support for both 32 and 64 bit signed integer, unsigned integer,
   and floating point values.
 - SIMD for 1, 2, (currently) 3, and 4 components. Transfers support up
   to 128-bit wide operations (need two operations to transfer a full
   4-component double/long vector), but all math operations support both
   128-bit (32-bit components) and 256-bit (64-bit components) vectors.
 - "Interpreted" operations for the various vector sizes: complex dot
   and multiplication, 3d vector dot and cross product, quaternion dot
   and multiplication, along with qv and vq shortcuts.
 - 4-component swizzles for both sizes (not yet implemented, but the
   instructions are allocated), with the option to zero or negate (thus
   conjugates for complex and quaternion values) individual components.
 - "Based offsets": all relevant instructions include base register
   indices for all three operands allowing for direct access to any of
   four areas (eg, current entity, current stack frame, Objective-QC
   self, ...) instructions to set a register and push/pop the four
   registers to/from the stack.

Remaining work:
 - Implement swizzle operations and a few other stragglers.
 = Make a decision about conversion operations (if any instructions
   remain, they'll be just single-component (at 14 meaningful pairs,
   that's a lot of instructions to waste on SIMD versions).
 - Decide whether to keep CALL1-CALL8: probably little point in
   supporting two different calling conventions, and it would free up
   another eight instructions.
 - Unit tests for the instructions.
 - Teach qfcc to generate code for the new instruction set (hah, biggest
   job, I'm sure, though hopefully not as crazy as the rewrite eleven
   years ago).
2022-01-03 00:49:49 +09:00
Bill Currie 0c17c6dc24 [gamecode] Rename the old opcodes
To reflect their basis on v6 progs instructions, they sport the v6p tag
where the p is for "plus" due to the QuakeForge extensions.
2022-01-02 21:30:02 +09:00
Bill Currie bc0a09f452 [gamecode] Switch to using type parameter op macros
I wish I'd done it this way years ago (but maybe gcc 2.95 couldn't hack
the casts, I do know there were aliasing problems in the past). Anyway,
this makes operand access much more consistent for variable sized
operands (eg float vs double vs vec4), and is a big part of the new
instruction set implementation.
2022-01-02 20:46:32 +09:00
Bill Currie 7b0eceda32 [gamecode] Split out the old quake c execution loop
There is no reasonable way (due to hardware-enforced alignment issues)
to simply convert old bytecode to new (probably best done with an
off-line tool, preferably just recompiling when I get qfcc up to the
job), so both loops will need to be present. This just moves the
original loop into its own function in order to make it easy to bring in
the new (and iron out integration issues).
2022-01-02 20:16:45 +09:00
Bill Currie ba5f6d97c6 [gamecode] Remove the right_associative field
It has been useless pretty much since I switched to using bison for the
parser.
2022-01-02 19:09:58 +09:00
Bill Currie c42043ced4 [gamecode] Add types needed for new instruction set
In particular, the various 2d and 4d vector types, and 64-bit types.
Also, some aliases to make instruction implementation macros workable.
2022-01-02 17:48:43 +09:00
Bill Currie 63442895fc [simd] Add the new headers to dist 2022-01-02 16:10:37 +09:00
Bill Currie 0e1964bf74 [simd] Split out the ivec implementations
And add any/all/none functions.
2022-01-02 16:02:57 +09:00
Bill Currie f56fd6ffb6 [qfcc] Preserve requested alignment if larger
build_struct was unconditionally setting the type's alignment. This was
not a problem before because no types were requesting alignments larger
than those requested by their members (for structs). However, with the
upcoming new instruction set, quaternions need to be 4-word aligned.
2022-01-02 11:44:48 +09:00
Bill Currie 5fb28d7c38 [math] Clean up vector component operations
And add a unary op macro. Having VectorCompOp makes it easy to write
macros that work for multiple data widths, which is why it and its users
now use (dst, ...) instead of (..., dst) as in the past. I'll sort out
the other macros later now that I know the compiler handily gives
messages about the switched order (uninitialized vars etc).
2022-01-02 01:15:17 +09:00
Bill Currie 937f36384b [cexpr] Use correct functions for double trunc/floor
Found while sorting out the changes for the new 2d vectors.
2022-01-02 01:13:17 +09:00
Bill Currie 9aa8f18d73 [math] Split out Quat/Vector compare implementations
This renames existing VectorCompCompare (and quaternion equivalent) to
VectorCompCompareAll and makes VectorCompCompare produce a vector of
results with optional negation (converting 0,1 to 0,-1 for compatibility
with simd semantics).
2022-01-02 01:09:51 +09:00
Bill Currie 97034d9dde [simd] Add 2d vector types
For int, long, float and double. I've been meaning to add them for a
while, and they're part of the new Ruamoko instructions set (which is
progressing nicely).
2022-01-02 00:57:55 +09:00
Bill Currie 365762b8a6 [gamecode] Switch to using indexed initializers
The opcode table is a nightmare to maintain, but this does clean it up
and speed up opcode lookups since they can now be indexed. Of course, it
turns out I had missed adding several instructions, so had to fix that,
and qfcc needed a bit of a re-jigger to get the opcode out of the table.
2021-12-31 19:16:02 +09:00
Bill Currie be474d9937 [gamecode] Remove the wart from def and function names
I never liked the leading s_ (though I guess it means one is supposed to
interpret the int as a string pointer, but meh).
2021-12-31 15:02:31 +09:00
Bill Currie 6990bd5752 [gamecode] Add some more comments to dfunction_t 2021-12-31 14:48:52 +09:00
Bill Currie 2dc806cff5 [ruamoko] Clean up Entity a little
Hide own, and add some class spawn methods.
2021-12-30 13:26:36 +09:00
Bill Currie 7a481039f8 [qw] Check tracked player name before printing
The server switching levels while the client is tracking a player (at
least a server client) seems to at least temporarily clear the player
slot and thus the name value pointer becomes null. This fixes the
resulting segfault.
2021-12-30 02:02:22 +09:00
Bill Currie 70aaafda10 [ruamoko] Clear dtable list on reset
The list of all allocated dispatch tables is used to free all the tables
when the progs are reloaded. Not clearing the list meant that the next
instance (second map change) corrupted the list.
2021-12-30 00:21:29 +09:00
Bill Currie 3c17efe91b [console] Unhook hooked functions on shutdown
Forgetting to unhook the functions (Sys_Printf and the client console's
input event handler) was not a problem for static builds because the
functions were always present, but in builds with dynamic plugins, the
client console's code got ripped away and thus Sys_Printf and the event
hander were being sent into invalid memory. Too much work, not enough
play (with a fully installed client).
2021-12-29 21:50:38 +09:00
Bill Currie 760256c99e [qw] Add SV_ClientNumber builtin
This is a quick way to find the client number for an entity. It returns
-1 if the entity is not a valid client (either outside the client block,
or not currently in use by a client).
2021-12-29 21:22:51 +09:00
Bill Currie 44c48feb56 [qfcc] Add attached node's parents to source edges
The assignment to the node's variable must come after any uses of that
node, which the node's parent set indicates. In the swap test, this was
not a problem as the node had no parents, and in the link order test, it
just happened(?) to work.
2021-12-28 09:23:14 +09:00
Bill Currie 5f4a330b02 [console] Tweak the server status bar colors
Now the yellow stands out nicely.
2021-12-28 00:06:12 +09:00
Bill Currie dd17e8120d [qw] Clear qtv message buf before writing
I'm not sure this is the right place, but it prevents the packet
overflowing when a qtv proxy connects to a busy server (12+ bots).
2021-12-27 22:55:29 +09:00
Bill Currie 2aae757eff [qtv] Set worldmodel just after svc_modellist
Not sure why I thought skins_f was a good place. This seems to be much
more reliable.
2021-12-27 22:54:22 +09:00
Bill Currie 6d6440457a [qw] Add progs memory display to server status bar
This makes it easy to check for memory leaks before they crash the
server.
2021-12-27 20:28:33 +09:00
Bill Currie 1be220559a [zone] Add function to retrieve memory usage 2021-12-27 20:12:03 +09:00
Bill Currie 06d14eb411 [qtv] Get entity bounds from the model
This gets culling working nicely
2021-12-27 19:45:25 +09:00
Bill Currie 65f78b43ac [gamecode] Try to set field def size
This fixes the edicts command not printing anything useful.
2021-12-27 19:02:39 +09:00
Bill Currie 78220ff420 [netchan] Correct type of last_received
Storing a double in a float does not go well when that double starts at
4294967296. Fixes the delayed timeouts in qtv.
2021-12-27 18:13:44 +09:00
Bill Currie 94871671d2 [qw] Use a callback for netchan logging
This gets outgoing packet logging working again. Yay, fill my hard-drive
faster ;)
2021-12-27 17:54:58 +09:00
Bill Currie 58bbed722a [qtv] Handle time a little more correctly
realtime needs to be set before any other part of qtv runs.
Fixes the instant timeouts.
2021-12-27 17:34:21 +09:00
Bill Currie 57dbd7ed72 [qtv] Load the right model for world
For whatever reason, the client puts the models offset by one, but qtv
does not. It's much easier to find dm6.bsp than *1 :P
2021-12-27 17:34:21 +09:00
Bill Currie 8433905015 [qfcc] Extend reachable to the label node's parents
While using just the label node's reachable set was sufficient for a
simple swap (t = a; a = b; b = t;), it is not sufficient for
read-before-write dependencies such as found in linked-list building:

    { o = array[ind]; o.next = obj; obj = o; }

The assignment to o.next uses obj, but that use is hidden because obj's
reachable nodes does not include o thus assigning o to obj causes the
array dereference to be assigned directly to obj and thus o.next winds
up pointing to o instead of whatever obj was. The parent nodes of obj's
node are its users, so any new assigned to obj must come after those
parents as well as any node reachable by obj's node.

Fixes a runaway loop error when adding a frikbot to the server.
2021-12-27 14:25:55 +09:00
Bill Currie 4ad84b3786 [qfcc] Add a test for use/write dependencies
I ran into this with frikbot causing an infinite loop due to incorrectly
linked objects.
2021-12-27 14:17:12 +09:00
Bill Currie 44dd183d55 [qfcc] Make it a little easier to see extra info
instead of having to find an #if 0, just uncomment the define.
2021-12-27 14:15:51 +09:00
Bill Currie cafc6a541f [gamecode] Get PR_Profile working
The switch from using pr_functions (dfunction_t) to function_table
(bfunction_t) for keeping track of the current function (and thus
profiling data) broke PR_Profile as it never saw anything but 0.
2021-12-27 13:50:49 +09:00
Bill Currie 6368791d2b [gamecode] Check entity_var is valid before display
Even NUM_FOR_BAD_EDICT will have a bad day if the edict pointer is
invalid, so make sure that the entity pointer is valid (within the edict
area AND a multiple of edict size).
2021-12-27 13:47:55 +09:00
Bill Currie 95991e0d77 [qfcc] Check switch test expression early
Avoids a segfault when the test expression has errors.
2021-12-27 00:47:35 +09:00
Bill Currie 3059aa7979 [qfcc] Preserve input qfo data in qfo_to_progs
qfo_to_progs was modifying the space data pointers in the input qfo,
making it impossible to reuse the qfo. However, qfo_relocate_refs needs
the updated pointers, thus do a shallow copy of the qfo and its spaces
(but not any of the data)
2021-12-27 00:27:15 +09:00
Bill Currie f373192a02 [gamecode] Set pr_string_resources in PR_Strings_Init
Like for debug, this is the most sensible place as the pointer will
never change.
2021-12-26 22:46:07 +09:00
Bill Currie 5588d0de60 [gamecode] Separate debug byte-swap and pointer init
PR_LoadDebug now does only the initial version and crc checks, and the
byte-swapping of the loaded symbols file. PR_DebugSetSym sets up all the
pointers.
2021-12-26 22:39:37 +09:00
Bill Currie dcf8beeccc [qfcc] Remove a union wart from qfo_mspace_t 2021-12-26 20:37:01 +09:00
Bill Currie c9f372fa38 [gamecode] Set pr_debug_resources in PR_Debug_Init
And use the cached value in PR_LoadDebug.
2021-12-26 20:35:09 +09:00
Bill Currie c163b311d0 [gamecode] Create hash tables in PR_Init
This makes much more sense than in PR_LoadProgsFile (and simplifies the
latter, too).
2021-12-26 20:33:37 +09:00
Bill Currie 1d3970bc38 [qfcc] Allow extern builtin function declarations
build_builtin_function does the right thing, and it was only legacy
syntax functions that were affected anyway. Certainly, external
variables should not be initialized, but klik uses @extern { } wrapped
around several builtin functions and I had added the feature to allow
just this as it is rather convenient.
2021-12-26 15:01:38 +09:00
Bill Currie 046b9600d5 [qtv] Fix a pile of bit-rot
qtv compiles again after rebasing. I doubt the changes actually work.
2021-12-26 14:45:32 +09:00
Bill Currie 0ba00652a1 some work on getting pvs compiling 2021-12-26 13:10:16 +09:00