Commit Graph

1427 Commits

Author SHA1 Message Date
Rémi Verschelde de7d4b6f5b
Merge pull request #94920 from gongpha/bring-back-print-verbose-when-loading-resources
Fix ResourceLoader is not printing a resource path on loading when `verbose_stdout` is enabled
2024-08-28 00:12:38 +02:00
Kongfa Waroros bfb5570c03 Fix ResourceLoader is not verbosely printing a resource path on loading 2024-08-28 03:37:51 +07:00
Rémi Verschelde 6e3320446a
Merge pull request #92799 from BlueCube3310/image-detech-signed
Image: Add a method for detecting signed values
2024-08-27 22:27:18 +02:00
Sébastien Dunne Fulmer c3ed8a842c
Remove confusing USER prefix from script-logged errors 2024-08-27 15:00:48 +01:00
BlueCube3310 76c8211653 Image: Add a method for detecting signed values 2024-08-27 09:23:17 +02:00
Rémi Verschelde ac5a528620
Merge pull request #84944 from KoBeWi/legacy_of_ancient_godots
Fix some legacy code
2024-08-26 23:28:14 +02:00
Rémi Verschelde ce44c91223
Merge pull request #93739 from AThousandShips/lock_unlock
[Core] Allow locking/unlocking of `MutexLock`
2024-08-26 22:45:13 +02:00
Rémi Verschelde b78da13e2a
Merge pull request #93064 from Hilderin/fix-fileSystem-dock-wont-show-any-file-folders
Fix FileSystem dock won't show any file folders (v2)
2024-08-26 22:45:04 +02:00
A Thousand Ships 723f5500f4
[Core] Allow locking/unlocking of `MutexLock` 2024-08-26 12:38:03 +02:00
Rémi Verschelde 0ba0be27c7
Merge pull request #94169 from RandomShaper/wtp_rl_prize
Batch of fixes for `WorkerThreadPool` and `ResourceLoader`
2024-08-26 10:51:25 +02:00
Rémi Verschelde b4f268fae8
Merge pull request #91018 from Daylily-Zeleen/daylily-zeleen/optionally_postinitialization_for_extension_owner
Allow ClassDB to create a Object without postinitialization for GDExtension.
2024-08-26 10:51:17 +02:00
Pedro J. Estébanez f4d76853b9 WorkerThreadPool (plus friends): Overhaul unlock allowance zones
This fixes a rare but possible deadlock, maybe due to undefined behavior. The new implementation is safer, at the cost of some added boilerplate.
2024-08-21 12:22:52 +02:00
Pedro J. Estébanez df23858488 ResourceLoader: Fix edge cases in the management of user tokens
1. Make handling of user tokens atomic:
   Loads started with the external-facing API used to perform a two-step setup of the user token. Between both, the mutex was unlocked without its reference count having been increased. A non-user-initiated load could therefore destroy the load task when it unreferenced the token.
   Those stages now happen atomically so in the one hand, the described race condition can't happen so the load task life insurance doesn't have a gap anymore and, on the other hand, the ugliness that the call to load could return `ERR_BUSY` if happening while other thread was between both steps is gone.
   The code has been refactored so the user token concerns are still outside the inner load start function, which is agnostic to that for a cleaner implementation.
2. Clear ambiguity between load operations running on `WorkerThreadPool`:
   The two cases are: single-loaded thread directly started by a user pool task and a load started by the system as part of a multi-threaded load.
   Since ensuring all the code dealing with this distinction would make it very complex, and error-prone, a different measure is applied instead: just take one of the cases out of the dicotomy. We now ensure every load happening on a pool thread has been initiated by the system.
   The way of achieving that is that a single-threaded user-started load initiated from a pool thread, is run as another task.
2024-08-21 12:22:52 +02:00
Pedro J. Estébanez 5c970db2e4 ResourceLoader: Optimize remap check by deferring until a non-mutex zone 2024-08-21 12:19:43 +02:00
Pedro J. Estébanez 28619e26cf ResourceLoader: Enhance deadlock prevention
Benefits:
- Simpler code. The main load function is renamed so it's apparent that it's not just a thread entry point anymore.
- Cache and thread modes of the original task are honored. A beautiful consequence of this is that, unlike formerly, re-issued loads can use the resource cache, which makes this mechanism much more performant.
- The newly added getter for caller task id in WorkerThreadPool allows to remove the custom tracking of that in ResourceLoader.
- The check to replace a cached resource and the replacement itself happen atomically. That fixes deadlock prevention leading to multiple resource instances of the same one on disk. As a side effect, it also makes the regular check for replace load mode more robust.
2024-08-21 12:19:43 +02:00
Pedro J. Estébanez bd0959ebdd ResourceLoader: Properly push & pop TLS state on recursive load tasks 2024-08-21 12:19:43 +02:00
Rémi Verschelde 5ca419e32c
Merge pull request #94801 from gamelessone/fix-cond-var
Fix use-after-free of `ConditionVariable` in `ResourceLoader`
2024-08-21 11:14:22 +02:00
Rémi Verschelde 4b8946102b
Merge pull request #91535 from BlueCube3310/betsy-bc6h
Add Betsy to speed up BC6 compression
2024-08-21 06:38:03 +02:00
Hilderin 1b0c5cbc01 Fix FileSystem dock won't show any file folders (v2) 2024-08-20 21:23:13 -04:00
Daylily-Zeleen 3d575801ce Allow ClassDB to create a Object without postinitialization for GDExtension. 2024-08-20 20:19:02 +08:00
Rémi Verschelde 6a829d5a86
Merge pull request #95508 from Summersay415/loaded-when-not
Return error when no ResourceFormatLoader found
2024-08-19 14:34:17 +02:00
Pedro J. Estébanez e9407d4877 ResourceLoader: Revert workaround resource loading crashes due to buggy TLS
This reverts commit 41c0785636.
2024-08-19 12:22:31 +02:00
Rémi Verschelde f4037d6f6c
Merge pull request #92496 from clayjohn/HDR-2D-sRGB
Ensure MovieWriter output is in gamma space when using HDR 2D
2024-08-19 12:08:40 +02:00
BlueCube3310 394ea653aa Add Betsy to speed up BC6 compression 2024-08-18 11:14:05 +02:00
Rémi Verschelde f01e052162
Merge pull request #95549 from timothyqiu/split-translation-server
Split `TranslationServer` into its own file
2024-08-16 14:36:16 +02:00
Rémi Verschelde ae2044dccb
Merge pull request #95477 from RandomShaper/res_load_dev_bugs
ResourceLoader: Use better error handling for possible engine bugs
2024-08-16 10:36:33 +02:00
Rémi Verschelde eb684cccdc
Merge pull request #92291 from BlueCube3310/image-convert-optimized
Optimize image conversion for half and float formats.
2024-08-16 10:33:32 +02:00
Haoyu Qiu 7343dc3a5d Split TranslationServer into its own file 2024-08-15 15:00:47 +08:00
Summersay415 6df3621b47 Return error when no ResourceFormatLoader found. 2024-08-14 11:45:23 +07:00
Pedro J. Estébanez 31a9e10ddb ResourceLoader: Use better error handling for possible engine bugs 2024-08-13 12:52:08 +02:00
Pedro J. Estébanez 17ea4b405a ResourceLoader: Fix error on querying progress for uncached loads 2024-08-13 12:41:11 +02:00
Mikael Hermansson 613600fa89 Fix use-after-free in `FileAccess::exists` 2024-08-09 03:33:51 +02:00
bruvzg f5bb14dceb
[ResourceLoader] Add check to prevent double free crashes. 2024-08-06 08:31:03 +03:00
kobewi 0d1c388991 Fix some legacy code 2024-08-01 12:08:14 +02:00
Aleksey Vasenev 2ff6594928 Fix use condition_variable after free 2024-07-30 13:59:20 +03:00
Pedro J. Estébanez 5640e8adc9 ResourceLoader: Let resource setup late steps invoke loading in turn 2024-07-29 18:13:37 +02:00
BlueCube3310 0ed45629fd Support 64-bit image sizes for VRAM compression 2024-07-21 21:06:14 +02:00
Hugo Locurcio 0445ccf428
Fix Image CowData crash when baking large lightmaps
This switches to 64-bit integers in select locations of the Image
class, so that image resolutions of 16384×16384 (used by
lightmap texture arrays) can be used properly. Values that are larger
should also work.

VRAM compression is also supported, although most VRAM-compressed
formats are limited to individual slices of 16384×16384. WebP
is limited to 16383×16383 due to format limitations.
2024-07-19 16:04:30 +02:00
Rémi Verschelde 293c0f7646
Merge pull request #94526 from RandomShaper/wtp_rl_prize_prequel
Batch of fixes for WorkerThreadPool and ResourceLoader (safe set)
2024-07-19 11:11:03 +02:00
Pedro J. Estébanez 28a7a95531 ResourceLoader: Fix sync issues with error reporting
This is about not letting the resource format loader set the error code directly on the task anymore. Instead, it's stored locally and assigned only when it is right to do so.

Otherwise, other tasks may see an error code in the current one before it's state having transitioned to errored. While this, besides the technically true data race, may not be a problem in practice, it causes surprising situations during debugging as it breaks assumptions.
2024-07-19 10:00:41 +02:00
Fabio Alessandrelli 31454423ba [Core] Fix TypedArray encoding when full objects is disabled 2024-07-18 09:58:17 +02:00
Pedro J. Estébanez 5b5cdf2414 Fixup recent changes to threading concerns
ResourceLoader:
- Fix invalid tokens being returned.
- Remove no longer written `ThreadLoadTask::dependent_path` and the code reading from it.
- Clear deadlock hazard by keeping the mutex unlocked during userland polling.

WorkerThreadPool:
- Include thread call queue override in the thread state reset set, which allows to simplify the code that handled that (imperfectly) in the ResourceLoader.
- Handle the mutex type correctly on entering an allowance zone.

CommandQueueMT:
- Handle the additional possibility of command buffer reallocation that mutex unlock allowance introduces.
2024-07-16 11:03:02 +02:00
Pedro J. Estébanez 62d9ce6445 Re-add resource thread-safety measures
These deferring measures were added to aid threaded resource loading in being safe.

They were removed as seemingly unneeded, but it seems they are needed so resources involved in threaded loading interact with others only after "sync points".
2024-07-15 12:15:22 +02:00
Rémi Verschelde 247a481001
Fix a couple GCC 14 `-Wmaybe-uninitialized` warnings 2024-07-09 16:12:22 +02:00
Pedro J. Estébanez a426479b3f ResourceLoader: Fix error message due to already-awaited tasks being re-awaited 2024-07-08 12:19:44 +02:00
Pedro J. Estébanez f952d3956c ResourceLoader: Fixup management of thread-specific status
- Allows the message queue override to flush after loading each resource, which was the original intent.
- Removes a redundant call to mark the thread as safe-for-nodes.
2024-07-08 10:30:25 +02:00
Alvin Wong 5b3857e5f1 Fix UTF-8 misintepreted as Latin-1 when logging to file 2024-07-07 02:46:41 +08:00
Pedro J. Estébanez ec61c5064c ResourceLoader: Support polling and get-before-complete on the main thread 2024-06-28 11:25:10 +02:00
Pedro J. Estébanez c1391489e3 GDScript: Enhance handling of cyclic dependencies 2024-06-26 17:44:32 +02:00
Rémi Verschelde e78dc83ee8
Merge pull request #93540 from RandomShaper/res_load_uncached
`ResourceLoader`: Fix handling of uncached loads
2024-06-24 13:20:24 +02:00