Commit Graph

7537 Commits

Author SHA1 Message Date
BlueCube3310 76c8211653 Image: Add a method for detecting signed values 2024-08-27 09:23:17 +02:00
Haoyu Qiu 8bf4ecc026 Add `String.is_valid_unicode_identifier()`
- Adds `is_valid_unicode_identifier()`
- Adds `is_valid_ascii_identifier()`
- Deprecates `is_valid_identifier()`
- Renames `validate_identifier()` to `validate_ascii_identifier()`
2024-08-27 11:34:08 +08:00
Rémi Verschelde 2e825c7d9c
Merge pull request #93141 from RadiantUwU/add_static_classdb_calls
Implement `ClassDB::class_call_static_method`
2024-08-26 23:28:36 +02:00
Rémi Verschelde c7702b350a
Merge pull request #92548 from AThousandShips/string_cleaning
[Core] Optimize some `String` methods
2024-08-26 23:28:24 +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 8019cdb444
Merge pull request #94137 from Craig-Stoneham/master
Improve template class conditionals with constexpr (code style)
2024-08-26 22:45:17 +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 0f16336be0
Merge pull request #93526 from m4gr3d/add_apksigner_util
[Android Editor] Add support for exporting platform binaries
2024-08-26 22:45:09 +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
Rémi Verschelde 8dad1ba482
Merge pull request #92933 from TokageItLab/match-concatenating
Match the coding style for concatenating String
2024-08-26 22:44:59 +02:00
Fredia Huya-Kouadio 794ea99240 Update the storage access handler logic to support accessing / retrieving contents with the `assets:/` prefix 2024-08-26 11:16:37 -07:00
Pedro J. Estébanez 9cbc3f1419 Change warning muting so it affects all levels, but locally 2024-08-26 13:13:29 +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 04f6321ecc
Merge pull request #91166 from raulsntos/gdextension/loader
GDExtension: Implement `GDExtensionLoader` concept
2024-08-26 10:51:21 +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
Craig-Stoneham 604df4fc83 Improve Template Class Conditionals (Code Style)
Refactored the following template classes by replacing runtime checks with compile-time checks using if constexpr for improved code clarity and maintainability:

- RID_Alloc
- SortArray
- PagedAllocator

Changes made:

- Updated conditional checks for THREAD_SAFE in the RID_Alloc class.
- Updated conditional checks for Validate in the SortArray class.
- Updated conditional checks for thread_safe in the PagedAllocator class.
2024-08-25 18:10:51 +01:00
Matias N. Goldberg 59d0422dcd Disable extra memory tracking by default
PR #90993 added several debugging utilities.

Among them, advanced memory tracking through the use of custom
allocators and VK_EXT_device_memory_report.

However as issue #95967 reveals, it is dangerous to leave it on by
default because drivers (or even the Vulkan loader) can too easily
accidentally break custom allocators by allocating memory through std
malloc but then request us to deallocate it (or viceversa).

This PR fixes the following problems:
 - Adds --extra-gpu-memory-tracking cmd line argument
 - Adds missing enum entries to
RenderingContextDriverVulkan::VkTrackedObjectType
 - Adds RenderingDevice::get_driver_and_device_memory_report
    - GDScript users can easily check via print(
RenderingServer.get_rendering_device().get_driver_and_device_memory_report()
)
- Uses get_driver_and_device_memory_report on device lost for appending
further info.

Fixes #95967
2024-08-24 20:52:39 -03:00
Radiant 02fc4bbc2a Implement `ClassDB::class_call_static_method` 2024-08-23 02:56:29 +03:00
Raul Santos 4dd6e8eca5
GDExtension: Implement `GDExtensionLoader` concept
- Implements the concept of GDExtension loaders that can be used to customize how GDExtensions are loaded and initialized.
- Moves the parsing of `.gdextension` config files to the new `GDExtensionLibraryLoader`.
- `GDExtensionManager` is now meant to be the main way to load/unload extensions and can optionally take a `GDExtensionLoader`.
- `EditorFileSystem` avoids unloading extensions if the file still exists, this should prevent unloading extensions that are outside the user project.
2024-08-22 05:29:11 +02:00
Rémi Verschelde 568589c9d8
Merge pull request #90993 from darksylinc/matias-TheForge
Add debug utilities for Vulkan
2024-08-22 00:38:22 +02:00
Rémi Verschelde 39b77ea04e
Merge pull request #95790 from aaronfranke/rect-aabb-support
Simplify Rect2/AABB `get_support` function
2024-08-22 00:10:39 +02:00
Rémi Verschelde 091212b4f1
Merge pull request #93602 from aaronp64/inspector_latency
Improve Editor Inspector/Theme item lookup performance
2024-08-22 00:10:26 +02:00
Matias N. Goldberg 364f916f3f
Add debug utilities for Vulkan
Features:
- Debug-only tracking of objects by type. See
get_driver_allocs_by_object_type et al.
 - Debug-only Breadcrumb info for debugging GPU crashes and device lost
 - Performance report per frame from get_perf_report
- Some VMA calls had to be modified in order to insert the necessary
memory callbacks

Functionality marked as "debug-only" is only available in debug or dev
builds.

Misc fixes:
 - Early break optimization in RenderingDevice::uniform_set_create

============================

The work was performed by collaboration of TheForge and Google. I am
merely splitting it up into smaller PRs and cleaning it up.
2024-08-21 23:48:08 +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
aaronp64 7593e55527 Improve Editor Inspector/Theme item lookup performance
Changes to reduce the latency between changing node selection in the editor and seeing the new node reflected in the Inspector tab

- Use Vector instead of List for ThemeOwner::get_theme_type_dependencies and related functions
- Use Vector instead of List for ThemeContext::themes, set_themes(), and get_themes()
- Add ClassDB:get_inheritance_chain_nocheck to get all parent/ancestor classes at once, to avoid repeated ClassDB locking overhead
- Update BIND_THEME_ITEM macros and ThemeDB::update_class_instance_items to use provided StringNames for call to ThemeItemSetter, instead of creating a new StringName in each call

These changes reduce the time taken by EditorInspector::update_tree by around 30-35%
2024-08-20 13:39:40 -04:00
Daylily-Zeleen 3d575801ce Allow ClassDB to create a Object without postinitialization for GDExtension. 2024-08-20 20:19:02 +08:00
Stuart Carnie 2d0165574d
Add Metal support for macOS (arm64) and iOS 2024-08-20 12:11:06 +02:00
Rémi Verschelde 6a9ecdcf0c
Merge pull request #91818 from rburing/fti_multimesh
Physics interpolation: `MultiMesh`
2024-08-20 10:01:46 +02:00
Aaron Franke 7db24a9ad5
Simplify and fix Rect2/AABB get_support function 2024-08-19 23:55:31 -07:00
Rémi Verschelde af919a845f
Merge pull request #94683 from kisg/string_name_fix
StringName: Use inline static field definitions
2024-08-19 16:05:16 +02: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
Rémi Verschelde 86212c1fe4
Merge pull request #94666 from RandomShaper/fix_tangled_obj_clear_crash
Avoid potential crash on signal disconnection
2024-08-19 14:33:44 +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
Pedro J. Estébanez 32b7f835d8 Avoid potential crash on signal disconnection 2024-08-19 12:18:04 +02:00
Rémi Verschelde ab2b06b8b1
Merge pull request #95730 from voidedWarranties/fix_reload_scripts_bind
Fix virtual binding for `ScriptLanguageExtension::_reload_scripts`
2024-08-19 12:09:39 +02:00
Rémi Verschelde 4afcbb1c8b
Merge pull request #92546 from AThousandShips/faster_replace
[Core] Optimize `String::replace` methods
2024-08-19 12:08:45 +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
Ricardo Buring 1728f80e7c Fixed Timestep Interpolation: MultiMesh
Adds fixed timestep interpolation to multimeshes.

Co-authored-by: lawnjelly <lawnjelly@gmail.com>
2024-08-18 17:14:59 +02:00
BlueCube3310 394ea653aa Add Betsy to speed up BC6 compression 2024-08-18 11:14:05 +02:00
voidedWarranties d65ea6fb9c Fix virtual binding for `ScriptLanguageExtension::_reload_scripts` 2024-08-17 21:09:32 -07:00
Rémi Verschelde 49e5fbfbd2
Merge pull request #95184 from jsjtxietian/shader-include-relative
Fix `String::simplify_path` handling of relative paths to parent dir (`../`), fixes relative shader includes
2024-08-17 00:46:11 +02:00
Rémi Verschelde 82adfebcf8
Merge pull request #94799 from m4gr3d/memory_allocation_cleanup_and_optimizations
Android memory cleanup and optimizations
2024-08-16 23:45:39 +02:00
Fredia Huya-Kouadio a57a99f5bc Memory cleanup and optimizations
- Returns an empty list when there's not registered plugins, thus preventing the creation of spurious iterator objects

- Inline `Godot#getRotatedValues(...)` given it only had a single caller. This allows to remove the allocation of a float array on each call and replace it with float variables

- Disable sensor events by default. Sensor events can fired at 10-100s Hz taking cpu and memory resources. Now the use of sensor data is behind a project setting allowing projects that have use of it to enable it, while other projects don't pay the cost for a feature they don't use

- Create a pool of specialized input `Runnable` objects to prevent spurious, unbounded `Runnable` allocations

- Disable showing the boot logo for Android XR projects

- Delete locale references of jni strings
2024-08-16 09:27:41 -07:00
Rémi Verschelde 803dfcc3cb
Merge pull request #95613 from timothyqiu/split-empty
Fix `split_floats` behavior when spaces are used as separators
2024-08-16 14:36:40 +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 1d4303c1fe
Merge pull request #95502 from bruvzg/net_ext_detect
[.NET] Move search in files extension list definition to be after Scene level module init.
2024-08-16 14:35:12 +02:00
Rémi Verschelde 69db19f058
Merge pull request #94826 from Naros/classdb-expose-property-getter-setter
Expose ClassDB methods `get_property_setter` / `get_property_getter`
2024-08-16 14:32:32 +02:00
Rémi Verschelde 6042c66663
Merge pull request #94720 from noidexe/fix-gamepad-triggers
Fix gamepad triggers not working on web exports
2024-08-16 14:32:27 +02:00
Haoyu Qiu f483c3aafa Fix split_floats behavior when spaces are used as separators 2024-08-16 17:30:44 +08: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 f1d6677713
Merge pull request #95469 from bruvzg/cowdata_unref
`CowData` remove hardcoded offset and unused argument from `_unref`.
2024-08-16 10:36:28 +02:00
Rémi Verschelde 886d5865a4
Merge pull request #95291 from BlueCube3310/hdr-optimizations
Optimize .hdr loading and RGB9E5 conversion
2024-08-16 10:35:32 +02:00
Rémi Verschelde a8bbb09bd5
Merge pull request #95143 from TV4Fun/fix_non_windows_library_load
Fix reload of GDExtension libraries in framework package on macOS
2024-08-16 10:35:19 +02:00
Rémi Verschelde 70096c0e6a
Merge pull request #94558 from stuartcarnie/sgc/sprintf_allocations
Reduce allocations in `String::sprintf`
2024-08-16 10:34:28 +02:00
Rémi Verschelde 91bf992168
Merge pull request #94353 from aaronp64/cowdata_insert
Improve `CowData::insert` performance
2024-08-16 10:34:22 +02:00
Rémi Verschelde 27f3dd8d01
Merge pull request #93149 from Malcolmnixon/smoothstep-degenerate-case
Handle the smoothstep degenerate case of empty range
2024-08-16 10:33:58 +02:00
Rémi Verschelde 71ca5aa5ec
Merge pull request #92555 from AThousandShips/insert_improve
[Core] Optimize `String::insert`
2024-08-16 10:33:47 +02:00
Rémi Verschelde e057c49bf7
Merge pull request #92550 from AThousandShips/join_improve
[Core] Optimize `String::join`
2024-08-16 10:33:42 +02:00
Rémi Verschelde 46c6865979
Merge pull request #92391 from rburing/fti_3d
Physics interpolation (3D)
2024-08-16 10:33:37 +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
Malcolm Nixon 23fc704cbc This PR handles the smoothstep degenerate case where the range is empty.
It also updates the documentation to describe positive and negative ranges.

Co-Authored-By: Hugo Locurcio <hugo.locurcio@hugo.pro>
Co-Authored-By: kleonc <9283098+kleonc@users.noreply.github.com>
2024-08-15 19:08:05 -04:00
A Thousand Ships ee19a092d9
[Core] Optimize some `String` methods
Avoids unnecessary COW checks by using pointers directly.
2024-08-15 17:17:11 +02:00
A Thousand Ships e211d08c92
[Core] Optimize `String::join`
Avoid reallocation by pre-computing size
2024-08-15 16:19:07 +02:00
A Thousand Ships 746c6b87eb
[Core] Optimize `String::insert` 2024-08-15 16:18:47 +02:00
A Thousand Ships cbaec62b03
[Core] Optimize `String::replace` methods
Performs a single allocation, only when any instances are found, and
avoids concatenations and other unnecessary conversions.
2024-08-15 16:15:58 +02:00
Haoyu Qiu 7343dc3a5d Split TranslationServer into its own file 2024-08-15 15:00:47 +08:00
Lisandro Lorea 9dd372f316 Fix gamepad triggers not working on web exports
Fixes #81758

DisplayServerWeb::process_joypads handles buttons 6 and 7 of the
HTML5 Standard Gamepad as a special case by doing:
`input->joy_axis(idx, (JoyAxis)b, s_btns[b]);`

This doesn't work because there is no JoyAxis 6 or 7 in the enum

To fix this we use JoyAxis::TRIGGER_LEFT and TRIGGER_RIGHT for button 6
and 7

However since we are now lying to input->joy_axis we also need to lie in
the mappings for the standard gamepad in godotcontrollersdb.txt,
otherwise input->joy_axis will try to find a mapping to axis 4(LT) and
axis 5(RT) that's not defined.

Therefore we set lefttrigger to +a4 and righttrigger to +a5 in the
mapping, to match what we are actually sending.

A cleaner, and more involved fix to this would be modifying
input->joy_button so that it can handle analog buttons and map them to
axes preserving their value instead of converting to boolean
2024-08-14 16:13:16 -03:00
Summersay415 6df3621b47 Return error when no ResourceFormatLoader found. 2024-08-14 11:45:23 +07:00
bruvzg 69d52ed081
[.NET] Move search in files extension list definition to be after Scene level module init. 2024-08-14 00:16:09 +03: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
bruvzg 273ba27c2f
`CowData` remove hardcoded offset and unused argument from `_unref`. 2024-08-13 08:53:45 +03:00
BlueCube3310 80cf6cbfe9 Optimize .hdr loading and RGB9E5 conversion 2024-08-09 22:39:30 +02:00
Sai Nane e6a7c63125 binder_common: Fix uninitialized marshalling
C# uses `long`s to access many native values. With `PtrToArg<m_enum>` and
`PtrToArg<bitfield<m_enum>>` this isn't a problem, as C++ code converts
through a `*(int64_t*)` cast in assignment, so all 64-bits are initialized.

However, with `PtrToArg<char32_t>`, value assignment happens through an
`*(int *)` cast, leaving 32 bits uninitialized where `int` is 32 bits. On
platforms where `int` is 16 bits, there are presumably 48 bits uninitialized,
though there are very few platforms where this is still the case.

The easiest way to see the practical effects of this is by looking at
`EventInputKey.Unicode`:

```csharp
    public override void _Input(InputEvent @event) {
        if (@event is InputEventKey keyEvent) {
            if (keyEvent.IsPressed() && !keyEvent.Echo) {
                var raw = keyEvent.Unicode;
                var value = raw & 0xffffffff;
                GD.Print($"Key pressed: raw: {raw}; masked: {(char) value} ({value})");
            }
        }
    }
```

Pressing 'a' emits the following line:
```
Key pressed: raw: -3617008645356650399; masked: a (97)
```

Examining execution flow in gdb shows this conversion going through the
following line:
```
PtrToArg<char32_t>::encode (p_ptr=0x7ffcd5bb4b18, p_val=97 U'a') at ./core/variant/binder_common.h:221
221			*(int *)p_ptr = p_val;
```

Here, `p_val` is still 97, which is the value `InputEventKey.Unicode`
is expected to have. After assignment, `p *(int64_t *)0x7ffcd5bb4b18` displays
`-3617008645356650399`, with only the lower 32 bits being properly assigned,
and is the value we see from C#.

With this patch applied, the above testing `_Input` now prints:
```
Key pressed: raw: 97; masked: a (97)
```

Thank you to blujay1269 for asking about an unexpected value they saw in
`EventInputKey.Unicode`, which prompted this investigation.
2024-08-09 05:15:54 +00:00
Mikael Hermansson 613600fa89 Fix use-after-free in `FileAccess::exists` 2024-08-09 03:33:51 +02:00
aaronp64 6e5175592d Improve ClassDB::_is_parent_class performance
Change ClassDB::_is_parent_class to use ClassInfo::inherits_ptr, instead of looking up each inherited class name.
2024-08-08 13:16:42 -04:00
Joel Croteau f44d6a235f Fix reload of GDExtension libraries in framework package on macos
`GDExtension::open_library` has a check in it to see if the library was loaded
from a temp file, and if it was to restore the original name as that is the one
we actually care about. This check is breaking extension reloading on Mac when
the library path is to a framework folder, as the file inside the framework
will not generally be the same name as the folder.

This check also shouldn't be necessary even on Windows, which is the only
platform that uses `generate_temp_files`, since disposal of the created temp
file is handled within `OS_Windows::open_dynamic_library`, and
`GDExtension::open_library` (which is the only function to call
`open_dynamic_library` with a `p_data` argument) only cares about the original
library file path and has to do extra work to remove the name of the temp file.
Instead, I have removed that check and set `OS_Windows::open_dynamic_library`
to return the name of the original file and not the name of the copy.

This fixes GDExtension reloading on macOS. I do not have a Windows machine
available to test that it still works properly on Windows, so someone should
check that before merging this.
2024-08-08 08:31:49 -06:00
jsjtxietian 6cf9af2817 Fix error when use relative #include in .gdshader / .gdshaderinc file 2024-08-08 11:59:14 +08:00
bruvzg f5bb14dceb
[ResourceLoader] Add check to prevent double free crashes. 2024-08-06 08:31:03 +03:00
kobewi ab4c23583a Add keep_screen_on editor setting 2024-08-02 03:44:29 +02:00
kobewi 0d1c388991 Fix some legacy code 2024-08-01 12:08:14 +02:00
Hilderin 1ed723bd19 Fix global class cache file not present when no class name 2024-07-31 16:57:25 -04:00
Rémi Verschelde 372b3f8437
Merge pull request #94910 from RandomShaper/res_load_unlocked
ResourceLoader: Let resource setup late steps invoke loading in turn
2024-07-31 11:37:41 +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
Alvin Wong c9f4436073
Fix use-after-free in WorkerThreadPool 2024-07-29 14:26:48 +02:00
Chris Cranford 7963e63165 Expose ClassDB methods `get_property_setter` / `get_property_getter` 2024-07-27 00:13:34 -04:00
Rémi Verschelde 13edeb3ee4
Core: Remove unused PoolAllocator 2024-07-26 13:05:51 +02:00
A Thousand Ships 8f3e2c96eb
[Core] Fix `Variant::construct` of `Object`
Variant type was not updated correctly causing leaks in ref-counted
2024-07-25 12:25:29 +02:00
Stuart Carnie 67eb6bed2b
use operator += (char32_t)
This prevents an allocation of a new string for every character.

Additionally, use some static constants for padding and sign characters
2024-07-25 09:17:58 +10:00
Gergely Kis 723878bbab StringName: Use inline static field definitions
Before this change StringName used regular static field
definitions for its mutex, _table, configured and debug_stringname
fields.

Since in the general case the ordering of the static variable and field
initialization and destruction is undefined, it was possible that
the destruction of StringName's static fields happened prior to
the destruction of statically allocated StringName instances.

By changing the static field definitions to inline in string_name.h,
the C++17 standard guarantees the correct initialization and destruction
ordering.
2024-07-24 02:40:36 +02:00
bruvzg 25f78a5eb6
Replace .NET detection code with `ClassDB::class_exists("CSharpScript")`. 2024-07-23 23:46:14 +03: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
Rémi Verschelde 0918fd2a21
Merge pull request #94452 from jamie-pate/fix_73374
Fix game window stops responding when debugger pauses
2024-07-17 15:45:14 +02:00
Rémi Verschelde 31f696cf03
Merge pull request #94373 from maiself/fix-library-path-as-abs
Fix to restore `library_path` as absolute path
2024-07-17 12:24:07 +02:00
Rémi Verschelde 59737bf3f0
Merge pull request #94413 from rburing/fix_action_press_tick
Fix physics tick count in `Input.action_press` and `Input.action_release`
2024-07-17 11:44:31 +02:00
Rémi Verschelde 1d13e95e06
Merge pull request #94307 from Bromeon/feature/bitfield-unsigned-docs
GDExtension docs: Advise bindings to use `uint64_t` for bitfields
2024-07-17 11:43:54 +02:00
Rémi Verschelde ab67408390
Merge pull request #94238 from RandomShaper/ref_is_now_rc
Make errors on `RefCounted.free()` more accurate
2024-07-17 11:43:32 +02:00
Rémi Verschelde 496fd12b17
Merge pull request #94052 from m4gr3d/clean_input_dispatch_settings
Cleanup Android input on render thread settings
2024-07-17 11:42:52 +02:00
Alvin Wong 4091abd727 Respect integrated GPU preference in Windows Settings 2024-07-16 23:46:37 +08: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
Ricardo Buring b41ec93d63 Fix physics tick count in Input.action_press and Input.action_release
The physics tick count was not yet updated there.
2024-07-16 00:31:44 +02:00
Jan Haller b2a9ea6d22 GDExtension docs: advise bindings to use uint64_t for bitfields 2024-07-15 22:37:33 +02:00
aaronp64 c1afe7dcdf Improve CowData::insert performance
Update CowData::insert to call ptrw() before loop, to avoid calling _copy_on_write for each item in the array, as well as repeated index checks in set and get.  For larger Vectors/Arrays, this makes inserts around 10x faster for ints, 3x faster for Strings, and 2x faster for Variants.  Less of an impact on smaller Vectors/Arrays, as a larger percentage of the time is spent allocating.
2024-07-15 14:01:19 -04:00
Pedro J. Estébanez 10b543f8a7 WorkerThreadPool: Fix wrong sync logic breaking task map integrity 2024-07-15 12:15:25 +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
Pedro J. Estébanez 76bfe8e0fd Make errors on RefCounted.free() more accurate 2024-07-15 08:51:42 +02:00
Mai Lavelle 16eea2c837
Fix to restore `library_path` as absolute path 2024-07-14 20:37:38 -04:00
Rémi Verschelde fe5d567917
Merge pull request #93942 from MikeSchulze/73525
Fix GDScript analyzer error when instantiating EditorPlugins.
2024-07-11 09:41:09 +02:00
Rémi Verschelde 34d4c9197d
Merge pull request #94133 from akien-mga/fix-gcc14-Wmaybe-uninitialized
Fix a couple GCC 14 `-Wmaybe-uninitialized` warnings
2024-07-11 00:27:32 +02:00
Jamie Pate b18e1e0dcd Fix Game window stops responding when debugger pauses
Fixes #73374

As of godot 4 On windows/osx the game window will be frozen and will not
be updated.

In the debugger loop it calls

OS::get_singleton()->process_and_drop_events();
which allows windows/osx to handle system events. If the window doesn't
handle these events then both systems will judge the window to be 'not
responding' (osx beachball cursor)

When the event processing code was migrated from OS to DisplayServer the
process_and_drop_events() logic was moved to DisplayServer, but the call
inside the remote debugger pause loop was not updated to call the
DisplayServer version, there are currently no implementations of
OS::process_and_drop_events() so i removed it and switched to the new
DisplayServer::force_process_and_drop_events() method.
2024-07-10 13:38:57 -07:00
baptr 810fcc7431 Fix gdscript analyzer error when instantiating EditorPlugins.
Editor code is not instantiable outside of the editor
(1d14c054a1/core/object/class_db.cpp (L369)).
This is fine for editor plugins and the like, but the GDScript analyzer
balks at it, causing F5 runs to fail: #73525.

Instead, we really just want to know if the type is abstract - so add
a new ClassDB method to check that and nothing else.

Update core/object/class_db.cpp

Apply code review comments

Co-Authored-By: Bryce <1522777+baptr@users.noreply.github.com>
2024-07-10 10:24:57 +02:00
Fredia Huya-Kouadio 5e59819727 Cleanup Android input on render thread settings
Follow up to https://github.com/godotengine/godot/pull/93933
Clean up the set of settings use to control whether Android input should be dispatched on the render thread.

Addresses comments in https://github.com/godotengine/godot/pull/93933#issuecomment-2210437977
2024-07-09 09:15:18 -07:00
Rémi Verschelde 247a481001
Fix a couple GCC 14 `-Wmaybe-uninitialized` warnings 2024-07-09 16:12:22 +02:00
Danil Alexeev 110c4d4067
GDScript: Fix "Mismatched external parser" for autoloads 2024-07-09 16:16:45 +03:00
Rémi Verschelde daba91d8c6
Merge pull request #93897 from akien-mga/vformat-better-error-message
Core: Improve `vformat` error reporting on `sprintf` failure
2024-07-09 00:03:17 +02:00
Rémi Verschelde 8ed9bfdc25
Merge pull request #94089 from dsnopek/gdext-valid-runtime-properties
GDExtension: Fix setting base class properties on a runtime class
2024-07-08 23:53:12 +02:00
David Snopek 91fcdff01e GDExtension: Fix setting base class properties on a runtime class 2024-07-08 12:33:55 -05:00
Rémi Verschelde 3ced38cf28
Merge pull request #94073 from mihe/macos-home-end
Add Home/End to text caret movements on macOS
2024-07-08 19:13:39 +02:00
Mikael Hermansson 085f0cc50a Add Home/End to text caret movements on macOS 2024-07-08 16:08:27 +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
Danil Alexeev 151f34bb80
Core: Remove unused method `_is_gpl_reversed()` 2024-07-08 12:31:09 +03: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
Ricardo Buring 2f8ab4a654 Fixed Timestep Interpolation (3D)
Adds 3D fixed timestep interpolation to the rendering server.
This does not yet include support for multimeshes or particles.

Co-authored-by: lawnjelly <lawnjelly@gmail.com>
2024-07-07 22:15:23 +02:00
Ricardo Buring 23521635d2 Fix physics tick counter
The counter is now incremented at the start of a physics tick rather than at the end.

Co-authored-by: lawnjelly <lawnjelly@gmail.com>
2024-07-07 19:04:05 +02:00
Rémi Verschelde 438382cdc2
Merge pull request #94006 from alvinhochun/log-file-utf8-fix
Fix UTF-8 misintepreted as Latin-1 when logging to file
2024-07-07 12:38:54 +02:00
Rémi Verschelde 5bc5ea898c
Merge pull request #93993 from Chaosus/astargrid2d_update_fix
Add a check to prevent user to call `AStarGrid2D::update` when its not needed
2024-07-07 12:38:44 +02:00
Rémi Verschelde 7197678df2
Merge pull request #91551 from m4rr5/configure_timestamp_query_elements
Add a project setting to configure the maximum number of timestamps.
2024-07-07 12:38:19 +02:00
Alvin Wong 5b3857e5f1 Fix UTF-8 misintepreted as Latin-1 when logging to file 2024-07-07 02:46:41 +08:00
Yuri Rubinsky 453c8753a9 Add a check to prevent user to call `AStarGrid2D::update` when its not needed 2024-07-06 14:59:38 +03:00
Rémi Verschelde 496b7b8482
Core: Improve vformat error reporting on sprintf failure
And fix a few occurrences of formatting errors that led me to this.
2024-07-04 10:54:55 +02:00
Togira ab13513403 Fix RandomPCG::rand_weighted incorrectly returning -1 2024-07-04 02:00:59 +02:00
rune-scape c8b697c64c Remove unused `initialize_ref` 2024-07-03 13:32:50 -07:00
Haoyu Qiu ee9cea521d Fix parsing of `4.` in Expression 2024-07-02 20:53:52 +08:00
lawnjelly 0ed71f3e0c Physics Interpolation - Fix `interpolated_transform_2d`
Uses the skew correct `Transform2D::interpolate_with()` function rather than the bugged 3.x version.
2024-07-02 08:10:55 +01:00
Rémi Verschelde 152d7c1bba
Revert "Make freed object different than null in comparison operators"
This reverts commit 150b50cfcd.

As discussed with the GDScript team, this has some implications which aren't
fully consensual yet, and which we want to revisit.

For now we revert to the 4.2 behavior for the 4.3 release, to avoid breaking
user expectations.
2024-07-01 14:11:43 +02:00
Pedro J. Estébanez f2f9a6b8a1 WorkerThreadPool: Fix wrong pointer used in the case of BinaryMutex 2024-06-28 19:46:55 +02:00
Rémi Verschelde e052a53bb6
Merge pull request #93695 from RandomShaper/res_load_main_th
`ResourceLoader`: Support polling and get-before-complete on the main thread
2024-06-28 14:43:01 +02:00
Rémi Verschelde 6f8b90e412
Merge pull request #93032 from RandomShaper/wtp_antilock
GDScript: Avoid deadlock possibility in multi-threaded load
2024-06-28 14:42:48 +02: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
Rémi Verschelde 6cdd303c68
Merge pull request #93564 from Calinou/project-user-dir-prevent-trailing-periods
Prevent folder names with trailing periods from being used automatically
2024-06-26 18:15:19 +02:00
Rémi Verschelde 0364443d12
Merge pull request #93346 from RandomShaper/gds_cyc_alt
GDScript: Enhance handling of cyclic dependencies
2024-06-26 18:15:16 +02:00
Rémi Verschelde 3d8562d775
Merge pull request #89197 from AThousandShips/arr_typed_fix
[Core] Fix sharing of typed arrays from constructor
2024-06-26 18:15:09 +02:00
Pedro J. Estébanez c1391489e3 GDScript: Enhance handling of cyclic dependencies 2024-06-26 17:44:32 +02:00
Hugo Locurcio 492787b134
Prevent folder names with trailing periods from being used automatically
Folder names ending with one or more `.` characters are not allowed
on Windows, so this would break writing logs, shader cache and other
project-specific files. Trailing periods are now stripped in this case.

On non-Windows platforms, this change still applies in the interest
of portability.
2024-06-26 17:42:47 +02:00
Ibrahn Sahir 607c5ec49f Move MIDI parsing up from ALSA driver to platform independent driver.
Aims for more consistent MIDI support across Windows, MacOS, Linux and
to provide a base for adding MIDI drivers for other platforms.
Reworks the MIDIDriverALSAMidi MIDI parsing implementation as a platform
independent version in MIDIDriver::Parser.
Uses MIDIDriver::Parser to provide running status support in MacOS
MIDIDriverCoreMidi.
Collects connected input names at open, ensuring devices indices reported
in events match names in array returned from get_connected_inputs.

Fixes #77035.
Fixes #79811.

With code review changes by: A Thousand Ships (she/her)
<96648715+AThousandShips@users.noreply.github.com>
2024-06-25 16:46:30 +01:00
Rémi Verschelde 6b281c0c07
Merge pull request #93563 from mihe/nothreads-feature
Add `nothreads` feature tag to signify lack of `THREADS_ENABLED`
2024-06-25 10:08:33 +02:00
Rémi Verschelde b9038501db
Merge pull request #90582 from Repiteo/core/remove-macro-_NO_DISCARD_
Core: Replace `_NO_DISCARD_` macro with `[[nodiscard]]`
2024-06-25 10:01:39 +02:00
Mikael Hermansson 53d3d66f9f Add `nothreads` feature tag to signify lack of `THREADS_ENABLED` 2024-06-24 19:52:21 +02:00
Rémi Verschelde f11e8d033d
Remove editor pseudolocalization debug feature
We've seen multiple users enable it by mistake and get utterly confused,
reporting as a bug that the interface text is garbled.

On the other hand we haven't really seen much use of the feature by editor
UI developers, so we can likely simply remove it.

If there's a need eventually, we can re-add it as a command line option
(which is also better than an editor setting as one would typically want
to toggle it during development).
2024-06-24 17:08:26 +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
Pedro J. Estébanez 884d1da938 ResourceLoader: Fix handling of uncached loads
- `CACHE_MODE_IGNORE_DEEP` is checked in addition to `CACHE_MODE_IGNORE` to determine if a load is uncached. This avoids crashes in uncached loads due to prematurely freed load tasks.
- Cached load tasks are isolated (not registered in the task map ever). This avoids regular loads from reusing in-flight cached loads, which is not correct.
2024-06-24 11:25:57 +02:00
Raul Santos 175e5bcf4e
Lookup method also in base scripts of a PlaceHolderScriptInstance 2024-06-22 08:11:48 +02:00
Rémi Verschelde c53a4a7f64
Merge pull request #90069 from KoBeWi/file_suicide_prevention_measures
Don't allow copying file into its own path
2024-06-21 16:49:26 +02:00
Rémi Verschelde 74f9f12c71
Merge pull request #92320 from Hilderin/fix-importing-assets-with-csv
Fix reimporting assets with csv in the project
2024-06-21 13:54:35 +02:00
Pedro J. Estébanez 03d14e436b WorkerThreadPool: Refactor deadlock prevention collaboration into a generic mechanism
This is strictly beyond a refactor because it also changes when the mutexes are relocked,
but that's only for extra safety.
2024-06-19 14:01:54 +02:00
Rémi Verschelde 19bf77f666
Merge pull request #91382 from adamscott/sample-player
Add sample playback support
2024-06-19 07:59:07 +02:00
bruvzg dd883bebd4
Improve PR plural translation rules handling. 2024-06-18 19:04:00 +03:00
Rémi Verschelde 0a83e7c5da
Merge pull request #93288 from rune-scape/gdextension-const-stringname-weird
Object: Use const correct `GDExtensionConstStringNamePtr`
2024-06-18 17:59:25 +02:00
Rémi Verschelde a492b32ed0
Merge pull request #93281 from TitanNano/jovan/fix_get_frame_data
Make `profiling_get_frame_data` call the correct GDVIRTUAL method
2024-06-18 17:59:22 +02:00
Adam Scott 52fa4f05f3
Add samples playback support 2024-06-18 11:06:31 -04:00
Rémi Verschelde 470cc59706
Merge pull request #93293 from rune-scape/cleanup-order
Fix cleanup order in `unregister_core_types()`
2024-06-18 14:09:04 +02:00
rune-scape 818fb63f03 fixed cleanup order in `unregister_core_types()` 2024-06-18 00:44:01 -07:00
rune-scape ca916a536a Object: use correct GDExtensionConstStringNamePtr 2024-06-17 19:06:40 -07:00
Jovan Gerodetti 21586da50e Make profiling_get_frame_data call the correct GDVIRTUAL method. 2024-06-18 00:53:25 +02:00
Fabio Alessandrelli ae7045f67e [Crypto] Expose OS.get_entropy 2024-06-17 12:02:37 +02:00
Rémi Verschelde c3336aa110
Merge pull request #93178 from Faless/crypto/expose_tls_options_getters
[Crypto] Expose TLSOptions getters
2024-06-17 10:58:51 +02:00
Fabio Alessandrelli 3639c1f0ca [Crypto] Expose TLSOptions getters 2024-06-14 22:33:10 +02:00
Fabio Alessandrelli 33d0e1c50c [Crypto] Expose get_system_ca_certificates. 2024-06-14 22:27:03 +02:00
Rémi Verschelde 087ef4b942
Merge pull request #93124 from RandomShaper/skull_trio
`ResourceLoader`: Let the caller thread use its own message queue override
2024-06-14 17:13:38 +02:00
Rémi Verschelde 75eb8ad510
Merge pull request #93091 from RandomShaper/remove_false_safety
Remove no longer needed thread safety measures
2024-06-14 17:13:31 +02:00
Rémi Verschelde 08a21fda8d
Merge pull request #93082 from RandomShaper/fix_err_deadlock
ResourceLoader: Avoid deadlock when awaiting a loader thread that failed early
2024-06-14 17:13:28 +02:00
Pedro J. Estébanez cc6f5d1a7a ResourceLoader: Let the caller thread use its own message queue override 2024-06-13 10:31:11 +02:00
Pedro J. Estébanez 21c03d1956 WorkerThreadPool: Fix thread message queue not restored after overridden in a task
Also, simplifies the thread override teardown in MessageQueue.
2024-06-13 10:31:08 +02:00
bruvzg e651421905
[TextServer, GDExtension] Fix building text servers as GDExtension, expose new/changed low-level methods to GDExtension API. 2024-06-12 19:30:19 +03:00
Pedro J. Estébanez b6994a414d Remove no longer needed thread safety measures
This is basically a revertion of commit 84b85d894c.
2024-06-12 18:10:11 +02:00
Pedro J. Estébanez bdcceef0e2 ResourceLoader: Avoid deadlock when awaiting a loader thread that failed early 2024-06-12 13:49:37 +02:00
Rémi Verschelde 5bab95a556
Merge pull request #92827 from raulsntos/core/node-to_string
Use GDExtension `to_string` in Node
2024-06-12 10:00:29 +02:00
Hilderin f1099ab943 Fix reimporting assets with csv in the project 2024-06-11 17:04:15 -04:00
Raul Santos 29bf60cc02
Use GDExtension `to_string` in Node
Matches the `Object::to_string` implementation.
2024-06-11 17:40:51 +02:00
Rémi Verschelde 4629845ead
Merge pull request #92718 from jsjtxietian/importer-duplicate
Fix same importer will be added multiple times in `get_importers_for_extension`
2024-06-11 11:51:06 +02:00
Rémi Verschelde e4fa8543ea
Revert "Fix FileSystem dock won't show any file folders"
This reverts commit 72856d633a.

Fixes #93022.
2024-06-11 11:46:35 +02:00
Rémi Verschelde 94929439b6
Revert "Fix method name for custom callable"
This reverts commit e88095ed8f.

Fixes #92695.
2024-06-11 11:02:03 +02:00
Rémi Verschelde 0a9f2d2262
Merge pull request #92650 from Hilderin/fix-fileSystem-dock-wont-show-any-file-folders
Fix FileSystem dock won't show any file folders
2024-06-11 10:48:46 +02:00
Hilderin 72856d633a Fix FileSystem dock won't show any file folders 2024-06-10 19:54:37 -04:00
Chris Cranford 8577340501 Expose several EngineDebugger methods and signals as plugin callbacks 2024-06-10 19:46:23 -04:00
Silc Lizard (Tokage) Renew 12571a1e95 Match the coding style for concatenating String 2024-06-09 18:35:23 +09:00
bruvzg d8e1ab085a
[Windows] Fix 32-bit MinGW LTO build. 2024-06-04 13:46:03 +03:00