Commit Graph

720 Commits

Author SHA1 Message Date
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
Alibek Omarov 34d7664342 ref: gl: disable TGA flip for detail textures, GoldSrc ignores it, so we will too 2023-10-26 05:12:38 +03:00
Alibek Omarov b0a79df86f ref: change r_traceglow to 0, as GoldSrc does 2023-10-26 04:59:01 +03: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
Alibek Omarov 3251b68df5 ref: gl: more simple search of GL func with alternative name (EXT, OES suffixes or no suffix) 2023-10-22 20:02:14 +03:00
mittorn c1d1aa6787 ref_gl: rewrite ARB workaround to check EXT/OES names, notify user that function found with different name 2023-10-22 20:02:14 +03: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
Alibek Omarov b76a75d6b4 ref: gl: respect gl_texture_nearest value for skyboxes 2023-10-20 18:55:22 +03: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 Avdeev a251600c8a
engine: common: imagelib: add KTX2 support (#1455)
* engine: common: imagelib: add KTX2 support

Adds basic KTX2 support for a few compressed formats. KTX2 essentially
is a Vulkan-centric texture format that supports literally hundreds of
pixel formats.
For now only support for these is added:
- `VK_FORMAT_BC4_UNORM_BLOCK`
- `VK_FORMAT_BC4_SNORM_BLOCK`
- `VK_FORMAT_BC5_UNORM_BLOCK`
- `VK_FORMAT_BC5_SNORM_BLOCK`
- `VK_FORMAT_BC6H_UFLOAT_BLOCK`
- `VK_FORMAT_BC6H_SFLOAT_BLOCK`
- `VK_FORMAT_BC7_UNORM_BLOCK`
- `VK_FORMAT_BC7_SRGB_BLOCK`

Adding more formats is relatively straightforward:
- Copy format definition from `VkFormat` enum in `vulkan_core.h`
- Add a new definition into `pixformat_t` enum.
- Add format size calculation into `Image_ComputeSize()`

While we're at it, also adds a few new formats to DDS:
- BC4_UNORM -- PF_BC4_UNSIGNED
- BC4_SNORM -- PF_BC4_SIGNED
- BC5_UNORM -- PF_BC5_UNSIGNED
- BC5_SNORM -- PF_BC5_SIGNED
- BC7 is expanded into BC7_UNORM and BC7_SRGB

ref_gl and ref_soft code is updated where it made sense. But not tested
really. Support for these formats has been tested with ref_vk.

* address spaces-vs-parentheses formatting where noticed

* parenthesize sizeofs

* move ktx2.h to imagelib as img_ktx2.h; massage it a bit

* use SetBits() instead of |=

* remove stale TODO comments
2023-10-18 10:31:40 +03: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 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 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
Ivan 'provod' Avdeev 9dbde6d547 vk: fix roughness on studio model chrome textures
With deprecation of `set` flag, roughness was always replaced on studio model chome textures.
2023-10-16 08:00:15 -07:00
mittorn a2b992d865 ref_gl: fix codestyle 2023-10-16 06:47:55 +03:00
mittorn ddf3f2ffdb gl2shim: Allow drawing huge QUADS sequences by splitting drawcalls on overflow 2023-10-16 06:47:55 +03:00
Alibek Omarov 2454e87509 ref_gl: gl2shim: refactoring, add missing spaces in parentheses and ternary ops, remove singleline multiple assignments, use bitset macros 2023-10-16 06:47:55 +03:00
mittorn 0dc44249a2 ref_gl: fix XASH_GL_STATIC build 2023-10-16 06:47:55 +03:00
mittorn 150cbfa4de ref_gl: do not trust REFAPI context version, get it from OpenGL anyway 2023-10-16 06:47:55 +03:00
mittorn c0b068d81b ref_gl: add workarounds for detecting extensions correctly on gles1/gles2 without wrapper (swiftshader works now) 2023-10-16 06:47:55 +03:00
mittorn fbc312b6cf gl2shim: remove float suffix in shaders, that makes glsl100 work in swiftshader 2023-10-16 06:47:55 +03:00
mittorn 342e0d3e2e gl2shim: add glsl100 support 2023-10-16 06:47:55 +03:00
mittorn 202b228691 gl2shim: correct allocation/cleanup 2023-10-16 06:47:55 +03:00
mittorn c9c1286803 ref_gl: fix typo 2023-10-16 06:47:55 +03:00
mittorn eab98b0eda gl2shim: dynamic extension checking and autoconfiguration 2023-10-16 06:47:55 +03:00
mittorn 35be80fc21 ref_gl: request gl1.1 if compatibility profile unavailiable, this fixes launching with GL <= 2.0, improve old version extension detection 2023-10-16 06:47:55 +03:00
mittorn c7dd9d6437 ref_gl: init r_temppool before InitExtensions, fix extension string allocation 2023-10-16 06:47:55 +03:00
mittorn d378878c91 gl2shim: try fix getting program link log 2023-10-16 06:47:55 +03:00
mittorn 4a2f8cafcd gl2shim: try fix errors in ViZual ZtudiO 2023-10-16 06:47:55 +03:00
mittorn d254bac16b ref_gl: integrate gl2shim extensions 2023-10-16 06:47:55 +03:00
mittorn e23b632ce5 ref_gl: add missing non-arb shader functions 2023-10-16 06:47:55 +03:00
mittorn 2f321b1471 ref_gl: implement minimum inclusion version for GL extensions, implement quering extensions on core profile 2023-10-16 06:47:55 +03:00
mittorn 0265e88d8f gl2shim: fix wrong color vertex 2023-10-16 06:47:55 +03:00
mittorn 4114d2f24d gl2shim: more refactoring 2023-10-16 06:47:55 +03:00
mittorn 8124035763 ref_gl: try fix psvita 2023-10-16 06:47:55 +03:00
mittorn 96127c6eb0 gl2shim: make shaders code more portable 2023-10-16 06:47:55 +03:00
mittorn cf65a39b83 gl2shim: refactoring 2023-10-16 06:47:55 +03:00
mittorn 0341f96b70 gl2shim: use IBO for quads 2023-10-16 06:47:55 +03:00
mittorn c95d91cfe3 gl2shim: limit begin-end chain length, cycle incremental buffers 2023-10-16 06:47:55 +03:00
mittorn cbd10c6279 gl2shim: improve shader version handling, fix particle issues 2023-10-16 06:47:55 +03:00
mittorn 5df9e57743 gl2shim: support incremental non-persistent buffers for arrays 2023-10-16 06:47:55 +03:00
mittorn c178022fb5 gl2shim: persistent incremental streaming buffers, buffer cycling support 2023-10-16 06:47:55 +03:00
mittorn 724c29d711 gl2shim: implement fallback vbo, glDrawRangeElements with non-vbo buffer works now on core contexts 2023-10-16 06:47:55 +03:00
mittorn 74a2dbeb91 gl2shim: batcher experiments (UGLY, DO NOT USE), fix bad shader bindings, Draw QUADS with TRIFAN when possible 2023-10-16 06:47:55 +03:00
mittorn 5d20d24ebc gl2shim: simple matrix invalidation, do not calculate MVP every drawcall 2023-10-16 06:47:55 +03:00
mittorn 0e2fc277c8 gl2shim: bind dummy VAO on DrawElements implementation on glcore, this generates GL Errors, but renders fine on mesa 2023-10-16 06:47:55 +03:00
mittorn 1505740b73 ref_gl: fix enabling multitexturing on GLES 2023-10-16 06:47:55 +03:00
mittorn 6bad07b39d gl2shim: support low (<130) shaders 2023-10-16 06:47:55 +03:00
mittorn f85437dfc5 gl2shim: implement client arrays (not in glcore/vao mode), make studio/world array render work 2023-10-16 06:47:55 +03:00
mittorn c765261db6 ref_gl: fix late studio cvars registration, enable DrawRangeElements in GLES contexts 2023-10-16 06:47:55 +03:00
mittorn 73087ead2d ref_gl: fix build with XASH_GL_STATIC, avoid using ARB shader extension on core context 2023-10-16 06:47:55 +03:00
mittorn 8c88e82709 gl2shim: support more GLSL versions 2023-10-16 06:47:55 +03:00
mittorn 40dd6e0234 gl2shim: Cleanup warnings, use APIENTRY declarations, stub unsupported functions 2023-10-16 06:47:55 +03:00
mittorn eb23b226cc Workaround core context issues 2023-10-16 06:47:55 +03:00
mittorn 676526a518 ref_gl: fix creating core context, support core in gl2shim by creating dumb array object 2023-10-16 06:47:55 +03:00
mittorn 7e0bd86b65 ref_gl: allow enabling XASH_GLES without wrapper, add ref_gles3compat, wrap gles functions in gl2wrap when XASH_GLES enabled 2023-10-16 06:47:55 +03:00
mittorn 97489635af gl2shim: limited matrix support 2023-10-16 06:47:55 +03:00
mittorn a9ea3976a7 ref_gl: introduce gl2_shim based on vgl_shim for future limited core/gles context support (SLOW, still needs ffp for matrix operations) 2023-10-16 06:47:55 +03:00
Alibek Omarov de19d78571 ref: fix late registration of studio cvars (thanks, @mittorn) 2023-10-14 08:11:25 +03:00
mittorn 287381d5ca ref_gl: remove complete useless macro, enable VBO under option 2023-10-14 08:04:17 +03:00
Ivan 'provod' Avdeev 2e2e17b008 imagelib: vk: add support for BC4
Tested with KTX2 and ref_vk
Added to DDS too.
Not added to any other renderers.
2023-10-13 21:47:22 -04:00
Ivan 'provod' Avdeev b64d8865fd imagelib: support BC7 in KTX2; split into UNORM and SRGB
Also, fix KTX2 mips corruption.
2023-10-13 21:31:39 -04:00
Valery Klachkov 61d32cd384 Fix dummy textures allocation. Fixes 532
It's backport from my old texture manager for Xash3D-FWGS
2023-10-13 20:47:30 +03:00
Ivan Avdeev a7a7026fdc vk: imagelib: support more dds/compressed formats
- vk: support more compressed formats from imagelib
- imagelib: add BC5(s/u) support for DDS
2023-10-13 09:39:11 -04:00
Ivan Avdeev 3ac5e88b59 vk: extract long functions from vk_image 2023-10-13 09:04:20 -04:00
Ivan Avdeev a0e1dfe4cd vk: use imagelib mipmaps if available 2023-10-13 09:02:08 -04:00
Ivan Avdeev 7cbd34ebdb vk: prototype dds/pf_bc* loading support
known issues:
- doesn't handle mips properly yet.
2023-10-12 14:33:18 -04:00
Ivan Avdeev 0a5f061ba3 vk: consolidate and simplify texture uploading 2023-10-12 14:05:15 -04:00
Ivan Avdeev 8ba7b3649e vk: extract tex/image uploading routines 2023-10-12 13:39:07 -04:00
Ivan Avdeev 4158234fb2 rename ktx_ to ktx2_ for consistency 2023-10-12 12:51:58 -04:00
Ivan Avdeev 90119ae84a imagelib: add rudimentary KTX2 support
It only does a very basic header validation, and passes the entire file
as PF_KTX2_RAW format. This is to simplify KTX2 reading in ref_vk and
trying out different formats. KTX2 has support for >200 format, and
passing all of them through PF_ types is a non-starter.

The plan is to figure out which formats we want to support, and add
their support to imagelib/ktx2 incrementally, leaving the rest as
PF_KTX2_RAW, so ref_vk still can use them.
2023-10-12 12:38:35 -04:00
Ivan Avdeev 9ca7aad276 vk: align textures to texel block size on upload
fixes occasional validation woes
2023-10-10 14:02:49 -04:00
Ivan Avdeev 5ba5fc4831 vk: fixup build after backmerge 2023-10-10 14:00:47 -04:00
NightFox ecdb68370b
Merge branch 'vulkan' into materials-table 2023-10-10 20:32:04 +03:00
Ivan Avdeev 7396403984 vk: materials: allow inheriting previously defined materials
`"inherit" "debug_test"` will replace all fields for the current
material with ones from material named "debug_test".
`"inherit"` should be specified before any material fields, except for
selectors like "new", "for" and "for_rendermode".
2023-10-10 13:27:10 -04:00
Ivan Avdeev fc36fb7c13 vk: create unorm image view only if asked and needed
Do not create unorm image view:
- if not asked
- already has unorm format
- format has no meaningful unorm counterpart
2023-10-10 12:18:58 -04:00
Ivan Avdeev 7b69988e41 vk: materials: use native color hint explicitly to avoid enforcing gamma 2023-10-10 12:08:25 -04:00
Ivan Avdeev bf403027c6 vk: rt: do linear vertex_color interpolation 2023-10-10 12:01:39 -04:00
Ivan Avdeev fadde2ea0d vk: rt: convert more engine-supplied colors from sRGB to linear
- model.color
- vertex_color
2023-10-10 11:56:42 -04:00
Ivan 'provod' Avdeev 4fa614d35b vk: rt: do not use fast srgb-linear conversion
FAST mode is incorrect for low values and leads to visible rendering artifacts.
2023-10-09 19:49:54 -04:00
Ivan Avdeev d76d6429d0 vk: rt: ensure that base_color_a is stored in sRGB-γ
Storing it linearly was a mistake: it is 8-bit only, and lacks enough
precision for dark values. It also doesn't really need any more
precision, and should be limited to 0..1 range.

Therefore, it makes sense to treat it as sRGB explicitly.
2023-10-09 14:51:29 -04:00
Ivan Avdeev 7bfba01954 vk: rt: add test for srgb-vs-linear model color 2023-10-09 14:51:07 -04:00
Ivan Avdeev 9843f53cde vk: rt: recreate images on format change 2023-10-09 14:48:50 -04:00
Ivan Avdeev 57093d7198 vk: remove extra stuff, add comments about SRGB swapchain 2023-10-09 13:13:11 -04:00
Ivan Avdeev 2ec92eea0d vk: add a bunch of profiler scopes to rt rendering 2023-10-09 13:02:04 -04:00
Ivan Avdeev 3b40469a87 vk: fix validation sync error on changelevel 2023-10-09 12:48:38 -04:00
Ivan Avdeev 1d2da5831e vk: image: make a raw unorm image view for trad renderer
Traditional renderer operates in sRGB-γ space (as everyone was in 199x).
Making vulkan textures explicitly SRGB for RT renderer breaks color for
trad rendere. Make sure trad renderer still has raw SRGB-unaware texture
sampling.

Adds an UNORM image view for all relevant SRGB textures, and uses them
exclusively for trad renderer. RT still gets proper SRGB views.

Also rename XVK_ to R_Vk for images
2023-10-09 12:39:12 -04:00
nilsoncore 79e0e52061 vk: profiler: devmem: save `peak` instead of `total` metrics
Also minor code structure changes.
2023-10-07 16:58:04 +03:00
Alibek Omarov 3f505103e1 ref: vk: do not create cl_righthand cvar 2023-10-07 00:53:15 +03:00
Alibek Omarov 2c520a6a55 ref: vk: enable compiling with older Vulkan headers 2023-10-07 00:53:15 +03:00
Alibek Omarov fcc6bba88a Merge upstream/master 2023-10-07 00:53:04 +03:00
Ivan Avdeev 9b9e89adec vk: make all texture samplers return values in linear space
Make sure that all SRGB-gamma textures are marked with SRGB format (this
includes all the original textues, 8bit PNG textues). All other
textures (roughness, metallic, normal maps) are linear (UNORM).

Trust KTX2 texture that they store in the correct colorspace.

Then we can just sample textures w/o SRGBtoLINEAR'izing them. Supposedly
this is better because of hw interpolation in the correct colorspace.

This is a bit experimental because Compressonator can't really into
BC7_SRGB, which is sad. And also we need to re-gamma all the textures
for the gamma/srgb-unaware traditional renderer.
2023-10-06 15:06:44 -04:00
Ivan Avdeev 60f83245ee vk: rt: make base_color_a linear-space
Convert from gamma to linear at the point where we read from texture.

Prerequisite for making textures in a right colorspace.
2023-10-06 13:51:32 -04:00
Ivan Avdeev 41ac5fa0eb vk: fix printing 64-bit numbers in x86 linux 2023-10-06 13:13:31 -04:00
Ivan Avdeev 96e9ef20ab vk: rt: make normalmaps switchable between xyz.png and xy.ktx2
They have slightly different incompatible encodings. Switch between them
using #define at build time.

Old png code can be removed when we fully switch to KTX2.
2023-10-06 13:05:42 -04:00
Alibek Omarov a738b2a50b ref: restore missing PARM_TEX_MEMORY RenderAPI parameter 2023-10-06 19:24:02 +03:00
NightFox 56737fd05f
Merge pull request #591 from w23/everything-is-smooth
vk: patch: allow smoothing entire brush model
2023-10-05 22:00:39 +03:00
Ivan Avdeev ab53aae359 vk: textures: preliminary KTX2 support
Loads something. Not everything. Not everything correctly.
Doesn't do validity checks.

Makes colorspace (srgb gamma vs linear) inconsistent between textures
(ktx has correct srgb-vs-unorm, all is unorm (but srgb gamma
semantically) in png)
Makes normals inconsistent too (.xy in ktx, .xyz in png)

related #154
2023-10-05 14:23:46 -04:00
Ivan Avdeev 7e3f8785f7 vk: fix normalmap glitches
Was triggered by renormalizing normal z when applying normal scale.
Not sure why exactly, though, the math checks out.

Doing it a bit differently solves the issue.

Fixes #595
2023-10-05 12:48:48 -04:00
Ivan Avdeev 9b90e920a7 vk: add textures counts/size to metrics
Also split frame flame graphs and metric graphs to different `r_speeds`
bits.

related to #594
2023-10-05 12:20:07 -04:00
NightFox 206fd528d8
Merge branch 'vulkan' into bluenoise 2023-10-04 22:44:49 +03:00
Ivan Avdeev 0d6f6d26af vk: material: add material table independent of texture table
It still reuses texture table for name lookup for now.
2023-10-03 12:48:26 -04:00
Ivan Avdeev 6bfa4c90fa vk: brush: assign white texture for kRenderTransColor
kRenderTransColor mode strips geometry of its texture and makes it solid
color. Previously we were noticing this rendermode late, and failed to
update the textures.

Now we depend on reading this rendermode from map entities, and
pre-assigning correct (white) textures on load.

Assumes that rendermode doesn't change at runtime for brush models.

Fixes #528
2023-10-02 11:39:00 -04:00
Ivan Avdeev 1bbcf44864 vk: patch: allow smoothing entire brush model
fixes #589
2023-10-02 11:18:22 -04:00
NightFox bdc66ba52b
Merge branch 'vulkan' into vulkan 2023-10-02 17:58:26 +03:00
Ivan Avdeev 737cd944bb
Merge pull request #572 from w23/lol-materials
- [x] Pass material reference via geom/render API
- [x] Show original textures for traditional renderer, #571
- [x] Remove old material type flags
  - [x] ~~Move sky surfaces to a separate BLAS~~ Remove `SURF_DRAWSKY` from geometries completely #474 
  - [x] **REVERT** `SURF_DRAWSKY` changes. Such surfaces still need to be "drawn" to hide geometry behind it (see comments).
  - [x] Chrome material: have an explicit material for it
    - [x] This needs vk_texture vs vk_material index decoupling
- [x] Assess #577
- [x] Improve paths #578 
  - [x] `pbr/maps/c0a0a.bsp/c0a0a.bsp.mat` -> `pbr/maps/c0a0a.bsp/c0a0a.mat`
  - [x] `pbr/halflife.wad/halflife.wad.mat` -> `pbr/halflife.wad/halflife.mat`
  - [x] Rename files in PBR repo for the above
  - [x] `luchiki/maps/c0a0.bsp.patch` -> `luchiki/maps/c0a0.patch`
  - [x] Rename patch files too
  - [x] Same for spr,mdl
  - [x] Rename
- [x] Pass material mode directly, instead of render type
- [x] Advanced material patching/selection
  - [x] Need a few advanced selection examples
    - [x] #317
    - [x] стёкла у костюма (??)
  - [x] #526
  - [x] #577
  - [x] #213
2023-10-02 07:54:10 -07:00
NightFox bd98fdd1d7
update patches 2023-10-02 01:46:47 +03:00
Ivan Avdeev 8ff89bd5ef vk: materials: add rendermode-specific overrides
Example:
```c1a0d.mat
{
	"for_rendermode" "kRenderTransTexture"
	"for" "table2"
	"basecolor_map" "/colors/white.png"
	"metal_map" "/colors/white.png"
	"roughness_map" "/colors/black.png"
}
```

Fixes #213
2023-09-29 13:59:27 -04:00
Ivan Avdeev 4e01947b6b vk: fix crashing on reloading materials
Needed to drop entity data cache before clearing studio model cache

Fixes #577
2023-09-29 13:02:51 -04:00
Ivan Avdeev e97691b27c vk: patch: allow mapping texture to materials for brush entities
```
{
	"_xvk_ent_id" "39"
	"_xvk_map_material" "generic028 mirror"
}
```

NOTES:
- might severely degrade performance in some cases/under debug as we're
  doing N^2 search with strcmp for rendered entities.
2023-09-29 12:48:32 -04:00
Ivan Avdeev 7839792964 vk: materials: fix bsp/mat file extension culling 2023-09-29 12:39:36 -04:00
Alibek Omarov 95f87e24ee ref: soft: do not register cl_righthand cvar 2023-09-29 13:45:24 +03:00
NightFox 884a4ad97e
Update de_dust2.patch
perestoralsya
2023-09-27 00:05:15 +03:00
Ivan Avdeev b07c5c3740 vk: rt: pass material mode directly from draw command
Different render sources (model types, render types, etc) might require
different material modes. E.g. brush should be translucent (refractive+mirror)
for blend mix modes. However, smoke particles should not be
mirror/refractive for the same blend mix render type.
2023-09-26 13:14:28 -04:00
Ivan 'provod' Avdeev f63dcd14ce vk: rt: draw skybox where ray hasn't hit anything
fixes #579
2023-09-26 12:41:10 -04:00
Ivan 'provod' Avdeev 02efba3902 Merge branch 'vulkan' into lol-materials 2023-09-26 12:36:37 -04:00
Ivan Avdeev acd87043fb vk: materials: load by mdl/spr individually, not by global {models,sprites}.mat 2023-09-26 12:27:24 -04:00
Ivan Avdeev b549ac76f6 vk: add logs and notes about mod/spr load sequence 2023-09-26 12:25:40 -04:00
nilsoncore e3d86af5ab vk: profiler: devmem: code style consistency
Also clarify one comment about enabling stats metrics only with
`-vkdebugmem` parameter.
2023-09-25 23:47:04 +03:00
nilsoncore 95223077b6 vk: profiler: devmem: take into account alignment holes
Also improve `VK_DevMemFree` debug printing: include usage type, size,
alignment, and unusable alignment hole size.
2023-09-25 23:43:45 +03:00
NightFox 24c0faca99
de_dust2.patch
remove bad sky surfaces
2023-09-25 21:40:18 +03:00
Ivan Avdeev 26224b4aca vk: materials: add a few stream E301 notes 2023-09-25 13:57:43 -04:00
Ivan Avdeev e8a09c85e5 vk: load map patches without extra .bsp extension
e.g. `c1a0d.patch`, not `c1a0d.bsp.patch`

Ref: #578
2023-09-25 12:53:58 -04:00
Ivan Avdeev e26ce740f1 vk: cut orig file extension from material files
E.g. load `pbr/halflife.wad/halflife.mat` not `pbr/halflife.wad/halflife.wad.mat`

Requires changes to the PBR repo.

Reference: #578
2023-09-25 12:44:41 -04:00
nilsoncore 985ebd23c2 vk: profiler: metrics: fix switch-case scoping to build on linux 2023-09-24 06:23:15 +03:00
nilsoncore aebc730b35 vk: profiler: metrics: make var column wider to fit new wider ones 2023-09-24 06:06:42 +03:00
nilsoncore c7f8a2a8f6 vk: profiler: devmem: store stats for each devmem usage type
Make struct `vk_devmem_allocation_stats_t` which will be able to store
overall stats and stats generic for each usage type.
Move Vulkan related devmem allocation arguments into their own type -
`vk_devmem_allocate_args_t`.
Store `vk_devmem_usage_type_t` inside `vk_devmem_t`, so we can handle
deallocations (frees) for each corresponding type aside from overall
stats.
Make `VK_DevMemAllocateBuffer` and `VK_DevMemAllocateImage` macros which
call generic function `VK_DevMemAllocate` with correspoding usage type
set.
Make function `VK_DevMemUsageTypeString` to be able to get short string
of long enum name.
2023-09-24 06:06:42 +03:00
nilsoncore f515228142 vk: devmem: fix debug message so it builds on linux (hopefully) 2023-09-24 06:06:42 +03:00
Ivan Avdeev 9ac7340974 vk: bring back SURF_DRAWSKY geometries
Needed to hide invisible geometry on e.g. c5a1. Breaks de_dust2 roofs
(#474). That will need to be addressed some other way.

Still uses special value for base_color texture to signal SKY SURFACE.
A supposedly better way to do this would be to have them have a special
material.
2023-09-22 10:15:34 -04:00
Ivan Avdeev 638bd163af vk: remove chrome material type; patch roughness manually instead
Also, material struct is now embedded into geometry, so it can be
individually patched.
2023-09-22 09:43:27 -04:00
nilsoncore a909f7bcab vk: profiler: use existing functions
Use built-in `Q_memprint` to output memory sizes.
Use built-in `COM_FileWithoutPath` instead of newly added
`get_filepath_from_filepath` to truncate full filepath from filename.
2023-09-22 05:06:57 +03:00
nilsoncore 4f6d9b8e1e vk: devmem: code style consistency 2023-09-22 05:01:46 +03:00
nilsoncore 5a745249e1 vk: devmem: integrate it with `r_speeds` metrics
Clarify type name `vk_device_memory_t` as `vk_device_memory_slot_t`
to not confuse it with `vk_devmem_t` as their names are pretty much
the same.
Add additional helper functions to standardize VK flags output format.
Also maybe it is a good idea to have it inside `vk_flags.{h,c}`,
for example.
Improve debug printing: bring colors and improve readability.
Add internal (private) field `_block_size` to `vk_devmem_t` so we can
keep track of how much memory we freed.
2023-09-22 04:59:23 +03:00
Ivan Avdeev dce0598962 vk: remove special SURF_DRAWSKY handling
1. Completely remove them from geometries
2. Draw skybox where the ray hasn't hit anything
3. In the same fashion sky is not shadowed when there's nothing hit by
   the shadow ray.

This allows completely removing the sky material flag.
Also supposedly fixes #474
2023-09-21 12:53:17 -04:00
Ivan Avdeev cd4014766b vk: explicitly pass old original texture for trad renderer
Fixes #571
2023-09-19 13:20:04 -04:00
Ivan Avdeev 07f1bac938 vk: pass material reference explicitly in geom structure
This is needed to enable advanced material patching, where the material
can be picked up based on source type, render mode, surface number, etc
etc and all of the above combined if needed.

Previous scheme was picking up materials very late when all of this info
has been already lost.
2023-09-19 13:05:12 -04:00
nilsoncore 02604cd901 vk: profiler: metrics: remove outdated comment 2023-09-18 05:57:49 +03:00
nilsoncore 977eda258a vk: profiler: metrics: little tweaks
Remove unnecessary `crtlib.h` import in `profiler.h`.
Simplify `get_filename_from_filepath` function.
Add extra guards in metrics line printing to make sure we would not
leak/blow up anything.
2023-09-18 02:57:09 +03:00
nilsoncore 37600be985 vk: profiler: metrics: call print on lines only if necessary 2023-09-18 01:47:58 +03:00
nilsoncore e939d3eab6 vk: profiler: metrics: drop arguments, use globals
This is related to static function of metrics print.  It probably does
not need to expose arguments and can just use globals directly.
2023-09-18 00:55:18 +03:00
nilsoncore d5df2d2791 vk: profiler: metrics: store filepath, but print only filename
Previously, source filepath was truncated right at metric registration,
so only the filename was stored.  Now, full source filepath is stored.
The truncation to its filename happens only in metrics print.  This way
we preserve full information, but also throw away redundancy in print.
2023-09-18 00:35:35 +03:00
nilsoncore 79c2d5768f vk: profiler: metrics: separate printing methods into different commands
Remove command `r_speeds_list_metrics` and cvar
`r_speeds_metrics_as_table`.  Now, there are 2 new commands:
`r_speeds_mlist` - to print metrics as a list, and
`r_speeds_mtable` - to print metrics as a table.
Both of them can handle optional filter argument.
2023-09-17 17:16:20 +03:00
nilsoncore b4aa0fcaf1 vk: profiler: metrics: print filenames instead of filepaths
Reduces enormous amount of space used by absolute filepaths in
metrics print.  This does not mean we cannot locate the files now.
Pretty much all of the vk files have such prefix in their name.
2023-09-17 17:06:49 +03:00
nilsoncore 6659c83c6d vk: profiler: print metrics header twice (top and bottom)
Second header down below the metrics print may help to visually see
the output format without the need to scroll console all the way up.
2023-09-17 16:35:19 +03:00
nilsoncore c07fe8cd9c vk: profiler: add option to print metrics as table
Slightly improve metrics list print formatting and
add new option to print it as a table.  Table alignment relies on
monospace font.
This can be turned on/off with cvar `r_speeds_metrics_as_table`.
2023-09-16 14:08:34 +03:00
nilsoncore d2b71eb3f7 vk: profiler: fix source locations for scopes (#542)
Fix source locations for scopes in `r_speeds_list_metrics`.
Closes #542.
2023-09-16 14:00:54 +03:00
Ivan Avdeev e27bfdc682 vk: studio: minor changes around FIXMEs
accidentally fixes #174
2023-09-15 14:00:37 -04:00
Ivan Avdeev 2e1cb8173e vk: studio: use explicitly set RI.currentmodel over entity->model
`thirdperson` mode overrides entity model while leaving entity->model
with the old value. Vk renderer was assuming that those are the same.

Fixes #551
2023-09-15 12:47:53 -04:00
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
Alibek Omarov 8eef212726 ref: gl: fix compile 2023-09-11 21:22:53 +03:00
Ivan Avdeev a1cae92a2c vk: textures: add blue noise textures
They are not used by anything yet.

Fallback to generating regular noise textures if bluenoise ones weren't
found.

Real blue noise textures require Half-Life-PBR repo textures.
2023-09-11 12:31:03 -04: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
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
Velaron 1589defda1 ref: gl: don't create cl_righthand cvar 2023-09-08 15:52:07 +03:00
Velaron df921d8664 some cleaner code 2023-09-08 15:52:07 +03:00
Velaron f3949474b9 ref: gl: fix cl_righthand behaviour 2023-09-08 15:52:07 +03: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 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 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
Alibek Omarov 22f60d50ac ref: gl: only enable/disable texture units in fixed-function pipeline rendering, in our case, low TMUs 2023-08-21 10:01:59 +03:00
fgsfds f79aaf93f8 ref: gl: psvita: disable NPOT textures, they're broken again 2023-06-25 18:15:18 +03:00
Alibek Omarov 21b47dff32 ref: gl: static-ize globals and functions in gl_warp 2023-06-25 13:17:46 +03: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
Ivan Avdeev 6583ed0c31 vk: fixup sequences fps formatting 2023-06-09 11:34:39 -07:00
Ivan 'provod' Avdeev ba041fce36 vk: update animated studio models geometry
Still slightly KORYAVY as:
- there's no cache eviction, it might get full pretty quick
- static-vs-dynamic animation decision is pretty rudimentary, might consider non-animated things as dynamic
- args passing vs global state is meh
2023-06-09 11:28:30 -07:00
Ivan 'provod' Avdeev cadf3dbdfc rt: update blas for brush water
Enable updating rt_blas, and use that for updating brush water models
2023-06-09 10:03:00 -07:00
Ivan Avdeev 406a5f9d4b vk: remove old dynamic beam segs code 2023-06-07 10:54:09 -07:00
Ivan Avdeev 4409e57a8d rt: fix dynamic models colors 2023-06-07 10:43:54 -07:00
Ivan Avdeev 0b8fe6fe33 rt: implement fast dynamic models
It works, and works really fast.
Known issues:
- missing colors
2023-06-07 10:24:29 -07:00
Ivan Avdeev e6bf0c452a rt: more removals 2023-06-06 11:21:47 -07:00
Ivan Avdeev 789982277d rt: remove more unused and obsolete things 2023-06-06 10:50:16 -07:00
Ivan Avdeev 98f8300ca2 vk: remove lots of obsolete code
TriApi/dynamic stuff is still not passed to RT, but removing old code
makes it easier to reason about.
2023-06-06 10:40:10 -07:00
Ivan Avdeev 8e0a9ac4d4 vk: remove old dynamic model implementation too
Breaks dynamic model RT rendering, as it is not implemented yet
2023-06-06 10:20:00 -07:00
Ivan Avdeev c105d45265 vk: remove public render dynamic model api
It still remains internally, and generates too many BLASes.
2023-06-06 09:50:24 -07:00
Ivan Avdeev 0e13ed38c1 vk: revert beam segs to use triapi, like gl 2023-06-06 09:29:05 -07:00
Ivan Avdeev c271078196 vk/speeds: print current metric value next to graphs 2023-06-06 09:27:52 -07:00
Ivan Avdeev 3e2e5e7cb2 vk: remove old dynamic model api usage from brush+water
This makes water static for now, and also makes it look weird, e.g.:
- no culling of water sides (it is "dynamic" in a sense that it's an
  entity property, not model property)
2023-06-05 12:53:25 -07:00
Ivan 'provod' Avdeev a2b0164e03 vk: put barney back together
Fixes computing total vertices/indices count. Were referencing the same `pmesh` for all meshes.

Floating and missing heads issue seems to be due to incorrect fixed animation frames. I.e. animation frames contain offsets to the correct positions. Should be fixed when animations are done.
2023-06-03 12:10:56 -07:00
Ivan Avdeev df102994c4 vk: pre-build and cache studio submodels on first draw
Known issues:
- no animations, stuck at first rendered frame of a given submodel.
  This is as intended for now, needs BLAS update functionality not yet implemented.
- wrong positions/transforms. Reasons unknown. May be "as intended" too.
- missing heads
- Barney model corruption. Consistent between maps/instances/animation
  frames.
2023-06-02 11:49:02 -07:00
Ivan Avdeev c34c56e203 vk: add r_speeds_list_metrics command, with filter 2023-06-01 12:12:10 -07:00
Ivan Avdeev 3bbca26087 vk: fix disappearing sprites for traditional renderer 2023-06-01 11:42:23 -07:00
Ivan Avdeev 72acf4882d vk: orient sprites to camera
Somehow makes sprites correctly oriented (and winding-culled) for ray
tracing, but makes them disappear (winding-culled) for traditional
renderer. This makes zero sense.
2023-06-01 11:00:50 -07:00
Ivan Avdeev edb151bd1b rt: apply instanced texture overrides to rt_model; makes sprites apply correct textures 2023-06-01 10:15:30 -07:00
Ivan Avdeev 8f47115a01 rt: hide internal apis 2023-06-01 09:25:55 -07:00
Ivan Avdeev ed4d0070f8 vk: override sprite textures for quad instances
Applies correct sprite textures for traditional renderer. Doesn't apply
them to RT yet.
2023-05-31 11:00:28 -07:00
Ivan 'provod' Avdeev 32cb4f73be vk: fixup sprite size and color, also reorient it
Sprites are still not oriented properly though
2023-05-31 10:16:06 -07:00
Ivan 'provod' Avdeev dd8f06ae60 rt: recreate sprite model on every map
This is a workaround for inconsistent memory management: some subsystems completely clear their memories and start allocating from zero. This leads to overwriting long lived sprite model with garbage.

TODO FIXME
2023-05-31 10:15:27 -07:00
Ivan 'provod' Avdeev 8b50ebb035 rt: pass and assign rt_blas debug names 2023-05-31 10:13:40 -07:00
Ivan Avdeev e9ea962bc0 vk: begin refactoring rendermodel api, instantiate sprites, crash gpu 2023-05-31 09:39:27 -07:00
Ivan 'provod' Avdeev c157c9acfc rt: don't forget to add new blases to render list 2023-05-31 08:46:34 -07:00
Ivan Avdeev 0853f1c182 rt: start adding new rt_blas-based rt_model_t
Make brush models use it. Black screen, kekw. But not explicit error
messages. Need to investigate.
2023-05-30 12:14:44 -07:00
Alibek Omarov 16595bf2c0 ref: gl: fix r_showhull check 2023-05-29 14:42:16 +03:00
Alibek Omarov d994c6df9a ref: a bit more verbosity if UserTracer color exceed limit 2023-05-27 22:06:33 +03:00
Alibek Omarov 3a57f26351 ref: gl: move ref_gl cvars to static allocation 2023-05-27 21:52:58 +03:00
Alibek Omarov 8680757844 ref: soft: move ref_soft cvars to static allocation, remove dead cvars 2023-05-27 21:52:58 +03:00
Alibek Omarov 95a8d2f51f ref: soft: attempt to fix freeze in decals on software renderer 2023-05-27 21:52:58 +03:00
Alibek Omarov 5d7d5319fd engine: move ref cvars to static allocation 2023-05-27 21:52:58 +03:00
Ivan Avdeev 7ee16cd82f vk: track block/geom/brush lifetimes
Make sure that things get created and destroyed at the right times.
Allow longer-than-map block allocations.
Fix brush model leaks -- previously they weren't destroyed on map
change/game exit properly. Also free geometry ranges accordingly.

Add a note about map loading process, and various models lifetimes.
2023-05-26 10:45:44 -07:00
Ivan Avdeev d24961db15 vk: add block allocator draft
The intent is to manage long-vs-single-frame allocations better.
Previously long allocations were map-long bump allocations, and couldn't be freed
mid-map, as there was neither a reference to the allocated range, nor a
way to actully free it.

Add a two-mode block allocator (similar to previous debuffer alloc) that
allows making long and once allocations. But now long allocations are
backed by "pool" allocator and return references to the range.

This commit doesn't do the deallocation yet, so map chaning doesn't yet
work.
2023-05-25 12:12:18 -07:00
Ivan Avdeev 9200cbfc25 rt: step even closer to explicit blas+kusochki management
- stop tracking color/xform/mmode with vk_ray_model
- do not expose model to things that don't need to know
2023-05-22 11:02:40 -07:00
Ivan Avdeev 8724efd748 rt: massage vk_ray_model a bit
- explicitly group cache-related fields
- move kusochki allocation to where it's actually used

this makes a step towards better blas management from bottom up
2023-05-22 10:39:48 -07:00
Velaron bb1b9dad23 ref: gl: Goldsrc compatible fog implementation 2023-05-20 23:36:04 +03:00
Alibek Omarov 7333ddc1d9 engine: client: move some RenderAPI GetParm queries to engine 2023-05-19 05:03:25 +03:00
Alibek Omarov 1d965d7543 ref: gl: ignore GenTextures objects that fall into reserved space for skyboxes 2023-05-19 04:37:53 +03:00
Alibek Omarov 1d62df0e2d ref: gl: turn magic skybox numbers into defined macros 2023-05-19 04:36:05 +03:00
Ivan Avdeev 322e7bc419 vk: recreate suboptimal swapchains with correct synchronization 2023-05-18 12:32:00 -07:00
Ivan Avdeev b5f79f3815 rt: DRY the accel creation code 2023-05-18 12:10:21 -07:00
Ivan Avdeev e55e411639 vk: add a couple of TODO comments 2023-05-18 12:00:58 -07:00
Ivan Avdeev b65f84793a rt: start refactoring blas/tlas mgmt code
Draft the new accel/blas apis. Consolidate everything accel-related into
vk_ray_accel.c. Start splitting into more atomic functions. Prepare for
blas-model+kusochki split. etc etc.

The new code isn't really used yet.
2023-05-18 11:59:14 -07:00
Ivan Avdeev 4af9f65cd0 vk: use better debug_break in validation errors callback
Allows us to continue in gdb
2023-05-18 11:58:00 -07:00
Ivan Avdeev 7060a86662 rt: propose rt_blas api 2023-05-17 11:28:09 -07:00
Ivan Avdeev 14a648d16c rt: prepare for blas mgmt refactoring
1. Rename models passed to TLAS to instances.
2. Remove BLAS validation: old, doesn't make sense anymore.
3. Draft general blas mgmt approach in NOTES.md
2023-05-17 10:42:18 -07:00
Alibek Omarov 277bead9b7 ref: remove SetCullState function from StudioAPI. It does nothing on GoldSrc. 2023-05-17 17:23:35 +03:00
Alibek Omarov 68ff265e8d ref: gl: switch texture object allocation to GenTextures usage
This should fix most overlay programs but I only tested it on MangoHud
2023-05-16 23:47:05 +03:00
Alibek Omarov a3ab04e0cb ref: gl: track current bound texture index in gl_textures array in separate glState field 2023-05-16 23:44:52 +03:00
Ivan Avdeev 7d6c12218f vk: comment on why we need inverse model matrix 2023-05-15 09:47:03 -07:00
Ivan Avdeev e54913f8af rt: improve prev frame bone matrix tracking for studio models
Still has some artifacts, but is generally rather close. Will look at
this again when caching studio model BLASes, as we'd be able to look at
them without extra animations.
2023-05-15 09:47:03 -07:00
Ivan Avdeev 091c61a45f vk: make sure studio model vertices are local space
TODO:
- revert not applying rotationmatrix in local vk_studio code
- make sure that prev_frame stuff hasn't changed
2023-05-15 09:47:03 -07:00
Ivan Avdeev e49f517dc0 vk: don't apply studio model matrix to vertices 2023-05-15 09:47:03 -07:00
NightFox c91db96008 update patches 2023-05-05 15:12:28 -07:00
NightFox e86e16235c add rad files for cstrike 2023-05-05 15:12:28 -07:00
NightFox a2c6e3b444 Add cs_assault.rad 2023-05-05 15:12:28 -07:00
NightFox 596d35ddfa update rad files 2023-05-05 15:12:28 -07:00
NightFox b49dca536d Rename c1a3b.bsp.patch to c1a3b-dayone.bsp.patch 2023-05-05 15:12:28 -07:00
NightFox d2f45c53a0 Rename c1a3c.bsp.patch to c1a3c-dayone.bsp.patch 2023-05-05 15:12:28 -07:00
NightFox 48f9813edd update patches 2023-05-05 15:12:28 -07:00
Ivan Avdeev babfbb08ab vk: improve mvp matrix handling a bit 2023-05-04 11:10:22 -07:00
Ivan Avdeev 4f43b316a6 rt: material: print fauly lines on unknown keys 2023-05-04 11:10:22 -07:00
Ivan Avdeev 481aa651c6 vk: refactor passing m,v,p matrices around
View and projection now set only once in a logical place.
Model matrix is now closely associated with its model, and not stored as
a global state.
2023-05-04 11:10:22 -07:00
Ivan Avdeev 0b6ef9fd65 vk: remove a couple unused things from vk_render draw structs 2023-05-04 11:10:22 -07:00
Ivan 'provod' Avdeev 58433a2221 rt: only load textures for potentially usable materials
Skip loading textures for materials which are not going to be used.
2023-05-04 11:10:22 -07:00
Ivan 'provod' Avdeev 1cfb183cbd rt: extract per-model data from kusochki 2023-05-01 17:03:22 -07:00
Ivan Avdeev 0d8a7f76f5
Merge pull request #529 from w23/E260
- [x] Improves #528 a bit
- [x] Fixes #523 
  - [x] Fix ![image](https://user-images.githubusercontent.com/321361/235242886-bbae06cf-4375-4e11-bae0-8bc4e7644d59.png)
  - [ ] ~верни зеркало! ![image](https://user-images.githubusercontent.com/321361/235250971-6652e2b2-e531-4b41-b603-1c50306b7ea3.png)~
  - [x] test_brush2 лесенки пропали на растеризации
2023-05-01 10:45:31 -07:00
Ivan Avdeev 54d909b715 vk: make sure blending is the same as for gl for brush models
Essentially just copy R_SetRenderMode() logic to vk_brush
2023-05-01 10:27:30 -07:00
Alibek Omarov 12dbfb467a ref: vk: studio: port optimized R_LightLambert function 2023-04-29 22:57:02 +03:00
Ivan Avdeev b93ef2e52c vk: fix freeing NULL bmodel memory 2023-04-28 13:29:02 -07:00
Ivan 'provod' Avdeev e1d250e8da vk: split geometries into static and animated
Load geometries only once, and then update only those which have animated textures.

Fixes #523
2023-04-28 12:35:48 -07:00
Ivan 'provod' Avdeev f722f38617 vk: infotool: mark ent index as dynamic 2023-04-28 11:31:41 -07:00
Ivan 'provod' Avdeev 52f99ec329 rt: only upload kusochki when needed
- Once at load
- When color/mode/prevxform changed

Breaks animated textures.
#523
2023-04-28 11:19:57 -07:00
Ivan Avdeev b17c00654b vk: silence a couple NOT IMPLEMENTED messages
- We're not going to implement R_ShowTextures for ref_vk, at least in
  its gl form.
- It seems that Mod_GetCurrentVis() can just return NULL, at least
  ref_soft does it.

Fixes #269, fixes #254
2023-04-28 10:32:01 -07:00
Ivan Avdeev 3447dfc5d6 rt: linearize alpha value for blending
This makes transparent brushes look more correct. But also makes sprites
look a bit dull.

Fixes #528
2023-04-28 10:12:15 -07:00
Alibek Omarov 62590dd2a9 ref: vk: use safe string functions, as unsafe versions were removed from libpublic 2023-04-28 17:43:50 +03:00
Alibek Omarov e5e2a63ba2 ref: vk: fix matrix4x4_identity to m_matrix4x4_identity which conflicts in Vita port 2023-04-28 17:43:01 +03:00
Alibek Omarov a117338435 ref: vk: port to RefAPI 4 2023-04-28 17:34:05 +03:00
Alibek Omarov c4757058e1 Merge upstream master 2023-04-28 17:15:31 +03:00