summaryrefslogtreecommitdiff
path: root/core/templates
AgeCommit message (Collapse)Author
2022-10-04Merge pull request #66804 from akien-mga/core-remove-NO_SAFE_CASTRémi Verschelde
Remove unsupported `NO_SAFE_CAST`/`-fno-rtti` from Android build
2022-10-03Remove NO_THREADS fallback code, Godot 4 requires thread supportRémi Verschelde
This also removes `OS::can_use_threads` from the public API since it's always true.
2022-10-03Remove unsupported `NO_SAFE_CAST`/`-fno-rtti` from Android buildRémi Verschelde
Android was the last platform to still attempt to disable RTTI (for binary size), but both the Android editor and now the ICU library used by templates need RTTI. There could still be the possibility to support this for non-ICU template builds (i.e. without the TextServerAdvanced module), but since this isn't one of the build configurations we test regularly it's pretty risky to keep this option only for that specific use case. And our code is already littered with `dynamic_cast`s which weren't guarded with `!defined(NO_SAFE_CAST)`.
2022-09-29Use `constexpr` in the conditions with template parameters and `sizeof`s to ↵bruvzg
suppress C4127 warnings.
2022-09-28Merge pull request #66548 from akien-mga/msvc-warnings-c4701-c4703Rémi Verschelde
Fix MSVC warnings C4701 and C4703: Potentially uninitialized variable used
2022-09-28Fix MSVC warnings C4701 and C4703: Potentially uninitialized variable usedRémi Verschelde
2022-09-28Fix MSVC warning C4706: assignment within conditional expressionRémi Verschelde
Part of #66537.
2022-09-26Style: Cleanup header guards for consistencyRémi Verschelde
Fix file names for {Static,Lightmap}RaycasterEmbree.
2022-08-05Add a Framebuffer cacheJuan Linietsky
Adds a FramebufferCache singletion that operates the same way as UniformSetCache. Allows creating framebuffers on the fly (and keep them cached if re-requested) such as: ```C++ RID fb = FramebufferCache::get_singleton()->get_cache(texture1,texture2); ```
2022-08-04Merge pull request #63906 from Faless/fix/4.x_warningsRémi Verschelde
2022-08-04[Core] Use std type traits to check operations triviality.Fabio Alessandrelli
2022-08-04Arrays: Zero new items of trivial types on resize() (bindings only)Rémi Verschelde
This is not enabled by default in the core version for performance reasons, as Vector/CowData are used in critical code paths where not zero'ing memory which is going to be set later on can be important. But for bindings / the scripting API, we make zero the new items by default (which already happened for built types like Vector3, etc., but not for trivial types like int, float). Fixes #43033. Co-authored-by: David Hoppenbrouwers <david@salt-inc.org>
2022-08-02Merge pull request #61315 from lawnjelly/variant_bucket_poolsRémi Verschelde
Variant memory pools
2022-07-25Remove ThreadWorkPool, replace by WorkerThreadPoolJuan Linietsky
The former needs to be allocated once per usage. The later is shared for all threads, which is more efficient. It can also be better debugged.
2022-07-25Code quality: Fix header guards consistencyRémi Verschelde
Adds `header_guards.sh` bash script, used in CI to validate future changes. Can be run locally to fix invalid header guards.
2022-07-23Implement Vector4, Vector4i, Projectionreduz
Implement built-in classes Vector4, Vector4i and Projection. * Two versions of Vector4 (float and integer). * A Projection class, which is a 4x4 matrix specialized in projection types. These types have been requested for a long time, but given they were very corner case they were not added before. Because in Godot 4, reimplementing parts of the rendering engine is now possible, access to these types (heavily used by the rendering code) becomes a necessity. **Q**: Why Projection and not Matrix4? **A**: Godot does not use Matrix2, Matrix3, Matrix4x3, etc. naming convention because, within the engine, these types always have a *purpose*. As such, Godot names them: Transform2D, Transform3D or Basis. In this case, this 4x4 matrix is _always_ used as a _Projection_, hence the naming.
2022-07-22Implement a Worker ThreadPoolreduz
This PR implements a worked thread pool. It uses a fixed amount of threads in a pool and allows scheduling tasks that can be run on threads (and then waited for). It satisfies the following use cases: * HTML5 thread count is fixed (and similar restrictions are known in consoles) so we need to reuse threads. * Thread spawning is slow in general, so reusing threads is faster anyway. * This implementation supports recursive waiting for tasks, making it less prone to deadlocks if threads from the pool also run tasks. After this is approved and merged, subsequent PRs will be needed to replace the ThreadWorkPool usage by this class.
2022-07-19Use the right memory ordering in SafeNumeric operationsPedro J. Estébanez
2022-07-06Refactor Font configuration and import UI, and Font resources.bruvzg
2022-07-04Variant memory poolslawnjelly
Memory pools via PagedAllocator for Transform2D, Transform3D, Basis and AABB.
2022-07-04Use custom key structs, instead of raw hashes for the Label3D and TextMesh, ↵bruvzg
to avoid potential hash collisions.
2022-07-01Merge pull request #62477 from lyuma/packedbytearrayRémi Verschelde
Prevent out-of-bounds write in array conversion; avoid logspam on empty arrays.
2022-06-30Prevent out-of-bounds write in array conversion; avoid logspam on empty arrays.Lyuma
2022-06-28Avoid manual memory management of certain arrays in Vulkan RDPedro J. Estébanez
2022-06-23Optimize HashMap/HashSet using fastmodHendrik Brucker
2022-06-20Clean up Hash Functionsreduz
Clean up and do fixes to hash functions and newly introduced murmur3 hashes in #61934 * Clean up usage of murmur3 * Fixed usages of binary murmur3 on floats (this is invalid) * Changed DJB2 to use xor (which seems to be better)
2022-06-15Hash function improvementsHendrik Brucker
2022-05-25use ERR_FAIL_INDEX when preferredNathan Franke
2022-05-20Add a new HashSet templatereduz
* Intended to replace RBSet in most cases. * Optimized for iteration speed
2022-05-16Replace most uses of Map by HashMapreduz
* Map is unnecessary and inefficient in almost every case. * Replaced by the new HashMap. * Renamed Map to RBMap and Set to RBSet for cases that still make sense (order matters) but use is discouraged. There were very few cases where replacing by HashMap was undesired because keeping the key order was intended. I tried to keep those (as RBMap) as much as possible, but might have missed some. Review appreciated!
2022-05-12Add a new HashMap implementationreduz
Adds a new, cleaned up, HashMap implementation. * Uses Robin Hood Hashing (https://en.wikipedia.org/wiki/Hash_table#Robin_Hood_hashing). * Keeps elements in a double linked list for simpler, ordered, iteration. * Allows keeping iterators for later use in removal (Unlike Map<>, it does not do much for performance vs keeping the key, but helps replace old code). * Uses a more modern C++ iterator API, deprecates the old one. * Supports custom allocator (in case there is a wish to use a paged one). This class aims to unify all the associative template usage and replace it by this one: * Map<> (whereas key order does not matter, which is 99% of cases) * HashMap<> * OrderedHashMap<> * OAHashMap<>
2022-05-07Add search methods for packed arraysHaoyu Qiu
* count() * find() * rfind()
2022-04-22Add mutable OAHashMap::lookup_ptr function to fix mutability.AndreaCatania
2022-04-12Merge pull request #60078 from Pineapple/cowdata-get-dataRémi Verschelde
Remove get_data() from CowData
2022-04-09Remove get_data() from CowDataBartłomiej T. Listwon
2022-04-08add SafeList destructor which calls maybe_cleanup() to prevent mem leakMark Riedesel
2022-04-06Fix some issues found by cppcheck.bruvzg
2022-04-04Zero initialize all pointer class and struct membersRémi Verschelde
This prevents the pitfall of UB when checking if they have been assigned something valid by comparing to nullptr.
2022-03-27Const Ref Callable for custom sort/searchmashumafi
2022-03-09Change some math macros to constexprkobewi
Changes `MAX`, `MIN`, `ABS`, `CLAMP` and `SIGN`.
2022-03-06Add a UniformSet cachereduz
* Changed syntax usage for RD::Uniform to create faster with a single RID * Converted render pass setup to use this in clustered renderer to test. This is the first step into creating a proper uniform set cache system to simplify large parts of the codebase.
2022-03-04Merge pull request #57630 from lawnjelly/bvh4_templated_checksRémi Verschelde
[4.x] BVH - Sync BVH with 3.x
2022-02-16Make VMap::find_nearest return -1 when emptyHaoyu Qiu
2022-02-05Remove RID_Owner.get_rid_by_indexreduz
* Implementing this function efficiently is not really possible. * Replaced by an option to get all RIDs into a buffer for performance.
2022-02-04BVH - Sync BVH with 3.xlawnjelly
Templated mask checks and generic NUM_TREES Fix leaking leaves
2022-02-02Vectors: Use clear() and has().Anilforextra
Use clear() instead of resize(0). Use has() instead of "find(p_val) != -1".
2022-01-18Merge pull request #56668 from akien-mga/array-slice-nicer-bound-checksRémi Verschelde
2022-01-12Merge pull request #56492 from akien-mga/remove-author-docstringsRémi Verschelde
2022-01-10`Array`: Relax `slice` bound checks to properly handle negative indicesRémi Verschelde
The same is done for `Vector` (and thus `Packed*Array`). `begin` and `end` can now take any value and will be clamped to `[-size(), size()]`. Negative values are a shorthand for indexing the array from the last element upward. `end` is given a default `INT_MAX` value (which will be clamped to `size()`) so that the `end` parameter can be omitted to go from `begin` to the max size of the array. This makes `slice` works similarly to numpy's and JavaScript's.
2022-01-10Fix crash on importing FBX fileHaoyu Qiu