Commit Graph

4233 Commits

Author SHA1 Message Date
Ivan Avdeev 6fda8bd977 vk: add a mechanism for exclusion of single surfaces from smoothing
Uses `_xvk_smoothing_excluded` field.

Surfaces can still be smoothed with a limited list of neightbours explicitly
by being included in a smoothing group.

Fixes #619
2023-10-31 09:55:06 -07:00
Ivan 'provod' Avdeev 5698746f42 vk: do not crash on corrupted scopes stack
This is not a valid reason to assert/crash, even though it is clearly a programming mistake.
If the stack is corrupted, just print its contents as an S_ERROR and continue.

Also:
- Fix the ultimate reason for stack being unbalanced for #604
- Do not analyze scopes when not needed, i.e. when `r_speeds` is zero.

Fixes #604
2023-10-31 09:13:47 -07:00
Ivan Avdeev f1c8b3ef2f
Merge pull request #612 from w23/texture-storage
Improve texture storage and lookup

- [x] Fix #594 
  - [x] Free engine textures
  - [x] Fixup descriptor sets
  - [x] Fix PBR leaks
    - [x] texture refcounts
      - [x] acquire/release textures in materials
- [x] Done #210 to separate refcount-aware material loading from refcount-unaware ref_interface_t
- [x] Done #602
- [x] #601
- [x] Fixes #617
- [x] кто украл скайбокс?! -- повар украл скайбокс
- [x] Convert blue noise to 3D texture
- [x] fixes #613
2023-10-31 08:49:18 -07:00
Ivan Avdeev a9df5cd86f
Merge branch 'vulkan' into texture-storage 2023-10-31 08:19:40 -07:00
Ivan Avdeev 737d1324e8 vk: assign translucent material mode to transparent studio models
fixes #613
2023-10-31 11:15:15 -04:00
Ivan Avdeev effbf3ea3d vk: fixup material lookup by texture name 2023-10-31 11:03:08 -04:00
Ivan Avdeev 36c06a514e vk: massage texture module a bit more 2023-10-31 10:48:14 -04:00
Ivan Avdeev 5962290b9d vk: simplify texture uploading failure cleanup 2023-10-31 10:43:12 -04:00
Ivan Avdeev 67f336b3c8 vk: load blue noise 3d texture from an array of png files 2023-10-31 09:44:06 -04:00
NightFox 6f40adab98 update rad files
Refactoring, performance improvement (more for c1a0b), minor changes
2023-10-31 05:30:46 -07:00
Ivan 'provod' Avdeev 23341c144c vk: fixup blue noise 3d texture refactoring
Fixed a bunch of validation and shader errors
2023-10-30 13:51:23 -04:00
Ivan Avdeev df3c0e30ba vk: convert blue noise texture to 3D
Note: not tested
2023-10-30 13:43:09 -04:00
Ivan Avdeev 1f043a90a6 vk: remove dummy textures for new material name resolution
Use dedicated hash table for new material names.
Updates a lot of dependent code:
- surface patches now target materials, not textures:
  `s/_xvk_textures/_xvk_material`
- patching now affects only materials, not texture ids. All logic that
  depends on texture ids now operate on original textures.
- brush normal smoothing now ignores patched surface materials when
  deciding whether two surfaces can be smoothed.

The rationale is that patching should only affect newer PBR/RT code paths.
2023-10-30 12:43:26 -04:00
Ivan Avdeev 8c37b25b31 vk: destroy textures on shutdown more explicitly 2023-10-30 10:44:57 -04:00
Ivan Avdeev 97a889cabb vk: fix missing skybox 2023-10-30 10:19:13 -04:00
NightFox 114015c208 update patches 2023-10-29 11:40:06 -07:00
Ivan Avdeev bc26e8150a vk: fixup mip auto generation 2023-10-27 10:50:46 -04:00
Ivan Avdeev 96864cf0bd vk: silence extra logs, add diagnostic checks 2023-10-27 10:41:39 -04:00
Ivan 'provod' Avdeev eab46bfe20 vk: fix unordered_roadmap windows compilation 2023-10-27 10:18:48 -04:00
Ivan Avdeev ef65ba56ba vk: fix textures leaking at shutdown; add hash table stats 2023-10-27 10:12:34 -04:00
Ivan Avdeev 7d53458ea3 vk: track all ref_interface texture access as a single refcount ref
Legacy ref_interface_t texture access is not refcountable. It does
create/destroy texture in a single call regardless of other users.
Track it with a separate flag that affects refcount with a single +1/-1.
2023-10-27 09:33:01 -04:00
Ivan 'provod' Avdeev bf9ca596eb vk: fix windows build
Windows lacks strcasestr, use Q_stristr
2023-10-27 09:05:53 -04:00
Ivan Avdeev 7eb1bedc9b vk: acquire/release textures more carefully in materials
Make sure that every texture used in materials is properly tracked.
2023-10-26 12:00:34 -04:00
Ivan Avdeev a5e3adf518 vk: make texture hash table case insensitive
Too many places in the engine and the renderer expect texture names to
be insensitive: RAD files, material references, probably engine and game
calls too.

Make it universally case insensitive. Also, add rudimentary tests for
it.
2023-10-26 11:38:37 -04:00
Ivan Avdeev d37020806a vk: fixup re-creating texture images 2023-10-26 11:04:23 -04:00
Ivan Avdeev ee35b02a5d vk: update todo for E318,E319 2023-10-26 10:39:35 -04:00
Ivan Avdeev 063b3d5246 vk: assert on empty pool allocation early 2023-10-26 10:39:12 -04:00
Ivan Avdeev afd98e50c9 vk: fixup disappearing surface lights
Previous hash table was case insensitive, while the new one is
sensitive.
For now the workaround is to tolower texture names in rad files.

Proper way would be to address case-sensitivity globally. Currently it's
not very consistent.
2023-10-26 10:10:01 -04:00
Ivan Avdeev 67e5109b4a vk: fixup loading pbr materials
Texture lookup was returning incorrect index=1 all the time.

Known issues:
- surface lights disappeared
2023-10-26 09:56:19 -04:00
Ivan Avdeev 718d6d2592 vk: move textures to urmom
Known issues:
- pbr materials are completely broken. They end up not being able to
  find textures, seemingly due to memory corruption on materials side,
  not textures.
- There are still places that try to get texture=1
2023-10-24 14:02:32 -04:00
Ivan Avdeev beddef8831 vk: remove direct dependence on vk_textures[] from vk_textures.c
also fixup textures shutdown
2023-10-24 12:24:14 -04:00
Ivan Avdeev c36080c982 vk: move things around between {r,vk}_texture
Another step in preparation for new hash table and better lifetime
management
2023-10-24 11:32:42 -04:00
Ivan Avdeev b016de0c83 vk: add unordered_roadmap simple hash map with tests
Adds unordered_roadmap simple hash map:
- open addressing with linear probing
- size is fixed at init/compile time
- operates on an pre-allocated array of items with hashmap headers

Also adds basic tests for it.
And properly enables tests for ref_vk (i.e. alolcator)
2023-10-23 13:13:16 -04:00
Ivan Avdeev b0a7a13c19 Update README.md 2023-10-21 20:29:23 -07:00
Ivan Avdeev ab6f18fc32 vk: incapsulate skybox textures 2023-10-20 13:04:33 -04:00
Ivan Avdeev af032bd2be vk: begin texture r_/vk_ split
no functional changes, just copied some functions over
2023-10-20 12:39:46 -04:00
Ivan Avdeev b315f463cf vk: rename vk_textures to r_textures 2023-10-20 11:18:55 -04:00
Ivan Avdeev c4935e483c vk: BREAK texture management with refcounts
THIS COMMIT IS BROKEN AND LEADS TO MISSING TEXTURES

There's a "race" between texture release/acquire on changelevel.
Textures end up being deleted when they shouldn't.

Addressing this is tedious, will be done in the following commits.
2023-10-20 10:55:19 -04:00
Ivan Avdeev 18261da713 vk: massage texture module function names
Bring function names to a single style.
Make them state what they actually do.
2023-10-19 11:15:48 -04:00
Ivan 'provod' Avdeev fd97dc2c24 vk: fix texture corruption after a few changelevels
We were running out of descriptor sets, as they weren't being freed at all.
Now there's a 1-1 table of texture-descset, and no way to run out of them.

Better solution would be to move this descset management to vk_render, and allocate them dynamically from a smaller pool.
2023-10-17 13:17:47 -04:00
Ivan Avdeev e1d478fa28 vk: free textures on map change (DO NOT USE)
Leads to texture corruption and GPU crashes on Linux.
2023-10-17 11:43:38 -04:00
Ivan Avdeev 806932b949 vk: clean up public rendering texture api 2023-10-17 11:26:29 -04:00
Ivan Avdeev aa44ab71e5 vk: show only `speeds.` metrics when doing `SPEEDS_BIT_STATS`(2) 2023-10-17 07:46:16 -07:00
Ivan Avdeev 2f7b9d5d14
Merge pull request #609 from w23/vulkan-upstream-merge-20231017
Merge from upstream
2023-10-17 07:12:45 -07:00
Ivan Avdeev bd07444d6e Merge remote-tracking branch 'upstream/master' into vulkan-upstream-merge-20231017 2023-10-17 09:48:42 -04:00
Ivan Avdeev 2f365b7f97
Merge pull request #603 from w23/dds_ktx
Support DDS and KTX2

- [x] Pass KTX2 as raw data
- [x] Simplify image uploading (there are 2 copies of the same uploading code for regular textures and for KTX2)
- [x] Extract long format lists from `vk_image.c` to e.g. `vk_image_extra.h`
- [x] Support DDS formats
  - [x] BC7
    - [x] PoC works
  - [x] read supplied mips
- [x] Pass most common KTX2 subformats as correct PF_ format
  - [x] BC5
  - [x] BC6H
  - [x] BC7 -- need UNORM/SRGB expansion
  - [x] BC4 -- need to add it
- [x] Alpha flag for KTX2 formats
- [x] swizzle r->rgba
- [x] check il_dds_hardware
- [x] add `IL_KTX2_RAW_SUPPORTED`
- [x] format imagelib things
- [x] extract image size function to img_utils

Fixes #154
2023-10-16 10:04:53 -07:00
Ivan Avdeev c5b6599be7 imagelib: deduplicate Image_ComputeSize function
Make so that img_ktx2 and img_dds use a common copy of the function
2023-10-16 12:37:58 -04:00
Ivan Avdeev 1d90bb1835 imagelib: format new ktx2 code to codestyle 2023-10-16 12:30:12 -04:00
Ivan Avdeev 1834f388b8 imagelib: check flags for DDS and KTX2 support
- Checks for `IL_DDS_HARDWARE` support for compressed formats in KTX2
- Checks for `IL_KTX2_RAW` before providing raw KTX2 data
2023-10-16 12:17:35 -04:00
Ivan Avdeev ee81a7228d vk: better swizzling
- expand BC4 and BC5 compressed blocks
- negate alpha semantic
2023-10-16 12:08:54 -04:00