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 --- vulkan/libvulkan/api.cpp | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) (limited to 'vulkan/libvulkan/api.cpp') 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() { -- cgit v1.2.3-59-g8ed1b