| 1 |
/* |
| 2 |
* Copyright (c) 2025 The Khronos Group Inc. |
| 3 |
* Copyright (c) 2025 Valve Corporation |
| 4 |
* Copyright (c) 2025 LunarG, Inc. |
| 5 |
* |
| 6 |
* Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 |
* of this software and/or associated documentation files (the "Materials"), to |
| 8 |
* deal in the Materials without restriction, including without limitation the |
| 9 |
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 10 |
* sell copies of the Materials, and to permit persons to whom the Materials are |
| 11 |
* furnished to do so, subject to the following conditions: |
| 12 |
* |
| 13 |
* The above copyright notice(s) and this permission notice shall be included in |
| 14 |
* all copies or substantial portions of the Materials. |
| 15 |
* |
| 16 |
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 19 |
* |
| 20 |
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| 21 |
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 22 |
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE |
| 23 |
* USE OR OTHER DEALINGS IN THE MATERIALS. |
| 24 |
* |
| 25 |
*/ |
| 26 |
|
| 27 |
#pragma once |
| 28 |
|
| 29 |
#include <vector> |
| 30 |
#include <string> |
| 31 |
#include <filesystem> |
| 32 |
|
| 33 |
#include <vulkan/vulkan_core.h> |
| 34 |
|
| 35 |
#include "builder_defines.h" |
| 36 |
|
| 37 |
// Forward declaration since we take it by reference only |
| 38 |
class JsonWriter; |
| 39 |
|
| 40 |
struct ManifestVersion { |
| 41 |
BUILDER_VALUE_WITH_DEFAULT(uint32_t, major, 1) |
| 42 |
BUILDER_VALUE_WITH_DEFAULT(uint32_t, minor, 0) |
| 43 |
BUILDER_VALUE_WITH_DEFAULT(uint32_t, patch, 0) |
| 44 |
|
| 45 |
std::string get_version_str() const noexcept { |
| 46 |
return std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(patch); |
| 47 |
} |
| 48 |
}; |
| 49 |
|
| 50 |
// ManifestICD builder |
| 51 |
struct ManifestICD { |
| 52 |
BUILDER_VALUE(ManifestVersion, file_format_version) |
| 53 |
BUILDER_VALUE_WITH_DEFAULT(uint32_t, api_version, VK_API_VERSION_1_0) |
| 54 |
BUILDER_VALUE(std::filesystem::path, lib_path) |
| 55 |
BUILDER_VALUE(bool, is_portability_driver) |
| 56 |
BUILDER_VALUE(std::string, library_arch) |
| 57 |
std::string get_manifest_str() const; |
| 58 |
}; |
| 59 |
|
| 60 |
// ManifestLayer builder |
| 61 |
struct ManifestLayer { |
| 62 |
struct LayerDescription { |
| 63 |
enum class Type { INSTANCE, GLOBAL, DEVICE }; |
| 64 |
std::string get_type_str(Type layer_type) const { |
| 65 |
if (layer_type == Type::GLOBAL) |
| 66 |
return "GLOBAL"; |
| 67 |
else if (layer_type == Type::DEVICE) |
| 68 |
return "DEVICE"; |
| 69 |
else // default |
| 70 |
return "INSTANCE"; |
| 71 |
} |
| 72 |
struct FunctionOverride { |
| 73 |
BUILDER_VALUE(std::string, vk_func) |
| 74 |
BUILDER_VALUE(std::string, override_name) |
| 75 |
|
| 76 |
void get_manifest_str(JsonWriter& writer) const; |
| 77 |
}; |
| 78 |
struct Extension { |
| 79 |
Extension() noexcept {} |
| 80 |
Extension(std::string name, uint32_t spec_version = 0, std::vector<std::string> entrypoints = {}) noexcept |
| 81 |
: name(name), spec_version(spec_version), entrypoints(entrypoints) {} |
| 82 |
std::string name; |
| 83 |
uint32_t spec_version = 0; |
| 84 |
std::vector<std::string> entrypoints; |
| 85 |
void get_manifest_str(JsonWriter& writer) const; |
| 86 |
}; |
| 87 |
BUILDER_VALUE(std::string, name) |
| 88 |
BUILDER_VALUE_WITH_DEFAULT(Type, type, Type::INSTANCE) |
| 89 |
BUILDER_VALUE(std::filesystem::path, lib_path) |
| 90 |
BUILDER_VALUE_WITH_DEFAULT(uint32_t, api_version, VK_API_VERSION_1_0) |
| 91 |
BUILDER_VALUE(uint32_t, implementation_version) |
| 92 |
BUILDER_VALUE(std::string, description) |
| 93 |
BUILDER_VECTOR(FunctionOverride, functions, function) |
| 94 |
BUILDER_VECTOR(Extension, instance_extensions, instance_extension) |
| 95 |
BUILDER_VECTOR(Extension, device_extensions, device_extension) |
| 96 |
BUILDER_VALUE(std::string, enable_environment) |
| 97 |
BUILDER_VALUE(std::string, disable_environment) |
| 98 |
BUILDER_VECTOR(std::string, component_layers, component_layer) |
| 99 |
BUILDER_VECTOR(std::string, blacklisted_layers, blacklisted_layer) |
| 100 |
BUILDER_VECTOR(std::filesystem::path, override_paths, override_path) |
| 101 |
BUILDER_VECTOR(FunctionOverride, pre_instance_functions, pre_instance_function) |
| 102 |
BUILDER_VECTOR(std::string, app_keys, app_key) |
| 103 |
BUILDER_VALUE(std::string, library_arch) |
| 104 |
|
| 105 |
void get_manifest_str(JsonWriter& writer) const; |
| 106 |
VkLayerProperties get_layer_properties() const; |
| 107 |
}; |
| 108 |
BUILDER_VALUE(ManifestVersion, file_format_version) |
| 109 |
BUILDER_VECTOR(LayerDescription, layers, layer) |
| 110 |
|
| 111 |
std::string get_manifest_str() const; |
| 112 |
}; |