diff options
author | David Reveman <reveman@google.com> | 2019-04-22 16:50:02 +0200 |
---|---|---|
committer | Roman Kiryanov <rkir@google.com> | 2019-04-24 13:36:01 -0700 |
commit | 893dc100909a56ef052394f1bbc66faeba8dc50c (patch) | |
tree | 757d4b3a9ac262572492c31712a4eaed4464670c | |
parent | b9ccbdaf086ac6512c595727beeed2209c94c544 (diff) | |
download | goldfish-opengl-893dc100909a56ef052394f1bbc66faeba8dc50c.tar.gz |
add missing fuchsia ICD code
This allows the full goldfish vulkan ICD to be built outside the
fuchsia tree.
Test: none
Bug: 111137294
Change-Id: I02fe24617e114e0c07dc010bb7268ec6124af48e
Merged-In: I62065020349dfc3e34f93380abcab22c31a7e856
-rw-r--r-- | BUILD.gn | 4 | ||||
-rw-r--r-- | system/vulkan/goldfish_vulkan.cpp | 45 |
2 files changed, 43 insertions, 6 deletions
@@ -1,4 +1,4 @@ -source_set("goldfish_vulkan") { +shared_library("vulkan_goldfish") { sources = [ "android-emu/android/base/AlignedBuf.cpp", "android-emu/android/base/AlignedBuf.h", @@ -84,6 +84,8 @@ source_set("goldfish_vulkan") { "-Wno-missing-field-initializers", ] + ldflags = [ "-static-libstdc++" ] + if (target_os == "fuchsia") { sources += [ "fuchsia/port.cc" ] diff --git a/system/vulkan/goldfish_vulkan.cpp b/system/vulkan/goldfish_vulkan.cpp index 18a94245..3b38994d 100644 --- a/system/vulkan/goldfish_vulkan.cpp +++ b/system/vulkan/goldfish_vulkan.cpp @@ -208,6 +208,8 @@ PFN_vkVoidFunction GetInstanceProcAddr(VkInstance instance, namespace { +#ifdef VK_USE_PLATFORM_ANDROID_KHR + int OpenDevice(const hw_module_t* module, const char* id, hw_device_t** device); hw_module_methods_t goldfish_vulkan_module_methods = { @@ -232,6 +234,8 @@ int CloseDevice(struct hw_device_t* /*device*/) { return 0; } +#endif + #define VK_HOST_CONNECTION(ret) \ HostConnection *hostCon = HostConnection::get(); \ if (!hostCon) { \ @@ -498,6 +502,8 @@ PFN_vkVoidFunction GetInstanceProcAddr(VkInstance instance, const char* name) { return (PFN_vkVoidFunction)(goldfish_vk::goldfish_vulkan_get_instance_proc_address(instance, name)); } +#ifdef VK_USE_PLATFORM_ANDROID_KHR + hwvulkan_device_t goldfish_vulkan_device = { .common = { .tag = HARDWARE_DEVICE_TAG, @@ -517,7 +523,19 @@ int OpenDevice(const hw_module_t* /*module*/, if (strcmp(id, HWVULKAN_DEVICE_0) == 0) { *device = &goldfish_vulkan_device.common; + goldfish_vk::ResourceTracker::get(); + return 0; + } + return -ENOENT; +} + +#endif + #ifdef VK_USE_PLATFORM_FUCHSIA + +class VulkanDevice { +public: + VulkanDevice() { goldfish_vk::ResourceTracker::get()->setColorBufferFunctions( [](uint32_t width, uint32_t height, uint32_t format) { VK_HOST_CONNECTION((uint32_t)0) @@ -532,12 +550,29 @@ int OpenDevice(const hw_module_t* /*module*/, VK_HOST_CONNECTION() rcEnc->rcCloseColorBuffer(rcEnc, id); }); -#else - goldfish_vk::ResourceTracker::get(); -#endif - return 0; } - return -ENOENT; + + static VulkanDevice& GetInstance() { + static VulkanDevice g_instance; + return g_instance; + } + + PFN_vkVoidFunction GetInstanceProcAddr(VkInstance instance, const char* name) { + return ::GetInstanceProcAddr(instance, name); + } +}; + +extern "C" __attribute__((visibility("default"))) PFN_vkVoidFunction +vk_icdGetInstanceProcAddr(VkInstance instance, const char* name) { + return VulkanDevice::GetInstance().GetInstanceProcAddr(instance, name); } +extern "C" __attribute__((visibility("default"))) VkResult +vk_icdNegotiateLoaderICDInterfaceVersion(uint32_t* pSupportedVersion) { + *pSupportedVersion = std::min(*pSupportedVersion, 3u); + return VK_SUCCESS; +} + +#endif + } // namespace |