blob: d8e9b98865bdbb9be48dee071d73cc7f58a8c406 [file] [log] [blame]
Karl Schultz6addd812016-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 *
Jon Ashburn3ebf1252016-04-19 11:30:31 -06006 * 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 Schultz6addd812016-02-02 17:17:23 -07009 *
Jon Ashburn3ebf1252016-04-19 11:30:31 -060010 * http://www.apache.org/licenses/LICENSE-2.0
Karl Schultz6addd812016-02-02 17:17:23 -070011 *
Jon Ashburn3ebf1252016-04-19 11:30:31 -060012 * 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 Schultz6addd812016-02-02 17:17:23 -070017 *
18 * Author: Courtney Goeltzenleuchter <courtney@LunarG.com>
19 * Author: Tony Barbour <tony@LunarG.com>
20 */
Courtney Goeltzenleuchter30e9dc42014-09-04 16:24:19 -060021
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060022#ifndef VKTESTFRAMEWORK_H
23#define VKTESTFRAMEWORK_H
Courtney Goeltzenleuchter30e9dc42014-09-04 16:24:19 -060024
Courtney Goeltzenleuchter58f3eff2015-10-07 13:28:58 -060025//#include "gtest-1.7.0/include/gtest/gtest.h"
GregF5af3f772015-09-22 13:58:21 -060026#include "SPIRV/GLSL.std.450.h"
Mark Lobodzinskic6a62142016-09-07 16:35:55 -060027#include "glslang/Public/ShaderLang.h"
Cody Northrop054a4702015-03-17 14:54:35 -060028#include "icd-spv.h"
Chia-I Wua6bc0ce2014-12-29 14:38:28 +080029#include "test_common.h"
Tony Barbour96db8822015-02-25 12:28:39 -070030#include "test_environment.h"
Mark Lobodzinskic6a62142016-09-07 16:35:55 -060031#include "vktestbinding.h"
Courtney Goeltzenleuchter30e9dc42014-09-04 16:24:19 -060032
Courtney Goeltzenleuchter30e9dc42014-09-04 16:24:19 -060033#include <fstream>
Mark Lobodzinskic6a62142016-09-07 16:35:55 -060034#include <iostream>
Courtney Goeltzenleuchter30e9dc42014-09-04 16:24:19 -060035#include <list>
Mark Lobodzinskic6a62142016-09-07 16:35:55 -060036#include <stdbool.h>
37#include <stdio.h>
38#include <stdlib.h>
39#include <string.h>
Courtney Goeltzenleuchterc5e00a12014-10-27 13:04:37 -060040
Tony Barbour3d69c9e2015-05-20 16:53:31 -060041#ifdef _WIN32
Courtney Goeltzenleuchter8e52a122015-12-16 16:03:43 -070042#ifndef WIN32_LEAN_AND_MEAN
Tony Barbour3d69c9e2015-05-20 16:53:31 -060043#define WIN32_LEAN_AND_MEAN
Courtney Goeltzenleuchter8e52a122015-12-16 16:03:43 -070044#endif
Tony Barbour3d69c9e2015-05-20 16:53:31 -060045#include <windows.h>
46#endif
47
Tony Barbourf20f87b2015-04-22 09:02:32 -060048#if defined(NDEBUG) && defined(__GNUC__)
49#define U_ASSERT_ONLY __attribute__((unused))
50#else
51#define U_ASSERT_ONLY
52#endif
53
Courtney Goeltzenleuchterc5e00a12014-10-27 13:04:37 -060054// Can be used by tests to record additional details / description of test
55#define TEST_DESCRIPTION(desc) RecordProperty("description", desc)
56
Courtney Goeltzenleuchter30e9dc42014-09-04 16:24:19 -060057using namespace std;
58
Tony Barbour6918cd52015-04-09 12:58:51 -060059class VkImageObj;
Chia-I Wua6bc0ce2014-12-29 14:38:28 +080060
Karl Schultz6addd812016-02-02 17:17:23 -070061class VkTestFramework : public ::testing::Test {
Mark Lobodzinski64318ba2017-01-26 13:34:13 -070062 public:
Tony Barbour6918cd52015-04-09 12:58:51 -060063 VkTestFramework();
64 ~VkTestFramework();
Courtney Goeltzenleuchter30e9dc42014-09-04 16:24:19 -060065
Tony Barbour7b60e492016-02-02 14:43:55 -070066 VkFormat GetFormat(VkInstance instance, vk_testing::Device *device);
Karl Schultz6addd812016-02-02 17:17:23 -070067 static bool optionMatch(const char *option, char *optionLine);
Courtney Goeltzenleuchter30e9dc42014-09-04 16:24:19 -060068 static void InitArgs(int *argc, char *argv[]);
69 static void Finish();
70
Mark Lobodzinskic6a62142016-09-07 16:35:55 -060071 bool GLSLtoSPV(const VkShaderStageFlagBits shader_type, const char *pshader, std::vector<unsigned int> &spv);
Karl Schultz6addd812016-02-02 17:17:23 -070072 static bool m_canonicalize_spv;
73 static bool m_strip_spv;
74 static bool m_do_everything_spv;
Tobin Ehlis72888642017-11-15 09:43:56 -070075 static bool m_devsim_layer;
Courtney Goeltzenleuchter30e9dc42014-09-04 16:24:19 -060076
Karl Schultz6addd812016-02-02 17:17:23 -070077 char **ReadFileData(const char *fileName);
78 void FreeFileData(char **data);
Courtney Goeltzenleuchter8bc46f42014-10-21 15:24:51 -060079
Mark Lobodzinski64318ba2017-01-26 13:34:13 -070080 private:
Courtney Goeltzenleuchter9818f782014-10-03 09:53:32 -060081 int m_compile_options;
82 int m_num_shader_strings;
83 TBuiltInResource Resources;
Karl Schultz6addd812016-02-02 17:17:23 -070084 void SetMessageOptions(EShMessages &messages);
Courtney Goeltzenleuchter9818f782014-10-03 09:53:32 -060085 void ProcessConfigFile();
Karl Schultz6addd812016-02-02 17:17:23 -070086 EShLanguage FindLanguage(const std::string &name);
Courtney Goeltzenleuchterd2635502015-10-21 17:08:06 -060087 EShLanguage FindLanguage(const VkShaderStageFlagBits shader_type);
Courtney Goeltzenleuchter9818f782014-10-03 09:53:32 -060088 std::string ConfigFile;
Karl Schultz6addd812016-02-02 17:17:23 -070089 bool SetConfigFile(const std::string &name);
90 static int m_width;
91 static int m_height;
92 string m_testName;
Courtney Goeltzenleuchter30e9dc42014-09-04 16:24:19 -060093};
94
Karl Schultz6addd812016-02-02 17:17:23 -070095class TestEnvironment : public ::testing::Environment {
Mark Lobodzinski64318ba2017-01-26 13:34:13 -070096 public:
Karl Schultz6addd812016-02-02 17:17:23 -070097 void SetUp();
Courtney Goeltzenleuchtera0f74c52014-10-08 08:46:51 -060098
Karl Schultz6addd812016-02-02 17:17:23 -070099 void TearDown();
Courtney Goeltzenleuchtera0f74c52014-10-08 08:46:51 -0600100};
101
Mark Lobodzinski64318ba2017-01-26 13:34:13 -0700102#endif // VKTESTFRAMEWORK_H