Skip to content

Commit

Permalink
tests: Use VK_EXT_layer_settings for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
christophe-lunarg committed Aug 18, 2023
1 parent b34cae8 commit 6f7f75a
Show file tree
Hide file tree
Showing 22 changed files with 64 additions and 558 deletions.
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ endif()

find_package(VulkanUtilityLibraries CONFIG REQUIRED QUIET)

target_compile_definitions(Vulkan::LayerSettings INTERFACE VK_ENABLE_BETA_EXTENSIONS) # Enable beta Vulkan extensions

option(BUILD_WERROR "Treat compiler warnings as errors")
if (BUILD_WERROR)
add_compile_options("$<IF:$<CXX_COMPILER_ID:MSVC>,/WX,-Werror>")
Expand Down
1 change: 1 addition & 0 deletions layers/VkLayer_khronos_memory_decompression.def
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ vkGetInstanceProcAddr
vkGetDeviceProcAddr
vkEnumerateInstanceExtensionProperties
vkNegotiateLoaderLayerInterfaceVersion
vkEnumerateInstanceLayerSettingsEXT
1 change: 1 addition & 0 deletions layers/VkLayer_khronos_shader_object.def
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ LIBRARY VkLayer_khronos_shader_object
EXPORTS
vkGetInstanceProcAddr
vkGetDeviceProcAddr
vkEnumerateInstanceLayerSettingsEXT
9 changes: 5 additions & 4 deletions layers/VkLayer_khronos_synchronization2.def
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

;;;; Begin Copyright Notice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Copyright (c) 2015-2021 The Khronos Group Inc.
; Copyright (c) 2015-2021 Valve Corporation
; Copyright (c) 2015-2021 LunarG, Inc.
; Copyright (c) 2020 Intel Corporation
; Copyright (c) 2015-2021, 2023 The Khronos Group Inc.
; Copyright (c) 2015-2021, 2023 Valve Corporation
; Copyright (c) 2015-2021, 2023 LunarG, Inc.
; Copyright (c) 2020 Intel Corporation
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
Expand All @@ -27,3 +27,4 @@ EXPORTS
vkGetInstanceProcAddr
vkGetDeviceProcAddr
vkNegotiateLoaderLayerInterfaceVersion
vkEnumerateInstanceLayerSettingsEXT
9 changes: 5 additions & 4 deletions layers/VkLayer_khronos_timeline_semaphore.def
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

;;;; Begin Copyright Notice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Copyright (c) 2015-2019, 2021 The Khronos Group Inc.
; Copyright (c) 2015-2019, 2021 Valve Corporation
; Copyright (c) 2015-2019, 2021 LunarG, Inc.
; Copyright (c) 2020 Intel Corporation
; Copyright (c) 2015-2019, 2021, 2023 The Khronos Group Inc.
; Copyright (c) 2015-2019, 2021, 2023 Valve Corporation
; Copyright (c) 2015-2019, 2021, 2023 LunarG, Inc.
; Copyright (c) 2020 Intel Corporation
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
Expand All @@ -27,3 +27,4 @@ EXPORTS
vkGetInstanceProcAddr
vkGetDeviceProcAddr
vkEnumerateInstanceExtensionProperties
vkEnumerateInstanceLayerSettingsEXT
1 change: 1 addition & 0 deletions layers/libVkLayer_khronos_memory_decompression.map
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
vkEnumerateInstanceLayerProperties;
vkEnumerateDeviceExtensionProperties;
vkEnumerateDeviceLayerProperties;
vkEnumerateInstanceLayerSettingsEXT;
local:
*;
};
1 change: 1 addition & 0 deletions layers/libVkLayer_khronos_shader_object.map
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
vkEnumerateInstanceLayerProperties;
vkEnumerateDeviceExtensionProperties;
vkEnumerateDeviceLayerProperties;
vkEnumerateInstanceLayerSettingsEXT;
local:
*;
};
1 change: 1 addition & 0 deletions layers/libVkLayer_khronos_synchronization2.map
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
vkEnumerateInstanceLayerProperties;
vkEnumerateDeviceExtensionProperties;
vkEnumerateDeviceLayerProperties;
vkEnumerateInstanceLayerSettingsEXT;
local:
*;
};
1 change: 1 addition & 0 deletions layers/libVkLayer_khronos_timeline_semaphore.map
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
vkEnumerateInstanceLayerProperties;
vkEnumerateDeviceExtensionProperties;
vkEnumerateDeviceLayerProperties;
vkEnumerateInstanceLayerSettingsEXT;
local:
*;
};
2 changes: 1 addition & 1 deletion scripts/known_good.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"sub_dir": "Vulkan-Utility-Libraries",
"build_dir": "Vulkan-Utility-Libraries/build",
"install_dir": "Vulkan-Utility-Libraries/build/install",
"commit": "c0525368d724896349b40d8aa7b779f32bbbed0c",
"commit": "6999ef9b82191d4824cd105aba1f5f2433b4ccb6",
"deps": [
{
"var_name": "VULKAN_HEADERS_INSTALL_DIR",
Expand Down
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ find_package(glslang REQUIRED CONFIG QUIET)

target_link_libraries(vk_extension_layer_tests PRIVATE
VkExtLayer_utils
Vulkan::LayerSettings
Vulkan::Headers
GTest::gtest
GTest::gtest_main
Expand Down
12 changes: 10 additions & 2 deletions tests/decompression_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,20 @@
#include "decompression_data.h"

void DecompressionTest::SetUp() {
SetEnvironment("VK_MEMORY_DECOMPRESSION_FORCE_ENABLE", "1");
VkBool32 force_enable = VK_TRUE;

VkLayerSettingEXT settings[] = {
{"VK_LAYER_KHRONOS_memory_decompression", "force_enable", VK_LAYER_SETTING_TYPE_BOOL32_EXT, 1, &force_enable}};

VkLayerSettingsCreateInfoEXT layer_settings_create_info{
VK_STRUCTURE_TYPE_LAYER_SETTINGS_EXT, nullptr,
static_cast<uint32_t>(std::size(settings)), &settings[0]};

VkExtensionLayerTest::SetUp();
SetTargetApiVersion(VK_API_VERSION_1_2);
VkExtensionLayerTest::AddSurfaceInstanceExtension();
instance_layers_.push_back("VK_LAYER_KHRONOS_memory_decompression");
ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor));
ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor, &layer_settings_create_info));

VkExtensionLayerTest::AddSwapchainDeviceExtension();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/extension_layer_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ int main(int argc, char **argv) {
#endif

// Set VK_LAYER_PATH so that the loader can find the layers
SetEnvironment("VK_LAYER_PATH", LAYER_BUILD_LOCATION);
VkTestFramework::setEnvironmentSetting("VK_LAYER_PATH", LAYER_BUILD_LOCATION);

::testing::InitGoogleTest(&argc, argv);
VkTestFramework::InitArgs(&argc, argv);
Expand Down
1 change: 1 addition & 0 deletions tests/extension_layer_tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#define VKLAYERTEST_H

#include <vulkan/vulkan.h>
#include <vulkan/layer/vk_layer_settings.hpp>

#if defined(ANDROID)
#include <android/log.h>
Expand Down
16 changes: 11 additions & 5 deletions tests/shader_object_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,23 @@

#include "extension_layer_tests.h"
#include "shader_object_tests.h"
#include "vk_layer_config.h"

void ShaderObjectTest::SetUp() {
SetEnvironment("VK_SHADER_OBJECT_FORCE_ENABLE", "1");
const std::string layer_path = std::string(SHADER_OBJECT_BINARY_PATH);
SetEnvironment("VK_LAYER_PATH", layer_path.c_str());
VkBool32 force_enable = VK_TRUE;

VkLayerSettingEXT settings[] = {
{"VK_LAYER_KHRONOS_shader_object", "force_enable", VK_LAYER_SETTING_TYPE_BOOL32_EXT, 1, &force_enable}
};

VkLayerSettingsCreateInfoEXT layer_settings_create_info{
VK_STRUCTURE_TYPE_LAYER_SETTINGS_EXT, nullptr,
static_cast<uint32_t>(std::size(settings)), &settings[0]};

VkExtensionLayerTest::SetUp();
SetTargetApiVersion(VK_API_VERSION_1_1);
VkExtensionLayerTest::AddSurfaceInstanceExtension();
instance_layers_.push_back("VK_LAYER_KHRONOS_shader_object");
ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor));
ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor, &layer_settings_create_info));

VkExtensionLayerTest::AddSwapchainDeviceExtension();
}
Expand Down
14 changes: 11 additions & 3 deletions tests/synchronization2_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,23 @@

#include "extension_layer_tests.h"
#include "synchronization2_tests.h"
#include "vk_layer_config.h"

void Sync2Test::SetUp() {
SetEnvironment("VK_SYNCHRONIZATION2_FORCE_ENABLE", "1");
VkBool32 force_enable = VK_TRUE;

VkLayerSettingEXT settings[] = {
{"VK_LAYER_KHRONOS_synchronization2", "force_enable", VK_LAYER_SETTING_TYPE_BOOL32_EXT, 1, &force_enable}
};

VkLayerSettingsCreateInfoEXT layer_settings_create_info{
VK_STRUCTURE_TYPE_LAYER_SETTINGS_EXT, nullptr,
static_cast<uint32_t>(std::size(settings)), &settings[0]};

VkExtensionLayerTest::SetUp();
SetTargetApiVersion(VK_API_VERSION_1_2);
VkExtensionLayerTest::AddSurfaceInstanceExtension();
instance_layers_.push_back("VK_LAYER_KHRONOS_synchronization2");
ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor));
ASSERT_NO_FATAL_FAILURE(InitFramework(m_errorMonitor, &layer_settings_create_info));

VkExtensionLayerTest::AddSwapchainDeviceExtension();
}
Expand Down
4 changes: 1 addition & 3 deletions tests/vkrenderframework.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ class VkImageObj;
#include <unordered_map>
#include <unordered_set>

#include "vk_layer_config.h"

using vk_testing::MakeVkHandles;

template <class Dst, class Src>
Expand Down Expand Up @@ -129,7 +127,7 @@ class ErrorMonitor {
// Helpers

// ExpectSuccess now takes an optional argument allowing a custom combination of debug flags
void ExpectSuccess(VkDebugReportFlagsEXT const message_flag_mask = kErrorBit);
void ExpectSuccess(VkDebugReportFlagsEXT const message_flag_mask = VK_DEBUG_REPORT_ERROR_BIT_EXT);

void VerifyFound();
void VerifyNotFound();
Expand Down
9 changes: 9 additions & 0 deletions tests/vktestframework.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,15 @@ VkTestFramework::VkTestFramework() : m_compile_options(0), m_num_shader_strings(

VkTestFramework::~VkTestFramework() {}

// TODO: When the layer path issue is resolved with CI (set outside of the tests) remove this function
void VkTestFramework::setEnvironmentSetting(std::string setting, const char *val) {
#ifdef _WIN32
_putenv_s(setting.c_str(), val);
#else
setenv(setting.c_str(), val, 1);
#endif
}

// Define all the static elements
bool VkTestFramework::m_canonicalize_spv = false;
bool VkTestFramework::m_strip_spv = false;
Expand Down
2 changes: 2 additions & 0 deletions tests/vktestframework.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ class VkTestFramework : public ::testing::Test {
char **ReadFileData(const char *fileName);
void FreeFileData(char **data);

static void setEnvironmentSetting(std::string setting, const char *val);

protected:
VkTestFramework();
virtual ~VkTestFramework() = 0;
Expand Down
1 change: 0 additions & 1 deletion utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ add_library(VkExtLayer_utils STATIC)
target_sources(VkExtLayer_utils PRIVATE
allocator.cpp
vk_format_utils.cpp
vk_layer_config.cpp
generated/vk_safe_struct.cpp
generated/lvt_function_pointers.cpp
)
Expand Down
Loading

0 comments on commit 6f7f75a

Please sign in to comment.