Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015-2016 The Khronos Group Inc. |
| 3 | * Copyright (c) 2015-2016 Valve Corporation |
| 4 | * Copyright (c) 2015-2016 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 | * |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 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 | * Author: Courtney Goeltzenleuchter <courtney@LunarG.com> |
| 26 | * Author: Tony Barbour <tony@LunarG.com> |
| 27 | */ |
Courtney Goeltzenleuchter | 30e9dc4 | 2014-09-04 16:24:19 -0600 | [diff] [blame] | 28 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 29 | #ifndef VKTESTFRAMEWORK_H |
| 30 | #define VKTESTFRAMEWORK_H |
Courtney Goeltzenleuchter | 30e9dc4 | 2014-09-04 16:24:19 -0600 | [diff] [blame] | 31 | |
Courtney Goeltzenleuchter | 58f3eff | 2015-10-07 13:28:58 -0600 | [diff] [blame] | 32 | //#include "gtest-1.7.0/include/gtest/gtest.h" |
Cody Northrop | 5a95b47 | 2015-06-03 13:01:54 -0600 | [diff] [blame] | 33 | #include "glslang/Public/ShaderLang.h" |
GregF | 5af3f77 | 2015-09-22 13:58:21 -0600 | [diff] [blame] | 34 | #include "SPIRV/GLSL.std.450.h" |
Cody Northrop | 054a470 | 2015-03-17 14:54:35 -0600 | [diff] [blame] | 35 | #include "icd-spv.h" |
Chia-I Wu | a6bc0ce | 2014-12-29 14:38:28 +0800 | [diff] [blame] | 36 | #include "test_common.h" |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 37 | #include "vktestbinding.h" |
Tony Barbour | 96db882 | 2015-02-25 12:28:39 -0700 | [diff] [blame] | 38 | #include "test_environment.h" |
Courtney Goeltzenleuchter | 30e9dc4 | 2014-09-04 16:24:19 -0600 | [diff] [blame] | 39 | |
| 40 | #include <stdlib.h> |
| 41 | #include <stdio.h> |
| 42 | #include <stdbool.h> |
| 43 | #include <string.h> |
| 44 | #include <iostream> |
| 45 | #include <fstream> |
| 46 | #include <list> |
Courtney Goeltzenleuchter | c5e00a1 | 2014-10-27 13:04:37 -0600 | [diff] [blame] | 47 | |
Tony Barbour | 3d69c9e | 2015-05-20 16:53:31 -0600 | [diff] [blame] | 48 | #ifdef _WIN32 |
Courtney Goeltzenleuchter | 8e52a12 | 2015-12-16 16:03:43 -0700 | [diff] [blame] | 49 | #ifndef WIN32_LEAN_AND_MEAN |
Tony Barbour | 3d69c9e | 2015-05-20 16:53:31 -0600 | [diff] [blame] | 50 | #define WIN32_LEAN_AND_MEAN |
Courtney Goeltzenleuchter | 8e52a12 | 2015-12-16 16:03:43 -0700 | [diff] [blame] | 51 | #endif |
Tony Barbour | 3d69c9e | 2015-05-20 16:53:31 -0600 | [diff] [blame] | 52 | #include <windows.h> |
| 53 | #endif |
| 54 | |
Tony Barbour | f20f87b | 2015-04-22 09:02:32 -0600 | [diff] [blame] | 55 | #if defined(NDEBUG) && defined(__GNUC__) |
| 56 | #define U_ASSERT_ONLY __attribute__((unused)) |
| 57 | #else |
| 58 | #define U_ASSERT_ONLY |
| 59 | #endif |
| 60 | |
Courtney Goeltzenleuchter | c5e00a1 | 2014-10-27 13:04:37 -0600 | [diff] [blame] | 61 | // Can be used by tests to record additional details / description of test |
| 62 | #define TEST_DESCRIPTION(desc) RecordProperty("description", desc) |
| 63 | |
Courtney Goeltzenleuchter | 30e9dc4 | 2014-09-04 16:24:19 -0600 | [diff] [blame] | 64 | using namespace std; |
| 65 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 66 | class VkImageObj; |
Chia-I Wu | a6bc0ce | 2014-12-29 14:38:28 +0800 | [diff] [blame] | 67 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 68 | class VkTestFramework : public ::testing::Test { |
| 69 | public: |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 70 | VkTestFramework(); |
| 71 | ~VkTestFramework(); |
Courtney Goeltzenleuchter | 30e9dc4 | 2014-09-04 16:24:19 -0600 | [diff] [blame] | 72 | |
Tony Barbour | 7b60e49 | 2016-02-02 14:43:55 -0700 | [diff] [blame] | 73 | VkFormat GetFormat(VkInstance instance, vk_testing::Device *device); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 74 | static bool optionMatch(const char *option, char *optionLine); |
Courtney Goeltzenleuchter | 30e9dc4 | 2014-09-04 16:24:19 -0600 | [diff] [blame] | 75 | static void InitArgs(int *argc, char *argv[]); |
| 76 | static void Finish(); |
| 77 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 78 | bool GLSLtoSPV(const VkShaderStageFlagBits shader_type, const char *pshader, |
Cody Northrop | 3bfd27c | 2015-03-17 15:55:58 -0600 | [diff] [blame] | 79 | std::vector<unsigned int> &spv); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 80 | static bool m_use_glsl; |
| 81 | static bool m_canonicalize_spv; |
| 82 | static bool m_strip_spv; |
| 83 | static bool m_do_everything_spv; |
Courtney Goeltzenleuchter | 30e9dc4 | 2014-09-04 16:24:19 -0600 | [diff] [blame] | 84 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 85 | char **ReadFileData(const char *fileName); |
| 86 | void FreeFileData(char **data); |
Courtney Goeltzenleuchter | 8bc46f4 | 2014-10-21 15:24:51 -0600 | [diff] [blame] | 87 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 88 | private: |
Courtney Goeltzenleuchter | 9818f78 | 2014-10-03 09:53:32 -0600 | [diff] [blame] | 89 | int m_compile_options; |
| 90 | int m_num_shader_strings; |
| 91 | TBuiltInResource Resources; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 92 | void SetMessageOptions(EShMessages &messages); |
Courtney Goeltzenleuchter | 9818f78 | 2014-10-03 09:53:32 -0600 | [diff] [blame] | 93 | void ProcessConfigFile(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 94 | EShLanguage FindLanguage(const std::string &name); |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 95 | EShLanguage FindLanguage(const VkShaderStageFlagBits shader_type); |
Courtney Goeltzenleuchter | 9818f78 | 2014-10-03 09:53:32 -0600 | [diff] [blame] | 96 | std::string ConfigFile; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 97 | bool SetConfigFile(const std::string &name); |
| 98 | static int m_width; |
| 99 | static int m_height; |
| 100 | string m_testName; |
Courtney Goeltzenleuchter | 30e9dc4 | 2014-09-04 16:24:19 -0600 | [diff] [blame] | 101 | }; |
| 102 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 103 | class TestEnvironment : public ::testing::Environment { |
| 104 | public: |
| 105 | void SetUp(); |
Courtney Goeltzenleuchter | a0f74c5 | 2014-10-08 08:46:51 -0600 | [diff] [blame] | 106 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 107 | void TearDown(); |
Courtney Goeltzenleuchter | a0f74c5 | 2014-10-08 08:46:51 -0600 | [diff] [blame] | 108 | }; |
| 109 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 110 | #endif // VKTESTFRAMEWORK_H |