Courtney Goeltzenleuchter | d0d7ccc | 2014-09-04 16:24:19 -0600 | [diff] [blame] | 1 | // XGL tests |
| 2 | // |
| 3 | // Copyright (C) 2014 LunarG, Inc. |
| 4 | // |
| 5 | // Permission is hereby granted, free of charge, to any person obtaining a |
| 6 | // copy of this software and associated documentation files (the "Software"), |
| 7 | // to deal in the Software without restriction, including without limitation |
| 8 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 9 | // and/or sell copies of the Software, and to permit persons to whom the |
| 10 | // Software is furnished to do so, subject to the following conditions: |
| 11 | // |
| 12 | // The above copyright notice and this permission notice shall be included |
| 13 | // in all copies or substantial portions of the Software. |
| 14 | // |
| 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 18 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 20 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 21 | // DEALINGS IN THE SOFTWARE. |
| 22 | |
| 23 | #ifndef XGLTESTFRAMEWORK_H |
| 24 | #define XGLTESTFRAMEWORK_H |
| 25 | |
| 26 | #include "gtest-1.7.0/include/gtest/gtest.h" |
| 27 | #include "xglimage.h" |
Courtney Goeltzenleuchter | 9419203 | 2014-10-03 09:53:32 -0600 | [diff] [blame] | 28 | #include "ShaderLang.h" |
| 29 | #include "GLSL450Lib.h" |
Courtney Goeltzenleuchter | ef5b116 | 2014-10-10 16:29:46 -0600 | [diff] [blame^] | 30 | #include "icd-bil.h" |
Courtney Goeltzenleuchter | d0d7ccc | 2014-09-04 16:24:19 -0600 | [diff] [blame] | 31 | |
| 32 | #include <stdlib.h> |
| 33 | #include <stdio.h> |
| 34 | #include <stdbool.h> |
| 35 | #include <string.h> |
| 36 | #include <iostream> |
| 37 | #include <fstream> |
| 38 | #include <list> |
| 39 | using namespace std; |
| 40 | |
| 41 | class XglTestImageRecord |
| 42 | { |
| 43 | public: |
| 44 | XglTestImageRecord(); |
| 45 | XglTestImageRecord(const XglTestImageRecord &); |
| 46 | ~XglTestImageRecord(); |
| 47 | XglTestImageRecord &operator=(const XglTestImageRecord &rhs); |
| 48 | int operator==(const XglTestImageRecord &rhs) const; |
| 49 | int operator<(const XglTestImageRecord &rhs) const; |
| 50 | |
| 51 | string m_title; |
| 52 | void *m_data; |
| 53 | unsigned m_data_size; |
| 54 | int m_width; |
| 55 | int m_height; |
| 56 | }; |
| 57 | |
| 58 | class XglTestFramework : public ::testing::Test |
| 59 | { |
| 60 | public: |
| 61 | XglTestFramework(); |
Courtney Goeltzenleuchter | 9419203 | 2014-10-03 09:53:32 -0600 | [diff] [blame] | 62 | ~XglTestFramework(); |
Courtney Goeltzenleuchter | d0d7ccc | 2014-09-04 16:24:19 -0600 | [diff] [blame] | 63 | |
| 64 | static void InitArgs(int *argc, char *argv[]); |
| 65 | static void Finish(); |
| 66 | |
| 67 | void WritePPM( const char *basename, XglImage *image ); |
| 68 | void Show(const char *comment, XglImage *image); |
| 69 | void RecordImage(XglImage *image); |
Courtney Goeltzenleuchter | 9419203 | 2014-10-03 09:53:32 -0600 | [diff] [blame] | 70 | bool GLSLtoBIL(const XGL_PIPELINE_SHADER_STAGE shader_type, |
| 71 | const char *pshader, |
| 72 | std::vector<unsigned int> &bil); |
Courtney Goeltzenleuchter | 54d02cb | 2014-10-09 09:13:56 -0600 | [diff] [blame] | 73 | static bool m_use_bil; |
Courtney Goeltzenleuchter | d0d7ccc | 2014-09-04 16:24:19 -0600 | [diff] [blame] | 74 | |
| 75 | private: |
Courtney Goeltzenleuchter | 9419203 | 2014-10-03 09:53:32 -0600 | [diff] [blame] | 76 | int m_compile_options; |
| 77 | int m_num_shader_strings; |
| 78 | TBuiltInResource Resources; |
Courtney Goeltzenleuchter | 9419203 | 2014-10-03 09:53:32 -0600 | [diff] [blame] | 79 | void SetMessageOptions(EShMessages& messages); |
| 80 | void ProcessConfigFile(); |
| 81 | char** ReadFileData(const char* fileName); |
| 82 | void FreeFileData(char** data); |
| 83 | EShLanguage FindLanguage(const std::string& name); |
| 84 | EShLanguage FindLanguage(const XGL_PIPELINE_SHADER_STAGE shader_type); |
| 85 | std::string ConfigFile; |
| 86 | bool SetConfigFile(const std::string& name); |
Courtney Goeltzenleuchter | d0d7ccc | 2014-09-04 16:24:19 -0600 | [diff] [blame] | 87 | static void Reshape( int w, int h ); |
| 88 | static void Display(); |
| 89 | static void Key(unsigned char key, int x, int y); |
| 90 | static void SpecialKey( int key, int x, int y ); |
| 91 | |
| 92 | void InitGLUT(int w, int h); |
| 93 | |
| 94 | static bool m_show_images; |
| 95 | static bool m_save_images; |
Courtney Goeltzenleuchter | 54d02cb | 2014-10-09 09:13:56 -0600 | [diff] [blame] | 96 | |
Courtney Goeltzenleuchter | d0d7ccc | 2014-09-04 16:24:19 -0600 | [diff] [blame] | 97 | static std::list<XglTestImageRecord> m_images; |
| 98 | static std::list<XglTestImageRecord>::iterator m_display_image; |
| 99 | static int m_display_image_idx; |
| 100 | |
Courtney Goeltzenleuchter | e540934 | 2014-10-08 14:26:40 -0600 | [diff] [blame] | 101 | static bool m_glut_initialized; |
Courtney Goeltzenleuchter | d0d7ccc | 2014-09-04 16:24:19 -0600 | [diff] [blame] | 102 | static int m_window; |
| 103 | static int m_width; // Window width |
| 104 | static int m_height; // Window height |
| 105 | }; |
| 106 | |
Courtney Goeltzenleuchter | f12c776 | 2014-10-08 08:46:51 -0600 | [diff] [blame] | 107 | class TestEnvironment : public ::testing::Environment |
| 108 | { |
| 109 | public: |
| 110 | void SetUp(); |
| 111 | |
| 112 | void TearDown(); |
| 113 | }; |
| 114 | |
Courtney Goeltzenleuchter | d0d7ccc | 2014-09-04 16:24:19 -0600 | [diff] [blame] | 115 | #endif // XGLTESTFRAMEWORK_H |