This commit is contained in:
xsl
2025-09-04 10:54:47 +08:00
commit 6bc8f61b18
1808 changed files with 208268 additions and 0 deletions
+91
View File
@@ -0,0 +1,91 @@
# Copyright (c) 2020-2024, Arm Limited and Contributors
#
# SPDX-License-Identifier: Apache-2.0
#
# 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.
#
cmake_minimum_required(VERSION 3.16)
project(apps)
# Generate apps.cpp
set(APP_INFO_LIST)
set(SAMPLE_INCLUDE_FILES)
set(SAMPLE_INFO_LIST)
foreach(SAMPLE_ID ${TOTAL_SAMPLE_ID_LIST})
if ("${VKB_${SAMPLE_ID}}" AND TARGET ${SAMPLE_ID})
get_target_property(SAMPLE_CATEGORY ${SAMPLE_ID} SAMPLE_CATEGORY)
get_target_property(SAMPLE_AUTHOR ${SAMPLE_ID} SAMPLE_AUTHOR)
get_target_property(SAMPLE_NAME ${SAMPLE_ID} SAMPLE_NAME)
get_target_property(SAMPLE_DESCRIPTION ${SAMPLE_ID} SAMPLE_DESCRIPTION)
get_target_property(SAMPLE_TAGS ${SAMPLE_ID} SAMPLE_TAGS)
# Ensure we send in an empty C++ string as the vendor category, rather than a string with a space
set(INCLUDE_DIR ${SAMPLE_CATEGORY}/${SAMPLE_ID})
set(SAMPLE_TAGS_VECTOR)
list(JOIN SAMPLE_TAGS "\", \"" SAMPLE_TAGS_VECTOR)
list(APPEND SAMPLE_INCLUDE_FILES "#include \"${INCLUDE_DIR}/${SAMPLE_ID}.h\"")
list(APPEND SAMPLE_INFO_LIST "\tSampleInfo{\"${SAMPLE_ID}\", create_${SAMPLE_ID}, \"${SAMPLE_CATEGORY}\"\, \"${SAMPLE_AUTHOR}\"\, \"${SAMPLE_NAME}\"\, \"${SAMPLE_DESCRIPTION}\", {\"${SAMPLE_TAGS_VECTOR}\"}},")
list(APPEND APP_INFO_LIST "\tAppInfo{\"${SAMPLE_ID}\", create_${SAMPLE_ID}},")
endif()
endforeach()
list(JOIN SAMPLE_INCLUDE_FILES "\n" SAMPLE_INCLUDE_FILES)
list(JOIN SAMPLE_INFO_LIST "\n" SAMPLE_INFO_LIST)
list(JOIN APP_INFO_LIST "\n" APP_INFO_LIST)
configure_file(apps.cpp.in apps.cpp)
# Create apps library
set(SRC
apps.h
${CMAKE_CURRENT_BINARY_DIR}/apps.cpp
)
add_library(${PROJECT_NAME} STATIC ${SRC})
target_link_libraries(${PROJECT_NAME} PUBLIC framework)
target_include_directories(${PROJECT_NAME} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/samples)
# Link all samples
set(PROJECT_ID_LIST ${TOTAL_SAMPLE_ID_LIST})
foreach(ID ${PROJECT_ID_LIST})
if(TARGET ${ID})
get_target_property(TARGET_TYPE ${ID} TYPE)
if(TARGET_TYPE STREQUAL "OBJECT_LIBRARY" OR TARGET_TYPE STREQUAL "STATIC_LIBRARY")
target_link_libraries(${PROJECT_NAME} PUBLIC ${ID})
endif()
endif()
endforeach()
if (IOS)
target_link_libraries(${PROJECT_NAME} PRIVATE
"-framework UIKit"
"-framework Foundation"
"-framework CoreGraphics"
"-framework Metal"
"-framework QuartzCore"
"-framework IOKit"
"-framework IOSurface"
)
endif ()
+122
View File
@@ -0,0 +1,122 @@
/* Copyright (c) 2020-2024, Arm Limited and Contributors
*
* SPDX-License-Identifier: Apache-2.0
*
* 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.
*/
// Generated file by CMake. Don't edit.
#include "apps.h"
@SAMPLE_INCLUDE_FILES@
namespace apps
{
std::vector<AppInfo> apps = {
@APP_INFO_LIST@
};
std::vector<SampleInfo> samples = {
@SAMPLE_INFO_LIST@
};
AppInfo *get_app(const std::string &id)
{
for (auto &app : apps)
{
if (app.id == id)
{
return &app;
}
}
return nullptr;
}
std::vector<AppInfo *> get_apps()
{
std::vector<AppInfo *> app_ptrs;
for (auto &app : apps)
{
app_ptrs.push_back(&app);
}
return app_ptrs;
}
std::vector<AppInfo *> get_samples(const std::vector<std::string> &categories, const std::vector<std::string> &tags)
{
std::vector<AppInfo *> app_ptrs;
for (auto &app : samples)
{
app_ptrs.push_back(&app);
}
// No filters
if (categories.empty() && tags.empty())
{
return app_ptrs;
}
std::vector<AppInfo *> filtered;
for (auto app : app_ptrs)
{
auto *sample = reinterpret_cast<SampleInfo *>(app);
bool selected = false;
// Sample is in one of the desired categories
for (auto &category : categories)
{
if (category == sample->category)
{
selected = true;
break;
}
}
// Sample has one or more of the desired tags
for (auto &tag : tags)
{
for (auto &s_tag : sample->tags)
{
if (s_tag == tag)
{
selected = true;
break;
}
}
}
if (selected)
{
filtered.push_back(app);
}
}
return filtered;
}
SampleInfo * get_sample(const std::string &id) {
for (auto& sample : samples) {
if (sample.id == id) {
return &sample;
}
}
return nullptr;
}
} // namespace apps
+98
View File
@@ -0,0 +1,98 @@
/* Copyright (c) 2020-2024, Arm Limited and Contributors
*
* SPDX-License-Identifier: Apache-2.0
*
* 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.
*/
#pragma once
#include <functional>
#include <memory>
#include <string>
#include <unordered_map>
#include <vector>
#include "platform/application.h"
/*
*
* Vulkan Samples currently has two types of apps, Samples and Tests. These apps work from the same interface AppInfo.
* Samples and Tests are categorised into namespaces samples and tests respectively. Each name space has a method to retrieve
* the AppInfo interface version of the app (tests::get_apps, samples::get_apps).
*
*/
namespace apps
{
using CreateFunc = std::function<std::unique_ptr<vkb::Application>()>;
/*
* Apps - Used by Vulkan Samples to load a vkb::Applicaiton with the creation function (CreateFunc create).
*/
class AppInfo
{
public:
AppInfo(const std::string &id, const CreateFunc &create) :
id(id), create(create)
{}
std::string id;
CreateFunc create;
};
/*
* Samples - These are individual applications which show different usages and optimizations of the Vulkan API
*/
class SampleInfo : public AppInfo
{
public:
SampleInfo(const std::string &id, const CreateFunc &create, const std::string &category, const std::string &author, const std::string &name, const std::string &description, const std::vector<std::string> &tags = {}) :
AppInfo(id, create), category(category), author(author), name(name), description(description), tags(tags)
{}
std::string category;
std::string author;
std::string name;
std::string description;
std::vector<std::string> tags;
};
/**
* @brief Get a specific app
*
* @param id ID of a specific app
* @return const std::vector<AppInfo *>
*/
AppInfo *get_app(const std::string &id);
/**
* @brief Get all apps
*
* @return const std::vector<AppInfo *> A list of all apps
*/
std::vector<AppInfo *> get_apps();
/**
* @brief Get all samples
*
* @param categories If not empty the lists will include samples that match on of the categories requested
* @param tags If not empty the lists will include samples that match on of the tags requested
* @return std::vector<AppInfo *> A list of samples
*/
std::vector<AppInfo *> get_samples(const std::vector<std::string> &categories = {}, const std::vector<std::string> &tags = {});
SampleInfo *get_sample(const std::string &id);
} // namespace apps