Commit Graph

714 Commits

Author SHA1 Message Date
Ivan Avdeev
8a648619c4 vk: revert -nort commit
`rt_force_disable` is perfectly fine, it just needs to be written into
either `vk.cfg` or `video.cfg` to work. Other configs are read *after*
`R_VkInit()` function get called.
2024-04-29 18:28:28 -04:00
Ivan Avdeev
68c076bce3 vk: add explicit depth buffer synchronization for trad renderer
Fixes sync hazard validation error for depth buffer.
2024-04-12 11:58:04 -04:00
Ivan Avdeev
bc294977fd vk: add -vknort argument to force disable RT 2024-04-12 11:01:43 -04:00
nilsoncore
3c7481a7cb Merge branch 'vulkan' into memory_usage 2024-03-25 08:27:41 +03:00
nilsoncore
4d2a6c0e1d vk: devmem: fix print formats for linux #2 2024-03-24 21:01:55 +03:00
nilsoncore
4bac2cc96f vk: devmem: fix print formats for linux. 2024-03-24 20:33:03 +03:00
nilsoncore
790bf25263 vk: devmem: fix previously conflicting code.
- `mem->priv_.devmem` -> `slot_index`;
- Move static `VK_DevMemUsageTypeString()` out of `devmem.h` header.
2024-03-22 06:31:39 +03:00
nilsoncore
8363cedf93 vk: devmem: resolve conflicts with w23:vulkan branch. 2024-03-22 06:05:51 +03:00
Ivan Avdeev
cf966b38cb vk: fix a couple of misc warnings 2024-02-07 09:41:45 -08:00
Ivan Avdeev
f9c77060d7 vk: unload previous skybox prior to loading a new one
Fixes #737
2024-02-07 09:40:33 -08:00
Ivan Avdeev
e5a33ea0c3 vk: don't forget to add new shaders 2024-02-06 10:20:35 -05:00
Ivan Avdeev
9fc1f85bcd vk: use original skybox for trad renderer
Also fix:
- a bunch of texture/image destruction issues
- `_xvk_remove_all_sky_surfaces` getting stuck
2024-02-05 13:21:21 -05:00
Ivan Avdeev
30f2b6372b vk: make trad render draw skybox
It does it in a super dirty way, trad renderer needs a massive
refactoring.

It also displays patched skybox, however, we need it to display the
oridingal one.
2024-02-05 12:52:20 -05:00
Ivan Avdeev
a2661fe95d vk: add skybox pipeline for traditional renderer
It is not wired up to render anything yet, but we just made sure that it
builds and gets destroyed.

Also, fixup dynamic BLAS double-free.
2024-02-05 10:57:50 -05:00
Ivan 'provod' Avdeev
cba60f7953 vk: rt: add workaround for holes in geometry
Once upon a time, there were some BLASes. There were the BLASes for dynamic geometry, that were to be used every frame to draw very dynamic things, like sprites and beams. They were initialized at the very begining of the renderer's lifetime, and were expected to live happily for the entire process duration.
However, an evil NewMap appeared. It didn't care abount anything or anyone, so when it came, it just cleared all the allocators, and allowed other BLASes to be allocated into the same space as dynamic BLASes were already given. This made BLASes live on top of each other, use each others toys and make them fight. They weren't happy.

So we just kill them and creat them again from scratch, when the evil NewMap comes.

The end.

Fixes #729
2024-02-02 11:45:43 -05:00
Ivan Avdeev
315073a564 vk: add -vkdbg_shaderprintf to enable printfs in shaders
Under `-vkvalidate` enables `debugPrintfEXT()` in shaders, allowing
extra validation and error reporting from shaders.
Severely degrades performance, so should be enabled only for debugging.
2024-02-01 12:57:12 -05:00
Ivan Avdeev
aaa6de330c vk: rt: add experimental second Á-Trous pass for indirect diffuse
Now indirect diffuse channel gets blurred with 2 Á-Trous passes. It
mostly follows the paper, except for Σd_i, which gives very bad
viusal artifacts.
2024-02-01 10:36:34 -05:00
Ivan Avdeev
a56e6a42a5 vk: rt: parametrize different light channels differently in denoiser 2024-01-29 12:49:32 -05:00
Ivan Avdeev
5d6c1d4bfc vk: rt: tune denoiser "a-trous" parameters a bit 2024-01-29 12:07:20 -05:00
Ivan Avdeev
1f8e9fe0c2 vk: rt: slightly cleanup bounce loop shader code 2024-01-29 11:30:41 -05:00
Ivan Avdeev
ae3f79c67a vk: rt: attenuate secondary bounces
`throughput` should be scaled based on BRDF. I.e. diffuse bounces should
be scales by base_color at the very least.

This fixes lighting being too bright after 3-5 bounces.
2024-01-29 11:02:48 -05:00
Ivan Avdeev
be8da3252a vk: rt: fixup too bright direct lighting 2024-01-26 14:38:31 -05:00
Ivan Avdeev
a578becdd9 vk: rt: add diffuse and specular debug display modes
These will display diffuse and specular channels, both direct and
indirect, after spatial denoiser, but before temporal one.
2024-01-26 14:02:19 -05:00
Ivan Avdeev
6169734f91 vk: rt: do À-Trous lighting denoise
Works reasonably well, but a bit under-tuned, and remains only single-pass for now.
2024-01-26 13:59:15 -05:00
Ivan Avdeev
cf59921c41 vk: rt: degrade spatial image quality by box blur denoiser
Our gaussian blur is incorrect, as it doesn't preserve luminance, and
the final imaga ends up being darker than it should be.

Do a box blur as a simple test. It does result in a correctly looking
white furnace test image (modulo square blocks and luminance leaking).
2024-01-26 12:50:08 -05:00
Ivan Avdeev
e8400398bd vk: rt: add debug non-blurring denoiser code
Enabling it makes it clear that blurSamples() loses luminance.
Also it exposes temporal denoiser glitches.
2024-01-26 11:24:49 -05:00
Ivan Avdeev
579b9e00ac vk: rt: enable white furnace via new rt_debug_flags 2024-01-26 10:52:17 -05:00
Ivan Avdeev
6d58ad8df0 vk: rt: add white furnace debug display mode
Known issues:
- it doesn't really look how it's supposed to look
- using debug display mode for it was a mistake
2024-01-26 10:34:46 -05:00
Ivan Avdeev
18269ebf81 vk: rt: fixup 2024-01-23 12:13:48 -05:00
Ivan Avdeev
7e7351c599 vk: rt: attenuate bounce channels better
Divide by probabilities, multiply specular by fresnel.
2024-01-23 11:24:47 -05:00
Ivan Avdeev
b01fa98c8b vk: rt: improve spec-vs-diff estimation for bounces
Estimate relative specular contribution based on fresnel term and
base_color. Pick bounce type based on that.
2024-01-23 10:47:21 -05:00
Ivan Avdeev
c7bf03c260 vk: rt: add incomplete and super experimental specular bounces
VNDF sampling is blatantly copypasted from 2023 paper
no specular BRDF attenuation is made
it's very dirty and not optimized
2024-01-22 10:37:50 -05:00
Ivan Avdeev
8359a04750 vk: rt: fixup bounce brightness
Shoulnd't have multiplied by diffuse BRDF result. It should be encoded
in diffuse-vs-specular split, and the cosine term is already taken care
of in sampling.
2024-01-19 12:51:32 -05:00
Ivan Avdeev
d20bbe1761 vk: attenuate flashlight 2024-01-19 12:26:06 -05:00
Ivan Avdeev
6e2a3d9004 vk: rt: add cvar to force backface culling for testing 2024-01-19 12:25:29 -05:00
Ivan Avdeev
e12b2c47b4 vk: rt: added minimal distance for legacy soft blending
Only engage soft particles/blending after a certain distance. Makes
certain see-beams-through-weapons visual glitches disappear.

Engages soft particles with a smoothstep so the don't immediately pop up
after a certain distance, rather appear gradually.
2024-01-19 12:02:26 -05:00
Ivan Avdeev
6ee8af040e vk: throttle zero normal messages 2024-01-19 11:42:15 -05:00
Ivan Avdeev
073dbc55f8 vk: fixup studio model zero normal printing 2024-01-19 11:39:26 -05:00
Ivan 'provod' Avdeev
344c804468 vk: remove extra includes 2024-01-19 11:34:44 -05:00
Ivan 'provod' Avdeev
5f3a0c233b vk: rt: investigate more nans
Found that some studio models end up producing zero-length normals. See #731
2024-01-19 11:34:31 -05:00
Ivan Avdeev
6a7cb77809 vk: shave todo yak 2024-01-18 11:37:16 -05:00
Ivan Avdeev
0e4e754fdb vk: cleanup todo a bit x2 2024-01-18 11:34:07 -05:00
Ivan Avdeev
e22f30608a vk: cleanup todo a bit 2024-01-18 11:33:45 -05:00
Ivan Avdeev
e808fa0d9d vk: rt: enable patching environment light solid angle
Two ways:
- skybox.mat `sun_solid_angle`
- entity patch field `_xvk_solid_angle`

Both values should be specified in steradians
2024-01-18 11:14:20 -05:00
Ivan Avdeev
0e403e119f vk: silence degenerate triangle diagnostic logs 2024-01-18 11:13:16 -05:00
Ivan Avdeev
de60cde7ab vk: rt: suggest dithering for precision errors 2024-01-18 09:59:02 -05:00
Ivan Avdeev
93cc0b5dd7 vk: rt: improve cosθ computation precision for sphere lights
It is only a bit better, makes some artifacts for strong small lights on
distant objects less visible.
2024-01-18 09:55:01 -05:00
Ivan Avdeev
7ef9bb87a9 vk: rt: fixup environment attenuation
Now environment emissive strength also depends on cos_theta (derived
from sun solid angle).
2024-01-16 13:22:32 -05:00
Ivan Avdeev
e7ff1f3d3a vk: filter out degenerate triangles in brush models
This fixes lighting NaNs caused by NaN poison from invalid/zero normals.
2024-01-16 12:29:15 -05:00
Ivan Avdeev
9f1b034769 vk: rt: fix point light cos>1. for large distances 2024-01-15 12:24:24 -05:00