xref: /aosp_15_r20/external/deqp/modules/gles31/functional/es31fStencilTexturingTests.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
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 2014 The Android Open Source Project
6*35238bceSAndroid Build Coastguard Worker  *
7*35238bceSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
8*35238bceSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
9*35238bceSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
10*35238bceSAndroid Build Coastguard Worker  *
11*35238bceSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
12*35238bceSAndroid Build Coastguard Worker  *
13*35238bceSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
14*35238bceSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
15*35238bceSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16*35238bceSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
17*35238bceSAndroid Build Coastguard Worker  * limitations under the License.
18*35238bceSAndroid Build Coastguard Worker  *
19*35238bceSAndroid Build Coastguard Worker  *//*!
20*35238bceSAndroid Build Coastguard Worker  * \file
21*35238bceSAndroid Build Coastguard Worker  * \brief Stencil texturing tests.
22*35238bceSAndroid Build Coastguard Worker  *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker 
24*35238bceSAndroid Build Coastguard Worker #include "es31fStencilTexturingTests.hpp"
25*35238bceSAndroid Build Coastguard Worker 
26*35238bceSAndroid Build Coastguard Worker #include "gluStrUtil.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "gluObjectWrapper.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "gluRenderContext.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "gluShaderProgram.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "gluDrawUtil.hpp"
31*35238bceSAndroid Build Coastguard Worker #include "gluPixelTransfer.hpp"
32*35238bceSAndroid Build Coastguard Worker #include "gluTextureUtil.hpp"
33*35238bceSAndroid Build Coastguard Worker #include "gluContextInfo.hpp"
34*35238bceSAndroid Build Coastguard Worker 
35*35238bceSAndroid Build Coastguard Worker #include "glsTextureTestUtil.hpp"
36*35238bceSAndroid Build Coastguard Worker 
37*35238bceSAndroid Build Coastguard Worker #include "tcuVector.hpp"
38*35238bceSAndroid Build Coastguard Worker #include "tcuTexture.hpp"
39*35238bceSAndroid Build Coastguard Worker #include "tcuTextureUtil.hpp"
40*35238bceSAndroid Build Coastguard Worker #include "tcuTestLog.hpp"
41*35238bceSAndroid Build Coastguard Worker #include "tcuTexLookupVerifier.hpp"
42*35238bceSAndroid Build Coastguard Worker 
43*35238bceSAndroid Build Coastguard Worker #include "glwFunctions.hpp"
44*35238bceSAndroid Build Coastguard Worker #include "glwEnums.hpp"
45*35238bceSAndroid Build Coastguard Worker 
46*35238bceSAndroid Build Coastguard Worker #include "deStringUtil.hpp"
47*35238bceSAndroid Build Coastguard Worker 
48*35238bceSAndroid Build Coastguard Worker namespace deqp
49*35238bceSAndroid Build Coastguard Worker {
50*35238bceSAndroid Build Coastguard Worker namespace gles31
51*35238bceSAndroid Build Coastguard Worker {
52*35238bceSAndroid Build Coastguard Worker namespace Functional
53*35238bceSAndroid Build Coastguard Worker {
54*35238bceSAndroid Build Coastguard Worker 
55*35238bceSAndroid Build Coastguard Worker using std::string;
56*35238bceSAndroid Build Coastguard Worker using std::vector;
57*35238bceSAndroid Build Coastguard Worker using tcu::IVec4;
58*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
59*35238bceSAndroid Build Coastguard Worker using tcu::TextureFormat;
60*35238bceSAndroid Build Coastguard Worker using tcu::TextureLevel;
61*35238bceSAndroid Build Coastguard Worker using tcu::Vec2;
62*35238bceSAndroid Build Coastguard Worker using tcu::Vec4;
63*35238bceSAndroid Build Coastguard Worker 
64*35238bceSAndroid Build Coastguard Worker namespace
65*35238bceSAndroid Build Coastguard Worker {
66*35238bceSAndroid Build Coastguard Worker 
genTestRects(vector<IVec4> & rects,int width,int height)67*35238bceSAndroid Build Coastguard Worker static void genTestRects(vector<IVec4> &rects, int width, int height)
68*35238bceSAndroid Build Coastguard Worker {
69*35238bceSAndroid Build Coastguard Worker     int curWidth  = width;
70*35238bceSAndroid Build Coastguard Worker     int curHeight = height;
71*35238bceSAndroid Build Coastguard Worker     int ndx       = 0;
72*35238bceSAndroid Build Coastguard Worker 
73*35238bceSAndroid Build Coastguard Worker     for (;;)
74*35238bceSAndroid Build Coastguard Worker     {
75*35238bceSAndroid Build Coastguard Worker         rects.push_back(IVec4(width - curWidth, height - curHeight, curWidth, curHeight));
76*35238bceSAndroid Build Coastguard Worker 
77*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(curWidth >= 1 && curHeight >= 1);
78*35238bceSAndroid Build Coastguard Worker         if (curWidth == 1 && curHeight == 1)
79*35238bceSAndroid Build Coastguard Worker             break;
80*35238bceSAndroid Build Coastguard Worker         else if (curHeight > 1 && ((ndx % 2) == 0 || curWidth == 1))
81*35238bceSAndroid Build Coastguard Worker             curHeight -= 1;
82*35238bceSAndroid Build Coastguard Worker         else
83*35238bceSAndroid Build Coastguard Worker             curWidth -= 1;
84*35238bceSAndroid Build Coastguard Worker 
85*35238bceSAndroid Build Coastguard Worker         ndx += 1;
86*35238bceSAndroid Build Coastguard Worker     }
87*35238bceSAndroid Build Coastguard Worker }
88*35238bceSAndroid Build Coastguard Worker 
rectsToTriangles(const vector<IVec4> & rects,int width,int height,vector<Vec2> & positions,vector<uint16_t> & indices)89*35238bceSAndroid Build Coastguard Worker static void rectsToTriangles(const vector<IVec4> &rects, int width, int height, vector<Vec2> &positions,
90*35238bceSAndroid Build Coastguard Worker                              vector<uint16_t> &indices)
91*35238bceSAndroid Build Coastguard Worker {
92*35238bceSAndroid Build Coastguard Worker     const float w = float(width);
93*35238bceSAndroid Build Coastguard Worker     const float h = float(height);
94*35238bceSAndroid Build Coastguard Worker 
95*35238bceSAndroid Build Coastguard Worker     positions.resize(rects.size() * 4);
96*35238bceSAndroid Build Coastguard Worker     indices.resize(rects.size() * 6);
97*35238bceSAndroid Build Coastguard Worker 
98*35238bceSAndroid Build Coastguard Worker     for (int rectNdx = 0; rectNdx < (int)rects.size(); rectNdx++)
99*35238bceSAndroid Build Coastguard Worker     {
100*35238bceSAndroid Build Coastguard Worker         const int rx = rects[rectNdx].x();
101*35238bceSAndroid Build Coastguard Worker         const int ry = rects[rectNdx].y();
102*35238bceSAndroid Build Coastguard Worker         const int rw = rects[rectNdx].z();
103*35238bceSAndroid Build Coastguard Worker         const int rh = rects[rectNdx].w();
104*35238bceSAndroid Build Coastguard Worker 
105*35238bceSAndroid Build Coastguard Worker         const float x0 = float(rx * 2) / w - 1.0f;
106*35238bceSAndroid Build Coastguard Worker         const float x1 = float((rx + rw) * 2) / w - 1.0f;
107*35238bceSAndroid Build Coastguard Worker         const float y0 = float(ry * 2) / h - 1.0f;
108*35238bceSAndroid Build Coastguard Worker         const float y1 = float((ry + rh) * 2) / h - 1.0f;
109*35238bceSAndroid Build Coastguard Worker 
110*35238bceSAndroid Build Coastguard Worker         positions[rectNdx * 4 + 0] = Vec2(x0, y0);
111*35238bceSAndroid Build Coastguard Worker         positions[rectNdx * 4 + 1] = Vec2(x1, y0);
112*35238bceSAndroid Build Coastguard Worker         positions[rectNdx * 4 + 2] = Vec2(x0, y1);
113*35238bceSAndroid Build Coastguard Worker         positions[rectNdx * 4 + 3] = Vec2(x1, y1);
114*35238bceSAndroid Build Coastguard Worker 
115*35238bceSAndroid Build Coastguard Worker         indices[rectNdx * 6 + 0] = (uint16_t)(rectNdx * 4 + 0);
116*35238bceSAndroid Build Coastguard Worker         indices[rectNdx * 6 + 1] = (uint16_t)(rectNdx * 4 + 1);
117*35238bceSAndroid Build Coastguard Worker         indices[rectNdx * 6 + 2] = (uint16_t)(rectNdx * 4 + 2);
118*35238bceSAndroid Build Coastguard Worker         indices[rectNdx * 6 + 3] = (uint16_t)(rectNdx * 4 + 2);
119*35238bceSAndroid Build Coastguard Worker         indices[rectNdx * 6 + 4] = (uint16_t)(rectNdx * 4 + 1);
120*35238bceSAndroid Build Coastguard Worker         indices[rectNdx * 6 + 5] = (uint16_t)(rectNdx * 4 + 3);
121*35238bceSAndroid Build Coastguard Worker     }
122*35238bceSAndroid Build Coastguard Worker }
123*35238bceSAndroid Build Coastguard Worker 
drawTestPattern(const glu::RenderContext & renderCtx,int width,int height)124*35238bceSAndroid Build Coastguard Worker static void drawTestPattern(const glu::RenderContext &renderCtx, int width, int height)
125*35238bceSAndroid Build Coastguard Worker {
126*35238bceSAndroid Build Coastguard Worker     const glu::ShaderProgram program(renderCtx, glu::ProgramSources()
127*35238bceSAndroid Build Coastguard Worker                                                     << glu::VertexSource("#version 300 es\n"
128*35238bceSAndroid Build Coastguard Worker                                                                          "in highp vec4 a_position;\n"
129*35238bceSAndroid Build Coastguard Worker                                                                          "void main (void)\n"
130*35238bceSAndroid Build Coastguard Worker                                                                          "{\n"
131*35238bceSAndroid Build Coastguard Worker                                                                          "    gl_Position = a_position;\n"
132*35238bceSAndroid Build Coastguard Worker                                                                          "}\n")
133*35238bceSAndroid Build Coastguard Worker                                                     << glu::FragmentSource("#version 300 es\n"
134*35238bceSAndroid Build Coastguard Worker                                                                            "void main (void) {}\n"));
135*35238bceSAndroid Build Coastguard Worker 
136*35238bceSAndroid Build Coastguard Worker     const glw::Functions &gl = renderCtx.getFunctions();
137*35238bceSAndroid Build Coastguard Worker     vector<IVec4> rects;
138*35238bceSAndroid Build Coastguard Worker     vector<Vec2> positions;
139*35238bceSAndroid Build Coastguard Worker     vector<uint16_t> indices;
140*35238bceSAndroid Build Coastguard Worker 
141*35238bceSAndroid Build Coastguard Worker     if (!program.isOk())
142*35238bceSAndroid Build Coastguard Worker         throw tcu::TestError("Compile failed");
143*35238bceSAndroid Build Coastguard Worker 
144*35238bceSAndroid Build Coastguard Worker     gl.useProgram(program.getProgram());
145*35238bceSAndroid Build Coastguard Worker     gl.viewport(0, 0, width, height);
146*35238bceSAndroid Build Coastguard Worker     gl.clear(GL_STENCIL_BUFFER_BIT);
147*35238bceSAndroid Build Coastguard Worker     gl.enable(GL_STENCIL_TEST);
148*35238bceSAndroid Build Coastguard Worker     gl.stencilOp(GL_KEEP, GL_KEEP, GL_INCR_WRAP);
149*35238bceSAndroid Build Coastguard Worker     gl.stencilFunc(GL_ALWAYS, 0, ~0u);
150*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(gl.getError(), "State setup failed");
151*35238bceSAndroid Build Coastguard Worker 
152*35238bceSAndroid Build Coastguard Worker     genTestRects(rects, width, height);
153*35238bceSAndroid Build Coastguard Worker     rectsToTriangles(rects, width, height, positions, indices);
154*35238bceSAndroid Build Coastguard Worker 
155*35238bceSAndroid Build Coastguard Worker     {
156*35238bceSAndroid Build Coastguard Worker         const glu::VertexArrayBinding posBinding =
157*35238bceSAndroid Build Coastguard Worker             glu::va::Float("a_position", 2, (int)positions.size(), 0, positions[0].getPtr());
158*35238bceSAndroid Build Coastguard Worker         glu::draw(renderCtx, program.getProgram(), 1, &posBinding,
159*35238bceSAndroid Build Coastguard Worker                   glu::pr::Triangles((int)indices.size(), &indices[0]));
160*35238bceSAndroid Build Coastguard Worker     }
161*35238bceSAndroid Build Coastguard Worker 
162*35238bceSAndroid Build Coastguard Worker     gl.disable(GL_STENCIL_TEST);
163*35238bceSAndroid Build Coastguard Worker }
164*35238bceSAndroid Build Coastguard Worker 
renderTestPatternReference(const tcu::PixelBufferAccess & dst)165*35238bceSAndroid Build Coastguard Worker static void renderTestPatternReference(const tcu::PixelBufferAccess &dst)
166*35238bceSAndroid Build Coastguard Worker {
167*35238bceSAndroid Build Coastguard Worker     const int stencilBits =
168*35238bceSAndroid Build Coastguard Worker         tcu::getTextureFormatBitDepth(tcu::getEffectiveDepthStencilAccess(dst, tcu::Sampler::MODE_STENCIL).getFormat())
169*35238bceSAndroid Build Coastguard Worker             .x();
170*35238bceSAndroid Build Coastguard Worker     const uint32_t stencilMask = (1u << stencilBits) - 1u;
171*35238bceSAndroid Build Coastguard Worker     vector<IVec4> rects;
172*35238bceSAndroid Build Coastguard Worker 
173*35238bceSAndroid Build Coastguard Worker     DE_ASSERT(dst.getFormat().order == TextureFormat::S || dst.getFormat().order == TextureFormat::DS);
174*35238bceSAndroid Build Coastguard Worker 
175*35238bceSAndroid Build Coastguard Worker     // clear depth and stencil
176*35238bceSAndroid Build Coastguard Worker     if (dst.getFormat().order == TextureFormat::DS)
177*35238bceSAndroid Build Coastguard Worker         tcu::clearDepth(dst, 0.0f);
178*35238bceSAndroid Build Coastguard Worker     tcu::clearStencil(dst, 0u);
179*35238bceSAndroid Build Coastguard Worker 
180*35238bceSAndroid Build Coastguard Worker     genTestRects(rects, dst.getWidth(), dst.getHeight());
181*35238bceSAndroid Build Coastguard Worker 
182*35238bceSAndroid Build Coastguard Worker     for (vector<IVec4>::const_iterator rectIter = rects.begin(); rectIter != rects.end(); ++rectIter)
183*35238bceSAndroid Build Coastguard Worker     {
184*35238bceSAndroid Build Coastguard Worker         const int x0 = rectIter->x();
185*35238bceSAndroid Build Coastguard Worker         const int y0 = rectIter->y();
186*35238bceSAndroid Build Coastguard Worker         const int x1 = x0 + rectIter->z();
187*35238bceSAndroid Build Coastguard Worker         const int y1 = y0 + rectIter->w();
188*35238bceSAndroid Build Coastguard Worker 
189*35238bceSAndroid Build Coastguard Worker         for (int y = y0; y < y1; y++)
190*35238bceSAndroid Build Coastguard Worker         {
191*35238bceSAndroid Build Coastguard Worker             for (int x = x0; x < x1; x++)
192*35238bceSAndroid Build Coastguard Worker             {
193*35238bceSAndroid Build Coastguard Worker                 const int oldVal = dst.getPixStencil(x, y);
194*35238bceSAndroid Build Coastguard Worker                 const int newVal = (oldVal + 1) & stencilMask;
195*35238bceSAndroid Build Coastguard Worker 
196*35238bceSAndroid Build Coastguard Worker                 dst.setPixStencil(newVal, x, y);
197*35238bceSAndroid Build Coastguard Worker             }
198*35238bceSAndroid Build Coastguard Worker         }
199*35238bceSAndroid Build Coastguard Worker     }
200*35238bceSAndroid Build Coastguard Worker }
201*35238bceSAndroid Build Coastguard Worker 
blitStencilToColor2D(const glu::RenderContext & renderCtx,uint32_t srcTex,int width,int height)202*35238bceSAndroid Build Coastguard Worker static void blitStencilToColor2D(const glu::RenderContext &renderCtx, uint32_t srcTex, int width, int height)
203*35238bceSAndroid Build Coastguard Worker {
204*35238bceSAndroid Build Coastguard Worker     const glu::ShaderProgram program(
205*35238bceSAndroid Build Coastguard Worker         renderCtx, glu::ProgramSources() << glu::VertexSource("#version 300 es\n"
206*35238bceSAndroid Build Coastguard Worker                                                               "in highp vec4 a_position;\n"
207*35238bceSAndroid Build Coastguard Worker                                                               "in highp vec2 a_texCoord;\n"
208*35238bceSAndroid Build Coastguard Worker                                                               "out highp vec2 v_texCoord;\n"
209*35238bceSAndroid Build Coastguard Worker                                                               "void main (void)\n"
210*35238bceSAndroid Build Coastguard Worker                                                               "{\n"
211*35238bceSAndroid Build Coastguard Worker                                                               "    gl_Position = a_position;\n"
212*35238bceSAndroid Build Coastguard Worker                                                               "    v_texCoord = a_texCoord;\n"
213*35238bceSAndroid Build Coastguard Worker                                                               "}\n")
214*35238bceSAndroid Build Coastguard Worker                                          << glu::FragmentSource("#version 300 es\n"
215*35238bceSAndroid Build Coastguard Worker                                                                 "uniform highp usampler2D u_sampler;\n"
216*35238bceSAndroid Build Coastguard Worker                                                                 "in highp vec2 v_texCoord;\n"
217*35238bceSAndroid Build Coastguard Worker                                                                 "layout(location = 0) out highp uint o_stencil;\n"
218*35238bceSAndroid Build Coastguard Worker                                                                 "void main (void)\n"
219*35238bceSAndroid Build Coastguard Worker                                                                 "{\n"
220*35238bceSAndroid Build Coastguard Worker                                                                 "    o_stencil = texture(u_sampler, v_texCoord).x;\n"
221*35238bceSAndroid Build Coastguard Worker                                                                 "}\n"));
222*35238bceSAndroid Build Coastguard Worker 
223*35238bceSAndroid Build Coastguard Worker     const float positions[]                      = {-1.0f, -1.0f, +1.0f, -1.0f, -1.0f, +1.0f, +1.0f, +1.0f};
224*35238bceSAndroid Build Coastguard Worker     const float texCoord[]                       = {0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f};
225*35238bceSAndroid Build Coastguard Worker     const glu::VertexArrayBinding vertexArrays[] = {glu::va::Float("a_position", 2, 4, 0, &positions[0]),
226*35238bceSAndroid Build Coastguard Worker                                                     glu::va::Float("a_texCoord", 2, 4, 0, &texCoord[0])};
227*35238bceSAndroid Build Coastguard Worker     const uint8_t indices[]                      = {0, 1, 2, 2, 1, 3};
228*35238bceSAndroid Build Coastguard Worker 
229*35238bceSAndroid Build Coastguard Worker     const glw::Functions &gl = renderCtx.getFunctions();
230*35238bceSAndroid Build Coastguard Worker 
231*35238bceSAndroid Build Coastguard Worker     if (!program.isOk())
232*35238bceSAndroid Build Coastguard Worker         throw tcu::TestError("Compile failed");
233*35238bceSAndroid Build Coastguard Worker 
234*35238bceSAndroid Build Coastguard Worker     gl.activeTexture(GL_TEXTURE0);
235*35238bceSAndroid Build Coastguard Worker     gl.bindTexture(GL_TEXTURE_2D, srcTex);
236*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
237*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
238*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, GL_STENCIL_INDEX);
239*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(gl.getError(), "Texture state setup failed");
240*35238bceSAndroid Build Coastguard Worker 
241*35238bceSAndroid Build Coastguard Worker     gl.useProgram(program.getProgram());
242*35238bceSAndroid Build Coastguard Worker     gl.uniform1i(gl.getUniformLocation(program.getProgram(), "u_sampler"), 0);
243*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(gl.getError(), "Program setup failed");
244*35238bceSAndroid Build Coastguard Worker 
245*35238bceSAndroid Build Coastguard Worker     gl.viewport(0, 0, width, height);
246*35238bceSAndroid Build Coastguard Worker     glu::draw(renderCtx, program.getProgram(), DE_LENGTH_OF_ARRAY(vertexArrays), &vertexArrays[0],
247*35238bceSAndroid Build Coastguard Worker               glu::pr::Triangles(DE_LENGTH_OF_ARRAY(indices), &indices[0]));
248*35238bceSAndroid Build Coastguard Worker }
249*35238bceSAndroid Build Coastguard Worker 
blitStencilToColor2DArray(const glu::RenderContext & renderCtx,uint32_t srcTex,int width,int height,int level)250*35238bceSAndroid Build Coastguard Worker static void blitStencilToColor2DArray(const glu::RenderContext &renderCtx, uint32_t srcTex, int width, int height,
251*35238bceSAndroid Build Coastguard Worker                                       int level)
252*35238bceSAndroid Build Coastguard Worker {
253*35238bceSAndroid Build Coastguard Worker     const glu::ShaderProgram program(
254*35238bceSAndroid Build Coastguard Worker         renderCtx, glu::ProgramSources() << glu::VertexSource("#version 300 es\n"
255*35238bceSAndroid Build Coastguard Worker                                                               "in highp vec4 a_position;\n"
256*35238bceSAndroid Build Coastguard Worker                                                               "in highp vec3 a_texCoord;\n"
257*35238bceSAndroid Build Coastguard Worker                                                               "out highp vec3 v_texCoord;\n"
258*35238bceSAndroid Build Coastguard Worker                                                               "void main (void)\n"
259*35238bceSAndroid Build Coastguard Worker                                                               "{\n"
260*35238bceSAndroid Build Coastguard Worker                                                               "    gl_Position = a_position;\n"
261*35238bceSAndroid Build Coastguard Worker                                                               "    v_texCoord = a_texCoord;\n"
262*35238bceSAndroid Build Coastguard Worker                                                               "}\n")
263*35238bceSAndroid Build Coastguard Worker                                          << glu::FragmentSource("#version 300 es\n"
264*35238bceSAndroid Build Coastguard Worker                                                                 "uniform highp usampler2DArray u_sampler;\n"
265*35238bceSAndroid Build Coastguard Worker                                                                 "in highp vec3 v_texCoord;\n"
266*35238bceSAndroid Build Coastguard Worker                                                                 "layout(location = 0) out highp uint o_stencil;\n"
267*35238bceSAndroid Build Coastguard Worker                                                                 "void main (void)\n"
268*35238bceSAndroid Build Coastguard Worker                                                                 "{\n"
269*35238bceSAndroid Build Coastguard Worker                                                                 "    o_stencil = texture(u_sampler, v_texCoord).x;\n"
270*35238bceSAndroid Build Coastguard Worker                                                                 "}\n"));
271*35238bceSAndroid Build Coastguard Worker 
272*35238bceSAndroid Build Coastguard Worker     const float positions[]                      = {-1.0f, -1.0f, +1.0f, -1.0f, -1.0f, +1.0f, +1.0f, +1.0f};
273*35238bceSAndroid Build Coastguard Worker     const float texCoord[]                       = {0.0f, 0.0f, float(level), 1.0f, 0.0f, float(level),
274*35238bceSAndroid Build Coastguard Worker                                                     0.0f, 1.0f, float(level), 1.0f, 1.0f, float(level)};
275*35238bceSAndroid Build Coastguard Worker     const glu::VertexArrayBinding vertexArrays[] = {glu::va::Float("a_position", 2, 4, 0, &positions[0]),
276*35238bceSAndroid Build Coastguard Worker                                                     glu::va::Float("a_texCoord", 3, 4, 0, &texCoord[0])};
277*35238bceSAndroid Build Coastguard Worker     const uint8_t indices[]                      = {0, 1, 2, 2, 1, 3};
278*35238bceSAndroid Build Coastguard Worker 
279*35238bceSAndroid Build Coastguard Worker     const glw::Functions &gl = renderCtx.getFunctions();
280*35238bceSAndroid Build Coastguard Worker 
281*35238bceSAndroid Build Coastguard Worker     if (!program.isOk())
282*35238bceSAndroid Build Coastguard Worker         throw tcu::TestError("Compile failed");
283*35238bceSAndroid Build Coastguard Worker 
284*35238bceSAndroid Build Coastguard Worker     gl.activeTexture(GL_TEXTURE0);
285*35238bceSAndroid Build Coastguard Worker     gl.bindTexture(GL_TEXTURE_2D_ARRAY, srcTex);
286*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
287*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
288*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_2D_ARRAY, GL_DEPTH_STENCIL_TEXTURE_MODE, GL_STENCIL_INDEX);
289*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(gl.getError(), "Texture state setup failed");
290*35238bceSAndroid Build Coastguard Worker 
291*35238bceSAndroid Build Coastguard Worker     gl.useProgram(program.getProgram());
292*35238bceSAndroid Build Coastguard Worker     gl.uniform1i(gl.getUniformLocation(program.getProgram(), "u_sampler"), 0);
293*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(gl.getError(), "Program setup failed");
294*35238bceSAndroid Build Coastguard Worker 
295*35238bceSAndroid Build Coastguard Worker     gl.viewport(0, 0, width, height);
296*35238bceSAndroid Build Coastguard Worker     glu::draw(renderCtx, program.getProgram(), DE_LENGTH_OF_ARRAY(vertexArrays), &vertexArrays[0],
297*35238bceSAndroid Build Coastguard Worker               glu::pr::Triangles(DE_LENGTH_OF_ARRAY(indices), &indices[0]));
298*35238bceSAndroid Build Coastguard Worker }
299*35238bceSAndroid Build Coastguard Worker 
blitStencilToColorCube(const glu::RenderContext & renderCtx,uint32_t srcTex,const float * texCoord,int width,int height)300*35238bceSAndroid Build Coastguard Worker static void blitStencilToColorCube(const glu::RenderContext &renderCtx, uint32_t srcTex, const float *texCoord,
301*35238bceSAndroid Build Coastguard Worker                                    int width, int height)
302*35238bceSAndroid Build Coastguard Worker {
303*35238bceSAndroid Build Coastguard Worker     const glu::ShaderProgram program(
304*35238bceSAndroid Build Coastguard Worker         renderCtx, glu::ProgramSources() << glu::VertexSource("#version 300 es\n"
305*35238bceSAndroid Build Coastguard Worker                                                               "in highp vec4 a_position;\n"
306*35238bceSAndroid Build Coastguard Worker                                                               "in highp vec3 a_texCoord;\n"
307*35238bceSAndroid Build Coastguard Worker                                                               "out highp vec3 v_texCoord;\n"
308*35238bceSAndroid Build Coastguard Worker                                                               "void main (void)\n"
309*35238bceSAndroid Build Coastguard Worker                                                               "{\n"
310*35238bceSAndroid Build Coastguard Worker                                                               "    gl_Position = a_position;\n"
311*35238bceSAndroid Build Coastguard Worker                                                               "    v_texCoord = a_texCoord;\n"
312*35238bceSAndroid Build Coastguard Worker                                                               "}\n")
313*35238bceSAndroid Build Coastguard Worker                                          << glu::FragmentSource(
314*35238bceSAndroid Build Coastguard Worker                                                 "#version 300 es\n"
315*35238bceSAndroid Build Coastguard Worker                                                 "uniform highp usamplerCube u_sampler;\n"
316*35238bceSAndroid Build Coastguard Worker                                                 "in highp vec3 v_texCoord;\n"
317*35238bceSAndroid Build Coastguard Worker                                                 "layout(location = 0) out highp vec4 o_color;\n"
318*35238bceSAndroid Build Coastguard Worker                                                 "void main (void)\n"
319*35238bceSAndroid Build Coastguard Worker                                                 "{\n"
320*35238bceSAndroid Build Coastguard Worker                                                 "    o_color.x = float(texture(u_sampler, v_texCoord).x) / 255.0;\n"
321*35238bceSAndroid Build Coastguard Worker                                                 "    o_color.yzw = vec3(0.0, 0.0, 1.0);\n"
322*35238bceSAndroid Build Coastguard Worker                                                 "}\n"));
323*35238bceSAndroid Build Coastguard Worker 
324*35238bceSAndroid Build Coastguard Worker     const float positions[]                      = {-1.0f, -1.0f, -1.0f, +1.0f, +1.0f, -1.0f, +1.0f, +1.0f};
325*35238bceSAndroid Build Coastguard Worker     const glu::VertexArrayBinding vertexArrays[] = {glu::va::Float("a_position", 2, 4, 0, &positions[0]),
326*35238bceSAndroid Build Coastguard Worker                                                     glu::va::Float("a_texCoord", 3, 4, 0, texCoord)};
327*35238bceSAndroid Build Coastguard Worker     const uint8_t indices[]                      = {0, 1, 2, 2, 1, 3};
328*35238bceSAndroid Build Coastguard Worker 
329*35238bceSAndroid Build Coastguard Worker     const glw::Functions &gl = renderCtx.getFunctions();
330*35238bceSAndroid Build Coastguard Worker 
331*35238bceSAndroid Build Coastguard Worker     if (!program.isOk())
332*35238bceSAndroid Build Coastguard Worker         throw tcu::TestError("Compile failed");
333*35238bceSAndroid Build Coastguard Worker 
334*35238bceSAndroid Build Coastguard Worker     gl.activeTexture(GL_TEXTURE0);
335*35238bceSAndroid Build Coastguard Worker     gl.bindTexture(GL_TEXTURE_CUBE_MAP, srcTex);
336*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
337*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
338*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_DEPTH_STENCIL_TEXTURE_MODE, GL_STENCIL_INDEX);
339*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(gl.getError(), "Texture state setup failed");
340*35238bceSAndroid Build Coastguard Worker 
341*35238bceSAndroid Build Coastguard Worker     gl.useProgram(program.getProgram());
342*35238bceSAndroid Build Coastguard Worker     gl.uniform1i(gl.getUniformLocation(program.getProgram(), "u_sampler"), 0);
343*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(gl.getError(), "Program setup failed");
344*35238bceSAndroid Build Coastguard Worker 
345*35238bceSAndroid Build Coastguard Worker     gl.viewport(0, 0, width, height);
346*35238bceSAndroid Build Coastguard Worker     glu::draw(renderCtx, program.getProgram(), DE_LENGTH_OF_ARRAY(vertexArrays), &vertexArrays[0],
347*35238bceSAndroid Build Coastguard Worker               glu::pr::Triangles(DE_LENGTH_OF_ARRAY(indices), &indices[0]));
348*35238bceSAndroid Build Coastguard Worker }
349*35238bceSAndroid Build Coastguard Worker 
stencilToRedAccess(const tcu::ConstPixelBufferAccess & access)350*35238bceSAndroid Build Coastguard Worker static inline tcu::ConstPixelBufferAccess stencilToRedAccess(const tcu::ConstPixelBufferAccess &access)
351*35238bceSAndroid Build Coastguard Worker {
352*35238bceSAndroid Build Coastguard Worker     DE_ASSERT(access.getFormat() == TextureFormat(TextureFormat::S, TextureFormat::UNSIGNED_INT8));
353*35238bceSAndroid Build Coastguard Worker     return tcu::ConstPixelBufferAccess(TextureFormat(TextureFormat::R, TextureFormat::UNSIGNED_INT8), access.getSize(),
354*35238bceSAndroid Build Coastguard Worker                                        access.getPitch(), access.getDataPtr());
355*35238bceSAndroid Build Coastguard Worker }
356*35238bceSAndroid Build Coastguard Worker 
compareStencilToRed(tcu::TestLog & log,const tcu::ConstPixelBufferAccess & stencilRef,const tcu::ConstPixelBufferAccess & result)357*35238bceSAndroid Build Coastguard Worker static bool compareStencilToRed(tcu::TestLog &log, const tcu::ConstPixelBufferAccess &stencilRef,
358*35238bceSAndroid Build Coastguard Worker                                 const tcu::ConstPixelBufferAccess &result)
359*35238bceSAndroid Build Coastguard Worker {
360*35238bceSAndroid Build Coastguard Worker     const int maxPrints = 10;
361*35238bceSAndroid Build Coastguard Worker     int numFailed       = 0;
362*35238bceSAndroid Build Coastguard Worker 
363*35238bceSAndroid Build Coastguard Worker     DE_ASSERT(stencilRef.getFormat().order == TextureFormat::S);
364*35238bceSAndroid Build Coastguard Worker     DE_ASSERT(stencilRef.getWidth() == result.getWidth() && stencilRef.getHeight() == result.getHeight());
365*35238bceSAndroid Build Coastguard Worker 
366*35238bceSAndroid Build Coastguard Worker     for (int y = 0; y < stencilRef.getHeight(); y++)
367*35238bceSAndroid Build Coastguard Worker     {
368*35238bceSAndroid Build Coastguard Worker         for (int x = 0; x < stencilRef.getWidth(); x++)
369*35238bceSAndroid Build Coastguard Worker         {
370*35238bceSAndroid Build Coastguard Worker             const int ref = stencilRef.getPixStencil(x, y);
371*35238bceSAndroid Build Coastguard Worker             const int res = result.getPixelInt(x, y).x();
372*35238bceSAndroid Build Coastguard Worker 
373*35238bceSAndroid Build Coastguard Worker             if (ref != res)
374*35238bceSAndroid Build Coastguard Worker             {
375*35238bceSAndroid Build Coastguard Worker                 if (numFailed < maxPrints)
376*35238bceSAndroid Build Coastguard Worker                     log << TestLog::Message << "ERROR: Expected " << ref << ", got " << res << " at (" << x << ", " << y
377*35238bceSAndroid Build Coastguard Worker                         << ")" << TestLog::EndMessage;
378*35238bceSAndroid Build Coastguard Worker                 else if (numFailed == maxPrints)
379*35238bceSAndroid Build Coastguard Worker                     log << TestLog::Message << "..." << TestLog::EndMessage;
380*35238bceSAndroid Build Coastguard Worker 
381*35238bceSAndroid Build Coastguard Worker                 numFailed += 1;
382*35238bceSAndroid Build Coastguard Worker             }
383*35238bceSAndroid Build Coastguard Worker         }
384*35238bceSAndroid Build Coastguard Worker     }
385*35238bceSAndroid Build Coastguard Worker 
386*35238bceSAndroid Build Coastguard Worker     log << TestLog::Message << "Found " << numFailed << " faulty pixels, comparison "
387*35238bceSAndroid Build Coastguard Worker         << (numFailed == 0 ? "passed." : "FAILED!") << TestLog::EndMessage;
388*35238bceSAndroid Build Coastguard Worker 
389*35238bceSAndroid Build Coastguard Worker     log << TestLog::ImageSet("ComparisonResult", "Image comparison result")
390*35238bceSAndroid Build Coastguard Worker         << TestLog::Image("Result", "Result stencil buffer", result);
391*35238bceSAndroid Build Coastguard Worker 
392*35238bceSAndroid Build Coastguard Worker     if (numFailed > 0)
393*35238bceSAndroid Build Coastguard Worker         log << TestLog::Image("Reference", "Reference stencil buffer", stencilToRedAccess(stencilRef));
394*35238bceSAndroid Build Coastguard Worker 
395*35238bceSAndroid Build Coastguard Worker     log << TestLog::EndImageSet;
396*35238bceSAndroid Build Coastguard Worker 
397*35238bceSAndroid Build Coastguard Worker     return numFailed == 0;
398*35238bceSAndroid Build Coastguard Worker }
399*35238bceSAndroid Build Coastguard Worker 
compareRedChannel(tcu::TestLog & log,const tcu::ConstPixelBufferAccess & result,int reference)400*35238bceSAndroid Build Coastguard Worker static bool compareRedChannel(tcu::TestLog &log, const tcu::ConstPixelBufferAccess &result, int reference)
401*35238bceSAndroid Build Coastguard Worker {
402*35238bceSAndroid Build Coastguard Worker     const int maxPrints = 10;
403*35238bceSAndroid Build Coastguard Worker     int numFailed       = 0;
404*35238bceSAndroid Build Coastguard Worker 
405*35238bceSAndroid Build Coastguard Worker     for (int y = 0; y < result.getHeight(); y++)
406*35238bceSAndroid Build Coastguard Worker     {
407*35238bceSAndroid Build Coastguard Worker         for (int x = 0; x < result.getWidth(); x++)
408*35238bceSAndroid Build Coastguard Worker         {
409*35238bceSAndroid Build Coastguard Worker             const int res = result.getPixelInt(x, y).x();
410*35238bceSAndroid Build Coastguard Worker 
411*35238bceSAndroid Build Coastguard Worker             if (reference != res)
412*35238bceSAndroid Build Coastguard Worker             {
413*35238bceSAndroid Build Coastguard Worker                 if (numFailed < maxPrints)
414*35238bceSAndroid Build Coastguard Worker                     log << TestLog::Message << "ERROR: Expected " << reference << ", got " << res << " at (" << x
415*35238bceSAndroid Build Coastguard Worker                         << ", " << y << ")" << TestLog::EndMessage;
416*35238bceSAndroid Build Coastguard Worker                 else if (numFailed == maxPrints)
417*35238bceSAndroid Build Coastguard Worker                     log << TestLog::Message << "..." << TestLog::EndMessage;
418*35238bceSAndroid Build Coastguard Worker 
419*35238bceSAndroid Build Coastguard Worker                 numFailed += 1;
420*35238bceSAndroid Build Coastguard Worker             }
421*35238bceSAndroid Build Coastguard Worker         }
422*35238bceSAndroid Build Coastguard Worker     }
423*35238bceSAndroid Build Coastguard Worker 
424*35238bceSAndroid Build Coastguard Worker     log << TestLog::Message << "Found " << numFailed << " faulty pixels, comparison "
425*35238bceSAndroid Build Coastguard Worker         << (numFailed == 0 ? "passed." : "FAILED!") << TestLog::EndMessage;
426*35238bceSAndroid Build Coastguard Worker 
427*35238bceSAndroid Build Coastguard Worker     log << TestLog::ImageSet("ComparisonResult", "Image comparison result")
428*35238bceSAndroid Build Coastguard Worker         << TestLog::Image("Result", "Result stencil buffer", result);
429*35238bceSAndroid Build Coastguard Worker 
430*35238bceSAndroid Build Coastguard Worker     log << TestLog::EndImageSet;
431*35238bceSAndroid Build Coastguard Worker 
432*35238bceSAndroid Build Coastguard Worker     return numFailed == 0;
433*35238bceSAndroid Build Coastguard Worker }
434*35238bceSAndroid Build Coastguard Worker 
stencilToUnorm8(const tcu::TextureCube & src,tcu::TextureCube & dst)435*35238bceSAndroid Build Coastguard Worker static void stencilToUnorm8(const tcu::TextureCube &src, tcu::TextureCube &dst)
436*35238bceSAndroid Build Coastguard Worker {
437*35238bceSAndroid Build Coastguard Worker     for (int levelNdx = 0; levelNdx < src.getNumLevels(); levelNdx++)
438*35238bceSAndroid Build Coastguard Worker     {
439*35238bceSAndroid Build Coastguard Worker         for (int faceNdx = 0; faceNdx < tcu::CUBEFACE_LAST; faceNdx++)
440*35238bceSAndroid Build Coastguard Worker         {
441*35238bceSAndroid Build Coastguard Worker             const tcu::CubeFace face = tcu::CubeFace(faceNdx);
442*35238bceSAndroid Build Coastguard Worker 
443*35238bceSAndroid Build Coastguard Worker             if (!src.isLevelEmpty(face, levelNdx))
444*35238bceSAndroid Build Coastguard Worker             {
445*35238bceSAndroid Build Coastguard Worker                 dst.allocLevel(face, levelNdx);
446*35238bceSAndroid Build Coastguard Worker 
447*35238bceSAndroid Build Coastguard Worker                 const tcu::ConstPixelBufferAccess srcLevel = src.getLevelFace(levelNdx, face);
448*35238bceSAndroid Build Coastguard Worker                 const tcu::PixelBufferAccess dstLevel      = dst.getLevelFace(levelNdx, face);
449*35238bceSAndroid Build Coastguard Worker 
450*35238bceSAndroid Build Coastguard Worker                 for (int y = 0; y < src.getSize(); y++)
451*35238bceSAndroid Build Coastguard Worker                     for (int x = 0; x < src.getSize(); x++)
452*35238bceSAndroid Build Coastguard Worker                         dstLevel.setPixel(Vec4(float(srcLevel.getPixStencil(x, y)) / 255.f, 0.f, 0.f, 1.f), x, y);
453*35238bceSAndroid Build Coastguard Worker             }
454*35238bceSAndroid Build Coastguard Worker         }
455*35238bceSAndroid Build Coastguard Worker     }
456*35238bceSAndroid Build Coastguard Worker }
457*35238bceSAndroid Build Coastguard Worker 
checkDepthStencilFormatSupport(Context & context,uint32_t format)458*35238bceSAndroid Build Coastguard Worker static void checkDepthStencilFormatSupport(Context &context, uint32_t format)
459*35238bceSAndroid Build Coastguard Worker {
460*35238bceSAndroid Build Coastguard Worker     if (format == GL_STENCIL_INDEX8)
461*35238bceSAndroid Build Coastguard Worker     {
462*35238bceSAndroid Build Coastguard Worker         const char *reqExt           = "GL_OES_texture_stencil8";
463*35238bceSAndroid Build Coastguard Worker         glu::ContextType contextType = context.getRenderContext().getType();
464*35238bceSAndroid Build Coastguard Worker         if (!glu::contextSupports(contextType, glu::ApiType::es(3, 2)) &&
465*35238bceSAndroid Build Coastguard Worker             !glu::contextSupports(contextType, glu::ApiType::core(4, 5)) &&
466*35238bceSAndroid Build Coastguard Worker             !context.getContextInfo().isExtensionSupported(reqExt))
467*35238bceSAndroid Build Coastguard Worker             throw tcu::NotSupportedError(glu::getTextureFormatStr(format).toString() + " requires " + reqExt);
468*35238bceSAndroid Build Coastguard Worker     }
469*35238bceSAndroid Build Coastguard Worker     else
470*35238bceSAndroid Build Coastguard Worker     {
471*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(format == GL_DEPTH32F_STENCIL8 || format == GL_DEPTH24_STENCIL8);
472*35238bceSAndroid Build Coastguard Worker     }
473*35238bceSAndroid Build Coastguard Worker }
474*35238bceSAndroid Build Coastguard Worker 
checkFramebufferStatus(const glw::Functions & gl)475*35238bceSAndroid Build Coastguard Worker static void checkFramebufferStatus(const glw::Functions &gl)
476*35238bceSAndroid Build Coastguard Worker {
477*35238bceSAndroid Build Coastguard Worker     const uint32_t status = gl.checkFramebufferStatus(GL_FRAMEBUFFER);
478*35238bceSAndroid Build Coastguard Worker 
479*35238bceSAndroid Build Coastguard Worker     if (status == GL_FRAMEBUFFER_UNSUPPORTED)
480*35238bceSAndroid Build Coastguard Worker         throw tcu::NotSupportedError("Unsupported framebuffer configuration");
481*35238bceSAndroid Build Coastguard Worker     else if (status != GL_FRAMEBUFFER_COMPLETE)
482*35238bceSAndroid Build Coastguard Worker         throw tcu::TestError("Incomplete framebuffer: " + glu::getFramebufferStatusStr(status).toString());
483*35238bceSAndroid Build Coastguard Worker }
484*35238bceSAndroid Build Coastguard Worker 
485*35238bceSAndroid Build Coastguard Worker class UploadTex2DCase : public TestCase
486*35238bceSAndroid Build Coastguard Worker {
487*35238bceSAndroid Build Coastguard Worker public:
UploadTex2DCase(Context & context,const char * name,uint32_t format)488*35238bceSAndroid Build Coastguard Worker     UploadTex2DCase(Context &context, const char *name, uint32_t format)
489*35238bceSAndroid Build Coastguard Worker         : TestCase(context, name, glu::getTextureFormatName(format))
490*35238bceSAndroid Build Coastguard Worker         , m_format(format)
491*35238bceSAndroid Build Coastguard Worker     {
492*35238bceSAndroid Build Coastguard Worker     }
493*35238bceSAndroid Build Coastguard Worker 
iterate(void)494*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void)
495*35238bceSAndroid Build Coastguard Worker     {
496*35238bceSAndroid Build Coastguard Worker         const glu::RenderContext &renderCtx = m_context.getRenderContext();
497*35238bceSAndroid Build Coastguard Worker         const glw::Functions &gl            = renderCtx.getFunctions();
498*35238bceSAndroid Build Coastguard Worker         const int width                     = 129;
499*35238bceSAndroid Build Coastguard Worker         const int height                    = 113;
500*35238bceSAndroid Build Coastguard Worker         glu::Framebuffer fbo(renderCtx);
501*35238bceSAndroid Build Coastguard Worker         glu::Renderbuffer colorBuf(renderCtx);
502*35238bceSAndroid Build Coastguard Worker         glu::Texture depthStencilTex(renderCtx);
503*35238bceSAndroid Build Coastguard Worker         TextureLevel uploadLevel(glu::mapGLInternalFormat(m_format), width, height);
504*35238bceSAndroid Build Coastguard Worker         TextureLevel readLevel(TextureFormat(TextureFormat::RGBA, TextureFormat::UNSIGNED_INT32), width, height);
505*35238bceSAndroid Build Coastguard Worker         TextureLevel stencilOnlyLevel(TextureFormat(TextureFormat::S, TextureFormat::UNSIGNED_INT8), width, height);
506*35238bceSAndroid Build Coastguard Worker 
507*35238bceSAndroid Build Coastguard Worker         checkDepthStencilFormatSupport(m_context, m_format);
508*35238bceSAndroid Build Coastguard Worker 
509*35238bceSAndroid Build Coastguard Worker         renderTestPatternReference(uploadLevel);
510*35238bceSAndroid Build Coastguard Worker         renderTestPatternReference(stencilOnlyLevel);
511*35238bceSAndroid Build Coastguard Worker 
512*35238bceSAndroid Build Coastguard Worker         gl.bindTexture(GL_TEXTURE_2D, *depthStencilTex);
513*35238bceSAndroid Build Coastguard Worker         gl.texStorage2D(GL_TEXTURE_2D, 1, m_format, width, height);
514*35238bceSAndroid Build Coastguard Worker         glu::texSubImage2D(renderCtx, GL_TEXTURE_2D, 0, 0, 0, uploadLevel);
515*35238bceSAndroid Build Coastguard Worker         GLU_EXPECT_NO_ERROR(gl.getError(), "Uploading texture data failed");
516*35238bceSAndroid Build Coastguard Worker 
517*35238bceSAndroid Build Coastguard Worker         gl.bindRenderbuffer(GL_RENDERBUFFER, *colorBuf);
518*35238bceSAndroid Build Coastguard Worker         gl.renderbufferStorage(GL_RENDERBUFFER, GL_R32UI, width, height);
519*35238bceSAndroid Build Coastguard Worker 
520*35238bceSAndroid Build Coastguard Worker         gl.bindFramebuffer(GL_FRAMEBUFFER, *fbo);
521*35238bceSAndroid Build Coastguard Worker         gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, *colorBuf);
522*35238bceSAndroid Build Coastguard Worker         checkFramebufferStatus(gl);
523*35238bceSAndroid Build Coastguard Worker 
524*35238bceSAndroid Build Coastguard Worker         blitStencilToColor2D(renderCtx, *depthStencilTex, width, height);
525*35238bceSAndroid Build Coastguard Worker         glu::readPixels(renderCtx, 0, 0, readLevel);
526*35238bceSAndroid Build Coastguard Worker 
527*35238bceSAndroid Build Coastguard Worker         {
528*35238bceSAndroid Build Coastguard Worker             const bool compareOk = compareStencilToRed(m_testCtx.getLog(), stencilOnlyLevel, readLevel);
529*35238bceSAndroid Build Coastguard Worker             m_testCtx.setTestResult(compareOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
530*35238bceSAndroid Build Coastguard Worker                                     compareOk ? "Pass" : "Image comparison failed");
531*35238bceSAndroid Build Coastguard Worker         }
532*35238bceSAndroid Build Coastguard Worker 
533*35238bceSAndroid Build Coastguard Worker         return STOP;
534*35238bceSAndroid Build Coastguard Worker     }
535*35238bceSAndroid Build Coastguard Worker 
536*35238bceSAndroid Build Coastguard Worker private:
537*35238bceSAndroid Build Coastguard Worker     const uint32_t m_format;
538*35238bceSAndroid Build Coastguard Worker };
539*35238bceSAndroid Build Coastguard Worker 
540*35238bceSAndroid Build Coastguard Worker class UploadTex2DArrayCase : public TestCase
541*35238bceSAndroid Build Coastguard Worker {
542*35238bceSAndroid Build Coastguard Worker public:
UploadTex2DArrayCase(Context & context,const char * name,uint32_t format)543*35238bceSAndroid Build Coastguard Worker     UploadTex2DArrayCase(Context &context, const char *name, uint32_t format)
544*35238bceSAndroid Build Coastguard Worker         : TestCase(context, name, glu::getTextureFormatName(format))
545*35238bceSAndroid Build Coastguard Worker         , m_format(format)
546*35238bceSAndroid Build Coastguard Worker     {
547*35238bceSAndroid Build Coastguard Worker     }
548*35238bceSAndroid Build Coastguard Worker 
iterate(void)549*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void)
550*35238bceSAndroid Build Coastguard Worker     {
551*35238bceSAndroid Build Coastguard Worker         const glu::RenderContext &renderCtx = m_context.getRenderContext();
552*35238bceSAndroid Build Coastguard Worker         const glw::Functions &gl            = renderCtx.getFunctions();
553*35238bceSAndroid Build Coastguard Worker         const int width                     = 41;
554*35238bceSAndroid Build Coastguard Worker         const int height                    = 13;
555*35238bceSAndroid Build Coastguard Worker         const int levels                    = 7;
556*35238bceSAndroid Build Coastguard Worker         const int ptrnLevel                 = 3;
557*35238bceSAndroid Build Coastguard Worker         glu::Framebuffer fbo(renderCtx);
558*35238bceSAndroid Build Coastguard Worker         glu::Renderbuffer colorBuf(renderCtx);
559*35238bceSAndroid Build Coastguard Worker         glu::Texture depthStencilTex(renderCtx);
560*35238bceSAndroid Build Coastguard Worker         TextureLevel uploadLevel(glu::mapGLInternalFormat(m_format), width, height, levels);
561*35238bceSAndroid Build Coastguard Worker 
562*35238bceSAndroid Build Coastguard Worker         checkDepthStencilFormatSupport(m_context, m_format);
563*35238bceSAndroid Build Coastguard Worker 
564*35238bceSAndroid Build Coastguard Worker         for (int levelNdx = 0; levelNdx < levels; levelNdx++)
565*35238bceSAndroid Build Coastguard Worker         {
566*35238bceSAndroid Build Coastguard Worker             const tcu::PixelBufferAccess levelAccess =
567*35238bceSAndroid Build Coastguard Worker                 tcu::getSubregion(uploadLevel.getAccess(), 0, 0, levelNdx, width, height, 1);
568*35238bceSAndroid Build Coastguard Worker 
569*35238bceSAndroid Build Coastguard Worker             if (levelNdx == ptrnLevel)
570*35238bceSAndroid Build Coastguard Worker                 renderTestPatternReference(levelAccess);
571*35238bceSAndroid Build Coastguard Worker             else
572*35238bceSAndroid Build Coastguard Worker                 tcu::clearStencil(levelAccess, levelNdx);
573*35238bceSAndroid Build Coastguard Worker         }
574*35238bceSAndroid Build Coastguard Worker 
575*35238bceSAndroid Build Coastguard Worker         gl.bindTexture(GL_TEXTURE_2D_ARRAY, *depthStencilTex);
576*35238bceSAndroid Build Coastguard Worker         gl.texStorage3D(GL_TEXTURE_2D_ARRAY, 1, m_format, width, height, levels);
577*35238bceSAndroid Build Coastguard Worker         glu::texSubImage3D(renderCtx, GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, uploadLevel);
578*35238bceSAndroid Build Coastguard Worker         GLU_EXPECT_NO_ERROR(gl.getError(), "Uploading texture data failed");
579*35238bceSAndroid Build Coastguard Worker 
580*35238bceSAndroid Build Coastguard Worker         gl.bindRenderbuffer(GL_RENDERBUFFER, *colorBuf);
581*35238bceSAndroid Build Coastguard Worker         gl.renderbufferStorage(GL_RENDERBUFFER, GL_R32UI, width, height);
582*35238bceSAndroid Build Coastguard Worker 
583*35238bceSAndroid Build Coastguard Worker         gl.bindFramebuffer(GL_FRAMEBUFFER, *fbo);
584*35238bceSAndroid Build Coastguard Worker         gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, *colorBuf);
585*35238bceSAndroid Build Coastguard Worker         checkFramebufferStatus(gl);
586*35238bceSAndroid Build Coastguard Worker 
587*35238bceSAndroid Build Coastguard Worker         {
588*35238bceSAndroid Build Coastguard Worker             TextureLevel readLevel(TextureFormat(TextureFormat::RGBA, TextureFormat::UNSIGNED_INT32), width, height);
589*35238bceSAndroid Build Coastguard Worker             bool allLevelsOk = true;
590*35238bceSAndroid Build Coastguard Worker 
591*35238bceSAndroid Build Coastguard Worker             for (int levelNdx = 0; levelNdx < levels; levelNdx++)
592*35238bceSAndroid Build Coastguard Worker             {
593*35238bceSAndroid Build Coastguard Worker                 tcu::ScopedLogSection section(m_testCtx.getLog(), "Level" + de::toString(levelNdx),
594*35238bceSAndroid Build Coastguard Worker                                               "Level " + de::toString(levelNdx));
595*35238bceSAndroid Build Coastguard Worker                 bool levelOk;
596*35238bceSAndroid Build Coastguard Worker 
597*35238bceSAndroid Build Coastguard Worker                 blitStencilToColor2DArray(renderCtx, *depthStencilTex, width, height, levelNdx);
598*35238bceSAndroid Build Coastguard Worker                 glu::readPixels(renderCtx, 0, 0, readLevel);
599*35238bceSAndroid Build Coastguard Worker 
600*35238bceSAndroid Build Coastguard Worker                 if (levelNdx == ptrnLevel)
601*35238bceSAndroid Build Coastguard Worker                 {
602*35238bceSAndroid Build Coastguard Worker                     TextureLevel reference(TextureFormat(TextureFormat::S, TextureFormat::UNSIGNED_INT8), width,
603*35238bceSAndroid Build Coastguard Worker                                            height);
604*35238bceSAndroid Build Coastguard Worker                     renderTestPatternReference(reference);
605*35238bceSAndroid Build Coastguard Worker 
606*35238bceSAndroid Build Coastguard Worker                     levelOk = compareStencilToRed(m_testCtx.getLog(), reference, readLevel);
607*35238bceSAndroid Build Coastguard Worker                 }
608*35238bceSAndroid Build Coastguard Worker                 else
609*35238bceSAndroid Build Coastguard Worker                     levelOk = compareRedChannel(m_testCtx.getLog(), readLevel, levelNdx);
610*35238bceSAndroid Build Coastguard Worker 
611*35238bceSAndroid Build Coastguard Worker                 if (!levelOk)
612*35238bceSAndroid Build Coastguard Worker                 {
613*35238bceSAndroid Build Coastguard Worker                     allLevelsOk = false;
614*35238bceSAndroid Build Coastguard Worker                     break;
615*35238bceSAndroid Build Coastguard Worker                 }
616*35238bceSAndroid Build Coastguard Worker             }
617*35238bceSAndroid Build Coastguard Worker 
618*35238bceSAndroid Build Coastguard Worker             m_testCtx.setTestResult(allLevelsOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
619*35238bceSAndroid Build Coastguard Worker                                     allLevelsOk ? "Pass" : "Image comparison failed");
620*35238bceSAndroid Build Coastguard Worker         }
621*35238bceSAndroid Build Coastguard Worker 
622*35238bceSAndroid Build Coastguard Worker         return STOP;
623*35238bceSAndroid Build Coastguard Worker     }
624*35238bceSAndroid Build Coastguard Worker 
625*35238bceSAndroid Build Coastguard Worker private:
626*35238bceSAndroid Build Coastguard Worker     const uint32_t m_format;
627*35238bceSAndroid Build Coastguard Worker };
628*35238bceSAndroid Build Coastguard Worker 
629*35238bceSAndroid Build Coastguard Worker class UploadTexCubeCase : public TestCase
630*35238bceSAndroid Build Coastguard Worker {
631*35238bceSAndroid Build Coastguard Worker public:
UploadTexCubeCase(Context & context,const char * name,uint32_t format)632*35238bceSAndroid Build Coastguard Worker     UploadTexCubeCase(Context &context, const char *name, uint32_t format)
633*35238bceSAndroid Build Coastguard Worker         : TestCase(context, name, glu::getTextureFormatName(format))
634*35238bceSAndroid Build Coastguard Worker         , m_format(format)
635*35238bceSAndroid Build Coastguard Worker     {
636*35238bceSAndroid Build Coastguard Worker     }
637*35238bceSAndroid Build Coastguard Worker 
iterate(void)638*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void)
639*35238bceSAndroid Build Coastguard Worker     {
640*35238bceSAndroid Build Coastguard Worker         const glu::RenderContext &renderCtx = m_context.getRenderContext();
641*35238bceSAndroid Build Coastguard Worker         const glw::Functions &gl            = renderCtx.getFunctions();
642*35238bceSAndroid Build Coastguard Worker         const int size                      = 64;
643*35238bceSAndroid Build Coastguard Worker         const int renderWidth               = 128;
644*35238bceSAndroid Build Coastguard Worker         const int renderHeight              = 128;
645*35238bceSAndroid Build Coastguard Worker         vector<float> texCoord;
646*35238bceSAndroid Build Coastguard Worker         glu::Framebuffer fbo(renderCtx);
647*35238bceSAndroid Build Coastguard Worker         glu::Renderbuffer colorBuf(renderCtx);
648*35238bceSAndroid Build Coastguard Worker         glu::Texture depthStencilTex(renderCtx);
649*35238bceSAndroid Build Coastguard Worker         tcu::TextureCube texData(glu::mapGLInternalFormat(m_format), size);
650*35238bceSAndroid Build Coastguard Worker         tcu::TextureLevel result(TextureFormat(TextureFormat::RGBA, TextureFormat::UNORM_INT8), renderWidth,
651*35238bceSAndroid Build Coastguard Worker                                  renderHeight);
652*35238bceSAndroid Build Coastguard Worker 
653*35238bceSAndroid Build Coastguard Worker         checkDepthStencilFormatSupport(m_context, m_format);
654*35238bceSAndroid Build Coastguard Worker 
655*35238bceSAndroid Build Coastguard Worker         for (int faceNdx = 0; faceNdx < tcu::CUBEFACE_LAST; faceNdx++)
656*35238bceSAndroid Build Coastguard Worker         {
657*35238bceSAndroid Build Coastguard Worker             const tcu::CubeFace face = tcu::CubeFace(faceNdx);
658*35238bceSAndroid Build Coastguard Worker             const int stencilVal     = 42 * faceNdx;
659*35238bceSAndroid Build Coastguard Worker 
660*35238bceSAndroid Build Coastguard Worker             texData.allocLevel(face, 0);
661*35238bceSAndroid Build Coastguard Worker             tcu::clearStencil(texData.getLevelFace(0, face), stencilVal);
662*35238bceSAndroid Build Coastguard Worker         }
663*35238bceSAndroid Build Coastguard Worker 
664*35238bceSAndroid Build Coastguard Worker         glu::TextureTestUtil::computeQuadTexCoordCube(texCoord, tcu::CUBEFACE_NEGATIVE_X, Vec2(-1.5f, -1.3f),
665*35238bceSAndroid Build Coastguard Worker                                                       Vec2(1.3f, 1.4f));
666*35238bceSAndroid Build Coastguard Worker 
667*35238bceSAndroid Build Coastguard Worker         gl.bindTexture(GL_TEXTURE_CUBE_MAP, *depthStencilTex);
668*35238bceSAndroid Build Coastguard Worker         gl.texStorage2D(GL_TEXTURE_CUBE_MAP, 1, m_format, size, size);
669*35238bceSAndroid Build Coastguard Worker 
670*35238bceSAndroid Build Coastguard Worker         for (int faceNdx = 0; faceNdx < tcu::CUBEFACE_LAST; faceNdx++)
671*35238bceSAndroid Build Coastguard Worker             glu::texSubImage2D(renderCtx, glu::getGLCubeFace(tcu::CubeFace(faceNdx)), 0, 0, 0,
672*35238bceSAndroid Build Coastguard Worker                                texData.getLevelFace(0, tcu::CubeFace(faceNdx)));
673*35238bceSAndroid Build Coastguard Worker 
674*35238bceSAndroid Build Coastguard Worker         GLU_EXPECT_NO_ERROR(gl.getError(), "Uploading texture data failed");
675*35238bceSAndroid Build Coastguard Worker 
676*35238bceSAndroid Build Coastguard Worker         gl.bindRenderbuffer(GL_RENDERBUFFER, *colorBuf);
677*35238bceSAndroid Build Coastguard Worker         gl.renderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, renderWidth, renderHeight);
678*35238bceSAndroid Build Coastguard Worker 
679*35238bceSAndroid Build Coastguard Worker         gl.bindFramebuffer(GL_FRAMEBUFFER, *fbo);
680*35238bceSAndroid Build Coastguard Worker         gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, *colorBuf);
681*35238bceSAndroid Build Coastguard Worker         checkFramebufferStatus(gl);
682*35238bceSAndroid Build Coastguard Worker 
683*35238bceSAndroid Build Coastguard Worker         blitStencilToColorCube(renderCtx, *depthStencilTex, &texCoord[0], renderWidth, renderHeight);
684*35238bceSAndroid Build Coastguard Worker         glu::readPixels(renderCtx, 0, 0, result);
685*35238bceSAndroid Build Coastguard Worker 
686*35238bceSAndroid Build Coastguard Worker         {
687*35238bceSAndroid Build Coastguard Worker             using namespace glu::TextureTestUtil;
688*35238bceSAndroid Build Coastguard Worker 
689*35238bceSAndroid Build Coastguard Worker             tcu::TextureCube redTex(TextureFormat(TextureFormat::R, TextureFormat::UNORM_INT8), size);
690*35238bceSAndroid Build Coastguard Worker             const ReferenceParams sampleParams(TEXTURETYPE_CUBE,
691*35238bceSAndroid Build Coastguard Worker                                                tcu::Sampler(tcu::Sampler::CLAMP_TO_EDGE, tcu::Sampler::CLAMP_TO_EDGE,
692*35238bceSAndroid Build Coastguard Worker                                                             tcu::Sampler::CLAMP_TO_EDGE, tcu::Sampler::NEAREST,
693*35238bceSAndroid Build Coastguard Worker                                                             tcu::Sampler::NEAREST));
694*35238bceSAndroid Build Coastguard Worker             tcu::LookupPrecision lookupPrec;
695*35238bceSAndroid Build Coastguard Worker             tcu::LodPrecision lodPrec;
696*35238bceSAndroid Build Coastguard Worker             bool compareOk;
697*35238bceSAndroid Build Coastguard Worker 
698*35238bceSAndroid Build Coastguard Worker             lookupPrec.colorMask      = tcu::BVec4(true, true, true, true);
699*35238bceSAndroid Build Coastguard Worker             lookupPrec.colorThreshold = tcu::computeFixedPointThreshold(IVec4(8, 8, 8, 8));
700*35238bceSAndroid Build Coastguard Worker             lookupPrec.coordBits      = tcu::IVec3(22, 22, 22);
701*35238bceSAndroid Build Coastguard Worker             lookupPrec.uvwBits        = tcu::IVec3(5, 5, 0);
702*35238bceSAndroid Build Coastguard Worker             lodPrec.lodBits           = 7;
703*35238bceSAndroid Build Coastguard Worker             lodPrec.derivateBits      = 16;
704*35238bceSAndroid Build Coastguard Worker 
705*35238bceSAndroid Build Coastguard Worker             stencilToUnorm8(texData, redTex);
706*35238bceSAndroid Build Coastguard Worker 
707*35238bceSAndroid Build Coastguard Worker             compareOk = verifyTextureResult(m_testCtx, result, redTex, &texCoord[0], sampleParams, lookupPrec, lodPrec,
708*35238bceSAndroid Build Coastguard Worker                                             tcu::PixelFormat(8, 8, 8, 8));
709*35238bceSAndroid Build Coastguard Worker 
710*35238bceSAndroid Build Coastguard Worker             m_testCtx.setTestResult(compareOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
711*35238bceSAndroid Build Coastguard Worker                                     compareOk ? "Pass" : "Image comparison failed");
712*35238bceSAndroid Build Coastguard Worker         }
713*35238bceSAndroid Build Coastguard Worker 
714*35238bceSAndroid Build Coastguard Worker         return STOP;
715*35238bceSAndroid Build Coastguard Worker     }
716*35238bceSAndroid Build Coastguard Worker 
717*35238bceSAndroid Build Coastguard Worker private:
718*35238bceSAndroid Build Coastguard Worker     const uint32_t m_format;
719*35238bceSAndroid Build Coastguard Worker };
720*35238bceSAndroid Build Coastguard Worker 
721*35238bceSAndroid Build Coastguard Worker class RenderTex2DCase : public TestCase
722*35238bceSAndroid Build Coastguard Worker {
723*35238bceSAndroid Build Coastguard Worker public:
RenderTex2DCase(Context & context,const char * name,uint32_t format)724*35238bceSAndroid Build Coastguard Worker     RenderTex2DCase(Context &context, const char *name, uint32_t format)
725*35238bceSAndroid Build Coastguard Worker         : TestCase(context, name, glu::getTextureFormatName(format))
726*35238bceSAndroid Build Coastguard Worker         , m_format(format)
727*35238bceSAndroid Build Coastguard Worker     {
728*35238bceSAndroid Build Coastguard Worker     }
729*35238bceSAndroid Build Coastguard Worker 
iterate(void)730*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void)
731*35238bceSAndroid Build Coastguard Worker     {
732*35238bceSAndroid Build Coastguard Worker         const glu::RenderContext &renderCtx = m_context.getRenderContext();
733*35238bceSAndroid Build Coastguard Worker         const glw::Functions &gl            = renderCtx.getFunctions();
734*35238bceSAndroid Build Coastguard Worker         const int width                     = 117;
735*35238bceSAndroid Build Coastguard Worker         const int height                    = 193;
736*35238bceSAndroid Build Coastguard Worker         glu::Framebuffer fbo(renderCtx);
737*35238bceSAndroid Build Coastguard Worker         glu::Renderbuffer colorBuf(renderCtx);
738*35238bceSAndroid Build Coastguard Worker         glu::Texture depthStencilTex(renderCtx);
739*35238bceSAndroid Build Coastguard Worker         TextureLevel result(TextureFormat(TextureFormat::RGBA, TextureFormat::UNSIGNED_INT32), width, height);
740*35238bceSAndroid Build Coastguard Worker         TextureLevel reference(TextureFormat(TextureFormat::S, TextureFormat::UNSIGNED_INT8), width, height);
741*35238bceSAndroid Build Coastguard Worker 
742*35238bceSAndroid Build Coastguard Worker         checkDepthStencilFormatSupport(m_context, m_format);
743*35238bceSAndroid Build Coastguard Worker 
744*35238bceSAndroid Build Coastguard Worker         gl.bindRenderbuffer(GL_RENDERBUFFER, *colorBuf);
745*35238bceSAndroid Build Coastguard Worker         gl.renderbufferStorage(GL_RENDERBUFFER, GL_R32UI, width, height);
746*35238bceSAndroid Build Coastguard Worker 
747*35238bceSAndroid Build Coastguard Worker         gl.bindTexture(GL_TEXTURE_2D, *depthStencilTex);
748*35238bceSAndroid Build Coastguard Worker         gl.texStorage2D(GL_TEXTURE_2D, 1, m_format, width, height);
749*35238bceSAndroid Build Coastguard Worker 
750*35238bceSAndroid Build Coastguard Worker         gl.bindFramebuffer(GL_FRAMEBUFFER, *fbo);
751*35238bceSAndroid Build Coastguard Worker         gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, *colorBuf);
752*35238bceSAndroid Build Coastguard Worker         gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, *depthStencilTex, 0);
753*35238bceSAndroid Build Coastguard Worker         checkFramebufferStatus(gl);
754*35238bceSAndroid Build Coastguard Worker 
755*35238bceSAndroid Build Coastguard Worker         drawTestPattern(renderCtx, width, height);
756*35238bceSAndroid Build Coastguard Worker 
757*35238bceSAndroid Build Coastguard Worker         gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, 0);
758*35238bceSAndroid Build Coastguard Worker         checkFramebufferStatus(gl);
759*35238bceSAndroid Build Coastguard Worker 
760*35238bceSAndroid Build Coastguard Worker         blitStencilToColor2D(renderCtx, *depthStencilTex, width, height);
761*35238bceSAndroid Build Coastguard Worker         glu::readPixels(renderCtx, 0, 0, result.getAccess());
762*35238bceSAndroid Build Coastguard Worker 
763*35238bceSAndroid Build Coastguard Worker         renderTestPatternReference(reference);
764*35238bceSAndroid Build Coastguard Worker 
765*35238bceSAndroid Build Coastguard Worker         {
766*35238bceSAndroid Build Coastguard Worker             const bool compareOk = compareStencilToRed(m_testCtx.getLog(), reference, result);
767*35238bceSAndroid Build Coastguard Worker             m_testCtx.setTestResult(compareOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
768*35238bceSAndroid Build Coastguard Worker                                     compareOk ? "Pass" : "Image comparison failed");
769*35238bceSAndroid Build Coastguard Worker         }
770*35238bceSAndroid Build Coastguard Worker 
771*35238bceSAndroid Build Coastguard Worker         return STOP;
772*35238bceSAndroid Build Coastguard Worker     }
773*35238bceSAndroid Build Coastguard Worker 
774*35238bceSAndroid Build Coastguard Worker private:
775*35238bceSAndroid Build Coastguard Worker     const uint32_t m_format;
776*35238bceSAndroid Build Coastguard Worker };
777*35238bceSAndroid Build Coastguard Worker 
778*35238bceSAndroid Build Coastguard Worker class ClearTex2DCase : public TestCase
779*35238bceSAndroid Build Coastguard Worker {
780*35238bceSAndroid Build Coastguard Worker public:
ClearTex2DCase(Context & context,const char * name,uint32_t format)781*35238bceSAndroid Build Coastguard Worker     ClearTex2DCase(Context &context, const char *name, uint32_t format)
782*35238bceSAndroid Build Coastguard Worker         : TestCase(context, name, glu::getTextureFormatName(format))
783*35238bceSAndroid Build Coastguard Worker         , m_format(format)
784*35238bceSAndroid Build Coastguard Worker     {
785*35238bceSAndroid Build Coastguard Worker     }
786*35238bceSAndroid Build Coastguard Worker 
iterate(void)787*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void)
788*35238bceSAndroid Build Coastguard Worker     {
789*35238bceSAndroid Build Coastguard Worker         const glu::RenderContext &renderCtx = m_context.getRenderContext();
790*35238bceSAndroid Build Coastguard Worker         const glw::Functions &gl            = renderCtx.getFunctions();
791*35238bceSAndroid Build Coastguard Worker         const int width                     = 125;
792*35238bceSAndroid Build Coastguard Worker         const int height                    = 117;
793*35238bceSAndroid Build Coastguard Worker         const int cellSize                  = 8;
794*35238bceSAndroid Build Coastguard Worker         glu::Framebuffer fbo(renderCtx);
795*35238bceSAndroid Build Coastguard Worker         glu::Renderbuffer colorBuf(renderCtx);
796*35238bceSAndroid Build Coastguard Worker         glu::Texture depthStencilTex(renderCtx);
797*35238bceSAndroid Build Coastguard Worker         TextureLevel result(TextureFormat(TextureFormat::RGBA, TextureFormat::UNSIGNED_INT32), width, height);
798*35238bceSAndroid Build Coastguard Worker         TextureLevel reference(TextureFormat(TextureFormat::S, TextureFormat::UNSIGNED_INT8), width, height);
799*35238bceSAndroid Build Coastguard Worker 
800*35238bceSAndroid Build Coastguard Worker         checkDepthStencilFormatSupport(m_context, m_format);
801*35238bceSAndroid Build Coastguard Worker 
802*35238bceSAndroid Build Coastguard Worker         gl.bindRenderbuffer(GL_RENDERBUFFER, *colorBuf);
803*35238bceSAndroid Build Coastguard Worker         gl.renderbufferStorage(GL_RENDERBUFFER, GL_R32UI, width, height);
804*35238bceSAndroid Build Coastguard Worker 
805*35238bceSAndroid Build Coastguard Worker         gl.bindTexture(GL_TEXTURE_2D, *depthStencilTex);
806*35238bceSAndroid Build Coastguard Worker         gl.texStorage2D(GL_TEXTURE_2D, 1, m_format, width, height);
807*35238bceSAndroid Build Coastguard Worker 
808*35238bceSAndroid Build Coastguard Worker         gl.bindFramebuffer(GL_FRAMEBUFFER, *fbo);
809*35238bceSAndroid Build Coastguard Worker         gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, *colorBuf);
810*35238bceSAndroid Build Coastguard Worker         gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, *depthStencilTex, 0);
811*35238bceSAndroid Build Coastguard Worker         checkFramebufferStatus(gl);
812*35238bceSAndroid Build Coastguard Worker 
813*35238bceSAndroid Build Coastguard Worker         gl.enable(GL_SCISSOR_TEST);
814*35238bceSAndroid Build Coastguard Worker 
815*35238bceSAndroid Build Coastguard Worker         for (int y = 0; y < height; y += cellSize)
816*35238bceSAndroid Build Coastguard Worker         {
817*35238bceSAndroid Build Coastguard Worker             for (int x = 0; x < width; x += cellSize)
818*35238bceSAndroid Build Coastguard Worker             {
819*35238bceSAndroid Build Coastguard Worker                 const int clearW  = de::min(cellSize, width - x);
820*35238bceSAndroid Build Coastguard Worker                 const int clearH  = de::min(cellSize, height - y);
821*35238bceSAndroid Build Coastguard Worker                 const int stencil = int((deInt32Hash(x) ^ deInt32Hash(y)) & 0xff);
822*35238bceSAndroid Build Coastguard Worker 
823*35238bceSAndroid Build Coastguard Worker                 gl.clearStencil(stencil);
824*35238bceSAndroid Build Coastguard Worker                 gl.scissor(x, y, clearW, clearH);
825*35238bceSAndroid Build Coastguard Worker                 gl.clear(GL_STENCIL_BUFFER_BIT);
826*35238bceSAndroid Build Coastguard Worker 
827*35238bceSAndroid Build Coastguard Worker                 tcu::clearStencil(tcu::getSubregion(reference.getAccess(), x, y, clearW, clearH), stencil);
828*35238bceSAndroid Build Coastguard Worker             }
829*35238bceSAndroid Build Coastguard Worker         }
830*35238bceSAndroid Build Coastguard Worker 
831*35238bceSAndroid Build Coastguard Worker         gl.disable(GL_SCISSOR_TEST);
832*35238bceSAndroid Build Coastguard Worker 
833*35238bceSAndroid Build Coastguard Worker         gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, 0);
834*35238bceSAndroid Build Coastguard Worker         checkFramebufferStatus(gl);
835*35238bceSAndroid Build Coastguard Worker 
836*35238bceSAndroid Build Coastguard Worker         blitStencilToColor2D(renderCtx, *depthStencilTex, width, height);
837*35238bceSAndroid Build Coastguard Worker         glu::readPixels(renderCtx, 0, 0, result.getAccess());
838*35238bceSAndroid Build Coastguard Worker 
839*35238bceSAndroid Build Coastguard Worker         {
840*35238bceSAndroid Build Coastguard Worker             const bool compareOk = compareStencilToRed(m_testCtx.getLog(), reference, result);
841*35238bceSAndroid Build Coastguard Worker             m_testCtx.setTestResult(compareOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
842*35238bceSAndroid Build Coastguard Worker                                     compareOk ? "Pass" : "Image comparison failed");
843*35238bceSAndroid Build Coastguard Worker         }
844*35238bceSAndroid Build Coastguard Worker 
845*35238bceSAndroid Build Coastguard Worker         return STOP;
846*35238bceSAndroid Build Coastguard Worker     }
847*35238bceSAndroid Build Coastguard Worker 
848*35238bceSAndroid Build Coastguard Worker private:
849*35238bceSAndroid Build Coastguard Worker     const uint32_t m_format;
850*35238bceSAndroid Build Coastguard Worker };
851*35238bceSAndroid Build Coastguard Worker 
852*35238bceSAndroid Build Coastguard Worker class CompareModeCase : public TestCase
853*35238bceSAndroid Build Coastguard Worker {
854*35238bceSAndroid Build Coastguard Worker public:
CompareModeCase(Context & context,const char * name,uint32_t format)855*35238bceSAndroid Build Coastguard Worker     CompareModeCase(Context &context, const char *name, uint32_t format)
856*35238bceSAndroid Build Coastguard Worker         : TestCase(context, name, glu::getTextureFormatName(format))
857*35238bceSAndroid Build Coastguard Worker         , m_format(format)
858*35238bceSAndroid Build Coastguard Worker     {
859*35238bceSAndroid Build Coastguard Worker     }
860*35238bceSAndroid Build Coastguard Worker 
iterate(void)861*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void)
862*35238bceSAndroid Build Coastguard Worker     {
863*35238bceSAndroid Build Coastguard Worker         const glu::RenderContext &renderCtx = m_context.getRenderContext();
864*35238bceSAndroid Build Coastguard Worker         const glw::Functions &gl            = renderCtx.getFunctions();
865*35238bceSAndroid Build Coastguard Worker         const int width                     = 64;
866*35238bceSAndroid Build Coastguard Worker         const int height                    = 64;
867*35238bceSAndroid Build Coastguard Worker         glu::Framebuffer fbo(renderCtx);
868*35238bceSAndroid Build Coastguard Worker         glu::Renderbuffer colorBuf(renderCtx);
869*35238bceSAndroid Build Coastguard Worker         glu::Texture depthStencilTex(renderCtx);
870*35238bceSAndroid Build Coastguard Worker         TextureLevel uploadLevel(glu::mapGLInternalFormat(m_format), width, height);
871*35238bceSAndroid Build Coastguard Worker         TextureLevel readLevel(TextureFormat(TextureFormat::RGBA, TextureFormat::UNSIGNED_INT32), width, height);
872*35238bceSAndroid Build Coastguard Worker         TextureLevel stencilOnlyLevel(TextureFormat(TextureFormat::S, TextureFormat::UNSIGNED_INT8), width, height);
873*35238bceSAndroid Build Coastguard Worker 
874*35238bceSAndroid Build Coastguard Worker         checkDepthStencilFormatSupport(m_context, m_format);
875*35238bceSAndroid Build Coastguard Worker 
876*35238bceSAndroid Build Coastguard Worker         m_testCtx.getLog() << TestLog::Message
877*35238bceSAndroid Build Coastguard Worker                            << "NOTE: Texture compare mode has no effect when reading stencil values."
878*35238bceSAndroid Build Coastguard Worker                            << TestLog::EndMessage;
879*35238bceSAndroid Build Coastguard Worker 
880*35238bceSAndroid Build Coastguard Worker         renderTestPatternReference(uploadLevel);
881*35238bceSAndroid Build Coastguard Worker         renderTestPatternReference(stencilOnlyLevel);
882*35238bceSAndroid Build Coastguard Worker 
883*35238bceSAndroid Build Coastguard Worker         gl.bindTexture(GL_TEXTURE_2D, *depthStencilTex);
884*35238bceSAndroid Build Coastguard Worker         gl.texStorage2D(GL_TEXTURE_2D, 1, m_format, width, height);
885*35238bceSAndroid Build Coastguard Worker         gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
886*35238bceSAndroid Build Coastguard Worker         gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LESS);
887*35238bceSAndroid Build Coastguard Worker         glu::texSubImage2D(renderCtx, GL_TEXTURE_2D, 0, 0, 0, uploadLevel);
888*35238bceSAndroid Build Coastguard Worker         GLU_EXPECT_NO_ERROR(gl.getError(), "Uploading texture data failed");
889*35238bceSAndroid Build Coastguard Worker 
890*35238bceSAndroid Build Coastguard Worker         gl.bindRenderbuffer(GL_RENDERBUFFER, *colorBuf);
891*35238bceSAndroid Build Coastguard Worker         gl.renderbufferStorage(GL_RENDERBUFFER, GL_R32UI, width, height);
892*35238bceSAndroid Build Coastguard Worker 
893*35238bceSAndroid Build Coastguard Worker         gl.bindFramebuffer(GL_FRAMEBUFFER, *fbo);
894*35238bceSAndroid Build Coastguard Worker         gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, *colorBuf);
895*35238bceSAndroid Build Coastguard Worker         checkFramebufferStatus(gl);
896*35238bceSAndroid Build Coastguard Worker 
897*35238bceSAndroid Build Coastguard Worker         blitStencilToColor2D(renderCtx, *depthStencilTex, width, height);
898*35238bceSAndroid Build Coastguard Worker         glu::readPixels(renderCtx, 0, 0, readLevel);
899*35238bceSAndroid Build Coastguard Worker 
900*35238bceSAndroid Build Coastguard Worker         {
901*35238bceSAndroid Build Coastguard Worker             const bool compareOk = compareStencilToRed(m_testCtx.getLog(), stencilOnlyLevel, readLevel);
902*35238bceSAndroid Build Coastguard Worker             m_testCtx.setTestResult(compareOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
903*35238bceSAndroid Build Coastguard Worker                                     compareOk ? "Pass" : "Image comparison failed");
904*35238bceSAndroid Build Coastguard Worker         }
905*35238bceSAndroid Build Coastguard Worker 
906*35238bceSAndroid Build Coastguard Worker         return STOP;
907*35238bceSAndroid Build Coastguard Worker     }
908*35238bceSAndroid Build Coastguard Worker 
909*35238bceSAndroid Build Coastguard Worker private:
910*35238bceSAndroid Build Coastguard Worker     const uint32_t m_format;
911*35238bceSAndroid Build Coastguard Worker };
912*35238bceSAndroid Build Coastguard Worker 
913*35238bceSAndroid Build Coastguard Worker class BaseLevelCase : public TestCase
914*35238bceSAndroid Build Coastguard Worker {
915*35238bceSAndroid Build Coastguard Worker public:
BaseLevelCase(Context & context,const char * name,uint32_t format)916*35238bceSAndroid Build Coastguard Worker     BaseLevelCase(Context &context, const char *name, uint32_t format)
917*35238bceSAndroid Build Coastguard Worker         : TestCase(context, name, glu::getTextureFormatName(format))
918*35238bceSAndroid Build Coastguard Worker         , m_format(format)
919*35238bceSAndroid Build Coastguard Worker     {
920*35238bceSAndroid Build Coastguard Worker     }
921*35238bceSAndroid Build Coastguard Worker 
iterate(void)922*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void)
923*35238bceSAndroid Build Coastguard Worker     {
924*35238bceSAndroid Build Coastguard Worker         const glu::RenderContext &renderCtx = m_context.getRenderContext();
925*35238bceSAndroid Build Coastguard Worker         const glw::Functions &gl            = renderCtx.getFunctions();
926*35238bceSAndroid Build Coastguard Worker         const int width                     = 128;
927*35238bceSAndroid Build Coastguard Worker         const int height                    = 128;
928*35238bceSAndroid Build Coastguard Worker         const int levelNdx                  = 2;
929*35238bceSAndroid Build Coastguard Worker         const int levelWidth                = width >> levelNdx;
930*35238bceSAndroid Build Coastguard Worker         const int levelHeight               = height >> levelNdx;
931*35238bceSAndroid Build Coastguard Worker         glu::Framebuffer fbo(renderCtx);
932*35238bceSAndroid Build Coastguard Worker         glu::Renderbuffer colorBuf(renderCtx);
933*35238bceSAndroid Build Coastguard Worker         glu::Texture depthStencilTex(renderCtx);
934*35238bceSAndroid Build Coastguard Worker         TextureLevel uploadLevel(glu::mapGLInternalFormat(m_format), levelWidth, levelHeight);
935*35238bceSAndroid Build Coastguard Worker         TextureLevel readLevel(TextureFormat(TextureFormat::RGBA, TextureFormat::UNSIGNED_INT32), levelWidth,
936*35238bceSAndroid Build Coastguard Worker                                levelHeight);
937*35238bceSAndroid Build Coastguard Worker         TextureLevel stencilOnlyLevel(TextureFormat(TextureFormat::S, TextureFormat::UNSIGNED_INT8), levelWidth,
938*35238bceSAndroid Build Coastguard Worker                                       levelHeight);
939*35238bceSAndroid Build Coastguard Worker 
940*35238bceSAndroid Build Coastguard Worker         checkDepthStencilFormatSupport(m_context, m_format);
941*35238bceSAndroid Build Coastguard Worker 
942*35238bceSAndroid Build Coastguard Worker         m_testCtx.getLog() << TestLog::Message << "GL_TEXTURE_BASE_LEVEL = " << levelNdx << TestLog::EndMessage;
943*35238bceSAndroid Build Coastguard Worker 
944*35238bceSAndroid Build Coastguard Worker         renderTestPatternReference(uploadLevel);
945*35238bceSAndroid Build Coastguard Worker         renderTestPatternReference(stencilOnlyLevel);
946*35238bceSAndroid Build Coastguard Worker 
947*35238bceSAndroid Build Coastguard Worker         gl.bindTexture(GL_TEXTURE_2D, *depthStencilTex);
948*35238bceSAndroid Build Coastguard Worker         gl.texStorage2D(GL_TEXTURE_2D, deLog2Floor32(de::max(width, height)) + 1, m_format, width, height);
949*35238bceSAndroid Build Coastguard Worker         gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, levelNdx);
950*35238bceSAndroid Build Coastguard Worker         glu::texSubImage2D(renderCtx, GL_TEXTURE_2D, levelNdx, 0, 0, uploadLevel);
951*35238bceSAndroid Build Coastguard Worker         GLU_EXPECT_NO_ERROR(gl.getError(), "Uploading texture data failed");
952*35238bceSAndroid Build Coastguard Worker 
953*35238bceSAndroid Build Coastguard Worker         gl.bindRenderbuffer(GL_RENDERBUFFER, *colorBuf);
954*35238bceSAndroid Build Coastguard Worker         gl.renderbufferStorage(GL_RENDERBUFFER, GL_R32UI, levelWidth, levelHeight);
955*35238bceSAndroid Build Coastguard Worker 
956*35238bceSAndroid Build Coastguard Worker         gl.bindFramebuffer(GL_FRAMEBUFFER, *fbo);
957*35238bceSAndroid Build Coastguard Worker         gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, *colorBuf);
958*35238bceSAndroid Build Coastguard Worker         checkFramebufferStatus(gl);
959*35238bceSAndroid Build Coastguard Worker 
960*35238bceSAndroid Build Coastguard Worker         blitStencilToColor2D(renderCtx, *depthStencilTex, levelWidth, levelHeight);
961*35238bceSAndroid Build Coastguard Worker         glu::readPixels(renderCtx, 0, 0, readLevel);
962*35238bceSAndroid Build Coastguard Worker 
963*35238bceSAndroid Build Coastguard Worker         {
964*35238bceSAndroid Build Coastguard Worker             const bool compareOk = compareStencilToRed(m_testCtx.getLog(), stencilOnlyLevel, readLevel);
965*35238bceSAndroid Build Coastguard Worker             m_testCtx.setTestResult(compareOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
966*35238bceSAndroid Build Coastguard Worker                                     compareOk ? "Pass" : "Image comparison failed");
967*35238bceSAndroid Build Coastguard Worker         }
968*35238bceSAndroid Build Coastguard Worker 
969*35238bceSAndroid Build Coastguard Worker         return STOP;
970*35238bceSAndroid Build Coastguard Worker     }
971*35238bceSAndroid Build Coastguard Worker 
972*35238bceSAndroid Build Coastguard Worker private:
973*35238bceSAndroid Build Coastguard Worker     const uint32_t m_format;
974*35238bceSAndroid Build Coastguard Worker };
975*35238bceSAndroid Build Coastguard Worker 
976*35238bceSAndroid Build Coastguard Worker } // namespace
977*35238bceSAndroid Build Coastguard Worker 
StencilTexturingTests(Context & context)978*35238bceSAndroid Build Coastguard Worker StencilTexturingTests::StencilTexturingTests(Context &context)
979*35238bceSAndroid Build Coastguard Worker     : TestCaseGroup(context, "stencil_texturing", "Stencil texturing tests")
980*35238bceSAndroid Build Coastguard Worker {
981*35238bceSAndroid Build Coastguard Worker }
982*35238bceSAndroid Build Coastguard Worker 
~StencilTexturingTests(void)983*35238bceSAndroid Build Coastguard Worker StencilTexturingTests::~StencilTexturingTests(void)
984*35238bceSAndroid Build Coastguard Worker {
985*35238bceSAndroid Build Coastguard Worker }
986*35238bceSAndroid Build Coastguard Worker 
init(void)987*35238bceSAndroid Build Coastguard Worker void StencilTexturingTests::init(void)
988*35238bceSAndroid Build Coastguard Worker {
989*35238bceSAndroid Build Coastguard Worker     // .format
990*35238bceSAndroid Build Coastguard Worker     {
991*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *const formatGroup = new tcu::TestCaseGroup(m_testCtx, "format", "Formats");
992*35238bceSAndroid Build Coastguard Worker         addChild(formatGroup);
993*35238bceSAndroid Build Coastguard Worker 
994*35238bceSAndroid Build Coastguard Worker         formatGroup->addChild(new UploadTex2DCase(m_context, "depth32f_stencil8_2d", GL_DEPTH32F_STENCIL8));
995*35238bceSAndroid Build Coastguard Worker         formatGroup->addChild(new UploadTex2DArrayCase(m_context, "depth32f_stencil8_2d_array", GL_DEPTH32F_STENCIL8));
996*35238bceSAndroid Build Coastguard Worker         formatGroup->addChild(new UploadTexCubeCase(m_context, "depth32f_stencil8_cube", GL_DEPTH32F_STENCIL8));
997*35238bceSAndroid Build Coastguard Worker         formatGroup->addChild(new UploadTex2DCase(m_context, "depth24_stencil8_2d", GL_DEPTH24_STENCIL8));
998*35238bceSAndroid Build Coastguard Worker         formatGroup->addChild(new UploadTex2DArrayCase(m_context, "depth24_stencil8_2d_array", GL_DEPTH24_STENCIL8));
999*35238bceSAndroid Build Coastguard Worker         formatGroup->addChild(new UploadTexCubeCase(m_context, "depth24_stencil8_cube", GL_DEPTH24_STENCIL8));
1000*35238bceSAndroid Build Coastguard Worker 
1001*35238bceSAndroid Build Coastguard Worker         // OES_texture_stencil8
1002*35238bceSAndroid Build Coastguard Worker         formatGroup->addChild(new UploadTex2DCase(m_context, "stencil_index8_2d", GL_STENCIL_INDEX8));
1003*35238bceSAndroid Build Coastguard Worker         formatGroup->addChild(new UploadTex2DArrayCase(m_context, "stencil_index8_2d_array", GL_STENCIL_INDEX8));
1004*35238bceSAndroid Build Coastguard Worker         formatGroup->addChild(new UploadTexCubeCase(m_context, "stencil_index8_cube", GL_STENCIL_INDEX8));
1005*35238bceSAndroid Build Coastguard Worker     }
1006*35238bceSAndroid Build Coastguard Worker 
1007*35238bceSAndroid Build Coastguard Worker     // .render
1008*35238bceSAndroid Build Coastguard Worker     {
1009*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *const readRenderGroup =
1010*35238bceSAndroid Build Coastguard Worker             new tcu::TestCaseGroup(m_testCtx, "render", "Read rendered stencil values");
1011*35238bceSAndroid Build Coastguard Worker         addChild(readRenderGroup);
1012*35238bceSAndroid Build Coastguard Worker 
1013*35238bceSAndroid Build Coastguard Worker         readRenderGroup->addChild(new ClearTex2DCase(m_context, "depth32f_stencil8_clear", GL_DEPTH32F_STENCIL8));
1014*35238bceSAndroid Build Coastguard Worker         readRenderGroup->addChild(new RenderTex2DCase(m_context, "depth32f_stencil8_draw", GL_DEPTH32F_STENCIL8));
1015*35238bceSAndroid Build Coastguard Worker         readRenderGroup->addChild(new ClearTex2DCase(m_context, "depth24_stencil8_clear", GL_DEPTH24_STENCIL8));
1016*35238bceSAndroid Build Coastguard Worker         readRenderGroup->addChild(new RenderTex2DCase(m_context, "depth24_stencil8_draw", GL_DEPTH24_STENCIL8));
1017*35238bceSAndroid Build Coastguard Worker     }
1018*35238bceSAndroid Build Coastguard Worker 
1019*35238bceSAndroid Build Coastguard Worker     // .misc
1020*35238bceSAndroid Build Coastguard Worker     {
1021*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *const miscGroup = new tcu::TestCaseGroup(m_testCtx, "misc", "Misc cases");
1022*35238bceSAndroid Build Coastguard Worker         addChild(miscGroup);
1023*35238bceSAndroid Build Coastguard Worker 
1024*35238bceSAndroid Build Coastguard Worker         miscGroup->addChild(new CompareModeCase(m_context, "compare_mode_effect", GL_DEPTH24_STENCIL8));
1025*35238bceSAndroid Build Coastguard Worker         miscGroup->addChild(new BaseLevelCase(m_context, "base_level", GL_DEPTH24_STENCIL8));
1026*35238bceSAndroid Build Coastguard Worker     }
1027*35238bceSAndroid Build Coastguard Worker }
1028*35238bceSAndroid Build Coastguard Worker 
1029*35238bceSAndroid Build Coastguard Worker } // namespace Functional
1030*35238bceSAndroid Build Coastguard Worker } // namespace gles31
1031*35238bceSAndroid Build Coastguard Worker } // namespace deqp
1032