Skip to content

Commit 2687833

Browse files
committed
Merge pull request godotengine#102454 from DarioSamo/rd-async-fixes
Fix erroneous logic when flushes are involved on RD async methods.
2 parents ca3e268 + 1bba9db commit 2687833

24 files changed

+134
-75
lines changed

.github/workflows/linux_builds.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
artifact: false
7575
cache-limit: 5
7676

77-
- name: Template w/ Mono (target=template_release, tests=yes)
77+
- name: Template w/ Mono, release (target=template_release, tests=yes)
7878
cache-name: linux-template-mono
7979
target: template_release
8080
sconsflags: module_mono_enabled=yes
@@ -84,6 +84,16 @@ jobs:
8484
artifact: true
8585
cache-limit: 1
8686

87+
- name: Template w/ Mono, debug (target=template_debug, tests=yes)
88+
cache-name: linux-template-mono-debug
89+
target: template_debug
90+
sconsflags: module_mono_enabled=yes
91+
bin: ./bin/godot.linuxbsd.template_debug.x86_64.mono
92+
build-mono: false
93+
tests: true
94+
artifact: true
95+
cache-limit: 1
96+
8797
- name: Minimal template (target=template_release, tests=yes, everything disabled)
8898
cache-name: linux-template-minimal
8999
target: template_release

doc/classes/CanvasItem.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@
535535
<description>
536536
Returns [code]true[/code] if the node is present in the [SceneTree], its [member visible] property is [code]true[/code] and all its ancestors are also visible. If any ancestor is hidden, this node will not be visible in the scene tree, and is therefore not drawn (see [method _draw]).
537537
Visibility is checked only in parent nodes that inherit from [CanvasItem], [CanvasLayer], and [Window]. If the parent is of any other type (such as [Node], [AnimationPlayer], or [Node3D]), it is assumed to be visible.
538-
[b]Note:[/b] This method does not take [member visibility_layer] into account, so even if this method returns [code]true[/code] the node might end up not being rendered.
538+
[b]Note:[/b] This method does not take [member visibility_layer] into account, so even if this method returns [code]true[/code], the node might end up not being rendered.
539539
</description>
540540
</method>
541541
<method name="make_canvas_position_local" qualifiers="const">

doc/classes/Node3D.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@
117117
<return type="bool" />
118118
<description>
119119
Returns [code]true[/code] if the node is present in the [SceneTree], its [member visible] property is [code]true[/code] and all its ancestors are also visible. If any ancestor is hidden, this node will not be visible in the scene tree.
120+
Visibility is checked only in parent nodes that inherit from [Node3D]. If the parent is of any other type (such as [Node], [AnimationPlayer], or [Node2D]), it is assumed to be visible.
121+
[b]Note:[/b] This method does not take [member VisualInstance3D.layers] into account, so even if this method returns [code]true[/code], the node might end up not being rendered.
120122
</description>
121123
</method>
122124
<method name="look_at">

drivers/metal/metal_device_properties.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ struct API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)) MetalFeatures {
9393
bool needs_arg_encoders = true;
9494
bool metal_fx_spatial = false; /**< If true, Metal FX spatial functions are supported. */
9595
bool metal_fx_temporal = false; /**< If true, Metal FX temporal functions are supported. */
96+
bool supports_gpu_address = false; /**< If true, referencing a GPU address in a shader is supported. */
9697
};
9798

9899
struct MetalLimits {

drivers/metal/metal_device_properties.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@
9999
features.supports32BitMSAA = p_device.supports32BitMSAA;
100100
}
101101

102+
if (@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)) {
103+
features.supports_gpu_address = true;
104+
}
105+
102106
features.hostMemoryPageSize = sysconf(_SC_PAGESIZE);
103107

104108
for (SampleCount sc = SampleCount1; sc <= SampleCount64; sc <<= 1) {

drivers/metal/metal_objects.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
#import <zlib.h>
6666
#import <initializer_list>
6767
#import <optional>
68-
#import <spirv.hpp>
6968

7069
// These types can be used in Vector and other containers that use
7170
// pointer operations not supported by ARC.
@@ -563,7 +562,7 @@ struct API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)) BindingInfo {
563562
MTLBindingAccess access = MTLBindingAccessReadOnly;
564563
MTLResourceUsage usage = 0;
565564
MTLTextureType textureType = MTLTextureType2D;
566-
spv::ImageFormat imageFormat = spv::ImageFormatUnknown;
565+
int imageFormat = 0;
567566
uint32_t arrayLength = 0;
568567
bool isMultisampled = false;
569568

drivers/metal/rendering_device_driver_metal.mm

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ _FORCE_INLINE_ MTLSize mipmapLevelSizeFromSize(MTLSize p_size, NSUInteger p_leve
164164
id<MTLBuffer> obj = rid::get(p_buffer);
165165
return obj.gpuAddress;
166166
} else {
167+
#if DEV_ENABLED
168+
WARN_PRINT_ONCE("buffer_get_device_address is not supported on this OS version.");
169+
#endif
167170
return 0;
168171
}
169172
}
@@ -355,7 +358,7 @@ _FORCE_INLINE_ MTLSize mipmapLevelSizeFromSize(MTLSize p_size, NSUInteger p_leve
355358

356359
// Check if it is a linear format for atomic operations and therefore needs a buffer,
357360
// as generally Metal does not support atomic operations on textures.
358-
bool needs_buffer = is_linear || (p_format.array_layers == 1 && p_format.mipmaps == 1 && p_format.texture_type == TEXTURE_TYPE_2D && flags::any(p_format.usage_bits, TEXTURE_USAGE_STORAGE_BIT) && (p_format.format == DATA_FORMAT_R32_UINT || p_format.format == DATA_FORMAT_R32_SINT));
361+
bool needs_buffer = is_linear || (p_format.array_layers == 1 && p_format.mipmaps == 1 && p_format.texture_type == TEXTURE_TYPE_2D && flags::any(p_format.usage_bits, TEXTURE_USAGE_STORAGE_BIT) && (p_format.format == DATA_FORMAT_R32_UINT || p_format.format == DATA_FORMAT_R32_SINT || p_format.format == DATA_FORMAT_R32G32_UINT || p_format.format == DATA_FORMAT_R32G32_SINT));
359362

360363
id<MTLTexture> obj = nil;
361364
if (needs_buffer) {
@@ -2033,10 +2036,6 @@ void deserialize(BufReader &p_reader) {
20332036

20342037
CompilerMSL::Options msl_options{};
20352038
msl_options.set_msl_version(version_major, version_minor);
2036-
if (version_major == 3 && version_minor >= 1) {
2037-
// TODO(sgc): Restrict to Metal 3.0 for now, until bugs in SPIRV-cross image atomics are resolved.
2038-
msl_options.set_msl_version(3, 0);
2039-
}
20402039
bin_data.msl_version = msl_options.msl_version;
20412040
#if TARGET_OS_OSX
20422041
msl_options.platform = CompilerMSL::Options::macOS;
@@ -2063,9 +2062,9 @@ void deserialize(BufReader &p_reader) {
20632062
msl_options.argument_buffers = false;
20642063
bin_data.set_uses_argument_buffers(false);
20652064
}
2066-
2067-
msl_options.force_active_argument_buffer_resources = true; // Same as MoltenVK when using argument buffers.
2068-
// msl_options.pad_argument_buffer_resources = true; // Same as MoltenVK when using argument buffers.
2065+
msl_options.force_active_argument_buffer_resources = true;
2066+
// We can't use this, as we have to add the descriptor sets via compiler.add_msl_resource_binding.
2067+
// msl_options.pad_argument_buffer_resources = true;
20692068
msl_options.texture_buffer_native = true; // Enable texture buffer support.
20702069
msl_options.use_framebuffer_fetch_subpasses = false;
20712070
msl_options.pad_fragment_output_components = true;
@@ -4036,7 +4035,7 @@ bool isArrayTexture(MTLTextureType p_type) {
40364035
case SUPPORTS_FRAGMENT_SHADER_WITH_ONLY_SIDE_EFFECTS:
40374036
return true;
40384037
case SUPPORTS_BUFFER_DEVICE_ADDRESS:
4039-
return false;
4038+
return device_properties->features.supports_gpu_address;
40404039
case SUPPORTS_METALFX_SPATIAL:
40414040
return device_properties->features.metal_fx_spatial;
40424041
case SUPPORTS_METALFX_TEMPORAL:

editor/plugins/animation_library_editor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ void AnimationLibraryEditor::_button_pressed(TreeItem *p_item, int p_column, int
605605
file_popup->add_separator();
606606
file_popup->add_item(TTR("Open in Inspector"), FILE_MENU_EDIT_LIBRARY);
607607
Rect2 pos = tree->get_item_rect(p_item, 1, 0);
608-
Vector2 popup_pos = tree->get_screen_transform().xform(pos.position + Vector2(0, pos.size.height)) - tree->get_scroll();
608+
Vector2 popup_pos = tree->get_screen_transform().xform(pos.position + Vector2(0, pos.size.height));
609609
file_popup->popup(Rect2(popup_pos, Size2()));
610610

611611
file_dialog_animation = StringName();
@@ -645,7 +645,7 @@ void AnimationLibraryEditor::_button_pressed(TreeItem *p_item, int p_column, int
645645
file_popup->add_separator();
646646
file_popup->add_item(TTR("Open in Inspector"), FILE_MENU_EDIT_ANIMATION);
647647
Rect2 pos = tree->get_item_rect(p_item, 1, 0);
648-
Vector2 popup_pos = tree->get_screen_transform().xform(pos.position + Vector2(0, pos.size.height)) - tree->get_scroll();
648+
Vector2 popup_pos = tree->get_screen_transform().xform(pos.position + Vector2(0, pos.size.height));
649649
file_popup->popup(Rect2(popup_pos, Size2()));
650650

651651
file_dialog_animation = anim_name;

editor/plugins/canvas_item_editor_plugin.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_no
623623
return;
624624
}
625625
xform = vp->get_popup_base_transform();
626-
if (!vp->get_visible_rect().has_point(xform.xform_inv(p_pos))) {
626+
if (!vp->get_visible_rect().has_point(xform.affine_inverse().xform(p_pos))) {
627627
return;
628628
}
629629
}
@@ -726,7 +726,7 @@ void CanvasItemEditor::_find_canvas_items_in_rect(const Rect2 &p_rect, Node *p_n
726726
return;
727727
}
728728
xform = vp->get_popup_base_transform();
729-
if (!vp->get_visible_rect().intersects(xform.xform_inv(p_rect))) {
729+
if (!vp->get_visible_rect().intersects(xform.affine_inverse().xform(p_rect))) {
730730
return;
731731
}
732732
}

editor/window_wrapper.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,11 @@ void WindowWrapper::restore_window_from_saved_position(const Rect2 p_window_rect
261261
window_rect = Rect2i(window_rect.position * screen_ratio, window_rect.size * screen_ratio);
262262
window_rect.position += real_screen_rect.position;
263263

264+
// Make sure to restore the window if the user minimized it the last time it was displayed.
265+
if (window->get_mode() == Window::MODE_MINIMIZED) {
266+
window->set_mode(Window::MODE_WINDOWED);
267+
}
268+
264269
// All good, restore the window.
265270
window->set_current_screen(p_screen);
266271
if (window->is_visible()) {

0 commit comments

Comments
 (0)