1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker * drawElements Quality Program OpenGL ES 2.0 Module
3*35238bceSAndroid Build Coastguard Worker * -------------------------------------------------
4*35238bceSAndroid Build Coastguard Worker *
5*35238bceSAndroid Build Coastguard Worker * Copyright 2014 The Android Open Source Project
6*35238bceSAndroid Build Coastguard Worker *
7*35238bceSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
8*35238bceSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
9*35238bceSAndroid Build Coastguard Worker * You may obtain a copy of the License at
10*35238bceSAndroid Build Coastguard Worker *
11*35238bceSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0
12*35238bceSAndroid Build Coastguard Worker *
13*35238bceSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
14*35238bceSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
15*35238bceSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16*35238bceSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
17*35238bceSAndroid Build Coastguard Worker * limitations under the License.
18*35238bceSAndroid Build Coastguard Worker *
19*35238bceSAndroid Build Coastguard Worker *//*!
20*35238bceSAndroid Build Coastguard Worker * \file
21*35238bceSAndroid Build Coastguard Worker * \brief Texture wrap mode tests.
22*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker
24*35238bceSAndroid Build Coastguard Worker #include "es2fTextureWrapTests.hpp"
25*35238bceSAndroid Build Coastguard Worker #include "glsTextureTestUtil.hpp"
26*35238bceSAndroid Build Coastguard Worker #include "gluTexture.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "gluStrUtil.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "gluTextureUtil.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "gluPixelTransfer.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "tcuTestLog.hpp"
31*35238bceSAndroid Build Coastguard Worker #include "tcuTextureUtil.hpp"
32*35238bceSAndroid Build Coastguard Worker
33*35238bceSAndroid Build Coastguard Worker #include "glwEnums.hpp"
34*35238bceSAndroid Build Coastguard Worker #include "glwFunctions.hpp"
35*35238bceSAndroid Build Coastguard Worker
36*35238bceSAndroid Build Coastguard Worker namespace deqp
37*35238bceSAndroid Build Coastguard Worker {
38*35238bceSAndroid Build Coastguard Worker namespace gles2
39*35238bceSAndroid Build Coastguard Worker {
40*35238bceSAndroid Build Coastguard Worker namespace Functional
41*35238bceSAndroid Build Coastguard Worker {
42*35238bceSAndroid Build Coastguard Worker
43*35238bceSAndroid Build Coastguard Worker using std::string;
44*35238bceSAndroid Build Coastguard Worker using std::vector;
45*35238bceSAndroid Build Coastguard Worker using tcu::Sampler;
46*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
47*35238bceSAndroid Build Coastguard Worker using namespace glu;
48*35238bceSAndroid Build Coastguard Worker using namespace gls::TextureTestUtil;
49*35238bceSAndroid Build Coastguard Worker using namespace glu::TextureTestUtil;
50*35238bceSAndroid Build Coastguard Worker
51*35238bceSAndroid Build Coastguard Worker enum
52*35238bceSAndroid Build Coastguard Worker {
53*35238bceSAndroid Build Coastguard Worker VIEWPORT_WIDTH = 256,
54*35238bceSAndroid Build Coastguard Worker VIEWPORT_HEIGHT = 256
55*35238bceSAndroid Build Coastguard Worker };
56*35238bceSAndroid Build Coastguard Worker
57*35238bceSAndroid Build Coastguard Worker class TextureWrapCase : public tcu::TestCase
58*35238bceSAndroid Build Coastguard Worker {
59*35238bceSAndroid Build Coastguard Worker public:
60*35238bceSAndroid Build Coastguard Worker TextureWrapCase(tcu::TestContext &testCtx, glu::RenderContext &renderCtx, const glu::ContextInfo &ctxInfo,
61*35238bceSAndroid Build Coastguard Worker const char *name, const char *description, uint32_t format, uint32_t dataType, uint32_t wrapS,
62*35238bceSAndroid Build Coastguard Worker uint32_t wrapT, uint32_t minFilter, uint32_t magFilter, int width, int height,
63*35238bceSAndroid Build Coastguard Worker bool enableRelaxedRef = false);
64*35238bceSAndroid Build Coastguard Worker TextureWrapCase(tcu::TestContext &testCtx, glu::RenderContext &renderCtx, const glu::ContextInfo &ctxInfo,
65*35238bceSAndroid Build Coastguard Worker const char *name, const char *description, uint32_t wrapS, uint32_t wrapT, uint32_t minFilter,
66*35238bceSAndroid Build Coastguard Worker uint32_t magFilter, const std::vector<std::string> &filenames, bool enableRelaxedRef = false);
67*35238bceSAndroid Build Coastguard Worker ~TextureWrapCase(void);
68*35238bceSAndroid Build Coastguard Worker
69*35238bceSAndroid Build Coastguard Worker void init(void);
70*35238bceSAndroid Build Coastguard Worker void deinit(void);
71*35238bceSAndroid Build Coastguard Worker IterateResult iterate(void);
72*35238bceSAndroid Build Coastguard Worker
73*35238bceSAndroid Build Coastguard Worker private:
74*35238bceSAndroid Build Coastguard Worker TextureWrapCase(const TextureWrapCase &other);
75*35238bceSAndroid Build Coastguard Worker TextureWrapCase &operator=(const TextureWrapCase &other);
76*35238bceSAndroid Build Coastguard Worker
77*35238bceSAndroid Build Coastguard Worker glu::RenderContext &m_renderCtx;
78*35238bceSAndroid Build Coastguard Worker const glu::ContextInfo &m_renderCtxInfo;
79*35238bceSAndroid Build Coastguard Worker
80*35238bceSAndroid Build Coastguard Worker uint32_t m_format;
81*35238bceSAndroid Build Coastguard Worker uint32_t m_dataType;
82*35238bceSAndroid Build Coastguard Worker uint32_t m_wrapS;
83*35238bceSAndroid Build Coastguard Worker uint32_t m_wrapT;
84*35238bceSAndroid Build Coastguard Worker uint32_t m_minFilter;
85*35238bceSAndroid Build Coastguard Worker uint32_t m_magFilter;
86*35238bceSAndroid Build Coastguard Worker
87*35238bceSAndroid Build Coastguard Worker int m_width;
88*35238bceSAndroid Build Coastguard Worker int m_height;
89*35238bceSAndroid Build Coastguard Worker std::vector<std::string> m_filenames;
90*35238bceSAndroid Build Coastguard Worker
91*35238bceSAndroid Build Coastguard Worker glu::Texture2D *m_texture;
92*35238bceSAndroid Build Coastguard Worker TextureRenderer m_renderer;
93*35238bceSAndroid Build Coastguard Worker
94*35238bceSAndroid Build Coastguard Worker bool m_enableRelaxedRef;
95*35238bceSAndroid Build Coastguard Worker };
96*35238bceSAndroid Build Coastguard Worker
TextureWrapCase(tcu::TestContext & testCtx,glu::RenderContext & renderCtx,const glu::ContextInfo & ctxInfo,const char * name,const char * description,uint32_t format,uint32_t dataType,uint32_t wrapS,uint32_t wrapT,uint32_t minFilter,uint32_t magFilter,int width,int height,bool enableRelaxedRef)97*35238bceSAndroid Build Coastguard Worker TextureWrapCase::TextureWrapCase(tcu::TestContext &testCtx, glu::RenderContext &renderCtx,
98*35238bceSAndroid Build Coastguard Worker const glu::ContextInfo &ctxInfo, const char *name, const char *description,
99*35238bceSAndroid Build Coastguard Worker uint32_t format, uint32_t dataType, uint32_t wrapS, uint32_t wrapT, uint32_t minFilter,
100*35238bceSAndroid Build Coastguard Worker uint32_t magFilter, int width, int height, bool enableRelaxedRef)
101*35238bceSAndroid Build Coastguard Worker : TestCase(testCtx, name, description)
102*35238bceSAndroid Build Coastguard Worker , m_renderCtx(renderCtx)
103*35238bceSAndroid Build Coastguard Worker , m_renderCtxInfo(ctxInfo)
104*35238bceSAndroid Build Coastguard Worker , m_format(format)
105*35238bceSAndroid Build Coastguard Worker , m_dataType(dataType)
106*35238bceSAndroid Build Coastguard Worker , m_wrapS(wrapS)
107*35238bceSAndroid Build Coastguard Worker , m_wrapT(wrapT)
108*35238bceSAndroid Build Coastguard Worker , m_minFilter(minFilter)
109*35238bceSAndroid Build Coastguard Worker , m_magFilter(magFilter)
110*35238bceSAndroid Build Coastguard Worker , m_width(width)
111*35238bceSAndroid Build Coastguard Worker , m_height(height)
112*35238bceSAndroid Build Coastguard Worker , m_texture(DE_NULL)
113*35238bceSAndroid Build Coastguard Worker , m_renderer(renderCtx, testCtx.getLog(), glu::GLSL_VERSION_100_ES, glu::PRECISION_MEDIUMP)
114*35238bceSAndroid Build Coastguard Worker , m_enableRelaxedRef(enableRelaxedRef)
115*35238bceSAndroid Build Coastguard Worker {
116*35238bceSAndroid Build Coastguard Worker }
117*35238bceSAndroid Build Coastguard Worker
TextureWrapCase(tcu::TestContext & testCtx,glu::RenderContext & renderCtx,const glu::ContextInfo & ctxInfo,const char * name,const char * description,uint32_t wrapS,uint32_t wrapT,uint32_t minFilter,uint32_t magFilter,const std::vector<std::string> & filenames,bool enableRelaxedRef)118*35238bceSAndroid Build Coastguard Worker TextureWrapCase::TextureWrapCase(tcu::TestContext &testCtx, glu::RenderContext &renderCtx,
119*35238bceSAndroid Build Coastguard Worker const glu::ContextInfo &ctxInfo, const char *name, const char *description,
120*35238bceSAndroid Build Coastguard Worker uint32_t wrapS, uint32_t wrapT, uint32_t minFilter, uint32_t magFilter,
121*35238bceSAndroid Build Coastguard Worker const std::vector<std::string> &filenames, bool enableRelaxedRef)
122*35238bceSAndroid Build Coastguard Worker : TestCase(testCtx, name, description)
123*35238bceSAndroid Build Coastguard Worker , m_renderCtx(renderCtx)
124*35238bceSAndroid Build Coastguard Worker , m_renderCtxInfo(ctxInfo)
125*35238bceSAndroid Build Coastguard Worker , m_format(GL_NONE)
126*35238bceSAndroid Build Coastguard Worker , m_dataType(GL_NONE)
127*35238bceSAndroid Build Coastguard Worker , m_wrapS(wrapS)
128*35238bceSAndroid Build Coastguard Worker , m_wrapT(wrapT)
129*35238bceSAndroid Build Coastguard Worker , m_minFilter(minFilter)
130*35238bceSAndroid Build Coastguard Worker , m_magFilter(magFilter)
131*35238bceSAndroid Build Coastguard Worker , m_width(0)
132*35238bceSAndroid Build Coastguard Worker , m_height(0)
133*35238bceSAndroid Build Coastguard Worker , m_filenames(filenames)
134*35238bceSAndroid Build Coastguard Worker , m_texture(DE_NULL)
135*35238bceSAndroid Build Coastguard Worker , m_renderer(renderCtx, testCtx.getLog(), glu::GLSL_VERSION_100_ES, glu::PRECISION_MEDIUMP)
136*35238bceSAndroid Build Coastguard Worker , m_enableRelaxedRef(enableRelaxedRef)
137*35238bceSAndroid Build Coastguard Worker {
138*35238bceSAndroid Build Coastguard Worker }
139*35238bceSAndroid Build Coastguard Worker
~TextureWrapCase(void)140*35238bceSAndroid Build Coastguard Worker TextureWrapCase::~TextureWrapCase(void)
141*35238bceSAndroid Build Coastguard Worker {
142*35238bceSAndroid Build Coastguard Worker deinit();
143*35238bceSAndroid Build Coastguard Worker }
144*35238bceSAndroid Build Coastguard Worker
init(void)145*35238bceSAndroid Build Coastguard Worker void TextureWrapCase::init(void)
146*35238bceSAndroid Build Coastguard Worker {
147*35238bceSAndroid Build Coastguard Worker if (!m_filenames.empty())
148*35238bceSAndroid Build Coastguard Worker {
149*35238bceSAndroid Build Coastguard Worker DE_ASSERT(m_width == 0 && m_height == 0 && m_format == GL_NONE && m_dataType == GL_NONE);
150*35238bceSAndroid Build Coastguard Worker
151*35238bceSAndroid Build Coastguard Worker m_texture = glu::Texture2D::create(m_renderCtx, m_renderCtxInfo, m_testCtx.getArchive(),
152*35238bceSAndroid Build Coastguard Worker (int)m_filenames.size(), m_filenames);
153*35238bceSAndroid Build Coastguard Worker m_width = m_texture->getRefTexture().getWidth();
154*35238bceSAndroid Build Coastguard Worker m_height = m_texture->getRefTexture().getHeight();
155*35238bceSAndroid Build Coastguard Worker }
156*35238bceSAndroid Build Coastguard Worker else
157*35238bceSAndroid Build Coastguard Worker {
158*35238bceSAndroid Build Coastguard Worker m_texture = new Texture2D(m_renderCtx, m_format, m_dataType, m_width, m_height);
159*35238bceSAndroid Build Coastguard Worker
160*35238bceSAndroid Build Coastguard Worker // Fill level 0.
161*35238bceSAndroid Build Coastguard Worker m_texture->getRefTexture().allocLevel(0);
162*35238bceSAndroid Build Coastguard Worker if (m_wrapS == GL_REPEAT || m_wrapT == GL_REPEAT)
163*35238bceSAndroid Build Coastguard Worker {
164*35238bceSAndroid Build Coastguard Worker // If run in repeat mode, use conical style texture to avoid edge sample result have a huge difference when coordinate offset in allow range.
165*35238bceSAndroid Build Coastguard Worker tcu::fillWithComponentGradients3(m_texture->getRefTexture().getLevel(0),
166*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-0.5f, -0.5f, -0.5f, 1.5f), tcu::Vec4(1.0f, 1.0f, 1.0f, 0.0f));
167*35238bceSAndroid Build Coastguard Worker }
168*35238bceSAndroid Build Coastguard Worker else
169*35238bceSAndroid Build Coastguard Worker {
170*35238bceSAndroid Build Coastguard Worker tcu::fillWithComponentGradients(m_texture->getRefTexture().getLevel(0),
171*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-0.5f, -0.5f, -0.5f, 1.5f), tcu::Vec4(1.0f, 1.0f, 1.0f, 0.0f));
172*35238bceSAndroid Build Coastguard Worker }
173*35238bceSAndroid Build Coastguard Worker
174*35238bceSAndroid Build Coastguard Worker m_texture->upload();
175*35238bceSAndroid Build Coastguard Worker }
176*35238bceSAndroid Build Coastguard Worker }
177*35238bceSAndroid Build Coastguard Worker
deinit(void)178*35238bceSAndroid Build Coastguard Worker void TextureWrapCase::deinit(void)
179*35238bceSAndroid Build Coastguard Worker {
180*35238bceSAndroid Build Coastguard Worker delete m_texture;
181*35238bceSAndroid Build Coastguard Worker m_texture = DE_NULL;
182*35238bceSAndroid Build Coastguard Worker
183*35238bceSAndroid Build Coastguard Worker m_renderer.clear();
184*35238bceSAndroid Build Coastguard Worker }
185*35238bceSAndroid Build Coastguard Worker
iterate(void)186*35238bceSAndroid Build Coastguard Worker TextureWrapCase::IterateResult TextureWrapCase::iterate(void)
187*35238bceSAndroid Build Coastguard Worker {
188*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_renderCtx.getFunctions();
189*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
190*35238bceSAndroid Build Coastguard Worker RandomViewport viewport(m_renderCtx.getRenderTarget(), VIEWPORT_WIDTH, VIEWPORT_HEIGHT, deStringHash(getName()));
191*35238bceSAndroid Build Coastguard Worker tcu::Surface renderedFrame(viewport.width, viewport.height);
192*35238bceSAndroid Build Coastguard Worker tcu::Surface referenceFrame(viewport.width, viewport.height);
193*35238bceSAndroid Build Coastguard Worker bool isCompressedTex = !m_filenames.empty();
194*35238bceSAndroid Build Coastguard Worker ReferenceParams refParams(TEXTURETYPE_2D);
195*35238bceSAndroid Build Coastguard Worker int leftWidth = viewport.width / 2;
196*35238bceSAndroid Build Coastguard Worker int rightWidth = viewport.width - leftWidth;
197*35238bceSAndroid Build Coastguard Worker vector<float> texCoord;
198*35238bceSAndroid Build Coastguard Worker
199*35238bceSAndroid Build Coastguard Worker tcu::RGBA threshold;
200*35238bceSAndroid Build Coastguard Worker if (m_texture->getRefTexture().getFormat().type == tcu::TextureFormat::UNORM_SHORT_4444 ||
201*35238bceSAndroid Build Coastguard Worker m_texture->getRefTexture().getFormat().type == tcu::TextureFormat::UNSIGNED_SHORT_4444)
202*35238bceSAndroid Build Coastguard Worker {
203*35238bceSAndroid Build Coastguard Worker threshold = tcu::PixelFormat(4, 4, 4, 4).getColorThreshold() + tcu::RGBA(1, 1, 1, 1);
204*35238bceSAndroid Build Coastguard Worker }
205*35238bceSAndroid Build Coastguard Worker else
206*35238bceSAndroid Build Coastguard Worker {
207*35238bceSAndroid Build Coastguard Worker threshold = m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() +
208*35238bceSAndroid Build Coastguard Worker (isCompressedTex ? tcu::RGBA(7, 7, 7, 7) : tcu::RGBA(3, 3, 3, 3));
209*35238bceSAndroid Build Coastguard Worker }
210*35238bceSAndroid Build Coastguard Worker
211*35238bceSAndroid Build Coastguard Worker // Bind to unit 0.
212*35238bceSAndroid Build Coastguard Worker gl.activeTexture(GL_TEXTURE0);
213*35238bceSAndroid Build Coastguard Worker gl.bindTexture(GL_TEXTURE_2D, m_texture->getGLTexture());
214*35238bceSAndroid Build Coastguard Worker
215*35238bceSAndroid Build Coastguard Worker // Setup filtering and wrap modes.
216*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, m_wrapS);
217*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, m_wrapT);
218*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, m_minFilter);
219*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, m_magFilter);
220*35238bceSAndroid Build Coastguard Worker
221*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "Set texturing state");
222*35238bceSAndroid Build Coastguard Worker
223*35238bceSAndroid Build Coastguard Worker // Parameters for reference images.
224*35238bceSAndroid Build Coastguard Worker refParams.sampler = mapGLSampler(m_wrapS, m_wrapT, m_minFilter, m_magFilter);
225*35238bceSAndroid Build Coastguard Worker refParams.lodMode = LODMODE_EXACT;
226*35238bceSAndroid Build Coastguard Worker
227*35238bceSAndroid Build Coastguard Worker // Left: minification
228*35238bceSAndroid Build Coastguard Worker {
229*35238bceSAndroid Build Coastguard Worker gl.viewport(viewport.x, viewport.y, leftWidth, viewport.height);
230*35238bceSAndroid Build Coastguard Worker
231*35238bceSAndroid Build Coastguard Worker computeQuadTexCoord2D(texCoord, tcu::Vec2(-1.5f, -3.0f), tcu::Vec2(1.5f, 2.5f));
232*35238bceSAndroid Build Coastguard Worker
233*35238bceSAndroid Build Coastguard Worker m_renderer.renderQuad(0, &texCoord[0], refParams);
234*35238bceSAndroid Build Coastguard Worker glu::readPixels(m_renderCtx, viewport.x, viewport.y, renderedFrame.getAccess());
235*35238bceSAndroid Build Coastguard Worker
236*35238bceSAndroid Build Coastguard Worker sampleTexture(tcu::SurfaceAccess(referenceFrame, m_renderCtx.getRenderTarget().getPixelFormat(), 0, 0,
237*35238bceSAndroid Build Coastguard Worker leftWidth, viewport.height),
238*35238bceSAndroid Build Coastguard Worker m_texture->getRefTexture(), &texCoord[0], refParams);
239*35238bceSAndroid Build Coastguard Worker }
240*35238bceSAndroid Build Coastguard Worker
241*35238bceSAndroid Build Coastguard Worker // Right: magnification
242*35238bceSAndroid Build Coastguard Worker {
243*35238bceSAndroid Build Coastguard Worker gl.viewport(viewport.x + leftWidth, viewport.y, rightWidth, viewport.height);
244*35238bceSAndroid Build Coastguard Worker
245*35238bceSAndroid Build Coastguard Worker computeQuadTexCoord2D(texCoord, tcu::Vec2(-0.5f, 0.75f), tcu::Vec2(0.25f, 1.25f));
246*35238bceSAndroid Build Coastguard Worker
247*35238bceSAndroid Build Coastguard Worker m_renderer.renderQuad(0, &texCoord[0], refParams);
248*35238bceSAndroid Build Coastguard Worker glu::readPixels(m_renderCtx, viewport.x, viewport.y, renderedFrame.getAccess());
249*35238bceSAndroid Build Coastguard Worker
250*35238bceSAndroid Build Coastguard Worker sampleTexture(tcu::SurfaceAccess(referenceFrame, m_renderCtx.getRenderTarget().getPixelFormat(), leftWidth, 0,
251*35238bceSAndroid Build Coastguard Worker rightWidth, viewport.height),
252*35238bceSAndroid Build Coastguard Worker m_texture->getRefTexture(), &texCoord[0], refParams);
253*35238bceSAndroid Build Coastguard Worker }
254*35238bceSAndroid Build Coastguard Worker
255*35238bceSAndroid Build Coastguard Worker // Compare and log.
256*35238bceSAndroid Build Coastguard Worker bool isOk = compareImages(log, referenceFrame, renderedFrame, threshold);
257*35238bceSAndroid Build Coastguard Worker
258*35238bceSAndroid Build Coastguard Worker if ((isOk == false) && m_enableRelaxedRef && m_renderer.getTexCoordPrecision() != PRECISION_HIGHP)
259*35238bceSAndroid Build Coastguard Worker {
260*35238bceSAndroid Build Coastguard Worker refParams.float16TexCoord = true;
261*35238bceSAndroid Build Coastguard Worker // Left: minification
262*35238bceSAndroid Build Coastguard Worker {
263*35238bceSAndroid Build Coastguard Worker computeQuadTexCoord2D(texCoord, tcu::Vec2(-1.5f, -3.0f), tcu::Vec2(1.5f, 2.5f));
264*35238bceSAndroid Build Coastguard Worker sampleTexture(tcu::SurfaceAccess(referenceFrame, m_renderCtx.getRenderTarget().getPixelFormat(), 0, 0,
265*35238bceSAndroid Build Coastguard Worker leftWidth, viewport.height),
266*35238bceSAndroid Build Coastguard Worker m_texture->getRefTexture(), &texCoord[0], refParams);
267*35238bceSAndroid Build Coastguard Worker }
268*35238bceSAndroid Build Coastguard Worker
269*35238bceSAndroid Build Coastguard Worker // Right: magnification
270*35238bceSAndroid Build Coastguard Worker {
271*35238bceSAndroid Build Coastguard Worker computeQuadTexCoord2D(texCoord, tcu::Vec2(-0.5f, 0.75f), tcu::Vec2(0.25f, 1.25f));
272*35238bceSAndroid Build Coastguard Worker sampleTexture(tcu::SurfaceAccess(referenceFrame, m_renderCtx.getRenderTarget().getPixelFormat(), leftWidth,
273*35238bceSAndroid Build Coastguard Worker 0, rightWidth, viewport.height),
274*35238bceSAndroid Build Coastguard Worker m_texture->getRefTexture(), &texCoord[0], refParams);
275*35238bceSAndroid Build Coastguard Worker }
276*35238bceSAndroid Build Coastguard Worker
277*35238bceSAndroid Build Coastguard Worker isOk |= compareImages(log, referenceFrame, renderedFrame, threshold);
278*35238bceSAndroid Build Coastguard Worker }
279*35238bceSAndroid Build Coastguard Worker
280*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(isOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
281*35238bceSAndroid Build Coastguard Worker isOk ? "Pass" : "Image comparison failed");
282*35238bceSAndroid Build Coastguard Worker
283*35238bceSAndroid Build Coastguard Worker return STOP;
284*35238bceSAndroid Build Coastguard Worker }
285*35238bceSAndroid Build Coastguard Worker
TextureWrapTests(Context & context)286*35238bceSAndroid Build Coastguard Worker TextureWrapTests::TextureWrapTests(Context &context) : TestCaseGroup(context, "wrap", "Wrap Mode Tests")
287*35238bceSAndroid Build Coastguard Worker {
288*35238bceSAndroid Build Coastguard Worker }
289*35238bceSAndroid Build Coastguard Worker
~TextureWrapTests(void)290*35238bceSAndroid Build Coastguard Worker TextureWrapTests::~TextureWrapTests(void)
291*35238bceSAndroid Build Coastguard Worker {
292*35238bceSAndroid Build Coastguard Worker }
293*35238bceSAndroid Build Coastguard Worker
init(void)294*35238bceSAndroid Build Coastguard Worker void TextureWrapTests::init(void)
295*35238bceSAndroid Build Coastguard Worker {
296*35238bceSAndroid Build Coastguard Worker static const struct
297*35238bceSAndroid Build Coastguard Worker {
298*35238bceSAndroid Build Coastguard Worker const char *name;
299*35238bceSAndroid Build Coastguard Worker uint32_t mode;
300*35238bceSAndroid Build Coastguard Worker } wrapModes[] = {{"clamp", GL_CLAMP_TO_EDGE}, {"repeat", GL_REPEAT}, {"mirror", GL_MIRRORED_REPEAT}};
301*35238bceSAndroid Build Coastguard Worker
302*35238bceSAndroid Build Coastguard Worker static const struct
303*35238bceSAndroid Build Coastguard Worker {
304*35238bceSAndroid Build Coastguard Worker const char *name;
305*35238bceSAndroid Build Coastguard Worker uint32_t mode;
306*35238bceSAndroid Build Coastguard Worker } filteringModes[] = {{"nearest", GL_NEAREST}, {"linear", GL_LINEAR}};
307*35238bceSAndroid Build Coastguard Worker
308*35238bceSAndroid Build Coastguard Worker static const struct
309*35238bceSAndroid Build Coastguard Worker {
310*35238bceSAndroid Build Coastguard Worker const char *name;
311*35238bceSAndroid Build Coastguard Worker int width;
312*35238bceSAndroid Build Coastguard Worker int height;
313*35238bceSAndroid Build Coastguard Worker } sizes[] = {{"pot", 64, 128}, {"npot", 63, 112}};
314*35238bceSAndroid Build Coastguard Worker
315*35238bceSAndroid Build Coastguard Worker static const struct
316*35238bceSAndroid Build Coastguard Worker {
317*35238bceSAndroid Build Coastguard Worker const char *name;
318*35238bceSAndroid Build Coastguard Worker uint32_t format;
319*35238bceSAndroid Build Coastguard Worker uint32_t dataType;
320*35238bceSAndroid Build Coastguard Worker } formats[] = {
321*35238bceSAndroid Build Coastguard Worker {"rgba8888", GL_RGBA, GL_UNSIGNED_BYTE},
322*35238bceSAndroid Build Coastguard Worker {"rgb888", GL_RGB, GL_UNSIGNED_BYTE},
323*35238bceSAndroid Build Coastguard Worker {"rgba4444", GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4},
324*35238bceSAndroid Build Coastguard Worker {"l8", GL_LUMINANCE, GL_UNSIGNED_BYTE},
325*35238bceSAndroid Build Coastguard Worker };
326*35238bceSAndroid Build Coastguard Worker
327*35238bceSAndroid Build Coastguard Worker #define FOR_EACH(ITERATOR, ARRAY, BODY) \
328*35238bceSAndroid Build Coastguard Worker for (int ITERATOR = 0; ITERATOR < DE_LENGTH_OF_ARRAY(ARRAY); ITERATOR++) \
329*35238bceSAndroid Build Coastguard Worker BODY
330*35238bceSAndroid Build Coastguard Worker
331*35238bceSAndroid Build Coastguard Worker FOR_EACH(
332*35238bceSAndroid Build Coastguard Worker wrapS, wrapModes,
333*35238bceSAndroid Build Coastguard Worker FOR_EACH(
334*35238bceSAndroid Build Coastguard Worker wrapT, wrapModes,
335*35238bceSAndroid Build Coastguard Worker FOR_EACH(filter, filteringModes,
336*35238bceSAndroid Build Coastguard Worker FOR_EACH(size, sizes, FOR_EACH(format, formats, {
337*35238bceSAndroid Build Coastguard Worker bool is_clamp_clamp = (wrapModes[wrapS].mode == GL_CLAMP_TO_EDGE &&
338*35238bceSAndroid Build Coastguard Worker wrapModes[wrapT].mode == GL_CLAMP_TO_EDGE);
339*35238bceSAndroid Build Coastguard Worker bool is_repeat_mirror = (wrapModes[wrapS].mode == GL_REPEAT &&
340*35238bceSAndroid Build Coastguard Worker wrapModes[wrapT].mode == GL_MIRRORED_REPEAT);
341*35238bceSAndroid Build Coastguard Worker bool enableRelaxedPrecisionRef = wrapModes[wrapS].mode == GL_REPEAT ||
342*35238bceSAndroid Build Coastguard Worker wrapModes[wrapT].mode == GL_REPEAT ||
343*35238bceSAndroid Build Coastguard Worker wrapModes[wrapS].mode == GL_MIRRORED_REPEAT ||
344*35238bceSAndroid Build Coastguard Worker wrapModes[wrapT].mode == GL_MIRRORED_REPEAT;
345*35238bceSAndroid Build Coastguard Worker
346*35238bceSAndroid Build Coastguard Worker if (!is_clamp_clamp && !is_repeat_mirror && format != 0)
347*35238bceSAndroid Build Coastguard Worker continue; // Use other format varants with clamp_clamp & repeat_mirror pair only.
348*35238bceSAndroid Build Coastguard Worker
349*35238bceSAndroid Build Coastguard Worker if (!is_clamp_clamp &&
350*35238bceSAndroid Build Coastguard Worker (!deIsPowerOfTwo32(sizes[size].width) || !deIsPowerOfTwo32(sizes[size].height)))
351*35238bceSAndroid Build Coastguard Worker continue; // Not supported as described in Spec section 3.8.2.
352*35238bceSAndroid Build Coastguard Worker
353*35238bceSAndroid Build Coastguard Worker string name = string("") + wrapModes[wrapS].name + "_" + wrapModes[wrapT].name + "_" +
354*35238bceSAndroid Build Coastguard Worker filteringModes[filter].name + "_" + sizes[size].name + "_" +
355*35238bceSAndroid Build Coastguard Worker formats[format].name;
356*35238bceSAndroid Build Coastguard Worker addChild(new TextureWrapCase(
357*35238bceSAndroid Build Coastguard Worker m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(), name.c_str(),
358*35238bceSAndroid Build Coastguard Worker "", formats[format].format, formats[format].dataType, wrapModes[wrapS].mode,
359*35238bceSAndroid Build Coastguard Worker wrapModes[wrapT].mode, filteringModes[filter].mode, filteringModes[filter].mode,
360*35238bceSAndroid Build Coastguard Worker sizes[size].width, sizes[size].height, enableRelaxedPrecisionRef));
361*35238bceSAndroid Build Coastguard Worker })))))
362*35238bceSAndroid Build Coastguard Worker
363*35238bceSAndroid Build Coastguard Worker // Power-of-two ETC1 texture
364*35238bceSAndroid Build Coastguard Worker std::vector<std::string> potFilenames;
365*35238bceSAndroid Build Coastguard Worker potFilenames.push_back("data/etc1/photo_helsinki_mip_0.pkm");
366*35238bceSAndroid Build Coastguard Worker
367*35238bceSAndroid Build Coastguard Worker FOR_EACH(wrapS, wrapModes,
368*35238bceSAndroid Build Coastguard Worker FOR_EACH(wrapT, wrapModes, FOR_EACH(filter, filteringModes, {
369*35238bceSAndroid Build Coastguard Worker bool enableRelaxedPrecisionRef = wrapModes[wrapS].mode == GL_REPEAT ||
370*35238bceSAndroid Build Coastguard Worker wrapModes[wrapT].mode == GL_REPEAT ||
371*35238bceSAndroid Build Coastguard Worker wrapModes[wrapS].mode == GL_MIRRORED_REPEAT ||
372*35238bceSAndroid Build Coastguard Worker wrapModes[wrapT].mode == GL_MIRRORED_REPEAT;
373*35238bceSAndroid Build Coastguard Worker
374*35238bceSAndroid Build Coastguard Worker string name = string("") + wrapModes[wrapS].name + "_" + wrapModes[wrapT].name + "_" +
375*35238bceSAndroid Build Coastguard Worker filteringModes[filter].name + "_pot_etc1";
376*35238bceSAndroid Build Coastguard Worker addChild(new TextureWrapCase(
377*35238bceSAndroid Build Coastguard Worker m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(), name.c_str(), "",
378*35238bceSAndroid Build Coastguard Worker wrapModes[wrapS].mode, wrapModes[wrapT].mode, filteringModes[filter].mode,
379*35238bceSAndroid Build Coastguard Worker filteringModes[filter].mode, potFilenames, enableRelaxedPrecisionRef));
380*35238bceSAndroid Build Coastguard Worker })))
381*35238bceSAndroid Build Coastguard Worker
382*35238bceSAndroid Build Coastguard Worker std::vector<std::string> npotFilenames;
383*35238bceSAndroid Build Coastguard Worker npotFilenames.push_back("data/etc1/photo_helsinki_113x89.pkm");
384*35238bceSAndroid Build Coastguard Worker
385*35238bceSAndroid Build Coastguard Worker // NPOT ETC1 texture
386*35238bceSAndroid Build Coastguard Worker for (int filter = 0; filter < DE_LENGTH_OF_ARRAY(filteringModes); filter++)
387*35238bceSAndroid Build Coastguard Worker {
388*35238bceSAndroid Build Coastguard Worker string name = string("clamp_clamp_") + filteringModes[filter].name + "_npot_etc1";
389*35238bceSAndroid Build Coastguard Worker addChild(new TextureWrapCase(m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(), name.c_str(),
390*35238bceSAndroid Build Coastguard Worker "", GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE, filteringModes[filter].mode,
391*35238bceSAndroid Build Coastguard Worker filteringModes[filter].mode, npotFilenames));
392*35238bceSAndroid Build Coastguard Worker }
393*35238bceSAndroid Build Coastguard Worker }
394*35238bceSAndroid Build Coastguard Worker
395*35238bceSAndroid Build Coastguard Worker } // namespace Functional
396*35238bceSAndroid Build Coastguard Worker } // namespace gles2
397*35238bceSAndroid Build Coastguard Worker } // namespace deqp
398