Commit Graph

720 Commits

Author SHA1 Message Date
Ivan Avdeev 7417cfa06f vk: rt: try to clear denoiser statistics on frame discontinuities
Somehow doesn't fix the teleport/levelchange glitches, but still feels
like a step in the right direction.
2023-11-30 10:27:47 -05:00
Ivan Avdeev 73d320f51f vk: print how long it took to make a screenshot 2023-11-30 10:26:52 -05:00
Ivan Avdeev d5f8b593f9 vk: make rendermode patching a bit less ugly 2023-11-30 10:20:47 -05:00
NightFox 36a6e56ee1
Update rad files
add c2a1, c2a1a, c2a1b
2023-11-30 15:37:22 +03:00
Ivan Avdeev dd21e665b1 vk: patch rendermode for entities
Probably not the best way to do it, but this is an attempt.

Issue #663
2023-11-28 13:01:14 -05:00
Ivan Avdeev 735260a3c5 vk: brush: fixup per-model material mapping
fixes #669
2023-11-27 13:20:06 -05:00
Ivan Avdeev bbd96b3e0e vk: consolidate all bindings to the top of shaders
That way it is more clear what we declare, why and how.
2023-11-23 12:25:24 -05:00
Ivan Avdeev 016cdeaa6c vk: tools: speedup imagecompare 16x
Use -O3 -march=native
Save into tga, not png
2023-11-21 12:50:29 -05:00
Ivan Avdeev 2fbe477dd2 vk: renderscript: add arguments 2023-11-21 12:11:01 -05:00
Ivan Avdeev 2139b32f75 vk: rt: allow disabling temporal denoiser 2023-11-21 12:10:14 -05:00
Ivan Avdeev 036379707d vk: imagecompare: highlight with green the desired zero-difference image 2023-11-21 11:01:39 -05:00
Ivan Avdeev f11461772a vk: add rt_debug_fixed_random_seed cvar
Needed to pin random seed to a known value to make sure that frames are
reproducible for regression testing purposes.
2023-11-21 11:00:45 -05:00
Ivan Avdeev 4897f97726 vk: add rendertest maker script 2023-11-21 10:45:25 -05:00
Ivan Avdeev 1ac00a8792 vk: imagecompare: highlight total difference > 1% 2023-11-21 10:43:39 -05:00
Ivan Avdeev 27ed4b157a vk: rt: fixup `rt_debug_display_only lighting` 2023-11-21 10:27:58 -05:00
Ivan Avdeev 9953a47397 vk: add example rendertest script 2023-11-20 13:04:48 -05:00
Ivan Avdeev 4897da4f45 vk: document frame comparison effort 2023-11-20 13:02:21 -05:00
Ivan Avdeev 17267fd8c3 vk: tools: add imagecompare tool to compare screenshots
Produces diff image file and total difference.
2023-11-20 12:59:32 -05:00
NightFox 5a3912dcb0
update c2a5.patch
more smooth
2023-11-20 16:30:21 +03:00
NightFox 7e3e847b43
update patches
fix wagonchik texture coordinates and more correct textures/materials
other minor changes (I'd already forgotten)
2023-11-20 00:36:31 +03:00
NightFox acc103221a
add ba_security2.patch 2023-11-20 00:32:34 +03:00
NightFox e67232e4bf
update c1a0c.rad
fix ~LIGHT3F for c1a0c
2023-11-20 00:23:13 +03:00
Ivan Avdeev 16de17527a vk: document regression testing approaches
ref: #646
2023-11-17 12:29:53 -05:00
Ivan Avdeev f0b80887e8 vk: brush: support normalmaps for water surfaces
Adds missing tangents.

Fixes #655
2023-11-17 11:06:09 -05:00
Ivan Avdeev de80c0da64 vk: comment on no light under emissive acid
ref: #56
2023-11-17 10:22:53 -05:00
Ivan Avdeev 7d8d59d338
Merge pull request #653 from 0x4E69676874466F78/vulkan
Update patches&rads
2023-11-17 07:08:39 -08:00
NightFox 174d601ba6
add c1a4g.rad 2023-11-17 13:08:34 +03:00
Ivan Avdeev 9b18ffbc02 vk: update todo 2023-11-16 13:05:28 -05:00
Ivan Avdeev 85fbe15f65 vk: make conveyors move again
Known issues: validation-induced crash on changlevel

fixes #465
2023-11-16 13:00:00 -05:00
NightFox 8858433928
Update c0a0d.rad
temporary tune !TOXICGRN, !TOXICGRN2
2023-11-16 19:54:51 +03:00
NightFox c23404cfa1
Update patches
c0a0d: more smooth geometry
2023-11-16 19:53:26 +03:00
Ivan Avdeev 4def45125c vk: add `trihash` to `rt_debug_display_only` cvar 2023-11-16 10:55:05 -05:00
Ivan Avdeev dc1ea9cb44 vk: shaders: normalize noise.glsl indentation 2023-11-16 10:54:21 -05:00
Ivan Avdeev b21a8240ec vk: update todo 2023-11-16 10:43:51 -05:00
Ivan Avdeev f535020f94 vk: update emissive color for water surfaces
In a not super efficient way: it will re-upload kusochki every time,
even though there has been no update.
2023-11-16 10:35:07 -05:00
Ivan Avdeev e4d7858330 vk: add emissive water surfaces to polygon lights
Makes acid water surfaces emissive again.
However, they are not assinged proper emissive color values for direct
ray hits yet, so they do emit light, but look dar still.

Ref: #56
2023-11-16 09:56:21 -05:00
Ivan Avdeev a3c52a8001 vk: hide "back" water surfaces
Only leave water surfaces directed towards "air".
This is consistent with:
- non-`kRenderNormal` surfaces, for which there's only one surface present
- opt2 for translucent surfaces, where we aim to detect medium boundary
  direction based on normal-vs-ray-direction

Also add notes about translucent surfaces in general, more info about
water rendering under ref_gl, etc.

Fixes #264
2023-11-14 11:44:29 -05:00
Ivan Avdeev 78548960e7 vk: improve culling; add notes about water and culling
Cull everything except:
- opaque geometry: to avoid shadow and reflection holes
- bleded geometry: particles and such should be visible from any angle

Alpha-tested geometries result in visual glitches when not culled
(double-sided ladders, double shadows, etc). These glitches are worse
than slightly misaligned shadows.

Translucent geometries are still matter of research.
2023-11-13 12:22:23 -05:00
Ivan Avdeev d802404d1c vk: brush: investigate water surfaces orientation
Adds a few things:
- verbose logs about surface flags/type/orientation
- same about surface subdivided polys
- tries culling back water surfaces (doesn't work that well)
- tries culling in rt shaders

This still unfinished
2023-11-10 10:30:24 -05:00
Ivan Avdeev f6c19527d5 vk: brush: hide side water surfaces for entities w/o EF_WATERSIDES
Worldmodel draws all water surfaces regardless of their
orientation/PLANE_Z.

All other entities only draw sides when EF_WATERSIDES effect bit is set.
2023-11-09 12:55:56 -05:00
Ivan Avdeev 4145969198 vk: brush: do not try to invert water height when underwater
Not sure that we need it.
2023-11-09 10:49:53 -05:00
Ivan Avdeev 5c3be09161 vk: brush: force worldmodel alternate_anims textures static
Many static worldmodel surfaces still contain alternate texture chains.
That was making these surfaces dynamic, even though there's no way to
trigger these alternate anims.

Make worldmodel ignore alternate_anims when looking for animated
surfaces.

Fixes #644
2023-11-09 10:32:47 -05:00
NightFox 840d618e4d
Update patches
Minor changes (replacement by _xvk_tex_rotate)
2023-11-09 15:54:12 +03:00
Ivan Avdeev 3e9f6bc7a4 vk: half-fix water levels being too high
Pass current entity to compute wave height. Still doesn't switch to
negative height when underwater for some reason.
And still displays water sides.

Add some notes regarding water geometry generation and drawing.
2023-11-07 13:45:25 -05:00
Ivan Avdeev c575cb6cfd vk: add alternate_anim display to infotool 2023-11-07 13:45:06 -05:00
Ivan Avdeev 2c0e7033ed vk: fix crashing on maps with skybox
We were using a negative value for `SURF_SKY` surfaces, which hit an
assert on uploading kusochki.
2023-11-07 13:30:46 -05:00
Ivan Avdeev c6c58a9842 vk: allow rotating matrices in patches
Adds `_xvk_tex_rotate` field for surface patches. Angle is specified in
degrees.

Note that it rotates the texture around origin, which might be very far
away. So offset patching might be needed to re-align.
2023-11-07 12:03:40 -05:00
Ivan Avdeev 266f57e8a5 vk: make `vk_debug_log` a command, not a cvar
This makes it easily switchable at any point in time.

Still not sure how to properly manage log verbosity cvars:
- cvars are loaded after initialization and map load, so we can't really
  depend on saved cvar values.
- reloading cvars each frame cancels `-vkverboselogs` arg that is
  supposed to work around the above limitation
2023-11-07 11:59:12 -05:00
Ivan Avdeev 9eff6fa907 vk: list supported arguments for `rt_debug_display_only` 2023-11-07 10:32:35 -05:00
Ivan Avdeev a25bf841ac vk: fix bright artifacts coming from unpatched chrome materials
Fixes a typo that rewrote roughness value with garbage.

Also adds a few more debug channel displays for lighting phases. And
prints out available debug displays.

Fixes #641
2023-11-06 12:47:21 -05:00
Ivan Avdeev 4509e2075d vk: fix changing textures on buttons, etc
Detect changes in alternate_anims sequences.

Fixes #640
2023-11-06 11:42:07 -05:00
Ivan Avdeev f8c0baf78d vk: fixup -vkverboselogs, make it actually work 2023-11-06 11:07:58 -05:00
Ivan Avdeev dfcfd786a9 vk: fix material basecolor_map handling
- Do not replace inherited base color texture
- Do not acquire default base color texture

Fixes #638
2023-11-06 10:31:55 -05:00
NightFox fd356e6124
update c1a0c.patch 2023-11-06 00:00:17 +03:00
NightFox 6963c158a4
update c1a0c.patch 2023-11-05 23:43:12 +03:00
NightFox 42dfd56f87
update c1a1c.patch 2023-11-05 20:45:28 +03:00
NightFox 0927e25ce2
update patches
Improvement geometry smoothing (normals)
2023-11-04 19:23:21 +03:00
Ivan Avdeev 6e56c8c78d vk: add -vkverboselogs argument to enable super verbose logs at init 2023-11-03 13:23:10 -04:00
Ivan Avdeev a42e5051b7 vk: cleanup cvar prefixes
Now:
- Not necessarily vulkan-specific cvars are prefixed with `r_`
- Vulkan-specific but not RT-specific things are `vk_`
- RT-specific are `rt_`

Fixes #632
2023-11-03 13:15:11 -04:00
Ivan Avdeev 3a7d047f09 vk: add `surfhash` argument to `rt_debug_display_only`
Allows highlighting all the surfaces with random colors to easily see
the surfaces structure and boundaries.

Fixes #635
2023-11-03 12:05:36 -04:00
Ivan Avdeev 28eec97cbf vk: implement r_lightmap for both traditional and RT renderers
Display lightmap plus lighting for traditional.
Display all collected lights (including bounces and simple transparency)
for RT.

Fixes #634
2023-11-03 11:26:57 -04:00
Ivan Avdeev 0ba85e3f08 vk: add `rt_debug_display_only` cvar
Displays only the specified channel.

Fixes #631
2023-11-03 10:58:13 -04:00
Ivan Avdeev 2a3f48fd50 vk: fix occasional inverted normal maps
When texture coordinates are inverted, it makes tangent look into
oppsite direction, which inverts TBN and therefore normal map.

Make sure the tangent points to a consistent direction.

Fixes #627
2023-11-02 10:58:11 -07:00
Ivan Avdeev dfa240a4db vk: fix weird lines on suit studio model
It was using old pre-transform values for prev_verts, and that was
confusing temporal denoiser.

We should bone-transform vertices first, and only then store them as
prev_verts.

Fixes #585
2023-11-02 10:13:56 -07:00
Ivan Avdeev c869223690 vk: fix compilation after upstream merge 2023-11-02 11:46:30 -04:00
Ivan Avdeev 1f9b489bdc Merge remote-tracking branch 'upstream/master' into vulkan-upstream-merge-20231102 2023-11-02 11:31:59 -04:00
Alibek Omarov e481e1d73e ref: gl: enable GL waves with r_ripple 2023-10-31 21:52:00 +03:00
Alibek Omarov 6c0eed1b2b ref: gl: allow viewing water textures in their full glory with enabled r_ripple 2 2023-10-31 21:52:00 +03:00
Alibek Omarov a6c67fdf9f ref: gl: upload only part of texture we're using, i.e. 64x64 for 64x64, 128x128 for 128x128 2023-10-31 21:52:00 +03:00
Alibek Omarov 46889ed453 ref: gl: libc rand() does better job at randomizing 2023-10-31 21:52:00 +03:00
Alibek Omarov 882fcc152c ref: gl: always scale down texture to 64x64, like sw.dll does 2023-10-31 21:52:00 +03:00
Alibek Omarov a6af32dafd ref: gl: connect ripply water to others parts of renderer (init, reset, animation and rendering) 2023-10-31 21:52:00 +03:00
Alibek Omarov d6dfb83be7 ref: gl: ripply water implementation (bugfixed version from my Quake-2 patches) 2023-10-31 21:52:00 +03:00
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 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
mittorn f2c080e736 gl2shim: fix broken matrix update when fog attribute enabled (32 bit shift overflow) 2023-10-30 22:34:34 +03: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
Alibek Omarov ea55e78855 ref: _inline -> static 2023-10-29 23:38:43 +03:00
NightFox 114015c208 update patches 2023-10-29 11:40:06 -07:00
Alibek Omarov 30d1492b93 engine: remove Set/GetCurrentLoadingModel from RefAPI 2023-10-28 15:22:21 +03: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
mittorn bf5fd40d64 gl2shim: workaround empty rgb5/rgb8 textures 2023-10-26 23:08:02 +03:00
mittorn 6bc613bdb4 ref_gl: force gles2 on non-nanogl until we support gles1 directly 2023-10-26 23:07:39 +03:00
mittorn a982562658 ref_gl: Fix missing DebugOutput functions on GLES 2023-10-26 23:07:22 +03: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
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