Commit graph

3152 commits

Author SHA1 Message Date
Ricardo Garcia
9661ce0ba0 Make scaled down view borders work with MSAA
The pipeline used to draw a texture quad was only created compatible
with the RP_UI render pass, which has a single-sample color attachment.
This made the pipeline work when MSAA was disabled, but it did not work
properly with it enabled.

To fix the issue, create a set of pipelines, instead of a single one,
with compatibility with the different types of render passes, as the
pipeline is used for both the scaled down view borders as well as UI
elements in the third render pass.
2021-01-31 10:38:59 +01:00
Yamagi
9a17eb9ac3 Make limiting power screen sounds to 16 optional.
This was added in e3e5bd1 as a work around for some openal-soft bug.
When too many audio samples got played at the same time, the global
volume dropped. This was fixed in openal-soft 0.19.0, released more
than two years ago. We're keeping the work around, because some
distros may still ship with buggy openal-soft versions and some
players may like the changed behavior. It's disabled by default.
2021-01-30 13:51:02 +01:00
Denis Pauk
6f045f71af sound: use current func name in Com_Error 2021-01-27 22:38:31 +02:00
Denis Pauk
f73bcf5fbd cppcheck fixes
src/client/refresh/soft/sw_main.c:
   1512 (style) Variable 'err' is assigned a value that is never used. [unreadVariable]

src/client/refresh/vk/vk_rmain.c:
  1023 (style) Suspicious calculation. Please use parentheses to clarify the code. The code ''a&b?c:d'' should be written as either ''(a&b)?c:d'' or ''a&(b?c:d)''. [clarifyCalculation]

src/client/sound/ogg.c:
  335 (style,inconclusive) Function 'OGG_PlayTrack' argument 1 names different: declaration 'track' definition 'trackNo'. [funcArgNamesDifferent]
  212 (style) Local variable 'gogTrack' shadows outer variable [shadowVariable]

src/client/sound/sdl.c:
  179 (style) The scope of the variable 'i' can be reduced.
  180 (style) The scope of the variable 'lpos' can be reduced.
  181 (style) The scope of the variable 'ls_paintedtime' can be reduced.
  182 (style) The scope of the variable 'out_idx' can be reduced.
  183 (style) The scope of the variable 'count' can be reduced.
  185 (style) The scope of the variable 'p' can be reduced.
  186 (style) The scope of the variable 'snd_linear_count' can be reduced.
  187 (style) The scope of the variable 'step' can be reduced.
  189 (style) The scope of the variable 'snd_out' can be reduced.
  330 (style) The scope of the variable 'data' can be reduced.
  368 (style) The scope of the variable 'data' can be reduced.
  369 (style) The scope of the variable 'left' can be reduced.
  369 (style) The scope of the variable 'right' can be reduced.
  401 (style) The scope of the variable 'end' can be reduced.
  529 (style) The scope of the variable 's' can be reduced.
  799 (style) The scope of the variable 'i' can be reduced.
  874 (style) The scope of the variable 'scale' can be reduced.
  910 (style) The scope of the variable 'srcsample' can be reduced.
  1093 (style) The scope of the variable 'total' can be reduced.
  196 (style) Local variable 'i' shadows outer variable [shadowVariable]
  197 (style) Local variable 'count' shadows outer variable [shadowVariable]

src/client/sound/sound.c:
  450 (style) The scope of the variable 'maleFilename' can be reduced.
  980 (style) The scope of the variable 'num' can be reduced.
  1085 (style) The scope of the variable 'sfx' can be reduced.
  423 (style,inconclusive) Function 'S_RegisterSound' argument 1 names different: declaration 'sample' definition 'name'. [funcArgNamesDifferent]
  909 (style,inconclusive) Function 'S_StartLocalSound' argument 1 names different: declaration 's' definition 'sound'. [funcArgNamesDifferent]
  1048 (style,inconclusive) Function 'S_Update' argument 2 names different: declaration 'v_forward' definition 'forward'. [funcArgNamesDifferent]
  1048 (style,inconclusive) Function 'S_Update' argument 3 names different: declaration 'v_right' definition 'right'. [funcArgNamesDifferent]
  1048 (style,inconclusive) Function 'S_Update' argument 4 names different: declaration 'v_up' definition 'up'. [funcArgNamesDifferent]
2021-01-27 22:38:31 +02:00
Denis Pauk
8c69684e8d client/sound: make local symbols static 2021-01-27 22:38:31 +02:00
Denis Pauk
c3e76236ba Support stereo effects #641
Based on:
  https://github.com/mczero80/KMQuake2/blob/4c23519/client/snd_mem.c#L324
  https://github.com/mczero80/KMQuake2/blob/4c23519/client/snd_mem.c#L236
2021-01-27 22:38:31 +02:00
Yamagi
957c11513c
Merge pull request #657 from rg3/vulkan_fullscreen_fixes
Fullscreen Vulkan fixes
2021-01-27 08:38:03 +01:00
Yamagi
506ccfa309
Merge pull request #656 from rg3/msaa_samples_text_fix
Fix text indicating MSAA samples for Vulkan
2021-01-27 07:15:32 +01:00
Ricardo Garcia
e85f266a84 Restore reduced view textured borders
This commit removes the previous R_CleanupBorders hack and fixes
textured border drawing, so borders are correctly drawn in the right
place and are not taken into account when applying the underwater
effect.
2021-01-24 23:47:21 +01:00
Ricardo Garcia
741f64604c Remove duplicate comment 2021-01-24 23:25:02 +01:00
Ricardo Garcia
abda667781 Fix screenshots so they capture the center of the framebuffer 2021-01-24 23:19:20 +01:00
Ricardo Garcia
fe13cfbbb7 Avoid frame cleaning hack in refdef changes
With the fix from 76f56458, we no longer need to clean the frame when
the world view changes sizes.
2021-01-24 22:18:41 +01:00
Ricardo Garcia
76f56458b1 Fix water warp edge distortion when keeping resolution
With vid_fullscreen 1 and a scaled down viewport, the water distortion
effect produced waves in the viewport edge. This commit fixes those.
2021-01-24 13:32:45 +01:00
Ricardo Garcia
5fcfcd56b3 Fullscreen Vulkan fixes
This commit includes the following changes:

* When vid_fullscreen is 1, the game is now drawn centered in the
  screen instead of the top left corner, by modifying the viewport and
  scissor when drawing the world warp and UI render passes.

* When vid_fullscreen is 1, the world view no longer has an incorrect
  size and/or aspect ratio. This was due to the world warp and UI
  render passes sampling from the whole color buffer instead of the
  restricted render area. To fix this, the postprocessing and world warp
  shaders now use unnormalized coordinates, corrected with the frame
  offset, and sample directly from the appropriate texels.

* The game no longer outputs pixels which have not been written to,
  which are usually displayed black but may come out with undefined
  colors. For this, some output color attachments are cleared before
  drawing the final elements in the frame.
2021-01-24 11:52:30 +01:00
Ricardo Garcia
bb827cad8c Fix text indicating MSAA samples for Vulkan 2021-01-23 09:56:24 +01:00
Yamagi
449776d3f6
Merge pull request #654 from 0lvin/ref_vk
Sync variable names for msaa, retexturing and anisotropic filtering
2021-01-22 12:27:18 +01:00
Yamagi
0488dcd4e9 Add a replacement chasing the cl_anglekicks -> cl_kickangles rename. 2021-01-22 12:22:47 +01:00
Yamagi
f322b28fa5
Merge pull request #653 from Calinou/rename-anglekicks-cvar
Rename `cl_anglekicks` to `cl_kickangles` for consistency with Q2PRO
2021-01-22 12:21:50 +01:00
Denis Pauk
46c24d4d18 Sync variable names for msaa, retexturing and anisotropic filtering #646 2021-01-19 21:39:44 +02:00
Denis Pauk
6a89f30768 Show message about anisotropy for selected device 2021-01-19 21:39:34 +02:00
Denis Pauk
b9d4549a9b Add support r_customwidth/r_customheight in ref_vk #652 2021-01-19 21:39:25 +02:00
Denis Pauk
000c72fecc Rework vk_msaa to use number of samples #646 2021-01-19 21:39:13 +02:00
Hugo Locurcio
08d59ee8e8
Rename cl_anglekicks to cl_kickangles for consistency with Q2PRO 2021-01-18 04:41:57 +01:00
Yamagi
2fae58d56b Implement singleplayer in the dedicated server.
When set to `1`, both `deathmatch` and `coop` are forced to `0`.
`maxclients` is forced to `1`. This makes it possible to play single
player campaigns over the dedicated server.

Closes #614.
2021-01-17 11:07:46 +01:00
Yamagi
f01998896f Hide the fix for sky surfaces missused for indoor lighting begind cvar.
All renderers had the fix, but it was only optional in the GL renderers.
And there it was missimplemented, cvars must be defined in the renderers
main() function. Otherwise they aren't available at startup.

Rename gl_fixsurfsky to r_fixsurfsky, implement it for all renderers and
enable it by default.
2021-01-17 10:25:09 +01:00
Yamagi
531cbdcdae Mention the Vulkan renderer on all appropriate places. 2021-01-17 10:05:04 +01:00
Yamagi
a9914efde7 Implement vk_underwater, make the underwater warp effect optional.
This was requested in #505.
2021-01-13 21:46:15 +01:00
Yamagi
8a54e49f61
Merge pull request #643 from 0lvin/ref_vk
Enable depthWriteEnable for particles
2021-01-13 18:27:17 +01:00
Yamagi
61766edbe1
Merge pull request #644 from rg3/skybox-fixes
Skybox fixes
2021-01-13 18:22:44 +01:00
Yamagi
d745e16523
Merge pull request #642 from DanielGibson/fix-lm-glitch
Makefile: Fix architecture detection on Windows
2021-01-13 18:11:03 +01:00
Ricardo Garcia
8142898b56 Fix black pixels along skybox edges in Vulkan
Due to the skybox geometry not always being watertight, it's sometimes
possible to see instances of isolated black pixels flickering along
skybox edges. This happens when the sampling coordinates for the given
pixel fall outside any triangle in the skybox due to the previous
problem.

These pixels are usually visible when MSAA is not used and pixels are
big enough on the screen, like when using lower screen resolutions or
large vk_pixel_size values. If MSAA is used, normally only a few of the
samples fall outside any triangle and the problem is masked a bit, being
harder to spot.

Instead of fixing the skybox clipping routines, which may be
complicated, this commit simply preserves color buffer contents between
frames. If any pixel ends up without coverage, its color will be taken
from a previous draw a few frames before, depending on the swapchain
size. This is usually more than enough to completely mask the problem
visually.
2021-01-12 23:33:55 +01:00
Ricardo Garcia
aa2baedd97 Fix skybox edges being visible in Vulkan
Skybox edges are sometimes visible in Vulkan, specially in lower screen
resolutions or when vk_pixel_size is used to the same effect.

To avoid this problem, draw the skybox using CLAMP_TO_EDGE addressing
mode in samplers. In order to do that, the number of texture samplers is
doubled and a second set of samplers with the new addressing mode are
created, and used only when drawing the skybox.
2021-01-12 23:33:55 +01:00
Daniel Gibson
9bc2fe29fe Clean up savegame's ReadGame() a bit
less duplicate code, more readable usage of strcmp()
2021-01-12 07:12:19 +01:00
Daniel Gibson
ee7923a9dd Fix architecture detection on Windows in Makefile, bump SAVEGAMEVER
$PROCESSOR_ARCHITECTURE seems to contain the architecture of the host,
but we need the architecture the current MinGW shell is targeting.
$MINGW_CHOST seems to be just that, and on my system it's either
i686-w64-mingw32 (mingw32.exe) or x86_64-w64-mingw32 (mingw64.exe)
(No idea what it looks like for Windows on ARM...)

As fixing this would otherwise break existing savegames, I bumped the
SAVEGAMEVER to "YQ2-4" and added a quirk for older savegameversions:
On Windows i386 savegames that contain "AMD64" instead of "i386" as
architecture are also accepted.
(For YQ2-1 this didn't seem necessary, apparently "i386" was hardcoded)
2021-01-12 05:04:11 +01:00
Yamagi
023a012e82 Change the hyperblaster back to yellow for Vanilla Q2 lightning.
In Vanilla Q2 (without any point releases) the hyperblaster projectiles
emitted white light. In the 3.21 sources it's yellow. It likely changed
in on of the (early) point releases. Change it to yellow, the code now
matches 3.21.
2021-01-11 07:34:30 +01:00
Yamagi
462a0ddff5
Merge pull request #636 from rg3/vk_resolution_scaling
Add resolution scaling to Vulkan renderer
2021-01-10 19:02:51 +01:00
Yamagi
a52402fd3c Add undefined behaviour sanitizer to the Makefile.
While here update some comments and add a comment sections for the
command line variables.
2021-01-10 18:55:42 +01:00
Yamagi
a98d533ae1 Add cl_r1q2_lighstyle, set to 0 for Vanilla Q2 dlight colors.
Since the first release Yamagi Quake II used the more fanzy R1Q2 colors
for some dynamic lights:

* In R1Q2 the rocket has orange light, matching the color of the fire
  trail and the generic explosion. Vanilla Quake II had yellow light,
  the same as the blaster and several muzzle flashs.
* In R1Q2 hyperblaster projectiles are emitting yellow light, like the
  normal blaster. That matches the projectile colors, the muzzle flash
  and the effect when hitting a wall. And it's more logical, since the
  hyperblaster is just a blaster on steroids. Vanilla Quake II had white
  / uncolored lights.

Add an option to revert to Vanilla Quake II colors, leave the R1Q2
colors as default. Closes #640.
2021-01-10 18:30:49 +01:00
Denis Pauk
3b9aa6448e Enable depthWriteEnable for particles 2021-01-10 13:25:10 +02:00
Denis Pauk
1bc60032e7 Fix pipeline debug naming 2021-01-10 13:07:44 +02:00
Yamagi
7163d133cb
Merge pull request #638 from devnexen/vulkan_optional
Proposing to make vulkan support eventually optional.
2020-12-31 10:28:56 +01:00
Yamagi
faf6a91ace
Merge pull request #635 from 0lvin/ref_soft
Port improvements to soft and vulkan
2020-12-31 10:27:03 +01:00
Yamagi
69ba055c2c Minimal error checking for Sys_Mkdir() on windows. 2020-12-31 09:09:09 +01:00
Yamagi
60d881437b Minimal error handling for Sys_Mkdir() under unixlike platforms. 2020-12-31 08:55:09 +01:00
Yamagi
8e223b2743 Make sure that the config dir exists.
Since 1a913eb we're calling realpath() on every dir and bail out if the
real path isn't available. If the game is started the first time, the
configuration dir doesn't exist at the first realpath() call and the
game errors out. Always create the configuration dir when determining
it's path.

This didn't happen on Windows because the configuration dir was created
when opening stdout.txt right after we entered main().

TODO: Sys_Mkdir() should grow at leas a little bit error handling. We're
silently ending up in -portable mode if the configuration dir couldn't
created.
2020-12-30 18:45:16 +01:00
Ricardo Garcia
150db4d443 Widen pipeline scissor adjusted for vk_pixel_size
When calculating the pipeline scissor adjusted for vk_pixel_size, round
scissor offset down and size up. This avoids black bars on image borders
when scaling up if the division is not exact.
2020-12-24 23:51:27 +01:00
Denis Pauk
84aceda76d Use submodels directly from current map 2020-12-24 13:40:07 +02:00
Ricardo Garcia
930872b358 Add resolution scaling to Vulkan renderer
This commit adds a new cvar called vk_pixel_size that represents how big
pixels should look in the rendered world in order to simulate lower
screen resolutions. With its default value of 1 everything looks normal,
but with bigger sizes (e.g. 4) the rendered world starts to look
"pixelated" due to pixels appearing bigger.

To implement the effect, the viewport and scissor are modified when
drawing the world so the rendering results cover a smaller area in the
top-left corner of the image.

The post-processing fragment shader is used to scale the image back to
the swapchain size before drawing UI elements on top of it.

The UI is not affected by this change, so the existing UI scaling
options continue to work as before with no changes, adding some
flexibility to the mix.

Related to feature request #588.
2020-12-24 10:14:39 +01:00
Denis Pauk
4f9067e6b8 Reallocate models with huge current map 2020-12-23 23:29:29 +02:00
Denis Pauk
2c00502b0b Free Unused Image and Models only if we are near to limit 2020-12-23 21:35:27 +02:00