havoc [Thu, 23 Jan 2020 20:47:27 +0000 (20:47 +0000)]
Move tracking of aliases and csqc function overrides to a separate cmd_userdefined_t structure, this way it can be shared between cmd_client and cmd_clientfromserver.
This restores functionality so that stuffcmd in svqc can create aliases that are usable in the client, and can invoke csqc commands, but still have restrictions on engine commands.
havoc [Thu, 23 Jan 2020 08:19:11 +0000 (08:19 +0000)]
Redesigned TaskQueue to have a queue and distributor model so that threads can keep their own queues of work to do without locking to check for more work. Tasks are not executed until TaskQueue_WaitForTaskDone calls TaskQueue_DistributeTasks.
Added a fast path to TaskQueue_DistributeTasks for tasks that are waiting on other tasks to finish first, they are simply dequeued and re-enqueued immediately, and tend to just live on the distributor queue.
TaskQueue thread count is now dynamically adjusted based on tasks being queued per frame, and has a minimum and maximum thread count.
TaskQueue threads now sleep when idle, this may not be ideal, but did substantially lower the cpu usage so that it doesn't make other applications relatively unresponsive like it did before.
Removed taskqueue_task_t->started field and some other unused fields.
havoc [Wed, 22 Jan 2020 10:33:30 +0000 (10:33 +0000)]
Changed loading screen to continue during a connection attempt if the console or menu is not forced.
Changed scr_conforcewhiledisconnected 1 to not force the console during a connection attempt, kept the old behavior as scr_conforcewhiledisconnected 2.
If console is already open, the loading screen while connecting is not forced.
havoc [Wed, 22 Jan 2020 09:39:43 +0000 (09:39 +0000)]
Change default value of scr_loadingscreen_background to 0. It's not clear to me if anyone wants this to be 1, some of the bigger games using the engine set it to 0 already.
havoc [Wed, 22 Jan 2020 09:25:29 +0000 (09:25 +0000)]
Fix drawflag handling in Mod_Mesh_GetTexture by duplicating texture_t when drawflag overrides differ (it still uses the same skinframe_t so it's not duplicating the actual texture).
This fixes a menu issue in Steel Storm: Burning Retribution where the black text over a hover button was being rendered as MATERIALFLAG_ADD due to DRAWFLAG_ADD being used earlier in the frame on the same font image, which made the text invisible.
havoc [Wed, 22 Jan 2020 07:21:11 +0000 (07:21 +0000)]
Disable combining of surfaces in R_PolygonBegin, it makes assumptions that break things, and the underlying surface draw will still combine these for us (albeit more slowly).
Thanks to Cloudwalk for the tip, and divVerent and others for debugging in depth.
havoc [Wed, 22 Jan 2020 04:15:01 +0000 (04:15 +0000)]
cvars are now instanced in &cvars_all as a tracking mechanism, there is also &cvars_null if one wishes for no expansion to occur (e.g. client commands received on the server are very untrusted).
cvars now have CVAR_CLIENT and CVAR_SERVER flags, dedicated server can only see CVAR_SERVER variables whereas client can see both because it could start a server.
cvars created via VMs will have the corresponding flag set (client vm and menu vm can see both CVAR_CLIENT and CVAR_SERVER, server vm can only see CVAR_SERVER - may cause issues with singleplayer mods, we'll see).
havoc [Tue, 21 Jan 2020 08:36:34 +0000 (08:36 +0000)]
Split the global cmd interpreter into 4 separate ones for specific uses (client console, server console, client commands received from server, server commands received from clients), this is intended to make clients more robust against malicious servers by restricting which commands make sense.
This also hides some network protocol implementation details from the console command interpreter, and makes the command list a lot shorter in dedicated servers.
Changed Cbuf_LockThreadMutex/Cbuf_UnlockThreadMutex to Cbuf_Lock/Cbuf_Unlock and they now use a spinlock internally.
havoc [Fri, 17 Jan 2020 06:24:40 +0000 (06:24 +0000)]
R_CanSeeBox no longer uses collision_cache for the random traces, only the fixed positions (corners, etc), random rays were simply wasting resources in the collision_cache.
havoc [Fri, 17 Jan 2020 06:22:09 +0000 (06:22 +0000)]
Overhauled r_shadow_bouncegrid, it performs much faster, makes use of as many threads as you wish, and has a nicer calculation for light path accumulation.
r_shadow_bouncegrid now does refractive index calculations on water surfaces, it's not very obvious yet because the traceline doesn't return texture information (if it did, there would be cool caustics effects in dynamic mode).
Implemented TaskQueue system for simple threaded tasks (fibers but less featureful), this is used by r_shadow_bouncegrid but will be used by other parts of the engine in future, also added Thread_Atomic* functions.
havoc [Wed, 15 Jan 2020 12:53:04 +0000 (12:53 +0000)]
Overhauled bouncegrid light splatting for performance reasons - instead of a series of radial dots being accumulated in the texture, it is spherical distance from line segment calculations performed at each pixel, optimized to process pixels in order (filtering down the list of splat paths in each loop). This is a big framerate increase (as raytracing was not the bottleneck at all), and could be threaded in theory.
This required rebalancing the way that spacing interacts with quality, and the conespread parameter has been eliminated (as measuring distance to a non-uniform capsule seems especially challenging, but maybe that could be added back someday), so all parameters have changed a bit.
havoc [Wed, 15 Jan 2020 09:01:10 +0000 (09:01 +0000)]
Fix UI rendering to not use the bouncegrid texture; it looked interesting on the console text but was definitely a bug - now tracks a ui parameter on several surface drawing functions, and triggers the notrippy path in the material rendering as one wouldn't want r_trippy affecting UI either.
Fix a bug that caused bouncegrid to render black if any light was culled by traces (return that was supposed to be a continue).
Changed default values for these cvars to make bouncegrid emphasize the bounced light more, but also reduce the intensity:
r_shadow_bouncegrid_dynamic_directionalshading : 0 -> 1
r_shadow_bouncegrid_dynamic_lightradiusscale : 2 -> 5
r_shadow_bouncegrid_dynamic_maxbounce : 2 -> 5
r_shadow_bouncegrid_static_lightradiusscale 2 -> 5
r_shadow_bouncegrid_intensity 4 -> 1
havoc [Tue, 7 Jan 2020 10:25:49 +0000 (10:25 +0000)]
Fix PRVM_ValueString and PRVM_UglyValueString to check for out of bounds
dereference on a value provided by VM code, and also a NULL pointer
check for another field type.
After migrating to SDL2 interfaces there is noise during startup fix
this by initializng buffer as specification requires.
Per SDL_AudioCallback spec:
The callback must completely initialize the buffer; as of SDL 2.0, this buffer is not initialized before the callback is called. If there is nothing to play, the callback should fill the buffer with silence.
havoc [Sun, 26 May 2019 03:04:36 +0000 (03:04 +0000)]
Implement SDL2 AUDIO_F32 format and use it as the default, since it has become the preferred format of more platforms these days, and SDL2 uses it internally.
Improved the fallback mechanism on SDL2 audio setup - by removing it; SDL2 will tell us what changes it makes for the format, and it will convert the rest automatically.
divverent [Mon, 4 Feb 2019 15:09:01 +0000 (15:09 +0000)]
Remove code for r_equalize_entities*.
r_fullbright_directed and slapping EF_FULLBRIGHT on these entities works a lot
better. I believe other than Xonotic nobody uses this, and Xonotic used it only
to make some fullbright stuff prettier and that's been removed for a few months
now.
After this change, older Xonotic versions will complain about nonexisting flag
at startup, but I bet no player will even notice the difference - all it changes
is that EF_FULLBRIGHT entities will appear less directionally, and
r_fullbright_directed 1 will fix this in a better way (already set in current
Xonotic).
divverent [Fri, 19 Oct 2018 07:38:00 +0000 (07:38 +0000)]
Do not build VBOs on a dedicated server.
Fixes crash at startup of dedicated server in Quake and Xonotic
(probably in everything).
The only reason why this ever worked before was that Mod_BuildVBOs's
main callee R_Mesh_CreateMeshBuffer did a GL2 feature test before
calling into anything VBO related (and on a dedicated server, which does
not initialize GL, the test always returns false); however now that we
require GL32, the feature test is gone and thus the crash happened. An
explicit check for being a dedicated server fixes that.
divverent [Fri, 19 Oct 2018 07:02:35 +0000 (07:02 +0000)]
Make CDAudio_Play_byName static.
It isn't called by any other compilation units, but only internally by
other cd_shared.c functions; more importantly, it does not check for
music_playlist being active like CDAudio_Play does, which would at the
very least be confusing if someone were to add a string version of
qw_svc_cdtrack (WHY WOULD ONE).
divverent [Fri, 19 Oct 2018 06:40:49 +0000 (06:40 +0000)]
Remove the CONFIG_CD macro, and enable faketracks unconditionally.
All support for playing back CD-DA has been removed by leaving only the
SDL2 clients, and it is rather unlikely for CD-DA support to come back.
However while doing so, the CONFIG_CD macro was disabled in the makefile
but not the MSVC project, which broke faketracks (i.e. background music
via track003.ogg files) on Linux.
This change removes all #ifdefs for CONFIG_CD as well as its enablement
in the MSVC project, which is basically equivalent to having the feature
always being enabled.
Fixes background music in Quake with ripped music, Nexuiz, Xonotic, and
probably many other DP-based games. Also fixes Xonotic log spam about
gettime(GETTIME_CDTRACK).
Added vid_conwidthauto cvar which updates vid_conwidth based on vid_conheight and aspect ratio (honoring vid_pixelheight), this defaults on for better usability.
Go back to defining GL enums ourselves rather than relying on SDL_opengl.h on desktop.
Relying on SDL_opengl.h broke the dedicated server build which does not rely on SDL - having better code isolation of the OpenGL code would make this hack unnecessary.
havoc [Sun, 5 Aug 2018 21:39:11 +0000 (21:39 +0000)]
Upload the VBOs for Mod_Mesh models (such as the UI) during Mod_Mesh_Finalize.
Refactored the vbooffset handling in models to allow different vertex buffers for each array (this would only happen in the dynamic case when a buffer is recycled - so some code makes that assumption about dynamic buffers when freeing these).
havoc [Sun, 13 May 2018 05:06:07 +0000 (05:06 +0000)]
Removed per-platform clients (wgl/glx/agl) - now only SDL2 client
exists.
Removed dedicated server from VS2017 projects - it's not really needed.
Removed cd_sdl.c since SDL1.2 support is not maintained, and the SDL2
code path in it is equivalent to cd_null.c as SDL2 does not support
controlling cd audio playback - also removed cd_null.c and the
corresponding code in cd_shared.c, which now only uses faketrack mode.
havoc [Sun, 6 May 2018 04:39:34 +0000 (04:39 +0000)]
Remove r_vertexgeneric_t, r_vertexmesh_t, vid.interleavedarrays and code related to them.
Refactor r_showsurfaces code to modify the rsurface.batchlightmapcolor4f in place instead of using the R_Mesh_PrepareVertices_Generic_Lock/Unlock functions which have been removed.