Merge "Allow alternative form for refract()." into nyc-dev am: f492a25
[platform/upstream/VK-GL-CTS.git] / modules / glshared / glsSamplerObjectTest.hpp
1 #ifndef _GLSSAMPLEROBJECTTEST_HPP
2 #define _GLSSAMPLEROBJECTTEST_HPP
3 /*-------------------------------------------------------------------------
4  * drawElements Quality Program OpenGL ES 3.0 Module
5  * -------------------------------------------------
6  *
7  * Copyright 2014 The Android Open Source Project
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  *//*!
22  * \file
23  * \brief Sampler object testcases.
24  *//*--------------------------------------------------------------------*/
25
26 #include "tcuTestCase.hpp"
27 #include "tcuTestLog.hpp"
28 #include "deRandom.hpp"
29 #include "tcuSurface.hpp"
30 #include "gluRenderContext.hpp"
31 #include "glw.h"
32 #include "glwEnums.hpp"
33 #include "gluShaderProgram.hpp"
34
35 namespace deqp
36 {
37 namespace gls
38 {
39
40 class TextureSamplerTest : public tcu::TestCase
41 {
42 public:
43         struct SamplingState
44         {
45                 GLenum  minFilter;
46                 GLenum  magFilter;
47                 GLenum  wrapT;
48                 GLenum  wrapS;
49                 GLenum  wrapR;
50                 GLfloat minLod;
51                 GLfloat maxLod;
52         };
53
54         struct TestSpec
55         {
56                 const char*             name;
57                 const char*             desc;
58                 GLenum                  target;
59                 SamplingState   textureState;
60                 SamplingState   samplerState;
61         };
62
63                                                 TextureSamplerTest      (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const TestSpec& spec);
64                                                 ~TextureSamplerTest     (void);
65
66         void                            init                            (void);
67         void                            deinit                          (void);
68
69         IterateResult           iterate                         (void);
70
71 private:
72         void                            renderReferences                (tcu::Surface& textureRef, tcu::Surface& samplerRef, int x, int y);
73         void                            renderResults                   (tcu::Surface& textureResult, tcu::Surface& samplerResult, int x, int y);
74
75         void                            render                                  (void);
76
77         static void                     setTextureState                 (const glw::Functions& gl, GLenum target, SamplingState state);
78         static void                     setSamplerState                 (const glw::Functions& gl, SamplingState state, GLuint sampler);
79
80         static GLuint           createTexture2D                 (const glw::Functions& gl);
81         static GLuint           createTexture3D                 (const glw::Functions& gl);
82         static GLuint           createTextureCube               (const glw::Functions& gl);
83         static GLuint           createTexture                   (const glw::Functions& gl, GLenum target);
84
85         static const char*      selectVertexShader              (GLenum target);
86         static const char*      selectFragmentShader    (GLenum target);
87
88         glu::RenderContext& m_renderCtx;
89         glu::ShaderProgram*     m_program;
90
91         GLenum                          m_target;
92         SamplingState           m_textureState;
93         SamplingState           m_samplerState;
94
95         de::Random                      m_random;
96 };
97
98 class MultiTextureSamplerTest : public tcu::TestCase
99 {
100 public:
101         struct SamplingState
102         {
103                 GLenum  minFilter;
104                 GLenum  magFilter;
105                 GLenum  wrapT;
106                 GLenum  wrapS;
107                 GLenum  wrapR;
108                 GLfloat minLod;
109                 GLfloat maxLod;
110         };
111
112         struct TestSpec
113         {
114                 const char*             name;
115                 const char*             desc;
116                 GLenum                  target;
117                 SamplingState   textureState1;
118                 SamplingState   textureState2;
119                 SamplingState   samplerState;
120         };
121
122                                                 MultiTextureSamplerTest         (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const TestSpec& spec);
123                                                 ~MultiTextureSamplerTest        (void);
124
125         void                            init                                            (void);
126         void                            deinit                                          (void);
127
128         IterateResult           iterate                                         (void);
129
130 private:
131         void                            renderReferences                        (tcu::Surface& textureRef, tcu::Surface& samplerRef, int x, int y);
132         void                            renderResults                           (tcu::Surface& textureResult, tcu::Surface& samplerResult, int x, int y);
133
134         void                            render                                          (void);
135
136         static void                     setTextureState                         (const glw::Functions& gl, GLenum target, SamplingState state);
137         static void                     setSamplerState                         (const glw::Functions& gl, SamplingState state, GLuint sampler);
138
139         static GLuint           createTexture2D                         (const glw::Functions& gl, int id);
140         static GLuint           createTexture3D                         (const glw::Functions& gl, int id);
141         static GLuint           createTextureCube                       (const glw::Functions& gl, int id);
142         static GLuint           createTexture                           (const glw::Functions& gl, GLenum target, int id);
143
144         static const char*      selectVertexShader                      (GLenum target);
145         static const char*      selectFragmentShader            (GLenum target);
146
147         glu::RenderContext& m_renderCtx;
148         glu::ShaderProgram*     m_program;
149
150         GLenum                          m_target;
151         SamplingState           m_textureState1;
152         SamplingState           m_textureState2;
153         SamplingState           m_samplerState;
154
155         de::Random                      m_random;
156 };
157
158
159 } // gls
160 } // deqp
161
162 #endif // _GLSSAMPLEROBJECTTEST_HPP