Commit Graph

285 Commits

Author SHA1 Message Date
Lukas Tenbrink
1b1ab76a14 Add FixedVector template.
This is a high performance `Vector`-like object that can be used if the maximum number of objects is small and known, and the objects are needed only temporarily.
2025-04-30 19:14:08 +02:00
Thaddeus Crews
44d20b2dc6 Merge pull request #100619 from Ivorforce/cowdata-resize-direct
Optimize / refactor `CowData`, combining resize and fork to avoid unnecessary reallocations.
2025-04-28 18:45:54 -05:00
lawnjelly
ae04a3a5dd Physics Interpolation - Move 3D FTI to SceneTree
Moves 3D interpolation from server to the client code (`SceneTree`).
Complete rework of 3D physics interpolation, but using the same user API.
2025-04-26 14:13:30 +01:00
Lukas Tenbrink
d74ef8cb01 Rename LocalVector.invert() -> LocalVector.reverse() to match the Vector, String and List APIs. 2025-04-24 22:36:32 +02:00
Lukas Tenbrink
7c37188ca1 Smoke test: In collections, log an error if reserve() is called with a number smaller than the current size. Don't log an error if it is called with a number smaller than the current capacity. 2025-04-23 16:47:47 +02:00
Thaddeus Crews
2ffd5a3913 Merge pull request #104738 from YYF233333/cleanup_rid_owner
Use `LocalVector` in `RID_Owner::get_owned_list`
2025-04-22 10:44:25 -05:00
Thaddeus Crews
c0e695d5e8 Merge pull request #100944 from Nazarwadim/LocalVector_use_1.5x_growth_factor
Use 1.5x growth factor for LocalVector
2025-04-21 08:24:22 -05:00
Yyf2333
1a70a06a43 Change RID_Owner::get_owned_list. 2025-04-21 01:04:27 +08:00
clayjohn
c6c06a966a Allow chunk validator to wrap around in RID_Alloc so that we do not need to crash once we have made 2^31 allocations 2025-04-18 00:06:53 -07:00
Lukas Tenbrink
015a3b0434 Optimize / refactor CowData, combining resize and fork to avoid unnecessary reallocations. 2025-04-15 17:01:26 +02:00
Thaddeus Crews
addab4f001 Merge pull request #95916 from Repiteo/core/bit-field
Core: Add dedicated `BitField` template
2025-04-11 13:29:13 -05:00
Thaddeus Crews
0d267e7b1e Core: Add dedicated BitField template 2025-04-11 11:53:26 -05:00
Lukas Tenbrink
b711d72e8f Remove unnecessary friend class declarations of CowData.
Use default implementations for various containers.
2025-04-11 18:26:08 +02:00
Thaddeus Crews
94282d88f9 Core: Use Math namespace for constants 2025-04-10 16:29:30 -05:00
Thaddeus Crews
5edb235018 CI: Bump various pre-commit hooks 2025-04-07 08:23:35 -05:00
Thaddeus Crews
207a2b6472 Core: Integrate warning suppression macro helpers 2025-04-03 10:13:46 -05:00
Lukas Tenbrink
ccdc5862e9 Add LocalVector.erase_unordered, mimicking erase but with remove_at_unordered, to remove duplicate logic.
`erase_unordered` should be preferred over `erase` where order is not important, for its performance benefits.

Co-authored-by: smix8 <smix8@users.noreply.github.com>
2025-03-31 13:31:53 +02:00
Rémi Verschelde
afc7398c2b Merge pull request #104616 from ibrahn/init-cmd-q-pending-and-gles3-skymatdata
Fix uninitialized member vars in CommandQueueMT and RasterizerSceneGLES3
2025-03-28 17:30:37 +01:00
Rémi Verschelde
4a31936bc1 Merge pull request #104693 from mihe/local-vector-move
Optimize `LocalVector::push_back` for non-trivial objects
2025-03-28 14:34:49 +01:00
Rémi Verschelde
76c30189fa Merge pull request #103923 from Ivorforce/span-array-init
Add C array constructor to `Span`.
2025-03-28 14:32:14 +01:00
Mikael Hermansson
5c5b9847da Optimize LocalVector::push_back for non-trivial objects 2025-03-27 14:22:30 +01:00
Ibrahn Sahir
c9352f06f7 Fix uninitialised member vars in CommandQueueMT and RasterizerSceneGLES3 2025-03-25 17:19:16 +00:00
Thaddeus Crews
8f16b86d7e Core: Include intrin.h for MSVC 2025-03-24 15:19:49 -05:00
Thaddeus Crews
4c9086312d Merge pull request #103698 from AThousandShips/fix_a_hash_map_construct
[Core] Fix `AHashMap` constructors reserving too few elements
2025-03-23 19:03:59 -05:00
Thaddeus Crews
f09ee0171a Style: Begin integrating simple .clangd fixes 2025-03-22 13:24:35 -05:00
Rémi Verschelde
64bd03269f Merge pull request #104286 from Ivorforce/localvector-find
Harmonize `String`, `Vector` and `LocalVector` `find` and `rfind`.
2025-03-19 12:27:27 +01:00
Lukas Tenbrink
fde71e0382 Harmonize String, Vector and LocalVector find and rfind.
Use `Span::find` for `LocalVector::find`, accepting negative `p_from`.
Return `-1` for invalid `p_from` values in `rfind`.
Accept negative values for `p_from` in `find`, starting from the back.
2025-03-18 12:37:36 +01:00
Thaddeus Crews
4320800621 Core: Expand is_zero_constructible coverage 2025-03-17 11:45:26 -05:00
Lukas Tenbrink
49e860159a Move CowData find, rfind and count to Span. 2025-03-16 03:31:11 +01:00
Lukas Tenbrink
78221946cc Add C array constructor to Span. [skip ci] 2025-03-12 16:48:16 +01:00
Thaddeus Crews
74907876d3 Merge pull request #103759 from Ivorforce/zero-constructible
Optimize `Array.resize` by using `memset` (through new `is_zero_constructible` type trait)
2025-03-12 10:31:55 -05:00
Lukas Tenbrink
75bc471965 Add is_zero_constructible to denote if a type can be semi-trivially constructed with all 0 bytes.
Optimize `CowData` and `LocalVector` resize for zero constructible types.
Mark several compatible types as `is_zero_constructible`.
2025-03-12 09:49:24 +01:00
Lukas Tenbrink
55a7de93c7 Add iteration to Span. 2025-03-11 23:46:25 +01:00
Lukas Tenbrink
f5cb739a18 Add Span conversion to LocalVector. 2025-03-10 22:30:39 +01:00
Thaddeus Crews
a13067e61f Merge pull request #97553 from AThousandShips/semantic_equal
[Core] Add `is_same` to types that have float components
2025-03-10 10:01:05 -05:00
Lukas Tenbrink
605b62cd29 Add Span struct (replacing StrRange). Spans represent read-only access to a contiguous array, resembling std::span. 2025-03-09 18:19:51 +01:00
Thaddeus Crews
324512e11c Style: Replace header guards with #pragma once 2025-03-07 17:33:47 -06:00
A Thousand Ships
fad8134dca [Core] Fix AHashMap constructors reserving too few elements 2025-03-06 15:28:37 +01:00
Pāvels Nadtočajevs
bdb5d522d1 Use atomic flag to prevent flush_if_pending from reading unlocked command_mem. 2025-02-25 23:26:43 +02:00
A Thousand Ships
e825085978 [Core] Add is_same to types that have float components
Compares `NaN` as equal.

Added to:
* `AABB`
* `Basis`
* `Color`
* `Plane`
* `Projection`
* `Quaternion`
* `Rect2`
* `Transform2D`
* `Transform3D`
* `Vector2`
* `Vector3`
* `Vector4`

And added as a method in `Math`
2025-02-03 19:25:50 +01:00
Matias N. Goldberg
7b2f1e1d09 Fix union order to simplify empty initializers
This is a followup to PR #101344 (commit
0e06eb80bc).

Some of them were not an issue because Godot was initializing all
members, but they were "fixed" just in case since it could become a
problem in the future.

Valgrind was specifically complaining about HashMapData &
GlobalPipelineData.
2025-01-14 19:05:01 -03:00
Lukas Tenbrink
cf145de21e Revert regression (GH-31736) of memory unsafe append_array (append vector to itself). Add comments to prevent future regressions. 2025-01-10 15:30:36 +01:00
Nazarii
6609caf76e Use 1.5x growth factor for LocalVector 2025-01-10 15:57:54 +02:00
Aarni Koskela
f134769506 Fix various typos
* Add TODO notes for typos that should be fixed for 5.0

Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
2025-01-08 14:47:42 +02:00
Rémi Verschelde
1aaf20b1f1 Merge pull request #98488 from RandomShaper/lockless_rid_fetch_pro
Fix `RID_Owner` synchronization
2025-01-06 08:38:14 +01:00
Pedro J. Estébanez
de7e4efef8 Fix RID_Owner synchronization 2025-01-03 17:05:36 +01:00
Rémi Verschelde
21e6671740 Merge pull request #100937 from Repiteo/style/clang-format-sync
Style: Enforce `AllowShortFunctionsOnASingleLine`
2025-01-03 00:49:44 +01:00
Rémi Verschelde
dd7d36e803 Merge pull request #100770 from hpvb/command-queue-mt
Core: Refactor CommandQueueMT to use vararg templates for performance and maintainability
2025-01-03 00:49:02 +01:00
Thaddeus Crews
e06d83860d Style: Enforce AllowShortFunctionsOnASingleLine 2025-01-02 10:09:41 -06:00
HP van Braam
cccd2432c3 Refactor CommandQueueMT to use vararg templates
In order to make CommandQueueMT more maintainable this PR changes the
previous macro hell with variadic templates instead. This makes the
class far more explicit and will allow us to more easily change the way
the class functions in the future.

Furthermore this refactoring has allowed for some optimizations. In
particular by using std::forward to delay the decision of decaying the
type to as late as possible we are able to move the data from the
callsite into our Command buffer and later move it to the call.

In practice what this means is that compared to the old version instead
of copying values 3 times, we can now get away with 1 copy, and 1 move
for lvalues, and just 2 moves for rvalues. This saves quite a few
operations in a hot codepath.

We also now test to make sure that the amount of copies and moves are
what we expect. This way we can spot performance regressions in this
code easily.

Somewhat unscientifically, running TPS-demo by pressing enter and not
touching the controls average mspf, repeatable across many runs:

before: 6.467
after : 6.202
2025-01-02 15:35:08 +01:00