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 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 17 | * |
| 18 | * Author: Courtney Goeltzenleuchter <courtney@LunarG.com> |
| 19 | * Author: Tony Barbour <tony@LunarG.com> |
| 20 | */ |
Courtney Goeltzenleuchter | 30e9dc4 | 2014-09-04 16:24:19 -0600 | [diff] [blame] | 21 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 22 | #ifndef VKTESTFRAMEWORK_H |
| 23 | #define VKTESTFRAMEWORK_H |
Courtney Goeltzenleuchter | 30e9dc4 | 2014-09-04 16:24:19 -0600 | [diff] [blame] | 24 | |
Courtney Goeltzenleuchter | 58f3eff | 2015-10-07 13:28:58 -0600 | [diff] [blame] | 25 | //#include "gtest-1.7.0/include/gtest/gtest.h" |
GregF | 5af3f77 | 2015-09-22 13:58:21 -0600 | [diff] [blame] | 26 | #include "SPIRV/GLSL.std.450.h" |
Mark Lobodzinski | c6a6214 | 2016-09-07 16:35:55 -0600 | [diff] [blame] | 27 | #include "glslang/Public/ShaderLang.h" |
Cody Northrop | 054a470 | 2015-03-17 14:54:35 -0600 | [diff] [blame] | 28 | #include "icd-spv.h" |
Chia-I Wu | a6bc0ce | 2014-12-29 14:38:28 +0800 | [diff] [blame] | 29 | #include "test_common.h" |
Tony Barbour | 96db882 | 2015-02-25 12:28:39 -0700 | [diff] [blame] | 30 | #include "test_environment.h" |
Mark Lobodzinski | c6a6214 | 2016-09-07 16:35:55 -0600 | [diff] [blame] | 31 | #include "vktestbinding.h" |
Courtney Goeltzenleuchter | 30e9dc4 | 2014-09-04 16:24:19 -0600 | [diff] [blame] | 32 | |
Courtney Goeltzenleuchter | 30e9dc4 | 2014-09-04 16:24:19 -0600 | [diff] [blame] | 33 | #include <fstream> |
Mark Lobodzinski | c6a6214 | 2016-09-07 16:35:55 -0600 | [diff] [blame] | 34 | #include <iostream> |
Courtney Goeltzenleuchter | 30e9dc4 | 2014-09-04 16:24:19 -0600 | [diff] [blame] | 35 | #include <list> |
Mark Lobodzinski | c6a6214 | 2016-09-07 16:35:55 -0600 | [diff] [blame] | 36 | #include <stdbool.h> |
| 37 | #include <stdio.h> |
| 38 | #include <stdlib.h> |
| 39 | #include <string.h> |
Courtney Goeltzenleuchter | c5e00a1 | 2014-10-27 13:04:37 -0600 | [diff] [blame] | 40 | |
Tony Barbour | 3d69c9e | 2015-05-20 16:53:31 -0600 | [diff] [blame] | 41 | #ifdef _WIN32 |
Courtney Goeltzenleuchter | 8e52a12 | 2015-12-16 16:03:43 -0700 | [diff] [blame] | 42 | #ifndef WIN32_LEAN_AND_MEAN |
Tony Barbour | 3d69c9e | 2015-05-20 16:53:31 -0600 | [diff] [blame] | 43 | #define WIN32_LEAN_AND_MEAN |
Courtney Goeltzenleuchter | 8e52a12 | 2015-12-16 16:03:43 -0700 | [diff] [blame] | 44 | #endif |
Tony Barbour | 3d69c9e | 2015-05-20 16:53:31 -0600 | [diff] [blame] | 45 | #include <windows.h> |
| 46 | #endif |
| 47 | |
Tony Barbour | f20f87b | 2015-04-22 09:02:32 -0600 | [diff] [blame] | 48 | #if defined(NDEBUG) && defined(__GNUC__) |
| 49 | #define U_ASSERT_ONLY __attribute__((unused)) |
| 50 | #else |
| 51 | #define U_ASSERT_ONLY |
| 52 | #endif |
| 53 | |
Courtney Goeltzenleuchter | c5e00a1 | 2014-10-27 13:04:37 -0600 | [diff] [blame] | 54 | // Can be used by tests to record additional details / description of test |
| 55 | #define TEST_DESCRIPTION(desc) RecordProperty("description", desc) |
| 56 | |
Courtney Goeltzenleuchter | 30e9dc4 | 2014-09-04 16:24:19 -0600 | [diff] [blame] | 57 | using namespace std; |
| 58 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 59 | class VkImageObj; |
Chia-I Wu | a6bc0ce | 2014-12-29 14:38:28 +0800 | [diff] [blame] | 60 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 61 | class VkTestFramework : public ::testing::Test { |
| 62 | public: |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 63 | VkTestFramework(); |
| 64 | ~VkTestFramework(); |
Courtney Goeltzenleuchter | 30e9dc4 | 2014-09-04 16:24:19 -0600 | [diff] [blame] | 65 | |
Tony Barbour | 7b60e49 | 2016-02-02 14:43:55 -0700 | [diff] [blame] | 66 | VkFormat GetFormat(VkInstance instance, vk_testing::Device *device); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 67 | static bool optionMatch(const char *option, char *optionLine); |
Courtney Goeltzenleuchter | 30e9dc4 | 2014-09-04 16:24:19 -0600 | [diff] [blame] | 68 | static void InitArgs(int *argc, char *argv[]); |
| 69 | static void Finish(); |
| 70 | |
Mark Lobodzinski | c6a6214 | 2016-09-07 16:35:55 -0600 | [diff] [blame] | 71 | bool GLSLtoSPV(const VkShaderStageFlagBits shader_type, const char *pshader, std::vector<unsigned int> &spv); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 72 | static bool m_use_glsl; |
| 73 | static bool m_canonicalize_spv; |
| 74 | static bool m_strip_spv; |
| 75 | static bool m_do_everything_spv; |
Courtney Goeltzenleuchter | 30e9dc4 | 2014-09-04 16:24:19 -0600 | [diff] [blame] | 76 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 77 | char **ReadFileData(const char *fileName); |
| 78 | void FreeFileData(char **data); |
Courtney Goeltzenleuchter | 8bc46f4 | 2014-10-21 15:24:51 -0600 | [diff] [blame] | 79 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 80 | private: |
Courtney Goeltzenleuchter | 9818f78 | 2014-10-03 09:53:32 -0600 | [diff] [blame] | 81 | int m_compile_options; |
| 82 | int m_num_shader_strings; |
| 83 | TBuiltInResource Resources; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 84 | void SetMessageOptions(EShMessages &messages); |
Courtney Goeltzenleuchter | 9818f78 | 2014-10-03 09:53:32 -0600 | [diff] [blame] | 85 | void ProcessConfigFile(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 86 | EShLanguage FindLanguage(const std::string &name); |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 87 | EShLanguage FindLanguage(const VkShaderStageFlagBits shader_type); |
Courtney Goeltzenleuchter | 9818f78 | 2014-10-03 09:53:32 -0600 | [diff] [blame] | 88 | std::string ConfigFile; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 89 | bool SetConfigFile(const std::string &name); |
| 90 | static int m_width; |
| 91 | static int m_height; |
| 92 | string m_testName; |
Courtney Goeltzenleuchter | 30e9dc4 | 2014-09-04 16:24:19 -0600 | [diff] [blame] | 93 | }; |
| 94 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 95 | class TestEnvironment : public ::testing::Environment { |
| 96 | public: |
| 97 | void SetUp(); |
Courtney Goeltzenleuchter | a0f74c5 | 2014-10-08 08:46:51 -0600 | [diff] [blame] | 98 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 99 | void TearDown(); |
Courtney Goeltzenleuchter | a0f74c5 | 2014-10-08 08:46:51 -0600 | [diff] [blame] | 100 | }; |
| 101 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 102 | #endif // VKTESTFRAMEWORK_H |