Commit Graph

2806 Commits

Author SHA1 Message Date
clayjohn
30801af298 Properly transform light rect and occluder rect to perform light2d culling in canvas space 2024-12-20 16:58:02 -07:00
Rémi Verschelde
6e23de0aa6
Merge pull request #100653 from stuartcarnie/remove_moltenvk_hack
Rendering: MoltenVK hack is no longer required, as bug was fixed.
2024-12-20 23:57:27 +01:00
Rémi Verschelde
87855e04ad
Merge pull request #100643 from ze2j/follow_up_of_array_mesh_surface_remove
Follow-up of `ArrayMesh::surface_remove` addition
2024-12-20 23:57:20 +01:00
Stuart Carnie
9344a29f0e Rendering: MoltenVK hack is no longer required, as bug was fixed.
Original issue: https://github.com/godotengine/godot/pull/51679#issuecomment-976900929

And related fix in SPIRV-Cross: https://github.com/KhronosGroup/SPIRV-Cross/issues/2046
2024-12-20 06:38:42 -07:00
Yufeng Ying
e88e30c273 Remove unused headers in servers.
Co-authored-by: bruvzg <7645683+bruvzg@users.noreply.github.com>
2024-12-20 18:51:01 +08:00
ze2j
97b093617d Follow-up of ArrayMesh::surface_remove addition 2024-12-20 10:53:43 +01:00
Thaddeus Crews
e51ab56f9a
Merge pull request #100593 from Namey5/lightmapgi-null-sky-crash
LightmapGI: Fix crash during baking when sky is null
2024-12-19 20:00:14 -06:00
Thaddeus Crews
1536e0e236
Merge pull request #100441 from StaydMcMuffin/scene-shaders-tbn-fixes
Scene Shaders - TBN Vector Fixes
2024-12-19 19:59:58 -06:00
Thaddeus Crews
b715fabd70
Merge pull request #76371 from ze2j/array_mesh_surface_remove
Add `ArrayMesh::surface_remove`
2024-12-19 19:59:56 -06:00
Thaddeus Crews
2fcd8223e8
Merge pull request #99538 from Geometror/lightmap-gi-transparent-surface
Add transparency support for LightmapGI
2024-12-19 19:59:52 -06:00
Thaddeus Crews
4665faaaa9
Merge pull request #100427 from Namey5/fog-sky-luminance
Separate sky luminance and brightness calculations for consistent fog
2024-12-19 19:59:50 -06:00
Thaddeus Crews
41b468f961
Merge pull request #100544 from Namey5/sdfgi-sky-rotation
Support custom sky rotation in SDFGI
2024-12-19 19:59:46 -06:00
Thaddeus Crews
0b2596a319
Merge pull request #100399 from Fahien/fahien/resource-usage-to-string
Convert resource usage to string
2024-12-19 19:59:40 -06:00
Thaddeus Crews
d3e5b62ea2
Merge pull request #99230 from paddy-exe/instance_uniforms_compatability_renderer
Implement 2D instance uniforms
2024-12-19 19:59:37 -06:00
Alex Threlfo
e4fd2f003f Support custom sky rotation in SDFGI 2024-12-20 11:26:28 +11:00
Alex Threlfo
5f617663aa fix: separate sky luminance and user brightness calculations around fog 2024-12-20 11:25:11 +11:00
clayjohn
793d065f8b Avoid allocating instance buffer for PointLight2D shadows when there are no instances.
Also avoid the render loop if there are no occluders. We still have to open the render pass to do a clear though.
2024-12-19 09:45:51 -08:00
Antonio Caggiano
b6e5b4dde7
Convert resource usage to string
Improve error message by converting resource usage values to a
human-readable string.
2024-12-19 17:08:01 +01:00
Alex Threlfo
31add2602a LightmapGI: fix crash during baking when sky is null 2024-12-19 16:16:33 +11:00
Hendrik Brucker
a3525bc015 Add transparency support for LightmapGI
Co-authored-by: Guerro323 <kaltobattle@gmail.com>
2024-12-18 19:36:16 +01:00
kobewi
ceefc0d38a Implement 2D instance shader parameters
Co-authored-by: kobewi <kobewi4e@gmail.com>
Co-authored-by: yesfish <huwpascoe@users.noreply.github.com>
Co-authored-by: Álex Román Núñez <eirexe123@gmail.com>
2024-12-17 23:59:16 +01:00
Rémi Verschelde
190ae9f9dc
Merge pull request #100302 from clayjohn/light2d-optimize
Optimize PointLight2D shadow rendering by reducing draw calls and RD state changes
2024-12-17 22:59:54 +01:00
clayjohn
7c61252dd7 Optimize PointLight2D shadow rendering by reducing draw calls and RD state changes.
This dramatically reduces the CPU time spent on rendering shadows for PointLight2Ds
2024-12-17 07:41:09 -08:00
Rémi Verschelde
d60c0e21a6
Merge pull request #88313 from wagnerfs/run-time-anisotropic-filtering
Allow changing the anisotropic filter level at run-time per Viewport
2024-12-17 16:18:38 +01:00
Rémi Verschelde
d701bc0032
Merge pull request #83917 from Calinou/directionallight3d-add-specular
Implement per-light Specular property in DirectionalLight3D
2024-12-17 16:18:29 +01:00
Stayd
ed0e3d7da8 Scene Shaders - TBN Fixes
Fixes two errors related to the normal, tangent,
and bitangent vectors, namely normals not always
being inverted on backfaces, and normalization
being reversed from what MikkTSpace expects.
2024-12-16 22:36:23 -07:00
Andrew_Shobbrook
e42def12d0
Implement per-light Specular property in DirectionalLight3D 2024-12-16 19:18:18 +01:00
Alex Threlfo
34ebec3748 fix: crash in scenes with more than 8 shadowed directional lights 2024-12-15 19:13:07 +11:00
Rémi Verschelde
ffe53cba3c
Merge pull request #100374 from hpvb/fix-rendering-ubsan
Fix ubsan reported errors in rendering
2024-12-14 18:25:46 +01:00
Rémi Verschelde
e271b2ca08
Merge pull request #99145 from dsnopek/xr-lock-camera
XR: Allow locking the camera to the `XROrigin3D` for benchmarking or automated testing
2024-12-14 18:25:21 +01:00
Thaddeus Crews
dc5f1b7a28
Merge pull request #100319 from Flarkk/fix_light_shadow_range
Some checks are pending
🔗 GHA / 📊 Static checks (push) Waiting to run
🔗 GHA / 🤖 Android (push) Blocked by required conditions
🔗 GHA / 🍏 iOS (push) Blocked by required conditions
🔗 GHA / 🐧 Linux (push) Blocked by required conditions
🔗 GHA / 🍎 macOS (push) Blocked by required conditions
🔗 GHA / 🏁 Windows (push) Blocked by required conditions
🔗 GHA / 🌐 Web (push) Blocked by required conditions
🔗 GHA / 🪲 Godot CPP (push) Blocked by required conditions
Fix shadows of long range `OmniLight3D` and `SpotLight3D`
2024-12-13 16:19:39 -06:00
Thaddeus Crews
9ecdeb3723
Merge pull request #98747 from tetrapod00/standardize-renderer-strings
Standardize terms for renderers in error strings
2024-12-13 16:19:37 -06:00
Thaddeus Crews
6594a6364e
Merge pull request #100213 from DarioSamo/pipeline-hash-map-thread-safety
Improve thread-safety of pipeline hash map.
2024-12-13 16:19:34 -06:00
Thaddeus Crews
9f0c6231c7
Merge pull request #100236 from Flarkk/fix_spot_clustering
Fix wide `SpotLight3D` clustering
2024-12-13 16:19:26 -06:00
Thaddeus Crews
f2c8f17906
Merge pull request #100325 from hpvb/fix-rendering-alignment
Fix several ubsan reported misaligned accesses
2024-12-13 16:19:20 -06:00
HP van Braam
062d74bb9c Fix ubsan reported errors in rendering
This allows the TPS demo to run without an ubsan reports from any of the
rendering code.
2024-12-13 21:27:37 +01:00
HP van Braam
e674379764 Fix several ubsan reported misaligned accesses
These misaligned accesses are shown in all of our CI hooks. It turned
out to not be difficult to fix.

It is likely that this will improve performance for aarch64.
2024-12-13 15:32:35 +01:00
Florent Guiocheau
02f05cf0ac Fix wide angle spotlight clustering 2024-12-13 11:28:42 +01:00
clayjohn
356fa37f89 Small fixups for the new reflection probe blending 2024-12-12 17:29:21 -08:00
Thaddeus Crews
bfc66f0608
Merge pull request #100282 from devloglogan/motion-vectors-openxr
Add renderer motion vectors API for use with OpenXR
2024-12-12 16:13:36 -06:00
Thaddeus Crews
7c015a768f
Merge pull request #99958 from lander-vr/reflection-probe-blend-property
Add Blend Distance property to ReflectionProbe
2024-12-12 16:13:32 -06:00
Thaddeus Crews
b7501d219c
Merge pull request #100322 from darksylinc/matias-tf-comment-fix
Fix grammar / spelling in comments
2024-12-12 16:13:25 -06:00
Matias N. Goldberg
a1b44ec7a7 Fix grammar / spelling in comments
Minor fixes for changes introduced in #99257 that could not be fixed in
time as the PR needed to be expedited.
2024-12-12 12:47:08 -03:00
Florent Guiocheau
5125adf40b Fix large range point lights shadows 2024-12-12 15:37:38 +01:00
Rémi Verschelde
562dd1ad85
Merge pull request #100305 from clayjohn/directional-light-2d-mask
Remove positional light mask from directional lights in Canvas Item shaders.
2024-12-12 14:10:24 +01:00
Rémi Verschelde
0e5c337453
Merge pull request #85653 from BlueCube3310/lightmap-gi-shadowmask
Implement LightmapGI shadowmasks
2024-12-12 14:09:30 +01:00
BlueCube3310
189c8eb671 Implement shadowmasks for LightmapGI
Co-authored-by: dearthdev <nathandearthdev@gmail.com>
2024-12-12 11:00:28 +01:00
clayjohn
f8827271d7 Remove positional light mask from directional lights in Canvas Item shaders. 2024-12-12 00:20:07 -08:00
Thaddeus Crews
3dacc5fb7f
Merge pull request #95737 from Chaosus/shader_fix_varyings
Fix shader crash when using varyings with non-`flat` integer type
2024-12-11 17:36:06 -06:00
Thaddeus Crews
ef3086bcdb
Merge pull request #94947 from ChrisBase/issue_94946
Change some image error messages to output the file path
2024-12-11 17:35:58 -06:00
Thaddeus Crews
572e1d6643
Merge pull request #100289 from bruvzg/token_name
[Shader Language] Add missing token name.
2024-12-11 17:35:44 -06:00
Thaddeus Crews
23afda44e4
Merge pull request #100257 from darksylinc/matias-minimize-leak
Keep processing Graphics if there are pending operations
2024-12-11 17:35:35 -06:00
Dario
054891de04 Implement buffer_get_data_async and texture_get_data_async. 2024-12-11 11:55:23 -08:00
Pāvels Nadtočajevs
133471afb0 [Shader Language] Add missing token name. 2024-12-11 21:05:14 +02:00
Matias N. Goldberg
acf439e96d Keep processing Graphics if there are pending operations
Fixes #90017
Fixes #90030
Fixes #98044

This PR makes the following changes:

# Force processing of GPU commands for frame_count frames

The variable `frames_pending_resources_for_processing` is added to track
this.

The ticket #98044 suggested to use `_flush_and_stall_for_all_frames()`
while minimized.

Technically this works and is a viable solution.

However I noticed that this issue was happening because Logic/Physics
continue to work "business as usual" while minimized(\*). Only Graphics
was being deactivated (which caused commands to accumulate until window
is restored).

To continue this behavior of "business as usual", I decided that GPU
work should also "continue as usual" by buffering commands in a double
or triple buffer scheme until all commands are done processing (if they
ever stop coming). This is specially important if the app specifically
intends to keep processing while minimized.

Calling `_flush_and_stall_for_all_frames()` would fix the leak, but it
would make  Godot's behavior different while minimized vs while the
window is presenting.

\* `OS::add_frame_delay` _does_ consider being minimized, but it just
throttles CPU usage. Some platforms such as Android completely disable
processing because the higher level code stops being called when the app
goes into background. But this seems like an implementation-detail that
diverges from the rest of the platforms (e.g. Windows, Linux & macOS
continue to process while minimized).

# Rename p_swap_buffers for p_present

**This is potentially a breaking change** (if it actually breaks
anything, I ignore. But I strongly suspect it doesn't break anything).

"Swap Buffers" is a concept carried from OpenGL, where a frame is "done"
when `glSwapBuffers()` is called, which basically means "present to the
screen".

However it _also_ means that OpenGL internally swaps its internal
buffers in a double/triple buffer scheme (in Vulkan, we do that
ourselves and is tracked by `RenderingDevice::frame`).

Modern APIs like Vulkan differentiate between "submitting GPU work" and
"presenting".

Before this PR, calling `RendererCompositorRD::end_frame(false)` would
literally do nothing. This is often undesired and the cause of the leak.
After this PR, calling `RendererCompositorRD::end_frame(false)` will now
process commands, swap our internal buffers in a double/triple buffer
scheme **but avoid presenting to the screen**.

Hence the rename of the variable from `p_swap_buffers` to `p_present`
(which slightly alters its behavior).
If we want `RendererCompositorRD::end_frame(false)` to do nothing, then
we should not call it at all.

This PR reflects such change: When we're minimized **_and_**
`has_pending_resources_for_processing()` returns false, we don't call
`RendererCompositorRD::end_frame()` at all.

But if `has_pending_resources_for_processing()` returns true, we will
call it, but with `p_present = false` because we're minimized.

There's still the issue that Godot keeps processing work (logic,
scripts, physics) while minimized, which we shouldn't do by default. But
that's work for follow up PR.
2024-12-11 14:13:29 -03:00
devloglogan
3deb5884d7 Renderer agnostic motion vector rendering/OpenXR changes 2024-12-10 15:59:17 -06:00
Thaddeus Crews
cf038deb10
Merge pull request #100222 from DarioSamo/partial-coverage-fix
Some checks are pending
🔗 GHA / 📊 Static checks (push) Waiting to run
🔗 GHA / 🤖 Android (push) Blocked by required conditions
🔗 GHA / 🍏 iOS (push) Blocked by required conditions
🔗 GHA / 🐧 Linux (push) Blocked by required conditions
🔗 GHA / 🍎 macOS (push) Blocked by required conditions
🔗 GHA / 🏁 Windows (push) Blocked by required conditions
🔗 GHA / 🌐 Web (push) Blocked by required conditions
🔗 GHA / 🪲 Godot CPP (push) Blocked by required conditions
Fix incorrect return value on partial coverage detection.
2024-12-10 14:16:13 -06:00
Thaddeus Crews
25122e7dd3
Merge pull request #100081 from clayjohn/rd-clearcoat
Ensure schlick is available when using clearcoat with GGX
2024-12-10 14:16:07 -06:00
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
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
Dario
56645f466c Fix incorrect return value on partial coverage detection. 2024-12-09 19:29:59 -03: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
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
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
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
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
Dario
be1dce1071 Improve thread-safety of pipeline hash map. 2024-12-09 15:12:40 -03: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
Chaosus
a7bb85d2b7 Fix shader crash when using varyings with non-flat integer type 2024-12-09 12:52:01 +03:00
Lukas Tenbrink
b5c31ebb41 Add contains_char() for single-character 'contains' calls. 2024-12-06 20:23:35 +01:00
clayjohn
9320865796 Avoid calculating dynamic lights when lights are baked into LightmapGI using the static bake mode 2024-12-06 10:17:44 -08:00
clayjohn
f92018288f Ensure schlick is available when using clearcoat with GGX 2024-12-05 19:11:03 -08:00
landervr
05010180ce ReflectionProbe add Blend Distance 2024-12-05 23:29:47 +01:00
Thaddeus Crews
637239e979
Merge pull request #94193 from BastiaanOlij/buildin_includes
Add ability to include built-in include files
2024-12-05 14:12:23 -06:00
Thaddeus Crews
8e01601123
Merge pull request #100064 from clayjohn/atlas-realloc-time
Correctly check time since shadow was allocated in atlas to avoid unnecessary re-allocations
2024-12-05 14:12:19 -06:00
Thaddeus Crews
f5d82af1fd
Merge pull request #99136 from DarioSamo/light-compute-attenuation-skip
Improve performance of shader lighting code in Forward renderers.
2024-12-05 14:12:08 -06:00
Thaddeus Crews
a4c2e16c19
Merge pull request #100028 from clayjohn/rd-lights-array
Use a vector instead of an array in canvas shader instance buffer
2024-12-05 14:12:05 -06:00
clayjohn
deac37c464 Clear AABB when Mesh is cleared 2024-12-05 11:40:44 -08:00
clayjohn
1b5a15d5d1 Correctly check time since shadow was allocated in atlas to avoid unnecessary re-allocations
Co-authored-by: jitspoe <jitspoe@yahoo.com>
2024-12-05 11:13:37 -08:00
clayjohn
e316739a13 Use a vector instead of an array in canvas shader instance buffer.
This avoids a pathological performance cliff on Adreno devices
2024-12-04 16:36:46 -08:00
clayjohn
0dfbf4a5df Optimize batch uniform set creation by caching ptrw when creating batch uniform 2024-12-03 17:16:44 -08:00
Dario
fa7615be9e Add specialization for directional light split blend and fog. 2024-12-03 15:12:46 -03:00
Rémi Verschelde
e60b18493d
Merge pull request #99704 from Chaosus/shader_pp_fix_orphan_strings
Fix orphan strings in shader preprocessor
2024-12-02 17:20:39 +01:00
Rémi Verschelde
d2c82a8ffc
Merge pull request #97378 from rune-scape/less-const-cast
Get rid of easily removable uses of `const_cast`
2024-12-02 15:50:06 +01:00
Rémi Verschelde
14ce5ba8a1
Merge pull request #94368 from CrazyRoka/optimize-render-pass-uniform-set
Optimize `RenderForwardClustered::_setup_render_pass_uniform_set` by reducing Vector allocations
2024-12-02 15:49:58 +01:00
CrazyRoka
d9ef826c54
Optimize RenderForwardClustered::_setup_render_pass_uniform_set by reducing Vector allocations during push_back operations 2024-12-02 15:03:50 +01:00
Joshua Staub
16ee2f22eb
Check device texture size limits in RenderingDevice::texture_create 2024-12-02 14:30:02 +01:00
rune-scape
d58b2e879f Get rid of easily removable uses of const_cast 2024-12-01 17:50:13 -08:00
Wagner
6995b6a03e Allow changing the anisotropic filter level at run-time per Viewport 2024-11-30 00:50:45 -03:00
Dario
c7198dda64 Fix another incorrect clear color flag on texture storage. 2024-11-28 09:59:03 -03:00
Chaosus
5a48e527b2 Fix orphan strings in shader preprocessor 2024-11-28 11:22:17 +03:00
Dario
1c6aad660f Fix incorrect clear color flag on canvas renderer. 2024-11-27 20:01:23 -03:00
Thaddeus Crews
ed01f5f2aa
Merge pull request #98670 from DarioSamo/rd-transient-targets
Automatically resolve initial and final action for draw lists.
2024-11-27 10:47:29 -06:00
Thaddeus Crews
c58ae91efa
Merge pull request #99220 from Flarkk/fix_sss_reverse_z
Fix regression in SSS with reverse-z
2024-11-27 10:46:56 -06:00
Dario
0ce4c6dac3 Improve performance of shader lighting code in Forward renderers.
- Skip sampling shadows if attenuation is very small.
- Skip computing diffuse and specular light if attenuation and shadow are very small.
2024-11-27 12:20:31 -03:00
ze2j
97e0b43faa Add ArrayMesh::surface_remove 2024-11-27 13:46:15 +01:00
Florent Guiocheau
3376b9166b Fix SSS with reverse-z 2024-11-26 10:51:22 +01:00
Dario
6d5ac8f7ef Resolve load and store ops automatically for render passes for discardable textures. 2024-11-25 11:27:48 -03:00
Bastiaan Olij
1bffefb346 Adding ability to include build-in include files (precursor to custom shader templates) 2024-11-24 08:47:45 +11:00
Thaddeus Crews
dcb59f0e7e Merge pull request #99548 from Repiteo/style/clang-format-19-options
Style: Add 19.1.0 LLVM options to `.clang-format`
2024-11-22 14:54:29 -06:00
Thaddeus Crews
e8a4b45ce4
Style: Add 19.1.0 LLVM options to .clang-format 2024-11-22 09:24:32 -06:00
clayjohn
2b68c63a88 Mask out shadows on CanvasItems that don't have a matching item_shadow_mask
This restores the behavior from 3.x
2024-11-21 22:15:54 -08:00
Thaddeus Crews
38ebcf92ed
Merge pull request #99463 from DarioSamo/rd-partial-coverage-fix-part-two
Do not check for command intersections when not using the write list.
2024-11-21 17:56:47 -06:00
Thaddeus Crews
8eee5066eb
Merge pull request #94981 from Chaosus/shader_fix_screen_uv_in_spatial_light
Allow `SCREEN_UV` to be used in light function of spatial shader
2024-11-21 17:56:45 -06:00
Rémi Verschelde
7c1f42506a
Merge pull request #99448 from clayjohn/RD-sky-flip
Unify y-flip behavior for sky in RD backends
2024-11-20 17:03:19 +01:00
Dario
8bfb631afc Do not check for command intersections when not using the write list. 2024-11-20 10:04:17 -03:00
clayjohn
02efdb28dc Unify y-flip behavior for sky in RD backends 2024-11-19 16:59:04 -08:00
Dario
288717d7eb Improve dependency detection in render graph for draw lists with partial coverage. 2024-11-19 11:23:11 -03:00
Chaosus
a64b3fd3f8 Allow SCREEN_UV to be used in light function of spatial shader 2024-11-19 11:39:49 +03:00
Thaddeus Crews
fd4c29a189
Merge pull request #98683 from clayjohn/wireframe
Some checks failed
🔗 GHA / 📊 Static checks (push) Has been cancelled
🔗 GHA / 🤖 Android (push) Has been cancelled
🔗 GHA / 🍏 iOS (push) Has been cancelled
🔗 GHA / 🐧 Linux (push) Has been cancelled
🔗 GHA / 🍎 macOS (push) Has been cancelled
🔗 GHA / 🏁 Windows (push) Has been cancelled
🔗 GHA / 🌐 Web (push) Has been cancelled
🔗 GHA / 🪲 Godot CPP (push) Has been cancelled
Ensure shadow material and mesh are not used with wireframe mode
2024-11-18 09:23:54 -06:00
Thaddeus Crews
3ded11d0bc
Merge pull request #85359 from miv391/faster-exit-from-cull_canvas_item
Faster exit from `_cull_canvas_item` if alpha is zero
2024-11-18 09:23:51 -06:00
Thaddeus Crews
0a50cef751
Merge pull request #98788 from Bonkahe/master
Add `multimesh_get_buffer_rd_rid` method to `RenderingServer`.
2024-11-18 09:23:46 -06:00
Thaddeus Crews
7a5b1ed736
Merge pull request #99299 from Bonkahe/ResolveParticlesSetViewAxisThreadIssue
Move `_scene_particles_set_view_axis` to new static function to allow call to be done on render thread, preventing multi threaded error on compute shader execution.
2024-11-18 09:23:45 -06:00
Thaddeus Crews
fa29dde142
Merge pull request #99367 from BlueCube3310/mobile-probe-capture
Fix updating lightmap captures on Mobile
2024-11-18 09:23:32 -06:00
BlueCube3310
bb3d0045b0 Fix updating lightmap captures on Mobile 2024-11-17 19:29:21 +01:00
clayjohn
90b4b48b5a Ensure shadow material and mesh are not used with wireframe mode
And in the Compatibility renderer actually use the wireframe render mode
2024-11-16 22:25:00 -08:00
David House
7e3d480087 Created static method and moved _particles_set_view_axis over to it to allow calling on render thread. 2024-11-16 13:26:26 -06:00
Mika Viskari
39423d99fa Faster exit from _cull_canvas_item if alpha is zero 2024-11-16 13:27:45 +02:00
Chris
fb75078308 Changed some image error messages to print the file path 2024-11-15 20:42:03 +01:00
David House
6e9d31f602 Implemented multimesh_get_buffer_rd_rid function into RenderingServer.
Fixed style error.

Updated dummy mesh_storage to move from cpp to h the return of a blank Rid on _multimesh_get_buffer_rd_rid.
2024-11-14 15:52:08 -06:00
Thaddeus Crews
7f6b272b28
Merge pull request #99163 from clayjohn/Mobile-normal-interp
Normalize normal, tangent, and binormal before interpolating in the mobile renderer to avoid precision errors on heavily scaled meshes
2024-11-14 14:52:02 -06:00
clayjohn
2c158c386b Normalize normal tangent and binormal before interpolating in the mobile renderer to avoid precision errors on heavily scaled meshes 2024-11-13 12:24:28 -08:00
Thaddeus Crews
76fa7b2914
Merge pull request #99066 from DarioSamo/rd-transfer-worker-deadlock-fix
Some checks failed
🔗 GHA / 📊 Static checks (push) Has been cancelled
🔗 GHA / 🤖 Android (push) Has been cancelled
🔗 GHA / 🍏 iOS (push) Has been cancelled
🔗 GHA / 🐧 Linux (push) Has been cancelled
🔗 GHA / 🍎 macOS (push) Has been cancelled
🔗 GHA / 🏁 Windows (push) Has been cancelled
🔗 GHA / 🌐 Web (push) Has been cancelled
🔗 GHA / 🪲 Godot CPP (push) Has been cancelled
Give the barrier pool its own mutex to avoid a deadlock with transfer workers.
2024-11-13 08:34:36 -06:00
Thaddeus Crews
e71a52dff7
Merge pull request #99073 from DarioSamo/rd-graph-dependency-fix
Improve graph's detection of intersection between draw lists.
2024-11-13 08:33:52 -06:00
David Snopek
d6a4fe6c05 XR: Allow locking the camera to the XROrigin3D for benchmarking or automated testing 2024-11-12 15:06:27 -06:00
Thaddeus Crews
74645109c4
Merge pull request #98767 from jadeharley2/master
Fix inability to set TextureLayeredRD as `TEXTURE_TYPE_CUBE` or `TEXTURE_TYPE_CUBE_ARRAY`
2024-11-11 14:18:29 -06:00
Thaddeus Crews
e5b77b184f
Merge pull request #98755 from Chaosus/shader_compiler_fix_struct_member_names
Add prefix to struct member names in shader compiler
2024-11-11 14:18:23 -06:00
Dario
a8269820b9 Improve graph's detection of intersection between draw lists. 2024-11-11 11:59:47 -03:00
Dario
bf8ecd3a9d Give the barrier pool its own mutex to avoid a deadlock with transfer workers. 2024-11-11 10:31:12 -03:00
jadeharley2
a4d1d36c85 Fix inability to set TextureLayeredRD as TEXTURE_TYPE_CUBE or TEXTURE_TYPE_CUBE_ARRAY 2024-11-11 15:31:43 +03:00
tetrapod00
899f5151c3 Standardize terms for renderers in error strings
Use "Forward+", "Mobile", "Compatibility", and "renderer" or "rendering method".
2024-11-10 13:30:44 -08:00
Thaddeus Crews
9dfb36ca0c
Merge pull request #98549 from Chaosus/shader_renderer_states
Add renderer state defines to shader preprocessor
2024-11-10 12:13:04 -06:00
Thaddeus Crews
3cff32a92d
Merge pull request #98910 from darksylinc/matias-id_arm32
Force `RDD::id` to be always `uint64_t`
2024-11-10 12:12:53 -06:00
Thaddeus Crews
2b02143d35
Merge pull request #98307 from clayjohn/Light2D-shadow-projection
Precompute projection matrices when rendering 2D shadows
2024-11-10 12:12:14 -06:00
Matias N. Goldberg
e69a0c7d60 Force RID::id to be always uint64_t
On Vulkan, some handles are meant to always be u64, even on 32-bit
architectures such as arm32.

Fixes #98654
2024-11-06 20:03:56 -03:00
Thaddeus Crews
88d9903f6d
Merge pull request #86138 from EnlightenedOne/master
Fix Frustum Sky projection translation logic shearing
2024-11-04 21:52:07 -06:00
Thaddeus Crews
2450dee1bc
Merge pull request #93401 from Repiteo/style/clang-tidy-fixes
Style: Apply `clang-tidy` fixes
2024-11-04 21:52:05 -06:00
Thaddeus Crews
2b49543478
Merge pull request #98709 from darksylinc/matias-upsidedown-splash
Fix splash screen upside down on Android
2024-11-04 21:52:01 -06:00
Thaddeus Crews
edc60c63f1
Merge pull request #98701 from DarioSamo/rd-graph-improvements
Add dependency detection improvements to the render graph.
2024-11-04 21:51:58 -06:00
Thaddeus Crews
c68ec6c369
Merge pull request #98825 from DarioSamo/mobile-scs
Add multiple specialization constants to Forward+ and Mobile.
2024-11-04 21:51:55 -06:00
Thaddeus Crews
11b90086b7
Merge pull request #96705 from elmajime/camera_from_external_feed
Add support for external camera feed from external plugin on Android
2024-11-04 21:51:50 -06:00
Thaddeus Crews
bb5f390fb9
Style: Apply clang-tidy fixes (superficial)
• `modernize-use-bool-literals`, `modernize-use-nullptr`, and `readability-braces-around-statements`
2024-11-04 12:11:14 -06:00
Thaddeus Crews
89a311205f
Style: Apply clang-tidy fixes
• `modernize-use-default-member-init` and `readability-redundant-member-init`
• Minor adjustments to `.clang-tidy` to improve syntax & remove redundancies
2024-11-04 12:11:06 -06:00
Dario
53099c56f0 Add multiple specialization constants to Forward+ and Mobile. 2024-11-04 14:35:40 -03:00
EnlightenedOne
1d141ab32a Fix Frustum Sky projection translation logic, all pipelines, fixes 63863 2024-11-02 21:34:55 +00:00
Chaosus
5efe8ccdea Add prefix to struct member names in shader compiler 2024-11-02 12:13:23 +03:00
Dario
5216ef5f9c Add dependency detection improvements to the render graph.
- Buffers changing their usage are no longer treated as write usage unless the API requires it.
- Draw lists are not treated as being dependent on each other if their regions do not intersect despite both being write commands.
- Particles were tweaked to use different unused buffers to reduce dependencies.
2024-11-01 09:46:52 -03:00
Matias N. Goldberg
b9a2f108fc Fix splash screen upside down on Android
Fixes an issue introduced in #96439 (see
https://github.com/godotengine/godot/pull/96439#issuecomment-2447288702)

Godot was relying on Java's
activity.getWindowManager().getDefaultDisplay().getRotation(); to apply
pre-rotation but this is wrong.

First, getRotation() may temporarily return a different value from the
correct one; which is what was causing the splash screen to be upside
down. It would return -90 instead of 90 for the first rendered frame.

But unfortunately, the splash screen is just one frame rendered for a
very long time, so the error lingered for a long time for everyone to
see.

Second, to determine what rotation to use, we should be looking at what
Vulkan told us, which is the value we pass to
VkSurfaceTransformFlagBitsKHR::preTransform.

This commit removes the now-unnecessary
screen_get_internal_current_rotation() function (which was introduced by
#96439) and now saves the preTransform value in the swapchain.
2024-10-31 16:52:26 -03:00
maxime.chambefort
6f846eb5c5 Added external camera feed from external plugin on Android 2024-10-30 18:30:28 +01:00
Thaddeus Crews
6d09a20c82
Merge pull request #97247 from thimenesup/draw_indirect_rd
Add draw indirect to Rendering Device
2024-10-29 19:25:57 -05:00