Skip to content

Commit 8d9a625

Browse files
authored
Dynamic loading libvulkan (#133)
1 parent 6d67e41 commit 8d9a625

File tree

7 files changed

+7192
-3
lines changed

7 files changed

+7192
-3
lines changed

NOTICES

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
==============================================================================
2+
The following software may be included in this product: volk
3+
4+
Files: flutter/third_party/volk/volk.*
5+
URL: https://github.com/zeux/volk
6+
Copyright: Copyright (C) 2018-2025, by Arseny Kapoulkine ([email protected])
7+
License: MIT License
8+
==============================================================================
9+
10+
MIT License
11+
12+
Copyright (c) 2018-2025 Arseny Kapoulkine
13+
14+
Permission is hereby granted, free of charge, to any person obtaining a copy
15+
of this software and associated documentation files (the "Software"), to deal
16+
in the Software without restriction, including without limitation the rights
17+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18+
copies of the Software, and to permit persons to whom the Software is
19+
furnished to do so, subject to the following conditions:
20+
21+
The above copyright notice and this permission notice shall be included in all
22+
copies or substantial portions of the Software.
23+
24+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30+
SOFTWARE.

flutter/shell/platform/tizen/BUILD.gn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ template("embedder") {
158158
target_name == "flutter_tizen_common_experimental") {
159159
defines += [ "FLUTTER_TIZEN_EXPERIMENTAL" ]
160160
sources += [ "tizen_renderer_vulkan.cc" ]
161-
libs += [ "vulkan" ]
161+
deps += [ "//flutter/third_party/volk" ]
162162
}
163163

164164
if (api_version != "6.0") {

flutter/shell/platform/tizen/tizen_renderer_vulkan.cc

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include "flutter/shell/platform/tizen/tizen_renderer_vulkan.h"
66

77
#include <stddef.h>
8-
#include <vulkan/vulkan_wayland.h>
98
#include <optional>
109

1110
#include "flutter/shell/platform/tizen/flutter_tizen_engine.h"
@@ -41,6 +40,14 @@ void DestroyDebugUtilsMessengerEXT(VkInstance instance,
4140
}
4241

4342
TizenRendererVulkan::TizenRendererVulkan(TizenViewBase* view) {
43+
if (volkInitialize() != VK_SUCCESS) {
44+
FT_LOG(Error) << "Failed to initialize volk";
45+
return;
46+
}
47+
uint32_t version = volkGetInstanceVersion();
48+
FT_LOG(Info) << "Vulkan version: " << VK_VERSION_MAJOR(version) << "."
49+
<< VK_VERSION_MINOR(version) << "." << VK_VERSION_PATCH(version);
50+
4451
InitVulkan(view);
4552
}
4653

@@ -49,6 +56,8 @@ bool TizenRendererVulkan::InitVulkan(TizenViewBase* view) {
4956
FT_LOG(Error) << "Failed to create Vulkan instance";
5057
return false;
5158
}
59+
volkLoadInstance(instance_);
60+
5261
if (enable_validation_layers_) {
5362
SetupDebugMessenger();
5463
}
@@ -65,6 +74,8 @@ bool TizenRendererVulkan::InitVulkan(TizenViewBase* view) {
6574
FT_LOG(Error) << "Failed to create logical device";
6675
return false;
6776
}
77+
volkLoadDevice(logical_device_);
78+
6879
if (!GetDeviceQueue()) {
6980
FT_LOG(Error) << "Failed to get device queue";
7081
return false;
@@ -442,6 +453,7 @@ bool TizenRendererVulkan::PickPhysicalDevice() {
442453

443454
TizenRendererVulkan::~TizenRendererVulkan() {
444455
Cleanup();
456+
volkFinalize();
445457
}
446458
bool TizenRendererVulkan::CreateSurface(void* render_target,
447459
void* render_target_display,

flutter/shell/platform/tizen/tizen_renderer_vulkan.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
#ifndef EMBEDDER_TIZEN_RENDERER_VULKAN_H_
66
#define EMBEDDER_TIZEN_RENDERER_VULKAN_H_
77

8+
#if defined(__linux__) || defined(__unix__)
9+
#define VK_USE_PLATFORM_WAYLAND_KHR
10+
#endif
811
#include "flutter/shell/platform/tizen/tizen_renderer.h"
912
#include "flutter/shell/platform/tizen/tizen_view_base.h"
13+
#include "flutter/third_party/volk/volk.h"
1014

11-
#include <vulkan/vulkan.h>
1215
#include <algorithm>
1316
#include <limits>
1417
#include <memory>

flutter/third_party/volk/BUILD.gn

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright 2025 Samsung Electronics Co., Ltd. All rights reserved.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
source_set("volk") {
6+
sources = [
7+
"volk.cc",
8+
"volk.h",
9+
]
10+
11+
include_dirs = [ "//flutter/third_party/volk" ]
12+
13+
defines = [ "VK_NO_PROTOTYPES" ]
14+
}

0 commit comments

Comments
 (0)