Commit Graph

69778 Commits

Author SHA1 Message Date
Thaddeus Crews
66dea152b5
Merge pull request #99257 from darksylinc/matias-TheForge-pr04-excluded-ubo+render_opt
Improvements from TheForge
2024-12-10 14:15:55 -06:00
Thaddeus Crews
6cbf7c77c2
Merge pull request #100150 from ArchercatNEO/homeless-export
Use temp dirs instead of cache dirs for export
2024-12-10 14:15:54 -06:00
Thaddeus Crews
8f16f864a6
Merge pull request #99765 from dalexeev/core-fix-json-from-to-native
Core: Fix `JSON.{from,to}_native()` issues
2024-12-10 14:15:53 -06:00
Thaddeus Crews
d108d4f29e
Merge pull request #100147 from esainane/vector-victor
Remove apparent contradiction in vector.h header
2024-12-10 14:15:52 -06:00
Thaddeus Crews
f222cc43f3
Merge pull request #99633 from buresu/fix-wayland-keymapping
Fix underscore input not working with jp106 keyboard on wayland platform
2024-12-10 14:15:51 -06:00
Thaddeus Crews
79dd5179e3
Merge pull request #99887 from JackErb/gdscript-parser-error-fix
Improve misleading `Unexpected "x" in class body.` GDScript parser error
2024-12-10 14:15:50 -06:00
Thaddeus Crews
78215f3cc6
Merge pull request #100132 from Ivorforce/string-compile-time-strlen
Optimize String construction from statically known strings by evaluating `strlen` at compile-time.
2024-12-10 14:15:49 -06:00
Thaddeus Crews
ef0d1e0eb9
Merge pull request #100001 from clayjohn/rd-uniform-set-cache
Increase the size of the uniform set cache to 4096 to avoid cache thrashing from projects with high numbers of unique textures
2024-12-10 14:15:48 -06:00
Thaddeus Crews
b26f9f0380
Merge pull request #85275 from TheSofox/anchors-undo-fix
Correctly restore Control position on undoing an Anchors Preset
2024-12-10 14:15:47 -06:00
Thaddeus Crews
2e7f5f1bf3
Merge pull request #100250 from YYF233333/style
[Codestyle] Merge identical code piece in ConvexHullComputer
2024-12-10 14:15:45 -06:00
Thaddeus Crews
14b2f62d04
Merge pull request #100247 from BlueCube3310/tex-preview-all
Consider all texture types for resource thumbnail generation
2024-12-10 14:15:44 -06:00
Thaddeus Crews
dfaf8074e0
Merge pull request #100245 from Faless/web/audio_worklet_fallback
[Web] Restore ScriptProcessorNode audio driver fallback
2024-12-10 14:15:43 -06:00
Thaddeus Crews
bfc1d2f95f
Merge pull request #96773 from tetrapod00/resource-save-popup
[Editor] Use toast (notification) instead of dialog when saving with no open scene
2024-12-10 14:15:42 -06:00
Thaddeus Crews
a167afd70a
Merge pull request #96771 from clayjohn/RD-static-lighting
Avoid calculating dynamic lights when lights are already baked using the static bake mode in the Forward+ renderer
2024-12-10 14:15:41 -06:00
Fabio Alessandrelli
9d329f54c0 [Web] Restore ScriptProcessorNode audio driver fallback
Godot has a ScriptProcessorNode audio driver implementation for the
(deprecated) Web API.

As reported by some users, this fallback was not properly re-added
during the Godot 4 transition, and was left as "dead code".

While the API is deprecated, it is still supported by most browsers, and
some WebView may not implement AudioWorklet correctly (the new
recommended API).

This commit re-adds the ScriptProcessorNode implementation as a fallback
if the AudioWorklet driver fails to initialized (and can be forced if
desired via project settings as usual).
2024-12-10 18:22:03 +01:00
Yufeng Ying
bdf24924e6 [Codestyle] Merge identical code piece. 2024-12-11 00:48:00 +08:00
BlueCube3310
ab0a2517b1 Consider all texture types for resource thumbnail generation 2024-12-10 14:57:10 +01:00
JackErb
13fcb05e7b Improve GDScript "unexpected token in class body" parser error
This parser error was misleading.

Fixes:
1. Now points at correct line
2. For identifiers, prints out `Identifier "%s"`
2024-12-09 21:01:46 -08:00
Sai Nane
66b7d5f1b5 Remove apparent contradiction in vector.h header
3205a92ad8 was a major commit which removed `PoolVector`, and replaced
most references to `PoolVector` with `Vector` instead. In most cases,
this was appropriate, given that `PoolVector` was being replaced with
`Vector`, as an effective generalist in 64-bit address space layouts.

However, vector.h itself was left with an artifact advising the reader
to use `Vector` instead of `Vector` for large arrays. While this led
to a fascinating deep dive, and hopefully improved some of the
documentation along the way, it's probably best to clean this up for
the next person.
2024-12-10 01:51:30 +00:00
Lukas Tenbrink
a3f48f7047 Optimize String construction from statically known strings allowing strlen to be evaluated at compile time, where possible. 2024-12-09 21:47:28 +01:00
Thaddeus Crews
a372214a4a
Merge pull request #76020 from dalexeev/gds-warning-ignore-regions
GDScript: Add `@warning_ignore_start` and `@warning_ignore_restore` annotations
2024-12-09 14:33:38 -06:00
Thaddeus Crews
b4bd38444b
Merge pull request #98545 from juanjp600/dotnet-generic-collections-set-typed
Fix generic arrays and dictionaries in .NET not calling `set_typed`
2024-12-09 14:33:37 -06:00
Thaddeus Crews
09dd5e6b20
Merge pull request #98032 from zaevi/fix_drag_preview_position
Fix incorrect drag preview position under transformed `CanvasLayer`.
2024-12-09 14:33:36 -06:00
Thaddeus Crews
4b1a51d3e3
Merge pull request #100075 from demolke/simplify
Fix handling of leading `..` in simplify_path
2024-12-09 14:33:34 -06:00
Thaddeus Crews
5b312d0e59
Merge pull request #99816 from Ivorforce/string-copy-from-optimizations
Optimize `String::copy_from` and `String::copy_from_unchecked` implementations, improving String allocation speed.
2024-12-09 14:33:33 -06:00
Thaddeus Crews
a3656083ca
Merge pull request #100065 from clayjohn/mesh-aabb-clear
Clear AABB when Mesh is cleared
2024-12-09 14:33:32 -06:00
Thaddeus Crews
da8b9ba1ff
Merge pull request #99168 from RandomShaper/even_better_spinlock
SpinLock: Overhaul false sharing prevention
2024-12-09 14:33:31 -06:00
Thaddeus Crews
e9679a28ff
Merge pull request #91604 from nongvantinh/implement-7946
Save color palette as resources to reuse later
2024-12-09 14:33:29 -06:00
Thaddeus Crews
94711acfe1
Merge pull request #87375 from limbonaut/instantiate_property_editor
Export `EditorInspector::instantiate_property_editor` for use by plugins
2024-12-09 14:33:28 -06:00
Thaddeus Crews
7d4db793e6
Merge pull request #100044 from Yelloween10/fix-input-event-metadata
Fix discarded input event metadata in `xformed_by`
2024-12-09 14:33:27 -06:00
Thaddeus Crews
d6473dd3fa
Merge pull request #100167 from AshWolf/header-guards-crash-fix
Fix crash within header_guards when a file is too short
2024-12-09 14:33:26 -06:00
Thaddeus Crews
473c28b1ad
Merge pull request #98118 from bruvzg/escape_colors
Add support for 24-bit color escape sequences, simplify `print_rich` BBCode parsing.
2024-12-09 14:33:25 -06:00
Thaddeus Crews
a607bca2fd
Merge pull request #100024 from Ivorforce/optimize-string-single-char
Optimize string single char contains calls.
2024-12-09 14:33:24 -06:00
Thaddeus Crews
101b78fbea
Merge pull request #100020 from Lielay9/mend-round-primitives
Mend gaps in meshes caused by trigonometric funcs.
2024-12-09 14:33:23 -06:00
Thaddeus Crews
fb4d401933
Merge pull request #81714 from CreepGin/navigation_feel
Add 3D translation sensitivity to Editor Settings
2024-12-09 14:33:21 -06:00
Thaddeus Crews
e06f699354
Merge pull request #99886 from ZhiyiHu93/update-sky-tests
Add unit tests for Sky
2024-12-09 14:33:20 -06:00
Thaddeus Crews
2256d6da34
Merge pull request #100140 from Chubercik/thorvg_patches
thorvg: Regenerate and apply patches
2024-12-09 14:33:18 -06:00
Thaddeus Crews
cc59949cfe
Merge pull request #100006 from Daylily-Zeleen/daylily-zeleen/hide_debug_instnce
Hide `NavigationRegion2D`'s debug instance instead of freeing it, and hide it when `navigation_polygon` is set to null.
2024-12-09 14:33:17 -06:00
Thaddeus Crews
5f5f86bff0
Merge pull request #100128 from clayjohn/rd-shader-spam
Avoid error spam when shaders fail to compile by freeing shader_data version when compilation fails
2024-12-09 14:33:16 -06:00
Thaddeus Crews
e7cdbf827b
Merge pull request #99871 from RossRothenstine/ross/fix-windows-sleep-underflow
Windows: Fix underflow before `delay_usec`
2024-12-09 14:33:15 -06:00
Thaddeus Crews
75a425f1d3
Merge pull request #99995 from clayjohn/RD-batch-ptrw
Optimize batch uniform set creation by caching ptrw when creating batch uniform
2024-12-09 14:33:14 -06:00
Thaddeus Crews
3b8c459dae
Merge pull request #99992 from yahkr/fix_control_orphan_startup
Fix for `RuntimeNodeSelect` `selection_list` showing up as an orphaned node when editor is open during runtime
2024-12-09 14:33:13 -06:00
Thaddeus Crews
6931930029
Merge pull request #99860 from akien-mga/basisu-clarify-encoder-only-deps
basis_universal: Clarify encoder-only dependencies, only used in editor builds
2024-12-09 14:33:12 -06:00
Thaddeus Crews
2654dbaf5c
Merge pull request #99984 from KoBeWi/negative_diff_but_it's_deleting_whole_files
Move singleton StringName definitions to header
2024-12-09 14:33:11 -06:00
Thaddeus Crews
b91c38eaac
Merge pull request #98443 from timoschwarzer/fix/control-offset-type
Fix Control `offset_*` property types
2024-12-09 14:33:10 -06:00
Thaddeus Crews
94caf59b71
Merge pull request #100105 from smix8/dirty_mold
Fix avoidance dirty flag regression
2024-12-09 14:33:09 -06:00
Thaddeus Crews
533091ae22
Merge pull request #99974 from Flarkk/improve_occlusion_jitter
Optimize Occlusion culling jitter
2024-12-09 14:33:08 -06:00
clayjohn
fce34f22a2 Avoid error spam when shaders fail to compile by freeing shader_data version when compilation fails 2024-12-09 10:51:57 -08:00
Matias N. Goldberg
c77cbf096b Improvements from TheForge (see description)
The work was performed by collaboration of TheForge and Google. I am
merely splitting it up into smaller PRs and cleaning it up.

This is the most "risky" PR so far because the previous ones have been
miscellaneous stuff aimed at either [improve
debugging](https://github.com/godotengine/godot/pull/90993) (e.g. device
lost), [improve Android
experience](https://github.com/godotengine/godot/pull/96439) (add Swappy
for better Frame Pacing + Pre-Transformed Swapchains for slightly better
performance), or harmless [ASTC
improvements](https://github.com/godotengine/godot/pull/96045) (better
performance by simply toggling a feature when available).

However this PR contains larger modifications aimed at improving
performance or reducing memory fragmentation. With greater
modifications, come greater risks of bugs or breakage.

Changes introduced by this PR:

TBDR GPUs (e.g. most of Android + iOS + M1 Apple) support rendering to
Render Targets that are not backed by actual GPU memory (everything
stays in cache). This works as long as load action isn't `LOAD`, and
store action must be `DONT_CARE`. This saves VRAM (it also makes
painfully obvious when a mistake introduces a performance regression).
Of particular usefulness is when doing MSAA and keeping the raw MSAA
content is not necessary.

Some GPUs get faster when the sampler settings are hard-coded into the
GLSL shaders (instead of being dynamically bound at runtime). This
required changes to the GLSL shaders, PSO creation routines, Descriptor
creation routines, and Descriptor binding routines.

 - `bool immutable_samplers_enabled = true`

Setting it to false enforces the old behavior. Useful for debugging bugs
and regressions.

Immutable samplers requires that the samplers stay... immutable, hence
this boolean is useful if the promise gets broken. We might want to turn
this into a `GLOBAL_DEF` setting.

Instead of creating dozen/hundreds/thousands of `VkDescriptorSet` every
frame that need to be freed individually when they are no longer needed,
they all get freed at once by resetting the whole pool. Once the whole
pool is no longer in use by the GPU, it gets reset and its memory
recycled. Descriptor sets that are created to be kept around for longer
or forever (i.e. not created and freed within the same frame) **must
not** use linear pools. There may be more than one pool per frame. How
many pools per frame Godot ends up with depends on its capacity, and
that is controlled by
`rendering/rendering_device/vulkan/max_descriptors_per_pool`.

- **Possible improvement for later:** It should be possible for Godot
to adapt to how many descriptors per pool are needed on a per-key basis
(i.e. grow their capacity like `std::vector` does) after rendering a few
frames; which would be better than the current solution of having a
single global value for all pools (`max_descriptors_per_pool`) that the
user needs to tweak.

 - `bool linear_descriptor_pools_enabled = true`

Setting it to false enforces the old behavior. Useful for debugging bugs
and regressions.
Setting it to false is required when workarounding driver bugs (e.g.
Adreno 730).

A ridiculous optimization. Ridiculous because the original code
should've done this in the first place. Previously Godot was doing the
following:

  1. Create a command buffer **pool**. One per frame.
  2. Create multiple command buffers from the pool in point 1.
3. Call `vkBeginCommandBuffer` on the cmd buffer in point 2. This
resets the cmd buffer because Godot requests the
`VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT` flag.
  4. Add commands to the cmd buffers from point 2.
  5. Submit those commands.
6. On frame N + 2, recycle the buffer pool and cmd buffers from pt 1 &
2, and repeat from step 3.

The problem here is that step 3 resets each command buffer individually.
Initially Godot used to have 1 cmd buffer per pool, thus the impact is
very low.

But not anymore (specially with Adreno workarounds to force splitting
compute dispatches into a new cmd buffer, more on this later). However
Godot keeps around a very low amount of command buffers per frame.

The recommended method is to reset the whole pool, to reset all cmd
buffers at once. Hence the new steps would be:

  1. Create a command buffer **pool**. One per frame.
  2. Create multiple command buffers from the pool in point 1.
3. Call `vkBeginCommandBuffer` on the cmd buffer in point 2, which is
already reset/empty (see step 6).
  4. Add commands to the cmd buffers from point 2.
  5. Submit those commands.
6. On frame N + 2, recycle the buffer pool and cmd buffers from pt 1 &
2, call `vkResetCommandPool` and repeat from step 3.

**Possible issues:** @dariosamo added `transfer_worker` which creates a
command buffer pool:

```cpp
transfer_worker->command_pool =
driver->command_pool_create(transfer_queue_family,
RDD::COMMAND_BUFFER_TYPE_PRIMARY);
```

As expected, validation was complaining that command buffers were being
reused without being reset (that's good, we now know Validation Layers
will warn us of wrong use).
I fixed it by adding:

```cpp
void RenderingDevice::_wait_for_transfer_worker(TransferWorker
*p_transfer_worker) {
	driver->fence_wait(p_transfer_worker->command_fence);
	driver->command_pool_reset(p_transfer_worker->command_pool); //
! New line !
```

**Secondary cmd buffers are subject to the same issue but I didn't alter
them. I talked this with Dario and he is aware of this.**
Secondary cmd buffers are currently disabled due to other issues (it's
disabled on master).

 - `bool RenderingDeviceCommons::command_pool_reset_enabled`

Setting it to false enforces the old behavior. Useful for debugging bugs
and regressions.

There's no other reason for this boolean. Possibly once it becomes well
tested, the boolean could be removed entirely.

Adds `command_bind_render_uniform_sets` and
`add_draw_list_bind_uniform_sets` (+ compute variants).

It performs the same as `add_draw_list_bind_uniform_set` (notice
singular vs plural), but on multiple consecutive uniform sets, thus
reducing graph and draw call overhead.

 - `bool descriptor_set_batching = true;`

Setting it to false enforces the old behavior. Useful for debugging bugs
and regressions.

There's no other reason for this boolean. Possibly once it becomes well
tested, the boolean could be removed entirely.

Godot currently does the following:

 1. Fill the entire cmd buffer with commands.
 2. `submit()`
    - Wait with a semaphore for the swapchain.
- Trigger a semaphore to indicate when we're done (so the swapchain
can submit).
 3. `present()`

The optimization opportunity here is that 95% of Godot's rendering is
done offscreen.
Then a fullscreen pass copies everything to the swapchain. Godot doesn't
practically render directly to the swapchain.

The problem with this is that the GPU has to wait for the swapchain to
be released **to start anything**, when we could start *much earlier*.
Only the final blit pass must wait for the swapchain.

TheForge changed it to the following (more complicated, I'm simplifying
the idea):

 1. Fill the entire cmd buffer with commands.
 2. In `screen_prepare_for_drawing` do `submit()`
    - There are no semaphore waits for the swapchain.
    - Trigger a semaphore to indicate when we're done.
3. Fill a new cmd buffer that only does the final blit to the
swapchain.
 4. `submit()`
    - Wait with a semaphore for the submit() from step 2.
- Wait with a semaphore for the swapchain (so the swapchain can
submit).
- Trigger a semaphore to indicate when we're done (so the swapchain
can submit).
 5. `present()`

Dario discovered this problem independently while working on a different
platform.

**However TheForge's solution had to be rewritten from scratch:** The
complexity to achieve the solution was high and quite difficult to
maintain with the way Godot works now (after Übershaders PR).
But on the other hand, re-implementing the solution became much simpler
because Dario already had to do something similar: To fix an Adreno 730
driver bug, he had to implement splitting command buffers. **This is
exactly what we need!**. Thus it was re-written using this existing
functionality for a new purpose.

To achieve this, I added a new argument, `bool p_split_cmd_buffer`, to
`RenderingDeviceGraph::add_draw_list_begin`, which is only set to true
by `RenderingDevice::draw_list_begin_for_screen`.

The graph will split the draw list into its own command buffer.

 - `bool split_swapchain_into_its_own_cmd_buffer = true;`

Setting it to false enforces the old behavior. This might be necessary
for consoles which follow an alternate solution to the same problem.
If not, then we should consider removing it.

PR #90993 added `shader_destroy_modules()` but it was not actually in
use.

This PR adds several places where `shader_destroy_modules()` is called
after initialization to free up memory of SPIR-V structures that are no
longer needed.
2024-12-09 11:49:28 -03:00
ArchercatNEO
00a791f04e Use temp dirs instead of cache dirs for export
Fixes #95897
During CI scenarios $HOME may be set to an invalid value (such as
`/var/empty`).
Using temp dirs fits better with godot's usage of these paths and is
independent from the user's $HOME.
2024-12-08 12:07:17 +00:00