Skip to content

Commit

Permalink
build: Downstream Vulkan-Tools 1.3.295
Browse files Browse the repository at this point in the history
  • Loading branch information
MathiasMagnus committed Oct 1, 2024
2 parents 156a649 + 4c63e84 commit d7cfe6a
Show file tree
Hide file tree
Showing 24 changed files with 1,209 additions and 996 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ out64/*
*.includes
.vscode/
.DS_Store
.cache

# Chromium build artifacts
.cipd/
Expand Down
16 changes: 10 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ option(BUILD_VKSC_DEVSIM "Build Vulkan SC device simulation layer" ON)
option(BUILD_CUBE "Build cube" ON)
option(BUILD_VULKANINFO "Build vulkaninfo" ON)
option(BUILD_ICD "Build icd" ON)
option(BUILD_TESTS "Build the tests")
option(BUILD_WERROR "Treat compiler warnings as errors")
# NOTE: Our custom code generation target isn't desirable for system package managers or add_subdirectory users.
# So this target needs to be off by default to avoid obtuse build errors or patches.
option(TOOLS_CODEGEN "Enable helper codegen target")

if(VULKANSC)
set(BUILD_CUBE OFF CACHE BOOL "cube sample is not currently supported for Vulkan SC" FORCE)
Expand All @@ -65,17 +70,18 @@ endif()

set_property(GLOBAL PROPERTY USE_FOLDERS ON)

find_package(VulkanHeaders QUIET CONFIG)
find_package(VulkanLoader QUIET CONFIG)
find_package(volk QUIET CONFIG)
find_package(VulkanHeaders QUIET REQUIRED CONFIG)
find_package(volk QUIET REQUIRED CONFIG)
if ((APPLE OR BUILD_TESTS) AND NOT ANDROID)
find_package(VulkanLoader QUIET REQUIRED CONFIG)
endif()

if(VULKANSC)
find_package(VulkanUtilityLibraries REQUIRED CONFIG QUIET)
endif()

include(GNUInstallDirs)

option(BUILD_WERROR "Treat compiler warnings as errors")
if (BUILD_WERROR)
add_compile_options("$<IF:$<CXX_COMPILER_ID:MSVC>,/WX,-Werror>")
endif()
Expand Down Expand Up @@ -115,7 +121,6 @@ elseif(MSVC)
add_compile_options("/w34245")
endif()

option(TOOLS_CODEGEN "Enable helper codegen target")
if (TOOLS_CODEGEN)
find_package(Python3 REQUIRED QUIET)
add_custom_target(tools_codegen
Expand Down Expand Up @@ -167,7 +172,6 @@ endif()

add_subdirectory(windows-runtime-installer)

option(BUILD_TESTS "Build the tests")
if(BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
Expand Down
14 changes: 6 additions & 8 deletions cube/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ if(APPLE)
endif()
endif()

if (CMAKE_SYSTEM_NAME MATCHES "Linux|BSD")
if (CMAKE_SYSTEM_NAME MATCHES "Linux|BSD|GNU")
option(BUILD_WSI_XCB_SUPPORT "Build XCB WSI support" ON)
option(BUILD_WSI_XLIB_SUPPORT "Build Xlib WSI support" ON)
option(BUILD_WSI_WAYLAND_SUPPORT "Build Wayland WSI support" ON)
Expand Down Expand Up @@ -134,7 +134,7 @@ elseif(ANDROID)
add_definitions(-DVK_USE_PLATFORM_ANDROID_KHR)
elseif(APPLE)
add_definitions(-DVK_USE_PLATFORM_METAL_EXT)
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux|BSD")
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux|BSD|GNU")
if(NOT CUBE_WSI_SELECTION)
set(CUBE_WSI_SELECTION "XCB")
endif()
Expand Down Expand Up @@ -210,7 +210,7 @@ endif()
# a missing dependency on libpthread. While newer Ubuntu versions use a glibc version where libpthread
# is integrated into libc, older ubuntu's do not so we need to link threads directly in order for
# validation layers to be loadable.
if (CMAKE_SYSTEM_NAME MATCHES "Linux|BSD")
if (CMAKE_SYSTEM_NAME MATCHES "Linux|BSD|GNU")
find_package(Threads REQUIRED)
endif()

Expand All @@ -227,7 +227,7 @@ elseif (ANDROID)
add_subdirectory(android)

target_link_libraries(vkcube PRIVATE Vulkan::Headers volk::volk_headers)
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux|BSD")
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux|BSD|GNU")
add_executable(vkcube)
target_sources(vkcube PRIVATE
cube.c
Expand Down Expand Up @@ -259,7 +259,6 @@ else()
endif()

target_include_directories(vkcube PRIVATE .)
target_compile_definitions(vkcube PRIVATE VK_NO_PROTOTYPES)

if (ANDROID)
install(TARGETS vkcube DESTINATION ${CMAKE_INSTALL_LIBDIR})
Expand All @@ -286,7 +285,7 @@ endif()

if(APPLE)
add_subdirectory(macOS/cubepp)
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux|BSD")
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux|BSD|GNU")
add_executable(vkcubepp
cube.cpp
${PROJECT_SOURCE_DIR}/cube/cube.vert
Expand All @@ -307,7 +306,6 @@ else()
target_link_libraries(vkcubepp Vulkan::Headers volk::volk_headers)
endif()
target_include_directories(vkcubepp PRIVATE .)
target_compile_definitions(vkcubepp PRIVATE VK_NO_PROTOTYPES)

if(APPLE)
install(
Expand Down Expand Up @@ -351,7 +349,7 @@ if (CMAKE_SYSTEM_NAME MATCHES "Linux|BSD")
Threads::Threads
PkgConfig::WAYLAND_CLIENT
)
target_compile_definitions(vkcube-wayland PRIVATE VK_USE_PLATFORM_WAYLAND_KHR VK_NO_PROTOTYPES)
target_compile_definitions(vkcube-wayland PRIVATE VK_USE_PLATFORM_WAYLAND_KHR)
include(CheckLibraryExists)
CHECK_LIBRARY_EXISTS("rt" clock_gettime "" NEED_RT)
if (NEED_RT)
Expand Down
6 changes: 4 additions & 2 deletions cube/cube.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
#define APP_NAME_STR_LEN 80
#endif // _WIN32

// Volk requires VK_NO_PROTOTYPES before including vulkan.h
#define VK_NO_PROTOTYPES
#include <vulkan/vulkan.h>
#define VOLK_IMPLEMENTATION
#include "volk.h"
Expand Down Expand Up @@ -4186,7 +4188,7 @@ static void demo_init_connection(struct demo *demo) {

demo->registry = wl_display_get_registry(demo->display);
wl_registry_add_listener(demo->registry, &registry_listener, demo);
wl_display_dispatch(demo->display);
wl_display_roundtrip(demo->display);
#endif
}

Expand Down Expand Up @@ -4503,7 +4505,7 @@ void android_main(struct android_app *app) {
while (1) {
int events;
struct android_poll_source *source;
while (ALooper_pollAll(active ? 0 : -1, NULL, &events, (void **)&source) >= 0) {
while (ALooper_pollOnce(active ? 0 : -1, NULL, &events, (void **)&source) >= 0) {
if (source) {
source->process(app, source);
}
Expand Down
5 changes: 4 additions & 1 deletion cube/cube.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
#define VULKAN_HPP_DISPATCH_LOADER_DYNAMIC 1
#define VULKAN_HPP_NO_EXCEPTIONS
#define VULKAN_HPP_TYPESAFE_CONVERSION 1

// Volk requires VK_NO_PROTOTYPES before including vulkan.hpp
#define VK_NO_PROTOTYPES
#include <vulkan/vulkan.hpp>

#define VOLK_IMPLEMENTATION
Expand Down Expand Up @@ -3384,7 +3387,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine,
return static_cast<int>(msg.wParam);
}

#elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__QNX__)
#elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__QNX__) || defined(__GNU__)

int main(int argc, char **argv) {
Demo demo;
Expand Down
2 changes: 0 additions & 2 deletions cube/macOS/cube/DemoViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
#import "DemoViewController.h"
#import <QuartzCore/CAMetalLayer.h>

#include <MoltenVK/mvk_vulkan.h>

#include "cube.c"

#pragma mark -
Expand Down
2 changes: 0 additions & 2 deletions cube/macOS/cubepp/DemoViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
#import "DemoViewController.h"
#import <QuartzCore/CAMetalLayer.h>

#include <MoltenVK/mvk_vulkan.h>

#include "cube.cpp"

#pragma mark -
Expand Down
35 changes: 20 additions & 15 deletions devsim/profiles_generated.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4138,21 +4138,26 @@ VkResult JsonLoader::LoadProfilesDatabase() {
for (std::size_t i = 0, n = layer_settings.simulate.profile_dirs.size(); i < n; ++i) {
const std::string& path = layer_settings.simulate.profile_dirs[i];

for (const auto& entry : fs::directory_iterator(path)) {
if (fs::is_directory(entry.path())) {
continue;
}

const std::string& file_path = entry.path().generic_string();
if (!EndsWith(file_path, ".json")) {
continue;
}

VkResult result = this->LoadFile(file_path);
if (result != VK_SUCCESS) {
continue;
}
}
if (fs::is_regular_file(path)) {
this->LoadFile(path);
continue;
}

for (const auto& entry : fs::directory_iterator(path)) {
if (fs::is_directory(entry.path())) {
continue;
}

const std::string& file_path = entry.path().generic_string();
if (!EndsWith(file_path, ".json")) {
continue;
}

VkResult result = this->LoadFile(file_path);
if (result != VK_SUCCESS) {
continue;
}
}
}

LogFoundProfiles();
Expand Down
9 changes: 7 additions & 2 deletions devsim/profiles_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ void LogMessage(ProfileLayerSettings *layer_settings, DebugReportBits report, co
assert(layer_settings);
#endif

if (!(layer_settings->log.debug_reports & report)) return;
if (!(layer_settings->log.debug_reports & report)) {
return;
}

std::size_t const STRING_BUFFER(4096);

Expand All @@ -123,7 +125,7 @@ void LogMessage(ProfileLayerSettings *layer_settings, DebugReportBits report, co
va_list list;

va_start(list, message);
vsnprintf(log + len, STRING_BUFFER, message, list);
vsnprintf(log + len, STRING_BUFFER - len, message, list);
va_end(list);

if (layer_settings->log.debug_actions & DEBUG_ACTION_STDOUT_BIT) {
Expand Down Expand Up @@ -206,6 +208,9 @@ void InitProfilesLayerSettings(const VkInstanceCreateInfo *pCreateInfo, const Vk
assert(layer_settings != nullptr);

#ifdef VULKANSC // We use a simplified configuration interface for Vulkan SC
(void)pCreateInfo;
(void)pAllocator;

const char *devsim_profile_file = std::getenv("VKSC_DEVSIM_PROFILE_FILE");

if (devsim_profile_file) {
Expand Down
2 changes: 1 addition & 1 deletion icd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ elseif(APPLE)
add_definitions(-DVK_USE_PLATFORM_MACOS_MVK)
elseif(BUILD_MOCK_ANDROID_SUPPORT)
add_definitions(-DVK_USE_PLATFORM_ANDROID_KHR)
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux|BSD|QNX")
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux|BSD|GNU|QNX")
if(BUILD_WSI_XCB_SUPPORT)
add_definitions(-DVK_USE_PLATFORM_XCB_KHR -DVK_USE_PLATFORM_XCB_KHX)
endif()
Expand Down
2 changes: 1 addition & 1 deletion icd/VkICD_mock_icd.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"file_format_version": "1.0.1",
"ICD": {
"library_path": "@JSON_LIBRARY_PATH@",
"api_version": "1.3.285"
"api_version": "1.3.295"
}
}
4 changes: 2 additions & 2 deletions icd/generated-vksc/function_declarations.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static const std::unordered_map<std::string, uint32_t> instance_extension_map =
{"VK_KHR_display", 23},
{"VK_EXT_direct_mode_display", 1},
{"VK_EXT_display_surface_counter", 1},
{"VK_EXT_swapchain_colorspace", 4},
{"VK_EXT_swapchain_colorspace", 5},
{"VK_KHR_get_surface_capabilities2", 1},
{"VK_KHR_get_display_properties2", 1},
{"VK_EXT_debug_utils", 2},
Expand All @@ -59,7 +59,7 @@ static const std::unordered_map<std::string, uint32_t> device_extension_map = {
{"VK_EXT_discard_rectangles", 2},
{"VK_EXT_conservative_rasterization", 1},
{"VK_EXT_depth_clip_enable", 1},
{"VK_EXT_hdr_metadata", 2},
{"VK_EXT_hdr_metadata", 3},
{"VK_KHR_shared_presentable_image", 1},
{"VK_KHR_external_fence_fd", 1},
{"VK_KHR_performance_query", 1},
Expand Down
Loading

0 comments on commit d7cfe6a

Please sign in to comment.