Commit graph

2841 commits

Author SHA1 Message Date
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
Yamagi
983f7f6b4b Port some lightning fixes from gl3 to vk.
* Fix for skyboxes abused as lightsources, was #393.
* Don't reuse i as counter variable when calculating light points.
2020-12-16 09:19:28 +01:00
Denis Pauk
b7bdd0be72 Add vk_nolerp_list support 2020-12-12 14:45:04 +01:00
Denis Pauk
539fea96bb add vk_retexturing force flag 2020-12-12 14:45:04 +01:00
Denis Pauk
1a4d495028 Enable retexturing by default and dump real image sizes 2020-12-12 14:45:04 +01:00
Denis Pauk
e3b387f7e7 Scale up 8bit images 2020-12-12 14:45:04 +01:00
Denis Pauk
8e5f68bb68 Remove vk_round_down as regressed visual quality 2020-12-12 14:45:04 +01:00
Denis Pauk
0d57f47b9b restore near color value only for transparent images 2020-12-12 14:45:04 +01:00
Denis Pauk
d4df592572 remove redundant suballocate (vk_util has already suballicate buffers) 2020-12-12 14:45:04 +01:00
Denis Pauk
07c043d8ce rename gammatable to overbrightable and apply only to world models 2020-12-12 14:45:04 +01:00
Denis Pauk
67821d753b Port VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU flag check 2020-12-12 14:45:04 +01:00
Denis Pauk
ff82bb5a78 Port memory flags from VulkanMemoryAllocator 2020-12-12 14:45:04 +01:00
Denis Pauk
16eb7f5c27 Show memory types supported by device 2020-12-12 14:45:04 +01:00
Denis Pauk
03a20b2050 Mark non VK_PRESENT_MODE_FIFO_KHR as triple buffered 2020-12-12 14:45:04 +01:00
Yamagi
17357d8c5e Fix another printf format specifier under Windows. 2020-12-12 14:45:04 +01:00
Denis Pauk
16ae9af406 Fix unmap warning on swap buffers resize 2020-12-12 14:45:04 +01:00
Denis Pauk
fd327dcdae vk: scale cinema raw images 2020-12-12 14:45:04 +01:00
Denis Pauk
124b0c224f Add palette image scale{2,3}x 2020-12-12 14:45:04 +01:00
Denis Pauk
4183c14cfa Update license in vk_util 2020-12-12 14:45:04 +01:00
Denis Pauk
5a4554cfb5 Fix multiplayer -> player setup 2020-12-12 14:45:04 +01:00
Denis Pauk
39e69c90f0 Rework memory allocation 2020-12-12 14:45:04 +01:00
Denis Pauk
59e5c4fca5 Add gunfov and farsee in ref_vk 2020-12-12 14:45:04 +01:00
Denis Pauk
17c5e04d8f Reuse TGA loader from STB 2020-12-12 14:45:04 +01:00
Denis Pauk
17d9ff77a6 update function declarations prototypes 2020-12-12 14:45:04 +01:00
Denis Pauk
01918110d7 fix symbol collision 2020-12-12 14:45:04 +01:00
Yamagi
85b9f84b3d Don't link against the Vulkan loader, load it at runtime. 2020-12-12 14:45:04 +01:00
Yamagi
d936bad256 Use uintptr_t instead of uint64_t for better Windows compatibility. 2020-12-12 14:45:04 +01:00
Yamagi
c9d54381a5 Fix uint64_t printf() format string for Windows. 2020-12-12 14:45:04 +01:00
Yamagi
3e0c3efa74 Fix size_t printf() format strings under Windows. 2020-12-12 14:45:04 +01:00
Yamagi
a72cd9ea50 Add the vulkan renderer to the beginning fallback sequence.
The fallback sequence is now: vk -> gl3 -> gl1 -> soft -> failed.
2020-12-12 14:45:04 +01:00
Yamagi
6329a1dfcb Shutdown QVK in R_Shutdown() by calling R_ShutdownContext().
The QVK shutdown is necessary, otherwise we'll leak all(?) allocated
Vulkan resources in case of a renderer restart by `vid_restart` and the
like. The also fixes some crashes in RADV at renderer shutdown.
2020-12-12 14:45:04 +01:00
Denis Pauk
00f676c973 Add support lavapipe (mesa vulkan software render) 2020-12-12 14:45:04 +01:00
Denis Pauk
d5f8791728 make current entity local 2020-12-12 14:45:04 +01:00
Denis Pauk
3648ef0866 make current model local 2020-12-12 14:45:04 +01:00
Denis Pauk
832d9666d4 Merge vk_point_particles with vk_particle_square to vk_custom_particles 2020-12-12 14:45:04 +01:00
Denis Pauk
7be20ac1cd Use vkResetCommandPool for vk_stagingCommandPool 2020-12-12 14:45:04 +01:00
Denis Pauk
e6e2a45e87 Use vkResetCommandPool for vk_commandPool 2020-12-12 14:45:04 +01:00
Denis Pauk
ca79fc78a6 remove window save code 2020-12-12 14:45:04 +01:00
Krzysztof Kondrak
da38e2a8f8 No need to request optional fillModeNonSolid since we're only using VK_POLYGON_MODE_FILL in all pipelines. 2020-12-12 14:45:04 +01:00
Krzysztof Kondrak
da32d051b3 Create MSAA color buffer only when it's actually needed. 2020-12-12 14:45:04 +01:00
Krzysztof Kondrak
a2ab709c2b Check if swapchain supports VK_IMAGE_USAGE_TRANSFER_SRC_BIT. 2020-12-12 14:45:04 +01:00
Krzysztof Kondrak
7784b197ca Enable VK_VALIDATION_FEATURE_ENABLE_BEST_PRACTICES_EXT only if the SDK supports it. 2020-12-12 14:45:04 +01:00
Denis Pauk
7eb075198e Fix vk_validation warnings 2020-12-12 14:45:04 +01:00
Denis Pauk
f6ae494637 rework Draw_StretchRaw 2020-12-12 14:45:04 +01:00
Denis Pauk
912fca15d9 Fix viewsize issues 2020-12-12 14:45:04 +01:00
Denis Pauk
2e5c5974d6 gamma calculation in shaders 2020-12-12 14:45:04 +01:00
Denis Pauk
a69c97f046 Add vk_particle_square support 2020-12-12 14:45:04 +01:00
Denis Pauk
3ec8e65d34 Staging buffers resize. 2020-12-12 14:45:04 +01:00
Denis Pauk
896346cf1a Fix MINGW64 windows build 2020-12-12 14:45:04 +01:00
Denis Pauk
a701226a19 cppcheck fixes
vk_common.c:1618:19: style: The if condition is the same as the previous if condition [duplicateCondition]
vk_draw.c:93:7: style: The scope of the variable 'fullname' can be reduced. [variableScope]
vk_draw.c:273:9: style: The scope of the variable 'source' can be reduced. [variableScope]
vk_draw.c:274:8: style: The scope of the variable 'frac' can be reduced. [variableScope]
vk_draw.c:274:14: style: The scope of the variable 'fracstep' can be reduced. [variableScope]
vk_draw.c:276:8: style: The scope of the variable 'row' can be reduced. [variableScope]
vk_draw.c:295:12: style: The scope of the variable 'dest' can be reduced. [variableScope]
vk_draw.c:111:45: style:inconclusive: Function 'Draw_GetPicSize' argument 3 names different: declaration 'name' definition 'pic'. [funcArgNamesDifferent]
vk_draw.c:131:57: style:inconclusive: Function 'Draw_StretchPic' argument 5 names different: declaration 'name' definition 'pic'. [funcArgNamesDifferent]
vk_draw.c:159:53: style:inconclusive: Function 'Draw_PicScaled' argument 4 names different: declaration 'factor' definition 'scale'. [funcArgNamesDifferent]
vk_draw.c:185:56: style:inconclusive: Function 'Draw_TileClear' argument 5 names different: declaration 'name' definition 'pic'. [funcArgNamesDifferent]
vk_image.c:586:7: style: The scope of the variable 'best' can be reduced. [variableScope]
vk_image.c:1170:8: style: The scope of the variable 'p' can be reduced. [variableScope]
vk_image.c:1591:7: style: The scope of the variable 'r' can be reduced. [variableScope]
vk_image.c:1591:10: style: The scope of the variable 'g' can be reduced. [variableScope]
vk_image.c:1591:13: style: The scope of the variable 'b' can be reduced. [variableScope]
vk_image.c:1592:11: style: The scope of the variable 'v' can be reduced. [variableScope]
vk_image.c:1628:9: style: The scope of the variable 'j' can be reduced. [variableScope]
vk_image.c:1261:8: style: Local variable 'i' shadows outer variable [shadowVariable]
vk_light.c:231:18: warning: Identical condition '(back<0)==side', second condition is always false [identicalConditionAfterEarlyExit]
vk_light.c:40:8: style: The scope of the variable 'a' can be reduced. [variableScope]
vk_light.c:306:9: style: The scope of the variable 'add' can be reduced. [variableScope]
vk_mesh.c:107:7: style: The scope of the variable 'count' can be reduced. [variableScope]
vk_mesh.c:316:7: style: The scope of the variable 'count' can be reduced. [variableScope]
vk_mesh.c:317:7: style: The scope of the variable 'i' can be reduced. [variableScope]
vk_mesh.c:647:9: style: The scope of the variable 'min' can be reduced. [variableScope]
vk_mesh.c:766:9: style: Local variable 'model' shadows outer variable [shadowVariable]
vk_mesh.c:267:52: style: Clarify calculation precedence for '&' and '?'. [clarifyCalculation]
vk_mesh.c:750:128: style: Clarify calculation precedence for '&' and '?'. [clarifyCalculation]
vk_model.c:53:9: style: The scope of the variable 'd' can be reduced. [variableScope]
vk_model.c:54:12: style: The scope of the variable 'plane' can be reduced. [variableScope]
vk_model.c:407:7: style: The scope of the variable 'next' can be reduced. [variableScope]
vk_model.c:462:12: style: The scope of the variable 'e' can be reduced. [variableScope]
vk_model.c:519:8: style: The scope of the variable 'planenum' can be reduced. [variableScope]
vk_model.c:519:18: style: The scope of the variable 'side' can be reduced. [variableScope]
vk_model.c:520:8: style: The scope of the variable 'ti' can be reduced. [variableScope]
vk_model.c:613:21: style: The scope of the variable 'p' can be reduced. [variableScope]
vk_model.c:663:21: style: The scope of the variable 'p' can be reduced. [variableScope]
vk_model.c:722:10: style: The scope of the variable 'j' can be reduced. [variableScope]
vk_model.c:783:8: style: The scope of the variable 'bits' can be reduced. [variableScope]
vk_model.c:901:18: style: The scope of the variable 'pinframe' can be reduced. [variableScope]
vk_model.c:901:29: style: The scope of the variable 'poutframe' can be reduced. [variableScope]
vk_model.c:1102:7: style: The scope of the variable 'i' can be reduced. [variableScope]
vk_model.c:1103:13: style: The scope of the variable 'sprout' can be reduced. [variableScope]
vk_model.c:1072:28: style:inconclusive: Function 'R_BeginRegistration' argument 1 names different: declaration 'map' definition 'model'. [funcArgNamesDifferent]
vk_pipeline.c:51:87: style:inconclusive: Function 'QVk_CreatePipeline' argument 2 names different: declaration 'desLayoutCount' definition 'descLayoutCount'. [funcArgNamesDifferent]
vk_rmain.c:405:10: style: The scope of the variable 'scale' can be reduced. [variableScope]
vk_rmain.c:400:28: style:inconclusive: Function 'Vk_DrawParticles' argument 1 names different: declaration 'n' definition 'num_particles'. [funcArgNamesDifferent]
vk_rmain.c:956:62: style: Clarify calculation precedence for '&' and '?'. [clarifyCalculation]
vk_rmain.c:1196:12: style: Variable 'err' is assigned a value that is never used. [unreadVariable]
vk_rmisc.c:97:10: style: The scope of the variable 'temp' can be reduced. [variableScope]
vk_rmisc.c:140:23: style: Variable 'isPreferred' is assigned a value that is never used. [unreadVariable]
vk_rsurf.c:678:11: style: The scope of the variable 'k' can be reduced. [variableScope]
vk_rsurf.c:679:12: style: The scope of the variable 'pplane' can be reduced. [variableScope]
vk_rsurf.c:680:9: style: The scope of the variable 'dot' can be reduced. [variableScope]
vk_rsurf.c:682:12: style: The scope of the variable 'lt' can be reduced. [variableScope]
vk_rsurf.c:741:8: style: The scope of the variable 'i' can be reduced. [variableScope]
vk_rsurf.c:811:22: style: The scope of the variable 'mark' can be reduced. [variableScope]
vk_rsurf.c:980:10: style: The scope of the variable 'c' can be reduced. [variableScope]
vk_rsurf.c:982:7: style: The scope of the variable 'cluster' can be reduced. [variableScope]
vk_rsurf.c:1055:6: style: The scope of the variable 'height' can be reduced. [variableScope]
vk_rsurf.c:1104:13: style: The scope of the variable 'best2' can be reduced. [variableScope]
vk_rsurf.c:1142:11: style: The scope of the variable 'lindex' can be reduced. [variableScope]
vk_rsurf.c:1145:9: style: The scope of the variable 's' can be reduced. [variableScope]
vk_rsurf.c:1145:12: style: The scope of the variable 't' can be reduced. [variableScope]
vk_rsurf.c:1257:12: style: The scope of the variable 'dummy' can be reduced. [variableScope]
vk_swapchain.c:68:7: warning: Possible null pointer dereference: presentModes [nullPointer]
vk_swapchain.c:182:91: style: Clarify calculation precedence for '&' and '?'. [clarifyCalculation]
vk_warp.c:57:8: style: The scope of the variable 'm' can be reduced. [variableScope]
vk_warp.c:64:8: style: The scope of the variable 's' can be reduced. [variableScope]
vk_warp.c:64:11: style: The scope of the variable 't' can be reduced. [variableScope]
vk_warp.c:168:8: style: The scope of the variable 'lindex' can be reduced. [variableScope]
vk_warp.c:325:9: style: The scope of the variable 'j' can be reduced. [variableScope]
vk_warp.c:530:11: style: The scope of the variable 'k' can be reduced. [variableScope]
2020-12-12 14:45:04 +01:00