|
13 | 13 | #include "flutter/shell/platform/embedder/tests/embedder_test_context_gl.h" |
14 | 14 | #endif |
15 | 15 |
|
16 | | -//#ifdef SHELL_ENABLE_VULKAN |
| 16 | +#ifdef SHELL_ENABLE_VULKAN |
17 | 17 | #include "flutter/shell/platform/embedder/tests/embedder_test_context_vulkan.h" |
18 | 18 | #include "flutter/vulkan/vulkan_device.h" |
19 | | -//#endif |
| 19 | +#endif |
20 | 20 |
|
21 | 21 | #ifdef SHELL_ENABLE_METAL |
22 | 22 | #include "flutter/shell/platform/embedder/tests/embedder_test_context_metal.h" |
@@ -74,53 +74,14 @@ EmbedderConfigBuilder::EmbedderConfigBuilder( |
74 | 74 | }; |
75 | 75 | #endif |
76 | 76 |
|
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 | | - |
120 | 77 | #ifdef SHELL_ENABLE_METAL |
121 | 78 | InitializeMetalRendererConfig(); |
122 | 79 | #endif |
123 | 80 |
|
| 81 | +#ifdef SHELL_ENABLE_VULKAN |
| 82 | + InitializeVulkanRendererConfig(); |
| 83 | +#endif |
| 84 | + |
124 | 85 | software_renderer_config_.struct_size = sizeof(FlutterSoftwareRendererConfig); |
125 | 86 | software_renderer_config_.surface_present_callback = |
126 | 87 | [](void* context, const void* allocation, size_t row_bytes, |
@@ -218,6 +179,14 @@ void EmbedderConfigBuilder::SetMetalRendererConfig(SkISize surface_size) { |
218 | 179 | #endif |
219 | 180 | } |
220 | 181 |
|
| 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 | + |
221 | 190 | void EmbedderConfigBuilder::SetAssetsPath() { |
222 | 191 | project_args_.assets_path = context_.GetAssetsPath().c_str(); |
223 | 192 | } |
@@ -476,5 +445,56 @@ void EmbedderConfigBuilder::InitializeMetalRendererConfig() { |
476 | 445 |
|
477 | 446 | #endif // SHELL_ENABLE_METAL |
478 | 447 |
|
| 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 | + |
479 | 499 | } // namespace testing |
480 | 500 | } // namespace flutter |
0 commit comments