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

Commit 0ecdd3ed authored by Jesse Hall's avatar Jesse Hall
Browse files

libvulkan: Don't log error if layer dir doesn't exist

It's normal for the global layer dir to not exist, and would be a
serious system bug if the APK native library dir didn't exist. Either
way, a VERBOSE message will be seen by the appropriate people, without
spamming the log during normal operation.

Change-Id: I7419b46304bb98b4dbb6d02effff0a4062c6de79
(cherry picked from commit e0059ade3836ec778f16a7c8998d056a21d2a7ab)
parent 74f28ddb
Loading
Loading
Loading
Loading
+52 −47
Original line number Diff line number Diff line
@@ -257,22 +257,30 @@ void DestroyDevice(Device* device) {
}

void FindLayersInDirectory(Instance& instance, const String& dir_name) {
    DIR* directory;
    struct dirent* entry;
    if ((directory = opendir(dir_name.c_str()))) {
    DIR* directory = opendir(dir_name.c_str());
    if (!directory) {
        android_LogPriority log_priority =
            (errno == ENOENT) ? ANDROID_LOG_VERBOSE : ANDROID_LOG_ERROR;
        LOG_PRI(log_priority, LOG_TAG,
                "failed to open layer directory '%s': %s (%d)",
                dir_name.c_str(), strerror(errno), errno);
        return;
    }

    Vector<VkLayerProperties> properties(
        CallbackAllocator<VkLayerProperties>(instance.alloc));
    struct dirent* entry;
    while ((entry = readdir(directory))) {
        size_t length = strlen(entry->d_name);
        if (strncmp(entry->d_name, "libVKLayer", 10) != 0 ||
            strncmp(entry->d_name + length - 3, ".so", 3) != 0)
            continue;
        // Open so
            SharedLibraryHandle layer_handle = dlopen(
                (dir_name + entry->d_name).c_str(), RTLD_NOW | RTLD_LOCAL);
        SharedLibraryHandle layer_handle =
            dlopen((dir_name + entry->d_name).c_str(), RTLD_NOW | RTLD_LOCAL);
        if (!layer_handle) {
                ALOGE("%s failed to load with error %s; Skipping",
                      entry->d_name, dlerror());
            ALOGE("%s failed to load with error %s; Skipping", entry->d_name,
                  dlerror());
            continue;
        }

@@ -304,11 +312,8 @@ void FindLayersInDirectory(Instance& instance, const String& dir_name) {
        }
        dlclose(layer_handle);
    }

    closedir(directory);
    } else {
        ALOGE("Failed to Open Directory %s: %s (%d)", dir_name.c_str(),
              strerror(errno), errno);
    }
}

template <class TObject>