blob: 247f61ab4ec4811d404df11d0a7554594f1239d9 [file] [log] [blame]
Karl Schultz99e9d1d2016-02-02 17:17:23 -07001/*
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 Schultz99e9d1d2016-02-02 17:17:23 -070016 * 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 Goeltzenleuchterd0d7ccc2014-09-04 16:24:19 -060028
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060029#ifndef VKTESTFRAMEWORK_H
30#define VKTESTFRAMEWORK_H
Courtney Goeltzenleuchterd0d7ccc2014-09-04 16:24:19 -060031
Courtney Goeltzenleuchter0abdb662015-10-07 13:28:58 -060032//#include "gtest-1.7.0/include/gtest/gtest.h"
Cody Northropeb9130e2015-06-03 13:01:54 -060033#include "glslang/Public/ShaderLang.h"
GregFf4b83ed2015-09-22 13:58:21 -060034#include "SPIRV/GLSL.std.450.h"
Cody Northropd4e020a2015-03-17 14:54:35 -060035#include "icd-spv.h"
Chia-I Wu13ecdcd2014-12-29 14:38:28 +080036#include "test_common.h"
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060037#include "vktestbinding.h"
Tony Barbouref20d322015-02-25 12:28:39 -070038#include "test_environment.h"
Courtney Goeltzenleuchterd0d7ccc2014-09-04 16:24:19 -060039
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 Goeltzenleuchter28d33962014-10-27 13:04:37 -060047
Tony Barbour25e3b832015-05-20 16:53:31 -060048#ifdef _WIN32
Courtney Goeltzenleuchter3068b352015-12-16 16:03:43 -070049#ifndef WIN32_LEAN_AND_MEAN
Tony Barbour25e3b832015-05-20 16:53:31 -060050#define WIN32_LEAN_AND_MEAN
Courtney Goeltzenleuchter3068b352015-12-16 16:03:43 -070051#endif
Tony Barbour25e3b832015-05-20 16:53:31 -060052#include <windows.h>
53#endif
54
Tony Barbour22a30862015-04-22 09:02:32 -060055#if defined(NDEBUG) && defined(__GNUC__)
56#define U_ASSERT_ONLY __attribute__((unused))
57#else
58#define U_ASSERT_ONLY
59#endif
60
Courtney Goeltzenleuchter28d33962014-10-27 13:04:37 -060061// Can be used by tests to record additional details / description of test
62#define TEST_DESCRIPTION(desc) RecordProperty("description", desc)
63
Courtney Goeltzenleuchterd0d7ccc2014-09-04 16:24:19 -060064using namespace std;
65
Tony Barbour01999182015-04-09 12:58:51 -060066class VkImageObj;
Chia-I Wu13ecdcd2014-12-29 14:38:28 +080067
Karl Schultz99e9d1d2016-02-02 17:17:23 -070068class VkTestFramework : public ::testing::Test {
69 public:
Tony Barbour01999182015-04-09 12:58:51 -060070 VkTestFramework();
71 ~VkTestFramework();
Courtney Goeltzenleuchterd0d7ccc2014-09-04 16:24:19 -060072
Tony Barbour55e270b2016-02-02 14:43:55 -070073 VkFormat GetFormat(VkInstance instance, vk_testing::Device *device);
Karl Schultz99e9d1d2016-02-02 17:17:23 -070074 static bool optionMatch(const char *option, char *optionLine);
Courtney Goeltzenleuchterd0d7ccc2014-09-04 16:24:19 -060075 static void InitArgs(int *argc, char *argv[]);
76 static void Finish();
77
Karl Schultz99e9d1d2016-02-02 17:17:23 -070078 bool GLSLtoSPV(const VkShaderStageFlagBits shader_type, const char *pshader,
Cody Northropacfb0492015-03-17 15:55:58 -060079 std::vector<unsigned int> &spv);
Karl Schultz99e9d1d2016-02-02 17:17:23 -070080 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 Goeltzenleuchterd0d7ccc2014-09-04 16:24:19 -060084
Karl Schultz99e9d1d2016-02-02 17:17:23 -070085 char **ReadFileData(const char *fileName);
86 void FreeFileData(char **data);
Courtney Goeltzenleuchter5c25faa2014-10-21 15:24:51 -060087
Karl Schultz99e9d1d2016-02-02 17:17:23 -070088 private:
Courtney Goeltzenleuchter94192032014-10-03 09:53:32 -060089 int m_compile_options;
90 int m_num_shader_strings;
91 TBuiltInResource Resources;
Karl Schultz99e9d1d2016-02-02 17:17:23 -070092 void SetMessageOptions(EShMessages &messages);
Courtney Goeltzenleuchter94192032014-10-03 09:53:32 -060093 void ProcessConfigFile();
Karl Schultz99e9d1d2016-02-02 17:17:23 -070094 EShLanguage FindLanguage(const std::string &name);
Courtney Goeltzenleuchter8e2f0972015-10-21 17:08:06 -060095 EShLanguage FindLanguage(const VkShaderStageFlagBits shader_type);
Courtney Goeltzenleuchter94192032014-10-03 09:53:32 -060096 std::string ConfigFile;
Karl Schultz99e9d1d2016-02-02 17:17:23 -070097 bool SetConfigFile(const std::string &name);
98 static int m_width;
99 static int m_height;
100 string m_testName;
Courtney Goeltzenleuchterd0d7ccc2014-09-04 16:24:19 -0600101};
102
Karl Schultz99e9d1d2016-02-02 17:17:23 -0700103class TestEnvironment : public ::testing::Environment {
104 public:
105 void SetUp();
Courtney Goeltzenleuchterf12c7762014-10-08 08:46:51 -0600106
Karl Schultz99e9d1d2016-02-02 17:17:23 -0700107 void TearDown();
Courtney Goeltzenleuchterf12c7762014-10-08 08:46:51 -0600108};
109
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600110#endif // VKTESTFRAMEWORK_H