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

Commit 1c69b9e3 authored by Michael Lentine's avatar Michael Lentine Committed by Jesse Hall
Browse files

Add support for loading layers from the apk.

Added the vulkan_layer_path interface which is used to set the path from
ThreadedRenderer. The vulkan loader then uses this path to search for layer
libraries that come preinstalled with the app.

Change-Id: Iee7d56c1950296ba5ece3a119741406d705479a8
(cherry picked from commit 1f920c1e52bbd59405761e5403def5dbc22e331b)
parent cd6cabf0
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
/*
 * 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 <string>

namespace vulkan {
    struct LoaderData {
        std::string layer_path;
        __attribute__((visibility("default"))) static LoaderData& GetInstance();
    };
}

#endif
+2 −1
Original line number Diff line number Diff line
@@ -33,7 +33,8 @@ LOCAL_SRC_FILES := \
	entry.cpp \
	get_proc_addr.cpp \
	loader.cpp \
	swapchain.cpp
	swapchain.cpp \
	vulkan_loader_data.cpp
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk

LOCAL_SHARED_LIBRARIES := libhardware liblog libsync libcutils
+5 −1
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@
#include <hardware/hwvulkan.h>
#include <log/log.h>
#include <vulkan/vk_debug_report_lunarg.h>
#include <vulkan/vulkan_loader_data.h>

using namespace vulkan;

@@ -753,13 +754,16 @@ VkResult CreateInstance(const VkInstanceCreateInfo* create_info,
    instance->message = VK_NULL_HANDLE;

    // Scan layers
    // TODO: Add more directories to scan
    UnorderedMap<String, SharedLibraryHandle> layers(
        CallbackAllocator<std::pair<String, SharedLibraryHandle> >(
            instance->alloc));
    CallbackAllocator<char> string_allocator(instance->alloc);
    String dir_name("/data/local/tmp/vulkan/", string_allocator);
    FindLayersInDirectory(*instance, layers, dir_name);
    const std::string& path = LoaderData::GetInstance().layer_path;
    dir_name.assign(path.c_str(), path.size());
    dir_name.append("/");
    FindLayersInDirectory(*instance, layers, dir_name);

    // Load layers
    {
+24 −0
Original line number Diff line number Diff line
/*
 * 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 <vulkan/vulkan_loader_data.h>

using namespace vulkan;

LoaderData& LoaderData::GetInstance() {
    static LoaderData loader_data;
    return loader_data;
}