diff options
author | Cody Northrop <cnorthrop@google.com> | 2017-10-20 09:01:53 -0600 |
---|---|---|
committer | Cody Northrop <cnorthrop@google.com> | 2017-11-15 20:47:10 -0700 |
commit | d2aa3ab0f37087ab784a0a9246cc6ec5f04a3abe (patch) | |
tree | f6e25c5ca6518cfa26e87e12a59adcac768a659b /vulkan/libvulkan/api.cpp | |
parent | 81be9993fc65414fea8a76c8e8e37122c1542da7 (diff) |
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
Diffstat (limited to 'vulkan/libvulkan/api.cpp')
-rw-r--r-- | vulkan/libvulkan/api.cpp | 37 |
1 files changed, 29 insertions, 8 deletions
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 <new> #include <utility> +#include <android-base/strings.h> #include <cutils/properties.h> #include <log/log.h> #include <vulkan/vk_layer_interface.h> +#include <graphicsenv/GraphicsEnv.h> #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<std::string> 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() { |