4683 Commits

Author SHA1 Message Date
Kawe Mazidjatari
9eeb0606e7 RTech: fix rare crash in pak listing and unloading debug commands
g_pakGlobals->loadedPakCount counts the total number of paks loaded in the runtime, which can exceed PAK_MAX_LOADED_PAKS, which is the absolute maximum number of live loaded paks. So we would overrun the buffer if we had loaded more than PAK_MAX_LOADED_PAKS (512) paks during the life of the process.

Just go over every pak memory instance and check if it isn't unloaded and then print out its details or perform the unload. We need to go over each slot because we can have a valid handle in slot 4 and slot 480 while having the rest inbetween marked as  PAK_STATUS_FREED.
2025-01-22 13:21:37 +01:00
Kawe Mazidjatari
1766530af1 Common: improve Mat_CrossHair_f() readability
Remove unnecessary indentation level.
2025-01-18 23:21:13 +01:00
Kawe Mazidjatari
2dc28bb742 Common: fix crash when GetMaterialAtCrossHair() returns NULL
We checked on the wrong far, materialGlue->Get() returns the static instance within the class, and since its always offset with 16 bytes, the address would be 0x10 if materialGlue is nullptr so the check would always be satisfied. Check on materialGlue itself now and only get the static instance if its available.
2025-01-18 23:19:28 +01:00
Kawe Mazidjatari
2083bc73fa GFX: add support for cubemap texture arrays
Previously we only supported cube textures, this patch implements support for cube texture arrays.
2025-01-15 14:00:56 +01:00
Kawe Mazidjatari
aa405dc4c3 GFX: improve CreateTexture error by logging the texture GUID as well
Most textures in the retail product do not have debug names. A GUID however is still very useful to have. Log the GUID here too.
The CreateShaderResourceView call already logs the GUID along with the texture debug name.
2025-01-15 13:57:40 +01:00
Kawe Mazidjatari
d3a2fd5238 InputSystem: rename function and corresponding enum
Returns the gamepad type. A confusion was made earlier when this was reverse engineered as this was used to determine the joystick deadzone index. But it is actually the controller type which it uses to index into the deadzone parameters.
2025-01-13 15:54:08 +01:00
Kawe Mazidjatari
d049b2df1c RapidJSON: add aligned memory allocator class
Added, but not implemented yet. We can revisit this in the future and check if its worth using the aligned memory allocator.
2025-01-13 15:52:27 +01:00
Kawe Mazidjatari
de4a3d294c NetworkSystem: provide buffer size to RapidJSON parser
We already know the buffer size, this avoids having to recalculate it in the parser.
2025-01-13 15:51:07 +01:00
Kawe Mazidjatari
9bcbf3187c RapidJSON: use 64bits wide size types
Promote to 64 bits since that is what our target uses.
2025-01-13 15:49:11 +01:00
Kawe Mazidjatari
18f2e27409 Engine: implement support for loading ui_mainmenu.rpak
For future updates, this allows for customizing the main menu to its full extend without modifying larger ui rpak files as we separate all title screen assets and put it into this new pak.
2025-01-09 17:08:47 +01:00
Kawe Mazidjatari
03dd7046a6 Engine: use correct format specifiers for edict_t
edict_t is an u16 and will always be as that is the type it uses in the engine itself.
2025-01-09 17:06:29 +01:00
Kawe Mazidjatari
eee6aed033 Engine: qualify functions as static where possible 2025-01-09 17:05:28 +01:00
Kawe Mazidjatari
ec9fc7d77f RTech: fix return type for 'PakLoadFuncs_s::WaitForAsyncLoad()'
WaitForAsyncLoad() returns a bool; returns false if pak status = PAK_STATUS_ERROR.
2025-01-09 17:03:45 +01:00
Kawe Mazidjatari
6827d1ed02 Tier0: make sure the memalloc singleton initializer is thread safe
Only enter code if the atomic exchange was performed.
2025-01-09 16:56:48 +01:00
Kawe Mazidjatari
716a3efa0c VGui: deprecate old texture streaming debug overlay
Replaced by the new imgui version which offers the ability to explore the real-time list, in commit c2deaaf3e8c50e08776e960934a161845f55addf.
2025-01-08 21:46:18 +01:00
Kawe Mazidjatari
c2deaaf3e8 DebugSurface: implement new texture streaming debug overlay
Implement a new imgui based texture streaming overlay. The old one typically clips out of the screen and cannot be explored.
2025-01-08 21:44:14 +01:00
Kawe Mazidjatari
74d8cdfb26 DebugSurface: don't run ImGui::Begin if we aren't visible
Small optimization.
2025-01-08 21:23:31 +01:00
Kawe Mazidjatari
4d4fb66477 DebugSurface: minor deduplication
Will be called in either of the 2 branches, can be deduplicated.
2025-01-08 20:57:24 +01:00
Kawe Mazidjatari
117e2d77e4 ImguiSystem: purge the surface list on shutdown
Move purging logic to shutdown.
2025-01-08 20:56:06 +01:00
Kawe Mazidjatari
e9a2aea17c ImguiSystem: make getters const
Can be const.
2025-01-08 20:54:25 +01:00
Kawe Mazidjatari
5d000db867 MaterialSystem: fix incorrect vendor constant for AMD graphics hardware
Users have reported that AMD Anti-Lag 2 didn't work. The issue turned out to be the incorrect vendor constant. After this patch the Anti-Lag 2 implementation appears to work perfectly.

This constant is used to check if installed (and currently selected) hardware is of target vendor before making any driver API calls.
2025-01-07 22:04:00 +01:00
Kawe Mazidjatari
1a5a77f9c8 MaterialSystem: only run model texture crediting if we aren't GPU driven
The compute shader already takes care of this. This code updates the STBSP histogram which won't be used if the cvar 'gpu_driven_tex_stream' is set.

Added a check for if 'gpu_driven_tex_stream' is set, and if so, we don't run this code to save on CPU load.
2025-01-07 22:00:29 +01:00
Kawe Mazidjatari
d8326575e5 MaterialSystem: add handle to 'StreamDB_CreditModelTextures()'
Will be used for an optimization in the future.
2025-01-07 21:56:59 +01:00
Kawe Mazidjatari
4a2f5d2aa5 MaterialSystem: reverse virtual function
This is used to check if a model can credit textures for the texture streaming system. It will be used in the future.
2025-01-07 21:56:09 +01:00
Kawe Mazidjatari
68271b9768 MaterialSystem: fix incorrect member variable type
Should be unsigned int 16, not 32. Member gets accessed with uint16 instructions. Structure is now alligned correctly with the engine, and its size also matches now.
2025-01-07 21:54:56 +01:00
Kawe Mazidjatari
e1f0de0089 MaterialSystem: only update STBSP camera if we aren't GPU driven
Only update the stream camera if we aren't GPU driven to save on load in the render thread.

The camera is used to get the correct column from the STBSP file. Though, if we use the GPU feedback driven texture streaming system, it doesn't make sense to burn CPU here since the GPU system doesn't use the camera at all.
2025-01-07 20:27:35 +01:00
Kawe Mazidjatari
164c594486 MaterialSystem: only run world texture crediting if we aren't GPU driven
This code credits textures based on the STBSP column we are in. However, the GPU driven texture streaming system has its own logic for this. Don't run the STBSP world texture crediting code if the GPU driven system is enabled to save on runtime overhead and possible interference.
2025-01-07 11:38:53 +01:00
Kawe Mazidjatari
37e3c8c653 MaterialSystem: correctly define 'CMaterialGlue'
Remove structure packing (not needed), and properly lay it out. The material glue class is a wrapper around the actual material struct, which is what has been seperated out in this path.

The material struct also contains more newly reversed members.
2025-01-07 01:53:01 +01:00
Kawe Mazidjatari
4445edac6d MaterialSystem: add material shader type enum 2025-01-07 00:57:14 +01:00
Kawe Mazidjatari
561fc25c8e MaterialSystem: split off the render parameters 2025-01-07 00:48:20 +01:00
Kawe Mazidjatari
6d4de8c5b7 MaterialSystem: split off remaining texture streaming specific code
This should all be moved to the new file dedicated to texture streaming.
2025-01-07 00:18:50 +01:00
Kawe Mazidjatari
ca7b0d9981 MaterialSystem: reverse engineer more of 'TextureStreamMgr_s'
More member variables reverse engineered.
2025-01-06 19:59:03 +01:00
Kawe Mazidjatari
b1ad2c19b8 RTech: improve StreamDB type name consistency 2025-01-06 19:46:34 +01:00
Kawe Mazidjatari
3cbdab512d RenderSystem: reverse engineer more of 'TextureAsset_s'
Reversed the last used frame (last time the texture was accumulated), and the last time the texture was credited. Also reversed the actual histogram bin fields; in Apex Legends there is a new one for the GPU driven texture streaming system.
2025-01-06 17:09:14 +01:00
Kawe Mazidjatari
b617caf1d8 MaterialSystem: add histogram bin count define
Will be used in the future.
2025-01-06 17:06:59 +01:00
Kawe Mazidjatari
538df8e02c RTech: enforce member name consistency 2025-01-06 16:57:07 +01:00
Kawe Mazidjatari
05f37cad73 RTech: move forward delcarations out of public headers
These are only used by the runtime's global state.
2025-01-06 16:43:21 +01:00
Kawe Mazidjatari
e6c7c7d279 RenderSystem: enforce type and type name consistency
Use same types used by the game in either the public presentations or binary code. And enforce type name consistency.
2025-01-06 16:41:25 +01:00
Kawe Mazidjatari
62d0dab7cd GFX: add support for creating cubemap textures
Later versions of the game store their cube maps in the RPak as DDS textures now, the engine needs a modification to its texture creation code to support these.
2025-01-06 16:35:36 +01:00
Kawe Mazidjatari
746660490b MaterialSystem: add more reversed types for texture streaming
Reverse engineered.
2025-01-06 16:26:23 +01:00
Kawe Mazidjatari
059f9fc82d RTech: move and rename texture streaming global state struct
More correct names.
2025-01-06 00:53:54 +01:00
Kawe Mazidjatari
aefebd846e MaterialSystem: decouple texture streaming code 2025-01-06 00:44:23 +01:00
Kawe Mazidjatari
aba1ed26b5 RTech: map more fields out for StreamDB_s
More fields reverse engineered.
2025-01-06 00:39:59 +01:00
Kawe Mazidjatari
48e79faffa RTech: search for pattern again
The extra runtime overhead this creates is negligible as all patterns will be searched once, and have their results being cached off. Due to a planned future change, we can't extern it anymore.
2025-01-06 00:37:00 +01:00
Kawe Mazidjatari
49d1f6f1fe RTech: remove unused define
As of commit 3b44bbc6bc8cf26136c5bf6db05a84907f74e089, no longer used.
2025-01-04 17:41:11 +01:00
Kawe Mazidjatari
3b44bbc6bc MaterialSystem: remove the need for a dummy STBSP file
As of commit 5e0c24ad8437a02c1c62325d1d0e5f39e6684f90, the dummy file is no longer necessary.
2025-01-04 17:40:43 +01:00
Kawe Mazidjatari
bd9beaa33a Resource: improve assembly code formatting
Don't use byte opcodes, and suffix hexadecimal values with 'h'.
2025-01-03 22:36:31 +01:00
Kawe Mazidjatari
5e0c24ad84 Resource: patch out forced texture streaming disable code
If we do not have resident pages, then we can still rely on the GPU driven texture streaming system. However, this code forces the mode to TSM_OPMODE_LEGACY_PICMIP. This is a bug because it contradicts the ability to switch between the dynamic and static systems. Patched the jump from a conditional one to an unconditional one to always skip over this broken code.

This also ultimately drops the need for having a dummy STBSP file, and the benefit of not having a dummy STBSP file is that 'hasResidentPages' will be false, which disables the STBSP world texture crediting code, reducing frame times.
2025-01-03 22:32:37 +01:00
Kawe Mazidjatari
36d2b3534a MaterialSystem: properly switch between static and dynamic texture streaming systems
The engine has a bug where it would use GPU feedback even when a static precomputed texture streaming database file exists. If we have an STBSP file for the given level or override, load that in and disable GPU feedback so proper use of the static file could be made. Else we load gpu_driven.stbsp which is a dummy to enable the dynamic, GPU based texture streaming system.
2025-01-03 15:19:48 +01:00
Kawe Mazidjatari
d20488c919 RTech: add constant for GPU driven texure streaming database file
This is a dummy file which enables the GPU driven texture streaming system, which loads/drops textures based on GPU feedback rather than a static texture streaming database file.
2025-01-03 15:15:36 +01:00