Commit Graph

1671 Commits

Author SHA1 Message Date
Bill Currie 4cef9792f4 [util] Make hash-tables semi-thread-safe
They take a pointer to a free-list used for hashlinks so the hashlink
pools can be per-thread. However, hash tables that are not updated are
always thread-safe, so this affects only updates. progs_t has been set
up such that it is easy for multiple progs within one thread can share
hashlinks.
2020-03-25 15:43:16 +09:00
Bill Currie 713150b41a [gamecode] Add debug hooks to the VM engine
While there was a breakpoint hook, it was for only breakpoints and more
was needed. Now there's a generic hook that is called for tracing,
breakpoints, watch points, runtime errors and VM errors, with the
"event" type passed as the first parameter and a data pointer in the
second.
2020-03-24 19:45:10 +09:00
Bill Currie 4dbf280012 [util] Add a means to open a gap in a text buffer
for loading files into the buffer.
2020-03-22 20:19:25 +09:00
Bill Currie 28f50d2719 Add function key defs up to F48
This allows for the four combinations of shift and control. Not
bothering with alt because alt-f4 closes my xterm (bbkeys from the looks
of it: it grabs a bunch of Mod1-* keys).
2020-03-22 13:46:27 +09:00
Bill Currie 84cff64f99 Remove many key number hard-codings
I left the ones below 256 alone (some were necessary anyway), but above
256 they were almost entirely sequential, which rather defeats the
purpose of using an enum, especially since it makes it difficult to
expand sections.
2020-03-22 11:18:44 +09:00
Bill Currie 88b4046632 [util] Pass a data pointer to shutdown functions
And clean up the mess.
2020-03-22 00:57:54 +09:00
Bill Currie 4e739f6b36 Use dynamic array element type instead of __auto_type
This allows using 0 for pointer arrays.
2020-03-21 12:58:07 +09:00
Bill Currie 9678eba59b Initialize array pointer in dynamic array
Oops. I guess I was using calloc in the vulkan branch.
2020-03-21 12:58:07 +09:00
Bill Currie 1a7add3f6d Merge branch 'master' into vulkan 2020-03-20 13:04:41 +09:00
Bill Currie 38fc7459e4 Add DARRAY_INIT from the vulkan branch
Couldn't cherry-pick this one as it was a bigger commit.
2020-03-20 12:59:25 +09:00
Bill Currie 2966b035bf Add a fixed-array allocator
Turned out to be very convenient.
2020-03-20 12:59:25 +09:00
Bill Currie 0764df1276 Fix incorrect include protection 2020-03-20 12:59:25 +09:00
Bill Currie 966bd267c5 Add a set of macros for dynamic arrays
Includes docs and test cases.
2020-03-20 12:59:25 +09:00
Bill Currie ec12941fcb Move the ring buffer macros to their own header
They seem to have proven themselves to be robust.
2020-03-19 23:53:54 +09:00
Bill Currie 99f89840f9 [gamecode] Show containing def and relative offset
No more guessing when accessing structure field members. Next is ivars,
I guess.
2020-03-15 02:51:29 +09:00
Bill Currie 3d62a7f253 [gamecode] Use fuzzy bsearch to find defs by address
The idea is to find th def that contains the address. Had to write my
own bsearch (well... lifted from wikipedia) because libc's is exact. The
defs are assumed to be sorted (which qfcc now ensures when it writes
progs and sym files).
2020-03-15 02:48:13 +09:00
Bill Currie fea6381574 [gamecode] Rework debug type handling a little
Type encodings are used whenever they are available. For now, if they
are not, then everything is treated as void (which prints <void>, not
very useful). Most return statements and references to .return are now
very readable (excluding structs), and only params going through "..."
are a messy union.
2020-03-14 20:44:43 +09:00
Bill Currie a0d85e33c2 [gamecode] Rework implementation of memset*
The memset instructions now match the move* instructions other than the
first operand (always int). Probably breaks much, but fixed in next few
commits.
2020-03-13 17:50:57 +09:00
Bill Currie 6ca85d770d [gamecode] Add memset instructions 2020-03-11 22:48:55 +09:00
Bill Currie f290b115a5 [gamecode] Add function PR_PushTempString
This "pushes" a temp string onto the callee's stack frame after removing
it from the caller's stack frame. This is so builtins can pass
auto-freed memory to called progs code. No checking is done, but mayhem
is likely to ensue if a string is pushed that was allocated in an
earlier frame.
2020-03-09 23:36:09 +09:00
Bill Currie 7d43bd5c66 [gamecode] Add function PR_AllocTempBlock()
PR_AllocTempBlock() works the same way as PR_SetTempString(), except
that it takes a size parameter and always allocates (never tries to
merge). This is, in a way, abusing the string system, but I needed a way
to allocate a block of progs memory that would be automatically freed
when the current frame ended. The biggest abuse is the need to cast away
the const of PR_GetString()'s return value.
2020-03-09 22:16:19 +09:00
Bill Currie e2f4c189f9 [ruamoko] Install and use dispatch tables
This should speed up ruamoko code somewhat as hash table lookups have
been replaced with direct array indexing. As a bonus, support for
message forwarding has been added (though not tested).
2020-03-09 18:11:36 +09:00
Bill Currie 98756df9f7 [gamecode] Set final resource map free list pointer
The sub-tables were being properly linked together, but the very final
table was not properly terminated.
2020-03-09 18:03:25 +09:00
Bill Currie 3b959c3ed0 [gamecode] Add a macros for arbitrary param/return types
Of course, the type has to be small enough to fit or bad things may
happen, but it beats having to type the crazy casting every time.
2020-03-06 00:23:44 +09:00
Bill Currie de01cff70e [build] Install QF/keys.h into qfcc's include directory
As well as $prefix/include, of course. This fixes the problem with
external ruamoko builds failing due to keys.h and qfcc's "lockdown" on
system headers.
2020-03-03 22:22:53 +09:00
Bill Currie 4e4b553cc3 [gamecode] Take care of missed type alias stuff 2020-03-01 16:20:23 +09:00
Bill Currie caa297b756 [qfcc] Remove type alias encoding
It proved to be too fragile in its current implementation. It broke
pointers to incomplete structs and switch enum checking, and getting it
to work for other things was overly invasive. I still want the encoding,
but need to come up with something more robust.a
2020-03-01 16:13:18 +09:00
Bill Currie 75f4cebf0e Clean up after removal of uint32.h
I guess I forgot to check for its usage in header files, and the fact that
it didn't get cleaned out from being installed hid the error.
2020-02-29 16:11:07 +09:00
Bill Currie ddd007e2d5 [dstring] Return the string instead of printed size
Other than consistency with printf(), I'm not sure why we went with the
printed size as the return value; returning the resultant strings makes
much more sense as dsprintf() (etc) can then be used as a safe va()
2020-02-26 19:00:19 +09:00
Bill Currie 383a7fe5e1 Remove File_Open
Other than its blocking of access to certain files, it really wasn't
that useful compared to the functions in qfs, and pointless with access
to qfs anyway.
2020-02-26 13:45:14 +09:00
Bill Currie aa02069dd1 Add a breakpoint flag to opcodes
The progs execution code will call a breakpoint handler just before
executing an instruction with the flag set. This means there's no need
for the breakpoint handler to mess with execution state or even the
instruction in order to continue past the breakpoint.

The flag being set in a progs file is invalid.
2020-02-26 13:40:26 +09:00
Bill Currie 42713cad8b Make script much friendlier to use
It now simply sets an error message pointer and returns false if there's
an error.
2020-02-26 09:39:03 +09:00
Bill Currie 35c9d6ee38 Make pr_obcode.c mostly thread safe
Its public data is all read-only, and once set up, its private data is
too (just don't call init in multiple threads).
2020-02-26 01:20:28 +09:00
Bill Currie 3577d27a45 Move the ObjQC data into a resource block
This makes it nice and private (though with the cached pointer, ObjQC is
still a first-class component).
2020-02-25 23:14:18 +09:00
Bill Currie 66dd3ef070 Make a bunch of count things positive-only
This fixes a pile of FIXMEs, because some things should never be
negative.
2020-02-25 21:23:13 +09:00
Bill Currie 4bc36836a1 Correct the type of an aux function's return type
It was made to be the address of the type encoding long ago.
2020-02-25 20:17:20 +09:00
Bill Currie 89e83d7d73 Move the debug info out of progs_t
The debug subsystem now uses the resources system to ensure it cleans
up, and its data is now semi-private. Unfortunately, PR_LoadDebug had to
remain public for qfprogs because using PR_RunLoadFuncs would cause
builtin resolution to complain.
2020-02-25 20:07:29 +09:00
Bill Currie a55b9544ac Improve handling of pr_argc
It is now set to 0 when progs are loaded and every time
PR_ExecuteProgram() returns. This takes care of the default case, but
when setting parameters, pr_argc needs to be set correctly in case a
vararg function is called.
2020-02-25 17:36:29 +09:00
Bill Currie 6a4ef598ab Allow progs num_edicts and reserved_edicts to be null
Really, while there are edict related instructions, edict support should
probably not be in the VM itself.
2020-02-25 15:00:33 +09:00
Bill Currie 9bb68f2d8c Allow nested use of PR_SaveParams()
PR_SaveParams() is required for implementing the +initialize diversion
used by Objective-QuakeC because builtins do not have local def spaces
(of course, a normal stack calling convention would help). However, it
is entirely possible for a call to +initialize to trigger another call
to +initialize, thus the need for stacking parameter stashes. As a
bonus, this implementation cleans up some fields in progs_t.
2020-02-25 14:30:26 +09:00
Bill Currie 256dee98a1 Make progs string resources management private
Strangely enough, using the progs resources system. This is a step
towards having progs that can be reset properly, or even dynamically
created VMs.
2020-02-25 00:23:08 +09:00
Bill Currie f7493fe8fb Add a buffer-gap text buffer
This should be good for text editing and working with text files in
general.
2020-02-24 17:30:33 +09:00
Bill Currie a30433fa9e Make header protection consistent
And delete a couple of useless files.
2020-02-24 12:21:20 +09:00
Bill Currie 7406e0308e Fix some warnings picked up in an optimized build 2020-02-24 11:28:43 +09:00
Bill Currie dda045bf96 Do lazy computation of def sizes from type encodings
The size is calculated when needed and cached.
2020-02-23 23:29:58 +09:00
Bill Currie e6f243323e Fix type of class in qfo type encodings 2020-02-23 22:26:09 +09:00
Bill Currie 23573953a7 Change pr_type_size to pr_ushort_t 2020-02-23 22:25:08 +09:00
Bill Currie 7efefceee2 Fix a comment 2020-02-23 22:21:25 +09:00
Bill Currie b173c35eb4 Rework progs debug to use the type encodings
It's only a start: the output is, if anything, slightly worse than
before, but it does have the basics going.
2020-02-23 19:01:59 +09:00
Bill Currie 4b7ecdf74a Make PR_Init take an instance to initialize
This allows internal sub-systems to do per-instance initializations
without other engine systems having to know about them.
2020-02-23 18:32:16 +09:00
Bill Currie f8b1a3a89f Return the previous sys print callbacks
This allows for temporary overrides.
2020-02-23 11:41:19 +09:00
Bill Currie 806af85447 Remove reference to ddef_t from progs.h
This cleans up some horrible names and redundant fields that were a
result of the transition to pr_def_t
2020-02-22 22:44:08 +09:00
Bill Currie 81083698a8 Move to using an in-memory form of ddef_t
This allows the VM to work with extended ddefs transparently. It seems
to have uncovered a typedef alias relocation bug, though.
2020-02-22 22:33:44 +09:00
Bill Currie 4df926e531 Write extended ddef information to progs far data
I was originally going to put it in the debug syms file, but I realized
that the data persistence code would need access to both def type and
certainly correct def offsets for defs in far data.
2020-02-22 14:11:15 +09:00
Bill Currie c296514b95 Make pr.load_file 'return' the file size 2020-02-21 21:17:28 +09:00
Bill Currie fe796eee68 Move the meta type enum ino pr_type.h 2020-02-21 17:58:19 +09:00
Bill Currie 3c9e2a6451 Rename the sys documentation group 2020-02-21 17:54:42 +09:00
Bill Currie caf78b5422 Rename ty_none to ty_basic
This far better reflects the actual meaning. It is very likely that
ty_none is a holdover from long before there was full type encoding and
it meant that the union in qfcc's type_t had no data. This is still
true for basic types, but only if not a function, field or pointer type.
If the type was function, field or pointer, it was not true, so it was
misnamed pretty much from the start.
2020-02-21 17:52:00 +09:00
Bill Currie 2f18364364 Start work on encoding typedef chains 2020-02-19 21:41:46 +09:00
Bill Currie ad175d054b Sanitize pipelines
wow, talk about doing things the wrong way. I guess that's the problem
with following a book targeted for C++: you get all that safety-goat
nonsense.
2020-02-18 22:38:01 +09:00
Bill Currie 264c4ccdac Sanitize descriptors
I'm sure it will end soon, I think pipelines is the end of it.
2020-02-18 21:18:03 +09:00
Bill Currie ba654b09f7 Create and destroy render pass and frame buffers 2020-02-18 17:18:37 +09:00
Bill Currie 1f4c019abc Create and destroy color/depth resources 2020-02-18 14:28:28 +09:00
Bill Currie 89d48b5650 Output first pixels
Just clearing the screen to 0xbada55, but the validation layer is quiet.
2020-02-18 01:03:36 +09:00
Bill Currie 73fde40cad Sanitize some more structs 2020-02-17 23:30:25 +09:00
Bill Currie 94565c2382 Rework much of the Vulkan array handling
So much for all those little wrappers hiding the device. Some survived,
but mostly just the bigger things like device, swapchain, etc.
2020-02-17 20:29:35 +09:00
Bill Currie 65890dd2fb Add a fixed-array allocator
Turned out to be very convenient.
2020-02-17 20:27:43 +09:00
Bill Currie cb70dc7212 Fix incorrect include protection 2020-02-17 16:40:12 +09:00
Bill Currie 0cb04dc490 Add a set of macros for dynamic arrays
Includes docs and test cases.
2020-02-17 16:17:21 +09:00
Bill Currie 916e57de37 Get the swapchain image switching sort of working
The render pass isn't set up yet, so the validation layer is having a
fit, but cycling through the swapchain images does seem to be working.
2020-02-17 00:50:39 +09:00
Bill Currie 4b152a4492 Rework semaphore sets 2020-02-17 00:10:32 +09:00
Bill Currie 559bd2e636 Create command pool and frame timing fences
Nothing is actually done yet, so the reported fps is around 172k (yes,
k), but startup and shutdown seems to be clean (yay validation layers).
2020-02-16 22:45:27 +09:00
Bill Currie b947cc1791 Rework command buffer and fence-set management
I found command buffer handling to be totally redundant and fence-set
management to be a bit awkward.
2020-02-16 22:43:57 +09:00
Bill Currie 9ff4eefe65 Merge branch 'master' into vulkan 2020-02-16 18:17:50 +09:00
Bill Currie f5741a979e Implement parameter alignment in the engine
The engine now requires non-v6 progs to store the log2 alignment for the
param struct in .param_alignment.

PR_EnterFunction is clearer and possibly more efficient.
2020-02-16 17:13:45 +09:00
Bill Currie 7a399c956b Encode function parameter alignment
The encoding is 3:5 giving 3 bits for alignment (log2) and 5 bits for
size, with alignment in the 3 most significant bits. This keeps the
format backwards compatible as until doubles were added, all types were
aligned to 1 word which gets encoded as 0, and the size is unaffected.
2020-02-16 17:10:43 +09:00
Bill Currie b4fd804e4e Implement true modulo in the engine 2020-02-16 11:53:56 +09:00
Bill Currie 4269c8cb07 Rename the mod instruction to rem
Because % really implements remainder rather than true modulo, and I
plan on adding %% to implement true modulo.
2020-02-16 11:04:30 +09:00
Bill Currie 98216c6eb0 Fixed some missed doxygen updates 2020-02-15 23:49:12 +09:00
Bill Currie df7c08a010 Add support for doubles to Ruamoko
Only as scalars, I still need to think about what to do for vectors and
quaternions due to param size issues. Also, doubles are not yet
guaranteed to be correctly aligned.
2020-02-15 23:49:12 +09:00
Bill Currie c50dda1d08 Document segmented text 2020-02-15 23:48:47 +09:00
Bill Currie 8654ac44bb Fix incorrect struct forward declaraction 2020-02-15 17:56:11 +09:00
Bill Currie d56f88f779 Implement swapchain image acquisition 2020-02-15 17:56:02 +09:00
Bill Currie 53b46f0541 Implement pipeline stuff 2020-02-13 04:21:35 +09:00
Bill Currie 61036378e2 Implement render pass stuff 2020-02-12 18:55:51 +09:00
Bill Currie 85a2f9f621 Implement descriptor stuff 2020-02-12 16:36:01 +09:00
Bill Currie 31501ad641 Add some docs for linked lists
Found in an old stash
2020-02-12 10:52:47 +09:00
Bill Currie 9248e8cf01 Update for doxygen 1.8.16 2020-02-11 15:22:42 +09:00
Bill Currie fbd79963bb Update for doxygen 1.8.16 2020-02-11 15:20:49 +09:00
Bill Currie 29b1d6baf8 Finish up memory stuff
For now, of course.
2020-02-11 09:37:04 +09:00
Bill Currie 1baee0cbba Implement mem mapping and buffer/image copying 2020-02-10 20:42:19 +09:00
Bill Currie 43e37aa31e Separate out the generic memory stuff 2020-02-10 18:33:29 +09:00
Bill Currie 9fdc15c439 Implement image stuff up to view creation 2020-02-10 18:18:37 +09:00
Bill Currie f4c0d0ebcf Implement buffer view creation
And rename memory allocation as it's buffer-specific.
2020-02-10 18:17:58 +09:00
Bill Currie 2f9ad73f78 Implement buffer memory up to barriers
Still lots to go (views, destruction, transfer...) and I'm uncertain
about the location of the pipeline barrier function.
2020-02-10 15:07:35 +09:00
Bill Currie 8148f256f5 Rework object device caching
It turned out I needed access to the physical device from a buffer
object, so rather than storing the vulkan logical device directly in
buffer (and other) objects, store the qfv logical device.
2020-02-07 11:45:05 +09:00
Bill Currie d3b4e4653e Cache physical devices in the instance 2020-02-06 19:04:28 +09:00
Bill Currie 4957c4f31a Implement the rest of the command stuff 2019-07-23 13:05:32 +09:00
Bill Currie a165d67dfa Add a queue type 2019-07-23 12:37:47 +09:00
Bill Currie 411b897f09 Implement most of the stuff for command submission 2019-07-23 12:28:57 +09:00