• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2015-2019 The Khronos Group Inc.
3  * Copyright (c) 2015-2019 Valve Corporation
4  * Copyright (c) 2015-2019 LunarG, Inc.
5  *
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
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
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.
17  *
18  * Author: Courtney Goeltzenleuchter <courtney@LunarG.com>
19  * Author: Tony Barbour <tony@LunarG.com>
20  */
21 
22 #ifndef VKTESTFRAMEWORK_H
23 #define VKTESTFRAMEWORK_H
24 
25 #include "SPIRV/GLSL.std.450.h"
26 #include "spirv-tools/libspirv.h"
27 #include "glslang/Public/ShaderLang.h"
28 #include "icd-spv.h"
29 #include "test_common.h"
30 #include "test_environment.h"
31 
32 #include <fstream>
33 #include <iostream>
34 #include <list>
35 #include <stdbool.h>
36 #include <stdio.h>
37 #include <stdlib.h>
38 #include <string.h>
39 
40 #ifdef _WIN32
41 #ifndef WIN32_LEAN_AND_MEAN
42 #define WIN32_LEAN_AND_MEAN
43 #endif
44 #include <windows.h>
45 #endif
46 
47 #if defined(NDEBUG) && defined(__GNUC__)
48 #define U_ASSERT_ONLY __attribute__((unused))
49 #else
50 #define U_ASSERT_ONLY
51 #endif
52 
53 // Can be used by tests to record additional details / description of test
54 #define TEST_DESCRIPTION(desc) RecordProperty("description", desc)
55 
56 using namespace std;
57 
58 class VkImageObj;
59 
60 class VkTestFramework : public ::testing::Test {
61    public:
62     VkTestFramework();
63     ~VkTestFramework();
64 
65     VkFormat GetFormat(VkInstance instance, vk_testing::Device *device);
66     static bool optionMatch(const char *option, char *optionLine);
67     static void InitArgs(int *argc, char *argv[]);
68     static void Finish();
69 
70     bool GLSLtoSPV(const VkShaderStageFlagBits shader_type, const char *pshader, std::vector<unsigned int> &spv,
71                    bool debug = false);
72     bool ASMtoSPV(const spv_target_env target_env, const uint32_t options, const char *pasm, std::vector<unsigned int> &spv);
73     static bool m_canonicalize_spv;
74     static bool m_strip_spv;
75     static bool m_do_everything_spv;
76     static bool m_devsim_layer;
77 
78     char **ReadFileData(const char *fileName);
79     void FreeFileData(char **data);
80 
81    private:
82     int m_compile_options;
83     int m_num_shader_strings;
84     TBuiltInResource Resources;
85     void SetMessageOptions(EShMessages &messages);
86     void ProcessConfigFile();
87     EShLanguage FindLanguage(const std::string &name);
88     EShLanguage FindLanguage(const VkShaderStageFlagBits shader_type);
89     std::string ConfigFile;
90     bool SetConfigFile(const std::string &name);
91     static int m_width;
92     static int m_height;
93     string m_testName;
94 };
95 
96 class TestEnvironment : public ::testing::Environment {
97    public:
98     void SetUp();
99 
100     void TearDown();
101 };
102 
103 #endif  // VKTESTFRAMEWORK_H
104