vulkan: Changes to 'debian-unstable'
CMakeLists.txt | 21
README.md | 8
build_windows_targets.bat | 12
debian/changelog | 7
debian/patches/layers-install-to-cmake-install-libdir.diff | 2
debian/patches/loader-add-install-rule.diff | 4
debian/patches/trim-build.diff | 2
debian/patches/use-mxgot-for-mips64.patch | 6
demos/android/include/lunarg.ppm.h | 4776 +--
demos/cube.c | 372
demos/cube.vert | 4
demos/lunarg.ppm | 248
demos/tri.c | 45
demos/vulkaninfo.c | 105
generator.py | 146
glslang_revert_a5c33d.patch.txt | 18
glslang_revision | 2
include/vulkan/vk_layer.h | 13
include/vulkan/vk_platform.h | 14
include/vulkan/vulkan.h | 169
include/vulkan/vulkan.hpp |20419 +++++++++++++
layers/CMakeLists.txt | 10
layers/README.md | 2
layers/core_validation.cpp | 2431 +
layers/core_validation.h | 86
layers/core_validation_error_enums.h | 14
layers/core_validation_types.h | 192
layers/descriptor_sets.cpp | 195
layers/descriptor_sets.h | 14
layers/image.cpp | 137
layers/linux/VkLayer_core_validation.json | 2
layers/linux/VkLayer_image.json | 2
layers/linux/VkLayer_object_tracker.json | 2
layers/linux/VkLayer_parameter_validation.json | 2
layers/linux/VkLayer_swapchain.json | 2
layers/linux/VkLayer_threading.json | 2
layers/linux/VkLayer_unique_objects.json | 2
layers/object_tracker.cpp | 4050 ++
layers/object_tracker.h | 1176
layers/parameter_name.h | 148
layers/parameter_validation.cpp | 2342 -
layers/parameter_validation_utils.h | 299
layers/swapchain.cpp | 1593 -
layers/swapchain.h | 60
layers/unique_objects.h | 196
layers/vk_layer_config.cpp | 4
layers/vk_layer_config.h | 2
layers/vk_layer_logging.h | 9
layers/vk_layer_settings.txt | 6
layers/vk_layer_table.cpp | 1
layers/vk_layer_utils.cpp | 416
layers/vk_layer_utils.h | 1
layers/vk_validation_layer_details.md | 77
layers/windows/VkLayer_core_validation.json | 2
layers/windows/VkLayer_image.json | 2
layers/windows/VkLayer_object_tracker.json | 2
layers/windows/VkLayer_parameter_validation.json | 2
layers/windows/VkLayer_swapchain.json | 2
layers/windows/VkLayer_threading.json | 2
layers/windows/VkLayer_unique_objects.json | 2
libs/vkjson/CMakeLists.txt | 4
libs/vkjson/vkjson_instance.cc | 9
loader/CMakeLists.txt | 4
loader/LoaderAndLayerInterface.md | 124
loader/debug_report.c | 87
loader/dev_ext_trampoline.c | 1500
loader/extensions.c | 171
loader/extensions.h | 38
loader/gpa_helper.h | 4
loader/loader.c | 496
loader/loader.h | 39
loader/loader.rc | 4
loader/table_ops.h | 28
loader/trampoline.c | 29
loader/vk_loader_platform.h | 61
loader/wsi.c | 358
spirv-headers_revision | 1
spirv-tools_revision | 2
tests/.clang-format | 6
tests/CMakeLists.txt | 1
tests/layer_validation_tests.cpp |11043 ++++---
tests/layers/CMakeLists.txt | 13
tests/layers/linux/VkLayer_test.json | 17
tests/layers/test.cpp | 140
tests/layers/windows/VkLayer_test.json | 17
tests/layers/wrap_objects.cpp | 6
tests/layers/wrap_objects.h | 55
tests/loader_validation_tests.cpp | 653
tests/run_extra_loader_tests.sh | 106
tests/run_loader_tests.sh | 89
tests/test_common.h | 162
tests/test_environment.cpp | 24
tests/vkrenderframework.cpp | 663
tests/vkrenderframework.h | 161
tests/vktestbinding.cpp | 304
tests/vktestbinding.h | 394
tests/vktestframework.cpp | 316
tests/vktestframework.h | 17
tests/vktestframeworkandroid.cpp | 59
tests/vktestframeworkandroid.h | 20
update_external_sources.bat | 15
update_external_sources.sh | 16
vk-generate.py | 103
vk-layer-generate.py | 719
vk.xml | 934
vk_helper.py | 10
vk_layer_documentation_generate.py | 31
vulkan.py | 198
108 files changed, 43225 insertions(+), 15908 deletions(-)
New commits:
commit 4bf11aa19b747fc208bb6440674360f50ee71f52
Author: Timo Aaltonen <tjaalton@debian.org>
Date: Tue Sep 20 08:31:08 2016 +0300
upload to sid
diff --git a/debian/changelog b/debian/changelog
index 452d4aa..4df80be 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,9 +1,9 @@
-vulkan (1.0.26.0+dfsg1-1) UNRELEASED; urgency=medium
+vulkan (1.0.26.0+dfsg1-1) unstable; urgency=medium
* New upstream release.
* patches: Refreshed.
- -- Timo Aaltonen <tjaalton@debian.org> Mon, 19 Sep 2016 21:48:11 +0300
+ -- Timo Aaltonen <tjaalton@debian.org> Tue, 20 Sep 2016 08:30:52 +0300
vulkan (1.0.21.0+dfsg1-1) unstable; urgency=medium
commit a6e65ac25029fbdc438b1366d5a7d87bbbfa328f
Author: Timo Aaltonen <tjaalton@debian.org>
Date: Tue Sep 20 08:28:56 2016 +0300
patches: Refreshed.
diff --git a/debian/changelog b/debian/changelog
index aaa7498..452d4aa 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,7 @@
vulkan (1.0.26.0+dfsg1-1) UNRELEASED; urgency=medium
* New upstream release.
+ * patches: Refreshed.
-- Timo Aaltonen <tjaalton@debian.org> Mon, 19 Sep 2016 21:48:11 +0300
diff --git a/debian/patches/layers-install-to-cmake-install-libdir.diff b/debian/patches/layers-install-to-cmake-install-libdir.diff
index ddfc3a0..710144b 100644
--- a/debian/patches/layers-install-to-cmake-install-libdir.diff
+++ b/debian/patches/layers-install-to-cmake-install-libdir.diff
@@ -15,7 +15,7 @@ Date: Wed Feb 10 15:11:54 2016 -0500
endmacro()
endif()
-@@ -148,7 +148,7 @@ if (WIN32)
+@@ -146,7 +146,7 @@ if (WIN32)
add_library(VkLayer_utils STATIC vk_layer_config.cpp vk_layer_extension_utils.cpp vk_layer_utils.cpp)
else()
add_library(VkLayer_utils SHARED vk_layer_config.cpp vk_layer_extension_utils.cpp vk_layer_utils.cpp)
diff --git a/debian/patches/loader-add-install-rule.diff b/debian/patches/loader-add-install-rule.diff
index 3be8930..b7bf0f7 100644
--- a/debian/patches/loader-add-install-rule.diff
+++ b/debian/patches/loader-add-install-rule.diff
@@ -6,9 +6,9 @@ Date: Wed Feb 10 15:17:06 2016 -0500
--- a/loader/CMakeLists.txt
+++ b/loader/CMakeLists.txt
-@@ -84,4 +84,5 @@ else()
+@@ -86,4 +86,5 @@ else()
add_library(vulkan SHARED ${LOADER_SRCS})
- set_target_properties(vulkan PROPERTIES SOVERSION "1" VERSION "1.0.21")
+ set_target_properties(vulkan PROPERTIES SOVERSION "1" VERSION "1.0.26")
target_link_libraries(vulkan -ldl -lpthread -lm)
+ install(TARGETS vulkan DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
diff --git a/debian/patches/trim-build.diff b/debian/patches/trim-build.diff
index 98cd147..1992e09 100644
--- a/debian/patches/trim-build.diff
+++ b/debian/patches/trim-build.diff
@@ -1,6 +1,6 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
-@@ -103,10 +103,10 @@ else()
+@@ -101,10 +101,10 @@ else()
endif()
option(BUILD_LOADER "Build loader" ON)
diff --git a/debian/patches/use-mxgot-for-mips64.patch b/debian/patches/use-mxgot-for-mips64.patch
index 14b60fd..2c1f17f 100644
--- a/debian/patches/use-mxgot-for-mips64.patch
+++ b/debian/patches/use-mxgot-for-mips64.patch
@@ -3,8 +3,8 @@ Author: Dejan Latinovic <Dejan.Latinovic@imgtec.com>
--- a/layers/CMakeLists.txt
+++ b/layers/CMakeLists.txt
-@@ -104,6 +104,12 @@ else()
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpointer-arith")
+@@ -102,6 +102,12 @@ else()
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpointer-arith -Wno-unused-function -Wno-sign-compare -fvisibility=default")
endif()
+if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "mips64")
@@ -14,5 +14,5 @@ Author: Dejan Latinovic <Dejan.Latinovic@imgtec.com>
+endif()
+
add_custom_command(OUTPUT vk_dispatch_table_helper.h
- COMMAND ${PYTHON_CMD} ${PROJECT_SOURCE_DIR}/vk-generate.py ${DisplayServer} dispatch-table-ops layer > vk_dispatch_table_helper.h
+ COMMAND ${PYTHON_CMD} ${PROJECT_SOURCE_DIR}/vk-generate.py AllPlatforms dispatch-table-ops layer > vk_dispatch_table_helper.h
DEPENDS ${PROJECT_SOURCE_DIR}/vk-generate.py ${PROJECT_SOURCE_DIR}/vulkan.py)
commit e09305ecad13520f2278e9432442ce7b82958af3
Author: Timo Aaltonen <tjaalton@debian.org>
Date: Tue Sep 20 08:28:30 2016 +0300
delete new files in build-android/ and windowsRuntimeInstaller/
diff --git a/build-android/AndroidManifest.xml b/build-android/AndroidManifest.xml
deleted file mode 100644
index 45a26b6..0000000
--- a/build-android/AndroidManifest.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.VulkanLayerValidationTests" android:versionCode="1" android:versionName="1.0">
-
- <!-- This is the platform API where NativeActivity was introduced. -->
- <uses-sdk android:minSdkVersion="23" android:targetSdkVersion="23"/>
-
- <!-- This .apk has no Java code itself, so set hasCode to false. -->
- <application android:label="@string/app_name" android:hasCode="false" android:debuggable='false'>
-
- <!-- This allows writing log files to sdcard -->
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
-
- <!-- Our activity is the built-in NativeActivity framework class.
- This will take care of integrating with our NDK code. -->
- <activity android:name="android.app.NativeActivity" android:label="@string/app_name" android:exported="true">
- <!-- Tell NativeActivity the name of or .so -->
- <meta-data android:name="android.app.lib_name" android:value="VulkanLayerValidationTests"/>
- <intent-filter>
- <action android:name="android.intent.action.MAIN"/>
- <category android:name="android.intent.category.LAUNCHER"/>
- </intent-filter>
- </activity>
- </application>
-
-</manifest>
diff --git a/build-android/res/values/strings.xml b/build-android/res/values/strings.xml
deleted file mode 100644
index 8ff71b0..0000000
--- a/build-android/res/values/strings.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright 2016 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.
--->
-
-<!-- This file contains resource definitions for displayed strings, allowing
- them to be changed based on the locale and options. -->
-
-<resources>
- <!-- Simple strings. -->
- <string name="app_name">VulkanLayerValidationTests</string>
-
-</resources>
diff --git a/build-android/spirv-headers_revision_android b/build-android/spirv-headers_revision_android
deleted file mode 100644
index 74846cc..0000000
--- a/build-android/spirv-headers_revision_android
+++ /dev/null
@@ -1 +0,0 @@
-3814effb879ab5a98a7b9288a4b4c7849d2bc8ac
diff --git a/windowsRuntimeInstaller/ConfigureRT.vcxproj b/windowsRuntimeInstaller/ConfigureRT.vcxproj
deleted file mode 100644
index 2627b17..0000000
--- a/windowsRuntimeInstaller/ConfigureRT.vcxproj
+++ /dev/null
@@ -1,78 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{09753397-FB1C-469E-9BCA-8F0A19B9A8DA}</ProjectGuid>
- <RootNamespace>ConfigureRT</RootNamespace>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v120</PlatformToolset>
- <CharacterSet>MultiByte</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v120</PlatformToolset>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>MultiByte</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup />
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <WarningLevel>Level2</WarningLevel>
- <Optimization>Disabled</Optimization>
- <SDLCheck>false</SDLCheck>
- <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
- </ClCompile>
- <Link>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <SubSystem>Windows</SubSystem>
- <EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <WarningLevel>Level2</WarningLevel>
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- <SDLCheck>false</SDLCheck>
- <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
- </ClCompile>
- <Link>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- <SubSystem>Windows</SubSystem>
- <EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
- </Link>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="configure_runtime.c" />
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project>
\ No newline at end of file
diff --git a/windowsRuntimeInstaller/configure_runtime.c b/windowsRuntimeInstaller/configure_runtime.c
deleted file mode 100644
index a8460a1..0000000
--- a/windowsRuntimeInstaller/configure_runtime.c
+++ /dev/null
@@ -1,700 +0,0 @@
-/******************************************************************************
- * Copyright (c) 2016 The Khronos Group
- * Copyright (c) 2016 Valve Corporation
- * Copyright (c) 2016 LunarG, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you man not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is destributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language govering permissions and
- * limitations under the License.
- *
- * Author: Lenny Komow <lenny@lunarg.com>
- *
- *****************************************************************************/
-
-/*
- * This program is used by the Vulkan Runtime Installer/Uninstaller to:
- * - Copy the most recent vulkan<majorabi>-*.dll in C:\Windows\System32
- * to vulkan<majorabi>.dll
- * - Copy the most recent version of vulkaninfo-<abimajor>-*.exe in
- * C:\Windows\System32 to vulkaninfo.exe
- * - The same thing is done for those files in C:\Windows\SysWOW64, but
- * only on a 64-bit target
- * - Set the layer registry entried to point to the layer json files in
- * the Vulkan SDK associated with the most recent vulkan*.dll
- *
- * The program must be called with the following parameters:
- * --major-abi: A single number specifying the major abi version
- */
-
-// Compile with: `cl.exe configure_runtime.c /link advapi32.lib`
-// Be sure to use the x86 version of cl.exe
-
-#include <stdbool.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <windows.h>
-
-// This hack gets Visual Studio 2013 to handle C99 stuff properly
-// If we drop support for 2013, it would be a good idea to remove this
-#if _MSC_VER < 1900
-#define inline __inline
-#define snprintf _snprintf
-#endif
-
-#if defined(_WIN64)
-#error "This program is designed only as a 32-bit program. It should not be built as 64-bit."
-#endif
-
-#define COPY_BUFFER_SIZE (1024)
-#define CHECK_ERROR(statement) { int error = (statement); if(error) return error; }
-#define CHECK_ERROR_HANDLED(statement, handler) { int error = (statement); if(error) { { handler } return error; } }
-#define SDK_VERSION_BUFFER_SIZE (64)
-
-enum Platform
-{
- PLATFORM_X64,
- PLATFORM_X86,
-};
-
-#pragma pack(1)
-struct SDKVersion
-{
- long major;
- long minor;
- long patch;
- long build;
- char extended[SDK_VERSION_BUFFER_SIZE];
-};
-
-const char* FLAG_ABI_MAJOR = "--abi-major";
-const char* PATH_SYSTEM32 = "\\SYSTEM32\\";
-const char* PATH_SYSWOW64 = "\\SysWOW64\\";
-
-inline size_t max_s(size_t a, size_t b) { return a > b ? a : b; }
-inline size_t min_s(size_t a, size_t b) { return a > b ? a : b; }
-
-// Add the registry entries for all explicit layers
-//
-// log (input) - Logging file stream
-// install_path (input) - The installation path of the SDK which provides the layers
-// platform (input) - The platform to set the installation for (x64 or x86)
-// Returns: Zero on success, an error code on failure
-int add_explicit_layers(FILE* log, const char* install_path, enum Platform platform);
-
-// Compare two sdk versions
-//
-// Returns: Zero if they are equal, below zero if a predates b, greater than zero if b predates a
-int compare_versions(const struct SDKVersion* a, const struct SDKVersion* b);
-
-// Locate all of the SDK installations
-//
-// install_paths (output) - A poiner to an array of the installations paths
-// install_versions (output) - A pointer to an array of the SDK versions
-// count (output) - A pointer to the number of items in each array
-// Returns: Zero on success, an error code on failure
-//
-// Both install_paths and install_versions are allocated on the heap. To free them properly,
-// call free_installations(), even if this function returned an error code. The orders of
-// install_paths and install_versions match, so (*install_paths)[2] is guaranteed to match
-// (*install_versions)[2]
-int find_installations(char*** install_paths, struct SDKVersion** install_versions, size_t* count);
-
-// Free the memory allocated by find_installations()
-void free_installations(char** install_paths, struct SDKVersion* install_versions, size_t count);
-
-// Parse command line arguments for the program
-//
-// log (input) - Logging file stream
-// argc (input) - The argument count
-// argv (input) - An array of argument strings
-// abi_major (output) - The major abi version from the arguments
-// Returns: Zero on success, an error code on failure
-int parse_arguments(FILE* log, int argc, char** argv, long* abi_major);
-
-// Read the version from a string
-//
-// version_string (input) - A string in the format <abi>.<major>.<minor>.<patch>.<build>.<extended>
-// version (output) - The version indicated by the input string
-// Returns: Zero on success, an error code on failure
-int read_version(const char* version_string, struct SDKVersion* version);
-
-// Read the version from a filename
-//
-// filename (input) - The name of a .dll or .exe file, in the format
-// somename-<abi>-<major>-<minor>-<path>-<build>-<extended>.dll
-// version (output) - The versions indicated by the input string
-// Returns: Zero on success, an error code on failure
-int read_version_from_filename(const char* filename, struct SDKVersion* version);
-
-// Remove explicit layers from the Windows registry
-//
-// log (input) - Loggin file stream
-// install_paths (input) - An array of every vulkan installation path
-// count (input) - The number of vulkan installations
-// platform (input) - The platform (x64 or x86) of the registry to use (both exist on x64)
-// Returns: Zero on success, an error code on failure
-int remove_explicit_layers(FILE* log, const char** install_paths, size_t count, enum Platform platform);
-
-// Update all explicity layers in the windows registry
-//
-// log (input) - Logging file stream
-// platform (input) - The platform of the OS (both registries will be modified if this is x64)
-// version (input) - The version that should be set to current (if it exists)
-// Returns: Zero on success, an error code on failure
-int update_registry_layers(FILE* log, enum Platform platform, const struct SDKVersion* version);
-
-// Update a single vulkan system file (vulkan.dll or vulkaninfo.exe)
-//
-// log (input) - Loggin file stream
-// name (input) - The name (excuding file extension) of the file to be updated
-// extension (input) - The file extensions of the file to be updated
-// path (input) - The directory of the file (usually System32 or SysWOW64)
-// abi_major (input) - The ABI major version to be updated
-// append_abi_major (input) - Whether or not the ABI number should be appended to the filename
-// latest_version (output) - The version of the runtime which the file was updated to
-// Returns: Zero on success, an error code on failure
-int update_system_file(FILE* log, const char* name, const char* extension, const char* path,
- long abi_major, bool append_abi_major, struct SDKVersion* latest_version);
-
-// Update vulkan.dll and vulkaninfo.exe in all of the windows directories (System32 and SysWOW64)
-//
-// log (input) - Loging file stream
-// abi_major (input) - The ABI major version of the files that should be used
-// platform (input) - The platform for the current OS
-// latest_runtime_version (output) - The version that the runtime files were updated to
-int update_windows_directories(FILE* log, long abi_major, enum Platform platform,
- struct SDKVersion* latest_runtime_version);
-
-int main(int argc, char** argv)
-{
- // Get the OS platform (x86 or x64)
- BOOL is_64_bit;
- IsWow64Process(GetCurrentProcess(), &is_64_bit);
- enum Platform platform = is_64_bit ? PLATFORM_X64 : PLATFORM_X86;
-
- FILE* log = fopen("configure_rt.log", "w");
- if(log == NULL) {
- return 10;
- }
-
- // Parse the arguments to get the abi version and the number of bits of the OS
- long abi_major;
- CHECK_ERROR_HANDLED(parse_arguments(log, argc, argv, &abi_major), { fclose(log); });
-
- // This makes System32 and SysWOW64 not do any redirection (well, until 128-bit is a thing)
- Wow64DisableWow64FsRedirection(NULL);
-
- // Update System32 (on all systems) and SysWOW64 on 64-bit system
- struct SDKVersion latest_runtime_version;
- CHECK_ERROR_HANDLED(update_windows_directories(log, abi_major, platform, &latest_runtime_version),
- { fclose(log); });
-
- // Update the explicit layers that are set in the windows registry
- CHECK_ERROR_HANDLED(update_registry_layers(log, platform, &latest_runtime_version), { fclose(log); });
-
- fclose(log);
- return 0;
-}
-
-int add_explicit_layers(FILE* log, const char* install_path, enum Platform platform)
-{
- switch(platform)
- {
- case PLATFORM_X64:
- fprintf(log, "Updating x64 explicit layers to path: %s\n", install_path);
- break;
- case PLATFORM_X86:
- fprintf(log, "Updating x86 explicit layers to path: %s\n", install_path);
- break;
- }
-
- // If this is a 32 bit system, we allow redirection to point this at the 32-bit registries.
- // If not, we add the flag KEY_WOW64_64KEY, to disable redirection for this node.
- HKEY hKey;
- REGSAM flags = KEY_ALL_ACCESS;
- if(platform == PLATFORM_X64) {
- flags |= KEY_WOW64_64KEY;
- }
-
- // Create (if needed) and open the explicit layer key
- if(RegCreateKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Khronos\\Vulkan\\ExplicitLayers",
- 0, NULL, REG_OPTION_NON_VOLATILE, flags, NULL, &hKey, NULL) != ERROR_SUCCESS) {
- return 20;
- }
-
- const char* pattern = platform == PLATFORM_X64 ? "%s\\Bin\\VkLayer*.json" : "%s\\Bin32\\VkLayer*.json";
- int filter_size = snprintf(NULL, 0, pattern, install_path) + 1;
- if(filter_size < 0) {
- return 30;
- }
- char* filter = malloc(filter_size);
- snprintf(filter, filter_size, pattern, install_path);
-
- WIN32_FIND_DATA find_data;
- HANDLE find = FindFirstFile(filter, &find_data);
- free(filter);
- for(bool at_end = (find != INVALID_HANDLE_VALUE); at_end;
- at_end = FindNextFile(find, &find_data)) {
-
- const char* layer_pattern = platform == PLATFORM_X64 ? "%s\\Bin\\%s" : "%s\\Bin32\\%s";
- int layer_size = snprintf(NULL, 0, layer_pattern, install_path, find_data.cFileName) + 1;
- if(layer_size < 0) {
- return 40;
- }
- char* layer = malloc(layer_size);
- snprintf(layer, layer_size, layer_pattern, install_path, find_data.cFileName);
-
- fprintf(log, "Adding explicit layer: %s\n", layer);
-
- DWORD zero = 0;
- LSTATUS err = RegSetValueEx(hKey, layer, zero, REG_DWORD, (BYTE*) &zero, sizeof(DWORD));
- free(layer);
- if(err != ERROR_SUCCESS) {
- return 50;
- }
- }
-
- RegCloseKey(hKey);
- return 0;
-}
-
-int compare_versions(const struct SDKVersion* a, const struct SDKVersion* b)
-{
- // Compare numerical versions
- for(int i = 0; i < 4; ++i) {
- long* a_current = ((long*) a) + i;
- long* b_current = ((long*) b) + i;
-
- if(*a_current < *b_current) {
- return -4 + i;
- } else if(*b_current < *a_current) {
- return 4 - i;
- }
- }
-
- // An empty string should be considered greater (and therefore more recent) than one with test
- if(a->extended[0] == '\0' && b->extended[0] != '\0') {
- return 1;
- } else if(b->extended[0] == '\0' && a->extended[0] != '\0') {
- return -1;
- }
-
- // Otherwise, just do a strncmp
- return strncmp(a->extended, b->extended, SDK_VERSION_BUFFER_SIZE);
-}
-
-int find_installations(char*** install_paths, struct SDKVersion** install_versions, size_t* count)
-{
- *install_paths = malloc(sizeof(char*) * 64);
- *install_versions = malloc(sizeof(struct SDKVersion) * 64);
- *count = 0;
-
- // We want the 64-bit registries on 64-bit windows, and the 32-bit registries on 32-bit Windows.
- // KEY_WOW64_64KEY accomplishes this because it gets ignored on 32-bit Windows.
- HKEY hKey;
- if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall",
- 0, KEY_READ | KEY_WOW64_64KEY, &hKey) != ERROR_SUCCESS) {
- return 90;
- }
-
- DWORD keyCount, keyLen;
- RegQueryInfoKey(hKey, NULL, NULL, NULL, &keyCount, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
- for(int i = 0; i < keyCount; ++i) {
- TCHAR name[COPY_BUFFER_SIZE];
- DWORD nameSize = COPY_BUFFER_SIZE;
- RegEnumKeyEx(hKey, i, name, &nameSize, NULL, NULL, NULL, NULL);
-
- if(strncmp("VulkanSDK", name, 9)) {
- continue;
- }
-
- HKEY subKey;
- if(RegOpenKeyEx(hKey, name, 0, KEY_READ | KEY_WOW64_64KEY, &subKey) != ERROR_SUCCESS) {
- continue;
- }
-
- bool found_installation = false, found_version = false;
- DWORD valueCount;
- RegQueryInfoKey(subKey, NULL, NULL, NULL, NULL, NULL, NULL, &valueCount, NULL, NULL, NULL, NULL);
- for(int j = 0; j < valueCount; ++j) {
-
- TCHAR name[COPY_BUFFER_SIZE], value[COPY_BUFFER_SIZE];
- DWORD type, buffSize = COPY_BUFFER_SIZE;
- RegEnumValue(subKey, j, name, &buffSize, NULL, &type, value, &buffSize);
- if(type == REG_SZ && !strcmp("InstallDir", name)) {
- *install_paths = realloc(*install_paths, sizeof(char*) * ((*count) + 1));
- (*install_paths)[*count] = malloc(sizeof(char) * COPY_BUFFER_SIZE);
- strcpy((*install_paths)[*count], value);
- found_installation = true;
- } else if(type == REG_SZ && !strncmp("DisplayVersion", name, 8)) {
- *install_versions = realloc(*install_versions, sizeof(struct SDKVersion) * ((*count) + 1));
- CHECK_ERROR(read_version(value, (*install_versions) + *count));
- found_version = true;
- }
-
- if(found_installation && found_version) {
- ++(*count);
- break;
- }
- }
- RegCloseKey(subKey);
-
- if(!(found_installation && found_version)) {
- RegCloseKey(hKey);
- return 100;
- }
- }
- RegCloseKey(hKey);
-
- return 0;
-}
-
-void free_installations(char** install_paths, struct SDKVersion* install_versions, size_t count)
-{
- for(size_t i = 0; i < count; ++i) {
- free(install_paths[i]);
- }
- free(install_paths);
- free(install_versions);
-}
-
-int parse_arguments(FILE* log, int argc, char** argv, long* abi_major)
-{
- *abi_major = 0;
-
- // Parse arguments
- for(int i = 0; i < argc; ++i) {
- if(!strcmp(argv[i], FLAG_ABI_MAJOR)) {
- if(i + 1 == argc) {
- fprintf(log, "ERROR: No value given for flag %s.\n", FLAG_ABI_MAJOR);
- return 110;
- }
- *abi_major = strtol(argv[++i], NULL, 10);
- if(*abi_major == 0) {
- fprintf(log, "ERROR: Unable to parse ABI major version as integer.\n");
- return 120;
- }
- }
- }
-
- // Check that we have everything we need
- if(*abi_major == 0 ) {
- fprintf(log, "ERROR: Flag %s must be provided.\n", FLAG_ABI_MAJOR);
- return 130;
- }
-
- // It all worked fine
- fprintf(log, "Found ABI: %ld\n\n", *abi_major);
- return 0;
-}
-
-int read_version(const char* version_string, struct SDKVersion* version)
-{
- size_t borders[4], dot_count = 0, i;
- for(i = 0; dot_count < 3 && version_string[i] != '\0'; ++i) {
- if(version_string[i] == '.') {
- borders[dot_count++] = i + 1;
- }
- }
- borders[3] = i + 1;
-
- if(dot_count < 3) {
- return 140;
- }
-
- // Read the version number
- version->major = strtol(version_string, NULL, 10);
- version->minor = strtol(version_string + borders[0], NULL, 10);
- version->patch = strtol(version_string + borders[1], NULL, 10);
- version->build = strtol(version_string + borders[2], NULL, 10);
-
- strncpy(version->extended, version_string + borders[3] + 1,
- min_s(SDK_VERSION_BUFFER_SIZE - 1, strlen(version_string + borders[3] + 1)));
-
- return 0;
-}
-
-int read_version_from_filename(const char* filename, struct SDKVersion* version)
-{
- size_t borders[5], dash_count = 0;
-
- // Locate all of the dashes that divides different version numbers
- size_t i;
- for(i = 0; dash_count < 5; ++i) {
- if(filename[i] == '-' && dash_count == 0) {
- ++dash_count;
- } else if(filename[i] == '-') {
- borders[dash_count++ - 1] = i + 1;
- } else if(filename[i] == '\0') {
- return 150;
- }
- }
- borders[4] = i + 1;
-
- // Read the version number
- version->major = strtol(filename + borders[0], NULL, 10);
- version->minor = strtol(filename + borders[1], NULL, 10);
- version->patch = strtol(filename + borders[2], NULL, 10);
- version->build = strtol(filename + borders[3], NULL, 10);
-
- if(strcmp(filename + borders[4] + 1, "dll") && strcmp(filename + borders[4] + 1, "exe")) {
- strncpy(version->extended, filename + borders[4] + 1, SDK_VERSION_BUFFER_SIZE - 1);
- size_t file_len = strlen(filename + borders[4] + 1);
- if(file_len - 4 < SDK_VERSION_BUFFER_SIZE) {
- version->extended[file_len - 4] = '\0';
- }
- } else {
- version->extended[0] = '\0';
- }
-
- for(size_t i = 0; version->extended[i] != '\0' && i < SDK_VERSION_BUFFER_SIZE; ++i) {
- if(version->extended[i] == '-') {
- version->extended[i] = '.';
- }
- }
-
- return 0;
-}
-
-int remove_explicit_layers(FILE* log, const char** install_paths, size_t count, enum Platform platform)
-{
- switch(platform)
- {
- case PLATFORM_X64:
- fprintf(log, "Removing x64 explicit layers from registry\n");
- break;
- case PLATFORM_X86:
- fprintf(log, "Removing x86 explicit layers from registry\n");
- break;
- }
-
- bool removed_one;
- do {
- // If this is a 32 bit system, we allow redirection to point this at the 32-bit registries.
- // If not, we add the flag KEY_WOW64_64KEY, to disable redirection for this node.
- HKEY hKey;
- REGSAM flags = KEY_ALL_ACCESS;
- if(platform == PLATFORM_X64) {
- flags |= KEY_WOW64_64KEY;
- }
-
- // Create (if needed) and open the explicit layer key
- if(RegCreateKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Khronos\\Vulkan\\ExplicitLayers",
- 0, NULL, REG_OPTION_NON_VOLATILE, flags, NULL, &hKey, NULL) != ERROR_SUCCESS) {
- return 160;
- }
-
- removed_one = false;
- DWORD valueCount;
- RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, NULL, NULL, &valueCount, NULL, NULL, NULL, NULL);
- for(DWORD i = 0; i < valueCount; ++i) {
- TCHAR name[COPY_BUFFER_SIZE];
- DWORD type, buffSize = COPY_BUFFER_SIZE;
- RegEnumValue(hKey, i, name, &buffSize, NULL, &type, NULL, NULL);
-
- for(size_t j = 0; j < count; ++j) {
- if(strncmp(install_paths[j], name, strlen(install_paths[j])) == 0) {
- fprintf(log, "Removing explicit layer entry: %s\n", name);
- LSTATUS err = RegDeleteValue(hKey, name);
- if(err != ERROR_SUCCESS) {
- return 170;
- }
- removed_one = true;
- break;
- }
- }
- if(removed_one) {
- break;
- }
- }
-
- RegCloseKey(hKey);
- } while(removed_one);
-
- return 0;
-}
-
-int update_registry_layers(FILE* log, enum Platform platform, const struct SDKVersion* version)
-{
- char** install_paths;
- struct SDKVersion* install_versions;
- size_t count;
- CHECK_ERROR_HANDLED(find_installations(&install_paths, &install_versions, &count),
- { free_installations(install_paths, install_versions, count); });
- for(size_t i = 0; i < count; ++i) {
- fprintf(log, "Found installation of %ld.%ld.%ld.%ld in: %s\n", install_versions[i].major,
- install_versions[i].minor, install_versions[i].patch, install_versions[i].build, install_paths[i]);
- }
- fprintf(log, "\n");
- if(platform == PLATFORM_X64) {
- CHECK_ERROR_HANDLED(remove_explicit_layers(log, install_paths, count, PLATFORM_X64),
- { free_installations(install_paths, install_versions, count); });
- fprintf(log, "\n");
- }
- CHECK_ERROR_HANDLED(remove_explicit_layers(log, install_paths, count, PLATFORM_X86),
- { free_installations(install_paths, install_versions, count); });
- fprintf(log, "\n");
-
- if(version->major == 0 && version->minor == 0 && version->patch == 0 && version->build == 0) {
- free_installations(install_paths, install_versions, count);
- return 0;
- }
-
- for(size_t i = 0; i < count; ++i) {
- if(compare_versions(install_versions + i, version) == 0) {
- if(platform == PLATFORM_X64) {
- CHECK_ERROR_HANDLED(add_explicit_layers(log, install_paths[i], PLATFORM_X64),
- { free_installations(install_paths, install_versions, count); });
- fprintf(log, "\n");
- }
- CHECK_ERROR_HANDLED(add_explicit_layers(log, install_paths[i], PLATFORM_X86),
- { free_installations(install_paths, install_versions, count); });
- break;
- }
- }
- free_installations(install_paths, install_versions, count);
- return 0;
-}
-
-//int update_system_file(FILE* log, const char* name, const char* extension, const char* path,
-// long abi_major, bool append_abi_major, struct SDKVersion* latest_version)
-int update_system_file(FILE* log, const char* name, const char* extension, const char* path,
- long abi_major, bool leave_abi_major, struct SDKVersion* latest_version)
-{
- // Generate the filter string
- const char* pattern = "%s%s-%ld-*-*-*-*%s";
- int filter_size = snprintf(NULL, 0, pattern, path, name, abi_major, extension) + 1;
- if(filter_size < 0) {
- return 180;
- }
- char* filter = malloc(filter_size);
- snprintf(filter, filter_size, pattern, path, name, abi_major, extension);
-
- // Find all of the files that match the pattern
- char* latest_filename = malloc(64);
- memset(latest_version, 0, sizeof(struct SDKVersion));
- WIN32_FIND_DATA find_data;
- HANDLE find = FindFirstFile(filter, &find_data);
- free(filter);
- for(bool at_end = (find != INVALID_HANDLE_VALUE); at_end;
- at_end = FindNextFile(find, &find_data)) {
-
- struct SDKVersion version;
- CHECK_ERROR_HANDLED(read_version_from_filename(find_data.cFileName, &version), { free(latest_filename); });
-
- // Decide if this is the latest file
- if(compare_versions(latest_version, &version) < 0) {
- *latest_version = version;
- const char* latestPattern = "%s%s";
- int size = snprintf(NULL, 0, latestPattern, path, find_data.cFileName) + 1;
- if(size < 0) {
- free(latest_filename);
- return 200;
- }
- latest_filename = realloc(latest_filename, size);
- snprintf(latest_filename, size, latestPattern, path, find_data.cFileName);
- }
- }
- FindClose(find);
-
- // Make sure something was found
- if(latest_version->major == 0 && latest_version->minor == 0 && latest_version->patch == 0 &&
- latest_version->build == 0) {
- fprintf(log, "Didn't find any version of %s%s\n", name, extension);
- return 0;
- }
-
- fprintf(log, "Found latest version of %s%s: %ld.%ld.%ld.%ld\n", name, extension, latest_version->major,
- latest_version->minor, latest_version->patch, latest_version->build);
-
Reply to: