1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker * drawElements Quality Program OpenGL ES 3.1 Module
3*35238bceSAndroid Build Coastguard Worker * -------------------------------------------------
4*35238bceSAndroid Build Coastguard Worker *
5*35238bceSAndroid Build Coastguard Worker * Copyright 2015 The Android Open Source Project
6*35238bceSAndroid Build Coastguard Worker *
7*35238bceSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
8*35238bceSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
9*35238bceSAndroid Build Coastguard Worker * You may obtain a copy of the License at
10*35238bceSAndroid Build Coastguard Worker *
11*35238bceSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0
12*35238bceSAndroid Build Coastguard Worker *
13*35238bceSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
14*35238bceSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
15*35238bceSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16*35238bceSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
17*35238bceSAndroid Build Coastguard Worker * limitations under the License.
18*35238bceSAndroid Build Coastguard Worker *
19*35238bceSAndroid Build Coastguard Worker *//*!
20*35238bceSAndroid Build Coastguard Worker * \file
21*35238bceSAndroid Build Coastguard Worker * \brief Texture border clamp tests.
22*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker
24*35238bceSAndroid Build Coastguard Worker #include "es31fTextureBorderClampTests.hpp"
25*35238bceSAndroid Build Coastguard Worker
26*35238bceSAndroid Build Coastguard Worker #include "glsTextureTestUtil.hpp"
27*35238bceSAndroid Build Coastguard Worker
28*35238bceSAndroid Build Coastguard Worker #include "tcuTextureUtil.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "tcuTexLookupVerifier.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "tcuTexCompareVerifier.hpp"
31*35238bceSAndroid Build Coastguard Worker #include "tcuCompressedTexture.hpp"
32*35238bceSAndroid Build Coastguard Worker #include "tcuResultCollector.hpp"
33*35238bceSAndroid Build Coastguard Worker #include "tcuSurface.hpp"
34*35238bceSAndroid Build Coastguard Worker #include "tcuSeedBuilder.hpp"
35*35238bceSAndroid Build Coastguard Worker #include "tcuVectorUtil.hpp"
36*35238bceSAndroid Build Coastguard Worker
37*35238bceSAndroid Build Coastguard Worker #include "rrGenericVector.hpp"
38*35238bceSAndroid Build Coastguard Worker
39*35238bceSAndroid Build Coastguard Worker #include "gluContextInfo.hpp"
40*35238bceSAndroid Build Coastguard Worker #include "gluTexture.hpp"
41*35238bceSAndroid Build Coastguard Worker #include "gluTextureUtil.hpp"
42*35238bceSAndroid Build Coastguard Worker #include "gluPixelTransfer.hpp"
43*35238bceSAndroid Build Coastguard Worker #include "gluStrUtil.hpp"
44*35238bceSAndroid Build Coastguard Worker #include "gluObjectWrapper.hpp"
45*35238bceSAndroid Build Coastguard Worker #include "gluShaderProgram.hpp"
46*35238bceSAndroid Build Coastguard Worker #include "gluDrawUtil.hpp"
47*35238bceSAndroid Build Coastguard Worker
48*35238bceSAndroid Build Coastguard Worker #include "glwEnums.hpp"
49*35238bceSAndroid Build Coastguard Worker #include "glwFunctions.hpp"
50*35238bceSAndroid Build Coastguard Worker
51*35238bceSAndroid Build Coastguard Worker #include "deStringUtil.hpp"
52*35238bceSAndroid Build Coastguard Worker #include "deUniquePtr.hpp"
53*35238bceSAndroid Build Coastguard Worker #include "deRandom.hpp"
54*35238bceSAndroid Build Coastguard Worker
55*35238bceSAndroid Build Coastguard Worker #include <limits>
56*35238bceSAndroid Build Coastguard Worker
57*35238bceSAndroid Build Coastguard Worker namespace deqp
58*35238bceSAndroid Build Coastguard Worker {
59*35238bceSAndroid Build Coastguard Worker namespace gles31
60*35238bceSAndroid Build Coastguard Worker {
61*35238bceSAndroid Build Coastguard Worker namespace Functional
62*35238bceSAndroid Build Coastguard Worker {
63*35238bceSAndroid Build Coastguard Worker namespace
64*35238bceSAndroid Build Coastguard Worker {
65*35238bceSAndroid Build Coastguard Worker
66*35238bceSAndroid Build Coastguard Worker enum SizeType
67*35238bceSAndroid Build Coastguard Worker {
68*35238bceSAndroid Build Coastguard Worker SIZE_POT = 0,
69*35238bceSAndroid Build Coastguard Worker SIZE_NPOT
70*35238bceSAndroid Build Coastguard Worker };
71*35238bceSAndroid Build Coastguard Worker
filterRequiresFilterability(uint32_t filter)72*35238bceSAndroid Build Coastguard Worker bool filterRequiresFilterability(uint32_t filter)
73*35238bceSAndroid Build Coastguard Worker {
74*35238bceSAndroid Build Coastguard Worker switch (filter)
75*35238bceSAndroid Build Coastguard Worker {
76*35238bceSAndroid Build Coastguard Worker case GL_NEAREST:
77*35238bceSAndroid Build Coastguard Worker case GL_NEAREST_MIPMAP_NEAREST:
78*35238bceSAndroid Build Coastguard Worker return false;
79*35238bceSAndroid Build Coastguard Worker
80*35238bceSAndroid Build Coastguard Worker case GL_LINEAR:
81*35238bceSAndroid Build Coastguard Worker case GL_LINEAR_MIPMAP_NEAREST:
82*35238bceSAndroid Build Coastguard Worker case GL_NEAREST_MIPMAP_LINEAR:
83*35238bceSAndroid Build Coastguard Worker case GL_LINEAR_MIPMAP_LINEAR:
84*35238bceSAndroid Build Coastguard Worker return true;
85*35238bceSAndroid Build Coastguard Worker
86*35238bceSAndroid Build Coastguard Worker default:
87*35238bceSAndroid Build Coastguard Worker DE_ASSERT(false);
88*35238bceSAndroid Build Coastguard Worker return false;
89*35238bceSAndroid Build Coastguard Worker }
90*35238bceSAndroid Build Coastguard Worker }
91*35238bceSAndroid Build Coastguard Worker
isDepthFormat(uint32_t format,tcu::Sampler::DepthStencilMode mode)92*35238bceSAndroid Build Coastguard Worker bool isDepthFormat(uint32_t format, tcu::Sampler::DepthStencilMode mode)
93*35238bceSAndroid Build Coastguard Worker {
94*35238bceSAndroid Build Coastguard Worker if (format == GL_LUMINANCE || format == GL_LUMINANCE_ALPHA || format == GL_ALPHA || format == GL_BGRA)
95*35238bceSAndroid Build Coastguard Worker {
96*35238bceSAndroid Build Coastguard Worker // Unsized formats are a special case
97*35238bceSAndroid Build Coastguard Worker return false;
98*35238bceSAndroid Build Coastguard Worker }
99*35238bceSAndroid Build Coastguard Worker else if (glu::isCompressedFormat(format))
100*35238bceSAndroid Build Coastguard Worker {
101*35238bceSAndroid Build Coastguard Worker // no known compressed depth formats
102*35238bceSAndroid Build Coastguard Worker return false;
103*35238bceSAndroid Build Coastguard Worker }
104*35238bceSAndroid Build Coastguard Worker else
105*35238bceSAndroid Build Coastguard Worker {
106*35238bceSAndroid Build Coastguard Worker const tcu::TextureFormat fmt = glu::mapGLInternalFormat(format);
107*35238bceSAndroid Build Coastguard Worker
108*35238bceSAndroid Build Coastguard Worker if (fmt.order == tcu::TextureFormat::D)
109*35238bceSAndroid Build Coastguard Worker {
110*35238bceSAndroid Build Coastguard Worker DE_ASSERT(mode == tcu::Sampler::MODE_DEPTH);
111*35238bceSAndroid Build Coastguard Worker return true;
112*35238bceSAndroid Build Coastguard Worker }
113*35238bceSAndroid Build Coastguard Worker else if (fmt.order == tcu::TextureFormat::DS && mode == tcu::Sampler::MODE_DEPTH)
114*35238bceSAndroid Build Coastguard Worker return true;
115*35238bceSAndroid Build Coastguard Worker else
116*35238bceSAndroid Build Coastguard Worker return false;
117*35238bceSAndroid Build Coastguard Worker }
118*35238bceSAndroid Build Coastguard Worker }
119*35238bceSAndroid Build Coastguard Worker
isStencilFormat(uint32_t format,tcu::Sampler::DepthStencilMode mode)120*35238bceSAndroid Build Coastguard Worker bool isStencilFormat(uint32_t format, tcu::Sampler::DepthStencilMode mode)
121*35238bceSAndroid Build Coastguard Worker {
122*35238bceSAndroid Build Coastguard Worker if (format == GL_LUMINANCE || format == GL_LUMINANCE_ALPHA || format == GL_ALPHA || format == GL_BGRA)
123*35238bceSAndroid Build Coastguard Worker {
124*35238bceSAndroid Build Coastguard Worker // Unsized formats are a special case
125*35238bceSAndroid Build Coastguard Worker return false;
126*35238bceSAndroid Build Coastguard Worker }
127*35238bceSAndroid Build Coastguard Worker else if (glu::isCompressedFormat(format))
128*35238bceSAndroid Build Coastguard Worker {
129*35238bceSAndroid Build Coastguard Worker // no known compressed stencil formats
130*35238bceSAndroid Build Coastguard Worker return false;
131*35238bceSAndroid Build Coastguard Worker }
132*35238bceSAndroid Build Coastguard Worker else
133*35238bceSAndroid Build Coastguard Worker {
134*35238bceSAndroid Build Coastguard Worker const tcu::TextureFormat fmt = glu::mapGLInternalFormat(format);
135*35238bceSAndroid Build Coastguard Worker
136*35238bceSAndroid Build Coastguard Worker if (fmt.order == tcu::TextureFormat::S)
137*35238bceSAndroid Build Coastguard Worker {
138*35238bceSAndroid Build Coastguard Worker DE_ASSERT(mode == tcu::Sampler::MODE_STENCIL);
139*35238bceSAndroid Build Coastguard Worker return true;
140*35238bceSAndroid Build Coastguard Worker }
141*35238bceSAndroid Build Coastguard Worker else if (fmt.order == tcu::TextureFormat::DS && mode == tcu::Sampler::MODE_STENCIL)
142*35238bceSAndroid Build Coastguard Worker return true;
143*35238bceSAndroid Build Coastguard Worker else
144*35238bceSAndroid Build Coastguard Worker return false;
145*35238bceSAndroid Build Coastguard Worker }
146*35238bceSAndroid Build Coastguard Worker }
147*35238bceSAndroid Build Coastguard Worker
getFormatChannelClass(uint32_t format,tcu::Sampler::DepthStencilMode mode)148*35238bceSAndroid Build Coastguard Worker tcu::TextureChannelClass getFormatChannelClass(uint32_t format, tcu::Sampler::DepthStencilMode mode)
149*35238bceSAndroid Build Coastguard Worker {
150*35238bceSAndroid Build Coastguard Worker if (format == GL_LUMINANCE || format == GL_LUMINANCE_ALPHA || format == GL_ALPHA || format == GL_BGRA)
151*35238bceSAndroid Build Coastguard Worker {
152*35238bceSAndroid Build Coastguard Worker // Unsized formats are a special c, use UNORM8
153*35238bceSAndroid Build Coastguard Worker return tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT;
154*35238bceSAndroid Build Coastguard Worker }
155*35238bceSAndroid Build Coastguard Worker else if (glu::isCompressedFormat(format))
156*35238bceSAndroid Build Coastguard Worker {
157*35238bceSAndroid Build Coastguard Worker const tcu::CompressedTexFormat compressedFmt = glu::mapGLCompressedTexFormat(format);
158*35238bceSAndroid Build Coastguard Worker const tcu::TextureFormat uncompressedFmt = tcu::getUncompressedFormat(compressedFmt);
159*35238bceSAndroid Build Coastguard Worker return tcu::getTextureChannelClass(uncompressedFmt.type);
160*35238bceSAndroid Build Coastguard Worker }
161*35238bceSAndroid Build Coastguard Worker else
162*35238bceSAndroid Build Coastguard Worker {
163*35238bceSAndroid Build Coastguard Worker const tcu::TextureFormat fmt = glu::mapGLInternalFormat(format);
164*35238bceSAndroid Build Coastguard Worker const tcu::TextureFormat effectiveFmt = tcu::getEffectiveDepthStencilTextureFormat(fmt, mode);
165*35238bceSAndroid Build Coastguard Worker
166*35238bceSAndroid Build Coastguard Worker return tcu::getTextureChannelClass(effectiveFmt.type);
167*35238bceSAndroid Build Coastguard Worker }
168*35238bceSAndroid Build Coastguard Worker }
169*35238bceSAndroid Build Coastguard Worker
getDimensionNumBlocks(int dimensionSize,int blockSize)170*35238bceSAndroid Build Coastguard Worker int getDimensionNumBlocks(int dimensionSize, int blockSize)
171*35238bceSAndroid Build Coastguard Worker {
172*35238bceSAndroid Build Coastguard Worker // ceil( a / b )
173*35238bceSAndroid Build Coastguard Worker return (dimensionSize + blockSize - 1) / blockSize;
174*35238bceSAndroid Build Coastguard Worker }
175*35238bceSAndroid Build Coastguard Worker
generateDefaultCompressedData(tcu::CompressedTexture & dst,const tcu::CompressedTexFormat & format)176*35238bceSAndroid Build Coastguard Worker void generateDefaultCompressedData(tcu::CompressedTexture &dst, const tcu::CompressedTexFormat &format)
177*35238bceSAndroid Build Coastguard Worker {
178*35238bceSAndroid Build Coastguard Worker const int blockByteSize = tcu::getBlockSize(format);
179*35238bceSAndroid Build Coastguard Worker const tcu::IVec3 blockPixelSize = tcu::getBlockPixelSize(format);
180*35238bceSAndroid Build Coastguard Worker const tcu::IVec3 numBlocks(getDimensionNumBlocks(dst.getWidth(), blockPixelSize.x()),
181*35238bceSAndroid Build Coastguard Worker getDimensionNumBlocks(dst.getHeight(), blockPixelSize.y()),
182*35238bceSAndroid Build Coastguard Worker getDimensionNumBlocks(dst.getDepth(), blockPixelSize.z()));
183*35238bceSAndroid Build Coastguard Worker const int numTotalBlocks = numBlocks.x() * numBlocks.y() * numBlocks.z();
184*35238bceSAndroid Build Coastguard Worker const int dataSize = numTotalBlocks * blockByteSize;
185*35238bceSAndroid Build Coastguard Worker
186*35238bceSAndroid Build Coastguard Worker DE_ASSERT(dst.getDataSize() == dataSize);
187*35238bceSAndroid Build Coastguard Worker
188*35238bceSAndroid Build Coastguard Worker if (tcu::isAstcFormat(format))
189*35238bceSAndroid Build Coastguard Worker {
190*35238bceSAndroid Build Coastguard Worker // generate data that is valid in LDR mode
191*35238bceSAndroid Build Coastguard Worker const int BLOCK_SIZE = 16;
192*35238bceSAndroid Build Coastguard Worker const uint8_t block[BLOCK_SIZE] = {252, 253, 255, 255, 255, 255, 255, 255,
193*35238bceSAndroid Build Coastguard Worker 223, 251, 28, 206, 54, 251, 160, 174};
194*35238bceSAndroid Build Coastguard Worker
195*35238bceSAndroid Build Coastguard Worker DE_ASSERT(blockByteSize == BLOCK_SIZE);
196*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < numTotalBlocks; ++ndx)
197*35238bceSAndroid Build Coastguard Worker deMemcpy((uint8_t *)dst.getData() + ndx * BLOCK_SIZE, block, BLOCK_SIZE);
198*35238bceSAndroid Build Coastguard Worker }
199*35238bceSAndroid Build Coastguard Worker else
200*35238bceSAndroid Build Coastguard Worker {
201*35238bceSAndroid Build Coastguard Worker // any data is ok
202*35238bceSAndroid Build Coastguard Worker de::Random rnd(0xabc);
203*35238bceSAndroid Build Coastguard Worker
204*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < dataSize; ++ndx)
205*35238bceSAndroid Build Coastguard Worker ((uint8_t *)dst.getData())[ndx] = rnd.getUint8();
206*35238bceSAndroid Build Coastguard Worker }
207*35238bceSAndroid Build Coastguard Worker }
208*35238bceSAndroid Build Coastguard Worker
209*35238bceSAndroid Build Coastguard Worker template <typename T>
210*35238bceSAndroid Build Coastguard Worker struct TextureTraits
211*35238bceSAndroid Build Coastguard Worker {
212*35238bceSAndroid Build Coastguard Worker };
213*35238bceSAndroid Build Coastguard Worker
214*35238bceSAndroid Build Coastguard Worker template <>
215*35238bceSAndroid Build Coastguard Worker struct TextureTraits<glu::Texture2D>
216*35238bceSAndroid Build Coastguard Worker {
217*35238bceSAndroid Build Coastguard Worker typedef tcu::IVec2 SizeType;
218*35238bceSAndroid Build Coastguard Worker
createTextureFromInternalFormatdeqp::gles31::Functional::__anon3e6ef60a0111::TextureTraits219*35238bceSAndroid Build Coastguard Worker static de::MovePtr<glu::Texture2D> createTextureFromInternalFormat(glu::RenderContext &renderCtx,
220*35238bceSAndroid Build Coastguard Worker uint32_t texFormat, const tcu::IVec2 &size)
221*35238bceSAndroid Build Coastguard Worker {
222*35238bceSAndroid Build Coastguard Worker return de::MovePtr<glu::Texture2D>(new glu::Texture2D(renderCtx, texFormat, size.x(), size.y()));
223*35238bceSAndroid Build Coastguard Worker }
224*35238bceSAndroid Build Coastguard Worker
createTextureFromFormatAndTypedeqp::gles31::Functional::__anon3e6ef60a0111::TextureTraits225*35238bceSAndroid Build Coastguard Worker static de::MovePtr<glu::Texture2D> createTextureFromFormatAndType(glu::RenderContext &renderCtx, uint32_t texFormat,
226*35238bceSAndroid Build Coastguard Worker uint32_t type, const tcu::IVec2 &size)
227*35238bceSAndroid Build Coastguard Worker {
228*35238bceSAndroid Build Coastguard Worker return de::MovePtr<glu::Texture2D>(new glu::Texture2D(renderCtx, texFormat, type, size.x(), size.y()));
229*35238bceSAndroid Build Coastguard Worker }
230*35238bceSAndroid Build Coastguard Worker
createTextureFromCompressedDatadeqp::gles31::Functional::__anon3e6ef60a0111::TextureTraits231*35238bceSAndroid Build Coastguard Worker static de::MovePtr<glu::Texture2D> createTextureFromCompressedData(
232*35238bceSAndroid Build Coastguard Worker glu::RenderContext &renderCtx, const glu::ContextInfo &ctxInfo, const tcu::CompressedTexture &compressedLevel,
233*35238bceSAndroid Build Coastguard Worker const tcu::TexDecompressionParams &decompressionParams)
234*35238bceSAndroid Build Coastguard Worker {
235*35238bceSAndroid Build Coastguard Worker return de::MovePtr<glu::Texture2D>(
236*35238bceSAndroid Build Coastguard Worker new glu::Texture2D(renderCtx, ctxInfo, 1, &compressedLevel, decompressionParams));
237*35238bceSAndroid Build Coastguard Worker }
238*35238bceSAndroid Build Coastguard Worker
getTextureNumLayersdeqp::gles31::Functional::__anon3e6ef60a0111::TextureTraits239*35238bceSAndroid Build Coastguard Worker static int getTextureNumLayers(const tcu::IVec2 &size)
240*35238bceSAndroid Build Coastguard Worker {
241*35238bceSAndroid Build Coastguard Worker // 2D textures have one layer
242*35238bceSAndroid Build Coastguard Worker DE_UNREF(size);
243*35238bceSAndroid Build Coastguard Worker return 1;
244*35238bceSAndroid Build Coastguard Worker }
245*35238bceSAndroid Build Coastguard Worker };
246*35238bceSAndroid Build Coastguard Worker
247*35238bceSAndroid Build Coastguard Worker template <>
248*35238bceSAndroid Build Coastguard Worker struct TextureTraits<glu::Texture3D>
249*35238bceSAndroid Build Coastguard Worker {
250*35238bceSAndroid Build Coastguard Worker typedef tcu::IVec3 SizeType;
251*35238bceSAndroid Build Coastguard Worker
createTextureFromInternalFormatdeqp::gles31::Functional::__anon3e6ef60a0111::TextureTraits252*35238bceSAndroid Build Coastguard Worker static de::MovePtr<glu::Texture3D> createTextureFromInternalFormat(glu::RenderContext &renderCtx,
253*35238bceSAndroid Build Coastguard Worker uint32_t texFormat, const tcu::IVec3 &size)
254*35238bceSAndroid Build Coastguard Worker {
255*35238bceSAndroid Build Coastguard Worker return de::MovePtr<glu::Texture3D>(new glu::Texture3D(renderCtx, texFormat, size.x(), size.y(), size.z()));
256*35238bceSAndroid Build Coastguard Worker }
257*35238bceSAndroid Build Coastguard Worker
createTextureFromFormatAndTypedeqp::gles31::Functional::__anon3e6ef60a0111::TextureTraits258*35238bceSAndroid Build Coastguard Worker static de::MovePtr<glu::Texture3D> createTextureFromFormatAndType(glu::RenderContext &renderCtx, uint32_t texFormat,
259*35238bceSAndroid Build Coastguard Worker uint32_t type, const tcu::IVec3 &size)
260*35238bceSAndroid Build Coastguard Worker {
261*35238bceSAndroid Build Coastguard Worker return de::MovePtr<glu::Texture3D>(
262*35238bceSAndroid Build Coastguard Worker new glu::Texture3D(renderCtx, texFormat, type, size.x(), size.y(), size.z()));
263*35238bceSAndroid Build Coastguard Worker }
264*35238bceSAndroid Build Coastguard Worker
createTextureFromCompressedDatadeqp::gles31::Functional::__anon3e6ef60a0111::TextureTraits265*35238bceSAndroid Build Coastguard Worker static de::MovePtr<glu::Texture3D> createTextureFromCompressedData(
266*35238bceSAndroid Build Coastguard Worker glu::RenderContext &renderCtx, const glu::ContextInfo &ctxInfo, const tcu::CompressedTexture &compressedLevel,
267*35238bceSAndroid Build Coastguard Worker const tcu::TexDecompressionParams &decompressionParams)
268*35238bceSAndroid Build Coastguard Worker {
269*35238bceSAndroid Build Coastguard Worker return de::MovePtr<glu::Texture3D>(
270*35238bceSAndroid Build Coastguard Worker new glu::Texture3D(renderCtx, ctxInfo, 1, &compressedLevel, decompressionParams));
271*35238bceSAndroid Build Coastguard Worker }
272*35238bceSAndroid Build Coastguard Worker
getTextureNumLayersdeqp::gles31::Functional::__anon3e6ef60a0111::TextureTraits273*35238bceSAndroid Build Coastguard Worker static int getTextureNumLayers(const tcu::IVec3 &size)
274*35238bceSAndroid Build Coastguard Worker {
275*35238bceSAndroid Build Coastguard Worker // 3D textures have Z layers
276*35238bceSAndroid Build Coastguard Worker return size.z();
277*35238bceSAndroid Build Coastguard Worker }
278*35238bceSAndroid Build Coastguard Worker };
279*35238bceSAndroid Build Coastguard Worker
280*35238bceSAndroid Build Coastguard Worker template <typename T>
genDefaultTexture(glu::RenderContext & renderCtx,const glu::ContextInfo & ctxInfo,uint32_t texFormat,const typename TextureTraits<T>::SizeType & size)281*35238bceSAndroid Build Coastguard Worker de::MovePtr<T> genDefaultTexture(glu::RenderContext &renderCtx, const glu::ContextInfo &ctxInfo, uint32_t texFormat,
282*35238bceSAndroid Build Coastguard Worker const typename TextureTraits<T>::SizeType &size)
283*35238bceSAndroid Build Coastguard Worker {
284*35238bceSAndroid Build Coastguard Worker de::MovePtr<T> texture;
285*35238bceSAndroid Build Coastguard Worker
286*35238bceSAndroid Build Coastguard Worker if (isDepthFormat(texFormat, tcu::Sampler::MODE_DEPTH) || isStencilFormat(texFormat, tcu::Sampler::MODE_STENCIL))
287*35238bceSAndroid Build Coastguard Worker {
288*35238bceSAndroid Build Coastguard Worker // fill different channels with different gradients
289*35238bceSAndroid Build Coastguard Worker texture = TextureTraits<T>::createTextureFromInternalFormat(renderCtx, texFormat, size);
290*35238bceSAndroid Build Coastguard Worker texture->getRefTexture().allocLevel(0);
291*35238bceSAndroid Build Coastguard Worker
292*35238bceSAndroid Build Coastguard Worker if (isDepthFormat(texFormat, tcu::Sampler::MODE_DEPTH))
293*35238bceSAndroid Build Coastguard Worker {
294*35238bceSAndroid Build Coastguard Worker // fill depth with 0 -> 1
295*35238bceSAndroid Build Coastguard Worker const tcu::PixelBufferAccess depthAccess =
296*35238bceSAndroid Build Coastguard Worker tcu::getEffectiveDepthStencilAccess(texture->getRefTexture().getLevel(0), tcu::Sampler::MODE_DEPTH);
297*35238bceSAndroid Build Coastguard Worker tcu::fillWithComponentGradients(depthAccess, tcu::Vec4(0.0f), tcu::Vec4(1.0f));
298*35238bceSAndroid Build Coastguard Worker }
299*35238bceSAndroid Build Coastguard Worker
300*35238bceSAndroid Build Coastguard Worker if (isStencilFormat(texFormat, tcu::Sampler::MODE_STENCIL))
301*35238bceSAndroid Build Coastguard Worker {
302*35238bceSAndroid Build Coastguard Worker // fill stencil with 0 -> max
303*35238bceSAndroid Build Coastguard Worker const tcu::PixelBufferAccess stencilAccess =
304*35238bceSAndroid Build Coastguard Worker tcu::getEffectiveDepthStencilAccess(texture->getRefTexture().getLevel(0), tcu::Sampler::MODE_STENCIL);
305*35238bceSAndroid Build Coastguard Worker const tcu::TextureFormatInfo texFormatInfo = tcu::getTextureFormatInfo(stencilAccess.getFormat());
306*35238bceSAndroid Build Coastguard Worker
307*35238bceSAndroid Build Coastguard Worker // Flip y to make stencil and depth cases not look identical
308*35238bceSAndroid Build Coastguard Worker tcu::fillWithComponentGradients(tcu::flipYAccess(stencilAccess), texFormatInfo.valueMax,
309*35238bceSAndroid Build Coastguard Worker texFormatInfo.valueMin);
310*35238bceSAndroid Build Coastguard Worker }
311*35238bceSAndroid Build Coastguard Worker
312*35238bceSAndroid Build Coastguard Worker texture->upload();
313*35238bceSAndroid Build Coastguard Worker }
314*35238bceSAndroid Build Coastguard Worker else if (!glu::isCompressedFormat(texFormat))
315*35238bceSAndroid Build Coastguard Worker {
316*35238bceSAndroid Build Coastguard Worker if (texFormat == GL_LUMINANCE || texFormat == GL_LUMINANCE_ALPHA || texFormat == GL_ALPHA ||
317*35238bceSAndroid Build Coastguard Worker texFormat == GL_BGRA)
318*35238bceSAndroid Build Coastguard Worker texture = TextureTraits<T>::createTextureFromFormatAndType(renderCtx, texFormat, GL_UNSIGNED_BYTE, size);
319*35238bceSAndroid Build Coastguard Worker else
320*35238bceSAndroid Build Coastguard Worker texture = TextureTraits<T>::createTextureFromInternalFormat(renderCtx, texFormat, size);
321*35238bceSAndroid Build Coastguard Worker
322*35238bceSAndroid Build Coastguard Worker // Fill level 0.
323*35238bceSAndroid Build Coastguard Worker texture->getRefTexture().allocLevel(0);
324*35238bceSAndroid Build Coastguard Worker
325*35238bceSAndroid Build Coastguard Worker // fill with gradient min -> max
326*35238bceSAndroid Build Coastguard Worker {
327*35238bceSAndroid Build Coastguard Worker const tcu::TextureFormatInfo texFormatInfo =
328*35238bceSAndroid Build Coastguard Worker tcu::getTextureFormatInfo(texture->getRefTexture().getFormat());
329*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 rampLow = texFormatInfo.valueMin;
330*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 rampHigh = texFormatInfo.valueMax;
331*35238bceSAndroid Build Coastguard Worker tcu::fillWithComponentGradients(texture->getRefTexture().getLevel(0), rampLow, rampHigh);
332*35238bceSAndroid Build Coastguard Worker }
333*35238bceSAndroid Build Coastguard Worker
334*35238bceSAndroid Build Coastguard Worker texture->upload();
335*35238bceSAndroid Build Coastguard Worker }
336*35238bceSAndroid Build Coastguard Worker else
337*35238bceSAndroid Build Coastguard Worker {
338*35238bceSAndroid Build Coastguard Worker const tcu::CompressedTexFormat compressedFormat = glu::mapGLCompressedTexFormat(texFormat);
339*35238bceSAndroid Build Coastguard Worker const int numLayers = TextureTraits<T>::getTextureNumLayers(size);
340*35238bceSAndroid Build Coastguard Worker tcu::CompressedTexture compressedLevel(compressedFormat, size.x(), size.y(), numLayers);
341*35238bceSAndroid Build Coastguard Worker const bool isAstcFormat = tcu::isAstcFormat(compressedFormat);
342*35238bceSAndroid Build Coastguard Worker tcu::TexDecompressionParams decompressionParams((isAstcFormat) ? (tcu::TexDecompressionParams::ASTCMODE_LDR) :
343*35238bceSAndroid Build Coastguard Worker (tcu::TexDecompressionParams::ASTCMODE_LAST));
344*35238bceSAndroid Build Coastguard Worker
345*35238bceSAndroid Build Coastguard Worker generateDefaultCompressedData(compressedLevel, compressedFormat);
346*35238bceSAndroid Build Coastguard Worker
347*35238bceSAndroid Build Coastguard Worker texture =
348*35238bceSAndroid Build Coastguard Worker TextureTraits<T>::createTextureFromCompressedData(renderCtx, ctxInfo, compressedLevel, decompressionParams);
349*35238bceSAndroid Build Coastguard Worker }
350*35238bceSAndroid Build Coastguard Worker
351*35238bceSAndroid Build Coastguard Worker return texture;
352*35238bceSAndroid Build Coastguard Worker }
353*35238bceSAndroid Build Coastguard Worker
getNBitIntegerMaxValue(bool isSigned,int numBits)354*35238bceSAndroid Build Coastguard Worker int getNBitIntegerMaxValue(bool isSigned, int numBits)
355*35238bceSAndroid Build Coastguard Worker {
356*35238bceSAndroid Build Coastguard Worker DE_ASSERT(numBits < 32);
357*35238bceSAndroid Build Coastguard Worker
358*35238bceSAndroid Build Coastguard Worker if (numBits == 0)
359*35238bceSAndroid Build Coastguard Worker return 0;
360*35238bceSAndroid Build Coastguard Worker else if (isSigned)
361*35238bceSAndroid Build Coastguard Worker return deIntMaxValue32(numBits);
362*35238bceSAndroid Build Coastguard Worker else
363*35238bceSAndroid Build Coastguard Worker return deUintMaxValue32(numBits);
364*35238bceSAndroid Build Coastguard Worker }
365*35238bceSAndroid Build Coastguard Worker
getNBitIntegerMinValue(bool isSigned,int numBits)366*35238bceSAndroid Build Coastguard Worker int getNBitIntegerMinValue(bool isSigned, int numBits)
367*35238bceSAndroid Build Coastguard Worker {
368*35238bceSAndroid Build Coastguard Worker DE_ASSERT(numBits < 32);
369*35238bceSAndroid Build Coastguard Worker
370*35238bceSAndroid Build Coastguard Worker if (numBits == 0)
371*35238bceSAndroid Build Coastguard Worker return 0;
372*35238bceSAndroid Build Coastguard Worker else if (isSigned)
373*35238bceSAndroid Build Coastguard Worker return deIntMinValue32(numBits);
374*35238bceSAndroid Build Coastguard Worker else
375*35238bceSAndroid Build Coastguard Worker return 0;
376*35238bceSAndroid Build Coastguard Worker }
377*35238bceSAndroid Build Coastguard Worker
getNBitIntegerVec4MaxValue(bool isSigned,const tcu::IVec4 & numBits)378*35238bceSAndroid Build Coastguard Worker tcu::IVec4 getNBitIntegerVec4MaxValue(bool isSigned, const tcu::IVec4 &numBits)
379*35238bceSAndroid Build Coastguard Worker {
380*35238bceSAndroid Build Coastguard Worker return tcu::IVec4(getNBitIntegerMaxValue(isSigned, numBits[0]), getNBitIntegerMaxValue(isSigned, numBits[1]),
381*35238bceSAndroid Build Coastguard Worker getNBitIntegerMaxValue(isSigned, numBits[2]), getNBitIntegerMaxValue(isSigned, numBits[3]));
382*35238bceSAndroid Build Coastguard Worker }
383*35238bceSAndroid Build Coastguard Worker
getNBitIntegerVec4MinValue(bool isSigned,const tcu::IVec4 & numBits)384*35238bceSAndroid Build Coastguard Worker tcu::IVec4 getNBitIntegerVec4MinValue(bool isSigned, const tcu::IVec4 &numBits)
385*35238bceSAndroid Build Coastguard Worker {
386*35238bceSAndroid Build Coastguard Worker return tcu::IVec4(getNBitIntegerMinValue(isSigned, numBits[0]), getNBitIntegerMinValue(isSigned, numBits[1]),
387*35238bceSAndroid Build Coastguard Worker getNBitIntegerMinValue(isSigned, numBits[2]), getNBitIntegerMinValue(isSigned, numBits[3]));
388*35238bceSAndroid Build Coastguard Worker }
389*35238bceSAndroid Build Coastguard Worker
mapToFormatColorUnits(const tcu::TextureFormat & texFormat,const tcu::Vec4 & normalizedRange)390*35238bceSAndroid Build Coastguard Worker rr::GenericVec4 mapToFormatColorUnits(const tcu::TextureFormat &texFormat, const tcu::Vec4 &normalizedRange)
391*35238bceSAndroid Build Coastguard Worker {
392*35238bceSAndroid Build Coastguard Worker const tcu::TextureFormatInfo texFormatInfo = tcu::getTextureFormatInfo(texFormat);
393*35238bceSAndroid Build Coastguard Worker
394*35238bceSAndroid Build Coastguard Worker switch (tcu::getTextureChannelClass(texFormat.type))
395*35238bceSAndroid Build Coastguard Worker {
396*35238bceSAndroid Build Coastguard Worker case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
397*35238bceSAndroid Build Coastguard Worker return rr::GenericVec4(normalizedRange);
398*35238bceSAndroid Build Coastguard Worker case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
399*35238bceSAndroid Build Coastguard Worker return rr::GenericVec4(normalizedRange * 2.0f - 1.0f);
400*35238bceSAndroid Build Coastguard Worker case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
401*35238bceSAndroid Build Coastguard Worker return rr::GenericVec4(texFormatInfo.valueMin + normalizedRange * texFormatInfo.valueMax);
402*35238bceSAndroid Build Coastguard Worker case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
403*35238bceSAndroid Build Coastguard Worker return rr::GenericVec4(
404*35238bceSAndroid Build Coastguard Worker tcu::mix(texFormatInfo.valueMin, texFormatInfo.valueMax, normalizedRange).cast<int32_t>());
405*35238bceSAndroid Build Coastguard Worker case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
406*35238bceSAndroid Build Coastguard Worker return rr::GenericVec4(
407*35238bceSAndroid Build Coastguard Worker tcu::mix(texFormatInfo.valueMin, texFormatInfo.valueMax, normalizedRange).cast<uint32_t>());
408*35238bceSAndroid Build Coastguard Worker
409*35238bceSAndroid Build Coastguard Worker default:
410*35238bceSAndroid Build Coastguard Worker DE_ASSERT(false);
411*35238bceSAndroid Build Coastguard Worker return rr::GenericVec4();
412*35238bceSAndroid Build Coastguard Worker }
413*35238bceSAndroid Build Coastguard Worker }
414*35238bceSAndroid Build Coastguard Worker
mapToFormatColorRepresentable(const tcu::TextureFormat & texFormat,const tcu::Vec4 & normalizedRange)415*35238bceSAndroid Build Coastguard Worker rr::GenericVec4 mapToFormatColorRepresentable(const tcu::TextureFormat &texFormat, const tcu::Vec4 &normalizedRange)
416*35238bceSAndroid Build Coastguard Worker {
417*35238bceSAndroid Build Coastguard Worker // make sure value is representable in the target format and clear channels
418*35238bceSAndroid Build Coastguard Worker // not present in the target format.
419*35238bceSAndroid Build Coastguard Worker
420*35238bceSAndroid Build Coastguard Worker const rr::GenericVec4 inFormatUnits = mapToFormatColorUnits(texFormat, normalizedRange);
421*35238bceSAndroid Build Coastguard Worker const tcu::BVec4 channelMask = tcu::getTextureFormatChannelMask(texFormat);
422*35238bceSAndroid Build Coastguard Worker de::ArrayBuffer<uint8_t, 4> buffer(texFormat.getPixelSize());
423*35238bceSAndroid Build Coastguard Worker tcu::PixelBufferAccess access(texFormat, tcu::IVec3(1, 1, 1), buffer.getPtr());
424*35238bceSAndroid Build Coastguard Worker
425*35238bceSAndroid Build Coastguard Worker if (tcu::isSRGB(texFormat))
426*35238bceSAndroid Build Coastguard Worker {
427*35238bceSAndroid Build Coastguard Worker DE_ASSERT(texFormat.type == tcu::TextureFormat::UNORM_INT8);
428*35238bceSAndroid Build Coastguard Worker
429*35238bceSAndroid Build Coastguard Worker // make sure border color (in linear space) can be converted to 8-bit sRGB space without
430*35238bceSAndroid Build Coastguard Worker // significant loss.
431*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 sRGB = tcu::linearToSRGB(normalizedRange);
432*35238bceSAndroid Build Coastguard Worker const tcu::IVec4 sRGB8 = tcu::IVec4(tcu::floatToU8(sRGB[0]), tcu::floatToU8(sRGB[1]), tcu::floatToU8(sRGB[2]),
433*35238bceSAndroid Build Coastguard Worker tcu::floatToU8(sRGB[3]));
434*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 linearized = tcu::sRGBToLinear(tcu::Vec4((float)sRGB8[0] / 255.0f, (float)sRGB8[1] / 255.0f,
435*35238bceSAndroid Build Coastguard Worker (float)sRGB8[2] / 255.0f, (float)sRGB8[3] / 255.0f));
436*35238bceSAndroid Build Coastguard Worker
437*35238bceSAndroid Build Coastguard Worker return rr::GenericVec4(tcu::select(linearized, tcu::Vec4(0.0f), channelMask));
438*35238bceSAndroid Build Coastguard Worker }
439*35238bceSAndroid Build Coastguard Worker
440*35238bceSAndroid Build Coastguard Worker switch (tcu::getTextureChannelClass(texFormat.type))
441*35238bceSAndroid Build Coastguard Worker {
442*35238bceSAndroid Build Coastguard Worker case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
443*35238bceSAndroid Build Coastguard Worker case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
444*35238bceSAndroid Build Coastguard Worker case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
445*35238bceSAndroid Build Coastguard Worker {
446*35238bceSAndroid Build Coastguard Worker access.setPixel(inFormatUnits.get<float>(), 0, 0);
447*35238bceSAndroid Build Coastguard Worker return rr::GenericVec4(tcu::select(access.getPixel(0, 0), tcu::Vec4(0.0f), channelMask));
448*35238bceSAndroid Build Coastguard Worker }
449*35238bceSAndroid Build Coastguard Worker case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
450*35238bceSAndroid Build Coastguard Worker {
451*35238bceSAndroid Build Coastguard Worker access.setPixel(inFormatUnits.get<int32_t>(), 0, 0);
452*35238bceSAndroid Build Coastguard Worker return rr::GenericVec4(tcu::select(access.getPixelInt(0, 0), tcu::IVec4(0), channelMask));
453*35238bceSAndroid Build Coastguard Worker }
454*35238bceSAndroid Build Coastguard Worker case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
455*35238bceSAndroid Build Coastguard Worker {
456*35238bceSAndroid Build Coastguard Worker access.setPixel(inFormatUnits.get<uint32_t>(), 0, 0);
457*35238bceSAndroid Build Coastguard Worker return rr::GenericVec4(tcu::select(access.getPixelUint(0, 0), tcu::UVec4(0u), channelMask));
458*35238bceSAndroid Build Coastguard Worker }
459*35238bceSAndroid Build Coastguard Worker default:
460*35238bceSAndroid Build Coastguard Worker {
461*35238bceSAndroid Build Coastguard Worker DE_ASSERT(false);
462*35238bceSAndroid Build Coastguard Worker return rr::GenericVec4();
463*35238bceSAndroid Build Coastguard Worker }
464*35238bceSAndroid Build Coastguard Worker }
465*35238bceSAndroid Build Coastguard Worker }
466*35238bceSAndroid Build Coastguard Worker
isCoreFilterableFormat(uint32_t format,tcu::Sampler::DepthStencilMode mode,bool is_texture_float_linear_supported=true)467*35238bceSAndroid Build Coastguard Worker bool isCoreFilterableFormat(uint32_t format, tcu::Sampler::DepthStencilMode mode,
468*35238bceSAndroid Build Coastguard Worker bool is_texture_float_linear_supported = true)
469*35238bceSAndroid Build Coastguard Worker {
470*35238bceSAndroid Build Coastguard Worker const bool isLuminanceOrAlpha = (format == GL_LUMINANCE || format == GL_ALPHA ||
471*35238bceSAndroid Build Coastguard Worker format == GL_LUMINANCE_ALPHA); // special case for luminance/alpha
472*35238bceSAndroid Build Coastguard Worker const bool isUnsizedColorFormat = (format == GL_BGRA);
473*35238bceSAndroid Build Coastguard Worker const bool isCompressed = glu::isCompressedFormat(format);
474*35238bceSAndroid Build Coastguard Worker const bool isDepth = isDepthFormat(format, mode);
475*35238bceSAndroid Build Coastguard Worker const bool isStencil = isStencilFormat(format, mode);
476*35238bceSAndroid Build Coastguard Worker const bool isFP32Format = (format == GL_RGBA32F || format == GL_RGB32F || format == GL_RG32F || format == GL_R32F);
477*35238bceSAndroid Build Coastguard Worker
478*35238bceSAndroid Build Coastguard Worker // special cases
479*35238bceSAndroid Build Coastguard Worker if (isLuminanceOrAlpha || isUnsizedColorFormat || isCompressed)
480*35238bceSAndroid Build Coastguard Worker return true;
481*35238bceSAndroid Build Coastguard Worker if (isStencil || isDepth)
482*35238bceSAndroid Build Coastguard Worker return false;
483*35238bceSAndroid Build Coastguard Worker if (isFP32Format)
484*35238bceSAndroid Build Coastguard Worker return is_texture_float_linear_supported;
485*35238bceSAndroid Build Coastguard Worker
486*35238bceSAndroid Build Coastguard Worker // color case
487*35238bceSAndroid Build Coastguard Worker return glu::isGLInternalColorFormatFilterable(format);
488*35238bceSAndroid Build Coastguard Worker }
489*35238bceSAndroid Build Coastguard Worker
490*35238bceSAndroid Build Coastguard Worker class TextureBorderClampTest : public TestCase
491*35238bceSAndroid Build Coastguard Worker {
492*35238bceSAndroid Build Coastguard Worker public:
493*35238bceSAndroid Build Coastguard Worker enum StateType
494*35238bceSAndroid Build Coastguard Worker {
495*35238bceSAndroid Build Coastguard Worker STATE_SAMPLER_PARAM = 0,
496*35238bceSAndroid Build Coastguard Worker STATE_TEXTURE_PARAM,
497*35238bceSAndroid Build Coastguard Worker
498*35238bceSAndroid Build Coastguard Worker STATE_LAST
499*35238bceSAndroid Build Coastguard Worker };
500*35238bceSAndroid Build Coastguard Worker
501*35238bceSAndroid Build Coastguard Worker enum SamplingFunction
502*35238bceSAndroid Build Coastguard Worker {
503*35238bceSAndroid Build Coastguard Worker SAMPLE_FILTER = 0,
504*35238bceSAndroid Build Coastguard Worker SAMPLE_GATHER,
505*35238bceSAndroid Build Coastguard Worker
506*35238bceSAndroid Build Coastguard Worker SAMPLE_LAST
507*35238bceSAndroid Build Coastguard Worker };
508*35238bceSAndroid Build Coastguard Worker
509*35238bceSAndroid Build Coastguard Worker enum Flag
510*35238bceSAndroid Build Coastguard Worker {
511*35238bceSAndroid Build Coastguard Worker FLAG_USE_SHADOW_SAMPLER = (1u << 0),
512*35238bceSAndroid Build Coastguard Worker FLAG_TEST_FLOAT_FILTERABLE = (1u << 1),
513*35238bceSAndroid Build Coastguard Worker };
514*35238bceSAndroid Build Coastguard Worker
515*35238bceSAndroid Build Coastguard Worker struct IterationConfig
516*35238bceSAndroid Build Coastguard Worker {
517*35238bceSAndroid Build Coastguard Worker tcu::Vec2 p0;
518*35238bceSAndroid Build Coastguard Worker tcu::Vec2 p1;
519*35238bceSAndroid Build Coastguard Worker rr::GenericVec4 borderColor;
520*35238bceSAndroid Build Coastguard Worker tcu::Vec4 lookupScale;
521*35238bceSAndroid Build Coastguard Worker tcu::Vec4 lookupBias;
522*35238bceSAndroid Build Coastguard Worker uint32_t minFilter;
523*35238bceSAndroid Build Coastguard Worker uint32_t magFilter;
524*35238bceSAndroid Build Coastguard Worker std::string description;
525*35238bceSAndroid Build Coastguard Worker uint32_t sWrapMode;
526*35238bceSAndroid Build Coastguard Worker uint32_t tWrapMode;
527*35238bceSAndroid Build Coastguard Worker uint32_t compareMode;
528*35238bceSAndroid Build Coastguard Worker float compareRef;
529*35238bceSAndroid Build Coastguard Worker };
530*35238bceSAndroid Build Coastguard Worker
531*35238bceSAndroid Build Coastguard Worker TextureBorderClampTest(Context &context, const char *name, const char *description, uint32_t texFormat,
532*35238bceSAndroid Build Coastguard Worker tcu::Sampler::DepthStencilMode mode, StateType stateType, int texWidth, int texHeight,
533*35238bceSAndroid Build Coastguard Worker SamplingFunction samplingFunction, uint32_t filter, uint32_t flags = 0);
534*35238bceSAndroid Build Coastguard Worker ~TextureBorderClampTest(void);
535*35238bceSAndroid Build Coastguard Worker
536*35238bceSAndroid Build Coastguard Worker protected:
537*35238bceSAndroid Build Coastguard Worker void init(void);
538*35238bceSAndroid Build Coastguard Worker void deinit(void);
539*35238bceSAndroid Build Coastguard Worker
540*35238bceSAndroid Build Coastguard Worker private:
541*35238bceSAndroid Build Coastguard Worker IterateResult iterate(void);
542*35238bceSAndroid Build Coastguard Worker
543*35238bceSAndroid Build Coastguard Worker void logParams(const IterationConfig &config, const glu::TextureTestUtil::ReferenceParams &samplerParams);
544*35238bceSAndroid Build Coastguard Worker
545*35238bceSAndroid Build Coastguard Worker void renderTo(tcu::Surface &surface, const IterationConfig &config,
546*35238bceSAndroid Build Coastguard Worker const glu::TextureTestUtil::ReferenceParams &samplerParams);
547*35238bceSAndroid Build Coastguard Worker void renderQuad(const float *texCoord, const glu::TextureTestUtil::ReferenceParams &samplerParams);
548*35238bceSAndroid Build Coastguard Worker
549*35238bceSAndroid Build Coastguard Worker void verifyImage(const tcu::Surface &image, const IterationConfig &config,
550*35238bceSAndroid Build Coastguard Worker const glu::TextureTestUtil::ReferenceParams &samplerParams);
551*35238bceSAndroid Build Coastguard Worker
552*35238bceSAndroid Build Coastguard Worker bool verifyTextureSampleResult(const tcu::ConstPixelBufferAccess &renderedFrame, const float *texCoord,
553*35238bceSAndroid Build Coastguard Worker const glu::TextureTestUtil::ReferenceParams &samplerParams,
554*35238bceSAndroid Build Coastguard Worker const tcu::LodPrecision &lodPrecision, const tcu::LookupPrecision &lookupPrecision);
555*35238bceSAndroid Build Coastguard Worker
556*35238bceSAndroid Build Coastguard Worker bool verifyTextureCompareResult(const tcu::ConstPixelBufferAccess &renderedFrame, const float *texCoord,
557*35238bceSAndroid Build Coastguard Worker const glu::TextureTestUtil::ReferenceParams &samplerParams,
558*35238bceSAndroid Build Coastguard Worker const tcu::TexComparePrecision &texComparePrecision,
559*35238bceSAndroid Build Coastguard Worker const tcu::TexComparePrecision &lowQualityTexComparePrecision,
560*35238bceSAndroid Build Coastguard Worker const tcu::LodPrecision &lodPrecision,
561*35238bceSAndroid Build Coastguard Worker const tcu::LodPrecision &lowQualityLodPrecision);
562*35238bceSAndroid Build Coastguard Worker
563*35238bceSAndroid Build Coastguard Worker bool verifyTextureGatherResult(const tcu::ConstPixelBufferAccess &renderedFrame, const float *texCoord,
564*35238bceSAndroid Build Coastguard Worker const glu::TextureTestUtil::ReferenceParams &samplerParams,
565*35238bceSAndroid Build Coastguard Worker const tcu::LookupPrecision &lookupPrecision);
566*35238bceSAndroid Build Coastguard Worker
567*35238bceSAndroid Build Coastguard Worker bool verifyTextureGatherCmpResult(const tcu::ConstPixelBufferAccess &renderedFrame, const float *texCoord,
568*35238bceSAndroid Build Coastguard Worker const glu::TextureTestUtil::ReferenceParams &samplerParams,
569*35238bceSAndroid Build Coastguard Worker const tcu::TexComparePrecision &texComparePrecision,
570*35238bceSAndroid Build Coastguard Worker const tcu::TexComparePrecision &lowQualityTexComparePrecision);
571*35238bceSAndroid Build Coastguard Worker
572*35238bceSAndroid Build Coastguard Worker uint32_t getIterationSeed(const IterationConfig &config) const;
573*35238bceSAndroid Build Coastguard Worker glu::TextureTestUtil::ReferenceParams genSamplerParams(const IterationConfig &config) const;
574*35238bceSAndroid Build Coastguard Worker glu::ShaderProgram *genGatherProgram(void) const;
575*35238bceSAndroid Build Coastguard Worker
576*35238bceSAndroid Build Coastguard Worker virtual int getNumIterations(void) const = 0;
577*35238bceSAndroid Build Coastguard Worker virtual IterationConfig getIteration(int ndx) const = 0;
578*35238bceSAndroid Build Coastguard Worker
579*35238bceSAndroid Build Coastguard Worker protected:
580*35238bceSAndroid Build Coastguard Worker const glu::Texture2D *getTexture(void) const;
581*35238bceSAndroid Build Coastguard Worker
582*35238bceSAndroid Build Coastguard Worker const uint32_t m_texFormat;
583*35238bceSAndroid Build Coastguard Worker const tcu::Sampler::DepthStencilMode m_sampleMode;
584*35238bceSAndroid Build Coastguard Worker const tcu::TextureChannelClass m_channelClass;
585*35238bceSAndroid Build Coastguard Worker const StateType m_stateType;
586*35238bceSAndroid Build Coastguard Worker
587*35238bceSAndroid Build Coastguard Worker const int m_texHeight;
588*35238bceSAndroid Build Coastguard Worker const int m_texWidth;
589*35238bceSAndroid Build Coastguard Worker
590*35238bceSAndroid Build Coastguard Worker const SamplingFunction m_samplingFunction;
591*35238bceSAndroid Build Coastguard Worker const bool m_useShadowSampler;
592*35238bceSAndroid Build Coastguard Worker const bool m_useFloatFilterable;
593*35238bceSAndroid Build Coastguard Worker
594*35238bceSAndroid Build Coastguard Worker const uint32_t m_filter;
595*35238bceSAndroid Build Coastguard Worker
596*35238bceSAndroid Build Coastguard Worker private:
597*35238bceSAndroid Build Coastguard Worker enum
598*35238bceSAndroid Build Coastguard Worker {
599*35238bceSAndroid Build Coastguard Worker VIEWPORT_WIDTH = 128,
600*35238bceSAndroid Build Coastguard Worker VIEWPORT_HEIGHT = 128,
601*35238bceSAndroid Build Coastguard Worker };
602*35238bceSAndroid Build Coastguard Worker
603*35238bceSAndroid Build Coastguard Worker de::MovePtr<glu::Texture2D> m_texture;
604*35238bceSAndroid Build Coastguard Worker de::MovePtr<gls::TextureTestUtil::TextureRenderer> m_renderer;
605*35238bceSAndroid Build Coastguard Worker de::MovePtr<glu::ShaderProgram> m_gatherProgram;
606*35238bceSAndroid Build Coastguard Worker
607*35238bceSAndroid Build Coastguard Worker int m_iterationNdx;
608*35238bceSAndroid Build Coastguard Worker tcu::ResultCollector m_result;
609*35238bceSAndroid Build Coastguard Worker };
610*35238bceSAndroid Build Coastguard Worker
TextureBorderClampTest(Context & context,const char * name,const char * description,uint32_t texFormat,tcu::Sampler::DepthStencilMode mode,StateType stateType,int texWidth,int texHeight,SamplingFunction samplingFunction,uint32_t filter,uint32_t flags)611*35238bceSAndroid Build Coastguard Worker TextureBorderClampTest::TextureBorderClampTest(Context &context, const char *name, const char *description,
612*35238bceSAndroid Build Coastguard Worker uint32_t texFormat, tcu::Sampler::DepthStencilMode mode,
613*35238bceSAndroid Build Coastguard Worker StateType stateType, int texWidth, int texHeight,
614*35238bceSAndroid Build Coastguard Worker SamplingFunction samplingFunction, uint32_t filter, uint32_t flags)
615*35238bceSAndroid Build Coastguard Worker : TestCase(context, name, description)
616*35238bceSAndroid Build Coastguard Worker , m_texFormat(texFormat)
617*35238bceSAndroid Build Coastguard Worker , m_sampleMode(mode)
618*35238bceSAndroid Build Coastguard Worker , m_channelClass(getFormatChannelClass(texFormat, mode))
619*35238bceSAndroid Build Coastguard Worker , m_stateType(stateType)
620*35238bceSAndroid Build Coastguard Worker , m_texHeight(texHeight)
621*35238bceSAndroid Build Coastguard Worker , m_texWidth(texWidth)
622*35238bceSAndroid Build Coastguard Worker , m_samplingFunction(samplingFunction)
623*35238bceSAndroid Build Coastguard Worker , m_useShadowSampler((flags & FLAG_USE_SHADOW_SAMPLER) != 0)
624*35238bceSAndroid Build Coastguard Worker , m_useFloatFilterable((flags & FLAG_TEST_FLOAT_FILTERABLE) != 0)
625*35238bceSAndroid Build Coastguard Worker , m_filter(filter)
626*35238bceSAndroid Build Coastguard Worker , m_iterationNdx(0)
627*35238bceSAndroid Build Coastguard Worker , m_result(context.getTestContext().getLog())
628*35238bceSAndroid Build Coastguard Worker {
629*35238bceSAndroid Build Coastguard Worker DE_ASSERT(stateType < STATE_LAST);
630*35238bceSAndroid Build Coastguard Worker DE_ASSERT(samplingFunction < SAMPLE_LAST);
631*35238bceSAndroid Build Coastguard Worker // mode must be set for combined depth-stencil formats
632*35238bceSAndroid Build Coastguard Worker DE_ASSERT(m_channelClass != tcu::TEXTURECHANNELCLASS_LAST || mode != tcu::Sampler::MODE_LAST);
633*35238bceSAndroid Build Coastguard Worker }
634*35238bceSAndroid Build Coastguard Worker
~TextureBorderClampTest(void)635*35238bceSAndroid Build Coastguard Worker TextureBorderClampTest::~TextureBorderClampTest(void)
636*35238bceSAndroid Build Coastguard Worker {
637*35238bceSAndroid Build Coastguard Worker deinit();
638*35238bceSAndroid Build Coastguard Worker }
639*35238bceSAndroid Build Coastguard Worker
init(void)640*35238bceSAndroid Build Coastguard Worker void TextureBorderClampTest::init(void)
641*35238bceSAndroid Build Coastguard Worker {
642*35238bceSAndroid Build Coastguard Worker // requirements
643*35238bceSAndroid Build Coastguard Worker const bool supportsGL45 = glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5));
644*35238bceSAndroid Build Coastguard Worker const bool supportsES32orGL45 =
645*35238bceSAndroid Build Coastguard Worker glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::es(3, 2)) || supportsGL45;
646*35238bceSAndroid Build Coastguard Worker
647*35238bceSAndroid Build Coastguard Worker // repeat filterable test with valid context
648*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
649*35238bceSAndroid Build Coastguard Worker const bool is_texture_float_linear_supported =
650*35238bceSAndroid Build Coastguard Worker glu::hasExtension(gl, glu::ApiType::es(3, 0), "GL_OES_texture_float_linear");
651*35238bceSAndroid Build Coastguard Worker const bool coreFilterable = isCoreFilterableFormat(m_texFormat, m_sampleMode, is_texture_float_linear_supported);
652*35238bceSAndroid Build Coastguard Worker
653*35238bceSAndroid Build Coastguard Worker if (m_useFloatFilterable && !coreFilterable && filterRequiresFilterability(m_filter))
654*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("Test requires GL_OES_texture_float_linear extension");
655*35238bceSAndroid Build Coastguard Worker
656*35238bceSAndroid Build Coastguard Worker if (!supportsES32orGL45 && !m_context.getContextInfo().isExtensionSupported("GL_EXT_texture_border_clamp"))
657*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("Test requires GL_EXT_texture_border_clamp extension");
658*35238bceSAndroid Build Coastguard Worker
659*35238bceSAndroid Build Coastguard Worker if (glu::isCompressedFormat(m_texFormat) && !supportsES32orGL45 &&
660*35238bceSAndroid Build Coastguard Worker tcu::isAstcFormat(glu::mapGLCompressedTexFormat(m_texFormat)) &&
661*35238bceSAndroid Build Coastguard Worker !m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_ldr"))
662*35238bceSAndroid Build Coastguard Worker {
663*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("Test requires GL_KHR_texture_compression_astc_ldr extension");
664*35238bceSAndroid Build Coastguard Worker }
665*35238bceSAndroid Build Coastguard Worker
666*35238bceSAndroid Build Coastguard Worker if (m_texFormat == GL_BGRA && !m_context.getContextInfo().isExtensionSupported("GL_EXT_texture_format_BGRA8888"))
667*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("Test requires GL_EXT_texture_format_BGRA8888 extension");
668*35238bceSAndroid Build Coastguard Worker
669*35238bceSAndroid Build Coastguard Worker if (m_context.getRenderTarget().getWidth() < VIEWPORT_WIDTH ||
670*35238bceSAndroid Build Coastguard Worker m_context.getRenderTarget().getHeight() < VIEWPORT_HEIGHT)
671*35238bceSAndroid Build Coastguard Worker {
672*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("Test requires " + de::toString<int>(VIEWPORT_WIDTH) + "x" +
673*35238bceSAndroid Build Coastguard Worker de::toString<int>(VIEWPORT_HEIGHT) + " viewport");
674*35238bceSAndroid Build Coastguard Worker }
675*35238bceSAndroid Build Coastguard Worker
676*35238bceSAndroid Build Coastguard Worker // resources
677*35238bceSAndroid Build Coastguard Worker
678*35238bceSAndroid Build Coastguard Worker m_texture = genDefaultTexture<glu::Texture2D>(m_context.getRenderContext(), m_context.getContextInfo(), m_texFormat,
679*35238bceSAndroid Build Coastguard Worker tcu::IVec2(m_texWidth, m_texHeight));
680*35238bceSAndroid Build Coastguard Worker
681*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::Message << "Created texture with format "
682*35238bceSAndroid Build Coastguard Worker << glu::getTextureFormatName(m_texFormat) << ", size (" << m_texture->getRefTexture().getWidth()
683*35238bceSAndroid Build Coastguard Worker << ", " << m_texture->getRefTexture().getHeight() << ")\n"
684*35238bceSAndroid Build Coastguard Worker << "Setting sampling state using "
685*35238bceSAndroid Build Coastguard Worker << ((m_stateType == STATE_TEXTURE_PARAM) ? ("texture state") : ("sampler state"))
686*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
687*35238bceSAndroid Build Coastguard Worker
688*35238bceSAndroid Build Coastguard Worker if (m_samplingFunction == SAMPLE_FILTER)
689*35238bceSAndroid Build Coastguard Worker {
690*35238bceSAndroid Build Coastguard Worker const glu::GLSLVersion glslVersion = glu::getContextTypeGLSLVersion(m_context.getRenderContext().getType());
691*35238bceSAndroid Build Coastguard Worker
692*35238bceSAndroid Build Coastguard Worker m_renderer = de::MovePtr<gls::TextureTestUtil::TextureRenderer>(new gls::TextureTestUtil::TextureRenderer(
693*35238bceSAndroid Build Coastguard Worker m_context.getRenderContext(), m_testCtx.getLog(), glslVersion, glu::PRECISION_HIGHP));
694*35238bceSAndroid Build Coastguard Worker }
695*35238bceSAndroid Build Coastguard Worker else
696*35238bceSAndroid Build Coastguard Worker {
697*35238bceSAndroid Build Coastguard Worker m_gatherProgram = de::MovePtr<glu::ShaderProgram>(genGatherProgram());
698*35238bceSAndroid Build Coastguard Worker
699*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::Message << "Using texture gather to sample texture"
700*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage << *m_gatherProgram;
701*35238bceSAndroid Build Coastguard Worker
702*35238bceSAndroid Build Coastguard Worker if (!m_gatherProgram->isOk())
703*35238bceSAndroid Build Coastguard Worker throw tcu::TestError("failed to build program");
704*35238bceSAndroid Build Coastguard Worker }
705*35238bceSAndroid Build Coastguard Worker }
706*35238bceSAndroid Build Coastguard Worker
deinit(void)707*35238bceSAndroid Build Coastguard Worker void TextureBorderClampTest::deinit(void)
708*35238bceSAndroid Build Coastguard Worker {
709*35238bceSAndroid Build Coastguard Worker m_texture.clear();
710*35238bceSAndroid Build Coastguard Worker m_renderer.clear();
711*35238bceSAndroid Build Coastguard Worker m_gatherProgram.clear();
712*35238bceSAndroid Build Coastguard Worker }
713*35238bceSAndroid Build Coastguard Worker
iterate(void)714*35238bceSAndroid Build Coastguard Worker TextureBorderClampTest::IterateResult TextureBorderClampTest::iterate(void)
715*35238bceSAndroid Build Coastguard Worker {
716*35238bceSAndroid Build Coastguard Worker const IterationConfig iterationConfig = getIteration(m_iterationNdx);
717*35238bceSAndroid Build Coastguard Worker const std::string iterationDesc =
718*35238bceSAndroid Build Coastguard Worker "Iteration " + de::toString(m_iterationNdx + 1) +
719*35238bceSAndroid Build Coastguard Worker (iterationConfig.description.empty() ? ("") : (" - " + iterationConfig.description));
720*35238bceSAndroid Build Coastguard Worker const tcu::ScopedLogSection section(m_testCtx.getLog(), "Iteration", iterationDesc);
721*35238bceSAndroid Build Coastguard Worker tcu::Surface renderedFrame(VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
722*35238bceSAndroid Build Coastguard Worker const glu::TextureTestUtil::ReferenceParams samplerParams = genSamplerParams(iterationConfig);
723*35238bceSAndroid Build Coastguard Worker
724*35238bceSAndroid Build Coastguard Worker logParams(iterationConfig, samplerParams);
725*35238bceSAndroid Build Coastguard Worker renderTo(renderedFrame, iterationConfig, samplerParams);
726*35238bceSAndroid Build Coastguard Worker verifyImage(renderedFrame, iterationConfig, samplerParams);
727*35238bceSAndroid Build Coastguard Worker
728*35238bceSAndroid Build Coastguard Worker if (++m_iterationNdx == getNumIterations())
729*35238bceSAndroid Build Coastguard Worker {
730*35238bceSAndroid Build Coastguard Worker m_result.setTestContextResult(m_testCtx);
731*35238bceSAndroid Build Coastguard Worker return STOP;
732*35238bceSAndroid Build Coastguard Worker }
733*35238bceSAndroid Build Coastguard Worker return CONTINUE;
734*35238bceSAndroid Build Coastguard Worker }
735*35238bceSAndroid Build Coastguard Worker
logParams(const IterationConfig & config,const glu::TextureTestUtil::ReferenceParams & samplerParams)736*35238bceSAndroid Build Coastguard Worker void TextureBorderClampTest::logParams(const IterationConfig &config,
737*35238bceSAndroid Build Coastguard Worker const glu::TextureTestUtil::ReferenceParams &samplerParams)
738*35238bceSAndroid Build Coastguard Worker {
739*35238bceSAndroid Build Coastguard Worker const std::string borderColorString = (m_channelClass == tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER) ?
740*35238bceSAndroid Build Coastguard Worker (de::toString(config.borderColor.get<int32_t>())) :
741*35238bceSAndroid Build Coastguard Worker (m_channelClass == tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER) ?
742*35238bceSAndroid Build Coastguard Worker (de::toString(config.borderColor.get<uint32_t>())) :
743*35238bceSAndroid Build Coastguard Worker (de::toString(config.borderColor.get<float>()));
744*35238bceSAndroid Build Coastguard Worker
745*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::Message << "Rendering full screen quad, tex coords bottom-left: " << config.p0
746*35238bceSAndroid Build Coastguard Worker << ", top-right " << config.p1 << "\n"
747*35238bceSAndroid Build Coastguard Worker << "Border color is " << borderColorString << "\n"
748*35238bceSAndroid Build Coastguard Worker << "Texture lookup bias: " << samplerParams.colorBias << "\n"
749*35238bceSAndroid Build Coastguard Worker << "Texture lookup scale: " << samplerParams.colorScale << "\n"
750*35238bceSAndroid Build Coastguard Worker << "Filters: min = "
751*35238bceSAndroid Build Coastguard Worker << glu::getTextureFilterName(glu::getGLFilterMode(samplerParams.sampler.minFilter))
752*35238bceSAndroid Build Coastguard Worker << ", mag = " << glu::getTextureFilterName(glu::getGLFilterMode(samplerParams.sampler.magFilter))
753*35238bceSAndroid Build Coastguard Worker << "\n"
754*35238bceSAndroid Build Coastguard Worker << "Wrap mode: s = " << glu::getRepeatModeStr(config.sWrapMode)
755*35238bceSAndroid Build Coastguard Worker << ", t = " << glu::getRepeatModeStr(config.tWrapMode) << "\n"
756*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
757*35238bceSAndroid Build Coastguard Worker
758*35238bceSAndroid Build Coastguard Worker if (m_sampleMode == tcu::Sampler::MODE_DEPTH)
759*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::Message << "Depth stencil texture mode is DEPTH_COMPONENT"
760*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
761*35238bceSAndroid Build Coastguard Worker else if (m_sampleMode == tcu::Sampler::MODE_STENCIL)
762*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::Message << "Depth stencil texture mode is STENCIL_INDEX"
763*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
764*35238bceSAndroid Build Coastguard Worker
765*35238bceSAndroid Build Coastguard Worker if (config.compareMode != GL_NONE)
766*35238bceSAndroid Build Coastguard Worker {
767*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::Message << "Texture mode is COMPARE_REF_TO_TEXTURE, mode = "
768*35238bceSAndroid Build Coastguard Worker << glu::getCompareFuncStr(config.compareMode) << "\n"
769*35238bceSAndroid Build Coastguard Worker << "Compare reference value = " << config.compareRef << "\n"
770*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
771*35238bceSAndroid Build Coastguard Worker }
772*35238bceSAndroid Build Coastguard Worker }
773*35238bceSAndroid Build Coastguard Worker
renderTo(tcu::Surface & surface,const IterationConfig & config,const glu::TextureTestUtil::ReferenceParams & samplerParams)774*35238bceSAndroid Build Coastguard Worker void TextureBorderClampTest::renderTo(tcu::Surface &surface, const IterationConfig &config,
775*35238bceSAndroid Build Coastguard Worker const glu::TextureTestUtil::ReferenceParams &samplerParams)
776*35238bceSAndroid Build Coastguard Worker {
777*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
778*35238bceSAndroid Build Coastguard Worker const gls::TextureTestUtil::RandomViewport viewport(m_context.getRenderTarget(), VIEWPORT_WIDTH, VIEWPORT_HEIGHT,
779*35238bceSAndroid Build Coastguard Worker getIterationSeed(config));
780*35238bceSAndroid Build Coastguard Worker std::vector<float> texCoord;
781*35238bceSAndroid Build Coastguard Worker de::MovePtr<glu::Sampler> sampler;
782*35238bceSAndroid Build Coastguard Worker
783*35238bceSAndroid Build Coastguard Worker glu::TextureTestUtil::computeQuadTexCoord2D(texCoord, config.p0, config.p1);
784*35238bceSAndroid Build Coastguard Worker
785*35238bceSAndroid Build Coastguard Worker // Bind to unit 0.
786*35238bceSAndroid Build Coastguard Worker gl.activeTexture(GL_TEXTURE0);
787*35238bceSAndroid Build Coastguard Worker gl.bindTexture(GL_TEXTURE_2D, m_texture->getGLTexture());
788*35238bceSAndroid Build Coastguard Worker
789*35238bceSAndroid Build Coastguard Worker if (m_sampleMode == tcu::Sampler::MODE_DEPTH)
790*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, GL_DEPTH_COMPONENT);
791*35238bceSAndroid Build Coastguard Worker else if (m_sampleMode == tcu::Sampler::MODE_STENCIL)
792*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, GL_STENCIL_INDEX);
793*35238bceSAndroid Build Coastguard Worker
794*35238bceSAndroid Build Coastguard Worker if (config.compareMode == GL_NONE)
795*35238bceSAndroid Build Coastguard Worker {
796*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE);
797*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_ALWAYS);
798*35238bceSAndroid Build Coastguard Worker }
799*35238bceSAndroid Build Coastguard Worker else
800*35238bceSAndroid Build Coastguard Worker {
801*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
802*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, config.compareMode);
803*35238bceSAndroid Build Coastguard Worker }
804*35238bceSAndroid Build Coastguard Worker
805*35238bceSAndroid Build Coastguard Worker if (m_stateType == STATE_TEXTURE_PARAM)
806*35238bceSAndroid Build Coastguard Worker {
807*35238bceSAndroid Build Coastguard Worker // Setup filtering and wrap modes.
808*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, glu::getGLWrapMode(samplerParams.sampler.wrapS));
809*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, glu::getGLWrapMode(samplerParams.sampler.wrapT));
810*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, glu::getGLFilterMode(samplerParams.sampler.minFilter));
811*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, glu::getGLFilterMode(samplerParams.sampler.magFilter));
812*35238bceSAndroid Build Coastguard Worker
813*35238bceSAndroid Build Coastguard Worker switch (m_channelClass)
814*35238bceSAndroid Build Coastguard Worker {
815*35238bceSAndroid Build Coastguard Worker case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
816*35238bceSAndroid Build Coastguard Worker case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
817*35238bceSAndroid Build Coastguard Worker case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
818*35238bceSAndroid Build Coastguard Worker gl.texParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, config.borderColor.getAccess<float>());
819*35238bceSAndroid Build Coastguard Worker break;
820*35238bceSAndroid Build Coastguard Worker
821*35238bceSAndroid Build Coastguard Worker case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
822*35238bceSAndroid Build Coastguard Worker gl.texParameterIiv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, config.borderColor.getAccess<int32_t>());
823*35238bceSAndroid Build Coastguard Worker break;
824*35238bceSAndroid Build Coastguard Worker
825*35238bceSAndroid Build Coastguard Worker case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
826*35238bceSAndroid Build Coastguard Worker gl.texParameterIuiv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, config.borderColor.getAccess<uint32_t>());
827*35238bceSAndroid Build Coastguard Worker break;
828*35238bceSAndroid Build Coastguard Worker
829*35238bceSAndroid Build Coastguard Worker default:
830*35238bceSAndroid Build Coastguard Worker DE_ASSERT(false);
831*35238bceSAndroid Build Coastguard Worker }
832*35238bceSAndroid Build Coastguard Worker }
833*35238bceSAndroid Build Coastguard Worker else if (m_stateType == STATE_SAMPLER_PARAM)
834*35238bceSAndroid Build Coastguard Worker {
835*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 blue(0.0f, 0.0f, 1.0f, 1.0f);
836*35238bceSAndroid Build Coastguard Worker
837*35238bceSAndroid Build Coastguard Worker // Setup filtering and wrap modes to bad values
838*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
839*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
840*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
841*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
842*35238bceSAndroid Build Coastguard Worker gl.texParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, blue.getPtr()); // just set some unlikely color
843*35238bceSAndroid Build Coastguard Worker
844*35238bceSAndroid Build Coastguard Worker // setup sampler to correct values
845*35238bceSAndroid Build Coastguard Worker sampler = de::MovePtr<glu::Sampler>(new glu::Sampler(m_context.getRenderContext()));
846*35238bceSAndroid Build Coastguard Worker
847*35238bceSAndroid Build Coastguard Worker gl.samplerParameteri(**sampler, GL_TEXTURE_WRAP_S, glu::getGLWrapMode(samplerParams.sampler.wrapS));
848*35238bceSAndroid Build Coastguard Worker gl.samplerParameteri(**sampler, GL_TEXTURE_WRAP_T, glu::getGLWrapMode(samplerParams.sampler.wrapT));
849*35238bceSAndroid Build Coastguard Worker gl.samplerParameteri(**sampler, GL_TEXTURE_MIN_FILTER, glu::getGLFilterMode(samplerParams.sampler.minFilter));
850*35238bceSAndroid Build Coastguard Worker gl.samplerParameteri(**sampler, GL_TEXTURE_MAG_FILTER, glu::getGLFilterMode(samplerParams.sampler.magFilter));
851*35238bceSAndroid Build Coastguard Worker
852*35238bceSAndroid Build Coastguard Worker switch (m_channelClass)
853*35238bceSAndroid Build Coastguard Worker {
854*35238bceSAndroid Build Coastguard Worker case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
855*35238bceSAndroid Build Coastguard Worker case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
856*35238bceSAndroid Build Coastguard Worker case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
857*35238bceSAndroid Build Coastguard Worker gl.samplerParameterfv(**sampler, GL_TEXTURE_BORDER_COLOR, config.borderColor.getAccess<float>());
858*35238bceSAndroid Build Coastguard Worker break;
859*35238bceSAndroid Build Coastguard Worker
860*35238bceSAndroid Build Coastguard Worker case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
861*35238bceSAndroid Build Coastguard Worker gl.samplerParameterIiv(**sampler, GL_TEXTURE_BORDER_COLOR, config.borderColor.getAccess<int32_t>());
862*35238bceSAndroid Build Coastguard Worker break;
863*35238bceSAndroid Build Coastguard Worker
864*35238bceSAndroid Build Coastguard Worker case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
865*35238bceSAndroid Build Coastguard Worker gl.samplerParameterIuiv(**sampler, GL_TEXTURE_BORDER_COLOR, config.borderColor.getAccess<uint32_t>());
866*35238bceSAndroid Build Coastguard Worker break;
867*35238bceSAndroid Build Coastguard Worker
868*35238bceSAndroid Build Coastguard Worker default:
869*35238bceSAndroid Build Coastguard Worker DE_ASSERT(false);
870*35238bceSAndroid Build Coastguard Worker }
871*35238bceSAndroid Build Coastguard Worker
872*35238bceSAndroid Build Coastguard Worker gl.bindSampler(0, **sampler);
873*35238bceSAndroid Build Coastguard Worker }
874*35238bceSAndroid Build Coastguard Worker
875*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "Set texturing state");
876*35238bceSAndroid Build Coastguard Worker
877*35238bceSAndroid Build Coastguard Worker gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);
878*35238bceSAndroid Build Coastguard Worker renderQuad(&texCoord[0], samplerParams);
879*35238bceSAndroid Build Coastguard Worker glu::readPixels(m_context.getRenderContext(), viewport.x, viewport.y, surface.getAccess());
880*35238bceSAndroid Build Coastguard Worker }
881*35238bceSAndroid Build Coastguard Worker
renderQuad(const float * texCoord,const glu::TextureTestUtil::ReferenceParams & samplerParams)882*35238bceSAndroid Build Coastguard Worker void TextureBorderClampTest::renderQuad(const float *texCoord,
883*35238bceSAndroid Build Coastguard Worker const glu::TextureTestUtil::ReferenceParams &samplerParams)
884*35238bceSAndroid Build Coastguard Worker {
885*35238bceSAndroid Build Coastguard Worker // use TextureRenderer for basic rendering, use custom for gather
886*35238bceSAndroid Build Coastguard Worker if (m_samplingFunction == SAMPLE_FILTER)
887*35238bceSAndroid Build Coastguard Worker m_renderer->renderQuad(0, texCoord, samplerParams);
888*35238bceSAndroid Build Coastguard Worker else
889*35238bceSAndroid Build Coastguard Worker {
890*35238bceSAndroid Build Coastguard Worker static const float position[] = {-1.0f, -1.0f, 0.0f, 1.0f, -1.0f, +1.0f, 0.0f, 1.0f,
891*35238bceSAndroid Build Coastguard Worker +1.0f, -1.0f, 0.0f, 1.0f, +1.0f, +1.0f, 0.0f, 1.0f};
892*35238bceSAndroid Build Coastguard Worker static const uint16_t indices[] = {0, 1, 2, 2, 1, 3};
893*35238bceSAndroid Build Coastguard Worker const glu::VertexArrayBinding vertexArrays[] = {glu::va::Float("a_position", 4, 4, 0, &position[0]),
894*35238bceSAndroid Build Coastguard Worker glu::va::Float("a_texcoord", 2, 4, 0, texCoord)};
895*35238bceSAndroid Build Coastguard Worker
896*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
897*35238bceSAndroid Build Coastguard Worker const uint32_t progId = m_gatherProgram->getProgram();
898*35238bceSAndroid Build Coastguard Worker
899*35238bceSAndroid Build Coastguard Worker gl.useProgram(progId);
900*35238bceSAndroid Build Coastguard Worker gl.uniform1i(gl.getUniformLocation(progId, "u_sampler"), 0);
901*35238bceSAndroid Build Coastguard Worker if (m_useShadowSampler)
902*35238bceSAndroid Build Coastguard Worker gl.uniform1f(gl.getUniformLocation(progId, "u_ref"), samplerParams.ref);
903*35238bceSAndroid Build Coastguard Worker gl.uniform4fv(gl.getUniformLocation(progId, "u_colorScale"), 1, samplerParams.colorScale.getPtr());
904*35238bceSAndroid Build Coastguard Worker gl.uniform4fv(gl.getUniformLocation(progId, "u_colorBias"), 1, samplerParams.colorBias.getPtr());
905*35238bceSAndroid Build Coastguard Worker
906*35238bceSAndroid Build Coastguard Worker glu::draw(m_context.getRenderContext(), progId, DE_LENGTH_OF_ARRAY(vertexArrays), &vertexArrays[0],
907*35238bceSAndroid Build Coastguard Worker glu::pr::Triangles(DE_LENGTH_OF_ARRAY(indices), &indices[0]));
908*35238bceSAndroid Build Coastguard Worker }
909*35238bceSAndroid Build Coastguard Worker }
910*35238bceSAndroid Build Coastguard Worker
verifyImage(const tcu::Surface & renderedFrame,const IterationConfig & config,const glu::TextureTestUtil::ReferenceParams & samplerParams)911*35238bceSAndroid Build Coastguard Worker void TextureBorderClampTest::verifyImage(const tcu::Surface &renderedFrame, const IterationConfig &config,
912*35238bceSAndroid Build Coastguard Worker const glu::TextureTestUtil::ReferenceParams &samplerParams)
913*35238bceSAndroid Build Coastguard Worker {
914*35238bceSAndroid Build Coastguard Worker const tcu::PixelFormat pixelFormat = m_context.getRenderTarget().getPixelFormat();
915*35238bceSAndroid Build Coastguard Worker
916*35238bceSAndroid Build Coastguard Worker tcu::LodPrecision lodPrecision;
917*35238bceSAndroid Build Coastguard Worker std::vector<float> texCoord;
918*35238bceSAndroid Build Coastguard Worker bool verificationOk;
919*35238bceSAndroid Build Coastguard Worker
920*35238bceSAndroid Build Coastguard Worker glu::TextureTestUtil::computeQuadTexCoord2D(texCoord, config.p0, config.p1);
921*35238bceSAndroid Build Coastguard Worker
922*35238bceSAndroid Build Coastguard Worker lodPrecision.derivateBits = 18;
923*35238bceSAndroid Build Coastguard Worker lodPrecision.lodBits = 5;
924*35238bceSAndroid Build Coastguard Worker
925*35238bceSAndroid Build Coastguard Worker if (samplerParams.sampler.compare == tcu::Sampler::COMPAREMODE_NONE)
926*35238bceSAndroid Build Coastguard Worker {
927*35238bceSAndroid Build Coastguard Worker const tcu::TextureFormat texFormat =
928*35238bceSAndroid Build Coastguard Worker tcu::getEffectiveDepthStencilTextureFormat(m_texture->getRefTexture().getFormat(), m_sampleMode);
929*35238bceSAndroid Build Coastguard Worker const bool isNearestMinFilter = samplerParams.sampler.minFilter == tcu::Sampler::NEAREST ||
930*35238bceSAndroid Build Coastguard Worker samplerParams.sampler.minFilter == tcu::Sampler::NEAREST_MIPMAP_NEAREST;
931*35238bceSAndroid Build Coastguard Worker const bool isNearestMagFilter = samplerParams.sampler.magFilter == tcu::Sampler::NEAREST;
932*35238bceSAndroid Build Coastguard Worker const bool isNearestOnly = isNearestMinFilter && isNearestMagFilter;
933*35238bceSAndroid Build Coastguard Worker const bool isSRGB = texFormat.order == tcu::TextureFormat::sRGB || texFormat.order == tcu::TextureFormat::sRGBA;
934*35238bceSAndroid Build Coastguard Worker const int colorErrorBits = (isNearestOnly && !isSRGB) ? (1) : (2);
935*35238bceSAndroid Build Coastguard Worker const tcu::IVec4 colorBits =
936*35238bceSAndroid Build Coastguard Worker tcu::max(glu::TextureTestUtil::getBitsVec(pixelFormat) - tcu::IVec4(colorErrorBits), tcu::IVec4(0));
937*35238bceSAndroid Build Coastguard Worker tcu::LookupPrecision lookupPrecision;
938*35238bceSAndroid Build Coastguard Worker
939*35238bceSAndroid Build Coastguard Worker lookupPrecision.colorThreshold = tcu::computeFixedPointThreshold(colorBits) / samplerParams.colorScale;
940*35238bceSAndroid Build Coastguard Worker lookupPrecision.coordBits = tcu::IVec3(20, 20, 0);
941*35238bceSAndroid Build Coastguard Worker lookupPrecision.uvwBits = tcu::IVec3(5, 5, 0);
942*35238bceSAndroid Build Coastguard Worker lookupPrecision.colorMask = glu::TextureTestUtil::getCompareMask(pixelFormat);
943*35238bceSAndroid Build Coastguard Worker
944*35238bceSAndroid Build Coastguard Worker if (m_samplingFunction == SAMPLE_FILTER)
945*35238bceSAndroid Build Coastguard Worker {
946*35238bceSAndroid Build Coastguard Worker verificationOk = verifyTextureSampleResult(renderedFrame.getAccess(), &texCoord[0], samplerParams,
947*35238bceSAndroid Build Coastguard Worker lodPrecision, lookupPrecision);
948*35238bceSAndroid Build Coastguard Worker }
949*35238bceSAndroid Build Coastguard Worker else if (m_samplingFunction == SAMPLE_GATHER)
950*35238bceSAndroid Build Coastguard Worker {
951*35238bceSAndroid Build Coastguard Worker verificationOk =
952*35238bceSAndroid Build Coastguard Worker verifyTextureGatherResult(renderedFrame.getAccess(), &texCoord[0], samplerParams, lookupPrecision);
953*35238bceSAndroid Build Coastguard Worker }
954*35238bceSAndroid Build Coastguard Worker else
955*35238bceSAndroid Build Coastguard Worker {
956*35238bceSAndroid Build Coastguard Worker DE_ASSERT(false);
957*35238bceSAndroid Build Coastguard Worker verificationOk = false;
958*35238bceSAndroid Build Coastguard Worker }
959*35238bceSAndroid Build Coastguard Worker }
960*35238bceSAndroid Build Coastguard Worker else
961*35238bceSAndroid Build Coastguard Worker {
962*35238bceSAndroid Build Coastguard Worker tcu::TexComparePrecision texComparePrecision;
963*35238bceSAndroid Build Coastguard Worker tcu::TexComparePrecision lowQualityTexComparePrecision;
964*35238bceSAndroid Build Coastguard Worker tcu::LodPrecision lowQualityLodPrecision = lodPrecision;
965*35238bceSAndroid Build Coastguard Worker
966*35238bceSAndroid Build Coastguard Worker texComparePrecision.coordBits = tcu::IVec3(20, 20, 0);
967*35238bceSAndroid Build Coastguard Worker texComparePrecision.uvwBits = tcu::IVec3(7, 7, 0);
968*35238bceSAndroid Build Coastguard Worker texComparePrecision.pcfBits = 5;
969*35238bceSAndroid Build Coastguard Worker texComparePrecision.referenceBits = 16;
970*35238bceSAndroid Build Coastguard Worker texComparePrecision.resultBits = de::max(0, pixelFormat.redBits - 1);
971*35238bceSAndroid Build Coastguard Worker
972*35238bceSAndroid Build Coastguard Worker lowQualityTexComparePrecision.coordBits = tcu::IVec3(20, 20, 0);
973*35238bceSAndroid Build Coastguard Worker lowQualityTexComparePrecision.uvwBits = tcu::IVec3(4, 4, 0);
974*35238bceSAndroid Build Coastguard Worker lowQualityTexComparePrecision.pcfBits = 0;
975*35238bceSAndroid Build Coastguard Worker lowQualityTexComparePrecision.referenceBits = 16;
976*35238bceSAndroid Build Coastguard Worker lowQualityTexComparePrecision.resultBits = de::max(0, pixelFormat.redBits - 1);
977*35238bceSAndroid Build Coastguard Worker
978*35238bceSAndroid Build Coastguard Worker lowQualityLodPrecision.lodBits = 4;
979*35238bceSAndroid Build Coastguard Worker
980*35238bceSAndroid Build Coastguard Worker if (m_samplingFunction == SAMPLE_FILTER)
981*35238bceSAndroid Build Coastguard Worker {
982*35238bceSAndroid Build Coastguard Worker verificationOk =
983*35238bceSAndroid Build Coastguard Worker verifyTextureCompareResult(renderedFrame.getAccess(), &texCoord[0], samplerParams, texComparePrecision,
984*35238bceSAndroid Build Coastguard Worker lowQualityTexComparePrecision, lodPrecision, lowQualityLodPrecision);
985*35238bceSAndroid Build Coastguard Worker }
986*35238bceSAndroid Build Coastguard Worker else if (m_samplingFunction == SAMPLE_GATHER)
987*35238bceSAndroid Build Coastguard Worker {
988*35238bceSAndroid Build Coastguard Worker verificationOk = verifyTextureGatherCmpResult(renderedFrame.getAccess(), &texCoord[0], samplerParams,
989*35238bceSAndroid Build Coastguard Worker texComparePrecision, lowQualityTexComparePrecision);
990*35238bceSAndroid Build Coastguard Worker }
991*35238bceSAndroid Build Coastguard Worker else
992*35238bceSAndroid Build Coastguard Worker {
993*35238bceSAndroid Build Coastguard Worker DE_ASSERT(false);
994*35238bceSAndroid Build Coastguard Worker verificationOk = false;
995*35238bceSAndroid Build Coastguard Worker }
996*35238bceSAndroid Build Coastguard Worker }
997*35238bceSAndroid Build Coastguard Worker
998*35238bceSAndroid Build Coastguard Worker if (!verificationOk)
999*35238bceSAndroid Build Coastguard Worker m_result.fail("Image verification failed");
1000*35238bceSAndroid Build Coastguard Worker }
1001*35238bceSAndroid Build Coastguard Worker
verifyTextureSampleResult(const tcu::ConstPixelBufferAccess & renderedFrame,const float * texCoord,const glu::TextureTestUtil::ReferenceParams & samplerParams,const tcu::LodPrecision & lodPrecision,const tcu::LookupPrecision & lookupPrecision)1002*35238bceSAndroid Build Coastguard Worker bool TextureBorderClampTest::verifyTextureSampleResult(const tcu::ConstPixelBufferAccess &renderedFrame,
1003*35238bceSAndroid Build Coastguard Worker const float *texCoord,
1004*35238bceSAndroid Build Coastguard Worker const glu::TextureTestUtil::ReferenceParams &samplerParams,
1005*35238bceSAndroid Build Coastguard Worker const tcu::LodPrecision &lodPrecision,
1006*35238bceSAndroid Build Coastguard Worker const tcu::LookupPrecision &lookupPrecision)
1007*35238bceSAndroid Build Coastguard Worker {
1008*35238bceSAndroid Build Coastguard Worker const tcu::PixelFormat pixelFormat = m_context.getRenderTarget().getPixelFormat();
1009*35238bceSAndroid Build Coastguard Worker tcu::Surface reference(renderedFrame.getWidth(), renderedFrame.getHeight());
1010*35238bceSAndroid Build Coastguard Worker tcu::Surface errorMask(renderedFrame.getWidth(), renderedFrame.getHeight());
1011*35238bceSAndroid Build Coastguard Worker int numFailedPixels;
1012*35238bceSAndroid Build Coastguard Worker
1013*35238bceSAndroid Build Coastguard Worker glu::TextureTestUtil::sampleTexture(tcu::SurfaceAccess(reference, pixelFormat), m_texture->getRefTexture(),
1014*35238bceSAndroid Build Coastguard Worker texCoord, samplerParams);
1015*35238bceSAndroid Build Coastguard Worker
1016*35238bceSAndroid Build Coastguard Worker numFailedPixels = glu::TextureTestUtil::computeTextureLookupDiff(
1017*35238bceSAndroid Build Coastguard Worker renderedFrame, reference.getAccess(), errorMask.getAccess(), m_texture->getRefTexture(), texCoord,
1018*35238bceSAndroid Build Coastguard Worker samplerParams, lookupPrecision, lodPrecision, m_testCtx.getWatchDog());
1019*35238bceSAndroid Build Coastguard Worker
1020*35238bceSAndroid Build Coastguard Worker if (numFailedPixels > 0)
1021*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::Message << "ERROR: Result verification failed, got " << numFailedPixels
1022*35238bceSAndroid Build Coastguard Worker << " invalid pixels!" << tcu::TestLog::EndMessage;
1023*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::ImageSet("VerifyResult", "Verification result")
1024*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Image("Rendered", "Rendered image", renderedFrame);
1025*35238bceSAndroid Build Coastguard Worker if (numFailedPixels > 0)
1026*35238bceSAndroid Build Coastguard Worker {
1027*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::Image("Reference", "Ideal reference image", reference)
1028*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Image("ErrorMask", "Error mask", errorMask);
1029*35238bceSAndroid Build Coastguard Worker }
1030*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::EndImageSet;
1031*35238bceSAndroid Build Coastguard Worker
1032*35238bceSAndroid Build Coastguard Worker return (numFailedPixels == 0);
1033*35238bceSAndroid Build Coastguard Worker }
1034*35238bceSAndroid Build Coastguard Worker
verifyTextureCompareResult(const tcu::ConstPixelBufferAccess & renderedFrame,const float * texCoord,const glu::TextureTestUtil::ReferenceParams & samplerParams,const tcu::TexComparePrecision & texComparePrecision,const tcu::TexComparePrecision & lowQualityTexComparePrecision,const tcu::LodPrecision & lodPrecision,const tcu::LodPrecision & lowQualityLodPrecision)1035*35238bceSAndroid Build Coastguard Worker bool TextureBorderClampTest::verifyTextureCompareResult(const tcu::ConstPixelBufferAccess &renderedFrame,
1036*35238bceSAndroid Build Coastguard Worker const float *texCoord,
1037*35238bceSAndroid Build Coastguard Worker const glu::TextureTestUtil::ReferenceParams &samplerParams,
1038*35238bceSAndroid Build Coastguard Worker const tcu::TexComparePrecision &texComparePrecision,
1039*35238bceSAndroid Build Coastguard Worker const tcu::TexComparePrecision &lowQualityTexComparePrecision,
1040*35238bceSAndroid Build Coastguard Worker const tcu::LodPrecision &lodPrecision,
1041*35238bceSAndroid Build Coastguard Worker const tcu::LodPrecision &lowQualityLodPrecision)
1042*35238bceSAndroid Build Coastguard Worker {
1043*35238bceSAndroid Build Coastguard Worker const tcu::PixelFormat pixelFormat = m_context.getRenderTarget().getPixelFormat();
1044*35238bceSAndroid Build Coastguard Worker const int colorErrorBits = 1;
1045*35238bceSAndroid Build Coastguard Worker const tcu::IVec4 nonShadowBits =
1046*35238bceSAndroid Build Coastguard Worker tcu::max(glu::TextureTestUtil::getBitsVec(pixelFormat) - tcu::IVec4(colorErrorBits), tcu::IVec4(0));
1047*35238bceSAndroid Build Coastguard Worker const tcu::Vec3 nonShadowThreshold = tcu::computeFixedPointThreshold(nonShadowBits).swizzle(1, 2, 3);
1048*35238bceSAndroid Build Coastguard Worker std::vector<tcu::ConstPixelBufferAccess> srcLevelStorage;
1049*35238bceSAndroid Build Coastguard Worker const tcu::Texture2DView effectiveView =
1050*35238bceSAndroid Build Coastguard Worker tcu::getEffectiveTextureView(m_texture->getRefTexture(), srcLevelStorage, samplerParams.sampler);
1051*35238bceSAndroid Build Coastguard Worker tcu::Surface reference(renderedFrame.getWidth(), renderedFrame.getHeight());
1052*35238bceSAndroid Build Coastguard Worker tcu::Surface errorMask(renderedFrame.getWidth(), renderedFrame.getHeight());
1053*35238bceSAndroid Build Coastguard Worker int numFailedPixels;
1054*35238bceSAndroid Build Coastguard Worker
1055*35238bceSAndroid Build Coastguard Worker glu::TextureTestUtil::sampleTexture(tcu::SurfaceAccess(reference, pixelFormat), effectiveView, texCoord,
1056*35238bceSAndroid Build Coastguard Worker samplerParams);
1057*35238bceSAndroid Build Coastguard Worker
1058*35238bceSAndroid Build Coastguard Worker numFailedPixels = glu::TextureTestUtil::computeTextureCompareDiff(
1059*35238bceSAndroid Build Coastguard Worker renderedFrame, reference.getAccess(), errorMask.getAccess(), effectiveView, texCoord, samplerParams,
1060*35238bceSAndroid Build Coastguard Worker texComparePrecision, lodPrecision, nonShadowThreshold);
1061*35238bceSAndroid Build Coastguard Worker
1062*35238bceSAndroid Build Coastguard Worker if (numFailedPixels > 0)
1063*35238bceSAndroid Build Coastguard Worker {
1064*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::Message
1065*35238bceSAndroid Build Coastguard Worker << "Warning: Verification assuming high-quality PCF filtering failed."
1066*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
1067*35238bceSAndroid Build Coastguard Worker
1068*35238bceSAndroid Build Coastguard Worker numFailedPixels = glu::TextureTestUtil::computeTextureCompareDiff(
1069*35238bceSAndroid Build Coastguard Worker renderedFrame, reference.getAccess(), errorMask.getAccess(), effectiveView, texCoord, samplerParams,
1070*35238bceSAndroid Build Coastguard Worker lowQualityTexComparePrecision, lowQualityLodPrecision, nonShadowThreshold);
1071*35238bceSAndroid Build Coastguard Worker
1072*35238bceSAndroid Build Coastguard Worker if (numFailedPixels > 0)
1073*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::Message
1074*35238bceSAndroid Build Coastguard Worker << "ERROR: Verification against low precision requirements failed, failing test case."
1075*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
1076*35238bceSAndroid Build Coastguard Worker else if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
1077*35238bceSAndroid Build Coastguard Worker m_result.addResult(QP_TEST_RESULT_QUALITY_WARNING, "Low-quality result");
1078*35238bceSAndroid Build Coastguard Worker }
1079*35238bceSAndroid Build Coastguard Worker
1080*35238bceSAndroid Build Coastguard Worker if (numFailedPixels > 0)
1081*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::Message << "ERROR: Result verification failed, got " << numFailedPixels
1082*35238bceSAndroid Build Coastguard Worker << " invalid pixels!" << tcu::TestLog::EndMessage;
1083*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::ImageSet("VerifyResult", "Verification result")
1084*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Image("Rendered", "Rendered image", renderedFrame);
1085*35238bceSAndroid Build Coastguard Worker if (numFailedPixels > 0)
1086*35238bceSAndroid Build Coastguard Worker {
1087*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::Image("Reference", "Ideal reference image", reference)
1088*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Image("ErrorMask", "Error mask", errorMask);
1089*35238bceSAndroid Build Coastguard Worker }
1090*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::EndImageSet;
1091*35238bceSAndroid Build Coastguard Worker
1092*35238bceSAndroid Build Coastguard Worker return (numFailedPixels == 0);
1093*35238bceSAndroid Build Coastguard Worker }
1094*35238bceSAndroid Build Coastguard Worker
1095*35238bceSAndroid Build Coastguard Worker template <typename T>
triQuadInterpolate(const T (& values)[4],float xFactor,float yFactor)1096*35238bceSAndroid Build Coastguard Worker static inline T triQuadInterpolate(const T (&values)[4], float xFactor, float yFactor)
1097*35238bceSAndroid Build Coastguard Worker {
1098*35238bceSAndroid Build Coastguard Worker if (xFactor + yFactor < 1.0f)
1099*35238bceSAndroid Build Coastguard Worker return values[0] + (values[2] - values[0]) * xFactor + (values[1] - values[0]) * yFactor;
1100*35238bceSAndroid Build Coastguard Worker else
1101*35238bceSAndroid Build Coastguard Worker return values[3] + (values[1] - values[3]) * (1.0f - xFactor) + (values[2] - values[3]) * (1.0f - yFactor);
1102*35238bceSAndroid Build Coastguard Worker }
1103*35238bceSAndroid Build Coastguard Worker
verifyTextureGatherResult(const tcu::ConstPixelBufferAccess & renderedFrame,const float * texCoordArray,const glu::TextureTestUtil::ReferenceParams & samplerParams,const tcu::LookupPrecision & lookupPrecision)1104*35238bceSAndroid Build Coastguard Worker bool TextureBorderClampTest::verifyTextureGatherResult(const tcu::ConstPixelBufferAccess &renderedFrame,
1105*35238bceSAndroid Build Coastguard Worker const float *texCoordArray,
1106*35238bceSAndroid Build Coastguard Worker const glu::TextureTestUtil::ReferenceParams &samplerParams,
1107*35238bceSAndroid Build Coastguard Worker const tcu::LookupPrecision &lookupPrecision)
1108*35238bceSAndroid Build Coastguard Worker {
1109*35238bceSAndroid Build Coastguard Worker const tcu::Vec2 texCoords[4] = {
1110*35238bceSAndroid Build Coastguard Worker tcu::Vec2(texCoordArray[0], texCoordArray[1]),
1111*35238bceSAndroid Build Coastguard Worker tcu::Vec2(texCoordArray[2], texCoordArray[3]),
1112*35238bceSAndroid Build Coastguard Worker tcu::Vec2(texCoordArray[4], texCoordArray[5]),
1113*35238bceSAndroid Build Coastguard Worker tcu::Vec2(texCoordArray[6], texCoordArray[7]),
1114*35238bceSAndroid Build Coastguard Worker };
1115*35238bceSAndroid Build Coastguard Worker
1116*35238bceSAndroid Build Coastguard Worker const tcu::PixelFormat pixelFormat = m_context.getRenderTarget().getPixelFormat();
1117*35238bceSAndroid Build Coastguard Worker const uint8_t fbColormask = tcu::getColorMask(pixelFormat);
1118*35238bceSAndroid Build Coastguard Worker
1119*35238bceSAndroid Build Coastguard Worker std::vector<tcu::ConstPixelBufferAccess> srcLevelStorage;
1120*35238bceSAndroid Build Coastguard Worker const tcu::Texture2DView effectiveView =
1121*35238bceSAndroid Build Coastguard Worker tcu::getEffectiveTextureView(m_texture->getRefTexture(), srcLevelStorage, samplerParams.sampler);
1122*35238bceSAndroid Build Coastguard Worker
1123*35238bceSAndroid Build Coastguard Worker tcu::Surface reference(renderedFrame.getWidth(), renderedFrame.getHeight());
1124*35238bceSAndroid Build Coastguard Worker tcu::Surface errorMask(renderedFrame.getWidth(), renderedFrame.getHeight());
1125*35238bceSAndroid Build Coastguard Worker int numFailedPixels = 0;
1126*35238bceSAndroid Build Coastguard Worker
1127*35238bceSAndroid Build Coastguard Worker tcu::clear(errorMask.getAccess(), tcu::RGBA::green().toVec());
1128*35238bceSAndroid Build Coastguard Worker
1129*35238bceSAndroid Build Coastguard Worker for (int py = 0; py < reference.getHeight(); ++py)
1130*35238bceSAndroid Build Coastguard Worker for (int px = 0; px < reference.getWidth(); ++px)
1131*35238bceSAndroid Build Coastguard Worker {
1132*35238bceSAndroid Build Coastguard Worker const tcu::Vec2 viewportCoord = (tcu::Vec2((float)px, (float)py) + tcu::Vec2(0.5f)) /
1133*35238bceSAndroid Build Coastguard Worker tcu::Vec2((float)reference.getWidth(), (float)reference.getHeight());
1134*35238bceSAndroid Build Coastguard Worker const tcu::Vec2 texCoord = triQuadInterpolate(texCoords, viewportCoord.x(), viewportCoord.y());
1135*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 referenceValue = effectiveView.gatherOffsets(
1136*35238bceSAndroid Build Coastguard Worker samplerParams.sampler, texCoord.x(), texCoord.y(), 0, glu::getDefaultGatherOffsets());
1137*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 referencePixel = referenceValue * samplerParams.colorScale + samplerParams.colorBias;
1138*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 resultPixel = renderedFrame.getPixel(px, py);
1139*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 resultValue = (resultPixel - samplerParams.colorBias) / samplerParams.colorScale;
1140*35238bceSAndroid Build Coastguard Worker
1141*35238bceSAndroid Build Coastguard Worker reference.setPixel(px, py, tcu::toRGBAMasked(referenceValue, fbColormask));
1142*35238bceSAndroid Build Coastguard Worker
1143*35238bceSAndroid Build Coastguard Worker if (tcu::boolAny(tcu::logicalAnd(
1144*35238bceSAndroid Build Coastguard Worker lookupPrecision.colorMask,
1145*35238bceSAndroid Build Coastguard Worker tcu::greaterThan(tcu::absDiff(resultPixel, referencePixel), lookupPrecision.colorThreshold))))
1146*35238bceSAndroid Build Coastguard Worker {
1147*35238bceSAndroid Build Coastguard Worker if (!tcu::isGatherOffsetsResultValid(effectiveView, samplerParams.sampler, lookupPrecision, texCoord, 0,
1148*35238bceSAndroid Build Coastguard Worker glu::getDefaultGatherOffsets(), resultValue))
1149*35238bceSAndroid Build Coastguard Worker {
1150*35238bceSAndroid Build Coastguard Worker errorMask.setPixel(px, py, tcu::RGBA::red());
1151*35238bceSAndroid Build Coastguard Worker ++numFailedPixels;
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 if (numFailedPixels > 0)
1157*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::Message << "ERROR: Result verification failed, got " << numFailedPixels
1158*35238bceSAndroid Build Coastguard Worker << " invalid pixels!" << tcu::TestLog::EndMessage;
1159*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::ImageSet("VerifyResult", "Verification result")
1160*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Image("Rendered", "Rendered image", renderedFrame);
1161*35238bceSAndroid Build Coastguard Worker if (numFailedPixels > 0)
1162*35238bceSAndroid Build Coastguard Worker {
1163*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::Image("Reference", "Ideal reference image", reference)
1164*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Image("ErrorMask", "Error mask", errorMask);
1165*35238bceSAndroid Build Coastguard Worker }
1166*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::EndImageSet;
1167*35238bceSAndroid Build Coastguard Worker
1168*35238bceSAndroid Build Coastguard Worker return (numFailedPixels == 0);
1169*35238bceSAndroid Build Coastguard Worker }
1170*35238bceSAndroid Build Coastguard Worker
verifyTextureGatherCmpResult(const tcu::ConstPixelBufferAccess & renderedFrame,const float * texCoordArray,const glu::TextureTestUtil::ReferenceParams & samplerParams,const tcu::TexComparePrecision & texComparePrecision,const tcu::TexComparePrecision & lowQualityTexComparePrecision)1171*35238bceSAndroid Build Coastguard Worker bool TextureBorderClampTest::verifyTextureGatherCmpResult(const tcu::ConstPixelBufferAccess &renderedFrame,
1172*35238bceSAndroid Build Coastguard Worker const float *texCoordArray,
1173*35238bceSAndroid Build Coastguard Worker const glu::TextureTestUtil::ReferenceParams &samplerParams,
1174*35238bceSAndroid Build Coastguard Worker const tcu::TexComparePrecision &texComparePrecision,
1175*35238bceSAndroid Build Coastguard Worker const tcu::TexComparePrecision &lowQualityTexComparePrecision)
1176*35238bceSAndroid Build Coastguard Worker {
1177*35238bceSAndroid Build Coastguard Worker const tcu::Vec2 texCoords[4] = {
1178*35238bceSAndroid Build Coastguard Worker tcu::Vec2(texCoordArray[0], texCoordArray[1]),
1179*35238bceSAndroid Build Coastguard Worker tcu::Vec2(texCoordArray[2], texCoordArray[3]),
1180*35238bceSAndroid Build Coastguard Worker tcu::Vec2(texCoordArray[4], texCoordArray[5]),
1181*35238bceSAndroid Build Coastguard Worker tcu::Vec2(texCoordArray[6], texCoordArray[7]),
1182*35238bceSAndroid Build Coastguard Worker };
1183*35238bceSAndroid Build Coastguard Worker
1184*35238bceSAndroid Build Coastguard Worker std::vector<tcu::ConstPixelBufferAccess> srcLevelStorage;
1185*35238bceSAndroid Build Coastguard Worker const tcu::Texture2DView effectiveView =
1186*35238bceSAndroid Build Coastguard Worker tcu::getEffectiveTextureView(m_texture->getRefTexture(), srcLevelStorage, samplerParams.sampler);
1187*35238bceSAndroid Build Coastguard Worker
1188*35238bceSAndroid Build Coastguard Worker const tcu::PixelFormat pixelFormat = m_context.getRenderTarget().getPixelFormat();
1189*35238bceSAndroid Build Coastguard Worker const tcu::BVec4 colorMask = glu::TextureTestUtil::getCompareMask(pixelFormat);
1190*35238bceSAndroid Build Coastguard Worker const uint8_t fbColormask = tcu::getColorMask(pixelFormat);
1191*35238bceSAndroid Build Coastguard Worker tcu::Surface reference(renderedFrame.getWidth(), renderedFrame.getHeight());
1192*35238bceSAndroid Build Coastguard Worker tcu::Surface errorMask(renderedFrame.getWidth(), renderedFrame.getHeight());
1193*35238bceSAndroid Build Coastguard Worker int numFailedPixels = 0;
1194*35238bceSAndroid Build Coastguard Worker bool lowQuality = false;
1195*35238bceSAndroid Build Coastguard Worker
1196*35238bceSAndroid Build Coastguard Worker tcu::clear(errorMask.getAccess(), tcu::RGBA::green().toVec());
1197*35238bceSAndroid Build Coastguard Worker
1198*35238bceSAndroid Build Coastguard Worker for (int py = 0; py < reference.getHeight(); ++py)
1199*35238bceSAndroid Build Coastguard Worker for (int px = 0; px < reference.getWidth(); ++px)
1200*35238bceSAndroid Build Coastguard Worker {
1201*35238bceSAndroid Build Coastguard Worker const tcu::Vec2 viewportCoord = (tcu::Vec2((float)px, (float)py) + tcu::Vec2(0.5f)) /
1202*35238bceSAndroid Build Coastguard Worker tcu::Vec2((float)reference.getWidth(), (float)reference.getHeight());
1203*35238bceSAndroid Build Coastguard Worker const tcu::Vec2 texCoord = triQuadInterpolate(texCoords, viewportCoord.x(), viewportCoord.y());
1204*35238bceSAndroid Build Coastguard Worker const float refZ = samplerParams.ref;
1205*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 referenceValue = effectiveView.gatherOffsetsCompare(
1206*35238bceSAndroid Build Coastguard Worker samplerParams.sampler, refZ, texCoord.x(), texCoord.y(), glu::getDefaultGatherOffsets());
1207*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 resultValue = renderedFrame.getPixel(px, py);
1208*35238bceSAndroid Build Coastguard Worker
1209*35238bceSAndroid Build Coastguard Worker reference.setPixel(px, py, tcu::toRGBAMasked(referenceValue, fbColormask));
1210*35238bceSAndroid Build Coastguard Worker
1211*35238bceSAndroid Build Coastguard Worker if (tcu::boolAny(tcu::logicalAnd(colorMask, tcu::notEqual(referenceValue, resultValue))))
1212*35238bceSAndroid Build Coastguard Worker {
1213*35238bceSAndroid Build Coastguard Worker if (!tcu::isGatherOffsetsCompareResultValid(effectiveView, samplerParams.sampler, texComparePrecision,
1214*35238bceSAndroid Build Coastguard Worker texCoord, glu::getDefaultGatherOffsets(), refZ,
1215*35238bceSAndroid Build Coastguard Worker resultValue))
1216*35238bceSAndroid Build Coastguard Worker {
1217*35238bceSAndroid Build Coastguard Worker lowQuality = true;
1218*35238bceSAndroid Build Coastguard Worker
1219*35238bceSAndroid Build Coastguard Worker // fall back to low quality verification
1220*35238bceSAndroid Build Coastguard Worker if (!tcu::isGatherOffsetsCompareResultValid(effectiveView, samplerParams.sampler,
1221*35238bceSAndroid Build Coastguard Worker lowQualityTexComparePrecision, texCoord,
1222*35238bceSAndroid Build Coastguard Worker glu::getDefaultGatherOffsets(), refZ, resultValue))
1223*35238bceSAndroid Build Coastguard Worker {
1224*35238bceSAndroid Build Coastguard Worker errorMask.setPixel(px, py, tcu::RGBA::red());
1225*35238bceSAndroid Build Coastguard Worker ++numFailedPixels;
1226*35238bceSAndroid Build Coastguard Worker }
1227*35238bceSAndroid Build Coastguard Worker }
1228*35238bceSAndroid Build Coastguard Worker }
1229*35238bceSAndroid Build Coastguard Worker }
1230*35238bceSAndroid Build Coastguard Worker
1231*35238bceSAndroid Build Coastguard Worker if (numFailedPixels > 0)
1232*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::Message << "ERROR: Result verification failed, got " << numFailedPixels
1233*35238bceSAndroid Build Coastguard Worker << " invalid pixels!" << tcu::TestLog::EndMessage;
1234*35238bceSAndroid Build Coastguard Worker else if (lowQuality)
1235*35238bceSAndroid Build Coastguard Worker {
1236*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::Message
1237*35238bceSAndroid Build Coastguard Worker << "Warning: Verification assuming high-quality PCF filtering failed."
1238*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
1239*35238bceSAndroid Build Coastguard Worker m_result.addResult(QP_TEST_RESULT_QUALITY_WARNING, "Low-quality result");
1240*35238bceSAndroid Build Coastguard Worker }
1241*35238bceSAndroid Build Coastguard Worker
1242*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::ImageSet("VerifyResult", "Verification result")
1243*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Image("Rendered", "Rendered image", renderedFrame);
1244*35238bceSAndroid Build Coastguard Worker if (numFailedPixels > 0)
1245*35238bceSAndroid Build Coastguard Worker {
1246*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::Image("Reference", "Ideal reference image", reference)
1247*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Image("ErrorMask", "Error mask", errorMask);
1248*35238bceSAndroid Build Coastguard Worker }
1249*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::EndImageSet;
1250*35238bceSAndroid Build Coastguard Worker
1251*35238bceSAndroid Build Coastguard Worker return (numFailedPixels == 0);
1252*35238bceSAndroid Build Coastguard Worker }
1253*35238bceSAndroid Build Coastguard Worker
getTexture(void) const1254*35238bceSAndroid Build Coastguard Worker const glu::Texture2D *TextureBorderClampTest::getTexture(void) const
1255*35238bceSAndroid Build Coastguard Worker {
1256*35238bceSAndroid Build Coastguard Worker return m_texture.get();
1257*35238bceSAndroid Build Coastguard Worker }
1258*35238bceSAndroid Build Coastguard Worker
getIterationSeed(const IterationConfig & config) const1259*35238bceSAndroid Build Coastguard Worker uint32_t TextureBorderClampTest::getIterationSeed(const IterationConfig &config) const
1260*35238bceSAndroid Build Coastguard Worker {
1261*35238bceSAndroid Build Coastguard Worker tcu::SeedBuilder builder;
1262*35238bceSAndroid Build Coastguard Worker builder << std::string(getName()) << m_iterationNdx << m_texFormat << config.minFilter << config.magFilter
1263*35238bceSAndroid Build Coastguard Worker << m_texture->getRefTexture().getWidth() << m_texture->getRefTexture().getHeight();
1264*35238bceSAndroid Build Coastguard Worker return builder.get();
1265*35238bceSAndroid Build Coastguard Worker }
1266*35238bceSAndroid Build Coastguard Worker
genSamplerParams(const IterationConfig & config) const1267*35238bceSAndroid Build Coastguard Worker glu::TextureTestUtil::ReferenceParams TextureBorderClampTest::genSamplerParams(const IterationConfig &config) const
1268*35238bceSAndroid Build Coastguard Worker {
1269*35238bceSAndroid Build Coastguard Worker const tcu::TextureFormat texFormat =
1270*35238bceSAndroid Build Coastguard Worker tcu::getEffectiveDepthStencilTextureFormat(m_texture->getRefTexture().getFormat(), m_sampleMode);
1271*35238bceSAndroid Build Coastguard Worker glu::TextureTestUtil::ReferenceParams refParams(glu::TextureTestUtil::TEXTURETYPE_2D);
1272*35238bceSAndroid Build Coastguard Worker
1273*35238bceSAndroid Build Coastguard Worker refParams.sampler = glu::mapGLSampler(config.sWrapMode, config.tWrapMode, config.minFilter, config.magFilter);
1274*35238bceSAndroid Build Coastguard Worker refParams.sampler.borderColor = config.borderColor;
1275*35238bceSAndroid Build Coastguard Worker refParams.sampler.compare =
1276*35238bceSAndroid Build Coastguard Worker (!m_useShadowSampler) ? (tcu::Sampler::COMPAREMODE_NONE) : (glu::mapGLCompareFunc(config.compareMode));
1277*35238bceSAndroid Build Coastguard Worker refParams.sampler.depthStencilMode = m_sampleMode;
1278*35238bceSAndroid Build Coastguard Worker refParams.lodMode = glu::TextureTestUtil::LODMODE_EXACT;
1279*35238bceSAndroid Build Coastguard Worker refParams.samplerType = (!m_useShadowSampler) ? (glu::TextureTestUtil::getSamplerType(texFormat)) :
1280*35238bceSAndroid Build Coastguard Worker (glu::TextureTestUtil::SAMPLERTYPE_SHADOW);
1281*35238bceSAndroid Build Coastguard Worker refParams.colorScale = config.lookupScale;
1282*35238bceSAndroid Build Coastguard Worker refParams.colorBias = config.lookupBias;
1283*35238bceSAndroid Build Coastguard Worker refParams.ref = config.compareRef;
1284*35238bceSAndroid Build Coastguard Worker
1285*35238bceSAndroid Build Coastguard Worker // compare can only be used with depth textures
1286*35238bceSAndroid Build Coastguard Worker if (!isDepthFormat(m_texFormat, m_sampleMode))
1287*35238bceSAndroid Build Coastguard Worker DE_ASSERT(refParams.sampler.compare == tcu::Sampler::COMPAREMODE_NONE);
1288*35238bceSAndroid Build Coastguard Worker
1289*35238bceSAndroid Build Coastguard Worker // sampler type must match compare mode
1290*35238bceSAndroid Build Coastguard Worker DE_ASSERT(m_useShadowSampler == (config.compareMode != GL_NONE));
1291*35238bceSAndroid Build Coastguard Worker
1292*35238bceSAndroid Build Coastguard Worker // in gather, weird mapping is most likely an error
1293*35238bceSAndroid Build Coastguard Worker if (m_samplingFunction == SAMPLE_GATHER)
1294*35238bceSAndroid Build Coastguard Worker {
1295*35238bceSAndroid Build Coastguard Worker DE_ASSERT(refParams.colorScale == tcu::Vec4(refParams.colorScale.x()));
1296*35238bceSAndroid Build Coastguard Worker DE_ASSERT(refParams.colorBias == tcu::Vec4(refParams.colorBias.x()));
1297*35238bceSAndroid Build Coastguard Worker }
1298*35238bceSAndroid Build Coastguard Worker
1299*35238bceSAndroid Build Coastguard Worker return refParams;
1300*35238bceSAndroid Build Coastguard Worker }
1301*35238bceSAndroid Build Coastguard Worker
genGatherProgram(void) const1302*35238bceSAndroid Build Coastguard Worker glu::ShaderProgram *TextureBorderClampTest::genGatherProgram(void) const
1303*35238bceSAndroid Build Coastguard Worker {
1304*35238bceSAndroid Build Coastguard Worker const std::string glslVersionDecl =
1305*35238bceSAndroid Build Coastguard Worker glu::getGLSLVersionDeclaration(glu::getContextTypeGLSLVersion(m_context.getRenderContext().getType()));
1306*35238bceSAndroid Build Coastguard Worker const std::string vtxSource = glslVersionDecl + "\n"
1307*35238bceSAndroid Build Coastguard Worker "in highp vec4 a_position;\n"
1308*35238bceSAndroid Build Coastguard Worker "in highp vec2 a_texcoord;\n"
1309*35238bceSAndroid Build Coastguard Worker "out highp vec2 v_texcoord;\n"
1310*35238bceSAndroid Build Coastguard Worker "void main()\n"
1311*35238bceSAndroid Build Coastguard Worker "{\n"
1312*35238bceSAndroid Build Coastguard Worker " gl_Position = a_position;\n"
1313*35238bceSAndroid Build Coastguard Worker " v_texcoord = a_texcoord;\n"
1314*35238bceSAndroid Build Coastguard Worker "}\n";
1315*35238bceSAndroid Build Coastguard Worker const char *samplerType;
1316*35238bceSAndroid Build Coastguard Worker const char *lookup;
1317*35238bceSAndroid Build Coastguard Worker std::ostringstream fragSource;
1318*35238bceSAndroid Build Coastguard Worker
1319*35238bceSAndroid Build Coastguard Worker if (m_useShadowSampler)
1320*35238bceSAndroid Build Coastguard Worker {
1321*35238bceSAndroid Build Coastguard Worker samplerType = "sampler2DShadow";
1322*35238bceSAndroid Build Coastguard Worker lookup = "textureGather(u_sampler, v_texcoord, u_ref)";
1323*35238bceSAndroid Build Coastguard Worker }
1324*35238bceSAndroid Build Coastguard Worker else
1325*35238bceSAndroid Build Coastguard Worker {
1326*35238bceSAndroid Build Coastguard Worker switch (m_channelClass)
1327*35238bceSAndroid Build Coastguard Worker {
1328*35238bceSAndroid Build Coastguard Worker case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
1329*35238bceSAndroid Build Coastguard Worker case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
1330*35238bceSAndroid Build Coastguard Worker case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
1331*35238bceSAndroid Build Coastguard Worker samplerType = "sampler2D";
1332*35238bceSAndroid Build Coastguard Worker lookup = "textureGather(u_sampler, v_texcoord)";
1333*35238bceSAndroid Build Coastguard Worker break;
1334*35238bceSAndroid Build Coastguard Worker
1335*35238bceSAndroid Build Coastguard Worker case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
1336*35238bceSAndroid Build Coastguard Worker samplerType = "isampler2D";
1337*35238bceSAndroid Build Coastguard Worker lookup = "vec4(textureGather(u_sampler, v_texcoord))";
1338*35238bceSAndroid Build Coastguard Worker break;
1339*35238bceSAndroid Build Coastguard Worker
1340*35238bceSAndroid Build Coastguard Worker case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
1341*35238bceSAndroid Build Coastguard Worker samplerType = "usampler2D";
1342*35238bceSAndroid Build Coastguard Worker lookup = "vec4(textureGather(u_sampler, v_texcoord))";
1343*35238bceSAndroid Build Coastguard Worker break;
1344*35238bceSAndroid Build Coastguard Worker
1345*35238bceSAndroid Build Coastguard Worker default:
1346*35238bceSAndroid Build Coastguard Worker samplerType = "";
1347*35238bceSAndroid Build Coastguard Worker lookup = "";
1348*35238bceSAndroid Build Coastguard Worker DE_ASSERT(false);
1349*35238bceSAndroid Build Coastguard Worker }
1350*35238bceSAndroid Build Coastguard Worker }
1351*35238bceSAndroid Build Coastguard Worker
1352*35238bceSAndroid Build Coastguard Worker fragSource << glslVersionDecl + "\n"
1353*35238bceSAndroid Build Coastguard Worker "uniform highp "
1354*35238bceSAndroid Build Coastguard Worker << samplerType
1355*35238bceSAndroid Build Coastguard Worker << " u_sampler;\n"
1356*35238bceSAndroid Build Coastguard Worker "uniform highp vec4 u_colorScale;\n"
1357*35238bceSAndroid Build Coastguard Worker "uniform highp vec4 u_colorBias;\n"
1358*35238bceSAndroid Build Coastguard Worker << ((m_useShadowSampler) ? ("uniform highp float u_ref;\n") : (""))
1359*35238bceSAndroid Build Coastguard Worker << "in highp vec2 v_texcoord;\n"
1360*35238bceSAndroid Build Coastguard Worker "layout(location=0) out highp vec4 o_color;\n"
1361*35238bceSAndroid Build Coastguard Worker "void main()\n"
1362*35238bceSAndroid Build Coastguard Worker "{\n"
1363*35238bceSAndroid Build Coastguard Worker " o_color = "
1364*35238bceSAndroid Build Coastguard Worker << lookup
1365*35238bceSAndroid Build Coastguard Worker << " * u_colorScale + u_colorBias;\n"
1366*35238bceSAndroid Build Coastguard Worker "}\n";
1367*35238bceSAndroid Build Coastguard Worker
1368*35238bceSAndroid Build Coastguard Worker return new glu::ShaderProgram(m_context.getRenderContext(), glu::ProgramSources()
1369*35238bceSAndroid Build Coastguard Worker << glu::VertexSource(vtxSource)
1370*35238bceSAndroid Build Coastguard Worker << glu::FragmentSource(fragSource.str()));
1371*35238bceSAndroid Build Coastguard Worker }
1372*35238bceSAndroid Build Coastguard Worker
1373*35238bceSAndroid Build Coastguard Worker class TextureBorderClampFormatCase : public TextureBorderClampTest
1374*35238bceSAndroid Build Coastguard Worker {
1375*35238bceSAndroid Build Coastguard Worker public:
1376*35238bceSAndroid Build Coastguard Worker TextureBorderClampFormatCase(Context &context, const char *name, const char *description, uint32_t texFormat,
1377*35238bceSAndroid Build Coastguard Worker tcu::Sampler::DepthStencilMode mode, StateType stateType, SizeType sizeType,
1378*35238bceSAndroid Build Coastguard Worker uint32_t filter, SamplingFunction samplingFunction);
1379*35238bceSAndroid Build Coastguard Worker
1380*35238bceSAndroid Build Coastguard Worker private:
1381*35238bceSAndroid Build Coastguard Worker void init(void);
1382*35238bceSAndroid Build Coastguard Worker
1383*35238bceSAndroid Build Coastguard Worker int getNumIterations(void) const;
1384*35238bceSAndroid Build Coastguard Worker IterationConfig getIteration(int ndx) const;
1385*35238bceSAndroid Build Coastguard Worker
1386*35238bceSAndroid Build Coastguard Worker const SizeType m_sizeType;
1387*35238bceSAndroid Build Coastguard Worker
1388*35238bceSAndroid Build Coastguard Worker std::vector<IterationConfig> m_iterations;
1389*35238bceSAndroid Build Coastguard Worker };
1390*35238bceSAndroid Build Coastguard Worker
TextureBorderClampFormatCase(Context & context,const char * name,const char * description,uint32_t texFormat,tcu::Sampler::DepthStencilMode mode,StateType stateType,SizeType sizeType,uint32_t filter,SamplingFunction samplingFunction)1391*35238bceSAndroid Build Coastguard Worker TextureBorderClampFormatCase::TextureBorderClampFormatCase(Context &context, const char *name, const char *description,
1392*35238bceSAndroid Build Coastguard Worker uint32_t texFormat, tcu::Sampler::DepthStencilMode mode,
1393*35238bceSAndroid Build Coastguard Worker StateType stateType, SizeType sizeType, uint32_t filter,
1394*35238bceSAndroid Build Coastguard Worker SamplingFunction samplingFunction)
1395*35238bceSAndroid Build Coastguard Worker : TextureBorderClampTest(context, name, description, texFormat, mode, stateType,
1396*35238bceSAndroid Build Coastguard Worker (sizeType == SIZE_POT) ? (32) : (17), (sizeType == SIZE_POT) ? (16) : (31),
1397*35238bceSAndroid Build Coastguard Worker samplingFunction, filter, FLAG_TEST_FLOAT_FILTERABLE)
1398*35238bceSAndroid Build Coastguard Worker , m_sizeType(sizeType)
1399*35238bceSAndroid Build Coastguard Worker {
1400*35238bceSAndroid Build Coastguard Worker if (m_sizeType == SIZE_POT)
1401*35238bceSAndroid Build Coastguard Worker DE_ASSERT(deIsPowerOfTwo32(m_texWidth) && deIsPowerOfTwo32(m_texHeight));
1402*35238bceSAndroid Build Coastguard Worker else
1403*35238bceSAndroid Build Coastguard Worker DE_ASSERT(!deIsPowerOfTwo32(m_texWidth) && !deIsPowerOfTwo32(m_texHeight));
1404*35238bceSAndroid Build Coastguard Worker
1405*35238bceSAndroid Build Coastguard Worker if (glu::isCompressedFormat(texFormat))
1406*35238bceSAndroid Build Coastguard Worker {
1407*35238bceSAndroid Build Coastguard Worker const tcu::CompressedTexFormat compressedFormat = glu::mapGLCompressedTexFormat(texFormat);
1408*35238bceSAndroid Build Coastguard Worker const tcu::IVec3 blockPixelSize = tcu::getBlockPixelSize(compressedFormat);
1409*35238bceSAndroid Build Coastguard Worker
1410*35238bceSAndroid Build Coastguard Worker // is (not) multiple of a block size
1411*35238bceSAndroid Build Coastguard Worker if (m_sizeType == SIZE_POT)
1412*35238bceSAndroid Build Coastguard Worker DE_ASSERT((m_texWidth % blockPixelSize.x()) == 0 && (m_texHeight % blockPixelSize.y()) == 0);
1413*35238bceSAndroid Build Coastguard Worker else
1414*35238bceSAndroid Build Coastguard Worker DE_ASSERT((m_texWidth % blockPixelSize.x()) != 0 && (m_texHeight % blockPixelSize.y()) != 0);
1415*35238bceSAndroid Build Coastguard Worker
1416*35238bceSAndroid Build Coastguard Worker DE_UNREF(blockPixelSize);
1417*35238bceSAndroid Build Coastguard Worker }
1418*35238bceSAndroid Build Coastguard Worker }
1419*35238bceSAndroid Build Coastguard Worker
init(void)1420*35238bceSAndroid Build Coastguard Worker void TextureBorderClampFormatCase::init(void)
1421*35238bceSAndroid Build Coastguard Worker {
1422*35238bceSAndroid Build Coastguard Worker TextureBorderClampTest::init();
1423*35238bceSAndroid Build Coastguard Worker
1424*35238bceSAndroid Build Coastguard Worker // \note TextureBorderClampTest::init() creates texture
1425*35238bceSAndroid Build Coastguard Worker const tcu::TextureFormat texFormat =
1426*35238bceSAndroid Build Coastguard Worker tcu::getEffectiveDepthStencilTextureFormat(getTexture()->getRefTexture().getFormat(), m_sampleMode);
1427*35238bceSAndroid Build Coastguard Worker const tcu::TextureFormatInfo texFormatInfo = tcu::getTextureFormatInfo(texFormat);
1428*35238bceSAndroid Build Coastguard Worker
1429*35238bceSAndroid Build Coastguard Worker // iterations
1430*35238bceSAndroid Build Coastguard Worker
1431*35238bceSAndroid Build Coastguard Worker {
1432*35238bceSAndroid Build Coastguard Worker IterationConfig iteration;
1433*35238bceSAndroid Build Coastguard Worker iteration.p0 = tcu::Vec2(-1.5f, -3.0f);
1434*35238bceSAndroid Build Coastguard Worker iteration.p1 = tcu::Vec2(1.5f, 2.5f);
1435*35238bceSAndroid Build Coastguard Worker iteration.borderColor = mapToFormatColorRepresentable(texFormat, tcu::Vec4(0.3f, 0.7f, 0.2f, 0.5f));
1436*35238bceSAndroid Build Coastguard Worker m_iterations.push_back(iteration);
1437*35238bceSAndroid Build Coastguard Worker }
1438*35238bceSAndroid Build Coastguard Worker {
1439*35238bceSAndroid Build Coastguard Worker IterationConfig iteration;
1440*35238bceSAndroid Build Coastguard Worker iteration.p0 = tcu::Vec2(-0.5f, 0.75f);
1441*35238bceSAndroid Build Coastguard Worker iteration.p1 = tcu::Vec2(0.25f, 1.25f);
1442*35238bceSAndroid Build Coastguard Worker iteration.borderColor = mapToFormatColorRepresentable(texFormat, tcu::Vec4(0.9f, 0.2f, 0.4f, 0.6f));
1443*35238bceSAndroid Build Coastguard Worker m_iterations.push_back(iteration);
1444*35238bceSAndroid Build Coastguard Worker }
1445*35238bceSAndroid Build Coastguard Worker
1446*35238bceSAndroid Build Coastguard Worker // common parameters
1447*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < (int)m_iterations.size(); ++ndx)
1448*35238bceSAndroid Build Coastguard Worker {
1449*35238bceSAndroid Build Coastguard Worker IterationConfig &iteration = m_iterations[ndx];
1450*35238bceSAndroid Build Coastguard Worker
1451*35238bceSAndroid Build Coastguard Worker if (m_samplingFunction == SAMPLE_GATHER)
1452*35238bceSAndroid Build Coastguard Worker {
1453*35238bceSAndroid Build Coastguard Worker iteration.lookupScale = tcu::Vec4(texFormatInfo.lookupScale.x());
1454*35238bceSAndroid Build Coastguard Worker iteration.lookupBias = tcu::Vec4(texFormatInfo.lookupBias.x());
1455*35238bceSAndroid Build Coastguard Worker }
1456*35238bceSAndroid Build Coastguard Worker else
1457*35238bceSAndroid Build Coastguard Worker {
1458*35238bceSAndroid Build Coastguard Worker iteration.lookupScale = texFormatInfo.lookupScale;
1459*35238bceSAndroid Build Coastguard Worker iteration.lookupBias = texFormatInfo.lookupBias;
1460*35238bceSAndroid Build Coastguard Worker }
1461*35238bceSAndroid Build Coastguard Worker
1462*35238bceSAndroid Build Coastguard Worker iteration.minFilter = m_filter;
1463*35238bceSAndroid Build Coastguard Worker iteration.magFilter = m_filter;
1464*35238bceSAndroid Build Coastguard Worker iteration.sWrapMode = GL_CLAMP_TO_BORDER;
1465*35238bceSAndroid Build Coastguard Worker iteration.tWrapMode = GL_CLAMP_TO_BORDER;
1466*35238bceSAndroid Build Coastguard Worker iteration.compareMode = GL_NONE;
1467*35238bceSAndroid Build Coastguard Worker iteration.compareRef = 0.0f;
1468*35238bceSAndroid Build Coastguard Worker }
1469*35238bceSAndroid Build Coastguard Worker }
1470*35238bceSAndroid Build Coastguard Worker
getNumIterations(void) const1471*35238bceSAndroid Build Coastguard Worker int TextureBorderClampFormatCase::getNumIterations(void) const
1472*35238bceSAndroid Build Coastguard Worker {
1473*35238bceSAndroid Build Coastguard Worker return (int)m_iterations.size();
1474*35238bceSAndroid Build Coastguard Worker }
1475*35238bceSAndroid Build Coastguard Worker
getIteration(int ndx) const1476*35238bceSAndroid Build Coastguard Worker TextureBorderClampTest::IterationConfig TextureBorderClampFormatCase::getIteration(int ndx) const
1477*35238bceSAndroid Build Coastguard Worker {
1478*35238bceSAndroid Build Coastguard Worker return m_iterations[ndx];
1479*35238bceSAndroid Build Coastguard Worker }
1480*35238bceSAndroid Build Coastguard Worker
1481*35238bceSAndroid Build Coastguard Worker class TextureBorderClampRangeClampCase : public TextureBorderClampTest
1482*35238bceSAndroid Build Coastguard Worker {
1483*35238bceSAndroid Build Coastguard Worker public:
1484*35238bceSAndroid Build Coastguard Worker TextureBorderClampRangeClampCase(Context &context, const char *name, const char *description, uint32_t texFormat,
1485*35238bceSAndroid Build Coastguard Worker tcu::Sampler::DepthStencilMode mode, uint32_t filter);
1486*35238bceSAndroid Build Coastguard Worker
1487*35238bceSAndroid Build Coastguard Worker private:
1488*35238bceSAndroid Build Coastguard Worker void init(void);
1489*35238bceSAndroid Build Coastguard Worker
1490*35238bceSAndroid Build Coastguard Worker int getNumIterations(void) const;
1491*35238bceSAndroid Build Coastguard Worker IterationConfig getIteration(int ndx) const;
1492*35238bceSAndroid Build Coastguard Worker
1493*35238bceSAndroid Build Coastguard Worker std::vector<IterationConfig> m_iterations;
1494*35238bceSAndroid Build Coastguard Worker };
1495*35238bceSAndroid Build Coastguard Worker
TextureBorderClampRangeClampCase(Context & context,const char * name,const char * description,uint32_t texFormat,tcu::Sampler::DepthStencilMode mode,uint32_t filter)1496*35238bceSAndroid Build Coastguard Worker TextureBorderClampRangeClampCase::TextureBorderClampRangeClampCase(Context &context, const char *name,
1497*35238bceSAndroid Build Coastguard Worker const char *description, uint32_t texFormat,
1498*35238bceSAndroid Build Coastguard Worker tcu::Sampler::DepthStencilMode mode, uint32_t filter)
1499*35238bceSAndroid Build Coastguard Worker : TextureBorderClampTest(context, name, description, texFormat, mode, TextureBorderClampTest::STATE_TEXTURE_PARAM,
1500*35238bceSAndroid Build Coastguard Worker 8, 32, SAMPLE_FILTER, filter, FLAG_TEST_FLOAT_FILTERABLE)
1501*35238bceSAndroid Build Coastguard Worker {
1502*35238bceSAndroid Build Coastguard Worker }
1503*35238bceSAndroid Build Coastguard Worker
init(void)1504*35238bceSAndroid Build Coastguard Worker void TextureBorderClampRangeClampCase::init(void)
1505*35238bceSAndroid Build Coastguard Worker {
1506*35238bceSAndroid Build Coastguard Worker TextureBorderClampTest::init();
1507*35238bceSAndroid Build Coastguard Worker
1508*35238bceSAndroid Build Coastguard Worker const tcu::TextureFormat texFormat =
1509*35238bceSAndroid Build Coastguard Worker tcu::getEffectiveDepthStencilTextureFormat(getTexture()->getRefTexture().getFormat(), m_sampleMode);
1510*35238bceSAndroid Build Coastguard Worker const bool isDepth = isDepthFormat(m_texFormat, m_sampleMode);
1511*35238bceSAndroid Build Coastguard Worker const bool isFloat = m_channelClass == tcu::TEXTURECHANNELCLASS_FLOATING_POINT;
1512*35238bceSAndroid Build Coastguard Worker const bool isFixed = m_channelClass == tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT ||
1513*35238bceSAndroid Build Coastguard Worker m_channelClass == tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT;
1514*35238bceSAndroid Build Coastguard Worker const bool isPureInteger = m_channelClass == tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER ||
1515*35238bceSAndroid Build Coastguard Worker m_channelClass == tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER;
1516*35238bceSAndroid Build Coastguard Worker
1517*35238bceSAndroid Build Coastguard Worker if (isDepth || isFloat)
1518*35238bceSAndroid Build Coastguard Worker {
1519*35238bceSAndroid Build Coastguard Worker // infinities are commonly used values on depth/float borders
1520*35238bceSAndroid Build Coastguard Worker {
1521*35238bceSAndroid Build Coastguard Worker IterationConfig iteration;
1522*35238bceSAndroid Build Coastguard Worker iteration.p0 = tcu::Vec2(-1.2f, -3.0f);
1523*35238bceSAndroid Build Coastguard Worker iteration.p1 = tcu::Vec2(1.2f, 2.5f);
1524*35238bceSAndroid Build Coastguard Worker iteration.borderColor = rr::GenericVec4(tcu::Vec4(std::numeric_limits<float>::infinity()));
1525*35238bceSAndroid Build Coastguard Worker iteration.lookupScale =
1526*35238bceSAndroid Build Coastguard Worker tcu::Vec4(0.5f); // scale & bias to [0.25, 0.5] range to make out-of-range values visible
1527*35238bceSAndroid Build Coastguard Worker iteration.lookupBias = tcu::Vec4(0.25f);
1528*35238bceSAndroid Build Coastguard Worker iteration.description = "border value infinity";
1529*35238bceSAndroid Build Coastguard Worker m_iterations.push_back(iteration);
1530*35238bceSAndroid Build Coastguard Worker }
1531*35238bceSAndroid Build Coastguard Worker {
1532*35238bceSAndroid Build Coastguard Worker IterationConfig iteration;
1533*35238bceSAndroid Build Coastguard Worker iteration.p0 = tcu::Vec2(-0.25f, -0.75f);
1534*35238bceSAndroid Build Coastguard Worker iteration.p1 = tcu::Vec2(2.25f, 1.25f);
1535*35238bceSAndroid Build Coastguard Worker iteration.borderColor = rr::GenericVec4(tcu::Vec4(-std::numeric_limits<float>::infinity()));
1536*35238bceSAndroid Build Coastguard Worker iteration.lookupScale = tcu::Vec4(0.5f);
1537*35238bceSAndroid Build Coastguard Worker iteration.lookupBias = tcu::Vec4(0.25f);
1538*35238bceSAndroid Build Coastguard Worker iteration.description = "border value negative infinity";
1539*35238bceSAndroid Build Coastguard Worker m_iterations.push_back(iteration);
1540*35238bceSAndroid Build Coastguard Worker }
1541*35238bceSAndroid Build Coastguard Worker }
1542*35238bceSAndroid Build Coastguard Worker else if (isPureInteger)
1543*35238bceSAndroid Build Coastguard Worker {
1544*35238bceSAndroid Build Coastguard Worker const tcu::IVec4 numBits = tcu::getTextureFormatBitDepth(texFormat);
1545*35238bceSAndroid Build Coastguard Worker const bool isSigned = m_channelClass == tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER;
1546*35238bceSAndroid Build Coastguard Worker
1547*35238bceSAndroid Build Coastguard Worker // can't overflow 32bit integers with 32bit integers
1548*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < 4; ++ndx)
1549*35238bceSAndroid Build Coastguard Worker DE_ASSERT(numBits[ndx] == 0 || numBits[ndx] == 8 || numBits[ndx] == 16);
1550*35238bceSAndroid Build Coastguard Worker
1551*35238bceSAndroid Build Coastguard Worker const tcu::IVec4 minValue = getNBitIntegerVec4MinValue(isSigned, numBits);
1552*35238bceSAndroid Build Coastguard Worker const tcu::IVec4 maxValue = getNBitIntegerVec4MaxValue(isSigned, numBits);
1553*35238bceSAndroid Build Coastguard Worker const tcu::IVec4 valueRange = maxValue - minValue;
1554*35238bceSAndroid Build Coastguard Worker const tcu::IVec4 divSafeRange(
1555*35238bceSAndroid Build Coastguard Worker (valueRange[0] == 0) ? (1) : (valueRange[0]), (valueRange[1] == 0) ? (1) : (valueRange[1]),
1556*35238bceSAndroid Build Coastguard Worker (valueRange[2] == 0) ? (1) : (valueRange[2]), (valueRange[3] == 0) ? (1) : (valueRange[3]));
1557*35238bceSAndroid Build Coastguard Worker
1558*35238bceSAndroid Build Coastguard Worker // format max
1559*35238bceSAndroid Build Coastguard Worker {
1560*35238bceSAndroid Build Coastguard Worker const tcu::IVec4 value = maxValue + tcu::IVec4(1);
1561*35238bceSAndroid Build Coastguard Worker
1562*35238bceSAndroid Build Coastguard Worker IterationConfig iteration;
1563*35238bceSAndroid Build Coastguard Worker iteration.p0 = tcu::Vec2(-1.2f, -3.0f);
1564*35238bceSAndroid Build Coastguard Worker iteration.p1 = tcu::Vec2(1.2f, 2.5f);
1565*35238bceSAndroid Build Coastguard Worker iteration.borderColor = (isSigned) ? (rr::GenericVec4(value)) : (rr::GenericVec4(value.cast<uint32_t>()));
1566*35238bceSAndroid Build Coastguard Worker iteration.lookupScale = tcu::Vec4(0.5f) / divSafeRange.cast<float>();
1567*35238bceSAndroid Build Coastguard Worker iteration.lookupBias = (isSigned) ? (tcu::Vec4(0.5f)) : (tcu::Vec4(0.25f));
1568*35238bceSAndroid Build Coastguard Worker iteration.description = "border values one larger than maximum";
1569*35238bceSAndroid Build Coastguard Worker m_iterations.push_back(iteration);
1570*35238bceSAndroid Build Coastguard Worker }
1571*35238bceSAndroid Build Coastguard Worker // format min
1572*35238bceSAndroid Build Coastguard Worker if (isSigned)
1573*35238bceSAndroid Build Coastguard Worker {
1574*35238bceSAndroid Build Coastguard Worker const tcu::IVec4 value = minValue - tcu::IVec4(1);
1575*35238bceSAndroid Build Coastguard Worker
1576*35238bceSAndroid Build Coastguard Worker IterationConfig iteration;
1577*35238bceSAndroid Build Coastguard Worker iteration.p0 = tcu::Vec2(-0.25f, -0.75f);
1578*35238bceSAndroid Build Coastguard Worker iteration.p1 = tcu::Vec2(2.25f, 1.25f);
1579*35238bceSAndroid Build Coastguard Worker iteration.borderColor = rr::GenericVec4(value);
1580*35238bceSAndroid Build Coastguard Worker iteration.lookupScale = tcu::Vec4(0.5f) / divSafeRange.cast<float>();
1581*35238bceSAndroid Build Coastguard Worker iteration.lookupBias = tcu::Vec4(0.5f);
1582*35238bceSAndroid Build Coastguard Worker iteration.description = "border values one less than minimum";
1583*35238bceSAndroid Build Coastguard Worker m_iterations.push_back(iteration);
1584*35238bceSAndroid Build Coastguard Worker }
1585*35238bceSAndroid Build Coastguard Worker // (u)int32 max
1586*35238bceSAndroid Build Coastguard Worker {
1587*35238bceSAndroid Build Coastguard Worker const tcu::IVec4 value = (isSigned) ? (tcu::IVec4(std::numeric_limits<int32_t>::max())) :
1588*35238bceSAndroid Build Coastguard Worker (tcu::IVec4(std::numeric_limits<uint32_t>::max()));
1589*35238bceSAndroid Build Coastguard Worker
1590*35238bceSAndroid Build Coastguard Worker IterationConfig iteration;
1591*35238bceSAndroid Build Coastguard Worker iteration.p0 = tcu::Vec2(-1.6f, -2.1f);
1592*35238bceSAndroid Build Coastguard Worker iteration.p1 = tcu::Vec2(1.2f, 3.5f);
1593*35238bceSAndroid Build Coastguard Worker iteration.borderColor = (isSigned) ? (rr::GenericVec4(value)) : (rr::GenericVec4(value.cast<uint32_t>()));
1594*35238bceSAndroid Build Coastguard Worker iteration.lookupScale = tcu::Vec4(0.5f) / divSafeRange.cast<float>();
1595*35238bceSAndroid Build Coastguard Worker iteration.lookupBias = tcu::Vec4(0.25f);
1596*35238bceSAndroid Build Coastguard Worker iteration.description = "border values 32-bit maximum";
1597*35238bceSAndroid Build Coastguard Worker m_iterations.push_back(iteration);
1598*35238bceSAndroid Build Coastguard Worker }
1599*35238bceSAndroid Build Coastguard Worker // int32 min
1600*35238bceSAndroid Build Coastguard Worker if (isSigned)
1601*35238bceSAndroid Build Coastguard Worker {
1602*35238bceSAndroid Build Coastguard Worker const tcu::IVec4 value = tcu::IVec4(std::numeric_limits<int32_t>::min());
1603*35238bceSAndroid Build Coastguard Worker
1604*35238bceSAndroid Build Coastguard Worker IterationConfig iteration;
1605*35238bceSAndroid Build Coastguard Worker iteration.p0 = tcu::Vec2(-2.6f, -4.0f);
1606*35238bceSAndroid Build Coastguard Worker iteration.p1 = tcu::Vec2(1.1f, 1.5f);
1607*35238bceSAndroid Build Coastguard Worker iteration.borderColor = rr::GenericVec4(value);
1608*35238bceSAndroid Build Coastguard Worker iteration.lookupScale = tcu::Vec4(0.5f) / divSafeRange.cast<float>();
1609*35238bceSAndroid Build Coastguard Worker iteration.lookupBias = tcu::Vec4(0.25f);
1610*35238bceSAndroid Build Coastguard Worker iteration.description = "border values 0";
1611*35238bceSAndroid Build Coastguard Worker m_iterations.push_back(iteration);
1612*35238bceSAndroid Build Coastguard Worker }
1613*35238bceSAndroid Build Coastguard Worker }
1614*35238bceSAndroid Build Coastguard Worker else if (isFixed)
1615*35238bceSAndroid Build Coastguard Worker {
1616*35238bceSAndroid Build Coastguard Worker const bool isSigned = m_channelClass == tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT;
1617*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 lookupBias =
1618*35238bceSAndroid Build Coastguard Worker (isSigned) ? (tcu::Vec4(0.5f)) :
1619*35238bceSAndroid Build Coastguard Worker (tcu::Vec4(0.25f)); // scale & bias to [0.25, 0.5] range to make out-of-range values visible
1620*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 lookupScale = (isSigned) ? (tcu::Vec4(0.25f)) : (tcu::Vec4(0.5f));
1621*35238bceSAndroid Build Coastguard Worker
1622*35238bceSAndroid Build Coastguard Worker {
1623*35238bceSAndroid Build Coastguard Worker IterationConfig iteration;
1624*35238bceSAndroid Build Coastguard Worker iteration.p0 = tcu::Vec2(-1.2f, -3.0f);
1625*35238bceSAndroid Build Coastguard Worker iteration.p1 = tcu::Vec2(1.2f, 2.5f);
1626*35238bceSAndroid Build Coastguard Worker iteration.borderColor = mapToFormatColorUnits(texFormat, tcu::Vec4(1.1f, 1.3f, 2.2f, 1.3f));
1627*35238bceSAndroid Build Coastguard Worker iteration.lookupScale = lookupScale;
1628*35238bceSAndroid Build Coastguard Worker iteration.lookupBias = lookupBias;
1629*35238bceSAndroid Build Coastguard Worker iteration.description = "border values larger than maximum";
1630*35238bceSAndroid Build Coastguard Worker m_iterations.push_back(iteration);
1631*35238bceSAndroid Build Coastguard Worker }
1632*35238bceSAndroid Build Coastguard Worker {
1633*35238bceSAndroid Build Coastguard Worker IterationConfig iteration;
1634*35238bceSAndroid Build Coastguard Worker iteration.p0 = tcu::Vec2(-0.25f, -0.75f);
1635*35238bceSAndroid Build Coastguard Worker iteration.p1 = tcu::Vec2(2.25f, 1.25f);
1636*35238bceSAndroid Build Coastguard Worker iteration.borderColor = mapToFormatColorUnits(texFormat, tcu::Vec4(-0.2f, -0.9f, -2.4f, -0.6f));
1637*35238bceSAndroid Build Coastguard Worker iteration.lookupScale = lookupScale;
1638*35238bceSAndroid Build Coastguard Worker iteration.lookupBias = lookupBias;
1639*35238bceSAndroid Build Coastguard Worker iteration.description = "border values less than minimum";
1640*35238bceSAndroid Build Coastguard Worker m_iterations.push_back(iteration);
1641*35238bceSAndroid Build Coastguard Worker }
1642*35238bceSAndroid Build Coastguard Worker }
1643*35238bceSAndroid Build Coastguard Worker else
1644*35238bceSAndroid Build Coastguard Worker DE_ASSERT(false);
1645*35238bceSAndroid Build Coastguard Worker
1646*35238bceSAndroid Build Coastguard Worker // common parameters
1647*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < (int)m_iterations.size(); ++ndx)
1648*35238bceSAndroid Build Coastguard Worker {
1649*35238bceSAndroid Build Coastguard Worker IterationConfig &iteration = m_iterations[ndx];
1650*35238bceSAndroid Build Coastguard Worker
1651*35238bceSAndroid Build Coastguard Worker iteration.minFilter = m_filter;
1652*35238bceSAndroid Build Coastguard Worker iteration.magFilter = m_filter;
1653*35238bceSAndroid Build Coastguard Worker iteration.sWrapMode = GL_CLAMP_TO_BORDER;
1654*35238bceSAndroid Build Coastguard Worker iteration.tWrapMode = GL_CLAMP_TO_BORDER;
1655*35238bceSAndroid Build Coastguard Worker iteration.compareMode = GL_NONE;
1656*35238bceSAndroid Build Coastguard Worker iteration.compareRef = 0.0f;
1657*35238bceSAndroid Build Coastguard Worker }
1658*35238bceSAndroid Build Coastguard Worker }
1659*35238bceSAndroid Build Coastguard Worker
getNumIterations(void) const1660*35238bceSAndroid Build Coastguard Worker int TextureBorderClampRangeClampCase::getNumIterations(void) const
1661*35238bceSAndroid Build Coastguard Worker {
1662*35238bceSAndroid Build Coastguard Worker return (int)m_iterations.size();
1663*35238bceSAndroid Build Coastguard Worker }
1664*35238bceSAndroid Build Coastguard Worker
getIteration(int ndx) const1665*35238bceSAndroid Build Coastguard Worker TextureBorderClampTest::IterationConfig TextureBorderClampRangeClampCase::getIteration(int ndx) const
1666*35238bceSAndroid Build Coastguard Worker {
1667*35238bceSAndroid Build Coastguard Worker return m_iterations[ndx];
1668*35238bceSAndroid Build Coastguard Worker }
1669*35238bceSAndroid Build Coastguard Worker
1670*35238bceSAndroid Build Coastguard Worker class TextureBorderClampPerAxisCase2D : public TextureBorderClampTest
1671*35238bceSAndroid Build Coastguard Worker {
1672*35238bceSAndroid Build Coastguard Worker public:
1673*35238bceSAndroid Build Coastguard Worker TextureBorderClampPerAxisCase2D(Context &context, const char *name, const char *description, uint32_t texFormat,
1674*35238bceSAndroid Build Coastguard Worker tcu::Sampler::DepthStencilMode mode, SizeType sizeType, uint32_t filter,
1675*35238bceSAndroid Build Coastguard Worker uint32_t texSWrap, uint32_t texTWrap, SamplingFunction samplingFunction);
1676*35238bceSAndroid Build Coastguard Worker
1677*35238bceSAndroid Build Coastguard Worker private:
1678*35238bceSAndroid Build Coastguard Worker void init(void);
1679*35238bceSAndroid Build Coastguard Worker
1680*35238bceSAndroid Build Coastguard Worker int getNumIterations(void) const;
1681*35238bceSAndroid Build Coastguard Worker IterationConfig getIteration(int ndx) const;
1682*35238bceSAndroid Build Coastguard Worker
1683*35238bceSAndroid Build Coastguard Worker const uint32_t m_texSWrap;
1684*35238bceSAndroid Build Coastguard Worker const uint32_t m_texTWrap;
1685*35238bceSAndroid Build Coastguard Worker
1686*35238bceSAndroid Build Coastguard Worker std::vector<IterationConfig> m_iterations;
1687*35238bceSAndroid Build Coastguard Worker };
1688*35238bceSAndroid Build Coastguard Worker
TextureBorderClampPerAxisCase2D(Context & context,const char * name,const char * description,uint32_t texFormat,tcu::Sampler::DepthStencilMode mode,SizeType sizeType,uint32_t filter,uint32_t texSWrap,uint32_t texTWrap,SamplingFunction samplingFunction)1689*35238bceSAndroid Build Coastguard Worker TextureBorderClampPerAxisCase2D::TextureBorderClampPerAxisCase2D(Context &context, const char *name,
1690*35238bceSAndroid Build Coastguard Worker const char *description, uint32_t texFormat,
1691*35238bceSAndroid Build Coastguard Worker tcu::Sampler::DepthStencilMode mode, SizeType sizeType,
1692*35238bceSAndroid Build Coastguard Worker uint32_t filter, uint32_t texSWrap, uint32_t texTWrap,
1693*35238bceSAndroid Build Coastguard Worker SamplingFunction samplingFunction)
1694*35238bceSAndroid Build Coastguard Worker : TextureBorderClampTest(context, name, description, texFormat, mode, TextureBorderClampTest::STATE_TEXTURE_PARAM,
1695*35238bceSAndroid Build Coastguard Worker (sizeType == SIZE_POT) ? (16) : (7), (sizeType == SIZE_POT) ? (8) : (9), samplingFunction,
1696*35238bceSAndroid Build Coastguard Worker filter, FLAG_TEST_FLOAT_FILTERABLE)
1697*35238bceSAndroid Build Coastguard Worker , m_texSWrap(texSWrap)
1698*35238bceSAndroid Build Coastguard Worker , m_texTWrap(texTWrap)
1699*35238bceSAndroid Build Coastguard Worker {
1700*35238bceSAndroid Build Coastguard Worker }
1701*35238bceSAndroid Build Coastguard Worker
init(void)1702*35238bceSAndroid Build Coastguard Worker void TextureBorderClampPerAxisCase2D::init(void)
1703*35238bceSAndroid Build Coastguard Worker {
1704*35238bceSAndroid Build Coastguard Worker TextureBorderClampTest::init();
1705*35238bceSAndroid Build Coastguard Worker
1706*35238bceSAndroid Build Coastguard Worker // \note TextureBorderClampTest::init() creates texture
1707*35238bceSAndroid Build Coastguard Worker const tcu::TextureFormat texFormat =
1708*35238bceSAndroid Build Coastguard Worker tcu::getEffectiveDepthStencilTextureFormat(getTexture()->getRefTexture().getFormat(), m_sampleMode);
1709*35238bceSAndroid Build Coastguard Worker const tcu::TextureFormatInfo texFormatInfo = tcu::getTextureFormatInfo(texFormat);
1710*35238bceSAndroid Build Coastguard Worker
1711*35238bceSAndroid Build Coastguard Worker IterationConfig iteration;
1712*35238bceSAndroid Build Coastguard Worker iteration.p0 = tcu::Vec2(-0.25f, -0.75f);
1713*35238bceSAndroid Build Coastguard Worker iteration.p1 = tcu::Vec2(2.25f, 1.25f);
1714*35238bceSAndroid Build Coastguard Worker iteration.borderColor = mapToFormatColorRepresentable(texFormat, tcu::Vec4(0.4f, 0.9f, 0.1f, 0.2f));
1715*35238bceSAndroid Build Coastguard Worker
1716*35238bceSAndroid Build Coastguard Worker if (m_samplingFunction == SAMPLE_GATHER)
1717*35238bceSAndroid Build Coastguard Worker {
1718*35238bceSAndroid Build Coastguard Worker iteration.lookupScale = tcu::Vec4(texFormatInfo.lookupScale.x());
1719*35238bceSAndroid Build Coastguard Worker iteration.lookupBias = tcu::Vec4(texFormatInfo.lookupBias.x());
1720*35238bceSAndroid Build Coastguard Worker }
1721*35238bceSAndroid Build Coastguard Worker else
1722*35238bceSAndroid Build Coastguard Worker {
1723*35238bceSAndroid Build Coastguard Worker iteration.lookupScale = texFormatInfo.lookupScale;
1724*35238bceSAndroid Build Coastguard Worker iteration.lookupBias = texFormatInfo.lookupBias;
1725*35238bceSAndroid Build Coastguard Worker }
1726*35238bceSAndroid Build Coastguard Worker
1727*35238bceSAndroid Build Coastguard Worker iteration.minFilter = m_filter;
1728*35238bceSAndroid Build Coastguard Worker iteration.magFilter = m_filter;
1729*35238bceSAndroid Build Coastguard Worker iteration.sWrapMode = m_texSWrap;
1730*35238bceSAndroid Build Coastguard Worker iteration.tWrapMode = m_texTWrap;
1731*35238bceSAndroid Build Coastguard Worker iteration.compareMode = GL_NONE;
1732*35238bceSAndroid Build Coastguard Worker iteration.compareRef = 0.0f;
1733*35238bceSAndroid Build Coastguard Worker
1734*35238bceSAndroid Build Coastguard Worker m_iterations.push_back(iteration);
1735*35238bceSAndroid Build Coastguard Worker }
1736*35238bceSAndroid Build Coastguard Worker
getNumIterations(void) const1737*35238bceSAndroid Build Coastguard Worker int TextureBorderClampPerAxisCase2D::getNumIterations(void) const
1738*35238bceSAndroid Build Coastguard Worker {
1739*35238bceSAndroid Build Coastguard Worker return (int)m_iterations.size();
1740*35238bceSAndroid Build Coastguard Worker }
1741*35238bceSAndroid Build Coastguard Worker
getIteration(int ndx) const1742*35238bceSAndroid Build Coastguard Worker TextureBorderClampTest::IterationConfig TextureBorderClampPerAxisCase2D::getIteration(int ndx) const
1743*35238bceSAndroid Build Coastguard Worker {
1744*35238bceSAndroid Build Coastguard Worker return m_iterations[ndx];
1745*35238bceSAndroid Build Coastguard Worker }
1746*35238bceSAndroid Build Coastguard Worker
1747*35238bceSAndroid Build Coastguard Worker class TextureBorderClampDepthCompareCase : public TextureBorderClampTest
1748*35238bceSAndroid Build Coastguard Worker {
1749*35238bceSAndroid Build Coastguard Worker public:
1750*35238bceSAndroid Build Coastguard Worker TextureBorderClampDepthCompareCase(Context &context, const char *name, const char *description, uint32_t texFormat,
1751*35238bceSAndroid Build Coastguard Worker SizeType sizeType, uint32_t filter, SamplingFunction samplingFunction);
1752*35238bceSAndroid Build Coastguard Worker
1753*35238bceSAndroid Build Coastguard Worker private:
1754*35238bceSAndroid Build Coastguard Worker void init(void);
1755*35238bceSAndroid Build Coastguard Worker
1756*35238bceSAndroid Build Coastguard Worker int getNumIterations(void) const;
1757*35238bceSAndroid Build Coastguard Worker IterationConfig getIteration(int ndx) const;
1758*35238bceSAndroid Build Coastguard Worker
1759*35238bceSAndroid Build Coastguard Worker std::vector<IterationConfig> m_iterations;
1760*35238bceSAndroid Build Coastguard Worker };
1761*35238bceSAndroid Build Coastguard Worker
TextureBorderClampDepthCompareCase(Context & context,const char * name,const char * description,uint32_t texFormat,SizeType sizeType,uint32_t filter,SamplingFunction samplingFunction)1762*35238bceSAndroid Build Coastguard Worker TextureBorderClampDepthCompareCase::TextureBorderClampDepthCompareCase(Context &context, const char *name,
1763*35238bceSAndroid Build Coastguard Worker const char *description, uint32_t texFormat,
1764*35238bceSAndroid Build Coastguard Worker SizeType sizeType, uint32_t filter,
1765*35238bceSAndroid Build Coastguard Worker SamplingFunction samplingFunction)
1766*35238bceSAndroid Build Coastguard Worker : TextureBorderClampTest(context, name, description, texFormat, tcu::Sampler::MODE_DEPTH,
1767*35238bceSAndroid Build Coastguard Worker TextureBorderClampTest::STATE_TEXTURE_PARAM, (sizeType == SIZE_POT) ? (32) : (13),
1768*35238bceSAndroid Build Coastguard Worker (sizeType == SIZE_POT) ? (16) : (17), samplingFunction, filter, FLAG_USE_SHADOW_SAMPLER)
1769*35238bceSAndroid Build Coastguard Worker {
1770*35238bceSAndroid Build Coastguard Worker }
1771*35238bceSAndroid Build Coastguard Worker
init(void)1772*35238bceSAndroid Build Coastguard Worker void TextureBorderClampDepthCompareCase::init(void)
1773*35238bceSAndroid Build Coastguard Worker {
1774*35238bceSAndroid Build Coastguard Worker TextureBorderClampTest::init();
1775*35238bceSAndroid Build Coastguard Worker
1776*35238bceSAndroid Build Coastguard Worker // 0.5 <= 0.7
1777*35238bceSAndroid Build Coastguard Worker {
1778*35238bceSAndroid Build Coastguard Worker IterationConfig iteration;
1779*35238bceSAndroid Build Coastguard Worker iteration.p0 = tcu::Vec2(-0.15f, -0.35f);
1780*35238bceSAndroid Build Coastguard Worker iteration.p1 = tcu::Vec2(1.25f, 1.1f);
1781*35238bceSAndroid Build Coastguard Worker iteration.borderColor = rr::GenericVec4(tcu::Vec4(0.7f, 0.0f, 0.0f, 0.0f));
1782*35238bceSAndroid Build Coastguard Worker iteration.description = "Border color in [0, 1] range";
1783*35238bceSAndroid Build Coastguard Worker iteration.compareMode = GL_LEQUAL;
1784*35238bceSAndroid Build Coastguard Worker iteration.compareRef = 0.5f;
1785*35238bceSAndroid Build Coastguard Worker m_iterations.push_back(iteration);
1786*35238bceSAndroid Build Coastguard Worker }
1787*35238bceSAndroid Build Coastguard Worker
1788*35238bceSAndroid Build Coastguard Worker // 1.5 <= 1.0
1789*35238bceSAndroid Build Coastguard Worker {
1790*35238bceSAndroid Build Coastguard Worker IterationConfig iteration;
1791*35238bceSAndroid Build Coastguard Worker iteration.p0 = tcu::Vec2(-0.15f, -0.35f);
1792*35238bceSAndroid Build Coastguard Worker iteration.p1 = tcu::Vec2(1.25f, 1.1f);
1793*35238bceSAndroid Build Coastguard Worker iteration.borderColor = rr::GenericVec4(tcu::Vec4(1.5f, 0.0f, 0.0f, 0.0f));
1794*35238bceSAndroid Build Coastguard Worker iteration.description = "Border color > 1, should be clamped";
1795*35238bceSAndroid Build Coastguard Worker iteration.compareMode = GL_LEQUAL;
1796*35238bceSAndroid Build Coastguard Worker iteration.compareRef = 1.0f;
1797*35238bceSAndroid Build Coastguard Worker m_iterations.push_back(iteration);
1798*35238bceSAndroid Build Coastguard Worker }
1799*35238bceSAndroid Build Coastguard Worker
1800*35238bceSAndroid Build Coastguard Worker // -0.5 >= 0.0
1801*35238bceSAndroid Build Coastguard Worker {
1802*35238bceSAndroid Build Coastguard Worker IterationConfig iteration;
1803*35238bceSAndroid Build Coastguard Worker iteration.p0 = tcu::Vec2(-0.15f, -0.35f);
1804*35238bceSAndroid Build Coastguard Worker iteration.p1 = tcu::Vec2(1.25f, 1.1f);
1805*35238bceSAndroid Build Coastguard Worker iteration.borderColor = rr::GenericVec4(tcu::Vec4(-0.5f, 0.0f, 0.0f, 0.0f));
1806*35238bceSAndroid Build Coastguard Worker iteration.description = "Border color < 0, should be clamped";
1807*35238bceSAndroid Build Coastguard Worker iteration.compareMode = GL_GEQUAL;
1808*35238bceSAndroid Build Coastguard Worker iteration.compareRef = 0.0f;
1809*35238bceSAndroid Build Coastguard Worker m_iterations.push_back(iteration);
1810*35238bceSAndroid Build Coastguard Worker }
1811*35238bceSAndroid Build Coastguard Worker
1812*35238bceSAndroid Build Coastguard Worker // inf < 1.25
1813*35238bceSAndroid Build Coastguard Worker {
1814*35238bceSAndroid Build Coastguard Worker IterationConfig iteration;
1815*35238bceSAndroid Build Coastguard Worker iteration.p0 = tcu::Vec2(-0.15f, -0.35f);
1816*35238bceSAndroid Build Coastguard Worker iteration.p1 = tcu::Vec2(1.25f, 1.1f);
1817*35238bceSAndroid Build Coastguard Worker iteration.borderColor = rr::GenericVec4(tcu::Vec4(std::numeric_limits<float>::infinity(), 0.0f, 0.0f, 0.0f));
1818*35238bceSAndroid Build Coastguard Worker iteration.description = "Border color == inf, should be clamped; ref > 1";
1819*35238bceSAndroid Build Coastguard Worker iteration.compareMode = GL_LESS;
1820*35238bceSAndroid Build Coastguard Worker iteration.compareRef = 1.25f;
1821*35238bceSAndroid Build Coastguard Worker m_iterations.push_back(iteration);
1822*35238bceSAndroid Build Coastguard Worker }
1823*35238bceSAndroid Build Coastguard Worker
1824*35238bceSAndroid Build Coastguard Worker // -inf > -0.5
1825*35238bceSAndroid Build Coastguard Worker {
1826*35238bceSAndroid Build Coastguard Worker IterationConfig iteration;
1827*35238bceSAndroid Build Coastguard Worker iteration.p0 = tcu::Vec2(-0.15f, -0.35f);
1828*35238bceSAndroid Build Coastguard Worker iteration.p1 = tcu::Vec2(1.25f, 1.1f);
1829*35238bceSAndroid Build Coastguard Worker iteration.borderColor = rr::GenericVec4(tcu::Vec4(-std::numeric_limits<float>::infinity(), 0.0f, 0.0f, 0.0f));
1830*35238bceSAndroid Build Coastguard Worker iteration.description = "Border color == inf, should be clamped; ref < 0";
1831*35238bceSAndroid Build Coastguard Worker iteration.compareMode = GL_GREATER;
1832*35238bceSAndroid Build Coastguard Worker iteration.compareRef = -0.5f;
1833*35238bceSAndroid Build Coastguard Worker m_iterations.push_back(iteration);
1834*35238bceSAndroid Build Coastguard Worker }
1835*35238bceSAndroid Build Coastguard Worker
1836*35238bceSAndroid Build Coastguard Worker // common parameters
1837*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < (int)m_iterations.size(); ++ndx)
1838*35238bceSAndroid Build Coastguard Worker {
1839*35238bceSAndroid Build Coastguard Worker IterationConfig &iteration = m_iterations[ndx];
1840*35238bceSAndroid Build Coastguard Worker
1841*35238bceSAndroid Build Coastguard Worker iteration.lookupScale = tcu::Vec4(1.0);
1842*35238bceSAndroid Build Coastguard Worker iteration.lookupBias = tcu::Vec4(0.0);
1843*35238bceSAndroid Build Coastguard Worker iteration.minFilter = m_filter;
1844*35238bceSAndroid Build Coastguard Worker iteration.magFilter = m_filter;
1845*35238bceSAndroid Build Coastguard Worker iteration.sWrapMode = GL_CLAMP_TO_BORDER;
1846*35238bceSAndroid Build Coastguard Worker iteration.tWrapMode = GL_CLAMP_TO_BORDER;
1847*35238bceSAndroid Build Coastguard Worker }
1848*35238bceSAndroid Build Coastguard Worker }
1849*35238bceSAndroid Build Coastguard Worker
getNumIterations(void) const1850*35238bceSAndroid Build Coastguard Worker int TextureBorderClampDepthCompareCase::getNumIterations(void) const
1851*35238bceSAndroid Build Coastguard Worker {
1852*35238bceSAndroid Build Coastguard Worker return (int)m_iterations.size();
1853*35238bceSAndroid Build Coastguard Worker }
1854*35238bceSAndroid Build Coastguard Worker
getIteration(int ndx) const1855*35238bceSAndroid Build Coastguard Worker TextureBorderClampTest::IterationConfig TextureBorderClampDepthCompareCase::getIteration(int ndx) const
1856*35238bceSAndroid Build Coastguard Worker {
1857*35238bceSAndroid Build Coastguard Worker return m_iterations[ndx];
1858*35238bceSAndroid Build Coastguard Worker }
1859*35238bceSAndroid Build Coastguard Worker
1860*35238bceSAndroid Build Coastguard Worker class TextureBorderClampUnusedChannelCase : public TextureBorderClampTest
1861*35238bceSAndroid Build Coastguard Worker {
1862*35238bceSAndroid Build Coastguard Worker public:
1863*35238bceSAndroid Build Coastguard Worker TextureBorderClampUnusedChannelCase(Context &context, const char *name, const char *description, uint32_t texFormat,
1864*35238bceSAndroid Build Coastguard Worker tcu::Sampler::DepthStencilMode depthStencilMode);
1865*35238bceSAndroid Build Coastguard Worker
1866*35238bceSAndroid Build Coastguard Worker private:
1867*35238bceSAndroid Build Coastguard Worker void init(void);
1868*35238bceSAndroid Build Coastguard Worker
1869*35238bceSAndroid Build Coastguard Worker int getNumIterations(void) const;
1870*35238bceSAndroid Build Coastguard Worker IterationConfig getIteration(int ndx) const;
1871*35238bceSAndroid Build Coastguard Worker
1872*35238bceSAndroid Build Coastguard Worker std::vector<IterationConfig> m_iterations;
1873*35238bceSAndroid Build Coastguard Worker };
1874*35238bceSAndroid Build Coastguard Worker
TextureBorderClampUnusedChannelCase(Context & context,const char * name,const char * description,uint32_t texFormat,tcu::Sampler::DepthStencilMode depthStencilMode)1875*35238bceSAndroid Build Coastguard Worker TextureBorderClampUnusedChannelCase::TextureBorderClampUnusedChannelCase(
1876*35238bceSAndroid Build Coastguard Worker Context &context, const char *name, const char *description, uint32_t texFormat,
1877*35238bceSAndroid Build Coastguard Worker tcu::Sampler::DepthStencilMode depthStencilMode)
1878*35238bceSAndroid Build Coastguard Worker : TextureBorderClampTest(context, name, description, texFormat, depthStencilMode,
1879*35238bceSAndroid Build Coastguard Worker TextureBorderClampTest::STATE_TEXTURE_PARAM, 8, 8, SAMPLE_FILTER, GL_NEAREST)
1880*35238bceSAndroid Build Coastguard Worker {
1881*35238bceSAndroid Build Coastguard Worker }
1882*35238bceSAndroid Build Coastguard Worker
selectComponents(const rr::GenericVec4 & trueComponents,const rr::GenericVec4 & falseComponents,const tcu::BVec4 & m)1883*35238bceSAndroid Build Coastguard Worker static rr::GenericVec4 selectComponents(const rr::GenericVec4 &trueComponents, const rr::GenericVec4 &falseComponents,
1884*35238bceSAndroid Build Coastguard Worker const tcu::BVec4 &m)
1885*35238bceSAndroid Build Coastguard Worker {
1886*35238bceSAndroid Build Coastguard Worker return rr::GenericVec4(tcu::select(trueComponents.get<uint32_t>(), falseComponents.get<uint32_t>(), m));
1887*35238bceSAndroid Build Coastguard Worker }
1888*35238bceSAndroid Build Coastguard Worker
init(void)1889*35238bceSAndroid Build Coastguard Worker void TextureBorderClampUnusedChannelCase::init(void)
1890*35238bceSAndroid Build Coastguard Worker {
1891*35238bceSAndroid Build Coastguard Worker TextureBorderClampTest::init();
1892*35238bceSAndroid Build Coastguard Worker
1893*35238bceSAndroid Build Coastguard Worker // \note TextureBorderClampTest::init() creates texture
1894*35238bceSAndroid Build Coastguard Worker const tcu::TextureFormat texFormat =
1895*35238bceSAndroid Build Coastguard Worker tcu::getEffectiveDepthStencilTextureFormat(getTexture()->getRefTexture().getFormat(), m_sampleMode);
1896*35238bceSAndroid Build Coastguard Worker const tcu::TextureFormatInfo texFormatInfo = tcu::getTextureFormatInfo(texFormat);
1897*35238bceSAndroid Build Coastguard Worker const tcu::BVec4 channelMask = tcu::getTextureFormatChannelMask(texFormat);
1898*35238bceSAndroid Build Coastguard Worker const float maxChannelValue = (channelMask[0]) ? (texFormatInfo.valueMax[0]) :
1899*35238bceSAndroid Build Coastguard Worker (channelMask[1]) ? (texFormatInfo.valueMax[1]) :
1900*35238bceSAndroid Build Coastguard Worker (channelMask[2]) ? (texFormatInfo.valueMax[2]) :
1901*35238bceSAndroid Build Coastguard Worker (texFormatInfo.valueMax[3]);
1902*35238bceSAndroid Build Coastguard Worker
1903*35238bceSAndroid Build Coastguard Worker const rr::GenericVec4 effectiveColors = mapToFormatColorRepresentable(texFormat, tcu::Vec4(0.6f));
1904*35238bceSAndroid Build Coastguard Worker rr::GenericVec4 nonEffectiveColors;
1905*35238bceSAndroid Build Coastguard Worker
1906*35238bceSAndroid Build Coastguard Worker switch (m_channelClass)
1907*35238bceSAndroid Build Coastguard Worker {
1908*35238bceSAndroid Build Coastguard Worker case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
1909*35238bceSAndroid Build Coastguard Worker case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
1910*35238bceSAndroid Build Coastguard Worker case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
1911*35238bceSAndroid Build Coastguard Worker nonEffectiveColors = rr::GenericVec4(tcu::Vec4(maxChannelValue * 0.8f));
1912*35238bceSAndroid Build Coastguard Worker break;
1913*35238bceSAndroid Build Coastguard Worker
1914*35238bceSAndroid Build Coastguard Worker case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
1915*35238bceSAndroid Build Coastguard Worker nonEffectiveColors = rr::GenericVec4(tcu::Vec4(maxChannelValue * 0.8f).cast<int32_t>());
1916*35238bceSAndroid Build Coastguard Worker break;
1917*35238bceSAndroid Build Coastguard Worker
1918*35238bceSAndroid Build Coastguard Worker case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
1919*35238bceSAndroid Build Coastguard Worker nonEffectiveColors = rr::GenericVec4(tcu::Vec4(maxChannelValue * 0.8f).cast<uint32_t>());
1920*35238bceSAndroid Build Coastguard Worker break;
1921*35238bceSAndroid Build Coastguard Worker default:
1922*35238bceSAndroid Build Coastguard Worker DE_ASSERT(false);
1923*35238bceSAndroid Build Coastguard Worker }
1924*35238bceSAndroid Build Coastguard Worker
1925*35238bceSAndroid Build Coastguard Worker IterationConfig iteration;
1926*35238bceSAndroid Build Coastguard Worker iteration.p0 = tcu::Vec2(-0.25f, -0.75f);
1927*35238bceSAndroid Build Coastguard Worker iteration.p1 = tcu::Vec2(2.25f, 1.25f);
1928*35238bceSAndroid Build Coastguard Worker iteration.borderColor = selectComponents(effectiveColors, nonEffectiveColors, channelMask);
1929*35238bceSAndroid Build Coastguard Worker iteration.lookupScale = texFormatInfo.lookupScale;
1930*35238bceSAndroid Build Coastguard Worker iteration.lookupBias = texFormatInfo.lookupBias;
1931*35238bceSAndroid Build Coastguard Worker iteration.minFilter = GL_NEAREST;
1932*35238bceSAndroid Build Coastguard Worker iteration.magFilter = GL_NEAREST;
1933*35238bceSAndroid Build Coastguard Worker iteration.sWrapMode = GL_CLAMP_TO_BORDER;
1934*35238bceSAndroid Build Coastguard Worker iteration.tWrapMode = GL_CLAMP_TO_BORDER;
1935*35238bceSAndroid Build Coastguard Worker iteration.compareMode = GL_NONE;
1936*35238bceSAndroid Build Coastguard Worker iteration.compareRef = 0.0f;
1937*35238bceSAndroid Build Coastguard Worker iteration.description = "Setting values to unused border color components";
1938*35238bceSAndroid Build Coastguard Worker
1939*35238bceSAndroid Build Coastguard Worker m_iterations.push_back(iteration);
1940*35238bceSAndroid Build Coastguard Worker }
1941*35238bceSAndroid Build Coastguard Worker
getNumIterations(void) const1942*35238bceSAndroid Build Coastguard Worker int TextureBorderClampUnusedChannelCase::getNumIterations(void) const
1943*35238bceSAndroid Build Coastguard Worker {
1944*35238bceSAndroid Build Coastguard Worker return (int)m_iterations.size();
1945*35238bceSAndroid Build Coastguard Worker }
1946*35238bceSAndroid Build Coastguard Worker
getIteration(int ndx) const1947*35238bceSAndroid Build Coastguard Worker TextureBorderClampTest::IterationConfig TextureBorderClampUnusedChannelCase::getIteration(int ndx) const
1948*35238bceSAndroid Build Coastguard Worker {
1949*35238bceSAndroid Build Coastguard Worker return m_iterations[ndx];
1950*35238bceSAndroid Build Coastguard Worker }
1951*35238bceSAndroid Build Coastguard Worker
1952*35238bceSAndroid Build Coastguard Worker class TextureBorderClampPerAxisCase3D : public TestCase
1953*35238bceSAndroid Build Coastguard Worker {
1954*35238bceSAndroid Build Coastguard Worker public:
1955*35238bceSAndroid Build Coastguard Worker TextureBorderClampPerAxisCase3D(Context &context, const char *name, const char *description, uint32_t texFormat,
1956*35238bceSAndroid Build Coastguard Worker SizeType size, uint32_t filter, uint32_t sWrap, uint32_t tWrap, uint32_t rWrap);
1957*35238bceSAndroid Build Coastguard Worker
1958*35238bceSAndroid Build Coastguard Worker private:
1959*35238bceSAndroid Build Coastguard Worker void init(void);
1960*35238bceSAndroid Build Coastguard Worker void deinit(void);
1961*35238bceSAndroid Build Coastguard Worker IterateResult iterate(void);
1962*35238bceSAndroid Build Coastguard Worker
1963*35238bceSAndroid Build Coastguard Worker void renderTo(tcu::Surface &surface, const glu::TextureTestUtil::ReferenceParams &samplerParams);
1964*35238bceSAndroid Build Coastguard Worker
1965*35238bceSAndroid Build Coastguard Worker void logParams(const glu::TextureTestUtil::ReferenceParams &samplerParams);
1966*35238bceSAndroid Build Coastguard Worker
1967*35238bceSAndroid Build Coastguard Worker void verifyImage(const tcu::Surface &image, const glu::TextureTestUtil::ReferenceParams &samplerParams);
1968*35238bceSAndroid Build Coastguard Worker
1969*35238bceSAndroid Build Coastguard Worker glu::TextureTestUtil::ReferenceParams getSamplerParams(void) const;
1970*35238bceSAndroid Build Coastguard Worker uint32_t getCaseSeed(void) const;
1971*35238bceSAndroid Build Coastguard Worker
1972*35238bceSAndroid Build Coastguard Worker enum
1973*35238bceSAndroid Build Coastguard Worker {
1974*35238bceSAndroid Build Coastguard Worker VIEWPORT_WIDTH = 128,
1975*35238bceSAndroid Build Coastguard Worker VIEWPORT_HEIGHT = 128,
1976*35238bceSAndroid Build Coastguard Worker };
1977*35238bceSAndroid Build Coastguard Worker
1978*35238bceSAndroid Build Coastguard Worker const uint32_t m_texFormat;
1979*35238bceSAndroid Build Coastguard Worker const tcu::TextureChannelClass m_channelClass;
1980*35238bceSAndroid Build Coastguard Worker const tcu::IVec3 m_size;
1981*35238bceSAndroid Build Coastguard Worker const uint32_t m_filter;
1982*35238bceSAndroid Build Coastguard Worker const uint32_t m_sWrap;
1983*35238bceSAndroid Build Coastguard Worker const uint32_t m_tWrap;
1984*35238bceSAndroid Build Coastguard Worker const uint32_t m_rWrap;
1985*35238bceSAndroid Build Coastguard Worker
1986*35238bceSAndroid Build Coastguard Worker de::MovePtr<glu::Texture3D> m_texture;
1987*35238bceSAndroid Build Coastguard Worker de::MovePtr<gls::TextureTestUtil::TextureRenderer> m_renderer;
1988*35238bceSAndroid Build Coastguard Worker
1989*35238bceSAndroid Build Coastguard Worker rr::GenericVec4 m_borderColor;
1990*35238bceSAndroid Build Coastguard Worker std::vector<float> m_texCoords;
1991*35238bceSAndroid Build Coastguard Worker tcu::Vec4 m_lookupScale;
1992*35238bceSAndroid Build Coastguard Worker tcu::Vec4 m_lookupBias;
1993*35238bceSAndroid Build Coastguard Worker };
1994*35238bceSAndroid Build Coastguard Worker
TextureBorderClampPerAxisCase3D(Context & context,const char * name,const char * description,uint32_t texFormat,SizeType size,uint32_t filter,uint32_t sWrap,uint32_t tWrap,uint32_t rWrap)1995*35238bceSAndroid Build Coastguard Worker TextureBorderClampPerAxisCase3D::TextureBorderClampPerAxisCase3D(Context &context, const char *name,
1996*35238bceSAndroid Build Coastguard Worker const char *description, uint32_t texFormat,
1997*35238bceSAndroid Build Coastguard Worker SizeType size, uint32_t filter, uint32_t sWrap,
1998*35238bceSAndroid Build Coastguard Worker uint32_t tWrap, uint32_t rWrap)
1999*35238bceSAndroid Build Coastguard Worker : TestCase(context, name, description)
2000*35238bceSAndroid Build Coastguard Worker , m_texFormat(texFormat)
2001*35238bceSAndroid Build Coastguard Worker , m_channelClass(getFormatChannelClass(texFormat, tcu::Sampler::MODE_LAST))
2002*35238bceSAndroid Build Coastguard Worker , m_size((size == SIZE_POT) ? (tcu::IVec3(8, 16, 4)) : (tcu::IVec3(13, 5, 7)))
2003*35238bceSAndroid Build Coastguard Worker , m_filter(filter)
2004*35238bceSAndroid Build Coastguard Worker , m_sWrap(sWrap)
2005*35238bceSAndroid Build Coastguard Worker , m_tWrap(tWrap)
2006*35238bceSAndroid Build Coastguard Worker , m_rWrap(rWrap)
2007*35238bceSAndroid Build Coastguard Worker {
2008*35238bceSAndroid Build Coastguard Worker }
2009*35238bceSAndroid Build Coastguard Worker
init(void)2010*35238bceSAndroid Build Coastguard Worker void TextureBorderClampPerAxisCase3D::init(void)
2011*35238bceSAndroid Build Coastguard Worker {
2012*35238bceSAndroid Build Coastguard Worker auto ctxType = m_context.getRenderContext().getType();
2013*35238bceSAndroid Build Coastguard Worker const bool isES32orGL45 = glu::contextSupports(ctxType, glu::ApiType::es(3, 2)) ||
2014*35238bceSAndroid Build Coastguard Worker glu::contextSupports(ctxType, glu::ApiType::core(4, 5));
2015*35238bceSAndroid Build Coastguard Worker const glu::GLSLVersion glslVersion = glu::getContextTypeGLSLVersion(ctxType);
2016*35238bceSAndroid Build Coastguard Worker
2017*35238bceSAndroid Build Coastguard Worker // repeat filterable test with valid context
2018*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
2019*35238bceSAndroid Build Coastguard Worker const bool is_texture_float_linear_supported =
2020*35238bceSAndroid Build Coastguard Worker glu::hasExtension(gl, glu::ApiType::es(3, 0), "GL_OES_texture_float_linear");
2021*35238bceSAndroid Build Coastguard Worker const bool coreFilterable =
2022*35238bceSAndroid Build Coastguard Worker isCoreFilterableFormat(m_texFormat, tcu::Sampler::MODE_LAST, is_texture_float_linear_supported);
2023*35238bceSAndroid Build Coastguard Worker
2024*35238bceSAndroid Build Coastguard Worker if (!coreFilterable && filterRequiresFilterability(m_filter))
2025*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("Test requires GL_OES_texture_float_linear extension");
2026*35238bceSAndroid Build Coastguard Worker
2027*35238bceSAndroid Build Coastguard Worker if (!isES32orGL45 && !m_context.getContextInfo().isExtensionSupported("GL_EXT_texture_border_clamp"))
2028*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("Test requires GL_EXT_texture_border_clamp extension");
2029*35238bceSAndroid Build Coastguard Worker
2030*35238bceSAndroid Build Coastguard Worker if (glu::isCompressedFormat(m_texFormat) && !isES32orGL45 &&
2031*35238bceSAndroid Build Coastguard Worker tcu::isAstcFormat(glu::mapGLCompressedTexFormat(m_texFormat)) &&
2032*35238bceSAndroid Build Coastguard Worker !m_context.getContextInfo().isExtensionSupported("GL_KHR_texture_compression_astc_ldr"))
2033*35238bceSAndroid Build Coastguard Worker {
2034*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("Test requires GL_KHR_texture_compression_astc_ldr extension");
2035*35238bceSAndroid Build Coastguard Worker }
2036*35238bceSAndroid Build Coastguard Worker if (m_texFormat == GL_BGRA && !m_context.getContextInfo().isExtensionSupported("GL_EXT_texture_format_BGRA8888"))
2037*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("Test requires GL_EXT_texture_format_BGRA8888 extension");
2038*35238bceSAndroid Build Coastguard Worker if (m_context.getRenderTarget().getWidth() < VIEWPORT_WIDTH ||
2039*35238bceSAndroid Build Coastguard Worker m_context.getRenderTarget().getHeight() < VIEWPORT_HEIGHT)
2040*35238bceSAndroid Build Coastguard Worker {
2041*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("Test requires " + de::toString<int>(VIEWPORT_WIDTH) + "x" +
2042*35238bceSAndroid Build Coastguard Worker de::toString<int>(VIEWPORT_HEIGHT) + " viewport");
2043*35238bceSAndroid Build Coastguard Worker }
2044*35238bceSAndroid Build Coastguard Worker
2045*35238bceSAndroid Build Coastguard Worker // resources
2046*35238bceSAndroid Build Coastguard Worker m_texture = genDefaultTexture<glu::Texture3D>(m_context.getRenderContext(), m_context.getContextInfo(), m_texFormat,
2047*35238bceSAndroid Build Coastguard Worker m_size);
2048*35238bceSAndroid Build Coastguard Worker m_renderer = de::MovePtr<gls::TextureTestUtil::TextureRenderer>(new gls::TextureTestUtil::TextureRenderer(
2049*35238bceSAndroid Build Coastguard Worker m_context.getRenderContext(), m_testCtx.getLog(), glslVersion, glu::PRECISION_HIGHP));
2050*35238bceSAndroid Build Coastguard Worker
2051*35238bceSAndroid Build Coastguard Worker // texture info
2052*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::Message << "Created 3D texture with format "
2053*35238bceSAndroid Build Coastguard Worker << glu::getTextureFormatName(m_texFormat) << ", size (" << m_texture->getRefTexture().getWidth()
2054*35238bceSAndroid Build Coastguard Worker << ", " << m_texture->getRefTexture().getHeight() << ", "
2055*35238bceSAndroid Build Coastguard Worker << m_texture->getRefTexture().getDepth() << ")\n"
2056*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
2057*35238bceSAndroid Build Coastguard Worker
2058*35238bceSAndroid Build Coastguard Worker // tex coord
2059*35238bceSAndroid Build Coastguard Worker {
2060*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::Message
2061*35238bceSAndroid Build Coastguard Worker << "Setting tex coords bottom-left: (-1, -1, -1.5), top-right (2, 2, 2.5)\n"
2062*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
2063*35238bceSAndroid Build Coastguard Worker
2064*35238bceSAndroid Build Coastguard Worker m_texCoords.resize(4 * 3);
2065*35238bceSAndroid Build Coastguard Worker
2066*35238bceSAndroid Build Coastguard Worker m_texCoords[0] = -1.0f;
2067*35238bceSAndroid Build Coastguard Worker m_texCoords[1] = -1.0f;
2068*35238bceSAndroid Build Coastguard Worker m_texCoords[2] = -1.5f;
2069*35238bceSAndroid Build Coastguard Worker m_texCoords[3] = -1.0f;
2070*35238bceSAndroid Build Coastguard Worker m_texCoords[4] = 2.0f;
2071*35238bceSAndroid Build Coastguard Worker m_texCoords[5] = 0.5f;
2072*35238bceSAndroid Build Coastguard Worker m_texCoords[6] = 2.0f;
2073*35238bceSAndroid Build Coastguard Worker m_texCoords[7] = -1.0f;
2074*35238bceSAndroid Build Coastguard Worker m_texCoords[8] = 0.5f;
2075*35238bceSAndroid Build Coastguard Worker m_texCoords[9] = 2.0f;
2076*35238bceSAndroid Build Coastguard Worker m_texCoords[10] = 2.0f;
2077*35238bceSAndroid Build Coastguard Worker m_texCoords[11] = 2.5f;
2078*35238bceSAndroid Build Coastguard Worker }
2079*35238bceSAndroid Build Coastguard Worker
2080*35238bceSAndroid Build Coastguard Worker // set render params
2081*35238bceSAndroid Build Coastguard Worker {
2082*35238bceSAndroid Build Coastguard Worker const tcu::TextureFormat texFormat = m_texture->getRefTexture().getFormat();
2083*35238bceSAndroid Build Coastguard Worker const tcu::TextureFormatInfo texFormatInfo = tcu::getTextureFormatInfo(texFormat);
2084*35238bceSAndroid Build Coastguard Worker
2085*35238bceSAndroid Build Coastguard Worker m_borderColor = mapToFormatColorRepresentable(texFormat, tcu::Vec4(0.2f, 0.6f, 0.9f, 0.4f));
2086*35238bceSAndroid Build Coastguard Worker
2087*35238bceSAndroid Build Coastguard Worker m_lookupScale = texFormatInfo.lookupScale;
2088*35238bceSAndroid Build Coastguard Worker m_lookupBias = texFormatInfo.lookupBias;
2089*35238bceSAndroid Build Coastguard Worker }
2090*35238bceSAndroid Build Coastguard Worker }
2091*35238bceSAndroid Build Coastguard Worker
deinit(void)2092*35238bceSAndroid Build Coastguard Worker void TextureBorderClampPerAxisCase3D::deinit(void)
2093*35238bceSAndroid Build Coastguard Worker {
2094*35238bceSAndroid Build Coastguard Worker m_texture.clear();
2095*35238bceSAndroid Build Coastguard Worker m_renderer.clear();
2096*35238bceSAndroid Build Coastguard Worker }
2097*35238bceSAndroid Build Coastguard Worker
iterate(void)2098*35238bceSAndroid Build Coastguard Worker TextureBorderClampPerAxisCase3D::IterateResult TextureBorderClampPerAxisCase3D::iterate(void)
2099*35238bceSAndroid Build Coastguard Worker {
2100*35238bceSAndroid Build Coastguard Worker tcu::Surface renderedFrame(VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
2101*35238bceSAndroid Build Coastguard Worker const glu::TextureTestUtil::ReferenceParams samplerParams = getSamplerParams();
2102*35238bceSAndroid Build Coastguard Worker
2103*35238bceSAndroid Build Coastguard Worker logParams(samplerParams);
2104*35238bceSAndroid Build Coastguard Worker renderTo(renderedFrame, samplerParams);
2105*35238bceSAndroid Build Coastguard Worker verifyImage(renderedFrame, samplerParams);
2106*35238bceSAndroid Build Coastguard Worker
2107*35238bceSAndroid Build Coastguard Worker return STOP;
2108*35238bceSAndroid Build Coastguard Worker }
2109*35238bceSAndroid Build Coastguard Worker
logParams(const glu::TextureTestUtil::ReferenceParams & samplerParams)2110*35238bceSAndroid Build Coastguard Worker void TextureBorderClampPerAxisCase3D::logParams(const glu::TextureTestUtil::ReferenceParams &samplerParams)
2111*35238bceSAndroid Build Coastguard Worker {
2112*35238bceSAndroid Build Coastguard Worker const std::string borderColorString =
2113*35238bceSAndroid Build Coastguard Worker (m_channelClass == tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER) ? (de::toString(m_borderColor.get<int32_t>())) :
2114*35238bceSAndroid Build Coastguard Worker (m_channelClass == tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER) ? (de::toString(m_borderColor.get<uint32_t>())) :
2115*35238bceSAndroid Build Coastguard Worker (de::toString(m_borderColor.get<float>()));
2116*35238bceSAndroid Build Coastguard Worker
2117*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::Message << "Border color is " << borderColorString << "\n"
2118*35238bceSAndroid Build Coastguard Worker << "Texture lookup bias: " << samplerParams.colorBias << "\n"
2119*35238bceSAndroid Build Coastguard Worker << "Texture lookup scale: " << samplerParams.colorScale << "\n"
2120*35238bceSAndroid Build Coastguard Worker << "Filter: " << glu::getTextureFilterName(m_filter) << "\n"
2121*35238bceSAndroid Build Coastguard Worker << "Wrap mode: s = " << glu::getRepeatModeStr(m_sWrap)
2122*35238bceSAndroid Build Coastguard Worker << ", t = " << glu::getRepeatModeStr(m_tWrap) << ", r = " << glu::getRepeatModeStr(m_rWrap)
2123*35238bceSAndroid Build Coastguard Worker << "\n"
2124*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
2125*35238bceSAndroid Build Coastguard Worker }
2126*35238bceSAndroid Build Coastguard Worker
renderTo(tcu::Surface & surface,const glu::TextureTestUtil::ReferenceParams & samplerParams)2127*35238bceSAndroid Build Coastguard Worker void TextureBorderClampPerAxisCase3D::renderTo(tcu::Surface &surface,
2128*35238bceSAndroid Build Coastguard Worker const glu::TextureTestUtil::ReferenceParams &samplerParams)
2129*35238bceSAndroid Build Coastguard Worker {
2130*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
2131*35238bceSAndroid Build Coastguard Worker const gls::TextureTestUtil::RandomViewport viewport(m_context.getRenderTarget(), VIEWPORT_WIDTH, VIEWPORT_HEIGHT,
2132*35238bceSAndroid Build Coastguard Worker getCaseSeed());
2133*35238bceSAndroid Build Coastguard Worker
2134*35238bceSAndroid Build Coastguard Worker // Bind to unit 0.
2135*35238bceSAndroid Build Coastguard Worker gl.activeTexture(GL_TEXTURE0);
2136*35238bceSAndroid Build Coastguard Worker gl.bindTexture(GL_TEXTURE_3D, m_texture->getGLTexture());
2137*35238bceSAndroid Build Coastguard Worker
2138*35238bceSAndroid Build Coastguard Worker // Setup filtering and wrap modes.
2139*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, glu::getGLWrapMode(samplerParams.sampler.wrapS));
2140*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, glu::getGLWrapMode(samplerParams.sampler.wrapT));
2141*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, glu::getGLWrapMode(samplerParams.sampler.wrapR));
2142*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, glu::getGLFilterMode(samplerParams.sampler.minFilter));
2143*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, glu::getGLFilterMode(samplerParams.sampler.magFilter));
2144*35238bceSAndroid Build Coastguard Worker
2145*35238bceSAndroid Build Coastguard Worker switch (m_channelClass)
2146*35238bceSAndroid Build Coastguard Worker {
2147*35238bceSAndroid Build Coastguard Worker case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
2148*35238bceSAndroid Build Coastguard Worker case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
2149*35238bceSAndroid Build Coastguard Worker case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
2150*35238bceSAndroid Build Coastguard Worker gl.texParameterfv(GL_TEXTURE_3D, GL_TEXTURE_BORDER_COLOR, m_borderColor.getAccess<float>());
2151*35238bceSAndroid Build Coastguard Worker break;
2152*35238bceSAndroid Build Coastguard Worker
2153*35238bceSAndroid Build Coastguard Worker case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
2154*35238bceSAndroid Build Coastguard Worker gl.texParameterIiv(GL_TEXTURE_3D, GL_TEXTURE_BORDER_COLOR, m_borderColor.getAccess<int32_t>());
2155*35238bceSAndroid Build Coastguard Worker break;
2156*35238bceSAndroid Build Coastguard Worker
2157*35238bceSAndroid Build Coastguard Worker case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
2158*35238bceSAndroid Build Coastguard Worker gl.texParameterIuiv(GL_TEXTURE_3D, GL_TEXTURE_BORDER_COLOR, m_borderColor.getAccess<uint32_t>());
2159*35238bceSAndroid Build Coastguard Worker break;
2160*35238bceSAndroid Build Coastguard Worker
2161*35238bceSAndroid Build Coastguard Worker default:
2162*35238bceSAndroid Build Coastguard Worker DE_ASSERT(false);
2163*35238bceSAndroid Build Coastguard Worker }
2164*35238bceSAndroid Build Coastguard Worker
2165*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "Set texturing state");
2166*35238bceSAndroid Build Coastguard Worker
2167*35238bceSAndroid Build Coastguard Worker gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);
2168*35238bceSAndroid Build Coastguard Worker m_renderer->renderQuad(0, &m_texCoords[0], samplerParams);
2169*35238bceSAndroid Build Coastguard Worker glu::readPixels(m_context.getRenderContext(), viewport.x, viewport.y, surface.getAccess());
2170*35238bceSAndroid Build Coastguard Worker }
2171*35238bceSAndroid Build Coastguard Worker
verifyImage(const tcu::Surface & renderedFrame,const glu::TextureTestUtil::ReferenceParams & samplerParams)2172*35238bceSAndroid Build Coastguard Worker void TextureBorderClampPerAxisCase3D::verifyImage(const tcu::Surface &renderedFrame,
2173*35238bceSAndroid Build Coastguard Worker const glu::TextureTestUtil::ReferenceParams &samplerParams)
2174*35238bceSAndroid Build Coastguard Worker {
2175*35238bceSAndroid Build Coastguard Worker const tcu::PixelFormat pixelFormat = m_context.getRenderTarget().getPixelFormat();
2176*35238bceSAndroid Build Coastguard Worker const int colorErrorBits = 2;
2177*35238bceSAndroid Build Coastguard Worker const tcu::IVec4 colorBits =
2178*35238bceSAndroid Build Coastguard Worker tcu::max(glu::TextureTestUtil::getBitsVec(pixelFormat) - tcu::IVec4(colorErrorBits), tcu::IVec4(0));
2179*35238bceSAndroid Build Coastguard Worker tcu::Surface reference(renderedFrame.getWidth(), renderedFrame.getHeight());
2180*35238bceSAndroid Build Coastguard Worker tcu::Surface errorMask(renderedFrame.getWidth(), renderedFrame.getHeight());
2181*35238bceSAndroid Build Coastguard Worker tcu::LodPrecision lodPrecision;
2182*35238bceSAndroid Build Coastguard Worker tcu::LookupPrecision lookupPrecision;
2183*35238bceSAndroid Build Coastguard Worker int numFailedPixels;
2184*35238bceSAndroid Build Coastguard Worker
2185*35238bceSAndroid Build Coastguard Worker lodPrecision.derivateBits = 18;
2186*35238bceSAndroid Build Coastguard Worker lodPrecision.lodBits = 5;
2187*35238bceSAndroid Build Coastguard Worker
2188*35238bceSAndroid Build Coastguard Worker lookupPrecision.colorThreshold = tcu::computeFixedPointThreshold(colorBits) / samplerParams.colorScale;
2189*35238bceSAndroid Build Coastguard Worker lookupPrecision.coordBits = tcu::IVec3(20, 20, 0);
2190*35238bceSAndroid Build Coastguard Worker lookupPrecision.uvwBits = tcu::IVec3(5, 5, 0);
2191*35238bceSAndroid Build Coastguard Worker lookupPrecision.colorMask = glu::TextureTestUtil::getCompareMask(pixelFormat);
2192*35238bceSAndroid Build Coastguard Worker
2193*35238bceSAndroid Build Coastguard Worker glu::TextureTestUtil::sampleTexture(tcu::SurfaceAccess(reference, pixelFormat), m_texture->getRefTexture(),
2194*35238bceSAndroid Build Coastguard Worker &m_texCoords[0], samplerParams);
2195*35238bceSAndroid Build Coastguard Worker
2196*35238bceSAndroid Build Coastguard Worker numFailedPixels = glu::TextureTestUtil::computeTextureLookupDiff(
2197*35238bceSAndroid Build Coastguard Worker renderedFrame.getAccess(), reference.getAccess(), errorMask.getAccess(), m_texture->getRefTexture(),
2198*35238bceSAndroid Build Coastguard Worker &m_texCoords[0], samplerParams, lookupPrecision, lodPrecision, m_testCtx.getWatchDog());
2199*35238bceSAndroid Build Coastguard Worker
2200*35238bceSAndroid Build Coastguard Worker if (numFailedPixels > 0)
2201*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::Message << "ERROR: Result verification failed, got " << numFailedPixels
2202*35238bceSAndroid Build Coastguard Worker << " invalid pixels!" << tcu::TestLog::EndMessage;
2203*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::ImageSet("VerifyResult", "Verification result")
2204*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Image("Rendered", "Rendered image", renderedFrame);
2205*35238bceSAndroid Build Coastguard Worker if (numFailedPixels > 0)
2206*35238bceSAndroid Build Coastguard Worker {
2207*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::Image("Reference", "Ideal reference image", reference)
2208*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Image("ErrorMask", "Error mask", errorMask);
2209*35238bceSAndroid Build Coastguard Worker }
2210*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::EndImageSet;
2211*35238bceSAndroid Build Coastguard Worker
2212*35238bceSAndroid Build Coastguard Worker if (numFailedPixels == 0)
2213*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
2214*35238bceSAndroid Build Coastguard Worker else
2215*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Image verification failed");
2216*35238bceSAndroid Build Coastguard Worker }
2217*35238bceSAndroid Build Coastguard Worker
getSamplerParams(void) const2218*35238bceSAndroid Build Coastguard Worker glu::TextureTestUtil::ReferenceParams TextureBorderClampPerAxisCase3D::getSamplerParams(void) const
2219*35238bceSAndroid Build Coastguard Worker {
2220*35238bceSAndroid Build Coastguard Worker const tcu::TextureFormat texFormat = m_texture->getRefTexture().getFormat();
2221*35238bceSAndroid Build Coastguard Worker glu::TextureTestUtil::ReferenceParams refParams(glu::TextureTestUtil::TEXTURETYPE_3D);
2222*35238bceSAndroid Build Coastguard Worker
2223*35238bceSAndroid Build Coastguard Worker refParams.sampler = glu::mapGLSampler(m_sWrap, m_tWrap, m_rWrap, m_filter, m_filter);
2224*35238bceSAndroid Build Coastguard Worker refParams.sampler.borderColor = m_borderColor;
2225*35238bceSAndroid Build Coastguard Worker refParams.lodMode = glu::TextureTestUtil::LODMODE_EXACT;
2226*35238bceSAndroid Build Coastguard Worker refParams.samplerType = glu::TextureTestUtil::getSamplerType(texFormat);
2227*35238bceSAndroid Build Coastguard Worker refParams.colorScale = m_lookupScale;
2228*35238bceSAndroid Build Coastguard Worker refParams.colorBias = m_lookupBias;
2229*35238bceSAndroid Build Coastguard Worker
2230*35238bceSAndroid Build Coastguard Worker return refParams;
2231*35238bceSAndroid Build Coastguard Worker }
2232*35238bceSAndroid Build Coastguard Worker
getCaseSeed(void) const2233*35238bceSAndroid Build Coastguard Worker uint32_t TextureBorderClampPerAxisCase3D::getCaseSeed(void) const
2234*35238bceSAndroid Build Coastguard Worker {
2235*35238bceSAndroid Build Coastguard Worker tcu::SeedBuilder builder;
2236*35238bceSAndroid Build Coastguard Worker builder << std::string(getName()) << m_texFormat << m_filter << m_sWrap << m_tWrap << m_rWrap
2237*35238bceSAndroid Build Coastguard Worker << m_texture->getRefTexture().getWidth() << m_texture->getRefTexture().getHeight()
2238*35238bceSAndroid Build Coastguard Worker << m_texture->getRefTexture().getDepth();
2239*35238bceSAndroid Build Coastguard Worker return builder.get();
2240*35238bceSAndroid Build Coastguard Worker }
2241*35238bceSAndroid Build Coastguard Worker
isFormatSupported(uint32_t format,bool isGL45)2242*35238bceSAndroid Build Coastguard Worker static bool isFormatSupported(uint32_t format, bool isGL45)
2243*35238bceSAndroid Build Coastguard Worker {
2244*35238bceSAndroid Build Coastguard Worker if (isGL45 && (format == GL_LUMINANCE || format == GL_ALPHA || format == GL_LUMINANCE_ALPHA))
2245*35238bceSAndroid Build Coastguard Worker return false;
2246*35238bceSAndroid Build Coastguard Worker
2247*35238bceSAndroid Build Coastguard Worker return true;
2248*35238bceSAndroid Build Coastguard Worker }
2249*35238bceSAndroid Build Coastguard Worker
2250*35238bceSAndroid Build Coastguard Worker } // namespace
2251*35238bceSAndroid Build Coastguard Worker
TextureBorderClampTests(Context & context,bool isGL45)2252*35238bceSAndroid Build Coastguard Worker TextureBorderClampTests::TextureBorderClampTests(Context &context, bool isGL45)
2253*35238bceSAndroid Build Coastguard Worker : TestCaseGroup(context, "border_clamp", "EXT_texture_border_clamp tests")
2254*35238bceSAndroid Build Coastguard Worker , m_isGL45(isGL45)
2255*35238bceSAndroid Build Coastguard Worker {
2256*35238bceSAndroid Build Coastguard Worker }
2257*35238bceSAndroid Build Coastguard Worker
~TextureBorderClampTests(void)2258*35238bceSAndroid Build Coastguard Worker TextureBorderClampTests::~TextureBorderClampTests(void)
2259*35238bceSAndroid Build Coastguard Worker {
2260*35238bceSAndroid Build Coastguard Worker }
2261*35238bceSAndroid Build Coastguard Worker
init(void)2262*35238bceSAndroid Build Coastguard Worker void TextureBorderClampTests::init(void)
2263*35238bceSAndroid Build Coastguard Worker {
2264*35238bceSAndroid Build Coastguard Worker static const struct
2265*35238bceSAndroid Build Coastguard Worker {
2266*35238bceSAndroid Build Coastguard Worker const char *name;
2267*35238bceSAndroid Build Coastguard Worker uint32_t filter;
2268*35238bceSAndroid Build Coastguard Worker TextureBorderClampTest::SamplingFunction sampling;
2269*35238bceSAndroid Build Coastguard Worker } s_filters[] = {
2270*35238bceSAndroid Build Coastguard Worker {"nearest", GL_NEAREST, TextureBorderClampTest::SAMPLE_FILTER},
2271*35238bceSAndroid Build Coastguard Worker {"linear", GL_LINEAR, TextureBorderClampTest::SAMPLE_FILTER},
2272*35238bceSAndroid Build Coastguard Worker {"gather", GL_NEAREST, TextureBorderClampTest::SAMPLE_GATHER},
2273*35238bceSAndroid Build Coastguard Worker };
2274*35238bceSAndroid Build Coastguard Worker
2275*35238bceSAndroid Build Coastguard Worker // .formats
2276*35238bceSAndroid Build Coastguard Worker {
2277*35238bceSAndroid Build Coastguard Worker static const struct
2278*35238bceSAndroid Build Coastguard Worker {
2279*35238bceSAndroid Build Coastguard Worker const char *name;
2280*35238bceSAndroid Build Coastguard Worker uint32_t format;
2281*35238bceSAndroid Build Coastguard Worker tcu::Sampler::DepthStencilMode mode;
2282*35238bceSAndroid Build Coastguard Worker } formats[] = {
2283*35238bceSAndroid Build Coastguard Worker {"luminance", GL_LUMINANCE, tcu::Sampler::MODE_LAST},
2284*35238bceSAndroid Build Coastguard Worker {"alpha", GL_ALPHA, tcu::Sampler::MODE_LAST},
2285*35238bceSAndroid Build Coastguard Worker {"luminance_alpha", GL_LUMINANCE_ALPHA, tcu::Sampler::MODE_LAST},
2286*35238bceSAndroid Build Coastguard Worker {"bgra", GL_BGRA, tcu::Sampler::MODE_LAST},
2287*35238bceSAndroid Build Coastguard Worker {"r8", GL_R8, tcu::Sampler::MODE_LAST},
2288*35238bceSAndroid Build Coastguard Worker {"r8_snorm", GL_R8_SNORM, tcu::Sampler::MODE_LAST},
2289*35238bceSAndroid Build Coastguard Worker {"rg8", GL_RG8, tcu::Sampler::MODE_LAST},
2290*35238bceSAndroid Build Coastguard Worker {"rg8_snorm", GL_RG8_SNORM, tcu::Sampler::MODE_LAST},
2291*35238bceSAndroid Build Coastguard Worker {"rgb8", GL_RGB8, tcu::Sampler::MODE_LAST},
2292*35238bceSAndroid Build Coastguard Worker {"rgb8_snorm", GL_RGB8_SNORM, tcu::Sampler::MODE_LAST},
2293*35238bceSAndroid Build Coastguard Worker {"rgb565", GL_RGB565, tcu::Sampler::MODE_LAST},
2294*35238bceSAndroid Build Coastguard Worker {"rgba4", GL_RGBA4, tcu::Sampler::MODE_LAST},
2295*35238bceSAndroid Build Coastguard Worker {"rgb5_a1", GL_RGB5_A1, tcu::Sampler::MODE_LAST},
2296*35238bceSAndroid Build Coastguard Worker {"rgba8", GL_RGBA8, tcu::Sampler::MODE_LAST},
2297*35238bceSAndroid Build Coastguard Worker {"rgba8_snorm", GL_RGBA8_SNORM, tcu::Sampler::MODE_LAST},
2298*35238bceSAndroid Build Coastguard Worker {"rgb10_a2", GL_RGB10_A2, tcu::Sampler::MODE_LAST},
2299*35238bceSAndroid Build Coastguard Worker {"rgb10_a2ui", GL_RGB10_A2UI, tcu::Sampler::MODE_LAST},
2300*35238bceSAndroid Build Coastguard Worker {"srgb8", GL_SRGB8, tcu::Sampler::MODE_LAST},
2301*35238bceSAndroid Build Coastguard Worker {"srgb8_alpha8", GL_SRGB8_ALPHA8, tcu::Sampler::MODE_LAST},
2302*35238bceSAndroid Build Coastguard Worker {"r16f", GL_R16F, tcu::Sampler::MODE_LAST},
2303*35238bceSAndroid Build Coastguard Worker {"rg16f", GL_RG16F, tcu::Sampler::MODE_LAST},
2304*35238bceSAndroid Build Coastguard Worker {"rgb16f", GL_RGB16F, tcu::Sampler::MODE_LAST},
2305*35238bceSAndroid Build Coastguard Worker {"rgba16f", GL_RGBA16F, tcu::Sampler::MODE_LAST},
2306*35238bceSAndroid Build Coastguard Worker {"r32f", GL_R32F, tcu::Sampler::MODE_LAST},
2307*35238bceSAndroid Build Coastguard Worker {"rg32f", GL_RG32F, tcu::Sampler::MODE_LAST},
2308*35238bceSAndroid Build Coastguard Worker {"rgb32f", GL_RGB32F, tcu::Sampler::MODE_LAST},
2309*35238bceSAndroid Build Coastguard Worker {"rgba32f", GL_RGBA32F, tcu::Sampler::MODE_LAST},
2310*35238bceSAndroid Build Coastguard Worker {"r11f_g11f_b10f", GL_R11F_G11F_B10F, tcu::Sampler::MODE_LAST},
2311*35238bceSAndroid Build Coastguard Worker {"rgb9_e5", GL_RGB9_E5, tcu::Sampler::MODE_LAST},
2312*35238bceSAndroid Build Coastguard Worker {"r8i", GL_R8I, tcu::Sampler::MODE_LAST},
2313*35238bceSAndroid Build Coastguard Worker {"r8ui", GL_R8UI, tcu::Sampler::MODE_LAST},
2314*35238bceSAndroid Build Coastguard Worker {"r16i", GL_R16I, tcu::Sampler::MODE_LAST},
2315*35238bceSAndroid Build Coastguard Worker {"r16ui", GL_R16UI, tcu::Sampler::MODE_LAST},
2316*35238bceSAndroid Build Coastguard Worker {"r32i", GL_R32I, tcu::Sampler::MODE_LAST},
2317*35238bceSAndroid Build Coastguard Worker {"r32ui", GL_R32UI, tcu::Sampler::MODE_LAST},
2318*35238bceSAndroid Build Coastguard Worker {"rg8i", GL_RG8I, tcu::Sampler::MODE_LAST},
2319*35238bceSAndroid Build Coastguard Worker {"rg8ui", GL_RG8UI, tcu::Sampler::MODE_LAST},
2320*35238bceSAndroid Build Coastguard Worker {"rg16i", GL_RG16I, tcu::Sampler::MODE_LAST},
2321*35238bceSAndroid Build Coastguard Worker {"rg16ui", GL_RG16UI, tcu::Sampler::MODE_LAST},
2322*35238bceSAndroid Build Coastguard Worker {"rg32i", GL_RG32I, tcu::Sampler::MODE_LAST},
2323*35238bceSAndroid Build Coastguard Worker {"rg32ui", GL_RG32UI, tcu::Sampler::MODE_LAST},
2324*35238bceSAndroid Build Coastguard Worker {"rgb8i", GL_RGB8I, tcu::Sampler::MODE_LAST},
2325*35238bceSAndroid Build Coastguard Worker {"rgb8ui", GL_RGB8UI, tcu::Sampler::MODE_LAST},
2326*35238bceSAndroid Build Coastguard Worker {"rgb16i", GL_RGB16I, tcu::Sampler::MODE_LAST},
2327*35238bceSAndroid Build Coastguard Worker {"rgb16ui", GL_RGB16UI, tcu::Sampler::MODE_LAST},
2328*35238bceSAndroid Build Coastguard Worker {"rgb32i", GL_RGB32I, tcu::Sampler::MODE_LAST},
2329*35238bceSAndroid Build Coastguard Worker {"rgb32ui", GL_RGB32UI, tcu::Sampler::MODE_LAST},
2330*35238bceSAndroid Build Coastguard Worker {"rgba8i", GL_RGBA8I, tcu::Sampler::MODE_LAST},
2331*35238bceSAndroid Build Coastguard Worker {"rgba8ui", GL_RGBA8UI, tcu::Sampler::MODE_LAST},
2332*35238bceSAndroid Build Coastguard Worker {"rgba16i", GL_RGBA16I, tcu::Sampler::MODE_LAST},
2333*35238bceSAndroid Build Coastguard Worker {"rgba16ui", GL_RGBA16UI, tcu::Sampler::MODE_LAST},
2334*35238bceSAndroid Build Coastguard Worker {"rgba32i", GL_RGBA32I, tcu::Sampler::MODE_LAST},
2335*35238bceSAndroid Build Coastguard Worker {"rgba32ui", GL_RGBA32UI, tcu::Sampler::MODE_LAST},
2336*35238bceSAndroid Build Coastguard Worker {"depth_component16", GL_DEPTH_COMPONENT16, tcu::Sampler::MODE_DEPTH},
2337*35238bceSAndroid Build Coastguard Worker {"depth_component24", GL_DEPTH_COMPONENT24, tcu::Sampler::MODE_DEPTH},
2338*35238bceSAndroid Build Coastguard Worker {"depth_component32f", GL_DEPTH_COMPONENT32F, tcu::Sampler::MODE_DEPTH},
2339*35238bceSAndroid Build Coastguard Worker {"stencil_index8", GL_STENCIL_INDEX8, tcu::Sampler::MODE_STENCIL},
2340*35238bceSAndroid Build Coastguard Worker {"depth24_stencil8_sample_depth", GL_DEPTH24_STENCIL8, tcu::Sampler::MODE_DEPTH},
2341*35238bceSAndroid Build Coastguard Worker {"depth32f_stencil8_sample_depth", GL_DEPTH32F_STENCIL8, tcu::Sampler::MODE_DEPTH},
2342*35238bceSAndroid Build Coastguard Worker {"depth24_stencil8_sample_stencil", GL_DEPTH24_STENCIL8, tcu::Sampler::MODE_STENCIL},
2343*35238bceSAndroid Build Coastguard Worker {"depth32f_stencil8_sample_stencil", GL_DEPTH32F_STENCIL8, tcu::Sampler::MODE_STENCIL},
2344*35238bceSAndroid Build Coastguard Worker {"compressed_r11_eac", GL_COMPRESSED_R11_EAC, tcu::Sampler::MODE_LAST},
2345*35238bceSAndroid Build Coastguard Worker {"compressed_signed_r11_eac", GL_COMPRESSED_SIGNED_R11_EAC, tcu::Sampler::MODE_LAST},
2346*35238bceSAndroid Build Coastguard Worker {"compressed_rg11_eac", GL_COMPRESSED_RG11_EAC, tcu::Sampler::MODE_LAST},
2347*35238bceSAndroid Build Coastguard Worker {"compressed_signed_rg11_eac", GL_COMPRESSED_SIGNED_RG11_EAC, tcu::Sampler::MODE_LAST},
2348*35238bceSAndroid Build Coastguard Worker {"compressed_rgb8_etc2", GL_COMPRESSED_RGB8_ETC2, tcu::Sampler::MODE_LAST},
2349*35238bceSAndroid Build Coastguard Worker {"compressed_srgb8_etc2", GL_COMPRESSED_SRGB8_ETC2, tcu::Sampler::MODE_LAST},
2350*35238bceSAndroid Build Coastguard Worker {"compressed_rgb8_punchthrough_alpha1_etc2", GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
2351*35238bceSAndroid Build Coastguard Worker tcu::Sampler::MODE_LAST},
2352*35238bceSAndroid Build Coastguard Worker {"compressed_srgb8_punchthrough_alpha1_etc2", GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
2353*35238bceSAndroid Build Coastguard Worker tcu::Sampler::MODE_LAST},
2354*35238bceSAndroid Build Coastguard Worker {"compressed_rgba8_etc2_eac", GL_COMPRESSED_RGBA8_ETC2_EAC, tcu::Sampler::MODE_LAST},
2355*35238bceSAndroid Build Coastguard Worker {"compressed_srgb8_alpha8_etc2_eac", GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, tcu::Sampler::MODE_LAST},
2356*35238bceSAndroid Build Coastguard Worker };
2357*35238bceSAndroid Build Coastguard Worker
2358*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *const formatsGroup = new tcu::TestCaseGroup(m_testCtx, "formats", "Format tests");
2359*35238bceSAndroid Build Coastguard Worker addChild(formatsGroup);
2360*35238bceSAndroid Build Coastguard Worker
2361*35238bceSAndroid Build Coastguard Worker // .format
2362*35238bceSAndroid Build Coastguard Worker for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(formats); ++formatNdx)
2363*35238bceSAndroid Build Coastguard Worker {
2364*35238bceSAndroid Build Coastguard Worker const uint32_t format = formats[formatNdx].format;
2365*35238bceSAndroid Build Coastguard Worker const tcu::Sampler::DepthStencilMode sampleMode = formats[formatNdx].mode;
2366*35238bceSAndroid Build Coastguard Worker const bool isCompressed = glu::isCompressedFormat(format);
2367*35238bceSAndroid Build Coastguard Worker const bool coreFilterable = isCoreFilterableFormat(format, sampleMode);
2368*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *const formatGroup =
2369*35238bceSAndroid Build Coastguard Worker new tcu::TestCaseGroup(m_testCtx, formats[formatNdx].name, "Format test");
2370*35238bceSAndroid Build Coastguard Worker
2371*35238bceSAndroid Build Coastguard Worker formatsGroup->addChild(formatGroup);
2372*35238bceSAndroid Build Coastguard Worker
2373*35238bceSAndroid Build Coastguard Worker // .nearest
2374*35238bceSAndroid Build Coastguard Worker // .linear
2375*35238bceSAndroid Build Coastguard Worker for (int filterNdx = 0; filterNdx < DE_LENGTH_OF_ARRAY(s_filters); ++filterNdx)
2376*35238bceSAndroid Build Coastguard Worker {
2377*35238bceSAndroid Build Coastguard Worker // [not-compressed]
2378*35238bceSAndroid Build Coastguard Worker // .size_pot
2379*35238bceSAndroid Build Coastguard Worker // .size_npot
2380*35238bceSAndroid Build Coastguard Worker // [compressed]
2381*35238bceSAndroid Build Coastguard Worker // .size_tile_multiple (also pot)
2382*35238bceSAndroid Build Coastguard Worker // .size_not_tile_multiple (also npot)
2383*35238bceSAndroid Build Coastguard Worker for (int sizeNdx = 0; sizeNdx < 2; ++sizeNdx)
2384*35238bceSAndroid Build Coastguard Worker {
2385*35238bceSAndroid Build Coastguard Worker const bool isNpotCase = (sizeNdx == 1);
2386*35238bceSAndroid Build Coastguard Worker const char *const sizePotName = (!isCompressed) ? ("size_pot") : ("size_tile_multiple");
2387*35238bceSAndroid Build Coastguard Worker const char *const sizeNpotName = (!isCompressed) ? ("size_npot") : ("size_not_tile_multiple");
2388*35238bceSAndroid Build Coastguard Worker const char *const sizeName = (isNpotCase) ? (sizeNpotName) : (sizePotName);
2389*35238bceSAndroid Build Coastguard Worker const SizeType sizeType = (isNpotCase) ? (SIZE_NPOT) : (SIZE_POT);
2390*35238bceSAndroid Build Coastguard Worker const std::string caseName = std::string() + s_filters[filterNdx].name + "_" + sizeName;
2391*35238bceSAndroid Build Coastguard Worker const uint32_t filter = s_filters[filterNdx].filter;
2392*35238bceSAndroid Build Coastguard Worker
2393*35238bceSAndroid Build Coastguard Worker if ((coreFilterable || !filterRequiresFilterability(filter)) && isFormatSupported(format, m_isGL45))
2394*35238bceSAndroid Build Coastguard Worker formatGroup->addChild(
2395*35238bceSAndroid Build Coastguard Worker new TextureBorderClampFormatCase(m_context, caseName.c_str(), "", format, sampleMode,
2396*35238bceSAndroid Build Coastguard Worker TextureBorderClampFormatCase::STATE_TEXTURE_PARAM,
2397*35238bceSAndroid Build Coastguard Worker sizeType, filter, s_filters[filterNdx].sampling));
2398*35238bceSAndroid Build Coastguard Worker }
2399*35238bceSAndroid Build Coastguard Worker }
2400*35238bceSAndroid Build Coastguard Worker }
2401*35238bceSAndroid Build Coastguard Worker }
2402*35238bceSAndroid Build Coastguard Worker
2403*35238bceSAndroid Build Coastguard Worker // .range_clamp
2404*35238bceSAndroid Build Coastguard Worker {
2405*35238bceSAndroid Build Coastguard Worker static const struct
2406*35238bceSAndroid Build Coastguard Worker {
2407*35238bceSAndroid Build Coastguard Worker const char *name;
2408*35238bceSAndroid Build Coastguard Worker uint32_t format;
2409*35238bceSAndroid Build Coastguard Worker tcu::Sampler::DepthStencilMode mode;
2410*35238bceSAndroid Build Coastguard Worker } formats[] = {
2411*35238bceSAndroid Build Coastguard Worker {"unorm_color", GL_R8, tcu::Sampler::MODE_LAST},
2412*35238bceSAndroid Build Coastguard Worker {"snorm_color", GL_R8_SNORM, tcu::Sampler::MODE_LAST},
2413*35238bceSAndroid Build Coastguard Worker {"float_color", GL_RG32F, tcu::Sampler::MODE_LAST},
2414*35238bceSAndroid Build Coastguard Worker {"int_color", GL_R8I, tcu::Sampler::MODE_LAST},
2415*35238bceSAndroid Build Coastguard Worker {"uint_color", GL_R16UI, tcu::Sampler::MODE_LAST},
2416*35238bceSAndroid Build Coastguard Worker {"srgb_color", GL_SRGB8_ALPHA8, tcu::Sampler::MODE_LAST},
2417*35238bceSAndroid Build Coastguard Worker {"unorm_depth", GL_DEPTH_COMPONENT24, tcu::Sampler::MODE_DEPTH},
2418*35238bceSAndroid Build Coastguard Worker {"float_depth", GL_DEPTH_COMPONENT32F, tcu::Sampler::MODE_DEPTH},
2419*35238bceSAndroid Build Coastguard Worker {"uint_stencil", GL_STENCIL_INDEX8, tcu::Sampler::MODE_STENCIL},
2420*35238bceSAndroid Build Coastguard Worker {"float_depth_uint_stencil_sample_depth", GL_DEPTH32F_STENCIL8, tcu::Sampler::MODE_DEPTH},
2421*35238bceSAndroid Build Coastguard Worker {"float_depth_uint_stencil_sample_stencil", GL_DEPTH32F_STENCIL8, tcu::Sampler::MODE_STENCIL},
2422*35238bceSAndroid Build Coastguard Worker {"unorm_depth_uint_stencil_sample_depth", GL_DEPTH24_STENCIL8, tcu::Sampler::MODE_DEPTH},
2423*35238bceSAndroid Build Coastguard Worker {"unorm_depth_uint_stencil_sample_stencil", GL_DEPTH24_STENCIL8, tcu::Sampler::MODE_STENCIL},
2424*35238bceSAndroid Build Coastguard Worker {"compressed_color", GL_COMPRESSED_RG11_EAC, tcu::Sampler::MODE_LAST},
2425*35238bceSAndroid Build Coastguard Worker };
2426*35238bceSAndroid Build Coastguard Worker
2427*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *const rangeClampGroup =
2428*35238bceSAndroid Build Coastguard Worker new tcu::TestCaseGroup(m_testCtx, "range_clamp", "Range clamp tests");
2429*35238bceSAndroid Build Coastguard Worker addChild(rangeClampGroup);
2430*35238bceSAndroid Build Coastguard Worker
2431*35238bceSAndroid Build Coastguard Worker for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(formats); ++formatNdx)
2432*35238bceSAndroid Build Coastguard Worker for (int filterNdx = 0; filterNdx < DE_LENGTH_OF_ARRAY(s_filters); ++filterNdx)
2433*35238bceSAndroid Build Coastguard Worker {
2434*35238bceSAndroid Build Coastguard Worker const uint32_t format = formats[formatNdx].format;
2435*35238bceSAndroid Build Coastguard Worker const tcu::Sampler::DepthStencilMode sampleMode = formats[formatNdx].mode;
2436*35238bceSAndroid Build Coastguard Worker const std::string caseName = std::string() + s_filters[filterNdx].name + "_" + formats[formatNdx].name;
2437*35238bceSAndroid Build Coastguard Worker const uint32_t filter = s_filters[filterNdx].filter;
2438*35238bceSAndroid Build Coastguard Worker const bool coreFilterable = isCoreFilterableFormat(format, sampleMode);
2439*35238bceSAndroid Build Coastguard Worker
2440*35238bceSAndroid Build Coastguard Worker if (s_filters[filterNdx].sampling == TextureBorderClampTest::SAMPLE_GATHER)
2441*35238bceSAndroid Build Coastguard Worker continue;
2442*35238bceSAndroid Build Coastguard Worker
2443*35238bceSAndroid Build Coastguard Worker if (coreFilterable || !filterRequiresFilterability(filter))
2444*35238bceSAndroid Build Coastguard Worker rangeClampGroup->addChild(new TextureBorderClampRangeClampCase(m_context, caseName.c_str(), "",
2445*35238bceSAndroid Build Coastguard Worker format, sampleMode, filter));
2446*35238bceSAndroid Build Coastguard Worker }
2447*35238bceSAndroid Build Coastguard Worker }
2448*35238bceSAndroid Build Coastguard Worker
2449*35238bceSAndroid Build Coastguard Worker // .sampler
2450*35238bceSAndroid Build Coastguard Worker {
2451*35238bceSAndroid Build Coastguard Worker static const struct
2452*35238bceSAndroid Build Coastguard Worker {
2453*35238bceSAndroid Build Coastguard Worker const char *name;
2454*35238bceSAndroid Build Coastguard Worker uint32_t format;
2455*35238bceSAndroid Build Coastguard Worker tcu::Sampler::DepthStencilMode mode;
2456*35238bceSAndroid Build Coastguard Worker } formats[] = {
2457*35238bceSAndroid Build Coastguard Worker {"unorm_color", GL_R8, tcu::Sampler::MODE_LAST},
2458*35238bceSAndroid Build Coastguard Worker {"snorm_color", GL_R8_SNORM, tcu::Sampler::MODE_LAST},
2459*35238bceSAndroid Build Coastguard Worker {"float_color", GL_RG32F, tcu::Sampler::MODE_LAST},
2460*35238bceSAndroid Build Coastguard Worker {"int_color", GL_R8I, tcu::Sampler::MODE_LAST},
2461*35238bceSAndroid Build Coastguard Worker {"uint_color", GL_R16UI, tcu::Sampler::MODE_LAST},
2462*35238bceSAndroid Build Coastguard Worker {"unorm_depth", GL_DEPTH_COMPONENT24, tcu::Sampler::MODE_DEPTH},
2463*35238bceSAndroid Build Coastguard Worker {"float_depth", GL_DEPTH_COMPONENT32F, tcu::Sampler::MODE_DEPTH},
2464*35238bceSAndroid Build Coastguard Worker {"uint_stencil", GL_STENCIL_INDEX8, tcu::Sampler::MODE_STENCIL},
2465*35238bceSAndroid Build Coastguard Worker {"compressed_color", GL_COMPRESSED_RG11_EAC, tcu::Sampler::MODE_LAST},
2466*35238bceSAndroid Build Coastguard Worker };
2467*35238bceSAndroid Build Coastguard Worker
2468*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *const samplerGroup = new tcu::TestCaseGroup(m_testCtx, "sampler", "Sampler param tests");
2469*35238bceSAndroid Build Coastguard Worker addChild(samplerGroup);
2470*35238bceSAndroid Build Coastguard Worker
2471*35238bceSAndroid Build Coastguard Worker for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(formats); ++formatNdx)
2472*35238bceSAndroid Build Coastguard Worker {
2473*35238bceSAndroid Build Coastguard Worker const uint32_t format = formats[formatNdx].format;
2474*35238bceSAndroid Build Coastguard Worker const tcu::Sampler::DepthStencilMode sampleMode = formats[formatNdx].mode;
2475*35238bceSAndroid Build Coastguard Worker const char *caseName = formats[formatNdx].name;
2476*35238bceSAndroid Build Coastguard Worker
2477*35238bceSAndroid Build Coastguard Worker samplerGroup->addChild(new TextureBorderClampFormatCase(
2478*35238bceSAndroid Build Coastguard Worker m_context, caseName, "", format, sampleMode, TextureBorderClampFormatCase::STATE_SAMPLER_PARAM,
2479*35238bceSAndroid Build Coastguard Worker SIZE_POT, GL_NEAREST, TextureBorderClampFormatCase::SAMPLE_FILTER));
2480*35238bceSAndroid Build Coastguard Worker }
2481*35238bceSAndroid Build Coastguard Worker }
2482*35238bceSAndroid Build Coastguard Worker
2483*35238bceSAndroid Build Coastguard Worker // .per_axis_wrap_mode
2484*35238bceSAndroid Build Coastguard Worker {
2485*35238bceSAndroid Build Coastguard Worker static const struct
2486*35238bceSAndroid Build Coastguard Worker {
2487*35238bceSAndroid Build Coastguard Worker const char *name;
2488*35238bceSAndroid Build Coastguard Worker bool is3D;
2489*35238bceSAndroid Build Coastguard Worker } targets[] = {
2490*35238bceSAndroid Build Coastguard Worker {"texture_2d", false},
2491*35238bceSAndroid Build Coastguard Worker {"texture_3d", true},
2492*35238bceSAndroid Build Coastguard Worker };
2493*35238bceSAndroid Build Coastguard Worker static const struct
2494*35238bceSAndroid Build Coastguard Worker {
2495*35238bceSAndroid Build Coastguard Worker const char *name;
2496*35238bceSAndroid Build Coastguard Worker uint32_t format;
2497*35238bceSAndroid Build Coastguard Worker tcu::Sampler::DepthStencilMode mode;
2498*35238bceSAndroid Build Coastguard Worker bool supports3D;
2499*35238bceSAndroid Build Coastguard Worker } formats[] = {
2500*35238bceSAndroid Build Coastguard Worker {"unorm_color", GL_RG8, tcu::Sampler::MODE_LAST, true},
2501*35238bceSAndroid Build Coastguard Worker {"snorm_color", GL_RG8_SNORM, tcu::Sampler::MODE_LAST, true},
2502*35238bceSAndroid Build Coastguard Worker {"float_color", GL_R32F, tcu::Sampler::MODE_LAST, true},
2503*35238bceSAndroid Build Coastguard Worker {"int_color", GL_RG16I, tcu::Sampler::MODE_LAST, true},
2504*35238bceSAndroid Build Coastguard Worker {"uint_color", GL_R8UI, tcu::Sampler::MODE_LAST, true},
2505*35238bceSAndroid Build Coastguard Worker {"unorm_depth", GL_DEPTH_COMPONENT16, tcu::Sampler::MODE_DEPTH, false},
2506*35238bceSAndroid Build Coastguard Worker {"float_depth", GL_DEPTH32F_STENCIL8, tcu::Sampler::MODE_DEPTH, false},
2507*35238bceSAndroid Build Coastguard Worker {"uint_stencil", GL_DEPTH32F_STENCIL8, tcu::Sampler::MODE_STENCIL, false},
2508*35238bceSAndroid Build Coastguard Worker {"compressed_color", GL_COMPRESSED_RGB8_ETC2, tcu::Sampler::MODE_LAST, false},
2509*35238bceSAndroid Build Coastguard Worker };
2510*35238bceSAndroid Build Coastguard Worker static const struct
2511*35238bceSAndroid Build Coastguard Worker {
2512*35238bceSAndroid Build Coastguard Worker const char *name;
2513*35238bceSAndroid Build Coastguard Worker uint32_t sWrap;
2514*35238bceSAndroid Build Coastguard Worker uint32_t tWrap;
2515*35238bceSAndroid Build Coastguard Worker uint32_t rWrap;
2516*35238bceSAndroid Build Coastguard Worker bool is3D;
2517*35238bceSAndroid Build Coastguard Worker } wrapConfigs[] = {
2518*35238bceSAndroid Build Coastguard Worker // 2d configs
2519*35238bceSAndroid Build Coastguard Worker {"s_clamp_to_edge_t_clamp_to_border", GL_CLAMP_TO_EDGE, GL_CLAMP_TO_BORDER, GL_NONE, false},
2520*35238bceSAndroid Build Coastguard Worker {"s_repeat_t_clamp_to_border", GL_REPEAT, GL_CLAMP_TO_BORDER, GL_NONE, false},
2521*35238bceSAndroid Build Coastguard Worker {"s_mirrored_repeat_t_clamp_to_border", GL_MIRRORED_REPEAT, GL_CLAMP_TO_BORDER, GL_NONE, false},
2522*35238bceSAndroid Build Coastguard Worker
2523*35238bceSAndroid Build Coastguard Worker // 3d configs
2524*35238bceSAndroid Build Coastguard Worker {"s_clamp_to_border_t_clamp_to_border_r_clamp_to_border", GL_CLAMP_TO_BORDER, GL_CLAMP_TO_BORDER,
2525*35238bceSAndroid Build Coastguard Worker GL_CLAMP_TO_BORDER, true},
2526*35238bceSAndroid Build Coastguard Worker {"s_clamp_to_border_t_clamp_to_border_r_repeat", GL_CLAMP_TO_BORDER, GL_CLAMP_TO_BORDER, GL_REPEAT, true},
2527*35238bceSAndroid Build Coastguard Worker {"s_mirrored_repeat_t_clamp_to_border_r_repeat", GL_MIRRORED_REPEAT, GL_CLAMP_TO_BORDER, GL_REPEAT, true},
2528*35238bceSAndroid Build Coastguard Worker {"s_repeat_t_mirrored_repeat_r_clamp_to_border", GL_REPEAT, GL_MIRRORED_REPEAT, GL_CLAMP_TO_BORDER, true},
2529*35238bceSAndroid Build Coastguard Worker };
2530*35238bceSAndroid Build Coastguard Worker
2531*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *const perAxisGroup =
2532*35238bceSAndroid Build Coastguard Worker new tcu::TestCaseGroup(m_testCtx, "per_axis_wrap_mode", "Per-axis wrapping modes");
2533*35238bceSAndroid Build Coastguard Worker addChild(perAxisGroup);
2534*35238bceSAndroid Build Coastguard Worker
2535*35238bceSAndroid Build Coastguard Worker // .texture_nd
2536*35238bceSAndroid Build Coastguard Worker for (int targetNdx = 0; targetNdx < DE_LENGTH_OF_ARRAY(targets); ++targetNdx)
2537*35238bceSAndroid Build Coastguard Worker {
2538*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *const targetGroup =
2539*35238bceSAndroid Build Coastguard Worker new tcu::TestCaseGroup(m_testCtx, targets[targetNdx].name, "Texture target test");
2540*35238bceSAndroid Build Coastguard Worker perAxisGroup->addChild(targetGroup);
2541*35238bceSAndroid Build Coastguard Worker
2542*35238bceSAndroid Build Coastguard Worker // .format
2543*35238bceSAndroid Build Coastguard Worker for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(formats); ++formatNdx)
2544*35238bceSAndroid Build Coastguard Worker {
2545*35238bceSAndroid Build Coastguard Worker if (targets[targetNdx].is3D && !formats[formatNdx].supports3D)
2546*35238bceSAndroid Build Coastguard Worker continue;
2547*35238bceSAndroid Build Coastguard Worker else
2548*35238bceSAndroid Build Coastguard Worker {
2549*35238bceSAndroid Build Coastguard Worker const uint32_t format = formats[formatNdx].format;
2550*35238bceSAndroid Build Coastguard Worker const tcu::Sampler::DepthStencilMode sampleMode = formats[formatNdx].mode;
2551*35238bceSAndroid Build Coastguard Worker const bool coreFilterable = isCoreFilterableFormat(format, sampleMode);
2552*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *const formatGroup =
2553*35238bceSAndroid Build Coastguard Worker new tcu::TestCaseGroup(m_testCtx, formats[formatNdx].name, "Format test");
2554*35238bceSAndroid Build Coastguard Worker targetGroup->addChild(formatGroup);
2555*35238bceSAndroid Build Coastguard Worker
2556*35238bceSAndroid Build Coastguard Worker // .linear
2557*35238bceSAndroid Build Coastguard Worker // .nearest
2558*35238bceSAndroid Build Coastguard Worker // .gather
2559*35238bceSAndroid Build Coastguard Worker for (int filterNdx = 0; filterNdx < DE_LENGTH_OF_ARRAY(s_filters); ++filterNdx)
2560*35238bceSAndroid Build Coastguard Worker {
2561*35238bceSAndroid Build Coastguard Worker const uint32_t filter = s_filters[filterNdx].filter;
2562*35238bceSAndroid Build Coastguard Worker
2563*35238bceSAndroid Build Coastguard Worker if (!coreFilterable && filterRequiresFilterability(filter))
2564*35238bceSAndroid Build Coastguard Worker {
2565*35238bceSAndroid Build Coastguard Worker // skip linear on pure integers
2566*35238bceSAndroid Build Coastguard Worker continue;
2567*35238bceSAndroid Build Coastguard Worker }
2568*35238bceSAndroid Build Coastguard Worker else if (s_filters[filterNdx].sampling == TextureBorderClampTest::SAMPLE_GATHER &&
2569*35238bceSAndroid Build Coastguard Worker targets[targetNdx].is3D)
2570*35238bceSAndroid Build Coastguard Worker {
2571*35238bceSAndroid Build Coastguard Worker // skip gather on 3d
2572*35238bceSAndroid Build Coastguard Worker continue;
2573*35238bceSAndroid Build Coastguard Worker }
2574*35238bceSAndroid Build Coastguard Worker else
2575*35238bceSAndroid Build Coastguard Worker {
2576*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *const filteringGroup = new tcu::TestCaseGroup(
2577*35238bceSAndroid Build Coastguard Worker m_testCtx, s_filters[filterNdx].name, "Tests with specific filter");
2578*35238bceSAndroid Build Coastguard Worker formatGroup->addChild(filteringGroup);
2579*35238bceSAndroid Build Coastguard Worker
2580*35238bceSAndroid Build Coastguard Worker // .s_XXX_t_XXX(_r_XXX)
2581*35238bceSAndroid Build Coastguard Worker for (int wrapNdx = 0; wrapNdx < DE_LENGTH_OF_ARRAY(wrapConfigs); ++wrapNdx)
2582*35238bceSAndroid Build Coastguard Worker {
2583*35238bceSAndroid Build Coastguard Worker if (wrapConfigs[wrapNdx].is3D != targets[targetNdx].is3D)
2584*35238bceSAndroid Build Coastguard Worker continue;
2585*35238bceSAndroid Build Coastguard Worker else
2586*35238bceSAndroid Build Coastguard Worker {
2587*35238bceSAndroid Build Coastguard Worker for (int sizeNdx = 0; sizeNdx < 2; ++sizeNdx)
2588*35238bceSAndroid Build Coastguard Worker {
2589*35238bceSAndroid Build Coastguard Worker const char *const wrapName = wrapConfigs[wrapNdx].name;
2590*35238bceSAndroid Build Coastguard Worker const bool isNpotCase = (sizeNdx == 1);
2591*35238bceSAndroid Build Coastguard Worker const char *const sizeNameExtension = (isNpotCase) ? ("_npot") : ("_pot");
2592*35238bceSAndroid Build Coastguard Worker const SizeType size = (isNpotCase) ? (SIZE_NPOT) : (SIZE_POT);
2593*35238bceSAndroid Build Coastguard Worker
2594*35238bceSAndroid Build Coastguard Worker if (!targets[targetNdx].is3D)
2595*35238bceSAndroid Build Coastguard Worker filteringGroup->addChild(new TextureBorderClampPerAxisCase2D(
2596*35238bceSAndroid Build Coastguard Worker m_context, (std::string() + wrapName + sizeNameExtension).c_str(), "",
2597*35238bceSAndroid Build Coastguard Worker format, sampleMode, size, filter, wrapConfigs[wrapNdx].sWrap,
2598*35238bceSAndroid Build Coastguard Worker wrapConfigs[wrapNdx].tWrap, s_filters[filterNdx].sampling));
2599*35238bceSAndroid Build Coastguard Worker else
2600*35238bceSAndroid Build Coastguard Worker {
2601*35238bceSAndroid Build Coastguard Worker DE_ASSERT(sampleMode == tcu::Sampler::MODE_LAST);
2602*35238bceSAndroid Build Coastguard Worker filteringGroup->addChild(new TextureBorderClampPerAxisCase3D(
2603*35238bceSAndroid Build Coastguard Worker m_context, (std::string() + wrapName + sizeNameExtension).c_str(), "",
2604*35238bceSAndroid Build Coastguard Worker format, size, filter, wrapConfigs[wrapNdx].sWrap,
2605*35238bceSAndroid Build Coastguard Worker wrapConfigs[wrapNdx].tWrap, wrapConfigs[wrapNdx].rWrap));
2606*35238bceSAndroid Build Coastguard Worker }
2607*35238bceSAndroid Build Coastguard Worker }
2608*35238bceSAndroid Build Coastguard Worker }
2609*35238bceSAndroid Build Coastguard Worker }
2610*35238bceSAndroid Build Coastguard Worker }
2611*35238bceSAndroid Build Coastguard Worker }
2612*35238bceSAndroid Build Coastguard Worker }
2613*35238bceSAndroid Build Coastguard Worker }
2614*35238bceSAndroid Build Coastguard Worker }
2615*35238bceSAndroid Build Coastguard Worker }
2616*35238bceSAndroid Build Coastguard Worker
2617*35238bceSAndroid Build Coastguard Worker // .depth_compare_mode
2618*35238bceSAndroid Build Coastguard Worker {
2619*35238bceSAndroid Build Coastguard Worker static const struct
2620*35238bceSAndroid Build Coastguard Worker {
2621*35238bceSAndroid Build Coastguard Worker const char *name;
2622*35238bceSAndroid Build Coastguard Worker uint32_t format;
2623*35238bceSAndroid Build Coastguard Worker } formats[] = {
2624*35238bceSAndroid Build Coastguard Worker {"depth_component16", GL_DEPTH_COMPONENT16},
2625*35238bceSAndroid Build Coastguard Worker {"depth_component24", GL_DEPTH_COMPONENT24},
2626*35238bceSAndroid Build Coastguard Worker {"depth24_stencil8", GL_DEPTH24_STENCIL8},
2627*35238bceSAndroid Build Coastguard Worker {"depth32f_stencil8", GL_DEPTH32F_STENCIL8},
2628*35238bceSAndroid Build Coastguard Worker };
2629*35238bceSAndroid Build Coastguard Worker
2630*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *const compareGroup =
2631*35238bceSAndroid Build Coastguard Worker new tcu::TestCaseGroup(m_testCtx, "depth_compare_mode", "Tests depth compare mode");
2632*35238bceSAndroid Build Coastguard Worker addChild(compareGroup);
2633*35238bceSAndroid Build Coastguard Worker
2634*35238bceSAndroid Build Coastguard Worker for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(formats); ++formatNdx)
2635*35238bceSAndroid Build Coastguard Worker {
2636*35238bceSAndroid Build Coastguard Worker const uint32_t format = formats[formatNdx].format;
2637*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *const formatGroup =
2638*35238bceSAndroid Build Coastguard Worker new tcu::TestCaseGroup(m_testCtx, formats[formatNdx].name, "Format test");
2639*35238bceSAndroid Build Coastguard Worker
2640*35238bceSAndroid Build Coastguard Worker compareGroup->addChild(formatGroup);
2641*35238bceSAndroid Build Coastguard Worker
2642*35238bceSAndroid Build Coastguard Worker // (format).(linear|nearest|gather)_(pot|npot)
2643*35238bceSAndroid Build Coastguard Worker for (int filterNdx = 0; filterNdx < DE_LENGTH_OF_ARRAY(s_filters); ++filterNdx)
2644*35238bceSAndroid Build Coastguard Worker for (int sizeNdx = 0; sizeNdx < 2; ++sizeNdx)
2645*35238bceSAndroid Build Coastguard Worker {
2646*35238bceSAndroid Build Coastguard Worker const bool isNpotCase = (sizeNdx == 1);
2647*35238bceSAndroid Build Coastguard Worker const char *const sizeName = (isNpotCase) ? ("size_npot") : ("size_pot");
2648*35238bceSAndroid Build Coastguard Worker const SizeType sizeType = (isNpotCase) ? (SIZE_NPOT) : (SIZE_POT);
2649*35238bceSAndroid Build Coastguard Worker const std::string caseName = std::string() + s_filters[filterNdx].name + "_" + sizeName;
2650*35238bceSAndroid Build Coastguard Worker const uint32_t filter = s_filters[filterNdx].filter;
2651*35238bceSAndroid Build Coastguard Worker
2652*35238bceSAndroid Build Coastguard Worker formatGroup->addChild(new TextureBorderClampDepthCompareCase(
2653*35238bceSAndroid Build Coastguard Worker m_context, caseName.c_str(), "", format, sizeType, filter, s_filters[filterNdx].sampling));
2654*35238bceSAndroid Build Coastguard Worker }
2655*35238bceSAndroid Build Coastguard Worker }
2656*35238bceSAndroid Build Coastguard Worker }
2657*35238bceSAndroid Build Coastguard Worker
2658*35238bceSAndroid Build Coastguard Worker // unused channels (A in rgb, G in stencil etc.)
2659*35238bceSAndroid Build Coastguard Worker {
2660*35238bceSAndroid Build Coastguard Worker static const struct
2661*35238bceSAndroid Build Coastguard Worker {
2662*35238bceSAndroid Build Coastguard Worker const char *name;
2663*35238bceSAndroid Build Coastguard Worker uint32_t format;
2664*35238bceSAndroid Build Coastguard Worker tcu::Sampler::DepthStencilMode mode;
2665*35238bceSAndroid Build Coastguard Worker } formats[] = {
2666*35238bceSAndroid Build Coastguard Worker {"r8", GL_R8, tcu::Sampler::MODE_LAST},
2667*35238bceSAndroid Build Coastguard Worker {"rg8_snorm", GL_RG8_SNORM, tcu::Sampler::MODE_LAST},
2668*35238bceSAndroid Build Coastguard Worker {"rgb8", GL_RGB8, tcu::Sampler::MODE_LAST},
2669*35238bceSAndroid Build Coastguard Worker {"rg32f", GL_RG32F, tcu::Sampler::MODE_LAST},
2670*35238bceSAndroid Build Coastguard Worker {"r16i", GL_RG16I, tcu::Sampler::MODE_LAST},
2671*35238bceSAndroid Build Coastguard Worker {"luminance", GL_LUMINANCE, tcu::Sampler::MODE_LAST},
2672*35238bceSAndroid Build Coastguard Worker {"alpha", GL_ALPHA, tcu::Sampler::MODE_LAST},
2673*35238bceSAndroid Build Coastguard Worker {"luminance_alpha", GL_LUMINANCE_ALPHA, tcu::Sampler::MODE_LAST},
2674*35238bceSAndroid Build Coastguard Worker {"depth_component16", GL_DEPTH_COMPONENT16, tcu::Sampler::MODE_DEPTH},
2675*35238bceSAndroid Build Coastguard Worker {"depth_component32f", GL_DEPTH_COMPONENT32F, tcu::Sampler::MODE_DEPTH},
2676*35238bceSAndroid Build Coastguard Worker {"stencil_index8", GL_STENCIL_INDEX8, tcu::Sampler::MODE_STENCIL},
2677*35238bceSAndroid Build Coastguard Worker {"depth32f_stencil8_sample_depth", GL_DEPTH32F_STENCIL8, tcu::Sampler::MODE_DEPTH},
2678*35238bceSAndroid Build Coastguard Worker {"depth32f_stencil8_sample_stencil", GL_DEPTH32F_STENCIL8, tcu::Sampler::MODE_STENCIL},
2679*35238bceSAndroid Build Coastguard Worker {"depth24_stencil8_sample_depth", GL_DEPTH24_STENCIL8, tcu::Sampler::MODE_DEPTH},
2680*35238bceSAndroid Build Coastguard Worker {"depth24_stencil8_sample_stencil", GL_DEPTH24_STENCIL8, tcu::Sampler::MODE_STENCIL},
2681*35238bceSAndroid Build Coastguard Worker {"compressed_r11_eac", GL_COMPRESSED_R11_EAC, tcu::Sampler::MODE_LAST},
2682*35238bceSAndroid Build Coastguard Worker };
2683*35238bceSAndroid Build Coastguard Worker
2684*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *const unusedGroup = new tcu::TestCaseGroup(
2685*35238bceSAndroid Build Coastguard Worker m_testCtx, "unused_channels", "Tests channels that are not present in the internal format");
2686*35238bceSAndroid Build Coastguard Worker addChild(unusedGroup);
2687*35238bceSAndroid Build Coastguard Worker
2688*35238bceSAndroid Build Coastguard Worker for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(formats); ++formatNdx)
2689*35238bceSAndroid Build Coastguard Worker {
2690*35238bceSAndroid Build Coastguard Worker if (isFormatSupported(formats[formatNdx].format, m_isGL45))
2691*35238bceSAndroid Build Coastguard Worker {
2692*35238bceSAndroid Build Coastguard Worker unusedGroup->addChild(new TextureBorderClampUnusedChannelCase(
2693*35238bceSAndroid Build Coastguard Worker m_context, formats[formatNdx].name, "", formats[formatNdx].format, formats[formatNdx].mode));
2694*35238bceSAndroid Build Coastguard Worker }
2695*35238bceSAndroid Build Coastguard Worker }
2696*35238bceSAndroid Build Coastguard Worker }
2697*35238bceSAndroid Build Coastguard Worker }
2698*35238bceSAndroid Build Coastguard Worker
2699*35238bceSAndroid Build Coastguard Worker } // namespace Functional
2700*35238bceSAndroid Build Coastguard Worker } // namespace gles31
2701*35238bceSAndroid Build Coastguard Worker } // namespace deqp
2702