Commit graph

1258 commits

Author SHA1 Message Date
Yamagi
11bcb785d0 Force SDL to minimize the window when focus is lost.
This was the default until 2.0.12 and is what the expects. It changed
with 2.0.14, casing problems with window ordering under windows and
some X11 window managers like kwin.

Do it unconditionally. So we're shure that we're ending with a minimized
windows, no matter what SDL does.

Fixes part of #647.
2021-03-17 09:21:48 +01:00
Denis Pauk
56a8ab6d4d Fix fullscreen value in hacks (f1b6b827) 2021-03-10 23:25:59 +02:00
Yamagi
18a9827b74 When drawing the renderer list, move vk before soft.
The software renderer should be the last option offered to the user,
because it is the weakest renderer.
2021-03-10 10:45:36 +01:00
Yamagi
f1b6b82721 Pull the major release card and switch the semantics of vid_fullscreen
One of the most common bug reports is, that the fullscreen mode doesn't
behave like users expect. This is caused by `vid_fullscreen 1` setting
desktop fullscreen mode (a fullscreen windows) and not the native
fullscreen mode. This commits switches the semantics:

* 1: Native fullscreen, like Vanilla Quake II.
* 2: Desktop fullscreen.

With this alt-tab reverts to native fullscreen. While at it improve the
documentation, suggest setting `r_mode -2` when using `vid_fullscreen
2`. Change the menu strings to make things clearer, set `r_mode -2` when
selecting 'fullscreen window' in the menu.

I pondered several other options:

* Introducing a second cvar for the desktop fullscreen, like we did in
  dhewm3. This has the problem, that in Quake II vi_fullscreen is
  special and used to communicate changed to the renderer configuration
  between the client and renderer. A second fullscreen cvar would
  complicate this already shaky mechanism even more.
* Setting `r_mode -2` when `vid_fullscreen 2`. This might not be what
  the user wants and causes problems when we're unable to get the
  desktop resolution.
2021-03-10 10:30:21 +01:00
Yamagi
51caf5b85e
Merge pull request #676 from rg3/vk_restart_fixes
Avoid restarting the whole video on VK_ERROR_OUT_OF_DATE_KHR
2021-03-10 10:01:47 +01:00
Yamagi
3c4dfcbba8 Switch the r_fixsurfsky default value to 0.
Switching this back to Vanilla Q2 behavior fixes at least one lightning
problem in the space map in baseq2. It'll break the lighting in some
addon maps, but is more correct from a global standpoint. You can't
have everything...

Closes #677.
2021-03-10 09:49:03 +01:00
Yamagi
e8107b4c64 Add else case missed / not committed in 9a17eb9a. 2021-03-08 21:30:34 +01:00
Ricardo Garcia
6989d22a2e Avoid restarting the whole video on VK_ERROR_OUT_OF_DATE_KHR
If an error is detected in vkAcquireNextImageKHR or vkQueuePresentKHR,
avoid restarting the whole video system and the game window. Instead,
shut down the Vulkan subsystem as gracefully as possible and restart it
without touching the window.

This fixes the problem with infinite video restarts under the Gnome
desktop environment.
2021-03-07 23:11:10 +01:00
Yamagi
80c637b5d6 Clamp scr_conspeed to 0.1f and use Cvar_Set().
Pointed out by @maraakate.
2021-03-05 10:29:46 +01:00
Yamagi
bfa25a13d9 Clamp the console speed to 1 or higher.
Lower values mess up the console rendering. Closes #671.
2021-03-04 07:13:42 +01:00
Yamagi
ae9a248e9e Add a cvar g_footsteps to control the generation of footstep sound.
1: The Vanilla Quake II behaviour, footsteps are generated when the
   player is faster than 255.
0: Footstep sounds are never generated.
2: Footstep sounds are always generated.

Defaults to `1`, cheat protected to `1`.

Closes #666.
2021-03-02 15:08:23 +01:00
Yamagi
d713944681
Merge pull request #658 from rg3/more_vulkan_fixes
More Vulkan fixes
2021-02-26 14:48:00 +01:00
Ricardo Garcia
bdd715ee5c Fix validation errors with unnormalized samplers
When using samplers with unnormalized coordinates in Vulkan, the shaders
must specify the LOD explicitly.
2021-02-23 22:07:32 +01:00
Ricardo Garcia
63f6778910 Only center Vulkan viewport in "keep resolution" mode
When windowed or in "switch resolution" mode, the viewport must be kept
in the top-left corner or it will appear cut while in fullscreen.

Also, make offset and width calculations safe from the point of view of
the swapchain extent, in case there's a mismatch.
2021-02-14 23:01:14 +01:00
Ricardo Garcia
b96b3a8d84 Synchronize color attachment layout transitions with loads
Since we are now loading the world color buffer content before drawing
on them again, we need to make sure the attachment layout transition
from shader-read-optimal to color-attachment-optimal happens before
color attachment read operations.
2021-02-14 00:03:40 +01:00
Ricardo Garcia
e0e52de47f Add a convenience Qvk_MemoryBarrier function 2021-02-14 00:02:08 +01:00
Denis Pauk
791b5e1e13 Save buffer size and use as limit for operations 2021-02-06 23:35:02 +02:00
Denis Pauk
ba173e68b5 rearrange init functions 2021-02-06 22:42:15 +02:00
Denis Pauk
0b79fa99ed #660: convert wrong modeltype to warning 2021-02-03 00:08:10 +02:00
Denis Pauk
1882fc2dbc #661: Use corrected resolution in fullscreen=1 2021-02-01 23:02:51 +02:00
Yamagi
06d183b6db
Merge pull request #655 from 0lvin/stereo_sound
Support of wav stereo sound
2021-01-31 12:18:26 +01:00
Ricardo Garcia
8599cab275 Load framebuffer contents correctly for MSAA
The contents of the previous drawn frame, used to mask geometry glitches
due to geometry sometimes not being watertight, was not being correctly
loaded for MSAA cases.

When MSAA is not used, the single-sample attachment needs to be loaded
and stored. With MSAA enabled, it's the multisample attachment the one
needing to be loaded and stored.
2021-01-31 10:54:03 +01:00
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
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
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
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
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
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
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
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