Commit Graph

3763 Commits

Author SHA1 Message Date
Ivan Avdeev 755b2d59a9 vk: fixup BLAS preallocation on Linux/amdgpu
Fixing pool allocator to properly signal allocation failure uncovered an
existing issue where we were lacking enough memory for dynamic model
BLASes on Linux/amdgpu. Erroneously the same memory region was used for
>1 BLAS. Surprisingly this hasn't led to any noticeable issues so far.

Increasing accels buffer size fixes the issue.
2023-09-14 13:57:59 -04:00
Ivan 'provod' Avdeev 06a7de02a8 vk: clear EntityData on new map regardless of save-load
Entity data gets reallocate on every NewMap regardless of whether it was a load from a save. Thus all entity pointers and data are invalidated. EntityData keeps things using pointers as keys.
Make sure it is properly cleared on `R_NewMap()`

Fixes #562
2023-09-14 13:48:39 -04:00
Ivan 'provod' Avdeev 7d115168ae vk: alolcator: report pool allocation failures correctly
Returning `0` instead of `ALO_ALLOC_FAILED` let to API consumers believe that allocation was successful. This lead to asserts failing when trying to free such allocations.

Makes #562 not crash (but miss studio models anyway)
2023-09-14 13:42:47 -04:00
Ivan Avdeev 3333d03a7b vk: studio: add submodel render acquire/release diagnostics
For #562 investigation
2023-09-14 13:02:01 -04:00
Ivan Avdeev 9ceb129576 vk: sprite: enable lerping
It Just Works™  even with raytracing, as RT just blends everything
(including coplanar sprites) order-dependent correctly.

Fixes #433
2023-09-14 12:13:30 -04:00
Ivan Avdeev 40a79d7280 vk: sprite: fix fading
Fixes #441
2023-09-14 11:58:32 -04:00
Ivan Avdeev 5767ddb30c vk: studio: do not ignore parent bones when detecting static submodels
python/357 has bullets submodels which are animated using parent bones.
Their direct bones are static, and thus the entire submodel was picked
up as static.

Now when computing bone transform for particular sequence/anim frame
also merge it with parent transform. Bones are laid out sequentially in
their "dependency order" so using a direct parent is fine, as it also
contains its parent transforms.

Fixes: #554
2023-09-12 11:12:40 -07:00
Ivan 'provod' Avdeev 64e1a9b763 vk: do not draw into empty swapchain
On Windows we're seeing a max size = 0x0 swapchains. Those cannot be created or used. Make sure that we're not, and we're not trying to draw anything when there's no swapchain available.

Unfortunately we still have to call some rendering functions (without actually rendering anything) to make sure that various invariants hold.

fixes #463
2023-09-12 10:48:26 -07:00
Ivan Avdeev d9207963f9
Merge pull request #557 from w23/E292
Things done in stream E292
2023-09-08 12:45:14 -07:00
Ivan Avdeev 26a4fff486 vk: brush: improve animated surfaces detection
Explicitly check that there are at least two different textures in an
animation sequence.

Fixes #555
2023-09-08 14:22:37 -04:00
Ivan Avdeev 48b7fcb153 vk: add a bunch of profiler metrics
Done as part of investigation for #555
2023-09-08 14:12:35 -04:00
Ivan Avdeev 49bfd28d3c
Merge pull request #556 from 0x4E69676874466F78/vulkan
Update patches&rads
2023-09-08 10:50:09 -07:00
NightFox f3b55c63bb
Update rads
performance improvement for c1a0/c1a0d
2023-09-08 17:39:27 +03:00
NightFox 9c7d8a6ee0
Update patches 2023-09-08 17:17:23 +03:00
Ivan Avdeev 4944b5eb05
Merge pull request #552 from w23/E291
Fixes from stream E291
- [x] Late studio models: #546 
- [x] Silence verbose logs: #545 
- [x] Synchronize kusochki updates: #553
2023-09-07 08:42:43 -07:00
Ivan 'provod' Avdeev 6d749ea8d0 vk: synchronize updating kusochki
Do not aggravate the validator by uploading to the same memory region twice. Make sure that there's synchronization between updating kusochki.

Fixes #553
2023-09-07 11:19:41 -04:00
Ivan Avdeev 13eef5dda2 vk: silence a bunch of verbose logs
There are some limits that we hit multiple times in a frame that result
int S_ERROR logs. Throttle them

Fixes #545
2023-09-07 10:43:21 -04:00
Ivan Avdeev b8eb6156a8 vk: studio: allow late "pre"loading for studio models
Sometimes the initial list of models doesn't contain everything that is
used later. I don't know why. So detect this and allow loading model
infos later.

Fixes #546
2023-09-07 10:18:31 -04:00
Ivan Avdeev 29508cd324
Merge pull request #547 from w23/brush-smoothing
Smooth normals between selected brush surfaces if the angle between them is small enough.

- [x] Per-vertex-per-surface smoothing functionality (differs from qrad, which is per-edge; this gives artifacts as (supposedly) we have higher than lightmap lighting resolution)
- [x] Automatically select surfaces with less than X degrees between normals.
- [x] Make this X threshold adjustable from <map>.bsp.patch
- [ ] ~~Try not joining coplanar surfaces~~ -- doesn't seem to be affecting anything.
- [ ] ~~Think about linking surfaces more. Should we link distant surfaces w/o direct edges to this one?~~ -- it seems that we should be fine for now. Per-surface+vertex vs per-edge smoothing has no clear winner, just different tradeoffs.
- [ ] ~~Scale normals according to surfaces areas, so larger surfaces have more weight (experimental; may improve some artifacts)~~ -- also, non trivial to compute, and may not affect things too much.
- [x] Patch: add explicit smoothing or no-smoothing for given surfaces.

Fixes #139, supersedes #348
2023-09-05 10:18:46 -07:00
Ivan Avdeev bdbfbef8a2 vk: add commented out normal debugging code 2023-09-05 13:06:00 -04:00
Ivan Avdeev f42ea011f1 vk: mapents: fix not clearing smoothing groups 2023-09-05 13:03:53 -04:00
Ivan Avdeev 58ed5e7277 vk: brush: add explicit smoothing group inclusion 2023-09-05 12:54:57 -04:00
Ivan Avdeev 61416cfc66 vk: brush: do not link pairs that were explicitly excluded in patches
This doesn't work as expected in some cases, as surfaces might still get
linked transitively by neighbours. Solving this seems non-trivial for
now, but maybe we can just live with it
2023-09-05 12:35:28 -04:00
Ivan Avdeev d8d5019971 vk: filter smoothing normals by texture
thanks to G.I.F
2023-09-05 12:07:02 -04:00
Ivan Avdeev 0856e9e70d vk: add patchable smoothing threshold
Automatically smooth normals between surfaces with normals less than 45
degrees off.

Can be adjusted from map.bsp.patch file like this (e.g. to 50 degrees):
```
{
	"_xvk_smoothing_threshold" "50"
}
```
2023-09-04 14:35:19 -04:00
Ivan Avdeev a9dcf94f1b vk: add initial support for brush surface normal smoothing
Lots of artifacts

Relevant: #139, #348
2023-09-04 13:49:03 -04:00
Ivan Avdeev 883ccff13f
Merge pull request #537 from w23/blas-mgmt
Improve BLAS management

This PR is to address #533 and related issues, e.g.:
- [x] Fixes #236
- [x] Fixes #350
- [x] Fixes #354
- [x] #364
- [x] Fixes #422
- [x] Fixes #443
- [x] Fixes #533
- [x] Fixes #539
- [x] Fixes #458 

An arbitrary list of other things to do in this PR also:
- [x] Use new model create and render for brushes
- [ ] ? split materials from kusochki
- [x] fix sprite textures: pass texture override and upload dynamic/instanced kusochki
- [x] orient sprites
- [ ] fix NewMap-vs-long allocations for:
  - [ ] accel buffer
  - [ ] kusochki
- [ ] create/allocate tlas only once
- [x] studio models:
  - [x] pre-cached models with prebuilt blases
  - [x] blas update
  - [x] counters for static-vs-dynamic cache entries count
    - [x] better `r_speeds_graphs`
      - [x] add/remove commands which modify the string
      - [x] constant monitoring of the available metrics: metric registering later should start being drawn
  - [ ] ~~cache eviction/LRU (needs proper allocs for accel buffer and kusochki)~~ -- doesn't seem to be a problem for now. Can totally live without.
  - [x] previous vertices and transform
- [x] Fix animated textures: pass and update kusochki
- [x] Fix emissive textures
  - loading order has changes, now kusochki are uploaded when brush model is loaded, and before lighting data is applied, thus losing emissive values
- [x] Remove deprecated APIs:
  - [x] dynamic model
  - [x] `VK_RenderModelInit_old`
  - [x] `VK_RenderModelDraw_old`
  - [x] `deprecated` section from `vk_render_model_t`
  - [x] old ray model
  - [x] old ray model cache
- [x] hide `rt_blas_t` as rt-internal, only expose new `rt_model_t`
- [x] restore TriApi/dynamic geometry for RT
  - [x] dynamic drawing for RT
  - [x] dynamic `rt_blas_t`
- [x] brush water update
  - [x] rt_blas update
  - [x] vk/rt models update
- [x] studio dynamic models
  - [x] reloading c2a5 leads to geometry exhaustion (cannot allocate N vertices M indices, and missing models)
  - [x] better static model detection: many sequences/frames are the same and are not in fact animated. This can be detected at load time.
- [x] `r_speeds` persistent metrics which are not reset on every frame, e.g. allocation counts, cache sizes, etc
2023-08-31 10:10:59 -07:00
Ivan Avdeev 1d9b987379 vk: treat emissive animated texture frames as polylights
Probably not the most optimal solution, but it works.

Fixes, #458
2023-08-31 12:49:30 -04:00
Ivan Avdeev 9c4fd15e65 vk: fix animated textures for brush models 2023-08-31 12:11:17 -04:00
Ivan Avdeev 3e14591082 vk: wkrutily lampotschkee
fixed missing emissive values for brush models
2023-08-31 11:45:51 -04:00
Ivan Avdeev ea1a98716d vk: restore dynamic polygon lights 2023-08-29 13:39:36 -04:00
Ivan Avdeev 0ccc107859 vk: associate more logs with modules 2023-08-29 13:12:35 -04:00
Ivan Avdeev 6d3c5bfa3e vk: add runtime-toggleable debug logs with module granularity
Use e.g. `vk_debug_log "mat,tex,brush"` to enable verbose debug (-dev 2)
logs for Material, Textures and Brush modules.
2023-08-29 12:31:57 -04:00
Ivan Avdeev e978871470 remove unused vk_previous_frame module 2023-08-28 13:12:02 -04:00
Ivan Avdeev ffa9603747 vk: studio: fix motion vectors for denoiser
Track prev_verts by render submodel
2023-08-28 12:59:54 -04:00
Ivan 'provod' Avdeev 2dc68544d6 vk: studio: remove obsolete comments 2023-08-28 09:11:48 -07:00
Ivan 'provod' Avdeev 45a141aa36 vk: studio: clear submodule cache at appropriate times
Add render refcount to submodels to diagnose when it can't properly clear things due to them being used somewhere still.

Also add `speeds.submodels_cache_{dynamic,static}` counters to show how many submodels render models have been allocated.
2023-08-28 09:11:48 -07:00
Ivan 'provod' Avdeev 03fc537d54 vk: studio: implement proper per-submodel rendermodel cache
Gives out individual render submodels for dynamic ones, receives and remembers them when they are not needed anymore.

Stores only one render submodel for static ones. Reuses/instantiates it for everyone.
2023-08-28 09:11:48 -07:00
Ivan 'provod' Avdeev c42cf2088c vk: studio: handle first half of entity reuse
Detect whether studio model has changed, and replace it with a new one.
It does (as predicted) run into a gpu sync issue if reuse happened while previous frame with the old user is still being drawn.
2023-08-28 09:11:48 -07:00
Ivan 'provod' Avdeev 567d014ada vk: studio: precompute per-submodel dynamic-ness
Basically go through all sequences and bones, and try to find out whether a given submodel is affected by animation frames.
2023-08-28 09:11:48 -07:00
Ivan 'provod' Avdeev 9636b541c5 vk: studio: make dynamic-ness detection more granular
also comment on the upcoming submodel caching plans
2023-08-28 09:11:48 -07:00
Ivan Avdeev 47cc51d9b1 vk: studio: track studio model state by entity 2023-08-28 09:11:48 -07:00
Ivan Avdeev 09d8534b01 vk: studio: extract all model/cache stuff into separate files 2023-08-28 09:11:48 -07:00
Ivan Avdeev f99d43ec4c add a bunch of wip changes wrt studio model cache 2023-08-28 09:11:48 -07:00
Ivan Avdeev f691b4b4b0 vk: add "persistent" speeds metrics for used memory, etc
Renames previous METRICS to COUNTERS. These are still reset to zero
every frame.

Adds new METRICS which are preserved, maintained externally to speeds,
and only sampled by speeds code once per frame.

Also adds new metrics:
- `studio.cached_submodels` -- number of submodels in cache
- `geom.used` -- memory used by long allocations
- `geom.{vertices,indices}` -- counts of vertices/indices for long
  allocations
- `geom.dyn_{vertices,indices}` -- counts of vertices/indices for
  single-frame dynamic allocations
2023-06-14 11:23:09 -07:00
Ivan Avdeev d13c0d4748 vk: add studio dynamic and static submodels metrics 2023-06-13 12:19:18 -07:00
Ivan Avdeev 5dda220751 vk/speeds: preserve metric names that might not be registered initially
When `r_speeds_graphs` cvar is read for the first time, not all metrics
might be registered yet. It leads to some graphs missing.

Retry searching for these metrics on further frames, thus preserving the
graph list from previous session fully.
2023-06-13 11:52:46 -07:00
Ivan Avdeev c72ff1d0c5 vk: add ability to delete graphs by their names
Also, track single changes vs cvar changes: do not reload everything
from cvar on every update
2023-06-13 10:32:32 -07:00
Ivan Avdeev 0b47621f69 vk: add r_speeds_graph <add/del/clear> command
Allows adding graphs w/o editing the cvar manually

Delete is not implemented yet
2023-06-13 10:12:41 -07:00
Ivan Avdeev 046ae3d7f3 vk: rename metrics to module.name, prettify list
- Add variable name and registration src:line to the
  `r_speeds_list_metrics` output. Makes it easier to reason about where
  does this metric come from.
- Group metrics by their modules, makes it easier to discover.
- Do not print the list immediately on command, do it later in the
  frame. Makes it print correct latest frame values.
2023-06-13 09:39:50 -07:00