Commit Graph

513 Commits

Author SHA1 Message Date
Thaddeus Crews
15d09a5767
Merge pull request #99149 from mrsaturnsan/set_max_fps_fix
Fix max FPS initialization
2024-11-13 08:34:21 -06:00
mrsaturnsan
4b94162320 Fix max FPS initialization
Remove unnecessary get_max_fps
2024-11-12 21:10:27 -06:00
Thaddeus Crews
bbde4ed324
Merge pull request #98883 from ducklin5/fix/VkResultError
Add vulkan error checks in command_queue_execute_and_present
2024-11-10 12:12:41 -06:00
Azeez Abass
ddf5c03f4b fix: add vulkan error checks in command_queue_execute_and_present
fix: add debug helper functoin and update messaging vulkan result
2024-11-06 22:13:20 +00:00
Trevor Davenport
a5070af460 Account for the case surface_capabilities.currentExtent is unset
Wayland in particular sets surface_capabilities.currentExtent.width to
the special value 0xFFFFFFFF, which is valid per spec.
Fixes #98779

It may also fix misc issues when resizing on all platforms.

Superseedes PR #98780 , thanks to user tdaven for the original patch.
PR #98780 would break Android support as it did not account that width
and height might need to be swapped.

Replaced manual swap by Godot's SWAP(), which indicates intention much
easier.
2024-11-05 11:52:26 -03: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
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
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
Clay John
748f4079e3
Merge pull request #96439 from darksylinc/matias-TheForge-pr03-rebased
Add Swappy & Pre-Transformed Swapchain
2024-10-29 12:34:40 -07:00
Matias N. Goldberg
aaa0e2fddf Add Swappy & Pre-Transformed Swapchain
- Adds Swappy for Android for stable frame pacing
- Implements pre-transformed Swapchain so that Godot's compositor is in
charge of rotating the screen instead of Android's compositor
(performance optimization for phones that don't have HW rotator)

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

The work was performed by collaboration of TheForge and Google. I am
merely splitting it up into smaller PRs and cleaning it up.

Changes from original PR:

- Removed "display/window/frame_pacing/android/target_frame_rate" option
to use Engine::get_max_fps instead.
- Target framerate can be changed at runtime using Engine::set_max_fps.
- Swappy is enabled by default.
- Added documentation.
- enable_auto_swap setting is replaced with swappy_mode.
2024-10-28 18:55:37 -03:00
Clay John
683d11a69f
Merge pull request #98279 from Calinou/vulkan-d3d12-silence-using-present-mode
Remove "Using present mode" verbose prints in Vulkan and Direct3D 12
2024-10-27 19:24:35 -07:00
Matias N. Goldberg
668c9b74e2 Fix race conditions in breadcrumbs
Adds "--accurate-breadcrumbs" CLI command

Additionally, leave out breadcrumbs code in non-debug, non-dev builds.
Fix regression introduced in #98388 where command_insert_breadcrumb() is
called even in non-debug builds.

Fixes #98338
2024-10-22 22:08:46 -03:00
Dario
4ad424234f Improve synchronization of rendering commands after changes from transfer queues.
Fix an error where barriers are expected to be inserted for the swap chain textures.
Add the relevant synchronization stages and accesses to resources between frames.
Fix an error where debug labels weren't finished correctly between frames.
Breadcrumbs are now behind an optional macro as they currently lead to synchronization errors which are harmless.
2024-10-21 11:27:56 -03:00
Dario
8c3e46b13b Move transitions of textures initialized by transfer workers to the main graphics queue.
Also adds a new possible texture layout and API trait to support a particular behavior in D3D12 where only the COMMON layout is supported in copy queues. Fixes #98158.
2024-10-18 09:15:25 -03:00
Hugo Locurcio
5ed10e3604 Remove "Using present mode" verbose prints in Vulkan and Direct3D 12
These messages were printed every time the swapchain was recreated
(e.g. on viewport size change), which could easily end up spamming
the output.

The chosen present mode is already displayed when using the Print FPS
project setting or command line argument.
2024-10-17 23:18:28 +02:00
Dario
e2c6daf7ef Implement asynchronous transfer queues, thread guards on RenderingDevice. Add ubershaders and rework pipeline caches for Forward+ and Mobile.
- Implements asynchronous transfer queues from PR #87590.
- Adds ubershaders that can run with specialization constants specified as push constants.
- Pipelines with specialization constants can compile in the background.
- Added monitoring for pipeline compilations.
- Materials and shaders can now be created asynchronously on background threads.
- Meshes that are loaded on background threads can also compile pipelines as part of the loading process.
2024-10-02 15:11:58 -03:00
Gergely Kis
146ba4106f Move Vulkan includes to a central godot_vulkan.h header
Also fixes Vulkan build problem with recent Clang.
2024-09-29 17:53:18 +02:00
Rémi Verschelde
a4c1804cab
Merge pull request #97483 from akien-mga/clang-format-19.1.0
CI: Update `clang-format` pre-commit hook to 19.1.0
2024-09-26 12:46:04 +02:00
Rémi Verschelde
c92a6c7e27
CI: Update clang-format pre-commit hook to 19.1.0 2024-09-26 11:46:12 +02:00
Thaddeus Crews
9f9ee0c813
SCons: Add unobtrusive type hints in SCons files 2024-09-25 09:34:35 -05:00
Sander
41fdc55b05 Vulkan: account for externally backed textures (i.e., created via texture_create_from_extension()), as such textures lack ownership information.
More info: #96832
2024-09-12 18:15:23 +03:00
Rémi Verschelde
61be39aed2
Merge pull request #96045 from darksylinc/matias-TheForge-pr02
Add `VK_EXT_astc_decode_mode` support
2024-09-02 12:13:04 +02: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
Matias N. Goldberg
d26c2f86cc Add VK_EXT_astc_decode_mode support
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-24 17:58:12 -03:00
Matias N. Goldberg
38ae58bda2 Fix build error in arm32
Fixes #95973
2024-08-23 12:52:47 -03: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
David Snopek
e018eabe1e Fix building with use_volk=yes on MacOS 2024-06-19 08:06:44 -05:00
Rémi Verschelde
940d629070
vulkan: Update all components to Vulkan SDK 1.3.183.0
Pass `VMA_ALLOCATOR_CREATE_KHR_MAINTENANCE5_BIT` to VMA when using Vulkan 1.3
features.

Co-authored-by: Pedro J. Estébanez <pedrojrulez@gmail.com>
2024-06-03 10:25:46 +02:00
Rémi Verschelde
f2796fa06d
Merge pull request #91769 from DarioSamo/d3d12_enhanced_barriers
Add support for enhanced barriers in D3D12.
2024-05-31 14:15:49 +02:00
bruvzg
628c81d2d9
[DisplayServer] Add method to check if window transparency is supported and enabled. 2024-05-23 15:23:18 +03:00
Dario
adabd14d08 Add support for enhanced barriers in D3D12.
Enables support for enhanced barriers if available.

Gets rid of the implementation of [CROSS_FAMILY_FALLBACK] in the D3D12 driver. The logic has been reimplemented at a higher level in RenderingDevice itself.

This fallback is only used if the RenderingDeviceDriver reports the API traits and the capability of sharing texture formats correctly. Aliases created in this way can only be used for sampling: never for writing. In most cases, the formats that do not support sharing do not support unordered access/storage writes in the first place.
2024-05-20 13:04:44 -03:00
Rémi Verschelde
68ac4ee358
Merge pull request #80232 from Calinou/vulkan-pipeline-cache-improve-messages
Improve warning messages related to Vulkan pipeline cache
2024-05-20 17:06:25 +02:00
Dario
d5789e09eb Add optional driver workaround to RenderingDevice for Adreno 6XX.
Co-authored-by: Clay John <claynjohn@gmail.com>
2024-05-13 10:20:31 -03:00
A Thousand Ships
86de59d60a
[Core] Add LocalVector::has for convenience 2024-05-06 18:03:37 +02:00
Bastiaan Olij
9042ddf19f Improvements to VRS/Foveated rendering 2024-05-03 17:20:30 +10:00
Dario
b95e18f557 Fix crash on compatibility fallback when vkCreateRenderPass2KHR is unavailable. 2024-04-25 14:03:02 -03:00
Hugo Locurcio
4a615924f8 Improve warning messages related to Vulkan pipeline cache
This gives better explanations on why the cache may have been invalidated,
along with usual consequences.

These messages have also been moved to verbose prints, as users
cannot do anything to resolve them specifically (so they are mostly
relevant to developers).
2024-03-26 22:42:27 +01:00
A Thousand Ships
79ba22a73f
Use Vector* component-wise min/max/clamp functions where applicable 2024-03-20 13:47:42 +01:00
Rémi Verschelde
ec55028f26
Merge pull request #89209 from RandomShaper/padding_for_dummies
Make shader binary alignment handling simpler and more robust
2024-03-06 13:17:09 +01:00
Pedro J. Estébanez
f77b4d155b Make shader binary alignment handling simpler and more robust
Bonus:
Also simplified the rounding to block size in image size calculations.
2024-03-06 11:48:23 +01:00
Rémi Verschelde
e74f4ea115
Vulkan: Don't warn about pipelines cache if missing
It used to warn when opening a new project because no cache pre-exists,
which isn't particularly helpful.

Also include the rendering method in the cache filename, as it differs
between Forward+ and Mobile for a same GPU.
2024-03-05 16:39:14 +01:00
Dario
ee2d8f68ba Merge execute and present commands for RenderingDeviceDriver. 2024-02-19 13:09:03 -03:00
Dario
24fcee6d67 Handle VK_SUBOPTIMAL_KHR as a valid error code to fix Android performance. 2024-02-15 10:59:36 -03:00
Dario
73eff10c76 Finish splitting functionality of the Vulkan and D3D12 backends into RenderingDeviceDriver. 2024-02-12 10:02:18 -03:00
Riteo
7e0f7d3abd Add Wayland support
Not everything is yet implemented, either for Godot or personal
limitations (I don't have all hardware in the world). A brief list of
the most important issues follows:

- Single-window only: the `DisplayServer` API doesn't expose enough
information for properly creating XDG shell windows.

- Very dumb rendering loop: this is very complicated, just know that
the low consumption mode is forced to 2000 Hz and some clever hacks are
in place to overcome a specific Wayland limitation. This will be
improved to the extent possible both downstream and upstream.

- Features to implement yet: IME, touch input, native file dialog,
drawing tablet (commented out due to a refactor), screen recording.

- Mouse passthrough can't be implement through a poly API, we need a
rect-based one.

- The cursor doesn't yet support fractional scaling.

- Auto scale is rounded up when using fractional scaling as we don't
have a per-window scale query API (basically we need
`DisplayServer::window_get_scale`).

- Building with `x11=no wayland=yes opengl=yes openxr=yes` fails.

This also adds a new project property and editor setting for selecting the
default DisplayServer to start, to allow this backend to start first in
exported projects (X11 is still the default for now). The editor setting
always overrides the project setting.

Special thanks to Drew Devault, toger5, Sebastian Krzyszkowiak, Leandro
Benedet Garcia, Subhransu, Yury Zhuravlev and Mara Huldra.
2024-01-30 16:44:47 +01:00
Dario
39f279710c Improve stage and slice tracking behavior of RenderingDeviceGraph to fix various synchronization issues. 2024-01-26 10:12:54 -03:00
Rémi Verschelde
1248fb9c18
Merge pull request #86855 from RandomShaper/fix_vk_get_image
Fix determination of copyable layout for compressed textures in Vulkan
2024-01-15 13:25:24 +01:00
Dario
cc4d39b0c1 Acyclic Command Graph for RenderingDevice.
Adds a new system to automatically reorder commands, perform layout transitions and insert synchronization barriers based on the commands issued to RenderingDevice.
2024-01-08 14:54:56 -03:00
Bastiaan Olij
d6caa69e11 Skip swapchain logic if there is nothing to present (Android OpenXR) 2024-01-08 21:51:04 +11:00