1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker * drawElements Quality Program OpenGL ES 3.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 Shadow texture lookup tests.
22*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker
24*35238bceSAndroid Build Coastguard Worker #include "es3fTextureShadowTests.hpp"
25*35238bceSAndroid Build Coastguard Worker #include "gluTexture.hpp"
26*35238bceSAndroid Build Coastguard Worker #include "gluPixelTransfer.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "gluTextureUtil.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "glsTextureTestUtil.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "tcuTextureUtil.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "tcuRenderTarget.hpp"
31*35238bceSAndroid Build Coastguard Worker #include "tcuTexCompareVerifier.hpp"
32*35238bceSAndroid Build Coastguard Worker #include "tcuVectorUtil.hpp"
33*35238bceSAndroid Build Coastguard Worker #include "deString.h"
34*35238bceSAndroid Build Coastguard Worker #include "deMath.h"
35*35238bceSAndroid Build Coastguard Worker #include "deStringUtil.hpp"
36*35238bceSAndroid Build Coastguard Worker #include "glwFunctions.hpp"
37*35238bceSAndroid Build Coastguard Worker #include "glwEnums.hpp"
38*35238bceSAndroid Build Coastguard Worker
39*35238bceSAndroid Build Coastguard Worker namespace deqp
40*35238bceSAndroid Build Coastguard Worker {
41*35238bceSAndroid Build Coastguard Worker namespace gles3
42*35238bceSAndroid Build Coastguard Worker {
43*35238bceSAndroid Build Coastguard Worker namespace Functional
44*35238bceSAndroid Build Coastguard Worker {
45*35238bceSAndroid Build Coastguard Worker
46*35238bceSAndroid Build Coastguard Worker using std::string;
47*35238bceSAndroid Build Coastguard Worker using std::vector;
48*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
49*35238bceSAndroid Build Coastguard Worker using namespace deqp::gls::TextureTestUtil;
50*35238bceSAndroid Build Coastguard Worker using namespace glu::TextureTestUtil;
51*35238bceSAndroid Build Coastguard Worker
52*35238bceSAndroid Build Coastguard Worker enum
53*35238bceSAndroid Build Coastguard Worker {
54*35238bceSAndroid Build Coastguard Worker TEX2D_VIEWPORT_WIDTH = 64,
55*35238bceSAndroid Build Coastguard Worker TEX2D_VIEWPORT_HEIGHT = 64,
56*35238bceSAndroid Build Coastguard Worker TEX2D_MIN_VIEWPORT_WIDTH = 64,
57*35238bceSAndroid Build Coastguard Worker TEX2D_MIN_VIEWPORT_HEIGHT = 64
58*35238bceSAndroid Build Coastguard Worker };
59*35238bceSAndroid Build Coastguard Worker
isFloatingPointDepthFormat(const tcu::TextureFormat & format)60*35238bceSAndroid Build Coastguard Worker static bool isFloatingPointDepthFormat(const tcu::TextureFormat &format)
61*35238bceSAndroid Build Coastguard Worker {
62*35238bceSAndroid Build Coastguard Worker // Only two depth and depth-stencil formats are floating point
63*35238bceSAndroid Build Coastguard Worker return (format.order == tcu::TextureFormat::D && format.type == tcu::TextureFormat::FLOAT) ||
64*35238bceSAndroid Build Coastguard Worker (format.order == tcu::TextureFormat::DS && format.type == tcu::TextureFormat::FLOAT_UNSIGNED_INT_24_8_REV);
65*35238bceSAndroid Build Coastguard Worker }
66*35238bceSAndroid Build Coastguard Worker
clampFloatingPointTexture(const tcu::PixelBufferAccess & access)67*35238bceSAndroid Build Coastguard Worker static void clampFloatingPointTexture(const tcu::PixelBufferAccess &access)
68*35238bceSAndroid Build Coastguard Worker {
69*35238bceSAndroid Build Coastguard Worker DE_ASSERT(isFloatingPointDepthFormat(access.getFormat()));
70*35238bceSAndroid Build Coastguard Worker
71*35238bceSAndroid Build Coastguard Worker for (int z = 0; z < access.getDepth(); ++z)
72*35238bceSAndroid Build Coastguard Worker for (int y = 0; y < access.getHeight(); ++y)
73*35238bceSAndroid Build Coastguard Worker for (int x = 0; x < access.getWidth(); ++x)
74*35238bceSAndroid Build Coastguard Worker access.setPixDepth(de::clamp(access.getPixDepth(x, y, z), 0.0f, 1.0f), x, y, z);
75*35238bceSAndroid Build Coastguard Worker }
76*35238bceSAndroid Build Coastguard Worker
clampFloatingPointTexture(tcu::Texture2D & target)77*35238bceSAndroid Build Coastguard Worker static void clampFloatingPointTexture(tcu::Texture2D &target)
78*35238bceSAndroid Build Coastguard Worker {
79*35238bceSAndroid Build Coastguard Worker for (int level = 0; level < target.getNumLevels(); ++level)
80*35238bceSAndroid Build Coastguard Worker if (!target.isLevelEmpty(level))
81*35238bceSAndroid Build Coastguard Worker clampFloatingPointTexture(target.getLevel(level));
82*35238bceSAndroid Build Coastguard Worker }
83*35238bceSAndroid Build Coastguard Worker
clampFloatingPointTexture(tcu::Texture2DArray & target)84*35238bceSAndroid Build Coastguard Worker static void clampFloatingPointTexture(tcu::Texture2DArray &target)
85*35238bceSAndroid Build Coastguard Worker {
86*35238bceSAndroid Build Coastguard Worker for (int level = 0; level < target.getNumLevels(); ++level)
87*35238bceSAndroid Build Coastguard Worker if (!target.isLevelEmpty(level))
88*35238bceSAndroid Build Coastguard Worker clampFloatingPointTexture(target.getLevel(level));
89*35238bceSAndroid Build Coastguard Worker }
90*35238bceSAndroid Build Coastguard Worker
clampFloatingPointTexture(tcu::TextureCube & target)91*35238bceSAndroid Build Coastguard Worker static void clampFloatingPointTexture(tcu::TextureCube &target)
92*35238bceSAndroid Build Coastguard Worker {
93*35238bceSAndroid Build Coastguard Worker for (int level = 0; level < target.getNumLevels(); ++level)
94*35238bceSAndroid Build Coastguard Worker for (int face = tcu::CUBEFACE_NEGATIVE_X; face < tcu::CUBEFACE_LAST; ++face)
95*35238bceSAndroid Build Coastguard Worker clampFloatingPointTexture(target.getLevelFace(level, (tcu::CubeFace)face));
96*35238bceSAndroid Build Coastguard Worker }
97*35238bceSAndroid Build Coastguard Worker
98*35238bceSAndroid Build Coastguard Worker template <typename TextureType>
verifyTexCompareResult(tcu::TestContext & testCtx,const tcu::ConstPixelBufferAccess & result,const TextureType & src,const float * texCoord,const ReferenceParams & sampleParams,const tcu::TexComparePrecision & comparePrec,const tcu::LodPrecision & lodPrec,const tcu::PixelFormat & pixelFormat)99*35238bceSAndroid Build Coastguard Worker bool verifyTexCompareResult(tcu::TestContext &testCtx, const tcu::ConstPixelBufferAccess &result,
100*35238bceSAndroid Build Coastguard Worker const TextureType &src, const float *texCoord, const ReferenceParams &sampleParams,
101*35238bceSAndroid Build Coastguard Worker const tcu::TexComparePrecision &comparePrec, const tcu::LodPrecision &lodPrec,
102*35238bceSAndroid Build Coastguard Worker const tcu::PixelFormat &pixelFormat)
103*35238bceSAndroid Build Coastguard Worker {
104*35238bceSAndroid Build Coastguard Worker tcu::TestLog &log = testCtx.getLog();
105*35238bceSAndroid Build Coastguard Worker tcu::Surface reference(result.getWidth(), result.getHeight());
106*35238bceSAndroid Build Coastguard Worker tcu::Surface errorMask(result.getWidth(), result.getHeight());
107*35238bceSAndroid Build Coastguard Worker const tcu::IVec4 nonShadowBits = tcu::max(getBitsVec(pixelFormat) - 1, tcu::IVec4(0));
108*35238bceSAndroid Build Coastguard Worker const tcu::Vec3 nonShadowThreshold = tcu::computeFixedPointThreshold(nonShadowBits).swizzle(1, 2, 3);
109*35238bceSAndroid Build Coastguard Worker int numFailedPixels;
110*35238bceSAndroid Build Coastguard Worker
111*35238bceSAndroid Build Coastguard Worker // sampleTexture() expects source image to be the same state as it would be in a GL implementation, that is
112*35238bceSAndroid Build Coastguard Worker // the floating point depth values should be in [0, 1] range as data is clamped during texture upload. Since
113*35238bceSAndroid Build Coastguard Worker // we don't have a separate "uploading" phase and just reuse the buffer we used for GL-upload, do the clamping
114*35238bceSAndroid Build Coastguard Worker // here if necessary.
115*35238bceSAndroid Build Coastguard Worker
116*35238bceSAndroid Build Coastguard Worker if (isFloatingPointDepthFormat(src.getFormat()))
117*35238bceSAndroid Build Coastguard Worker {
118*35238bceSAndroid Build Coastguard Worker TextureType clampedSource(src);
119*35238bceSAndroid Build Coastguard Worker
120*35238bceSAndroid Build Coastguard Worker clampFloatingPointTexture(clampedSource);
121*35238bceSAndroid Build Coastguard Worker
122*35238bceSAndroid Build Coastguard Worker // sample clamped values
123*35238bceSAndroid Build Coastguard Worker
124*35238bceSAndroid Build Coastguard Worker sampleTexture(tcu::SurfaceAccess(reference, pixelFormat), clampedSource, texCoord, sampleParams);
125*35238bceSAndroid Build Coastguard Worker numFailedPixels = computeTextureCompareDiff(result, reference.getAccess(), errorMask.getAccess(), clampedSource,
126*35238bceSAndroid Build Coastguard Worker texCoord, sampleParams, comparePrec, lodPrec, nonShadowThreshold);
127*35238bceSAndroid Build Coastguard Worker }
128*35238bceSAndroid Build Coastguard Worker else
129*35238bceSAndroid Build Coastguard Worker {
130*35238bceSAndroid Build Coastguard Worker // sample raw values (they are guaranteed to be in [0, 1] range as the format cannot represent any other values)
131*35238bceSAndroid Build Coastguard Worker
132*35238bceSAndroid Build Coastguard Worker sampleTexture(tcu::SurfaceAccess(reference, pixelFormat), src, texCoord, sampleParams);
133*35238bceSAndroid Build Coastguard Worker numFailedPixels = computeTextureCompareDiff(result, reference.getAccess(), errorMask.getAccess(), src, texCoord,
134*35238bceSAndroid Build Coastguard Worker sampleParams, comparePrec, lodPrec, nonShadowThreshold);
135*35238bceSAndroid Build Coastguard Worker }
136*35238bceSAndroid Build Coastguard Worker
137*35238bceSAndroid Build Coastguard Worker if (numFailedPixels > 0)
138*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "ERROR: Result verification failed, got " << numFailedPixels << " invalid pixels!"
139*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
140*35238bceSAndroid Build Coastguard Worker
141*35238bceSAndroid Build Coastguard Worker log << TestLog::ImageSet("VerifyResult", "Verification result")
142*35238bceSAndroid Build Coastguard Worker << TestLog::Image("Rendered", "Rendered image", result);
143*35238bceSAndroid Build Coastguard Worker
144*35238bceSAndroid Build Coastguard Worker if (numFailedPixels > 0)
145*35238bceSAndroid Build Coastguard Worker {
146*35238bceSAndroid Build Coastguard Worker log << TestLog::Image("Reference", "Ideal reference image", reference)
147*35238bceSAndroid Build Coastguard Worker << TestLog::Image("ErrorMask", "Error mask", errorMask);
148*35238bceSAndroid Build Coastguard Worker }
149*35238bceSAndroid Build Coastguard Worker
150*35238bceSAndroid Build Coastguard Worker log << TestLog::EndImageSet;
151*35238bceSAndroid Build Coastguard Worker
152*35238bceSAndroid Build Coastguard Worker return numFailedPixels == 0;
153*35238bceSAndroid Build Coastguard Worker }
154*35238bceSAndroid Build Coastguard Worker
155*35238bceSAndroid Build Coastguard Worker class Texture2DShadowCase : public TestCase
156*35238bceSAndroid Build Coastguard Worker {
157*35238bceSAndroid Build Coastguard Worker public:
158*35238bceSAndroid Build Coastguard Worker Texture2DShadowCase(Context &context, const char *name, const char *desc, uint32_t minFilter, uint32_t magFilter,
159*35238bceSAndroid Build Coastguard Worker uint32_t wrapS, uint32_t wrapT, uint32_t format, int width, int height, uint32_t compareFunc);
160*35238bceSAndroid Build Coastguard Worker ~Texture2DShadowCase(void);
161*35238bceSAndroid Build Coastguard Worker
162*35238bceSAndroid Build Coastguard Worker void init(void);
163*35238bceSAndroid Build Coastguard Worker void deinit(void);
164*35238bceSAndroid Build Coastguard Worker IterateResult iterate(void);
165*35238bceSAndroid Build Coastguard Worker
166*35238bceSAndroid Build Coastguard Worker private:
167*35238bceSAndroid Build Coastguard Worker Texture2DShadowCase(const Texture2DShadowCase &other);
168*35238bceSAndroid Build Coastguard Worker Texture2DShadowCase &operator=(const Texture2DShadowCase &other);
169*35238bceSAndroid Build Coastguard Worker
170*35238bceSAndroid Build Coastguard Worker const uint32_t m_minFilter;
171*35238bceSAndroid Build Coastguard Worker const uint32_t m_magFilter;
172*35238bceSAndroid Build Coastguard Worker const uint32_t m_wrapS;
173*35238bceSAndroid Build Coastguard Worker const uint32_t m_wrapT;
174*35238bceSAndroid Build Coastguard Worker const uint32_t m_format;
175*35238bceSAndroid Build Coastguard Worker const int m_width;
176*35238bceSAndroid Build Coastguard Worker const int m_height;
177*35238bceSAndroid Build Coastguard Worker const uint32_t m_compareFunc;
178*35238bceSAndroid Build Coastguard Worker
179*35238bceSAndroid Build Coastguard Worker struct FilterCase
180*35238bceSAndroid Build Coastguard Worker {
181*35238bceSAndroid Build Coastguard Worker const glu::Texture2D *texture;
182*35238bceSAndroid Build Coastguard Worker tcu::Vec2 minCoord;
183*35238bceSAndroid Build Coastguard Worker tcu::Vec2 maxCoord;
184*35238bceSAndroid Build Coastguard Worker float ref;
185*35238bceSAndroid Build Coastguard Worker
FilterCasedeqp::gles3::Functional::Texture2DShadowCase::FilterCase186*35238bceSAndroid Build Coastguard Worker FilterCase(void) : texture(DE_NULL), ref(0.0f)
187*35238bceSAndroid Build Coastguard Worker {
188*35238bceSAndroid Build Coastguard Worker }
189*35238bceSAndroid Build Coastguard Worker
FilterCasedeqp::gles3::Functional::Texture2DShadowCase::FilterCase190*35238bceSAndroid Build Coastguard Worker FilterCase(const glu::Texture2D *tex_, const float ref_, const tcu::Vec2 &minCoord_, const tcu::Vec2 &maxCoord_)
191*35238bceSAndroid Build Coastguard Worker : texture(tex_)
192*35238bceSAndroid Build Coastguard Worker , minCoord(minCoord_)
193*35238bceSAndroid Build Coastguard Worker , maxCoord(maxCoord_)
194*35238bceSAndroid Build Coastguard Worker , ref(ref_)
195*35238bceSAndroid Build Coastguard Worker {
196*35238bceSAndroid Build Coastguard Worker }
197*35238bceSAndroid Build Coastguard Worker };
198*35238bceSAndroid Build Coastguard Worker
199*35238bceSAndroid Build Coastguard Worker std::vector<glu::Texture2D *> m_textures;
200*35238bceSAndroid Build Coastguard Worker std::vector<FilterCase> m_cases;
201*35238bceSAndroid Build Coastguard Worker
202*35238bceSAndroid Build Coastguard Worker TextureRenderer m_renderer;
203*35238bceSAndroid Build Coastguard Worker
204*35238bceSAndroid Build Coastguard Worker int m_caseNdx;
205*35238bceSAndroid Build Coastguard Worker };
206*35238bceSAndroid Build Coastguard Worker
Texture2DShadowCase(Context & context,const char * name,const char * desc,uint32_t minFilter,uint32_t magFilter,uint32_t wrapS,uint32_t wrapT,uint32_t format,int width,int height,uint32_t compareFunc)207*35238bceSAndroid Build Coastguard Worker Texture2DShadowCase::Texture2DShadowCase(Context &context, const char *name, const char *desc, uint32_t minFilter,
208*35238bceSAndroid Build Coastguard Worker uint32_t magFilter, uint32_t wrapS, uint32_t wrapT, uint32_t format, int width,
209*35238bceSAndroid Build Coastguard Worker int height, uint32_t compareFunc)
210*35238bceSAndroid Build Coastguard Worker : TestCase(context, name, desc)
211*35238bceSAndroid Build Coastguard Worker , m_minFilter(minFilter)
212*35238bceSAndroid Build Coastguard Worker , m_magFilter(magFilter)
213*35238bceSAndroid Build Coastguard Worker , m_wrapS(wrapS)
214*35238bceSAndroid Build Coastguard Worker , m_wrapT(wrapT)
215*35238bceSAndroid Build Coastguard Worker , m_format(format)
216*35238bceSAndroid Build Coastguard Worker , m_width(width)
217*35238bceSAndroid Build Coastguard Worker , m_height(height)
218*35238bceSAndroid Build Coastguard Worker , m_compareFunc(compareFunc)
219*35238bceSAndroid Build Coastguard Worker , m_renderer(context.getRenderContext(), context.getTestContext().getLog(), glu::GLSL_VERSION_300_ES,
220*35238bceSAndroid Build Coastguard Worker glu::PRECISION_HIGHP)
221*35238bceSAndroid Build Coastguard Worker , m_caseNdx(0)
222*35238bceSAndroid Build Coastguard Worker {
223*35238bceSAndroid Build Coastguard Worker }
224*35238bceSAndroid Build Coastguard Worker
~Texture2DShadowCase(void)225*35238bceSAndroid Build Coastguard Worker Texture2DShadowCase::~Texture2DShadowCase(void)
226*35238bceSAndroid Build Coastguard Worker {
227*35238bceSAndroid Build Coastguard Worker deinit();
228*35238bceSAndroid Build Coastguard Worker }
229*35238bceSAndroid Build Coastguard Worker
init(void)230*35238bceSAndroid Build Coastguard Worker void Texture2DShadowCase::init(void)
231*35238bceSAndroid Build Coastguard Worker {
232*35238bceSAndroid Build Coastguard Worker try
233*35238bceSAndroid Build Coastguard Worker {
234*35238bceSAndroid Build Coastguard Worker // Create 2 textures.
235*35238bceSAndroid Build Coastguard Worker m_textures.reserve(2);
236*35238bceSAndroid Build Coastguard Worker m_textures.push_back(new glu::Texture2D(m_context.getRenderContext(), m_format, m_width, m_height));
237*35238bceSAndroid Build Coastguard Worker m_textures.push_back(new glu::Texture2D(m_context.getRenderContext(), m_format, m_width, m_height));
238*35238bceSAndroid Build Coastguard Worker
239*35238bceSAndroid Build Coastguard Worker int numLevels = m_textures[0]->getRefTexture().getNumLevels();
240*35238bceSAndroid Build Coastguard Worker
241*35238bceSAndroid Build Coastguard Worker // Fill first gradient texture.
242*35238bceSAndroid Build Coastguard Worker for (int levelNdx = 0; levelNdx < numLevels; levelNdx++)
243*35238bceSAndroid Build Coastguard Worker {
244*35238bceSAndroid Build Coastguard Worker m_textures[0]->getRefTexture().allocLevel(levelNdx);
245*35238bceSAndroid Build Coastguard Worker tcu::fillWithComponentGradients(m_textures[0]->getRefTexture().getLevel(levelNdx),
246*35238bceSAndroid Build Coastguard Worker tcu::Vec4(-0.5f, -0.5f, -0.5f, 2.0f), tcu::Vec4(1.0f, 1.0f, 1.0f, 0.0f));
247*35238bceSAndroid Build Coastguard Worker }
248*35238bceSAndroid Build Coastguard Worker
249*35238bceSAndroid Build Coastguard Worker // Fill second with grid texture.
250*35238bceSAndroid Build Coastguard Worker for (int levelNdx = 0; levelNdx < numLevels; levelNdx++)
251*35238bceSAndroid Build Coastguard Worker {
252*35238bceSAndroid Build Coastguard Worker uint32_t step = 0x00ffffff / numLevels;
253*35238bceSAndroid Build Coastguard Worker uint32_t rgb = step * levelNdx;
254*35238bceSAndroid Build Coastguard Worker uint32_t colorA = 0xff000000 | rgb;
255*35238bceSAndroid Build Coastguard Worker uint32_t colorB = 0xff000000 | ~rgb;
256*35238bceSAndroid Build Coastguard Worker
257*35238bceSAndroid Build Coastguard Worker m_textures[1]->getRefTexture().allocLevel(levelNdx);
258*35238bceSAndroid Build Coastguard Worker tcu::fillWithGrid(m_textures[1]->getRefTexture().getLevel(levelNdx), 4, tcu::RGBA(colorA).toVec(),
259*35238bceSAndroid Build Coastguard Worker tcu::RGBA(colorB).toVec());
260*35238bceSAndroid Build Coastguard Worker }
261*35238bceSAndroid Build Coastguard Worker
262*35238bceSAndroid Build Coastguard Worker // Upload.
263*35238bceSAndroid Build Coastguard Worker for (std::vector<glu::Texture2D *>::iterator i = m_textures.begin(); i != m_textures.end(); i++)
264*35238bceSAndroid Build Coastguard Worker (*i)->upload();
265*35238bceSAndroid Build Coastguard Worker }
266*35238bceSAndroid Build Coastguard Worker catch (const std::exception &)
267*35238bceSAndroid Build Coastguard Worker {
268*35238bceSAndroid Build Coastguard Worker // Clean up to save memory.
269*35238bceSAndroid Build Coastguard Worker Texture2DShadowCase::deinit();
270*35238bceSAndroid Build Coastguard Worker throw;
271*35238bceSAndroid Build Coastguard Worker }
272*35238bceSAndroid Build Coastguard Worker
273*35238bceSAndroid Build Coastguard Worker // Compute cases.
274*35238bceSAndroid Build Coastguard Worker {
275*35238bceSAndroid Build Coastguard Worker const float refInRangeUpper = (m_compareFunc == GL_EQUAL || m_compareFunc == GL_NOTEQUAL) ? 1.0f : 0.5f;
276*35238bceSAndroid Build Coastguard Worker const float refInRangeLower = (m_compareFunc == GL_EQUAL || m_compareFunc == GL_NOTEQUAL) ? 0.0f : 0.5f;
277*35238bceSAndroid Build Coastguard Worker const float refOutOfBoundsUpper = 1.1f; // !< lookup function should clamp values to [0, 1] range
278*35238bceSAndroid Build Coastguard Worker const float refOutOfBoundsLower = -0.1f;
279*35238bceSAndroid Build Coastguard Worker
280*35238bceSAndroid Build Coastguard Worker const struct
281*35238bceSAndroid Build Coastguard Worker {
282*35238bceSAndroid Build Coastguard Worker int texNdx;
283*35238bceSAndroid Build Coastguard Worker float ref;
284*35238bceSAndroid Build Coastguard Worker float lodX;
285*35238bceSAndroid Build Coastguard Worker float lodY;
286*35238bceSAndroid Build Coastguard Worker float oX;
287*35238bceSAndroid Build Coastguard Worker float oY;
288*35238bceSAndroid Build Coastguard Worker } cases[] = {
289*35238bceSAndroid Build Coastguard Worker {0, refInRangeUpper, 1.6f, 2.9f, -1.0f, -2.7f},
290*35238bceSAndroid Build Coastguard Worker {0, refInRangeLower, -2.0f, -1.35f, -0.2f, 0.7f},
291*35238bceSAndroid Build Coastguard Worker {1, refInRangeUpper, 0.14f, 0.275f, -1.5f, -1.1f},
292*35238bceSAndroid Build Coastguard Worker {1, refInRangeLower, -0.92f, -2.64f, 0.4f, -0.1f},
293*35238bceSAndroid Build Coastguard Worker {1, refOutOfBoundsUpper, -0.39f, -0.52f, 0.65f, 0.87f},
294*35238bceSAndroid Build Coastguard Worker {1, refOutOfBoundsLower, -1.55f, 0.65f, 0.35f, 0.91f},
295*35238bceSAndroid Build Coastguard Worker };
296*35238bceSAndroid Build Coastguard Worker
297*35238bceSAndroid Build Coastguard Worker const float viewportW = (float)de::min<int>(TEX2D_VIEWPORT_WIDTH, m_context.getRenderTarget().getWidth());
298*35238bceSAndroid Build Coastguard Worker const float viewportH = (float)de::min<int>(TEX2D_VIEWPORT_HEIGHT, m_context.getRenderTarget().getHeight());
299*35238bceSAndroid Build Coastguard Worker
300*35238bceSAndroid Build Coastguard Worker for (int caseNdx = 0; caseNdx < DE_LENGTH_OF_ARRAY(cases); caseNdx++)
301*35238bceSAndroid Build Coastguard Worker {
302*35238bceSAndroid Build Coastguard Worker const int texNdx = de::clamp(cases[caseNdx].texNdx, 0, (int)m_textures.size() - 1);
303*35238bceSAndroid Build Coastguard Worker const float ref = cases[caseNdx].ref;
304*35238bceSAndroid Build Coastguard Worker const float lodX = cases[caseNdx].lodX;
305*35238bceSAndroid Build Coastguard Worker const float lodY = cases[caseNdx].lodY;
306*35238bceSAndroid Build Coastguard Worker const float oX = cases[caseNdx].oX;
307*35238bceSAndroid Build Coastguard Worker const float oY = cases[caseNdx].oY;
308*35238bceSAndroid Build Coastguard Worker const float sX = deFloatExp2(lodX) * viewportW / float(m_textures[texNdx]->getRefTexture().getWidth());
309*35238bceSAndroid Build Coastguard Worker const float sY = deFloatExp2(lodY) * viewportH / float(m_textures[texNdx]->getRefTexture().getHeight());
310*35238bceSAndroid Build Coastguard Worker
311*35238bceSAndroid Build Coastguard Worker m_cases.push_back(FilterCase(m_textures[texNdx], ref, tcu::Vec2(oX, oY), tcu::Vec2(oX + sX, oY + sY)));
312*35238bceSAndroid Build Coastguard Worker }
313*35238bceSAndroid Build Coastguard Worker }
314*35238bceSAndroid Build Coastguard Worker
315*35238bceSAndroid Build Coastguard Worker m_caseNdx = 0;
316*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
317*35238bceSAndroid Build Coastguard Worker }
318*35238bceSAndroid Build Coastguard Worker
deinit(void)319*35238bceSAndroid Build Coastguard Worker void Texture2DShadowCase::deinit(void)
320*35238bceSAndroid Build Coastguard Worker {
321*35238bceSAndroid Build Coastguard Worker for (std::vector<glu::Texture2D *>::iterator i = m_textures.begin(); i != m_textures.end(); i++)
322*35238bceSAndroid Build Coastguard Worker delete *i;
323*35238bceSAndroid Build Coastguard Worker m_textures.clear();
324*35238bceSAndroid Build Coastguard Worker
325*35238bceSAndroid Build Coastguard Worker m_renderer.clear();
326*35238bceSAndroid Build Coastguard Worker m_cases.clear();
327*35238bceSAndroid Build Coastguard Worker }
328*35238bceSAndroid Build Coastguard Worker
iterate(void)329*35238bceSAndroid Build Coastguard Worker Texture2DShadowCase::IterateResult Texture2DShadowCase::iterate(void)
330*35238bceSAndroid Build Coastguard Worker {
331*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
332*35238bceSAndroid Build Coastguard Worker const RandomViewport viewport(m_context.getRenderTarget(), TEX2D_VIEWPORT_WIDTH, TEX2D_VIEWPORT_HEIGHT,
333*35238bceSAndroid Build Coastguard Worker deStringHash(getName()) ^ deInt32Hash(m_caseNdx));
334*35238bceSAndroid Build Coastguard Worker const FilterCase &curCase = m_cases[m_caseNdx];
335*35238bceSAndroid Build Coastguard Worker const tcu::ScopedLogSection section(m_testCtx.getLog(), string("Test") + de::toString(m_caseNdx),
336*35238bceSAndroid Build Coastguard Worker string("Test ") + de::toString(m_caseNdx));
337*35238bceSAndroid Build Coastguard Worker ReferenceParams sampleParams(TEXTURETYPE_2D);
338*35238bceSAndroid Build Coastguard Worker tcu::Surface rendered(viewport.width, viewport.height);
339*35238bceSAndroid Build Coastguard Worker vector<float> texCoord;
340*35238bceSAndroid Build Coastguard Worker
341*35238bceSAndroid Build Coastguard Worker if (viewport.width < TEX2D_MIN_VIEWPORT_WIDTH || viewport.height < TEX2D_MIN_VIEWPORT_HEIGHT)
342*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("Too small render target", "", __FILE__, __LINE__);
343*35238bceSAndroid Build Coastguard Worker
344*35238bceSAndroid Build Coastguard Worker // Setup params for reference.
345*35238bceSAndroid Build Coastguard Worker sampleParams.sampler = glu::mapGLSampler(m_wrapS, m_wrapT, m_minFilter, m_magFilter);
346*35238bceSAndroid Build Coastguard Worker sampleParams.sampler.compare = glu::mapGLCompareFunc(m_compareFunc);
347*35238bceSAndroid Build Coastguard Worker sampleParams.samplerType = SAMPLERTYPE_SHADOW;
348*35238bceSAndroid Build Coastguard Worker sampleParams.lodMode = LODMODE_EXACT;
349*35238bceSAndroid Build Coastguard Worker sampleParams.ref = curCase.ref;
350*35238bceSAndroid Build Coastguard Worker
351*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "Compare reference value = " << sampleParams.ref << TestLog::EndMessage;
352*35238bceSAndroid Build Coastguard Worker
353*35238bceSAndroid Build Coastguard Worker // Compute texture coordinates.
354*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "Texture coordinates: " << curCase.minCoord << " -> " << curCase.maxCoord
355*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
356*35238bceSAndroid Build Coastguard Worker computeQuadTexCoord2D(texCoord, curCase.minCoord, curCase.maxCoord);
357*35238bceSAndroid Build Coastguard Worker
358*35238bceSAndroid Build Coastguard Worker gl.bindTexture(GL_TEXTURE_2D, curCase.texture->getGLTexture());
359*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, m_minFilter);
360*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, m_magFilter);
361*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, m_wrapS);
362*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, m_wrapT);
363*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
364*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, m_compareFunc);
365*35238bceSAndroid Build Coastguard Worker
366*35238bceSAndroid Build Coastguard Worker gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);
367*35238bceSAndroid Build Coastguard Worker m_renderer.renderQuad(0, &texCoord[0], sampleParams);
368*35238bceSAndroid Build Coastguard Worker glu::readPixels(m_context.getRenderContext(), viewport.x, viewport.y, rendered.getAccess());
369*35238bceSAndroid Build Coastguard Worker
370*35238bceSAndroid Build Coastguard Worker {
371*35238bceSAndroid Build Coastguard Worker const tcu::PixelFormat pixelFormat = m_context.getRenderTarget().getPixelFormat();
372*35238bceSAndroid Build Coastguard Worker tcu::LodPrecision lodPrecision;
373*35238bceSAndroid Build Coastguard Worker tcu::TexComparePrecision texComparePrecision;
374*35238bceSAndroid Build Coastguard Worker
375*35238bceSAndroid Build Coastguard Worker lodPrecision.derivateBits = 18;
376*35238bceSAndroid Build Coastguard Worker lodPrecision.lodBits = 6;
377*35238bceSAndroid Build Coastguard Worker texComparePrecision.coordBits = tcu::IVec3(20, 20, 0);
378*35238bceSAndroid Build Coastguard Worker texComparePrecision.uvwBits = tcu::IVec3(7, 7, 0);
379*35238bceSAndroid Build Coastguard Worker texComparePrecision.pcfBits = 5;
380*35238bceSAndroid Build Coastguard Worker texComparePrecision.referenceBits = 16;
381*35238bceSAndroid Build Coastguard Worker texComparePrecision.resultBits = pixelFormat.redBits - 1;
382*35238bceSAndroid Build Coastguard Worker
383*35238bceSAndroid Build Coastguard Worker const bool isHighQuality =
384*35238bceSAndroid Build Coastguard Worker verifyTexCompareResult(m_testCtx, rendered.getAccess(), curCase.texture->getRefTexture(), &texCoord[0],
385*35238bceSAndroid Build Coastguard Worker sampleParams, texComparePrecision, lodPrecision, pixelFormat);
386*35238bceSAndroid Build Coastguard Worker
387*35238bceSAndroid Build Coastguard Worker if (!isHighQuality)
388*35238bceSAndroid Build Coastguard Worker {
389*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message
390*35238bceSAndroid Build Coastguard Worker << "Warning: Verification assuming high-quality PCF filtering failed."
391*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
392*35238bceSAndroid Build Coastguard Worker
393*35238bceSAndroid Build Coastguard Worker lodPrecision.lodBits = 4;
394*35238bceSAndroid Build Coastguard Worker texComparePrecision.uvwBits = tcu::IVec3(4, 4, 0);
395*35238bceSAndroid Build Coastguard Worker texComparePrecision.pcfBits = 0;
396*35238bceSAndroid Build Coastguard Worker
397*35238bceSAndroid Build Coastguard Worker const bool isOk =
398*35238bceSAndroid Build Coastguard Worker verifyTexCompareResult(m_testCtx, rendered.getAccess(), curCase.texture->getRefTexture(), &texCoord[0],
399*35238bceSAndroid Build Coastguard Worker sampleParams, texComparePrecision, lodPrecision, pixelFormat);
400*35238bceSAndroid Build Coastguard Worker
401*35238bceSAndroid Build Coastguard Worker if (!isOk)
402*35238bceSAndroid Build Coastguard Worker {
403*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog()
404*35238bceSAndroid Build Coastguard Worker << TestLog::Message
405*35238bceSAndroid Build Coastguard Worker << "ERROR: Verification against low precision requirements failed, failing test case."
406*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
407*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Image verification failed");
408*35238bceSAndroid Build Coastguard Worker }
409*35238bceSAndroid Build Coastguard Worker else if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
410*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_QUALITY_WARNING, "Low-quality result");
411*35238bceSAndroid Build Coastguard Worker }
412*35238bceSAndroid Build Coastguard Worker }
413*35238bceSAndroid Build Coastguard Worker
414*35238bceSAndroid Build Coastguard Worker m_caseNdx += 1;
415*35238bceSAndroid Build Coastguard Worker return m_caseNdx < (int)m_cases.size() ? CONTINUE : STOP;
416*35238bceSAndroid Build Coastguard Worker }
417*35238bceSAndroid Build Coastguard Worker
418*35238bceSAndroid Build Coastguard Worker class TextureCubeShadowCase : public TestCase
419*35238bceSAndroid Build Coastguard Worker {
420*35238bceSAndroid Build Coastguard Worker public:
421*35238bceSAndroid Build Coastguard Worker TextureCubeShadowCase(Context &context, const char *name, const char *desc, uint32_t minFilter, uint32_t magFilter,
422*35238bceSAndroid Build Coastguard Worker uint32_t wrapS, uint32_t wrapT, uint32_t format, int size, uint32_t compareFunc);
423*35238bceSAndroid Build Coastguard Worker ~TextureCubeShadowCase(void);
424*35238bceSAndroid Build Coastguard Worker
425*35238bceSAndroid Build Coastguard Worker void init(void);
426*35238bceSAndroid Build Coastguard Worker void deinit(void);
427*35238bceSAndroid Build Coastguard Worker IterateResult iterate(void);
428*35238bceSAndroid Build Coastguard Worker
429*35238bceSAndroid Build Coastguard Worker private:
430*35238bceSAndroid Build Coastguard Worker TextureCubeShadowCase(const TextureCubeShadowCase &other);
431*35238bceSAndroid Build Coastguard Worker TextureCubeShadowCase &operator=(const TextureCubeShadowCase &other);
432*35238bceSAndroid Build Coastguard Worker
433*35238bceSAndroid Build Coastguard Worker const uint32_t m_minFilter;
434*35238bceSAndroid Build Coastguard Worker const uint32_t m_magFilter;
435*35238bceSAndroid Build Coastguard Worker const uint32_t m_wrapS;
436*35238bceSAndroid Build Coastguard Worker const uint32_t m_wrapT;
437*35238bceSAndroid Build Coastguard Worker
438*35238bceSAndroid Build Coastguard Worker const uint32_t m_format;
439*35238bceSAndroid Build Coastguard Worker const int m_size;
440*35238bceSAndroid Build Coastguard Worker
441*35238bceSAndroid Build Coastguard Worker const uint32_t m_compareFunc;
442*35238bceSAndroid Build Coastguard Worker
443*35238bceSAndroid Build Coastguard Worker struct FilterCase
444*35238bceSAndroid Build Coastguard Worker {
445*35238bceSAndroid Build Coastguard Worker const glu::TextureCube *texture;
446*35238bceSAndroid Build Coastguard Worker tcu::Vec2 bottomLeft;
447*35238bceSAndroid Build Coastguard Worker tcu::Vec2 topRight;
448*35238bceSAndroid Build Coastguard Worker float ref;
449*35238bceSAndroid Build Coastguard Worker
FilterCasedeqp::gles3::Functional::TextureCubeShadowCase::FilterCase450*35238bceSAndroid Build Coastguard Worker FilterCase(void) : texture(DE_NULL), ref(0.0f)
451*35238bceSAndroid Build Coastguard Worker {
452*35238bceSAndroid Build Coastguard Worker }
453*35238bceSAndroid Build Coastguard Worker
FilterCasedeqp::gles3::Functional::TextureCubeShadowCase::FilterCase454*35238bceSAndroid Build Coastguard Worker FilterCase(const glu::TextureCube *tex_, const float ref_, const tcu::Vec2 &bottomLeft_,
455*35238bceSAndroid Build Coastguard Worker const tcu::Vec2 &topRight_)
456*35238bceSAndroid Build Coastguard Worker : texture(tex_)
457*35238bceSAndroid Build Coastguard Worker , bottomLeft(bottomLeft_)
458*35238bceSAndroid Build Coastguard Worker , topRight(topRight_)
459*35238bceSAndroid Build Coastguard Worker , ref(ref_)
460*35238bceSAndroid Build Coastguard Worker {
461*35238bceSAndroid Build Coastguard Worker }
462*35238bceSAndroid Build Coastguard Worker };
463*35238bceSAndroid Build Coastguard Worker
464*35238bceSAndroid Build Coastguard Worker glu::TextureCube *m_gradientTex;
465*35238bceSAndroid Build Coastguard Worker glu::TextureCube *m_gridTex;
466*35238bceSAndroid Build Coastguard Worker std::vector<FilterCase> m_cases;
467*35238bceSAndroid Build Coastguard Worker
468*35238bceSAndroid Build Coastguard Worker TextureRenderer m_renderer;
469*35238bceSAndroid Build Coastguard Worker
470*35238bceSAndroid Build Coastguard Worker int m_caseNdx;
471*35238bceSAndroid Build Coastguard Worker };
472*35238bceSAndroid Build Coastguard Worker
TextureCubeShadowCase(Context & context,const char * name,const char * desc,uint32_t minFilter,uint32_t magFilter,uint32_t wrapS,uint32_t wrapT,uint32_t format,int size,uint32_t compareFunc)473*35238bceSAndroid Build Coastguard Worker TextureCubeShadowCase::TextureCubeShadowCase(Context &context, const char *name, const char *desc, uint32_t minFilter,
474*35238bceSAndroid Build Coastguard Worker uint32_t magFilter, uint32_t wrapS, uint32_t wrapT, uint32_t format,
475*35238bceSAndroid Build Coastguard Worker int size, uint32_t compareFunc)
476*35238bceSAndroid Build Coastguard Worker : TestCase(context, name, desc)
477*35238bceSAndroid Build Coastguard Worker , m_minFilter(minFilter)
478*35238bceSAndroid Build Coastguard Worker , m_magFilter(magFilter)
479*35238bceSAndroid Build Coastguard Worker , m_wrapS(wrapS)
480*35238bceSAndroid Build Coastguard Worker , m_wrapT(wrapT)
481*35238bceSAndroid Build Coastguard Worker , m_format(format)
482*35238bceSAndroid Build Coastguard Worker , m_size(size)
483*35238bceSAndroid Build Coastguard Worker , m_compareFunc(compareFunc)
484*35238bceSAndroid Build Coastguard Worker , m_gradientTex(DE_NULL)
485*35238bceSAndroid Build Coastguard Worker , m_gridTex(DE_NULL)
486*35238bceSAndroid Build Coastguard Worker , m_renderer(context.getRenderContext(), context.getTestContext().getLog(), glu::GLSL_VERSION_300_ES,
487*35238bceSAndroid Build Coastguard Worker glu::PRECISION_HIGHP)
488*35238bceSAndroid Build Coastguard Worker , m_caseNdx(0)
489*35238bceSAndroid Build Coastguard Worker {
490*35238bceSAndroid Build Coastguard Worker }
491*35238bceSAndroid Build Coastguard Worker
~TextureCubeShadowCase(void)492*35238bceSAndroid Build Coastguard Worker TextureCubeShadowCase::~TextureCubeShadowCase(void)
493*35238bceSAndroid Build Coastguard Worker {
494*35238bceSAndroid Build Coastguard Worker TextureCubeShadowCase::deinit();
495*35238bceSAndroid Build Coastguard Worker }
496*35238bceSAndroid Build Coastguard Worker
init(void)497*35238bceSAndroid Build Coastguard Worker void TextureCubeShadowCase::init(void)
498*35238bceSAndroid Build Coastguard Worker {
499*35238bceSAndroid Build Coastguard Worker try
500*35238bceSAndroid Build Coastguard Worker {
501*35238bceSAndroid Build Coastguard Worker DE_ASSERT(!m_gradientTex && !m_gridTex);
502*35238bceSAndroid Build Coastguard Worker
503*35238bceSAndroid Build Coastguard Worker int numLevels = deLog2Floor32(m_size) + 1;
504*35238bceSAndroid Build Coastguard Worker tcu::TextureFormat texFmt = glu::mapGLInternalFormat(m_format);
505*35238bceSAndroid Build Coastguard Worker tcu::TextureFormatInfo fmtInfo = tcu::getTextureFormatInfo(texFmt);
506*35238bceSAndroid Build Coastguard Worker tcu::Vec4 cBias = fmtInfo.valueMin;
507*35238bceSAndroid Build Coastguard Worker tcu::Vec4 cScale = fmtInfo.valueMax - fmtInfo.valueMin;
508*35238bceSAndroid Build Coastguard Worker
509*35238bceSAndroid Build Coastguard Worker // Create textures.
510*35238bceSAndroid Build Coastguard Worker m_gradientTex = new glu::TextureCube(m_context.getRenderContext(), m_format, m_size);
511*35238bceSAndroid Build Coastguard Worker m_gridTex = new glu::TextureCube(m_context.getRenderContext(), m_format, m_size);
512*35238bceSAndroid Build Coastguard Worker
513*35238bceSAndroid Build Coastguard Worker // Fill first with gradient texture.
514*35238bceSAndroid Build Coastguard Worker static const tcu::Vec4 gradients[tcu::CUBEFACE_LAST][2] = {
515*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-1.0f, -1.0f, -1.0f, 2.0f), tcu::Vec4(1.0f, 1.0f, 1.0f, 0.0f)}, // negative x
516*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.0f, -1.0f, -1.0f, 2.0f), tcu::Vec4(1.0f, 1.0f, 1.0f, 0.0f)}, // positive x
517*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-1.0f, 0.0f, -1.0f, 2.0f), tcu::Vec4(1.0f, 1.0f, 1.0f, 0.0f)}, // negative y
518*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-1.0f, -1.0f, 0.0f, 2.0f), tcu::Vec4(1.0f, 1.0f, 1.0f, 0.0f)}, // positive y
519*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(-1.0f, -1.0f, -1.0f, 0.0f), tcu::Vec4(1.0f, 1.0f, 1.0f, 1.0f)}, // negative z
520*35238bceSAndroid Build Coastguard Worker {tcu::Vec4(0.0f, 0.0f, 0.0f, 2.0f), tcu::Vec4(1.0f, 1.0f, 1.0f, 0.0f)} // positive z
521*35238bceSAndroid Build Coastguard Worker };
522*35238bceSAndroid Build Coastguard Worker for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
523*35238bceSAndroid Build Coastguard Worker {
524*35238bceSAndroid Build Coastguard Worker for (int levelNdx = 0; levelNdx < numLevels; levelNdx++)
525*35238bceSAndroid Build Coastguard Worker {
526*35238bceSAndroid Build Coastguard Worker m_gradientTex->getRefTexture().allocLevel((tcu::CubeFace)face, levelNdx);
527*35238bceSAndroid Build Coastguard Worker tcu::fillWithComponentGradients(
528*35238bceSAndroid Build Coastguard Worker m_gradientTex->getRefTexture().getLevelFace(levelNdx, (tcu::CubeFace)face),
529*35238bceSAndroid Build Coastguard Worker gradients[face][0] * cScale + cBias, gradients[face][1] * cScale + cBias);
530*35238bceSAndroid Build Coastguard Worker }
531*35238bceSAndroid Build Coastguard Worker }
532*35238bceSAndroid Build Coastguard Worker
533*35238bceSAndroid Build Coastguard Worker // Fill second with grid texture.
534*35238bceSAndroid Build Coastguard Worker for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
535*35238bceSAndroid Build Coastguard Worker {
536*35238bceSAndroid Build Coastguard Worker for (int levelNdx = 0; levelNdx < numLevels; levelNdx++)
537*35238bceSAndroid Build Coastguard Worker {
538*35238bceSAndroid Build Coastguard Worker uint32_t step = 0x00ffffff / (numLevels * tcu::CUBEFACE_LAST);
539*35238bceSAndroid Build Coastguard Worker uint32_t rgb = step * levelNdx * face;
540*35238bceSAndroid Build Coastguard Worker uint32_t colorA = 0xff000000 | rgb;
541*35238bceSAndroid Build Coastguard Worker uint32_t colorB = 0xff000000 | ~rgb;
542*35238bceSAndroid Build Coastguard Worker
543*35238bceSAndroid Build Coastguard Worker m_gridTex->getRefTexture().allocLevel((tcu::CubeFace)face, levelNdx);
544*35238bceSAndroid Build Coastguard Worker tcu::fillWithGrid(m_gridTex->getRefTexture().getLevelFace(levelNdx, (tcu::CubeFace)face), 4,
545*35238bceSAndroid Build Coastguard Worker tcu::RGBA(colorA).toVec() * cScale + cBias,
546*35238bceSAndroid Build Coastguard Worker tcu::RGBA(colorB).toVec() * cScale + cBias);
547*35238bceSAndroid Build Coastguard Worker }
548*35238bceSAndroid Build Coastguard Worker }
549*35238bceSAndroid Build Coastguard Worker
550*35238bceSAndroid Build Coastguard Worker // Upload.
551*35238bceSAndroid Build Coastguard Worker m_gradientTex->upload();
552*35238bceSAndroid Build Coastguard Worker m_gridTex->upload();
553*35238bceSAndroid Build Coastguard Worker }
554*35238bceSAndroid Build Coastguard Worker catch (const std::exception &)
555*35238bceSAndroid Build Coastguard Worker {
556*35238bceSAndroid Build Coastguard Worker // Clean up to save memory.
557*35238bceSAndroid Build Coastguard Worker TextureCubeShadowCase::deinit();
558*35238bceSAndroid Build Coastguard Worker throw;
559*35238bceSAndroid Build Coastguard Worker }
560*35238bceSAndroid Build Coastguard Worker
561*35238bceSAndroid Build Coastguard Worker // Compute cases
562*35238bceSAndroid Build Coastguard Worker {
563*35238bceSAndroid Build Coastguard Worker const float refInRangeUpper = (m_compareFunc == GL_EQUAL || m_compareFunc == GL_NOTEQUAL) ? 1.0f : 0.5f;
564*35238bceSAndroid Build Coastguard Worker const float refInRangeLower = (m_compareFunc == GL_EQUAL || m_compareFunc == GL_NOTEQUAL) ? 0.0f : 0.5f;
565*35238bceSAndroid Build Coastguard Worker const float refOutOfBoundsUpper = 1.1f;
566*35238bceSAndroid Build Coastguard Worker const float refOutOfBoundsLower = -0.1f;
567*35238bceSAndroid Build Coastguard Worker const bool singleSample = m_context.getRenderTarget().getNumSamples() == 0;
568*35238bceSAndroid Build Coastguard Worker
569*35238bceSAndroid Build Coastguard Worker if (singleSample)
570*35238bceSAndroid Build Coastguard Worker m_cases.push_back(FilterCase(m_gradientTex, refInRangeUpper, tcu::Vec2(-1.25f, -1.2f),
571*35238bceSAndroid Build Coastguard Worker tcu::Vec2(1.2f, 1.25f))); // minification
572*35238bceSAndroid Build Coastguard Worker else
573*35238bceSAndroid Build Coastguard Worker m_cases.push_back(FilterCase(
574*35238bceSAndroid Build Coastguard Worker m_gradientTex, refInRangeUpper, tcu::Vec2(-1.19f, -1.3f),
575*35238bceSAndroid Build Coastguard Worker tcu::Vec2(1.1f, 1.35f))); // minification - w/ tuned coordinates to avoid hitting triangle edges
576*35238bceSAndroid Build Coastguard Worker
577*35238bceSAndroid Build Coastguard Worker m_cases.push_back(FilterCase(m_gradientTex, refInRangeLower, tcu::Vec2(0.8f, 0.8f),
578*35238bceSAndroid Build Coastguard Worker tcu::Vec2(1.25f, 1.20f))); // magnification
579*35238bceSAndroid Build Coastguard Worker m_cases.push_back(
580*35238bceSAndroid Build Coastguard Worker FilterCase(m_gridTex, refInRangeUpper, tcu::Vec2(-1.19f, -1.3f), tcu::Vec2(1.1f, 1.35f))); // minification
581*35238bceSAndroid Build Coastguard Worker m_cases.push_back(
582*35238bceSAndroid Build Coastguard Worker FilterCase(m_gridTex, refInRangeLower, tcu::Vec2(-1.2f, -1.1f), tcu::Vec2(-0.8f, -0.8f))); // magnification
583*35238bceSAndroid Build Coastguard Worker m_cases.push_back(FilterCase(m_gridTex, refOutOfBoundsUpper, tcu::Vec2(-0.61f, -0.1f),
584*35238bceSAndroid Build Coastguard Worker tcu::Vec2(0.9f, 1.18f))); // reference value clamp, upper
585*35238bceSAndroid Build Coastguard Worker
586*35238bceSAndroid Build Coastguard Worker if (singleSample)
587*35238bceSAndroid Build Coastguard Worker m_cases.push_back(FilterCase(m_gridTex, refOutOfBoundsLower, tcu::Vec2(-0.75f, 1.0f),
588*35238bceSAndroid Build Coastguard Worker tcu::Vec2(0.05f, 0.75f))); // reference value clamp, lower
589*35238bceSAndroid Build Coastguard Worker else
590*35238bceSAndroid Build Coastguard Worker m_cases.push_back(FilterCase(m_gridTex, refOutOfBoundsLower, tcu::Vec2(-0.75f, 1.0f),
591*35238bceSAndroid Build Coastguard Worker tcu::Vec2(0.25f, 0.75f))); // reference value clamp, lower
592*35238bceSAndroid Build Coastguard Worker }
593*35238bceSAndroid Build Coastguard Worker
594*35238bceSAndroid Build Coastguard Worker m_caseNdx = 0;
595*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
596*35238bceSAndroid Build Coastguard Worker }
597*35238bceSAndroid Build Coastguard Worker
deinit(void)598*35238bceSAndroid Build Coastguard Worker void TextureCubeShadowCase::deinit(void)
599*35238bceSAndroid Build Coastguard Worker {
600*35238bceSAndroid Build Coastguard Worker delete m_gradientTex;
601*35238bceSAndroid Build Coastguard Worker delete m_gridTex;
602*35238bceSAndroid Build Coastguard Worker
603*35238bceSAndroid Build Coastguard Worker m_gradientTex = DE_NULL;
604*35238bceSAndroid Build Coastguard Worker m_gridTex = DE_NULL;
605*35238bceSAndroid Build Coastguard Worker
606*35238bceSAndroid Build Coastguard Worker m_renderer.clear();
607*35238bceSAndroid Build Coastguard Worker m_cases.clear();
608*35238bceSAndroid Build Coastguard Worker }
609*35238bceSAndroid Build Coastguard Worker
getFaceDesc(const tcu::CubeFace face)610*35238bceSAndroid Build Coastguard Worker static const char *getFaceDesc(const tcu::CubeFace face)
611*35238bceSAndroid Build Coastguard Worker {
612*35238bceSAndroid Build Coastguard Worker switch (face)
613*35238bceSAndroid Build Coastguard Worker {
614*35238bceSAndroid Build Coastguard Worker case tcu::CUBEFACE_NEGATIVE_X:
615*35238bceSAndroid Build Coastguard Worker return "-X";
616*35238bceSAndroid Build Coastguard Worker case tcu::CUBEFACE_POSITIVE_X:
617*35238bceSAndroid Build Coastguard Worker return "+X";
618*35238bceSAndroid Build Coastguard Worker case tcu::CUBEFACE_NEGATIVE_Y:
619*35238bceSAndroid Build Coastguard Worker return "-Y";
620*35238bceSAndroid Build Coastguard Worker case tcu::CUBEFACE_POSITIVE_Y:
621*35238bceSAndroid Build Coastguard Worker return "+Y";
622*35238bceSAndroid Build Coastguard Worker case tcu::CUBEFACE_NEGATIVE_Z:
623*35238bceSAndroid Build Coastguard Worker return "-Z";
624*35238bceSAndroid Build Coastguard Worker case tcu::CUBEFACE_POSITIVE_Z:
625*35238bceSAndroid Build Coastguard Worker return "+Z";
626*35238bceSAndroid Build Coastguard Worker default:
627*35238bceSAndroid Build Coastguard Worker DE_ASSERT(false);
628*35238bceSAndroid Build Coastguard Worker return DE_NULL;
629*35238bceSAndroid Build Coastguard Worker }
630*35238bceSAndroid Build Coastguard Worker }
631*35238bceSAndroid Build Coastguard Worker
iterate(void)632*35238bceSAndroid Build Coastguard Worker TextureCubeShadowCase::IterateResult TextureCubeShadowCase::iterate(void)
633*35238bceSAndroid Build Coastguard Worker {
634*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
635*35238bceSAndroid Build Coastguard Worker const int viewportSize = 28;
636*35238bceSAndroid Build Coastguard Worker const RandomViewport viewport(m_context.getRenderTarget(), viewportSize, viewportSize,
637*35238bceSAndroid Build Coastguard Worker deStringHash(getName()) ^ deInt32Hash(m_caseNdx));
638*35238bceSAndroid Build Coastguard Worker const tcu::ScopedLogSection iterSection(m_testCtx.getLog(), string("Test") + de::toString(m_caseNdx),
639*35238bceSAndroid Build Coastguard Worker string("Test ") + de::toString(m_caseNdx));
640*35238bceSAndroid Build Coastguard Worker const FilterCase &curCase = m_cases[m_caseNdx];
641*35238bceSAndroid Build Coastguard Worker ReferenceParams sampleParams(TEXTURETYPE_CUBE);
642*35238bceSAndroid Build Coastguard Worker
643*35238bceSAndroid Build Coastguard Worker if (viewport.width < viewportSize || viewport.height < viewportSize)
644*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("Too small render target", DE_NULL, __FILE__, __LINE__);
645*35238bceSAndroid Build Coastguard Worker
646*35238bceSAndroid Build Coastguard Worker // Setup texture
647*35238bceSAndroid Build Coastguard Worker gl.bindTexture(GL_TEXTURE_CUBE_MAP, curCase.texture->getGLTexture());
648*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, m_minFilter);
649*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, m_magFilter);
650*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, m_wrapS);
651*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, m_wrapT);
652*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
653*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_COMPARE_FUNC, m_compareFunc);
654*35238bceSAndroid Build Coastguard Worker
655*35238bceSAndroid Build Coastguard Worker // Other state
656*35238bceSAndroid Build Coastguard Worker gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);
657*35238bceSAndroid Build Coastguard Worker
658*35238bceSAndroid Build Coastguard Worker // Params for reference computation.
659*35238bceSAndroid Build Coastguard Worker sampleParams.sampler = glu::mapGLSampler(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE, m_minFilter, m_magFilter);
660*35238bceSAndroid Build Coastguard Worker sampleParams.sampler.seamlessCubeMap = true;
661*35238bceSAndroid Build Coastguard Worker sampleParams.sampler.compare = glu::mapGLCompareFunc(m_compareFunc);
662*35238bceSAndroid Build Coastguard Worker sampleParams.samplerType = SAMPLERTYPE_SHADOW;
663*35238bceSAndroid Build Coastguard Worker sampleParams.lodMode = LODMODE_EXACT;
664*35238bceSAndroid Build Coastguard Worker sampleParams.ref = curCase.ref;
665*35238bceSAndroid Build Coastguard Worker
666*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "Compare reference value = " << sampleParams.ref << "\n"
667*35238bceSAndroid Build Coastguard Worker << "Coordinates: " << curCase.bottomLeft << " -> " << curCase.topRight << TestLog::EndMessage;
668*35238bceSAndroid Build Coastguard Worker
669*35238bceSAndroid Build Coastguard Worker for (int faceNdx = 0; faceNdx < tcu::CUBEFACE_LAST; faceNdx++)
670*35238bceSAndroid Build Coastguard Worker {
671*35238bceSAndroid Build Coastguard Worker const tcu::CubeFace face = tcu::CubeFace(faceNdx);
672*35238bceSAndroid Build Coastguard Worker tcu::Surface result(viewport.width, viewport.height);
673*35238bceSAndroid Build Coastguard Worker vector<float> texCoord;
674*35238bceSAndroid Build Coastguard Worker
675*35238bceSAndroid Build Coastguard Worker computeQuadTexCoordCube(texCoord, face, curCase.bottomLeft, curCase.topRight);
676*35238bceSAndroid Build Coastguard Worker
677*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "Face " << getFaceDesc(face) << TestLog::EndMessage;
678*35238bceSAndroid Build Coastguard Worker
679*35238bceSAndroid Build Coastguard Worker // \todo Log texture coordinates.
680*35238bceSAndroid Build Coastguard Worker
681*35238bceSAndroid Build Coastguard Worker m_renderer.renderQuad(0, &texCoord[0], sampleParams);
682*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "Draw");
683*35238bceSAndroid Build Coastguard Worker
684*35238bceSAndroid Build Coastguard Worker glu::readPixels(m_context.getRenderContext(), viewport.x, viewport.y, result.getAccess());
685*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "Read pixels");
686*35238bceSAndroid Build Coastguard Worker
687*35238bceSAndroid Build Coastguard Worker {
688*35238bceSAndroid Build Coastguard Worker const tcu::PixelFormat pixelFormat = m_context.getRenderTarget().getPixelFormat();
689*35238bceSAndroid Build Coastguard Worker tcu::LodPrecision lodPrecision;
690*35238bceSAndroid Build Coastguard Worker tcu::TexComparePrecision texComparePrecision;
691*35238bceSAndroid Build Coastguard Worker
692*35238bceSAndroid Build Coastguard Worker lodPrecision.derivateBits = 10;
693*35238bceSAndroid Build Coastguard Worker lodPrecision.lodBits = 5;
694*35238bceSAndroid Build Coastguard Worker texComparePrecision.coordBits = tcu::IVec3(10, 10, 10);
695*35238bceSAndroid Build Coastguard Worker texComparePrecision.uvwBits = tcu::IVec3(6, 6, 0);
696*35238bceSAndroid Build Coastguard Worker texComparePrecision.pcfBits = 5;
697*35238bceSAndroid Build Coastguard Worker texComparePrecision.referenceBits = 16;
698*35238bceSAndroid Build Coastguard Worker texComparePrecision.resultBits = pixelFormat.redBits - 1;
699*35238bceSAndroid Build Coastguard Worker
700*35238bceSAndroid Build Coastguard Worker const bool isHighQuality =
701*35238bceSAndroid Build Coastguard Worker verifyTexCompareResult(m_testCtx, result.getAccess(), curCase.texture->getRefTexture(), &texCoord[0],
702*35238bceSAndroid Build Coastguard Worker sampleParams, texComparePrecision, lodPrecision, pixelFormat);
703*35238bceSAndroid Build Coastguard Worker
704*35238bceSAndroid Build Coastguard Worker if (!isHighQuality)
705*35238bceSAndroid Build Coastguard Worker {
706*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message
707*35238bceSAndroid Build Coastguard Worker << "Warning: Verification assuming high-quality PCF filtering failed."
708*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
709*35238bceSAndroid Build Coastguard Worker
710*35238bceSAndroid Build Coastguard Worker lodPrecision.lodBits = 4;
711*35238bceSAndroid Build Coastguard Worker texComparePrecision.uvwBits = tcu::IVec3(4, 4, 0);
712*35238bceSAndroid Build Coastguard Worker texComparePrecision.pcfBits = 0;
713*35238bceSAndroid Build Coastguard Worker
714*35238bceSAndroid Build Coastguard Worker const bool isOk =
715*35238bceSAndroid Build Coastguard Worker verifyTexCompareResult(m_testCtx, result.getAccess(), curCase.texture->getRefTexture(),
716*35238bceSAndroid Build Coastguard Worker &texCoord[0], sampleParams, texComparePrecision, lodPrecision, pixelFormat);
717*35238bceSAndroid Build Coastguard Worker
718*35238bceSAndroid Build Coastguard Worker if (!isOk)
719*35238bceSAndroid Build Coastguard Worker {
720*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog()
721*35238bceSAndroid Build Coastguard Worker << TestLog::Message
722*35238bceSAndroid Build Coastguard Worker << "ERROR: Verification against low precision requirements failed, failing test case."
723*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
724*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Image verification failed");
725*35238bceSAndroid Build Coastguard Worker }
726*35238bceSAndroid Build Coastguard Worker else if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
727*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_QUALITY_WARNING, "Low-quality result");
728*35238bceSAndroid Build Coastguard Worker }
729*35238bceSAndroid Build Coastguard Worker }
730*35238bceSAndroid Build Coastguard Worker }
731*35238bceSAndroid Build Coastguard Worker
732*35238bceSAndroid Build Coastguard Worker m_caseNdx += 1;
733*35238bceSAndroid Build Coastguard Worker return m_caseNdx < (int)m_cases.size() ? CONTINUE : STOP;
734*35238bceSAndroid Build Coastguard Worker }
735*35238bceSAndroid Build Coastguard Worker
736*35238bceSAndroid Build Coastguard Worker class Texture2DArrayShadowCase : public TestCase
737*35238bceSAndroid Build Coastguard Worker {
738*35238bceSAndroid Build Coastguard Worker public:
739*35238bceSAndroid Build Coastguard Worker Texture2DArrayShadowCase(Context &context, const char *name, const char *desc, uint32_t minFilter,
740*35238bceSAndroid Build Coastguard Worker uint32_t magFilter, uint32_t wrapS, uint32_t wrapT, uint32_t format, int width, int height,
741*35238bceSAndroid Build Coastguard Worker int numLayers, uint32_t compareFunc);
742*35238bceSAndroid Build Coastguard Worker ~Texture2DArrayShadowCase(void);
743*35238bceSAndroid Build Coastguard Worker
744*35238bceSAndroid Build Coastguard Worker void init(void);
745*35238bceSAndroid Build Coastguard Worker void deinit(void);
746*35238bceSAndroid Build Coastguard Worker IterateResult iterate(void);
747*35238bceSAndroid Build Coastguard Worker
748*35238bceSAndroid Build Coastguard Worker private:
749*35238bceSAndroid Build Coastguard Worker Texture2DArrayShadowCase(const Texture2DArrayShadowCase &other);
750*35238bceSAndroid Build Coastguard Worker Texture2DArrayShadowCase &operator=(const Texture2DArrayShadowCase &other);
751*35238bceSAndroid Build Coastguard Worker
752*35238bceSAndroid Build Coastguard Worker const uint32_t m_minFilter;
753*35238bceSAndroid Build Coastguard Worker const uint32_t m_magFilter;
754*35238bceSAndroid Build Coastguard Worker const uint32_t m_wrapS;
755*35238bceSAndroid Build Coastguard Worker const uint32_t m_wrapT;
756*35238bceSAndroid Build Coastguard Worker
757*35238bceSAndroid Build Coastguard Worker const uint32_t m_format;
758*35238bceSAndroid Build Coastguard Worker const int m_width;
759*35238bceSAndroid Build Coastguard Worker const int m_height;
760*35238bceSAndroid Build Coastguard Worker const int m_numLayers;
761*35238bceSAndroid Build Coastguard Worker
762*35238bceSAndroid Build Coastguard Worker const uint32_t m_compareFunc;
763*35238bceSAndroid Build Coastguard Worker
764*35238bceSAndroid Build Coastguard Worker struct FilterCase
765*35238bceSAndroid Build Coastguard Worker {
766*35238bceSAndroid Build Coastguard Worker const glu::Texture2DArray *texture;
767*35238bceSAndroid Build Coastguard Worker tcu::Vec3 minCoord;
768*35238bceSAndroid Build Coastguard Worker tcu::Vec3 maxCoord;
769*35238bceSAndroid Build Coastguard Worker float ref;
770*35238bceSAndroid Build Coastguard Worker
FilterCasedeqp::gles3::Functional::Texture2DArrayShadowCase::FilterCase771*35238bceSAndroid Build Coastguard Worker FilterCase(void) : texture(DE_NULL), ref(0.0f)
772*35238bceSAndroid Build Coastguard Worker {
773*35238bceSAndroid Build Coastguard Worker }
774*35238bceSAndroid Build Coastguard Worker
FilterCasedeqp::gles3::Functional::Texture2DArrayShadowCase::FilterCase775*35238bceSAndroid Build Coastguard Worker FilterCase(const glu::Texture2DArray *tex_, float ref_, const tcu::Vec3 &minCoord_, const tcu::Vec3 &maxCoord_)
776*35238bceSAndroid Build Coastguard Worker : texture(tex_)
777*35238bceSAndroid Build Coastguard Worker , minCoord(minCoord_)
778*35238bceSAndroid Build Coastguard Worker , maxCoord(maxCoord_)
779*35238bceSAndroid Build Coastguard Worker , ref(ref_)
780*35238bceSAndroid Build Coastguard Worker {
781*35238bceSAndroid Build Coastguard Worker }
782*35238bceSAndroid Build Coastguard Worker };
783*35238bceSAndroid Build Coastguard Worker
784*35238bceSAndroid Build Coastguard Worker glu::Texture2DArray *m_gradientTex;
785*35238bceSAndroid Build Coastguard Worker glu::Texture2DArray *m_gridTex;
786*35238bceSAndroid Build Coastguard Worker std::vector<FilterCase> m_cases;
787*35238bceSAndroid Build Coastguard Worker
788*35238bceSAndroid Build Coastguard Worker TextureRenderer m_renderer;
789*35238bceSAndroid Build Coastguard Worker
790*35238bceSAndroid Build Coastguard Worker int m_caseNdx;
791*35238bceSAndroid Build Coastguard Worker };
792*35238bceSAndroid Build Coastguard Worker
Texture2DArrayShadowCase(Context & context,const char * name,const char * desc,uint32_t minFilter,uint32_t magFilter,uint32_t wrapS,uint32_t wrapT,uint32_t format,int width,int height,int numLayers,uint32_t compareFunc)793*35238bceSAndroid Build Coastguard Worker Texture2DArrayShadowCase::Texture2DArrayShadowCase(Context &context, const char *name, const char *desc,
794*35238bceSAndroid Build Coastguard Worker uint32_t minFilter, uint32_t magFilter, uint32_t wrapS,
795*35238bceSAndroid Build Coastguard Worker uint32_t wrapT, uint32_t format, int width, int height,
796*35238bceSAndroid Build Coastguard Worker int numLayers, uint32_t compareFunc)
797*35238bceSAndroid Build Coastguard Worker : TestCase(context, name, desc)
798*35238bceSAndroid Build Coastguard Worker , m_minFilter(minFilter)
799*35238bceSAndroid Build Coastguard Worker , m_magFilter(magFilter)
800*35238bceSAndroid Build Coastguard Worker , m_wrapS(wrapS)
801*35238bceSAndroid Build Coastguard Worker , m_wrapT(wrapT)
802*35238bceSAndroid Build Coastguard Worker , m_format(format)
803*35238bceSAndroid Build Coastguard Worker , m_width(width)
804*35238bceSAndroid Build Coastguard Worker , m_height(height)
805*35238bceSAndroid Build Coastguard Worker , m_numLayers(numLayers)
806*35238bceSAndroid Build Coastguard Worker , m_compareFunc(compareFunc)
807*35238bceSAndroid Build Coastguard Worker , m_gradientTex(DE_NULL)
808*35238bceSAndroid Build Coastguard Worker , m_gridTex(DE_NULL)
809*35238bceSAndroid Build Coastguard Worker , m_renderer(context.getRenderContext(), context.getTestContext().getLog(), glu::GLSL_VERSION_300_ES,
810*35238bceSAndroid Build Coastguard Worker glu::PRECISION_HIGHP)
811*35238bceSAndroid Build Coastguard Worker , m_caseNdx(0)
812*35238bceSAndroid Build Coastguard Worker {
813*35238bceSAndroid Build Coastguard Worker }
814*35238bceSAndroid Build Coastguard Worker
~Texture2DArrayShadowCase(void)815*35238bceSAndroid Build Coastguard Worker Texture2DArrayShadowCase::~Texture2DArrayShadowCase(void)
816*35238bceSAndroid Build Coastguard Worker {
817*35238bceSAndroid Build Coastguard Worker Texture2DArrayShadowCase::deinit();
818*35238bceSAndroid Build Coastguard Worker }
819*35238bceSAndroid Build Coastguard Worker
init(void)820*35238bceSAndroid Build Coastguard Worker void Texture2DArrayShadowCase::init(void)
821*35238bceSAndroid Build Coastguard Worker {
822*35238bceSAndroid Build Coastguard Worker try
823*35238bceSAndroid Build Coastguard Worker {
824*35238bceSAndroid Build Coastguard Worker tcu::TextureFormat texFmt = glu::mapGLInternalFormat(m_format);
825*35238bceSAndroid Build Coastguard Worker tcu::TextureFormatInfo fmtInfo = tcu::getTextureFormatInfo(texFmt);
826*35238bceSAndroid Build Coastguard Worker tcu::Vec4 cScale = fmtInfo.valueMax - fmtInfo.valueMin;
827*35238bceSAndroid Build Coastguard Worker tcu::Vec4 cBias = fmtInfo.valueMin;
828*35238bceSAndroid Build Coastguard Worker int numLevels = deLog2Floor32(de::max(m_width, m_height)) + 1;
829*35238bceSAndroid Build Coastguard Worker
830*35238bceSAndroid Build Coastguard Worker // Create textures.
831*35238bceSAndroid Build Coastguard Worker m_gradientTex = new glu::Texture2DArray(m_context.getRenderContext(), m_format, m_width, m_height, m_numLayers);
832*35238bceSAndroid Build Coastguard Worker m_gridTex = new glu::Texture2DArray(m_context.getRenderContext(), m_format, m_width, m_height, m_numLayers);
833*35238bceSAndroid Build Coastguard Worker
834*35238bceSAndroid Build Coastguard Worker // Fill first gradient texture.
835*35238bceSAndroid Build Coastguard Worker for (int levelNdx = 0; levelNdx < numLevels; levelNdx++)
836*35238bceSAndroid Build Coastguard Worker {
837*35238bceSAndroid Build Coastguard Worker tcu::Vec4 gMin = tcu::Vec4(-0.5f, -0.5f, -0.5f, 2.0f) * cScale + cBias;
838*35238bceSAndroid Build Coastguard Worker tcu::Vec4 gMax = tcu::Vec4(1.0f, 1.0f, 1.0f, 0.0f) * cScale + cBias;
839*35238bceSAndroid Build Coastguard Worker
840*35238bceSAndroid Build Coastguard Worker m_gradientTex->getRefTexture().allocLevel(levelNdx);
841*35238bceSAndroid Build Coastguard Worker tcu::fillWithComponentGradients(m_gradientTex->getRefTexture().getLevel(levelNdx), gMin, gMax);
842*35238bceSAndroid Build Coastguard Worker }
843*35238bceSAndroid Build Coastguard Worker
844*35238bceSAndroid Build Coastguard Worker // Fill second with grid texture.
845*35238bceSAndroid Build Coastguard Worker for (int levelNdx = 0; levelNdx < numLevels; levelNdx++)
846*35238bceSAndroid Build Coastguard Worker {
847*35238bceSAndroid Build Coastguard Worker uint32_t step = 0x00ffffff / numLevels;
848*35238bceSAndroid Build Coastguard Worker uint32_t rgb = step * levelNdx;
849*35238bceSAndroid Build Coastguard Worker uint32_t colorA = 0xff000000 | rgb;
850*35238bceSAndroid Build Coastguard Worker uint32_t colorB = 0xff000000 | ~rgb;
851*35238bceSAndroid Build Coastguard Worker
852*35238bceSAndroid Build Coastguard Worker m_gridTex->getRefTexture().allocLevel(levelNdx);
853*35238bceSAndroid Build Coastguard Worker tcu::fillWithGrid(m_gridTex->getRefTexture().getLevel(levelNdx), 4,
854*35238bceSAndroid Build Coastguard Worker tcu::RGBA(colorA).toVec() * cScale + cBias, tcu::RGBA(colorB).toVec() * cScale + cBias);
855*35238bceSAndroid Build Coastguard Worker }
856*35238bceSAndroid Build Coastguard Worker
857*35238bceSAndroid Build Coastguard Worker // Upload.
858*35238bceSAndroid Build Coastguard Worker m_gradientTex->upload();
859*35238bceSAndroid Build Coastguard Worker m_gridTex->upload();
860*35238bceSAndroid Build Coastguard Worker }
861*35238bceSAndroid Build Coastguard Worker catch (...)
862*35238bceSAndroid Build Coastguard Worker {
863*35238bceSAndroid Build Coastguard Worker // Clean up to save memory.
864*35238bceSAndroid Build Coastguard Worker Texture2DArrayShadowCase::deinit();
865*35238bceSAndroid Build Coastguard Worker throw;
866*35238bceSAndroid Build Coastguard Worker }
867*35238bceSAndroid Build Coastguard Worker
868*35238bceSAndroid Build Coastguard Worker // Compute cases.
869*35238bceSAndroid Build Coastguard Worker {
870*35238bceSAndroid Build Coastguard Worker const float refInRangeUpper = (m_compareFunc == GL_EQUAL || m_compareFunc == GL_NOTEQUAL) ? 1.0f : 0.5f;
871*35238bceSAndroid Build Coastguard Worker const float refInRangeLower = (m_compareFunc == GL_EQUAL || m_compareFunc == GL_NOTEQUAL) ? 0.0f : 0.5f;
872*35238bceSAndroid Build Coastguard Worker const float refOutOfBoundsUpper = 1.1f; // !< lookup function should clamp values to [0, 1] range
873*35238bceSAndroid Build Coastguard Worker const float refOutOfBoundsLower = -0.1f;
874*35238bceSAndroid Build Coastguard Worker
875*35238bceSAndroid Build Coastguard Worker const struct
876*35238bceSAndroid Build Coastguard Worker {
877*35238bceSAndroid Build Coastguard Worker int texNdx;
878*35238bceSAndroid Build Coastguard Worker float ref;
879*35238bceSAndroid Build Coastguard Worker float lodX;
880*35238bceSAndroid Build Coastguard Worker float lodY;
881*35238bceSAndroid Build Coastguard Worker float oX;
882*35238bceSAndroid Build Coastguard Worker float oY;
883*35238bceSAndroid Build Coastguard Worker } cases[] = {
884*35238bceSAndroid Build Coastguard Worker {0, refInRangeUpper, 1.6f, 2.9f, -1.0f, -2.7f},
885*35238bceSAndroid Build Coastguard Worker {0, refInRangeLower, -2.0f, -1.35f, -0.2f, 0.7f},
886*35238bceSAndroid Build Coastguard Worker {1, refInRangeUpper, 0.14f, 0.275f, -1.5f, -1.1f},
887*35238bceSAndroid Build Coastguard Worker {1, refInRangeLower, -0.92f, -2.64f, 0.4f, -0.1f},
888*35238bceSAndroid Build Coastguard Worker {1, refOutOfBoundsUpper, -0.49f, -0.22f, 0.45f, 0.97f},
889*35238bceSAndroid Build Coastguard Worker {1, refOutOfBoundsLower, -0.85f, 0.75f, 0.25f, 0.61f},
890*35238bceSAndroid Build Coastguard Worker };
891*35238bceSAndroid Build Coastguard Worker
892*35238bceSAndroid Build Coastguard Worker const float viewportW = (float)de::min<int>(TEX2D_VIEWPORT_WIDTH, m_context.getRenderTarget().getWidth());
893*35238bceSAndroid Build Coastguard Worker const float viewportH = (float)de::min<int>(TEX2D_VIEWPORT_HEIGHT, m_context.getRenderTarget().getHeight());
894*35238bceSAndroid Build Coastguard Worker
895*35238bceSAndroid Build Coastguard Worker const float minLayer = -0.5f;
896*35238bceSAndroid Build Coastguard Worker const float maxLayer = (float)m_numLayers;
897*35238bceSAndroid Build Coastguard Worker
898*35238bceSAndroid Build Coastguard Worker for (int caseNdx = 0; caseNdx < DE_LENGTH_OF_ARRAY(cases); caseNdx++)
899*35238bceSAndroid Build Coastguard Worker {
900*35238bceSAndroid Build Coastguard Worker const glu::Texture2DArray *tex = cases[caseNdx].texNdx > 0 ? m_gridTex : m_gradientTex;
901*35238bceSAndroid Build Coastguard Worker const float ref = cases[caseNdx].ref;
902*35238bceSAndroid Build Coastguard Worker const float lodX = cases[caseNdx].lodX;
903*35238bceSAndroid Build Coastguard Worker const float lodY = cases[caseNdx].lodY;
904*35238bceSAndroid Build Coastguard Worker const float oX = cases[caseNdx].oX;
905*35238bceSAndroid Build Coastguard Worker const float oY = cases[caseNdx].oY;
906*35238bceSAndroid Build Coastguard Worker const float sX = deFloatExp2(lodX) * viewportW / float(tex->getRefTexture().getWidth());
907*35238bceSAndroid Build Coastguard Worker const float sY = deFloatExp2(lodY) * viewportH / float(tex->getRefTexture().getHeight());
908*35238bceSAndroid Build Coastguard Worker
909*35238bceSAndroid Build Coastguard Worker m_cases.push_back(FilterCase(tex, ref, tcu::Vec3(oX, oY, minLayer), tcu::Vec3(oX + sX, oY + sY, maxLayer)));
910*35238bceSAndroid Build Coastguard Worker }
911*35238bceSAndroid Build Coastguard Worker }
912*35238bceSAndroid Build Coastguard Worker
913*35238bceSAndroid Build Coastguard Worker m_caseNdx = 0;
914*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
915*35238bceSAndroid Build Coastguard Worker }
916*35238bceSAndroid Build Coastguard Worker
deinit(void)917*35238bceSAndroid Build Coastguard Worker void Texture2DArrayShadowCase::deinit(void)
918*35238bceSAndroid Build Coastguard Worker {
919*35238bceSAndroid Build Coastguard Worker delete m_gradientTex;
920*35238bceSAndroid Build Coastguard Worker delete m_gridTex;
921*35238bceSAndroid Build Coastguard Worker
922*35238bceSAndroid Build Coastguard Worker m_gradientTex = DE_NULL;
923*35238bceSAndroid Build Coastguard Worker m_gridTex = DE_NULL;
924*35238bceSAndroid Build Coastguard Worker
925*35238bceSAndroid Build Coastguard Worker m_renderer.clear();
926*35238bceSAndroid Build Coastguard Worker m_cases.clear();
927*35238bceSAndroid Build Coastguard Worker }
928*35238bceSAndroid Build Coastguard Worker
iterate(void)929*35238bceSAndroid Build Coastguard Worker Texture2DArrayShadowCase::IterateResult Texture2DArrayShadowCase::iterate(void)
930*35238bceSAndroid Build Coastguard Worker {
931*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
932*35238bceSAndroid Build Coastguard Worker const RandomViewport viewport(m_context.getRenderTarget(), TEX2D_VIEWPORT_WIDTH, TEX2D_VIEWPORT_HEIGHT,
933*35238bceSAndroid Build Coastguard Worker deStringHash(getName()) ^ deInt32Hash(m_caseNdx));
934*35238bceSAndroid Build Coastguard Worker const FilterCase &curCase = m_cases[m_caseNdx];
935*35238bceSAndroid Build Coastguard Worker const tcu::ScopedLogSection section(m_testCtx.getLog(), string("Test") + de::toString(m_caseNdx),
936*35238bceSAndroid Build Coastguard Worker string("Test ") + de::toString(m_caseNdx));
937*35238bceSAndroid Build Coastguard Worker ReferenceParams sampleParams(TEXTURETYPE_2D_ARRAY);
938*35238bceSAndroid Build Coastguard Worker tcu::Surface rendered(viewport.width, viewport.height);
939*35238bceSAndroid Build Coastguard Worker
940*35238bceSAndroid Build Coastguard Worker const float texCoord[] = {
941*35238bceSAndroid Build Coastguard Worker curCase.minCoord.x(), curCase.minCoord.y(), curCase.minCoord.z(),
942*35238bceSAndroid Build Coastguard Worker curCase.minCoord.x(), curCase.maxCoord.y(), (curCase.minCoord.z() + curCase.maxCoord.z()) / 2.0f,
943*35238bceSAndroid Build Coastguard Worker curCase.maxCoord.x(), curCase.minCoord.y(), (curCase.minCoord.z() + curCase.maxCoord.z()) / 2.0f,
944*35238bceSAndroid Build Coastguard Worker curCase.maxCoord.x(), curCase.maxCoord.y(), curCase.maxCoord.z()};
945*35238bceSAndroid Build Coastguard Worker
946*35238bceSAndroid Build Coastguard Worker if (viewport.width < TEX2D_MIN_VIEWPORT_WIDTH || viewport.height < TEX2D_MIN_VIEWPORT_HEIGHT)
947*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("Too small render target", "", __FILE__, __LINE__);
948*35238bceSAndroid Build Coastguard Worker
949*35238bceSAndroid Build Coastguard Worker // Setup params for reference.
950*35238bceSAndroid Build Coastguard Worker sampleParams.sampler = glu::mapGLSampler(m_wrapS, m_wrapT, m_minFilter, m_magFilter);
951*35238bceSAndroid Build Coastguard Worker sampleParams.sampler.compare = glu::mapGLCompareFunc(m_compareFunc);
952*35238bceSAndroid Build Coastguard Worker sampleParams.samplerType = SAMPLERTYPE_SHADOW;
953*35238bceSAndroid Build Coastguard Worker sampleParams.lodMode = LODMODE_EXACT;
954*35238bceSAndroid Build Coastguard Worker sampleParams.ref = curCase.ref;
955*35238bceSAndroid Build Coastguard Worker
956*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "Compare reference value = " << sampleParams.ref << "\n"
957*35238bceSAndroid Build Coastguard Worker << "Texture coordinates: " << curCase.minCoord << " -> " << curCase.maxCoord
958*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
959*35238bceSAndroid Build Coastguard Worker
960*35238bceSAndroid Build Coastguard Worker gl.bindTexture(GL_TEXTURE_2D_ARRAY, curCase.texture->getGLTexture());
961*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, m_minFilter);
962*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, m_magFilter);
963*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, m_wrapS);
964*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, m_wrapT);
965*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
966*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_FUNC, m_compareFunc);
967*35238bceSAndroid Build Coastguard Worker
968*35238bceSAndroid Build Coastguard Worker gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);
969*35238bceSAndroid Build Coastguard Worker m_renderer.renderQuad(0, &texCoord[0], sampleParams);
970*35238bceSAndroid Build Coastguard Worker glu::readPixels(m_context.getRenderContext(), viewport.x, viewport.y, rendered.getAccess());
971*35238bceSAndroid Build Coastguard Worker
972*35238bceSAndroid Build Coastguard Worker {
973*35238bceSAndroid Build Coastguard Worker const tcu::PixelFormat pixelFormat = m_context.getRenderTarget().getPixelFormat();
974*35238bceSAndroid Build Coastguard Worker tcu::LodPrecision lodPrecision;
975*35238bceSAndroid Build Coastguard Worker tcu::TexComparePrecision texComparePrecision;
976*35238bceSAndroid Build Coastguard Worker
977*35238bceSAndroid Build Coastguard Worker lodPrecision.derivateBits = 18;
978*35238bceSAndroid Build Coastguard Worker lodPrecision.lodBits = 6;
979*35238bceSAndroid Build Coastguard Worker texComparePrecision.coordBits = tcu::IVec3(20, 20, 20);
980*35238bceSAndroid Build Coastguard Worker texComparePrecision.uvwBits = tcu::IVec3(7, 7, 7);
981*35238bceSAndroid Build Coastguard Worker texComparePrecision.pcfBits = 5;
982*35238bceSAndroid Build Coastguard Worker texComparePrecision.referenceBits = 16;
983*35238bceSAndroid Build Coastguard Worker texComparePrecision.resultBits = pixelFormat.redBits - 1;
984*35238bceSAndroid Build Coastguard Worker
985*35238bceSAndroid Build Coastguard Worker const bool isHighQuality =
986*35238bceSAndroid Build Coastguard Worker verifyTexCompareResult(m_testCtx, rendered.getAccess(), curCase.texture->getRefTexture(), &texCoord[0],
987*35238bceSAndroid Build Coastguard Worker sampleParams, texComparePrecision, lodPrecision, pixelFormat);
988*35238bceSAndroid Build Coastguard Worker
989*35238bceSAndroid Build Coastguard Worker if (!isHighQuality)
990*35238bceSAndroid Build Coastguard Worker {
991*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message
992*35238bceSAndroid Build Coastguard Worker << "Warning: Verification assuming high-quality PCF filtering failed."
993*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
994*35238bceSAndroid Build Coastguard Worker
995*35238bceSAndroid Build Coastguard Worker lodPrecision.lodBits = 4;
996*35238bceSAndroid Build Coastguard Worker texComparePrecision.uvwBits = tcu::IVec3(4, 4, 4);
997*35238bceSAndroid Build Coastguard Worker texComparePrecision.pcfBits = 0;
998*35238bceSAndroid Build Coastguard Worker
999*35238bceSAndroid Build Coastguard Worker const bool isOk =
1000*35238bceSAndroid Build Coastguard Worker verifyTexCompareResult(m_testCtx, rendered.getAccess(), curCase.texture->getRefTexture(), &texCoord[0],
1001*35238bceSAndroid Build Coastguard Worker sampleParams, texComparePrecision, lodPrecision, pixelFormat);
1002*35238bceSAndroid Build Coastguard Worker
1003*35238bceSAndroid Build Coastguard Worker if (!isOk)
1004*35238bceSAndroid Build Coastguard Worker {
1005*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog()
1006*35238bceSAndroid Build Coastguard Worker << TestLog::Message
1007*35238bceSAndroid Build Coastguard Worker << "ERROR: Verification against low precision requirements failed, failing test case."
1008*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
1009*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Image verification failed");
1010*35238bceSAndroid Build Coastguard Worker }
1011*35238bceSAndroid Build Coastguard Worker else if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
1012*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_QUALITY_WARNING, "Low-quality result");
1013*35238bceSAndroid Build Coastguard Worker }
1014*35238bceSAndroid Build Coastguard Worker }
1015*35238bceSAndroid Build Coastguard Worker
1016*35238bceSAndroid Build Coastguard Worker m_caseNdx += 1;
1017*35238bceSAndroid Build Coastguard Worker return m_caseNdx < (int)m_cases.size() ? CONTINUE : STOP;
1018*35238bceSAndroid Build Coastguard Worker }
1019*35238bceSAndroid Build Coastguard Worker
TextureShadowTests(Context & context)1020*35238bceSAndroid Build Coastguard Worker TextureShadowTests::TextureShadowTests(Context &context)
1021*35238bceSAndroid Build Coastguard Worker : TestCaseGroup(context, "shadow", "Shadow texture lookup tests")
1022*35238bceSAndroid Build Coastguard Worker {
1023*35238bceSAndroid Build Coastguard Worker }
1024*35238bceSAndroid Build Coastguard Worker
~TextureShadowTests(void)1025*35238bceSAndroid Build Coastguard Worker TextureShadowTests::~TextureShadowTests(void)
1026*35238bceSAndroid Build Coastguard Worker {
1027*35238bceSAndroid Build Coastguard Worker }
1028*35238bceSAndroid Build Coastguard Worker
init(void)1029*35238bceSAndroid Build Coastguard Worker void TextureShadowTests::init(void)
1030*35238bceSAndroid Build Coastguard Worker {
1031*35238bceSAndroid Build Coastguard Worker static const struct
1032*35238bceSAndroid Build Coastguard Worker {
1033*35238bceSAndroid Build Coastguard Worker const char *name;
1034*35238bceSAndroid Build Coastguard Worker uint32_t format;
1035*35238bceSAndroid Build Coastguard Worker } formats[] = {{"depth_component16", GL_DEPTH_COMPONENT16},
1036*35238bceSAndroid Build Coastguard Worker {"depth_component32f", GL_DEPTH_COMPONENT32F},
1037*35238bceSAndroid Build Coastguard Worker {"depth24_stencil8", GL_DEPTH24_STENCIL8}};
1038*35238bceSAndroid Build Coastguard Worker
1039*35238bceSAndroid Build Coastguard Worker static const struct
1040*35238bceSAndroid Build Coastguard Worker {
1041*35238bceSAndroid Build Coastguard Worker const char *name;
1042*35238bceSAndroid Build Coastguard Worker uint32_t minFilter;
1043*35238bceSAndroid Build Coastguard Worker uint32_t magFilter;
1044*35238bceSAndroid Build Coastguard Worker } filters[] = {{"nearest", GL_NEAREST, GL_NEAREST},
1045*35238bceSAndroid Build Coastguard Worker {"linear", GL_LINEAR, GL_LINEAR},
1046*35238bceSAndroid Build Coastguard Worker {"nearest_mipmap_nearest", GL_NEAREST_MIPMAP_NEAREST, GL_LINEAR},
1047*35238bceSAndroid Build Coastguard Worker {"linear_mipmap_nearest", GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR},
1048*35238bceSAndroid Build Coastguard Worker {"nearest_mipmap_linear", GL_NEAREST_MIPMAP_LINEAR, GL_LINEAR},
1049*35238bceSAndroid Build Coastguard Worker {"linear_mipmap_linear", GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR}};
1050*35238bceSAndroid Build Coastguard Worker
1051*35238bceSAndroid Build Coastguard Worker static const struct
1052*35238bceSAndroid Build Coastguard Worker {
1053*35238bceSAndroid Build Coastguard Worker const char *name;
1054*35238bceSAndroid Build Coastguard Worker uint32_t func;
1055*35238bceSAndroid Build Coastguard Worker } compareFuncs[] = {
1056*35238bceSAndroid Build Coastguard Worker {"less_or_equal", GL_LEQUAL}, {"greater_or_equal", GL_GEQUAL}, {"less", GL_LESS}, {"greater", GL_GREATER},
1057*35238bceSAndroid Build Coastguard Worker {"equal", GL_EQUAL}, {"not_equal", GL_NOTEQUAL}, {"always", GL_ALWAYS}, {"never", GL_NEVER}};
1058*35238bceSAndroid Build Coastguard Worker
1059*35238bceSAndroid Build Coastguard Worker // 2D cases.
1060*35238bceSAndroid Build Coastguard Worker {
1061*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *group2D = new tcu::TestCaseGroup(m_testCtx, "2d", "2D texture shadow lookup tests");
1062*35238bceSAndroid Build Coastguard Worker addChild(group2D);
1063*35238bceSAndroid Build Coastguard Worker
1064*35238bceSAndroid Build Coastguard Worker for (int filterNdx = 0; filterNdx < DE_LENGTH_OF_ARRAY(filters); filterNdx++)
1065*35238bceSAndroid Build Coastguard Worker {
1066*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *filterGroup = new tcu::TestCaseGroup(m_testCtx, filters[filterNdx].name, "");
1067*35238bceSAndroid Build Coastguard Worker group2D->addChild(filterGroup);
1068*35238bceSAndroid Build Coastguard Worker
1069*35238bceSAndroid Build Coastguard Worker for (int compareNdx = 0; compareNdx < DE_LENGTH_OF_ARRAY(compareFuncs); compareNdx++)
1070*35238bceSAndroid Build Coastguard Worker {
1071*35238bceSAndroid Build Coastguard Worker for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(formats); formatNdx++)
1072*35238bceSAndroid Build Coastguard Worker {
1073*35238bceSAndroid Build Coastguard Worker uint32_t minFilter = filters[filterNdx].minFilter;
1074*35238bceSAndroid Build Coastguard Worker uint32_t magFilter = filters[filterNdx].magFilter;
1075*35238bceSAndroid Build Coastguard Worker uint32_t format = formats[formatNdx].format;
1076*35238bceSAndroid Build Coastguard Worker uint32_t compareFunc = compareFuncs[compareNdx].func;
1077*35238bceSAndroid Build Coastguard Worker const uint32_t wrapS = GL_REPEAT;
1078*35238bceSAndroid Build Coastguard Worker const uint32_t wrapT = GL_REPEAT;
1079*35238bceSAndroid Build Coastguard Worker const int width = 32;
1080*35238bceSAndroid Build Coastguard Worker const int height = 64;
1081*35238bceSAndroid Build Coastguard Worker string name = string(compareFuncs[compareNdx].name) + "_" + formats[formatNdx].name;
1082*35238bceSAndroid Build Coastguard Worker
1083*35238bceSAndroid Build Coastguard Worker filterGroup->addChild(new Texture2DShadowCase(m_context, name.c_str(), "", minFilter, magFilter,
1084*35238bceSAndroid Build Coastguard Worker wrapS, wrapT, format, width, height, compareFunc));
1085*35238bceSAndroid Build Coastguard Worker }
1086*35238bceSAndroid Build Coastguard Worker }
1087*35238bceSAndroid Build Coastguard Worker }
1088*35238bceSAndroid Build Coastguard Worker }
1089*35238bceSAndroid Build Coastguard Worker
1090*35238bceSAndroid Build Coastguard Worker // Cubemap cases.
1091*35238bceSAndroid Build Coastguard Worker {
1092*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *groupCube =
1093*35238bceSAndroid Build Coastguard Worker new tcu::TestCaseGroup(m_testCtx, "cube", "Cube map texture shadow lookup tests");
1094*35238bceSAndroid Build Coastguard Worker addChild(groupCube);
1095*35238bceSAndroid Build Coastguard Worker
1096*35238bceSAndroid Build Coastguard Worker for (int filterNdx = 0; filterNdx < DE_LENGTH_OF_ARRAY(filters); filterNdx++)
1097*35238bceSAndroid Build Coastguard Worker {
1098*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *filterGroup = new tcu::TestCaseGroup(m_testCtx, filters[filterNdx].name, "");
1099*35238bceSAndroid Build Coastguard Worker groupCube->addChild(filterGroup);
1100*35238bceSAndroid Build Coastguard Worker
1101*35238bceSAndroid Build Coastguard Worker for (int compareNdx = 0; compareNdx < DE_LENGTH_OF_ARRAY(compareFuncs); compareNdx++)
1102*35238bceSAndroid Build Coastguard Worker {
1103*35238bceSAndroid Build Coastguard Worker for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(formats); formatNdx++)
1104*35238bceSAndroid Build Coastguard Worker {
1105*35238bceSAndroid Build Coastguard Worker uint32_t minFilter = filters[filterNdx].minFilter;
1106*35238bceSAndroid Build Coastguard Worker uint32_t magFilter = filters[filterNdx].magFilter;
1107*35238bceSAndroid Build Coastguard Worker uint32_t format = formats[formatNdx].format;
1108*35238bceSAndroid Build Coastguard Worker uint32_t compareFunc = compareFuncs[compareNdx].func;
1109*35238bceSAndroid Build Coastguard Worker const uint32_t wrapS = GL_REPEAT;
1110*35238bceSAndroid Build Coastguard Worker const uint32_t wrapT = GL_REPEAT;
1111*35238bceSAndroid Build Coastguard Worker const int size = 32;
1112*35238bceSAndroid Build Coastguard Worker string name = string(compareFuncs[compareNdx].name) + "_" + formats[formatNdx].name;
1113*35238bceSAndroid Build Coastguard Worker
1114*35238bceSAndroid Build Coastguard Worker filterGroup->addChild(new TextureCubeShadowCase(m_context, name.c_str(), "", minFilter, magFilter,
1115*35238bceSAndroid Build Coastguard Worker wrapS, wrapT, format, size, compareFunc));
1116*35238bceSAndroid Build Coastguard Worker }
1117*35238bceSAndroid Build Coastguard Worker }
1118*35238bceSAndroid Build Coastguard Worker }
1119*35238bceSAndroid Build Coastguard Worker }
1120*35238bceSAndroid Build Coastguard Worker
1121*35238bceSAndroid Build Coastguard Worker // 2D array cases.
1122*35238bceSAndroid Build Coastguard Worker {
1123*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *group2DArray =
1124*35238bceSAndroid Build Coastguard Worker new tcu::TestCaseGroup(m_testCtx, "2d_array", "2D texture array shadow lookup tests");
1125*35238bceSAndroid Build Coastguard Worker addChild(group2DArray);
1126*35238bceSAndroid Build Coastguard Worker
1127*35238bceSAndroid Build Coastguard Worker for (int filterNdx = 0; filterNdx < DE_LENGTH_OF_ARRAY(filters); filterNdx++)
1128*35238bceSAndroid Build Coastguard Worker {
1129*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *filterGroup = new tcu::TestCaseGroup(m_testCtx, filters[filterNdx].name, "");
1130*35238bceSAndroid Build Coastguard Worker group2DArray->addChild(filterGroup);
1131*35238bceSAndroid Build Coastguard Worker
1132*35238bceSAndroid Build Coastguard Worker for (int compareNdx = 0; compareNdx < DE_LENGTH_OF_ARRAY(compareFuncs); compareNdx++)
1133*35238bceSAndroid Build Coastguard Worker {
1134*35238bceSAndroid Build Coastguard Worker for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(formats); formatNdx++)
1135*35238bceSAndroid Build Coastguard Worker {
1136*35238bceSAndroid Build Coastguard Worker uint32_t minFilter = filters[filterNdx].minFilter;
1137*35238bceSAndroid Build Coastguard Worker uint32_t magFilter = filters[filterNdx].magFilter;
1138*35238bceSAndroid Build Coastguard Worker uint32_t format = formats[formatNdx].format;
1139*35238bceSAndroid Build Coastguard Worker uint32_t compareFunc = compareFuncs[compareNdx].func;
1140*35238bceSAndroid Build Coastguard Worker const uint32_t wrapS = GL_REPEAT;
1141*35238bceSAndroid Build Coastguard Worker const uint32_t wrapT = GL_REPEAT;
1142*35238bceSAndroid Build Coastguard Worker const int width = 32;
1143*35238bceSAndroid Build Coastguard Worker const int height = 64;
1144*35238bceSAndroid Build Coastguard Worker const int numLayers = 8;
1145*35238bceSAndroid Build Coastguard Worker string name = string(compareFuncs[compareNdx].name) + "_" + formats[formatNdx].name;
1146*35238bceSAndroid Build Coastguard Worker
1147*35238bceSAndroid Build Coastguard Worker filterGroup->addChild(new Texture2DArrayShadowCase(m_context, name.c_str(), "", minFilter,
1148*35238bceSAndroid Build Coastguard Worker magFilter, wrapS, wrapT, format, width, height,
1149*35238bceSAndroid Build Coastguard Worker numLayers, compareFunc));
1150*35238bceSAndroid Build Coastguard Worker }
1151*35238bceSAndroid Build Coastguard Worker }
1152*35238bceSAndroid Build Coastguard Worker }
1153*35238bceSAndroid Build Coastguard Worker }
1154*35238bceSAndroid Build Coastguard Worker }
1155*35238bceSAndroid Build Coastguard Worker
1156*35238bceSAndroid Build Coastguard Worker } // namespace Functional
1157*35238bceSAndroid Build Coastguard Worker } // namespace gles3
1158*35238bceSAndroid Build Coastguard Worker } // namespace deqp
1159