Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 69140e9c authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Update checking debug.vulkan.layer.* system props" am: 3fa63965 am: df476ddd

Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1596925

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I77967ca44d89eef806f6100ae5a8e5190a5fa3ff
parents 356101a3 df476ddd
Loading
Loading
Loading
Loading
+32 −22
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@
#include <unordered_set>
#include <utility>

#include <android-base/properties.h>
#include <android-base/strings.h>
#include <cutils/properties.h>
#include <log/log.h>
@@ -134,7 +135,7 @@ class OverrideLayerNames {
        // If no layers specified via Settings, check legacy properties
        if (implicit_layers_.count <= 0) {
            ParseDebugVulkanLayers();
            property_list(ParseDebugVulkanLayer, this);
            ParseDebugVulkanLayer();

            // sort by priorities
            auto& arr = implicit_layers_;
@@ -181,30 +182,39 @@ class OverrideLayerNames {
            AddImplicitLayer(prio, p, strlen(p));
    }

    static void ParseDebugVulkanLayer(const char* key,
                                      const char* val,
                                      void* user_data) {
    void ParseDebugVulkanLayer() {
        // Checks for consecutive debug.vulkan.layer.<priority> system
        // properties after always checking an initial fixed range.
        static const char prefix[] = "debug.vulkan.layer.";
        const size_t prefix_len = sizeof(prefix) - 1;

        if (strncmp(key, prefix, prefix_len) || val[0] == '\0')
            return;
        key += prefix_len;

        // debug.vulkan.layer.<priority>
        int priority = -1;
        if (key[0] >= '0' && key[0] <= '9')
            priority = atoi(key);

        if (priority < 0) {
            ALOGW("Ignored implicit layer %s with invalid priority %s", val,
                  key);
        static constexpr int kFixedRangeBeginInclusive = 0;
        static constexpr int kFixedRangeEndInclusive = 9;

        bool logged = false;

        int priority = kFixedRangeBeginInclusive;
        while (true) {
            const std::string prop_key =
                std::string(prefix) + std::to_string(priority);
            const std::string prop_val =
                android::base::GetProperty(prop_key, "");

            if (!prop_val.empty()) {
                if (!logged) {
                    ALOGI(
                        "Detected Vulkan layers configured with "
                        "debug.vulkan.layer.<priority>. Checking for "
                        "debug.vulkan.layer.<priority> in the range [%d, %d] "
                        "followed by a consecutive scan.",
                        kFixedRangeBeginInclusive, kFixedRangeEndInclusive);
                    logged = true;
                }
                AddImplicitLayer(priority, prop_val.c_str(), prop_val.length());
            } else if (priority >= kFixedRangeEndInclusive) {
                return;
            }

        OverrideLayerNames& override_layers =
            *reinterpret_cast<OverrideLayerNames*>(user_data);
        override_layers.AddImplicitLayer(priority, val, strlen(val));
            ++priority;
        }
    }

    void AddImplicitLayer(int priority, const char* name, size_t len) {