Skip to content

Commit

Permalink
Statically link swiftshader into flutter_tester (flutter#48708)
Browse files Browse the repository at this point in the history
  • Loading branch information
dnfield authored Dec 16, 2023
1 parent 539e34d commit 74e4965
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 11 deletions.
2 changes: 1 addition & 1 deletion shell/testing/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ executable("testing") {
deps += [
":tester_gpu_configuration",
"//flutter/impeller",
"//flutter/third_party/swiftshader",
"//flutter/third_party/swiftshader/src/Vulkan:swiftshader_libvulkan_static",
]
}

Expand Down
3 changes: 1 addition & 2 deletions shell/testing/tester_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#if ALLOW_IMPELLER
#include <vulkan/vulkan.h> // nogncheck
#include "flutter/vulkan/procs/vulkan_proc_table.h" // nogncheck
#include "flutter/vulkan/swiftshader_path.h" // nogncheck
#include "impeller/entity/vk/entity_shaders_vk.h" // nogncheck
#include "impeller/entity/vk/framebuffer_blend_shaders_vk.h" // nogncheck
#include "impeller/entity/vk/modern_shaders_vk.h" // nogncheck
Expand Down Expand Up @@ -78,7 +77,7 @@ struct ImpellerVulkanContextHolder {

bool ImpellerVulkanContextHolder::Initialize(bool enable_validation) {
vulkan_proc_table =
fml::MakeRefCounted<vulkan::VulkanProcTable>(VULKAN_SO_PATH);
fml::MakeRefCounted<vulkan::VulkanProcTable>(&vkGetInstanceProcAddr);
if (!vulkan_proc_table->NativeGetInstanceProcAddr()) {
FML_LOG(ERROR) << "Could not load Swiftshader library.";
return false;
Expand Down
8 changes: 0 additions & 8 deletions vulkan/procs/vulkan_proc_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,9 @@ PFN_vkGetInstanceProcAddr VulkanProcTable::NativeGetInstanceProcAddr() const {
return GetInstanceProcAddr;
}

#if VULKAN_LINK_STATICALLY
return &vkGetInstanceProcAddr;
#else // VULKAN_LINK_STATICALLY
auto instance_proc =
const_cast<uint8_t*>(handle_->ResolveSymbol("vkGetInstanceProcAddr"));
return reinterpret_cast<PFN_vkGetInstanceProcAddr>(instance_proc);
#endif // VULKAN_LINK_STATICALLY
}

bool VulkanProcTable::SetupLoaderProcAddresses() {
Expand Down Expand Up @@ -200,11 +196,7 @@ bool VulkanProcTable::SetupDeviceProcAddresses(
}

bool VulkanProcTable::OpenLibraryHandle(const char* path) {
#if VULKAN_LINK_STATICALLY
handle_ = fml::NativeLibrary::CreateForCurrentProcess();
#else // VULKAN_LINK_STATICALLY
handle_ = fml::NativeLibrary::Create(path);
#endif // VULKAN_LINK_STATICALLY
if (!handle_) {
FML_DLOG(ERROR) << "Could not open Vulkan library handle: " << path;
return false;
Expand Down

0 comments on commit 74e4965

Please sign in to comment.