Commit Graph

499 Commits

Author SHA1 Message Date
Pedro J. Estébanez
7e598642d2 Bump version of Vulkan RD binary shader format 2023-10-18 17:45:10 +02:00
A Thousand Ships
f18aa00e85 Replace ERR_FAIL_COND with ERR_FAIL_NULL where applicable 2023-10-08 17:23:33 +02:00
Rémi Verschelde
68926d5919
Merge pull request #81827 from darksylinc/matias-vkfeatures-opt-in
Opt-in to Vulkan features we actually use.
2023-10-05 22:49:21 +02:00
clayjohn
51ed3aef63 Vertex and attribute compression to reduce the size of the vertex format.
This allows Godot to automatically compress meshes to save a lot of bandwidth.

In general, this requires no interaction from the user and should result in
no noticable quality loss.

This scheme is not backwards compatible, so we have provided an upgrade
mechanism, and a mesh versioning mechanism.

Existing meshes can still be used as a result, but users can get a
performance boost by reimporting assets.
2023-10-05 12:02:23 -06:00
Lyuma
1d34033143 Workaround crash due to null shader when running XR project with --xr-mode off 2023-10-02 06:12:01 -07:00
A Thousand Ships
517e9f8aef [Modules] Replace ERR_FAIL_COND with ERR_FAIL_NULL where applicable 2023-09-26 16:44:52 +02:00
Dario
057367bf4f Add FidelityFX Super Resolution 2.2 (FSR 2.2.1) support.
Introduces support for FSR2 as a new upscaler option available from the project settings. Also introduces an specific render list for surfaces that require motion and the ability to derive motion vectors from depth buffer and camera motion.
2023-09-25 10:37:47 -03:00
Matias N. Goldberg
d5f913ce1d Opt-in to Vulkan features we actually use. 2023-09-24 21:05:48 -03:00
Shawn Wallace
b12ed82c04 Expose texture_create_from_extension to GDExtension 2023-09-23 16:57:12 -04:00
Pedro J. Estébanez
bda6fc5d2f Polish a few things in Vulkan RD 2023-09-19 18:10:46 +02:00
Matias N. Goldberg
cfeccc2146 Fix validation error when using pipeline cache control
PR #80296 introduced a regression because it checks if the
VK_EXT_pipeline_creation_cache_control extension has been enabled before
using it, but turns out the process is a bit more convoluted than that
(a Vulkan driver may support the extension but then say the feature is
not supported)
2023-09-16 18:59:04 -03:00
A Thousand Ships
3565d1bf7e [Drivers,Platform] Replace ERR_FAIL_COND with ERR_FAIL_NULL where applicable 2023-09-12 20:13:32 +02:00
Pedro J. Estébanez
bcf33cfbd1 Enhance Vulkan PSO caching 2023-08-30 12:00:54 +02:00
Matias N. Goldberg
677d2d6fb0 Fix missing EARLY_FRAGMENT_TESTS_BIT barrier flags 2023-08-27 19:38:34 -03:00
bitsawer
3daa19dd95 Fix Vulkan texture update 2023-08-19 12:18:54 +03:00
Hugo Locurcio
ce57c2379c
Abort on startup with a visible alert if required Vulkan features are missing 2023-08-17 14:48:36 +02:00
Rémi Verschelde
c1dbc3dd04
Merge pull request #80288 from pkpro/memcpy_into_nullptr
Vulkan: Fix sanitizers error with empty shader name
2023-08-17 12:29:29 +02:00
Rémi Verschelde
d1b8e9abd6
Merge pull request #80571 from darksylinc/matias-resize-window-fix
Fix validation error when resizing window
2023-08-16 09:13:53 +02:00
Rémi Verschelde
04c2bc5a37
Merge pull request #80424 from DarioSamo/rd-buffer-copy-vulkan
Add `buffer_copy` method to RenderingDevice
2023-08-16 09:13:06 +02:00
Matias N. Goldberg
0b09fdd96c Fix validation error when resizing window
Sometimes when resizing the window we may get the following validation
error:

ERROR: VALIDATION - Message Id Number: -370888023 | Message Id Name:
VUID-vkAcquireNextImageKHR-semaphore-01286
	Validation Error: [ VUID-vkAcquireNextImageKHR-semaphore-01286 ]
Object 0: handle = 0xdcc8fd0000000012, type = VK_OBJECT_TYPE_SEMAPHORE;
| MessageID = 0xe9e4b2a9 | vkAcquireNextImageKHR: Semaphore must not be
currently signaled or in a wait state. The Vulkan spec states: If
semaphore is not VK_NULL_HANDLE it must be unsignaled
(https://vulkan.lunarg.com/doc/view/1.2.198.1/linux/1.2-extensions/vkspec.html#VUID-vkAcquireNextImageKHR-semaphore-01286)

In VulkanContext::prepare_buffers the problem was that
vkAcquireNextImageKHR returned VK_SUBOPTIMAL_KHR but it already signaled
the semaphore (because it is possible to continue normally with a
VK_SUBOPTIMAL_KHR result).

Then we recreate the swapchain and reuse the
w->image_acquired_semaphores[frame_index] which is in an inconsistent
state.

Fixed by recreating the semamphores along the swapchain.

Fix #80570
2023-08-15 20:57:49 -03:00
sakrel
80a36ff985 Add support for GLSL source-level debugging with RenderDoc (--generate-spirv-debug-info) 2023-08-12 14:56:49 +02:00
Dario
0d7deca4e2 Add buffer_copy method to RenderingDevice interface and an implementation for the Vulkan driver.
Direct buffer copies are required to perform certain operations more efficiently, as the only current alternative is to download the buffer to the CPU and upload it again. As the first use case, the new function is used when enabling motion vectors on multimeshes.
2023-08-12 09:38:39 -03:00
Pavel Kraynyukhov
77b02359c9
Vulkan: Fix sanitizers error with empty shader name
Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
2023-08-09 12:12:56 +02:00
clayjohn
558f4b7559 Initialize shader placeholders up front
Then use the placeholder to create the shader instead of swapping RIDs
This fixes a false positive that reported leaked shaders
2023-08-03 16:13:33 +02:00
Yuri Sizov
eda04c5658 Merge pull request #80071 from darksylinc/matias-fixes2
Fix validation layer warnings
2023-08-01 17:26:04 +02:00
Yuri Sizov
1c40263665 Merge pull request #79606 from clayjohn/ShaderRD-compilation-groups
Shader rd compilation groups
2023-08-01 17:25:16 +02:00
Matias N. Goldberg
4ce41495b1 Fix validation layer warnings
1. Validation layers on Windows were complaining w/
VUID-VkSwapchainCreateInfoKHR-surface-01270 that we were not calling
vkGetPhysicalDeviceSurfaceSupportKHR before vkCreateSwapchainKHR.

2. Godot was only calling vkGetPhysicalDeviceSurfaceSupportKHR at
startup, but it should be doing this for every window w/ a new surface
it wants to create, not just the first one.
- In practice this will likely not make a difference. If
vkGetPhysicalDeviceSurfaceSupportKHR returns false after initialization,
there's nothing we can do about it and it is likely because something
else went terribly wrong, which is why the error message is worded like
that.
- This is mostly to shut up validation layers. Though technically,
the layers are right.

3. Do not call vkGetPhysicalDeviceSurfaceSupportKHR on queues we don't
even plan on ever using. We don't know how drivers will react to that
(e.g. they may preemptetively allocate resources to support presentation
on exotic queues, instead of just saying no). Just behave like every
other Vulkan app out there.
2023-07-30 17:07:27 -03:00
Matias N. Goldberg
472226422e Fix uninitialized variable ending up sent to Vulkan
The first time a shader is compiled Godot performs the following:

```cpp
for (uint32_t i = 0; i < SHADER_STAGE_MAX; i++) {
	if
(spirv_data.push_constant_stages_mask.has_flag((ShaderStage)(1 << i))) {
		binary_data.push_constant_vk_stages_mask |=
shader_stage_masks[i];
	}
}
```

However binary_data.push_constant_vk_stages_mask is never initialized to
0 and thus contains garbage data or'ed with the good data.

This value is used by push constants (and many other things) thus it can
be a big deal.

Fortunately because the relevant flags are always guaranteed to be set
(but not guaranteed to be unset), the damage is restricted to:

1. Performance (unnecessary flushing & over-excessive barriers)
2. Overwriting push descriptors already set (this would be serious,
doesn't seem to be an issue)
3. Driver implementations going crazy when they see bits set they don't
expect (unknown if this is an issue)

This uninitialized value is later saved into the binary cache.

Valgrind is able to detect this bug on the first run, but not on the
subsequent ones because they data comes from a file.

cache_file_version has been bumped to force rebuild of all cached
shaders. Because the ones generated so far are compromised.
2023-07-29 18:28:33 -03:00
Bastiaan Olij
63d6e9c557 Add custom texture create function 2023-07-26 20:46:34 +10:00
Florian Kothmeier
7f7a2b2557
Fix dangling pointers in _clean_up_swap_chain 2023-07-25 14:41:57 +02:00
bitsawer
5d18e2ee00 Fix Vulkan multithreaded compute list and GPU particle processing 2023-07-24 12:56:55 +03:00
clayjohn
e970f5249c Add Shader compile groups to RD Shader system
This allows us to specify a subset of variants to compile at load time and conditionally other variants later.

This works seamlessly with shader caching.

Needed to ensure that users only pay the cost for variants they use
2023-07-21 16:42:30 +02:00
Marc Gilleron
8722cbc0a0 Add missing thread-safe method macros to RD Vulkan submit and sync 2023-07-18 20:04:51 +01:00
Bastiaan Olij
a22f495a3c Split raster barrier into vertex and fragment barrier 2023-07-15 12:30:32 +10:00
Rémi Verschelde
1453dc9d5d
Merge pull request #79143 from clayjohn/wayland-menu
Avoid freeze when interacting with menus on Wayland by re-aquiring next swapchain image after updating swapchain
2023-07-09 12:24:07 +02:00
clayjohn
df021b5063 Avoid freeze when interacting with menus on Wayland by re-aquiring next swapchain image after updating swapchain 2023-07-07 10:19:28 +02:00
Joe Marshall
c52fadbe75
fix threading bug in vulkan rendering device 2023-06-28 13:50:25 +01:00
jpcerrone
bd786ce0d9 Fix for Win+M crashing the editor
Fixes #77790
Adds missing 'break' statement to 'VulkanContext::prepare_buffers' function.
It was mistakenly removed in #72859
2023-06-14 14:34:09 -03:00
Bastiaan Olij
6dd47e232b Expose RD::texture_native_handle 2023-06-14 09:58:08 +10:00
Rémi Verschelde
3dd0307f3f
Merge pull request #76348 from warriormaster12/pipeline-cache
Implement Vulkan pipeline caching
2023-06-01 00:40:33 +02:00
warriormaster12
dded713dc0 Implement Vulkan pipeline caching 2023-05-31 22:24:18 +03:00
Rémi Verschelde
8b0530be64
Merge pull request #77022 from sakrel/fix_buffer_get_data
RenderingDeviceVulkan::buffer_get_data: Use draw command buffer instead of setup command buffer
2023-05-24 08:47:19 +02:00
Rémi Verschelde
b917f748b5
Merge pull request #75945 from Calinou/renderingdevice-finalaction-fix-typo
Fix typo in FinalAction `switch` statement in RenderingDevice
2023-05-24 08:46:01 +02:00
sakrel
f52c151fcf RenderingDeviceVulkan::buffer_get_data: Use draw command buffer instead of setup command buffer 2023-05-12 23:25:20 +02:00
warriormaster12
10797d58dd fixed a query pool validation error 2023-05-11 17:17:23 +03:00
Rémi Verschelde
564d1b34e0
Merge pull request #74711 from BastiaanOlij/add_texture_native_handle
Provide access to internal graphics handles for textures
2023-05-09 19:28:26 +02:00
Bastiaan Olij
c328676d96 For GDExternal use, provides access to internal graphics handles for textures 2023-05-09 13:47:22 +10:00
Pedro J. Estébanez
6465432570 Save cluster render shader from being optimized out entirely 2023-05-08 18:39:49 +02:00
Rémi Verschelde
392fdd106d
Merge pull request #75937 from RandomShaper/threaded_render_load
Allow creation of rendering buffers at any time
2023-05-08 13:52:33 +02:00
Hugo Locurcio
5056c427d3
Improve RenderingServer, RenderingDevice, ShaderGlobalsOverride documentation
This brings the overall class reference completion percentage from 87% to 92%.
2023-05-06 22:40:32 +02:00
Pedro J. Estébanez
09aa1bbdb3 Fix unsupported sampler filter used for voxel GI 2023-04-26 20:54:06 +02:00
Pedro J. Estébanez
882b869220 Fix issues with Vulkan layout transitions 2023-04-24 12:24:24 +02:00
Hugo Locurcio
dd53037f74
Fix typo in FinalAction switch statement in RenderingDevice 2023-04-11 18:44:12 +02:00
Pedro J. Estébanez
d4c46f15ae Allow creation of rendering buffers at any time 2023-04-11 16:33:47 +02:00
Rémi Verschelde
253b4875f3
Merge pull request #72859 from clayjohn/VK-suboptimal
Recreate swap chain when suboptimal to avoid error spam
2023-04-03 15:57:43 +02:00
bruvzg
09465f3fe6
Remove (or make verbose only) various debug prints. 2023-03-20 08:14:18 +02:00
clayjohn
06042a23b6 Avoid overflow when calculating ptr address for 3D textures in RenderingDevice texture update 2023-03-06 15:46:40 -08:00
ChibiDenDen
d104d8447b
Fix use-after-free for VkAttachmentReference
In the flow where VK_KHR_CREATE_RENDERPASS_2_EXTENSION_NAME does not exist
VkAttachmentReference are created inside a loop and their backing buffer is referenced in the subpass object.
the VkAttachmentReference vectors are freed once the loop exists, causing the subpass to point to freed data.

Add all the VkAttachmentReference to a vector in the scope of the entire function, to ensure they are not freed until vkCreateRenderPass is called
2023-02-20 11:54:52 +02:00
Wiktor Kocielski
b66f3846b4 Make present mode info message print only on change
Styling fix
2023-02-12 16:08:11 +03:00
sakrel
089dbecef4 Make draw command labels thread safe 2023-02-10 21:27:31 +01:00
Rémi Verschelde
ed85a2c8ce
Merge pull request #70663 from EpEpDragon/feature_buffer_get_data_size_option
Add optional size parameter to the RenderDevice buffer_get_data method.
2023-02-10 18:49:28 +01:00
clayjohn
22291d7ae2 Add more debug information to swapchain errors in Vulkan context 2023-02-07 13:52:36 -08:00
clayjohn
c9d2bc91aa Recreate swap chain when suboptimal to avoid error spam 2023-02-07 13:43:14 -08:00
Hugo Locurcio
f3e8300b50
Print name of Vulkan rendering method on startup
This helps troubleshooting as the CLI logs now distinguish between
Forward+ and Forward Mobile.
2023-02-03 13:01:48 +01:00
Bastiaan Olij
093289364f Add layer slice support to render device and render buffers 2023-02-03 09:48:56 +11:00
clayjohn
5931d504c1 Add a few more checks to ensure that unsupported image formats are not used in the mobile renderer 2023-01-23 12:38:09 -08:00
Rémi Verschelde
591100cbd6
Merge pull request #70429 from BastiaanOlij/check_more_vulkan_extensions
Enabling additional vulkan extension and adding further checks
2023-01-23 20:10:19 +01:00
Rémi Verschelde
5b1df48c6c
Convert en_GB spelling to en_US with codespell 2023-01-23 11:02:20 +01:00
kobewi
615c517034 Use range iterators in LocalVector loops 2023-01-21 18:44:42 +01:00
Bastiaan Olij
318656d326 Enabling additional vulkan extension and adding further checks 2023-01-15 14:49:15 +11:00
Pedro J. Estébanez
5ca2ba45f1 Make inclusion of Godot version in shader hash universal 2023-01-09 17:47:02 +01:00
EpEpDragon
36d02882b9 Added optional offset and size parameter to RenderDevice buffer_get_data method 2023-01-06 17:08:37 +02:00
Rémi Verschelde
d95794ec8a
One Copyright Update to rule them all
As many open source projects have started doing it, we're removing the
current year from the copyright notice, so that we don't need to bump
it every year.

It seems like only the first year of publication is technically
relevant for copyright notices, and even that seems to be something
that many companies stopped listing altogether (in a version controlled
codebase, the commits are a much better source of date of publication
than a hardcoded copyright statement).

We also now list Godot Engine contributors first as we're collectively
the current maintainers of the project, and we clarify that the
"exclusive" copyright of the co-founders covers the timespan before
opensourcing (their further contributions are included as part of Godot
Engine contributors).

Also fixed "cf." Frenchism - it's meant as "refer to / see".
2023-01-05 13:25:55 +01:00
Rémi Verschelde
f318d60e06
Merge pull request #65376 from reduz/astc-support
Implement basic ASTC support
2022-12-20 12:44:30 +01:00
Juan Linietsky
71d21c7ccb Implement basic ASTC support
Implements basic ASTC support:
* Only 4x4 and 8x8 block sizes.
* Other block sizes are too complex to handle for Godot image compression handling. May be implemented sometime in the future.

The need for ASTC is mostly for the following use cases:
* Implement a high quality compression option for textures on mobile and M1 Apple hardware.
* For this, the 4x4 is sufficient, since it uses the same size as BPTC.

ASTC supports a lot of block sizes, but the benefit of supporting most of them is slim, while the implementation complexity in Godot is very high.
Supporting only 4x4 (and 8x8) solves the real problem, which is lack of a BPTC alternative on hardware where it's missing.

Note: This does not yet support encoding on import, an ASTC encoder will need to be added.
2022-12-20 11:26:30 +01:00
Clay John
aa8a899f52
Merge pull request #70104 from RandomShaper/vk_dev_asserts
Replace certain sanity checks with proper dev-only assertions in Vulkan RD
2022-12-15 08:22:17 -08:00
Pedro J. Estébanez
af6189711e Replace certain sanity checks with proper dev-only assertions in Vulkan RD 2022-12-15 12:34:08 +01:00
Yuri Rubinsky
807632a90c Changed STORAGE_BUFFER_USAGE_DISPATCH_INDIRECT type to enum flags 2022-12-15 14:10:37 +03:00
Rémi Verschelde
762c6d4b36
Merge pull request #69709 from RandomShaper/refactor_spirv_reflection
Refactor SPIR-V reflection into a generic RenderingDevice feature
2022-12-15 09:21:35 +01:00
Pedro J. Estébanez
14e301467e Refactor SPIR-V reflection into a generic RenderingDevice feature 2022-12-12 14:14:53 +01:00
Pedro J. Estébanez
c985ee985f Tidy up some aspects of Vulkan RD 2022-12-12 14:14:53 +01:00
Rémi Verschelde
f79c034713
Merge pull request #69635 from BastiaanOlij/fix_get_buffer
Fix barrier on buffer_get_data
2022-12-12 11:44:29 +01:00
Yuri Rubinsky
6e48db69a3 Changed RD::PipelineDynamicStateFlags type to enum flags 2022-12-11 15:37:35 +03:00
Bastiaan Olij
d79f692cae Fix barrier on buffer_get_data 2022-12-06 22:44:35 +11:00
Bastiaan Olij
2562c06032 Fix issue where we should be using device supported version instead of instance version for Vulkan 2022-12-05 10:12:07 +11:00
Yuri Rubinsky
5934eef44c Changed RenderingDevice::TextureUsageBits type to enum flags 2022-11-26 13:08:07 +03:00
Bastiaan Olij
a479f5af22 Improve logic for detecting and tracking extensions 2022-11-24 21:48:16 +11:00
Rémi Verschelde
e7418cac3d
Merge pull request #68942 from Chaosus/barrier_mask_flags
Expose `BarrierMask` as flags enum in `RenderingDevice`
2022-11-22 08:31:12 +01:00
Yuri Rubinsky
acaf38cfbc Expose BarrierMask as flags enum in RenderingDevice 2022-11-22 09:45:20 +03:00
Rémi Verschelde
a9a75e643e
Merge pull request #68527 from pkdawson/vertex-array-offsets
Add `offsets` parameter to RenderingDevice::vertex_array_create
2022-11-21 11:43:28 +01:00
Bastiaan Olij
616ba8745f Fix VRS issues 2022-11-17 00:32:42 +11:00
Hugo Locurcio
efe3220b2e
Fix periods in editor strings and messages
- Ensure all strings with ellipsis end with 3 periods instead of 2.
- Fix extraneous period in "Error calling from signal '...' to callable"
  messages.
2022-11-14 19:36:36 +01:00
Patrick Dawson
d7136f2d51 Add offsets parameter to RenderingDevice::vertex_array_create 2022-11-11 15:45:36 +01:00
kobewi
d9f066d5fa Remove duplicate project settings definitions 2022-11-08 01:29:39 +01:00
Patrick Dawson
382f0f97d6 RenderingDevice: Fix usage of index offset 2022-11-05 21:03:32 +01:00
Rémi Verschelde
c98d6142d0
Merge pull request #68102 from BastiaanOlij/fix_render_issues_xr
Fix several render issues found while debugging XR
2022-11-03 22:37:42 +01:00
Rémi Verschelde
f7c611ab71
Style: Misc docs and comment style and language fixes
- Removed empty paragraphs in XML.
- Consistently use bold style for "Example:", on a new line.
- Fix usage of `[code]` when hyperlinks could be used (`[member]`, `[constant]`).
- Fix invalid usage of backticks for inline code in BBCode.
- Fix some American/British English spelling inconsistencies.
- Other minor fixes spotted along the way, including typo fixes with codespell.
- Don't specify `@GlobalScope` for `enum` and `constant`.
2022-11-02 19:01:18 +01:00
Bastiaan Olij
a4e58ec84a Fix several render issues found while debugging XR 2022-11-01 13:27:03 +11:00
Rémi Verschelde
5947f22be9
Merge pull request #67578 from KoBeWi/GEDITOR
Unify usage of GLOBAL/EDITOR_GET
2022-10-31 13:15:58 +01:00
Rémi Verschelde
e12043ae3a
Merge pull request #67729 from Riteo/workaround-extension-feature-bug
Check for a Vulkan extension before checking its features
2022-10-31 10:48:35 +01:00