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

Commit 1de7ccd

Browse files
committed
Fix extension init segfault
1 parent 9e2ffa3 commit 1de7ccd

File tree

2 files changed

+32
-27
lines changed

2 files changed

+32
-27
lines changed

shell/platform/embedder/embedder_surface_vulkan.cc

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "flutter/shell/common/shell_io_manager.h"
88
#include "include/gpu/GrDirectContext.h"
99
#include "include/gpu/vk/GrVkBackendContext.h"
10+
#include "include/gpu/vk/GrVkExtensions.h"
1011
#include "shell/gpu/gpu_surface_vulkan.h"
1112
#include "shell/gpu/gpu_surface_vulkan_delegate.h"
1213

@@ -103,30 +104,31 @@ sk_sp<GrDirectContext> EmbedderSurfaceVulkan::CreateGrContext(
103104
return nullptr;
104105
}
105106

106-
GrVkBackendContext backend_context = {
107-
.fInstance = instance,
108-
.fPhysicalDevice = device_.GetPhysicalDeviceHandle(),
109-
.fDevice = device_.GetHandle(),
110-
.fQueue = device_.GetQueueHandle(),
111-
.fGraphicsQueueIndex = device_.GetGraphicsQueueIndex(),
112-
.fMinAPIVersion = VK_MAKE_VERSION(1, 0, 0),
113-
.fMaxAPIVersion = VK_MAKE_VERSION(1, 0, 0),
114-
.fFeatures = skia_features,
115-
.fGetProc = get_proc,
116-
.fOwnsInstanceAndDevice = false,
117-
};
107+
GrVkExtensions extensions;
108+
109+
GrVkBackendContext backend_context = {};
110+
backend_context.fInstance = instance;
111+
backend_context.fPhysicalDevice = device_.GetPhysicalDeviceHandle();
112+
backend_context.fDevice = device_.GetHandle();
113+
backend_context.fQueue = device_.GetQueueHandle();
114+
backend_context.fGraphicsQueueIndex = device_.GetGraphicsQueueIndex();
115+
backend_context.fMinAPIVersion = VK_MAKE_VERSION(1, 0, 0);
116+
backend_context.fMaxAPIVersion = VK_MAKE_VERSION(1, 0, 0);
117+
backend_context.fFeatures = skia_features;
118+
backend_context.fVkExtensions = &extensions;
119+
backend_context.fGetProc = get_proc;
120+
backend_context.fOwnsInstanceAndDevice = false;
121+
118122
// TODO(bdero): Activate MEMORY_REQUIREMENTS_2 if available because VMA (the
119123
// allocator used by Skia) knows how to take advantage of these
120124
// features.
121125
/*
122126
const char* device_extensions[] = {
123127
VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME,
124128
};
125-
GrVkExtensions vk_extensions;
126-
vk_extensions.init(backend_context.fGetProc, backend_context.fInstance,
129+
extensions.init(backend_context.fGetProc, backend_context.fInstance,
127130
backend_context.fPhysicalDevice, 0, nullptr,
128131
countof(device_extensions), device_extensions);
129-
backend_context.fVkExtensions = &vk_extensions;
130132
*/
131133

132134
GrContextOptions options =

testing/test_vulkan_context.cc

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "flutter/testing/test_vulkan_context.h"
1010

1111
#include "include/gpu/GrDirectContext.h"
12+
#include "include/gpu/vk/GrVkExtensions.h"
1213
#include "third_party/skia/include/core/SkSurface.h"
1314

1415
#ifdef OS_MACOSX
@@ -68,18 +69,20 @@ TestVulkanContext::TestVulkanContext() {
6869
return;
6970
}
7071

71-
GrVkBackendContext backend_context = {
72-
.fInstance = application_->GetInstance(),
73-
.fPhysicalDevice = device_->GetPhysicalDeviceHandle(),
74-
.fDevice = device_->GetHandle(),
75-
.fQueue = device_->GetQueueHandle(),
76-
.fGraphicsQueueIndex = device_->GetGraphicsQueueIndex(),
77-
.fMinAPIVersion = VK_MAKE_VERSION(1, 0, 0),
78-
.fMaxAPIVersion = VK_MAKE_VERSION(1, 0, 0),
79-
.fFeatures = skia_features,
80-
.fGetProc = get_proc,
81-
.fOwnsInstanceAndDevice = false,
82-
};
72+
GrVkExtensions extensions;
73+
74+
GrVkBackendContext backend_context = {};
75+
backend_context.fInstance = application_->GetInstance();
76+
backend_context.fPhysicalDevice = device_->GetPhysicalDeviceHandle();
77+
backend_context.fDevice = device_->GetHandle();
78+
backend_context.fQueue = device_->GetQueueHandle();
79+
backend_context.fGraphicsQueueIndex = device_->GetGraphicsQueueIndex();
80+
backend_context.fMinAPIVersion = VK_MAKE_VERSION(1, 0, 0);
81+
backend_context.fMaxAPIVersion = VK_MAKE_VERSION(1, 0, 0);
82+
backend_context.fFeatures = skia_features;
83+
backend_context.fVkExtensions = &extensions;
84+
backend_context.fGetProc = get_proc;
85+
backend_context.fOwnsInstanceAndDevice = false;
8386

8487
GrContextOptions options =
8588
MakeDefaultContextOptions(ContextType::kRender, GrBackendApi::kVulkan);

0 commit comments

Comments
 (0)