From f25f5bb3eb1ee3e7a3c33b5e44143ad296245f3f Mon Sep 17 00:00:00 2001 From: Daniel Koch Date: Thu, 5 Oct 2017 00:26:58 -0400 Subject: Vulkan api update to 1.1 Import Vulkan 1.1 header from khronos master@5b2d66c0e6906388385ed7adfd015d80ec0d846a with the following modifications: - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETER_FEATURES 10006300 -> 1000063000 - remove VK_KHR_get_display_properties2 (which is not ratified) - device_group interactions from KHR_surface to KHR_swapchain (per MR 2409) Summary of changes since 1.0.61: * VK_KHR_surface -> v26 (subsumed interactions with VK_KHR_device_group) * VK_KHR_swapchain -> v69 (subsumed interactions with VK_KHR_device_group) * VK_EXT_debug_report -> v9 (no api changes) * VK_KHX_multiview -> VK_KHR_multiview * VK_KHX_device_group -> VK_KHR_device_group * VK_KHX_device_group_creation -> VK_KHR_device_group_creation * VK_KHR_push_descriptor -> v2 * Added VK_KHR_maintenance3 * Added 1.1 core enums, structs, and functions (kept KHR suffixed ones too) Implemented the following in libvulkan: * EnumerateInstanceVersion * GetDeviceGroupPresentCapabilitiesKHR (minimal support for 1 device) * GetDeviceGroupSurfacePresentModesKHR (minimal support for local present modes only) * GetPhysicalDevicePresentRectanglesKHR (assumes whole window) * AcquireNextImage2KHR (minimal thunk to AcquireNextImageKHR) * GetDeviceQueue2 * added support for VK_SWAPCHAIN_CREATE_PROTECTED_BIT_KHR * support for 1.1 core device_groups functionality (no VK_KHR_device_group_creation) - EnumeratePhysicalDeviceGroups * added trampolines for 1.1 core entry points * disabled apiVersion >= 1.1 check Implemented in nulldrv (but largely untested beyond build/link) * EnumerateInstanceVersion * enough empty thunks for VK 1.1 core functions that it links Test: Build Android Change-Id: I247cd670543867bdf80877156d941cf3bfcf6303 --- vulkan/libvulkan/Android.bp | 1 + 1 file changed, 1 insertion(+) (limited to 'vulkan/libvulkan/Android.bp') diff --git a/vulkan/libvulkan/Android.bp b/vulkan/libvulkan/Android.bp index 5f9b357a35..b55fa27a76 100644 --- a/vulkan/libvulkan/Android.bp +++ b/vulkan/libvulkan/Android.bp @@ -80,6 +80,7 @@ cc_library_shared { "libcutils", "libz", "libnativewindow", + "android.hardware.graphics.common@1.0", ], static_libs: ["libgrallocusage"], } -- cgit v1.2.3-59-g8ed1b From d2aa3ab0f37087ab784a0a9246cc6ec5f04a3abe Mon Sep 17 00:00:00 2001 From: Cody Northrop Date: Fri, 20 Oct 2017 09:01:53 -0600 Subject: Rootless GPU Debug Add the ability to load GPU debug layers from the base directory of debuggable applications. This update concides with changes to framework/base to control the enabling logic in GraphicsEnvironment. This commit changes the Vulkan loader to: * Scan an additional location for debug layers. * Use the provided order of layers from GraphicsEnvironment, overriding system properties. * Use the first instance of a layer found, in the case of duplicates. * Move layers paths and namespace to GraphicsEnv, removing vulkan_loader_data Bug: 63708377 Test: Manual, CTS tests to follow Change-Id: I38dc91bbc26671f5093ee1b12454fc024c0b5892 --- libs/graphicsenv/GraphicsEnv.cpp | 27 +++++++++++++ libs/graphicsenv/include/graphicsenv/GraphicsEnv.h | 10 +++++ vulkan/include/vulkan/vulkan_loader_data.h | 33 --------------- vulkan/libvulkan/Android.bp | 1 - vulkan/libvulkan/api.cpp | 37 +++++++++++++---- vulkan/libvulkan/layers_extensions.cpp | 47 +++++++++++++++++----- vulkan/libvulkan/vulkan_loader_data.cpp | 24 ----------- 7 files changed, 103 insertions(+), 76 deletions(-) delete mode 100644 vulkan/include/vulkan/vulkan_loader_data.h delete mode 100644 vulkan/libvulkan/vulkan_loader_data.cpp (limited to 'vulkan/libvulkan/Android.bp') diff --git a/libs/graphicsenv/GraphicsEnv.cpp b/libs/graphicsenv/GraphicsEnv.cpp index 39b5829faf..f46e9f6c53 100644 --- a/libs/graphicsenv/GraphicsEnv.cpp +++ b/libs/graphicsenv/GraphicsEnv.cpp @@ -22,6 +22,7 @@ #include #include +#include // TODO(b/37049319) Get this from a header once one exists extern "C" { @@ -45,6 +46,32 @@ void GraphicsEnv::setDriverPath(const std::string path) { mDriverPath = path; } +void GraphicsEnv::setLayerPaths(android_namespace_t* appNamespace, const std::string layerPaths) { + if (mLayerPaths.empty()) { + mLayerPaths = layerPaths; + mAppNamespace = appNamespace; + } else { + ALOGV("Vulkan layer search path already set, not clobbering with '%s' for namespace %p'", + layerPaths.c_str(), appNamespace); + } +} + +android_namespace_t* GraphicsEnv::getAppNamespace() { + return mAppNamespace; +} + +const std::string GraphicsEnv::getLayerPaths(){ + return mLayerPaths; +} + +const std::string GraphicsEnv::getDebugLayers() { + return mDebugLayers; +} + +void GraphicsEnv::setDebugLayers(const std::string layers) { + mDebugLayers = layers; +} + android_namespace_t* GraphicsEnv::getDriverNamespace() { static std::once_flag once; std::call_once(once, [this]() { diff --git a/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h b/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h index 781707694a..213580c20b 100644 --- a/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h +++ b/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h @@ -35,10 +35,20 @@ public: void setDriverPath(const std::string path); android_namespace_t* getDriverNamespace(); + void setLayerPaths(android_namespace_t* appNamespace, const std::string layerPaths); + android_namespace_t* getAppNamespace(); + const std::string getLayerPaths(); + + void setDebugLayers(const std::string layers); + const std::string getDebugLayers(); + private: GraphicsEnv() = default; std::string mDriverPath; + std::string mDebugLayers; + std::string mLayerPaths; android_namespace_t* mDriverNamespace = nullptr; + android_namespace_t* mAppNamespace = nullptr; }; } // namespace android diff --git a/vulkan/include/vulkan/vulkan_loader_data.h b/vulkan/include/vulkan/vulkan_loader_data.h deleted file mode 100644 index 8ea46666c5..0000000000 --- a/vulkan/include/vulkan/vulkan_loader_data.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef VULKAN_VULKAN_LOADER_DATA_H -#define VULKAN_VULKAN_LOADER_DATA_H - -#include - -struct android_namespace_t; - -namespace vulkan { - struct LoaderData { - std::string layer_path; - android_namespace_t* app_namespace; - - __attribute__((visibility("default"))) static LoaderData& GetInstance(); - }; -} - -#endif diff --git a/vulkan/libvulkan/Android.bp b/vulkan/libvulkan/Android.bp index b55fa27a76..c9faf28606 100644 --- a/vulkan/libvulkan/Android.bp +++ b/vulkan/libvulkan/Android.bp @@ -61,7 +61,6 @@ cc_library_shared { "layers_extensions.cpp", "stubhal.cpp", "swapchain.cpp", - "vulkan_loader_data.cpp", ], export_header_lib_headers: ["vulkan_headers"], diff --git a/vulkan/libvulkan/api.cpp b/vulkan/libvulkan/api.cpp index d840786ae5..673a066182 100644 --- a/vulkan/libvulkan/api.cpp +++ b/vulkan/libvulkan/api.cpp @@ -29,14 +29,17 @@ #include #include +#include #include #include #include +#include #include "api.h" #include "driver.h" #include "layers_extensions.h" + namespace vulkan { namespace api { @@ -121,15 +124,33 @@ class OverrideLayerNames { if (!is_instance_ || !driver::Debuggable()) return; - ParseDebugVulkanLayers(); - property_list(ParseDebugVulkanLayer, this); + GetLayersFromSettings(); - // sort by priorities - auto& arr = implicit_layers_; - std::sort(arr.elements, arr.elements + arr.count, - [](const ImplicitLayer& a, const ImplicitLayer& b) { - return (a.priority < b.priority); - }); + // If no layers specified via Settings, check legacy properties + if (implicit_layers_.count <= 0) { + ParseDebugVulkanLayers(); + property_list(ParseDebugVulkanLayer, this); + + // sort by priorities + auto& arr = implicit_layers_; + std::sort(arr.elements, arr.elements + arr.count, + [](const ImplicitLayer& a, const ImplicitLayer& b) { + return (a.priority < b.priority); + }); + } + } + + void GetLayersFromSettings() { + // These will only be available if conditions are met in GraphicsEnvironemnt + // gpu_debug_layers = layer1:layer2:layerN + const std::string layers = android::GraphicsEnv::getInstance().getDebugLayers(); + if (!layers.empty()) { + ALOGV("Debug layer list: %s", layers.c_str()); + std::vector paths = android::base::Split(layers, ":"); + for (uint32_t i = 0; i < paths.size(); i++) { + AddImplicitLayer(int(i), paths[i].c_str(), paths[i].length()); + } + } } void ParseDebugVulkanLayers() { diff --git a/vulkan/libvulkan/layers_extensions.cpp b/vulkan/libvulkan/layers_extensions.cpp index 05856d3c1c..3a59208446 100644 --- a/vulkan/libvulkan/layers_extensions.cpp +++ b/vulkan/libvulkan/layers_extensions.cpp @@ -29,11 +29,10 @@ #include #include #include +#include #include #include -#include - // TODO(jessehall): The whole way we deal with extensions is pretty hokey, and // not a good long-term solution. Having a hard-coded enum of extensions is // bad, of course. Representing sets of extensions (requested, supported, etc.) @@ -69,11 +68,16 @@ const char kSystemLayerLibraryDir[] = "/data/local/debug/vulkan"; class LayerLibrary { public: - explicit LayerLibrary(const std::string& path) - : path_(path), dlhandle_(nullptr), refcount_(0) {} + explicit LayerLibrary(const std::string& path, + const std::string& filename) + : path_(path), + filename_(filename), + dlhandle_(nullptr), + refcount_(0) {} LayerLibrary(LayerLibrary&& other) : path_(std::move(other.path_)), + filename_(std::move(other.filename_)), dlhandle_(other.dlhandle_), refcount_(other.refcount_) { other.dlhandle_ = nullptr; @@ -94,9 +98,14 @@ class LayerLibrary { const char* gpa_name, size_t gpa_name_len) const; + const std::string GetFilename() { return filename_; } + private: const std::string path_; + // Track the filename alone so we can detect duplicates + const std::string filename_; + std::mutex mutex_; void* dlhandle_; size_t refcount_; @@ -111,7 +120,7 @@ bool LayerLibrary::Open() { // any symbol dependencies will be resolved by system libraries. They // can't safely use libc++_shared, for example. Which is one reason // (among several) we only allow them in non-user builds. - auto app_namespace = LoaderData::GetInstance().app_namespace; + auto app_namespace = android::GraphicsEnv::getInstance().getAppNamespace(); if (app_namespace && !android::base::StartsWith(path_, kSystemLayerLibraryDir)) { android_dlextinfo dlextinfo = {}; @@ -305,8 +314,8 @@ void* LayerLibrary::GetGPA(const Layer& layer, std::vector g_layer_libraries; std::vector g_instance_layers; -void AddLayerLibrary(const std::string& path) { - LayerLibrary library(path); +void AddLayerLibrary(const std::string& path, const std::string& filename) { + LayerLibrary library(path + "/" + filename, filename); if (!library.Open()) return; @@ -398,7 +407,25 @@ void DiscoverLayersInPathList(const std::string& pathstr) { ForEachFileInPath(path, [&](const std::string& filename) { if (android::base::StartsWith(filename, "libVkLayer") && android::base::EndsWith(filename, ".so")) { - AddLayerLibrary(path + "/" + filename); + + // Check to ensure we haven't seen this layer already + // Let the first instance of the shared object be enumerated + // We're searching for layers in following order: + // 1. system path + // 2. libraryPermittedPath (if enabled) + // 3. libraryPath + + bool duplicate = false; + for (auto& layer : g_layer_libraries) { + if (layer.GetFilename() == filename) { + ALOGV("Skipping duplicate layer %s in %s", + filename.c_str(), path.c_str()); + duplicate = true; + } + } + + if (!duplicate) + AddLayerLibrary(path, filename); } }); } @@ -428,8 +455,8 @@ void DiscoverLayers() { prctl(PR_GET_DUMPABLE, 0, 0, 0, 0)) { DiscoverLayersInPathList(kSystemLayerLibraryDir); } - if (!LoaderData::GetInstance().layer_path.empty()) - DiscoverLayersInPathList(LoaderData::GetInstance().layer_path); + if (!android::GraphicsEnv::getInstance().getLayerPaths().empty()) + DiscoverLayersInPathList(android::GraphicsEnv::getInstance().getLayerPaths()); } uint32_t GetLayerCount() { diff --git a/vulkan/libvulkan/vulkan_loader_data.cpp b/vulkan/libvulkan/vulkan_loader_data.cpp deleted file mode 100644 index 0eda0af59a..0000000000 --- a/vulkan/libvulkan/vulkan_loader_data.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -using namespace vulkan; - -LoaderData& LoaderData::GetInstance() { - static LoaderData loader_data = {}; - return loader_data; -} -- cgit v1.2.3-59-g8ed1b From 7671d4616faef3b3781dacf953069a3f24f6fdc2 Mon Sep 17 00:00:00 2001 From: Courtney Goeltzenleuchter Date: Wed, 24 Jan 2018 11:51:01 -0800 Subject: Add HDR support to Vulkan bug: 63710530 Test: adb -d shell am start -n \ com.drawelements.deqp/android.app.NativeActivity \ -e cmdLine '"deqp --deqp-case=dEQP-VK.wsi.android.colorspace.* \ --deqp-log-filename=/sdcard/dEQP-Log.qpa"' Change-Id: Ia5a5349aed06d875965972a2d809738329196e5a --- vulkan/libvulkan/Android.bp | 4 ++++ vulkan/libvulkan/driver.cpp | 13 +++++++++++++ vulkan/libvulkan/swapchain.cpp | 36 ++++++++++++++++++++++++++++++------ 3 files changed, 47 insertions(+), 6 deletions(-) (limited to 'vulkan/libvulkan/Android.bp') diff --git a/vulkan/libvulkan/Android.bp b/vulkan/libvulkan/Android.bp index c9faf28606..7f4f2c4ab3 100644 --- a/vulkan/libvulkan/Android.bp +++ b/vulkan/libvulkan/Android.bp @@ -68,10 +68,14 @@ cc_library_shared { "vulkan_headers", ], shared_libs: [ + "android.hardware.configstore@1.0", + "android.hardware.configstore-utils", "libziparchive", "libhardware", "libsync", "libbase", + "libhidlbase", + "libhidltransport", "liblog", "libui", "libgraphicsenv", diff --git a/vulkan/libvulkan/driver.cpp b/vulkan/libvulkan/driver.cpp index 26f60fb93e..97d7865928 100644 --- a/vulkan/libvulkan/driver.cpp +++ b/vulkan/libvulkan/driver.cpp @@ -27,6 +27,8 @@ #include #include +#include +#include #include #include #include @@ -36,6 +38,9 @@ #include "driver.h" #include "stubhal.h" +using namespace android::hardware::configstore; +using namespace android::hardware::configstore::V1_0; + // TODO(b/37049319) Get this from a header once one exists extern "C" { android_namespace_t* android_get_exported_namespace(const char*); @@ -814,6 +819,14 @@ VkResult EnumerateDeviceExtensionProperties( VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME, VK_KHR_INCREMENTAL_PRESENT_SPEC_VERSION}); + bool hdrBoardConfig = + getBool( + false); + if (hdrBoardConfig) { + loader_extensions.push_back({VK_EXT_HDR_METADATA_EXTENSION_NAME, + VK_EXT_HDR_METADATA_SPEC_VERSION}); + } + VkPhysicalDevicePresentationPropertiesANDROID presentation_properties; if (QueryPresentationProperties(physicalDevice, &presentation_properties) && presentation_properties.sharedImage) { diff --git a/vulkan/libvulkan/swapchain.cpp b/vulkan/libvulkan/swapchain.cpp index 03e6ee0870..9fbde8c938 100644 --- a/vulkan/libvulkan/swapchain.cpp +++ b/vulkan/libvulkan/swapchain.cpp @@ -1650,15 +1650,39 @@ VkResult GetSwapchainStatusKHR( } VKAPI_ATTR void SetHdrMetadataEXT( - VkDevice device, + VkDevice, uint32_t swapchainCount, const VkSwapchainKHR* pSwapchains, const VkHdrMetadataEXT* pHdrMetadataEXTs) { - // TODO: courtneygo: implement actual function - (void)device; - (void)swapchainCount; - (void)pSwapchains; - (void)pHdrMetadataEXTs; + + for (uint32_t idx = 0; idx < swapchainCount; idx++) { + Swapchain* swapchain = SwapchainFromHandle(pSwapchains[idx]); + if (!swapchain) + continue; + + if (swapchain->surface.swapchain_handle != pSwapchains[idx]) continue; + + ANativeWindow* window = swapchain->surface.window.get(); + + VkHdrMetadataEXT vulkanMetadata = pHdrMetadataEXTs[idx]; + const android_smpte2086_metadata smpteMetdata = { + {vulkanMetadata.displayPrimaryRed.x, + vulkanMetadata.displayPrimaryRed.y}, + {vulkanMetadata.displayPrimaryGreen.x, + vulkanMetadata.displayPrimaryGreen.y}, + {vulkanMetadata.displayPrimaryBlue.x, + vulkanMetadata.displayPrimaryBlue.y}, + {vulkanMetadata.whitePoint.x, vulkanMetadata.whitePoint.y}, + vulkanMetadata.maxLuminance, + vulkanMetadata.minLuminance}; + native_window_set_buffers_smpte2086_metadata(window, &smpteMetdata); + + const android_cta861_3_metadata cta8613Metadata = { + vulkanMetadata.maxContentLightLevel, + vulkanMetadata.maxFrameAverageLightLevel}; + native_window_set_buffers_cta861_3_metadata(window, &cta8613Metadata); + } + return; } -- cgit v1.2.3-59-g8ed1b