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