Skip to content
Commits on Source (65)
......@@ -30,6 +30,9 @@ before_build:
- python scripts/update_deps.py --dir=external
# Get Google Test
- git clone https://github.com/google/googletest.git external/googletest
- cd external/googletest
- git checkout tags/release-1.8.1
- cd %APPVEYOR_BUILD_FOLDER%
# Generate build files using CMake for the build step.
- echo Generating CMake files for %PLATFORM%
- mkdir build
......
# Configuration for cmake-format (v0.3.6, circa Apr 2018)
# Configuration for cmake-format (v0.4.1, circa Jul 2018)
# https://github.com/cheshirekow/cmake_format
# How wide to allow formatted cmake files
......
# Build Configuration for Travis CI
# https://travis-ci.org
dist: trusty
dist: xenial
sudo: required
language: cpp
......@@ -48,11 +48,11 @@ before_install:
if [[ "$VULKAN_BUILD_TARGET" == "LINUX" ]]; then
# Install the appropriate Linux packages.
sudo apt-get -qq update
sudo apt-get -y install libxkbcommon-dev libwayland-dev libmirclient-dev libxrandr-dev libx11-xcb-dev
sudo apt-get -y install libxkbcommon-dev libwayland-dev libxrandr-dev libx11-xcb-dev
fi
- |
if [[ "$VULKAN_BUILD_TARGET" == "MACOS" ]]; then
# Install the appropriate MacOS packages
# We need to upgrade to a newer python
brew upgrade python3
fi
- |
......@@ -61,6 +61,9 @@ before_install:
python scripts/update_deps.py --dir=external $UPDATE_DEPS_EXTRA_OPTIONS
# Get Google Test
git clone https://github.com/google/googletest.git external/googletest
pushd ${TRAVIS_BUILD_DIR}/external/googletest
git checkout tags/release-1.8.1
popd
fi
- |
if [[ "$CHECK_FORMAT" == "ON" && "$TRAVIS_PULL_REQUEST" != "false" ]]; then
......
......@@ -81,6 +81,8 @@ To obtain the framework, change your current directory to the top of your
Vulkan-Loader repository and run:
git clone https://github.com/google/googletest.git external/googletest
cd external/googletest
git checkout tags/release-1.8.1
before configuring your build with CMake.
......@@ -154,7 +156,6 @@ on/off options currently supported by this repository:
| BUILD_WSI_XCB_SUPPORT | Linux | `ON` | Build the loader with the XCB entry points enabled. Without this, the XCB headers should not be needed, but the extension `VK_KHR_xcb_surface` won't be available. |
| BUILD_WSI_XLIB_SUPPORT | Linux | `ON` | Build the loader with the Xlib entry points enabled. Without this, the X11 headers should not be needed, but the extension `VK_KHR_xlib_surface` won't be available. |
| BUILD_WSI_WAYLAND_SUPPORT | Linux | `ON` | Build the loader with the Wayland entry points enabled. Without this, the Wayland headers should not be needed, but the extension `VK_KHR_wayland_surface` won't be available. |
| BUILD_WSI_MIR_SUPPORT | Linux | `OFF` | Build the loader with the Mir entry points enabled. Without this, the Mir headers should not be needed, but the extension `VK_KHR_mir_surface` won't be available. |
| ENABLE_STATIC_LOADER | Windows | `OFF` | By default, the loader is built as a dynamic library. This allows it to be built as a static library, instead. |
| ENABLE_WIN10_ONECORE | Windows | `OFF` | Link the loader to the [OneCore](https://msdn.microsoft.com/en-us/library/windows/desktop/mt654039.aspx) umbrella library, instead of the standard Win32 ones. |
| USE_CCACHE | Linux | `OFF` | Enable caching with the CCache program. |
......@@ -362,7 +363,7 @@ repository to other Linux distributions.
#### Required Package List
sudo apt-get install git cmake build-essential libx11-xcb-dev \
libxkbcommon-dev libmirclient-dev libwayland-dev libxrandr-dev
libxkbcommon-dev libwayland-dev libxrandr-dev
### Linux Build
......
......@@ -15,13 +15,14 @@
# limitations under the License.
# ~~~
cmake_minimum_required(VERSION 2.8.11)
cmake_minimum_required(VERSION 3.4)
# This must come before the project command.
# Apple: Must be set before enable_language() or project() as it may influence configuration of the toolchain and flags.
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.12" CACHE STRING "Minimum OS X deployment version")
project(Vulkan-Loader)
set(CMAKE_VERBOSE_MAKEFILE 0)
add_definitions(-DAPI_NAME="Vulkan")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
find_package(PythonInterp 3 REQUIRED)
......@@ -31,20 +32,23 @@ if(NOT ${VulkanHeaders_FOUND})
message(FATAL_ERROR "Could not find Vulkan headers path. This can be fixed by setting VULKAN_HEADERS_INSTALL_DIR to an "
"installation of the Vulkan-Headers repository.")
endif()
if(NOT ${VulkanRegistry_FOUND})
message(FATAL_ERROR "Could not find Vulkan registry path. This can be fixed by setting VULKAN_HEADERS_INSTALL_DIR to an "
"installation of the Vulkan-Headers repository.")
endif()
option(USE_CCACHE "Use ccache" OFF)
if(USE_CCACHE)
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
endif(CCACHE_FOUND)
endif()
endif()
include(GNUInstallDirs)
# Set a better default install location for Windows only if the user did not provide one.
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND WIN32)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "default install path" FORCE)
if(UNIX AND NOT APPLE) # i.e.: Linux
include(FindPkgConfig)
endif()
if(APPLE)
......@@ -52,12 +56,16 @@ if(APPLE)
set(CMAKE_MACOSX_RPATH 1)
endif()
# Enable IDE GUI folders
if(WIN32 AND CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
# Windows: if install locations not set by user, set install prefix to "<build_dir>\install".
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "default install path" FORCE)
endif()
# Enable IDE GUI folders. "Helper targets" that don't have interesting source code should set their FOLDER property to this
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# "Helper" targets that don't have interesting source code should set their FOLDER property to this
set(LOADER_HELPER_FOLDER "Helper Targets")
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Darwin")
if(UNIX)
set(
FALLBACK_CONFIG_DIRS "/etc/xdg"
CACHE
......@@ -72,12 +80,10 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Darwin")
)
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
include(FindPkgConfig)
if(UNIX AND NOT APPLE) # i.e.: Linux
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)
option(BUILD_WSI_MIR_SUPPORT "Build Mir WSI support" OFF)
if(BUILD_WSI_XCB_SUPPORT)
find_package(XCB REQUIRED)
......@@ -91,10 +97,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
find_package(Wayland REQUIRED)
include_directories(${WAYLAND_CLIENT_INCLUDE_DIR})
endif()
if(BUILD_WSI_MIR_SUPPORT)
find_package(Mir REQUIRED)
endif()
endif()
if(WIN32)
......@@ -102,13 +104,19 @@ if(WIN32)
option(ENABLE_STATIC_LOADER "Build the loader as a static library" OFF)
endif()
set(SCRIPTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/scripts")
option(BUILD_LOADER "Build loader" ON)
if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/external/googletest)
option(BUILD_TESTS "Build Tests" ON)
else()
option(BUILD_TESTS "Build Tests" OFF)
endif()
# Add location of Vulkan header files to include search path
include_directories(${VulkanHeaders_INCLUDE_DIRS})
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
set(COMMON_COMPILE_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers")
set(COMMON_COMPILE_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-stringop-truncation -Wno-stringop-overflow")
set(COMMON_COMPILE_FLAGS "${COMMON_COMPILE_FLAGS} -fno-strict-aliasing -fno-builtin-memcmp")
# For GCC version 7.1 or greater, we need to disable the implicit fallthrough warning since there's no consistent way to satisfy
......@@ -129,44 +137,40 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
endif()
endif()
if(WIN32)
# Treat warnings as errors
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/WX>")
# Disable RTTI
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/GR->")
# Warn about nested declarations
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/w34456>")
# Warn about potentially uninitialized variables
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/w34701>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/w34703>")
# Warn about different indirection types.
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/w34057>")
# Warn about signed/unsigned mismatch.
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/w34245>")
if(MSVC)
# /WX: Treat warnings as errors
# /GR-: Disable RTTI
# /w34456: Warn about nested declarations
# /w34701, /w34703: Warn about potentially uninitialized variables
# /w34057: Warn about different indirection types.
# /w34245: Warn about signed/unsigned mismatch.
set(MSVC_LOADER_COMPILE_OPTIONS /WX /GR- /w34456 /w34701 /w34703 /w34057 /w34245)
endif()
option(BUILD_LOADER "Build loader" ON)
if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/external/googletest)
option(BUILD_TESTS "Build Tests" ON)
else()
option(BUILD_TESTS "Build Tests" OFF)
endif()
set(PYTHON_CMD ${PYTHON_EXECUTABLE})
# Define macro used for building vkxml generated files
macro(run_vk_xml_generate dependency output)
# Define a macro to generate source code from vk.xml
set(SCRIPTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/scripts")
macro(GenerateFromVkXml output dependency)
add_custom_command(OUTPUT ${output}
COMMAND ${PYTHON_CMD} ${SCRIPTS_DIR}/loader_genvk.py -registry ${VulkanRegistry_DIR}/vk.xml -scripts
COMMAND ${PYTHON_EXECUTABLE} ${SCRIPTS_DIR}/loader_genvk.py -registry ${VulkanRegistry_DIR}/vk.xml -scripts
${VulkanRegistry_DIR} ${output}
DEPENDS ${VulkanRegistry_DIR}/vk.xml
${VulkanRegistry_DIR}/generator.py
${SCRIPTS_DIR}/${dependency}
DEPENDS ${SCRIPTS_DIR}/${dependency}
${SCRIPTS_DIR}/loader_genvk.py
${VulkanRegistry_DIR}/vk.xml
${VulkanRegistry_DIR}/generator.py
${VulkanRegistry_DIR}/reg.py)
endmacro()
# Custom target for generated vulkan helper file dependencies
# Use the macro to generate the source files.
GenerateFromVkXml(vk_layer_dispatch_table.h loader_extension_generator.py)
GenerateFromVkXml(vk_dispatch_table_helper.h dispatch_table_helper_generator.py)
GenerateFromVkXml(vk_safe_struct.h helper_file_generator.py)
GenerateFromVkXml(vk_safe_struct.cpp helper_file_generator.py)
GenerateFromVkXml(vk_enum_string_helper.h helper_file_generator.py)
GenerateFromVkXml(vk_object_types.h helper_file_generator.py)
GenerateFromVkXml(vk_extension_helper.h helper_file_generator.py)
GenerateFromVkXml(vk_typemap_helper.h helper_file_generator.py)
# Use a custom target to cause the source files to be generated.
add_custom_target(generate_helper_files
DEPENDS vk_enum_string_helper.h
vk_safe_struct.h
......@@ -176,19 +180,10 @@ add_custom_target(generate_helper_files
vk_dispatch_table_helper.h
vk_extension_helper.h
vk_typemap_helper.h)
set_target_properties(generate_helper_files PROPERTIES FOLDER ${LOADER_HELPER_FOLDER})
# Rules to build generated helper files
run_vk_xml_generate(loader_extension_generator.py vk_layer_dispatch_table.h)
run_vk_xml_generate(dispatch_table_helper_generator.py vk_dispatch_table_helper.h)
run_vk_xml_generate(helper_file_generator.py vk_safe_struct.h)
run_vk_xml_generate(helper_file_generator.py vk_safe_struct.cpp)
run_vk_xml_generate(helper_file_generator.py vk_enum_string_helper.h)
run_vk_xml_generate(helper_file_generator.py vk_object_types.h)
run_vk_xml_generate(helper_file_generator.py vk_extension_helper.h)
run_vk_xml_generate(helper_file_generator.py vk_typemap_helper.h)
if(NOT WIN32)
if(UNIX)
add_definitions(-DFALLBACK_CONFIG_DIRS="${FALLBACK_CONFIG_DIRS}")
add_definitions(-DFALLBACK_DATA_DIRS="${FALLBACK_DATA_DIRS}")
add_definitions(-DSYSCONFDIR="${CMAKE_INSTALL_FULL_SYSCONFDIR}")
......@@ -201,15 +196,14 @@ endif()
# uninstall target
if(NOT TARGET uninstall)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE
@ONLY)
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
set_target_properties(uninstall PROPERTIES FOLDER ${LOADER_HELPER_FOLDER})
endif()
add_definitions(-DAPI_NAME="Vulkan")
if(BUILD_LOADER)
add_subdirectory(loader)
endif()
......
A reminder that this issue tracker is managed by the Khronos Group. Interactions here should follow the Khronos Code of Conduct (https://www.khronos.org/developers/code-of-conduct), which prohibits aggressive or derogatory language. Please keep the discussion friendly and civil.
This diff is collapsed.
......@@ -45,6 +45,14 @@ Includes directions for building all components.
Architecture and interface information for the loader is in
[loader/LoaderAndLayerInterface.md](loader/LoaderAndLayerInterface.md).
## Version Tagging Scheme
Updates to the `Vulkan-Loader` repository which correspond to a new Vulkan specification release are tagged using the following format: `v<`_`version`_`>` (e.g., `v1.1.96`).
**Note**: Marked version releases have undergone thorough testing but do not imply the same quality level as SDK tags. SDK tags follow the `sdk-<`_`version`_`>.<`_`patch`_`>` format (e.g., `sdk-1.1.92.0`).
This scheme was adopted following the 1.1.96 Vulkan specification release.
## License
This work is released as open source under a Apache-style license from Khronos
......
# Try to find Mir on a Unix system
#
# This will define:
#
# MIR_FOUND - System has Mir
# MIR_LIBRARIES - Link these to use Mir
# MIR_INCLUDE_DIR - Include directory for Mir
# MIR_DEFINITIONS - Compiler switches required for using Mir
if (NOT WIN32)
find_package (PkgConfig)
pkg_check_modules (PKG_MIR QUIET mirclient)
set(MIR_DEFINITIONS ${PKG_MIR_CFLAGS_OTHER})
find_path(MIR_INCLUDE_DIR
NAMES xkbcommon/xkbcommon.h
HINTS ${PC_XKBCOMMON_INCLUDE_DIR} ${PC_XKBCOMMON_INCLUDE_DIRS}
)
find_library(MIR_LIBRARY
NAMES mirclient
HINTS ${PKG_MIR_LIBRARIES} ${MIR_LIBRARY_DIRS}
)
set (MIR_INCLUDE_DIR ${PKG_MIR_INCLUDE_DIRS})
set (MIR_LIBRARIES ${MIR_LIBRARY})
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (MIR DEFAULT_MSG
MIR_LIBRARIES
MIR_INCLUDE_DIR
)
mark_as_advanced (MIR_LIBRARIES MIR_INCLUDE_DIR)
endif ()
......@@ -15,16 +15,17 @@
# limitations under the License.
# ~~~
# Add all optional dependencies. Currently, the only optional project is googletest.
# Add your optional dependencies in this "external" directory.
# googletest is an optional external dependency for this repo.
if(BUILD_TESTS)
# googletest is an external dependency for the tests in the ValidationLayers repo. Add googletest to the project if present and
# not already defined.
# Attempt to enable if it is available.
if(TARGET gtest_main)
# It is possible that a project enclosing this one has defined the gtest target
message(STATUS "Vulkan-Loader/external: " "Google Test (googletest) already configured - use it")
# Already enabled as a target (perhaps by a project enclosing this one)
message(STATUS "Vulkan-Loader/external: " "googletest already configured - using it")
elseif(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/googletest")
message(STATUS "Vulkan-Loader/external: " "googletests found - configuring it for tests")
# The googletest directory exists, so enable it as a target.
message(STATUS "Vulkan-Loader/external: " "googletest found - configuring it for tests")
set(BUILD_GTEST ON CACHE BOOL "Builds the googletest subproject")
set(BUILD_GMOCK OFF CACHE BOOL "Builds the googlemock subproject")
set(gtest_force_shared_crt ON CACHE BOOL "Link gtest runtimes dynamically")
......@@ -32,7 +33,7 @@ if(BUILD_TESTS)
# EXCLUDE_FROM_ALL keeps the install target from installing GTEST files.
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/googletest" EXCLUDE_FROM_ALL)
else()
message(SEND_ERROR "Vulkan-Loader/external: Google Test was not found. "
message(SEND_ERROR "Vulkan-Loader/external: " "Google Test was not found. "
"Provide Google Test in external/googletest or set BUILD_TESTS=OFF")
endif()
endif()
......@@ -15,11 +15,6 @@
# limitations under the License.
# ~~~
if(NOT ${VulkanRegistry_FOUND})
message(FATAL_ERROR "Could not find Vulkan registry path. This can be fixed by setting VULKAN_HEADERS_INSTALL_DIR to an "
"installation of the Vulkan-Headers repository.")
endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_BINARY_DIR} ${CMAKE_BINARY_DIR})
# Check for the existance of the secure_getenv or __secure_getenv commands
......@@ -28,19 +23,20 @@ check_function_exists(secure_getenv HAVE_SECURE_GETENV)
check_function_exists(__secure_getenv HAVE___SECURE_GETENV)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/loader_cmake_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/loader_cmake_config.h)
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
if(WIN32)
add_definitions(-DVK_USE_PLATFORM_WIN32_KHR -DWIN32_LEAN_AND_MEAN)
set(DisplayServer Win32)
if(NOT MSVC_VERSION LESS 1900)
if(MSVC AND NOT MSVC_VERSION LESS 1900)
# Enable control flow guard
message(STATUS "Building loader with control flow guard")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/guard:cf>")
set(MSVC_LOADER_COMPILE_OPTIONS ${MSVC_LOADER_COMPILE_OPTIONS} /guard:cf)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /guard:cf")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /guard:cf")
endif()
elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
elseif(ANDROID)
add_definitions(-DVK_USE_PLATFORM_ANDROID_KHR)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
elseif(APPLE)
add_definitions(-DVK_USE_PLATFORM_MACOS_MVK)
elseif(UNIX AND NOT APPLE) # i.e.: Linux
if(BUILD_WSI_XCB_SUPPORT)
add_definitions(-DVK_USE_PLATFORM_XCB_KHR)
endif()
......@@ -52,13 +48,6 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
if(BUILD_WSI_WAYLAND_SUPPORT)
add_definitions(-DVK_USE_PLATFORM_WAYLAND_KHR)
endif()
if(BUILD_WSI_MIR_SUPPORT)
add_definitions(-DVK_USE_PLATFORM_MIR_KHR)
include_directories(${MIR_INCLUDE_DIR})
endif()
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
add_definitions(-DVK_USE_PLATFORM_MACOS_MVK)
else()
message(FATAL_ERROR "Unsupported Platform!")
endif()
......@@ -67,6 +56,45 @@ endif()
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
if(WIN32)
# Use static MSVCRT libraries
foreach(configuration
in
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if(${configuration} MATCHES "/MD")
string(REGEX
REPLACE "/MD"
"/MT"
${configuration}
"${${configuration}}")
endif()
endforeach()
if(ENABLE_WIN10_ONECORE)
# Note: When linking your app or driver to OneCore.lib, be sure to remove any links to non-umbrella libs (such as
# kernel32.lib).
set(CMAKE_CXX_STANDARD_LIBRARIES " ") # space is intentional
set(CMAKE_C_STANDARD_LIBRARIES ${CMAKE_CXX_STANDARD_LIBRARIES})
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS")
# ~~~
# Build dev_ext_trampoline.c with -O2 to allow tail-call optimization.
# Build other C files with normal options.
# Setup two CMake targets (loader-norm and loader-opt) for the different compilation flags.
# ~~~
separate_arguments(LOCAL_C_FLAGS_DBG WINDOWS_COMMAND ${CMAKE_C_FLAGS_DEBUG})
set(CMAKE_C_FLAGS_DEBUG " ")
separate_arguments(LOCAL_C_FLAGS_REL WINDOWS_COMMAND ${CMAKE_C_FLAGS_RELEASE})
endif()
set(NORMAL_LOADER_SRCS
extension_manual.c
loader.c
......@@ -97,31 +125,40 @@ if(WIN32)
if(NOT CMAKE_CL_64)
set(CMAKE_ASM_MASM_FLAGS ${CMAKE_ASM_MASM_FLAGS} /safeseh)
endif()
set(OPT_LOADER_SRCS ${OPT_LOADER_SRCS} unknown_ext_chain_masm.asm)
add_executable(asm_offset asm_offset.c)
add_dependencies(asm_offset generate_helper_files loader_gen_files)
add_custom_command(OUTPUT gen_defines.asm DEPENDS asm_offset COMMAND asm_offset MASM)
add_custom_target(loader_asm_gen_files DEPENDS gen_defines.asm)
set_target_properties(loader_asm_gen_files PROPERTIES FOLDER ${LOADER_HELPER_FOLDER})
add_library(loader-unknown-chain OBJECT unknown_ext_chain_masm.asm)
add_dependencies(loader-unknown-chain loader_asm_gen_files)
else()
message(WARNING "Could not find working MASM assebler\n${ASM_FAILURE_MSG}")
set(OPT_LOADER_SRCS ${OPT_LOADER_SRCS} unknown_ext_chain.c)
add_custom_target(loader_asm_gen_files)
add_library(loader-unknown-chain OBJECT unknown_ext_chain.c)
add_dependencies(loader-unknown-chain generate_helper_files loader_gen_files)
target_compile_options(loader-unknown-chain PUBLIC "$<$<CONFIG:DEBUG>:${LOCAL_C_FLAGS_REL}>")
target_compile_options(loader-unknown-chain PUBLIC ${MSVC_LOADER_COMPILE_OPTIONS})
endif()
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
elseif(APPLE)
# For MacOS, use the C code and force the compiler's tail-call optimization instead of using assembly code.
set(OPT_LOADER_SRCS ${OPT_LOADER_SRCS} unknown_ext_chain.c)
set_source_files_properties(${OPT_LOADER_SRCS} PROPERTIES COMPILE_FLAGS -O)
add_custom_target(loader_asm_gen_files) # This causes no assembly files to be generated.
else()
else(UNIX AND NOT APPLE) # i.e.: Linux
enable_language(ASM-ATT)
set(CMAKE_ASM-ATT_COMPILE_FLAGS "${CMAKE_ASM-ATT_COMPILE_FLAGS} $ENV{ASFLAGS}")
set(CMAKE_ASM-ATT_COMPILE_FLAGS "${CMAKE_ASM-ATT_COMPILE_FLAGS} -I\"${CMAKE_CURRENT_BINARY_DIR}\"")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/asm_test.asm
".intel_syntax noprefix\n.text\n.global sample\nsample:\nmov ecx, [eax + 16]\n")
# try_compile uses the C/C++ linker flags even for ASM,
# while they're not valid for ASM and making linking fail.
set(TMP_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS})
set(CMAKE_EXE_LINKER_FLAGS "")
try_compile(ASSEMBLER_WORKS ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/asm_test.asm)
set(CMAKE_EXE_LINKER_FLAGS ${TMP_EXE_LINKER_FLAGS})
file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/asm_test.asm)
if(ASSEMBLER_WORKS)
set(CMAKE_ASM-ATT_FLAGS "$ENV{ASFLAGS} -I\"${CMAKE_CURRENT_BINARY_DIR}\"")
......@@ -137,52 +174,21 @@ else()
endif()
endif()
run_vk_xml_generate(loader_extension_generator.py vk_loader_extensions.h)
run_vk_xml_generate(loader_extension_generator.py vk_loader_extensions.c)
GenerateFromVkXml(vk_loader_extensions.h loader_extension_generator.py)
GenerateFromVkXml(vk_loader_extensions.c loader_extension_generator.py)
add_custom_target(loader_gen_files DEPENDS vk_loader_extensions.h vk_loader_extensions.c)
set_target_properties(loader_gen_files PROPERTIES FOLDER ${LOADER_HELPER_FOLDER})
if(WIN32)
# Use static MSVCRT libraries
foreach(configuration
in
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if(${configuration} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${configuration} "${${configuration}}")
endif()
endforeach()
if(ENABLE_WIN10_ONECORE)
# Note: When linking your app or driver to OneCore.lib, be sure to remove any links to non-umbrella libs (such as
# kernel32.lib).
set(CMAKE_CXX_STANDARD_LIBRARIES " ") # space is intentional
set(CMAKE_C_STANDARD_LIBRARIES ${CMAKE_CXX_STANDARD_LIBRARIES})
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS")
# ~~~
# Build dev_ext_trampoline.c with -O2 to allow tail-call optimization.
# Build other C files with normal options.
# Setup two CMake targets (loader-norm and loader-opt) for the different compilation flags.
# ~~~
separate_arguments(LOCAL_C_FLAGS_DBG WINDOWS_COMMAND ${CMAKE_C_FLAGS_DEBUG})
set(CMAKE_C_FLAGS_DEBUG " ")
separate_arguments(LOCAL_C_FLAGS_REL WINDOWS_COMMAND ${CMAKE_C_FLAGS_RELEASE})
add_library(loader-norm OBJECT ${NORMAL_LOADER_SRCS} dirent_on_windows.c)
add_dependencies(loader-norm generate_helper_files loader_gen_files)
target_compile_options(loader-norm PUBLIC "$<$<CONFIG:DEBUG>:${LOCAL_C_FLAGS_DBG}>")
target_compile_options(loader-norm PUBLIC ${MSVC_LOADER_COMPILE_OPTIONS})
add_library(loader-opt OBJECT ${OPT_LOADER_SRCS})
add_dependencies(loader-opt generate_helper_files loader_gen_files loader_asm_gen_files)
target_compile_options(loader-opt PUBLIC "$<$<CONFIG:DEBUG>:${LOCAL_C_FLAGS_REL}>")
target_compile_options(loader-opt PUBLIC ${MSVC_LOADER_COMPILE_OPTIONS})
if(NOT ENABLE_STATIC_LOADER)
target_compile_definitions(loader-norm PUBLIC LOADER_DYNAMIC_LIB)
......@@ -192,11 +198,20 @@ if(WIN32)
SHARED
$<TARGET_OBJECTS:loader-opt>
$<TARGET_OBJECTS:loader-norm>
$<TARGET_OBJECTS:loader-unknown-chain>
${CMAKE_CURRENT_SOURCE_DIR}/vulkan-1.def
${CMAKE_CURRENT_SOURCE_DIR}/loader.rc)
set_target_properties(vulkan PROPERTIES LINK_FLAGS_DEBUG "/ignore:4098" OUTPUT_NAME vulkan-1)
set_target_properties(vulkan
PROPERTIES LINK_FLAGS_DEBUG
"/ignore:4098"
OUTPUT_NAME
vulkan-1)
else()
add_library(vulkan STATIC $<TARGET_OBJECTS:loader-opt> $<TARGET_OBJECTS:loader-norm>)
add_library(vulkan
STATIC
$<TARGET_OBJECTS:loader-opt>
$<TARGET_OBJECTS:loader-norm>
$<TARGET_OBJECTS:loader-unknown-chain>)
set_target_properties(vulkan PROPERTIES OUTPUT_NAME VKstatic.1)
endif()
......@@ -222,7 +237,11 @@ else()
add_library(vulkan SHARED ${NORMAL_LOADER_SRCS} ${OPT_LOADER_SRCS})
add_dependencies(vulkan generate_helper_files loader_gen_files loader_asm_gen_files)
target_compile_definitions(vulkan PUBLIC -DLOADER_DYNAMIC_LIB)
set_target_properties(vulkan PROPERTIES SOVERSION "1" VERSION "${VulkanHeaders_VERSION_MAJOR}.${VulkanHeaders_VERSION_MINOR}.${VulkanHeaders_VERSION_PATCH}")
set_target_properties(vulkan
PROPERTIES SOVERSION
"1"
VERSION
"${VulkanHeaders_VERSION_MAJOR}.${VulkanHeaders_VERSION_MINOR}.${VulkanHeaders_VERSION_PATCH}")
target_link_libraries(vulkan -ldl -lpthread -lm)
if(APPLE)
......@@ -239,7 +258,6 @@ else()
${VulkanHeaders_INCLUDE_DIRS}/vulkan/vulkan_core.h
${VulkanHeaders_INCLUDE_DIRS}/vulkan/vulkan_ios.h
${VulkanHeaders_INCLUDE_DIRS}/vulkan/vulkan_macos.h
${VulkanHeaders_INCLUDE_DIRS}/vulkan/vulkan_mir.h
${VulkanHeaders_INCLUDE_DIRS}/vulkan/vulkan_vi.h
${VulkanHeaders_INCLUDE_DIRS}/vulkan/vulkan_wayland.h
${VulkanHeaders_INCLUDE_DIRS}/vulkan/vulkan_win32.h
......@@ -273,7 +291,7 @@ else()
FRAMEWORK DESTINATION loader
)
# cmake-format: on
endif(APPLE)
endif()
if(NOT APPLE)
# Generate pkg-config file.
......
This diff is collapsed.
......@@ -87,14 +87,16 @@ VkBool32 util_SubmitDebugUtilsMessageEXT(const struct loader_instance *inst, VkD
const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData) {
VkBool32 bail = false;
if (NULL != pCallbackData && NULL != pCallbackData->pObjects && 0 < pCallbackData->objectCount) {
if (NULL != pCallbackData) {
VkLayerDbgFunctionNode *pTrav = inst->DbgFunctionHead;
VkDebugReportObjectTypeEXT object_type;
VkDebugReportObjectTypeEXT object_type = VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT;
VkDebugReportFlagsEXT object_flags = 0;
uint64_t object_handle;
uint64_t object_handle = 0;
debug_utils_AnnotFlagsToReportFlags(messageSeverity, messageTypes, &object_flags);
if (0 < pCallbackData->objectCount) {
debug_utils_AnnotObjectToDebugReportObject(pCallbackData->pObjects, &object_type, &object_handle);
}
while (pTrav) {
if (pTrav->is_messenger && (pTrav->messenger.messageSeverity & messageSeverity) &&
......@@ -427,22 +429,13 @@ VKAPI_ATTR void VKAPI_CALL terminator_SubmitDebugUtilsMessageEXT(VkInstance inst
VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
VkDebugUtilsMessageTypeFlagsEXT messageTypes,
const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData) {
const struct loader_icd_term *icd_term;
struct loader_instance *inst = (struct loader_instance *)instance;
loader_platform_thread_lock_mutex(&loader_lock);
for (icd_term = inst->icd_terms; icd_term; icd_term = icd_term->next) {
if (icd_term->dispatch.SubmitDebugUtilsMessageEXT != NULL) {
icd_term->dispatch.SubmitDebugUtilsMessageEXT(icd_term->instance, messageSeverity, messageTypes, pCallbackData);
}
}
// Now that all ICDs have seen the message, call the necessary callbacks. Ignoring "bail" return value
// as there is nothing to bail from at this point.
// NOTE: Just make the callback ourselves because there could be one or more ICDs that support this extension
// and each one will trigger the callback to the user. This would result in multiple callback triggers
// per message. Instead, if we get a messaged up to here, then just trigger the message ourselves and
// return. This would still allow the ICDs to trigger their own messages, but won't get any external ones.
struct loader_instance *inst = (struct loader_instance *)instance;
util_SubmitDebugUtilsMessageEXT(inst, messageSeverity, messageTypes, pCallbackData);
loader_platform_thread_unlock_mutex(&loader_lock);
}
......
......@@ -188,6 +188,7 @@ static inline void *trampolineGetProcAddr(struct loader_instance *inst, const ch
if (!strcmp(funcName, "vkDestroyDescriptorUpdateTemplate")) return vkDestroyDescriptorUpdateTemplate;
if (!strcmp(funcName, "vkUpdateDescriptorSetWithTemplate")) return vkUpdateDescriptorSetWithTemplate;
if (!strcmp(funcName, "vkGetImageSparseMemoryRequirements2")) return vkGetImageSparseMemoryRequirements2;
if (!strcmp(funcName, "vkGetBufferMemoryRequirements2")) return vkGetBufferMemoryRequirements2;
// Instance extensions
void *addr;
......@@ -225,6 +226,7 @@ static inline void *loader_non_passthrough_gdpa(const char *name) {
if (!strcmp(name, "GetDeviceProcAddr")) return vkGetDeviceProcAddr;
if (!strcmp(name, "DestroyDevice")) return vkDestroyDevice;
if (!strcmp(name, "GetDeviceQueue")) return vkGetDeviceQueue;
if (!strcmp(name, "GetDeviceQueue2")) return vkGetDeviceQueue2;
if (!strcmp(name, "AllocateCommandBuffers")) return vkAllocateCommandBuffers;
return NULL;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -27,9 +27,6 @@
typedef struct {
union {
#ifdef VK_USE_PLATFORM_MIR_KHR
VkIcdSurfaceMir mir_surf;
#endif // VK_USE_PLATFORM_MIR_KHR
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
VkIcdSurfaceWayland wayland_surf;
#endif // VK_USE_PLATFORM_WAYLAND_KHR
......@@ -92,13 +89,6 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWin32SurfaceKHR(VkInstance insta
VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceWin32PresentationSupportKHR(VkPhysicalDevice physicalDevice,
uint32_t queueFamilyIndex);
#endif
#ifdef VK_USE_PLATFORM_MIR_KHR
VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateMirSurfaceKHR(VkInstance instance, const VkMirSurfaceCreateInfoKHR *pCreateInfo,
const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface);
VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceMirPresentationSupportKHR(VkPhysicalDevice physicalDevice,
uint32_t queueFamilyIndex,
MirConnection *connection);
#endif
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWaylandSurfaceKHR(VkInstance instance,
const VkWaylandSurfaceCreateInfoKHR *pCreateInfo,
......