Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 46ad11b

Browse files
committed
Gate vk config initialization
1 parent be42b6e commit 46ad11b

File tree

3 files changed

+68
-48
lines changed

3 files changed

+68
-48
lines changed

shell/platform/embedder/tests/embedder_config_builder.cc

Lines changed: 65 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
#include "flutter/shell/platform/embedder/tests/embedder_test_context_gl.h"
1414
#endif
1515

16-
//#ifdef SHELL_ENABLE_VULKAN
16+
#ifdef SHELL_ENABLE_VULKAN
1717
#include "flutter/shell/platform/embedder/tests/embedder_test_context_vulkan.h"
1818
#include "flutter/vulkan/vulkan_device.h"
19-
//#endif
19+
#endif
2020

2121
#ifdef SHELL_ENABLE_METAL
2222
#include "flutter/shell/platform/embedder/tests/embedder_test_context_metal.h"
@@ -74,53 +74,14 @@ EmbedderConfigBuilder::EmbedderConfigBuilder(
7474
};
7575
#endif
7676

77-
#ifdef SHELL_ENABLE_VULKAN
78-
vulkan_renderer_config_.struct_size = sizeof(FlutterVulkanRendererConfig);
79-
vulkan_renderer_config_.instance =
80-
static_cast<EmbedderTestContextVulkan&>(context)
81-
.application_->GetInstance();
82-
vulkan_renderer_config_.physical_device =
83-
static_cast<EmbedderTestContextVulkan&>(context)
84-
.logical_device_->GetPhysicalDeviceHandle();
85-
vulkan_renderer_config_.device =
86-
static_cast<EmbedderTestContextVulkan&>(context)
87-
.logical_device_->GetHandle();
88-
vulkan_renderer_config_.queue_family_index =
89-
static_cast<EmbedderTestContextVulkan&>(context)
90-
.logical_device_->GetGraphicsQueueIndex();
91-
vulkan_renderer_config_.queue =
92-
static_cast<EmbedderTestContextVulkan&>(context)
93-
.logical_device_->GetQueueHandle();
94-
vulkan_renderer_config_.get_instance_proc_address_callback =
95-
[](void* context, FlutterVulkanInstanceHandle instance,
96-
const char* name) -> void* {
97-
return reinterpret_cast<EmbedderTestContextVulkan*>(context)
98-
->vk_->GetInstanceProcAddr(reinterpret_cast<VkInstance>(instance),
99-
name);
100-
};
101-
vulkan_renderer_config_.get_next_image_callback =
102-
[](void* context,
103-
const FlutterFrameInfo* frame_info) -> FlutterVulkanImage {
104-
VkImage image =
105-
reinterpret_cast<EmbedderTestContextVulkan*>(context)->GetNextImage(
106-
{static_cast<int>(frame_info->size.width),
107-
static_cast<int>(frame_info->size.height)});
108-
return {
109-
.struct_size = sizeof(FlutterVulkanImage),
110-
.image = image,
111-
};
112-
};
113-
vulkan_renderer_config_.present_image_callback =
114-
[](void* context, const FlutterVulkanImage* image) -> bool {
115-
return reinterpret_cast<EmbedderTestContextVulkan*>(context)->PresentImage(
116-
reinterpret_cast<VkImage>(image->image));
117-
};
118-
#endif
119-
12077
#ifdef SHELL_ENABLE_METAL
12178
InitializeMetalRendererConfig();
12279
#endif
12380

81+
#ifdef SHELL_ENABLE_VULKAN
82+
InitializeVulkanRendererConfig();
83+
#endif
84+
12485
software_renderer_config_.struct_size = sizeof(FlutterSoftwareRendererConfig);
12586
software_renderer_config_.surface_present_callback =
12687
[](void* context, const void* allocation, size_t row_bytes,
@@ -218,6 +179,14 @@ void EmbedderConfigBuilder::SetMetalRendererConfig(SkISize surface_size) {
218179
#endif
219180
}
220181

182+
void EmbedderConfigBuilder::SetVulkanRendererConfig(SkISize surface_size) {
183+
#ifdef SHELL_ENABLE_VULKAN
184+
renderer_config_.type = FlutterRendererType::kVulkan;
185+
renderer_config_.vulkan = vulkan_renderer_config_;
186+
context_.SetupSurface(surface_size);
187+
#endif
188+
}
189+
221190
void EmbedderConfigBuilder::SetAssetsPath() {
222191
project_args_.assets_path = context_.GetAssetsPath().c_str();
223192
}
@@ -476,5 +445,56 @@ void EmbedderConfigBuilder::InitializeMetalRendererConfig() {
476445

477446
#endif // SHELL_ENABLE_METAL
478447

448+
#ifdef SHELL_ENABLE_VULKAN
449+
450+
void EmbedderConfigBuilder::InitializeVulkanRendererConfig() {
451+
if (context_.GetContextType() != EmbedderTestContextType::kVulkanContext) {
452+
return;
453+
}
454+
455+
vulkan_renderer_config_.struct_size = sizeof(FlutterVulkanRendererConfig);
456+
vulkan_renderer_config_.instance =
457+
static_cast<EmbedderTestContextVulkan&>(context_)
458+
.application_->GetInstance();
459+
vulkan_renderer_config_.physical_device =
460+
static_cast<EmbedderTestContextVulkan&>(context_)
461+
.logical_device_->GetPhysicalDeviceHandle();
462+
vulkan_renderer_config_.device =
463+
static_cast<EmbedderTestContextVulkan&>(context_)
464+
.logical_device_->GetHandle();
465+
vulkan_renderer_config_.queue_family_index =
466+
static_cast<EmbedderTestContextVulkan&>(context_)
467+
.logical_device_->GetGraphicsQueueIndex();
468+
vulkan_renderer_config_.queue =
469+
static_cast<EmbedderTestContextVulkan&>(context_)
470+
.logical_device_->GetQueueHandle();
471+
vulkan_renderer_config_.get_instance_proc_address_callback =
472+
[](void* context, FlutterVulkanInstanceHandle instance,
473+
const char* name) -> void* {
474+
return reinterpret_cast<EmbedderTestContextVulkan*>(context)
475+
->vk_->GetInstanceProcAddr(reinterpret_cast<VkInstance>(instance),
476+
name);
477+
};
478+
vulkan_renderer_config_.get_next_image_callback =
479+
[](void* context,
480+
const FlutterFrameInfo* frame_info) -> FlutterVulkanImage {
481+
VkImage image =
482+
reinterpret_cast<EmbedderTestContextVulkan*>(context)->GetNextImage(
483+
{static_cast<int>(frame_info->size.width),
484+
static_cast<int>(frame_info->size.height)});
485+
return {
486+
.struct_size = sizeof(FlutterVulkanImage),
487+
.image = image,
488+
};
489+
};
490+
vulkan_renderer_config_.present_image_callback =
491+
[](void* context, const FlutterVulkanImage* image) -> bool {
492+
return reinterpret_cast<EmbedderTestContextVulkan*>(context)->PresentImage(
493+
reinterpret_cast<VkImage>(image->image));
494+
};
495+
}
496+
497+
#endif
498+
479499
} // namespace testing
480500
} // namespace flutter

shell/platform/embedder/tests/embedder_config_builder.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ class EmbedderConfigBuilder {
4848

4949
void SetOpenGLRendererConfig(SkISize surface_size);
5050

51-
void SetVulkanRendererConfig(SkISize surface_size);
52-
5351
void SetMetalRendererConfig(SkISize surface_size);
5452

53+
void SetVulkanRendererConfig(SkISize surface_size);
54+
5555
// Used to explicitly set an `open_gl.fbo_callback`. Using this method will
5656
// cause your test to fail since the ctor for this class sets
5757
// `open_gl.fbo_callback_with_frame_info`. This method exists as a utility to
@@ -119,6 +119,7 @@ class EmbedderConfigBuilder {
119119
FlutterOpenGLRendererConfig opengl_renderer_config_ = {};
120120
#endif
121121
#ifdef SHELL_ENABLE_VULKAN
122+
void InitializeVulkanRendererConfig();
122123
FlutterVulkanRendererConfig vulkan_renderer_config_ = {};
123124
#endif
124125
#ifdef SHELL_ENABLE_METAL

vulkan/vulkan_proc_table.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ VulkanProcTable::VulkanProcTable() : VulkanProcTable("libvulkan.so"){};
1818

1919
VulkanProcTable::VulkanProcTable(const char* so_path)
2020
: handle_(nullptr), acquired_mandatory_proc_addresses_(false) {
21-
FML_DLOG(WARNING) << "Cowabunga";
2221
acquired_mandatory_proc_addresses_ = OpenLibraryHandle(so_path) &&
2322
SetupGetInstanceProcAddress() &&
2423
SetupLoaderProcAddresses();

0 commit comments

Comments
 (0)