13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*-------------------------------------------------------------------------
23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL ES 3.1 Module
33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * -------------------------------------------------
43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project
63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License");
83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License.
93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at
103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *      http://www.apache.org/licenses/LICENSE-2.0
123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software
143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS,
153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and
173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License.
183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*!
203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file
213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Stencil texturing tests.
223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es31fStencilTexturingTests.hpp"
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluStrUtil.hpp"
273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluObjectWrapper.hpp"
283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluRenderContext.hpp"
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluShaderProgram.hpp"
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluDrawUtil.hpp"
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluPixelTransfer.hpp"
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluTextureUtil.hpp"
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluContextInfo.hpp"
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glsTextureTestUtil.hpp"
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuVector.hpp"
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTexture.hpp"
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTextureUtil.hpp"
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestLog.hpp"
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTexLookupVerifier.hpp"
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwFunctions.hpp"
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp"
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deStringUtil.hpp"
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles31
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Functional
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::vector;
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::string;
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::IVec4;
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::Vec2;
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::Vec4;
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TestLog;
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TextureLevel;
623c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TextureFormat;
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void genTestRects (vector<IVec4>& rects, int width, int height)
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int curWidth	= width;
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int curHeight	= height;
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int ndx			= 0;
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (;;)
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		rects.push_back(IVec4(width-curWidth, height-curHeight, curWidth, curHeight));
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(curWidth >= 1 && curHeight >= 1);
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (curWidth == 1 && curHeight == 1)
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			break;
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		else if (curHeight > 1 && ((ndx%2) == 0 || curWidth == 1))
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			curHeight -= 1;
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		else
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			curWidth -= 1;
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ndx += 1;
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void rectsToTriangles (const vector<IVec4>& rects, int width, int height, vector<Vec2>& positions, vector<deUint16>& indices)
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const float		w		= float(width);
923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const float		h		= float(height);
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	positions.resize(rects.size()*4);
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	indices.resize(rects.size()*6);
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int rectNdx = 0; rectNdx < (int)rects.size(); rectNdx++)
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int		rx		= rects[rectNdx].x();
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int		ry		= rects[rectNdx].y();
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int		rw		= rects[rectNdx].z();
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int		rh		= rects[rectNdx].w();
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const float		x0		= float(rx*2)/w - 1.0f;
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const float		x1		= float((rx+rw)*2)/w - 1.0f;
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const float		y0		= float(ry*2)/h - 1.0f;
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const float		y1		= float((ry+rh)*2)/h - 1.0f;
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		positions[rectNdx*4 + 0] = Vec2(x0, y0);
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		positions[rectNdx*4 + 1] = Vec2(x1, y0);
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		positions[rectNdx*4 + 2] = Vec2(x0, y1);
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		positions[rectNdx*4 + 3] = Vec2(x1, y1);
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1147a161d243743d8d12e12669d7464c360de1b5e97Jarkko Pöyry		indices[rectNdx*6 + 0] = (deUint16)(rectNdx*4 + 0);
1157a161d243743d8d12e12669d7464c360de1b5e97Jarkko Pöyry		indices[rectNdx*6 + 1] = (deUint16)(rectNdx*4 + 1);
1167a161d243743d8d12e12669d7464c360de1b5e97Jarkko Pöyry		indices[rectNdx*6 + 2] = (deUint16)(rectNdx*4 + 2);
1177a161d243743d8d12e12669d7464c360de1b5e97Jarkko Pöyry		indices[rectNdx*6 + 3] = (deUint16)(rectNdx*4 + 2);
1187a161d243743d8d12e12669d7464c360de1b5e97Jarkko Pöyry		indices[rectNdx*6 + 4] = (deUint16)(rectNdx*4 + 1);
1197a161d243743d8d12e12669d7464c360de1b5e97Jarkko Pöyry		indices[rectNdx*6 + 5] = (deUint16)(rectNdx*4 + 3);
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void drawTestPattern (const glu::RenderContext& renderCtx, int width, int height)
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glu::ShaderProgram program(renderCtx, glu::ProgramSources()
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< glu::VertexSource(
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"#version 300 es\n"
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"in highp vec4 a_position;\n"
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	gl_Position = a_position;\n"
1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n")
1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< glu::FragmentSource(
1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"#version 300 es\n"
1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void) {}\n"));
1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glw::Functions&	gl		= renderCtx.getFunctions();
1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	vector<IVec4>			rects;
1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	vector<Vec2>			positions;
1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	vector<deUint16>		indices;
1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!program.isOk())
1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		throw tcu::TestError("Compile failed");
1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.useProgram	(program.getProgram());
1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.viewport		(0, 0, width, height);
1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.clear		(GL_STENCIL_BUFFER_BIT);
1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.enable		(GL_STENCIL_TEST);
1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.stencilOp	(GL_KEEP, GL_KEEP, GL_INCR_WRAP);
1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.stencilFunc	(GL_ALWAYS, 0, ~0u);
1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_EXPECT_NO_ERROR(gl.getError(), "State setup failed");
1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	genTestRects	(rects, width, height);
1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rectsToTriangles(rects, width, height, positions, indices);
1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const glu::VertexArrayBinding posBinding = glu::va::Float("a_position", 2, (int)positions.size(), 0, positions[0].getPtr());
1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::draw(renderCtx, program.getProgram(), 1, &posBinding, glu::pr::Triangles((int)indices.size(), &indices[0]));
1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.disable(GL_STENCIL_TEST);
1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void renderTestPatternReference (const tcu::PixelBufferAccess& dst)
1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
16609037a4653649d707449463dfe9817a78ccf7d2fJarkko Pöyry	const int		stencilBits		= tcu::getTextureFormatBitDepth(tcu::getEffectiveDepthStencilAccess(dst, tcu::Sampler::MODE_STENCIL).getFormat()).x();
1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint32	stencilMask		= (1u<<stencilBits)-1u;
1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	vector<IVec4>	rects;
1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT(dst.getFormat().order == TextureFormat::S || dst.getFormat().order == TextureFormat::DS);
1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17209037a4653649d707449463dfe9817a78ccf7d2fJarkko Pöyry	// clear depth and stencil
1735a0a3bbda9383ed89e44198619b9564282905865Jarkko Pöyry	if (dst.getFormat().order == TextureFormat::DS)
1745a0a3bbda9383ed89e44198619b9564282905865Jarkko Pöyry		tcu::clearDepth(dst, 0.0f);
1755a0a3bbda9383ed89e44198619b9564282905865Jarkko Pöyry	tcu::clearStencil(dst, 0u);
1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	genTestRects(rects, dst.getWidth(), dst.getHeight());
1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (vector<IVec4>::const_iterator rectIter = rects.begin(); rectIter != rects.end(); ++rectIter)
1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int	x0		= rectIter->x();
1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int	y0		= rectIter->y();
1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int	x1		= x0+rectIter->z();
1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int	y1		= y0+rectIter->w();
1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int y = y0; y < y1; y++)
1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int x = x0; x < x1; x++)
1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const int oldVal	= dst.getPixStencil(x, y);
1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const int newVal	= (oldVal+1)&stencilMask;
1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				dst.setPixStencil(newVal, x, y);
1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void blitStencilToColor2D (const glu::RenderContext& renderCtx, deUint32 srcTex, int width, int height)
2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glu::ShaderProgram program(renderCtx, glu::ProgramSources()
2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< glu::VertexSource(
2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"#version 300 es\n"
2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"in highp vec4 a_position;\n"
2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"in highp vec2 a_texCoord;\n"
2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"out highp vec2 v_texCoord;\n"
2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	gl_Position = a_position;\n"
2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	v_texCoord = a_texCoord;\n"
2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n")
2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< glu::FragmentSource(
2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"#version 300 es\n"
2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp usampler2D u_sampler;\n"
2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"in highp vec2 v_texCoord;\n"
2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"layout(location = 0) out highp uint o_stencil;\n"
2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	o_stencil = texture(u_sampler, v_texCoord).x;\n"
2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n"));
2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const float positions[] =
2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		-1.0f, -1.0f,
2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		+1.0f, -1.0f,
2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		-1.0f, +1.0f,
2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		+1.0f, +1.0f
2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const float texCoord[] =
2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		0.0f, 0.0f,
2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		1.0f, 0.0f,
2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		0.0f, 1.0f,
2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		1.0f, 1.0f
2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glu::VertexArrayBinding vertexArrays[] =
2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::va::Float("a_position", 2, 4, 0, &positions[0]),
2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::va::Float("a_texCoord", 2, 4, 0, &texCoord[0])
2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint8 indices[] = { 0, 1, 2, 2, 1, 3 };
2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glw::Functions& gl = renderCtx.getFunctions();
2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!program.isOk())
2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		throw tcu::TestError("Compile failed");
2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.activeTexture(GL_TEXTURE0);
2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.bindTexture(GL_TEXTURE_2D, srcTex);
2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.texParameteri(GL_TEXTURE_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, GL_STENCIL_INDEX);
2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_EXPECT_NO_ERROR(gl.getError(), "Texture state setup failed");
2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.useProgram(program.getProgram());
2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.uniform1i(gl.getUniformLocation(program.getProgram(), "u_sampler"), 0);
2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_EXPECT_NO_ERROR(gl.getError(), "Program setup failed");
2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.viewport(0, 0, width, height);
2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::draw(renderCtx, program.getProgram(), DE_LENGTH_OF_ARRAY(vertexArrays), &vertexArrays[0],
2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			  glu::pr::Triangles(DE_LENGTH_OF_ARRAY(indices), &indices[0]));
2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void blitStencilToColor2DArray (const glu::RenderContext& renderCtx, deUint32 srcTex, int width, int height, int level)
2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glu::ShaderProgram program(renderCtx, glu::ProgramSources()
2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< glu::VertexSource(
2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"#version 300 es\n"
2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"in highp vec4 a_position;\n"
2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"in highp vec3 a_texCoord;\n"
2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"out highp vec3 v_texCoord;\n"
2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	gl_Position = a_position;\n"
2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	v_texCoord = a_texCoord;\n"
2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n")
2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< glu::FragmentSource(
2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"#version 300 es\n"
2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp usampler2DArray u_sampler;\n"
2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"in highp vec3 v_texCoord;\n"
2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"layout(location = 0) out highp uint o_stencil;\n"
2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	o_stencil = texture(u_sampler, v_texCoord).x;\n"
2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n"));
2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const float positions[] =
2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		-1.0f, -1.0f,
2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		+1.0f, -1.0f,
2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		-1.0f, +1.0f,
2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		+1.0f, +1.0f
2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const float texCoord[] =
2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		0.0f, 0.0f, float(level),
2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		1.0f, 0.0f, float(level),
2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		0.0f, 1.0f, float(level),
2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		1.0f, 1.0f, float(level)
3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glu::VertexArrayBinding vertexArrays[] =
3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::va::Float("a_position", 2, 4, 0, &positions[0]),
3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::va::Float("a_texCoord", 3, 4, 0, &texCoord[0])
3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint8 indices[] = { 0, 1, 2, 2, 1, 3 };
3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glw::Functions& gl = renderCtx.getFunctions();
3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!program.isOk())
3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		throw tcu::TestError("Compile failed");
3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.activeTexture(GL_TEXTURE0);
3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.bindTexture(GL_TEXTURE_2D_ARRAY, srcTex);
3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.texParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.texParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.texParameteri(GL_TEXTURE_2D_ARRAY, GL_DEPTH_STENCIL_TEXTURE_MODE, GL_STENCIL_INDEX);
3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_EXPECT_NO_ERROR(gl.getError(), "Texture state setup failed");
3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.useProgram(program.getProgram());
3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.uniform1i(gl.getUniformLocation(program.getProgram(), "u_sampler"), 0);
3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_EXPECT_NO_ERROR(gl.getError(), "Program setup failed");
3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.viewport(0, 0, width, height);
3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::draw(renderCtx, program.getProgram(), DE_LENGTH_OF_ARRAY(vertexArrays), &vertexArrays[0],
3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			  glu::pr::Triangles(DE_LENGTH_OF_ARRAY(indices), &indices[0]));
3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void blitStencilToColorCube (const glu::RenderContext& renderCtx, deUint32 srcTex, const float* texCoord, int width, int height)
3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glu::ShaderProgram program(renderCtx, glu::ProgramSources()
3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< glu::VertexSource(
3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"#version 300 es\n"
3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"in highp vec4 a_position;\n"
3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"in highp vec3 a_texCoord;\n"
3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"out highp vec3 v_texCoord;\n"
3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	gl_Position = a_position;\n"
3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	v_texCoord = a_texCoord;\n"
3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n")
3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< glu::FragmentSource(
3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"#version 300 es\n"
3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp usamplerCube u_sampler;\n"
3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"in highp vec3 v_texCoord;\n"
3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"layout(location = 0) out highp vec4 o_color;\n"
3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	o_color.x = float(texture(u_sampler, v_texCoord).x) / 255.0;\n"
3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	o_color.yzw = vec3(0.0, 0.0, 1.0);\n"
3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n"));
3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const float positions[] =
3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		-1.0f, -1.0f,
3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		-1.0f, +1.0f,
3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		+1.0f, -1.0f,
3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		+1.0f, +1.0f
3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glu::VertexArrayBinding vertexArrays[] =
3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::va::Float("a_position", 2, 4, 0, &positions[0]),
3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::va::Float("a_texCoord", 3, 4, 0, texCoord)
3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint8 indices[] = { 0, 1, 2, 2, 1, 3 };
3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glw::Functions& gl = renderCtx.getFunctions();
3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!program.isOk())
3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		throw tcu::TestError("Compile failed");
3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.activeTexture(GL_TEXTURE0);
3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.bindTexture(GL_TEXTURE_CUBE_MAP, srcTex);
3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_DEPTH_STENCIL_TEXTURE_MODE, GL_STENCIL_INDEX);
3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_EXPECT_NO_ERROR(gl.getError(), "Texture state setup failed");
3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.useProgram(program.getProgram());
3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.uniform1i(gl.getUniformLocation(program.getProgram(), "u_sampler"), 0);
3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_EXPECT_NO_ERROR(gl.getError(), "Program setup failed");
3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.viewport(0, 0, width, height);
3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::draw(renderCtx, program.getProgram(), DE_LENGTH_OF_ARRAY(vertexArrays), &vertexArrays[0],
3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			  glu::pr::Triangles(DE_LENGTH_OF_ARRAY(indices), &indices[0]));
3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic inline tcu::ConstPixelBufferAccess stencilToRedAccess (const tcu::ConstPixelBufferAccess& access)
3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT(access.getFormat() == TextureFormat(TextureFormat::S, TextureFormat::UNSIGNED_INT8));
39109037a4653649d707449463dfe9817a78ccf7d2fJarkko Pöyry	return tcu::ConstPixelBufferAccess(TextureFormat(TextureFormat::R, TextureFormat::UNSIGNED_INT8), access.getSize(), access.getPitch(), access.getDataPtr());
3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic bool compareStencilToRed (tcu::TestLog& log, const tcu::ConstPixelBufferAccess& stencilRef, const tcu::ConstPixelBufferAccess& result)
3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int		maxPrints		= 10;
3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int				numFailed		= 0;
3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT(stencilRef.getFormat().order == TextureFormat::S);
4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT(stencilRef.getWidth() == result.getWidth() && stencilRef.getHeight() == result.getHeight());
4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int y = 0; y < stencilRef.getHeight(); y++)
4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int x = 0; x < stencilRef.getWidth(); x++)
4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int		ref		= stencilRef.getPixStencil(x, y);
4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int		res		= result.getPixelInt(x, y).x();
4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (ref != res)
4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (numFailed < maxPrints)
4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					log << TestLog::Message << "ERROR: Expected " << ref << ", got " << res << " at (" << x << ", " << y << ")" << TestLog::EndMessage;
4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				else if (numFailed == maxPrints)
4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					log << TestLog::Message << "..." << TestLog::EndMessage;
4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				numFailed += 1;
4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	log << TestLog::Message << "Found " << numFailed << " faulty pixels, comparison " << (numFailed == 0 ? "passed." : "FAILED!") << TestLog::EndMessage;
4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	log << TestLog::ImageSet("ComparisonResult", "Image comparison result")
4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< TestLog::Image("Result", "Result stencil buffer", result);
4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (numFailed > 0)
4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		log << TestLog::Image("Reference", "Reference stencil buffer", stencilToRedAccess(stencilRef));
4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	log << TestLog::EndImageSet;
4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return numFailed == 0;
4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic bool compareRedChannel (tcu::TestLog& log, const tcu::ConstPixelBufferAccess& result, int reference)
4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int		maxPrints		= 10;
4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int				numFailed		= 0;
4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int y = 0; y < result.getHeight(); y++)
4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int x = 0; x < result.getWidth(); x++)
4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int res = result.getPixelInt(x, y).x();
4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (reference != res)
4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (numFailed < maxPrints)
4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					log << TestLog::Message << "ERROR: Expected " << reference << ", got " << res << " at (" << x << ", " << y << ")" << TestLog::EndMessage;
4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				else if (numFailed == maxPrints)
4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					log << TestLog::Message << "..." << TestLog::EndMessage;
4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				numFailed += 1;
4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	log << TestLog::Message << "Found " << numFailed << " faulty pixels, comparison " << (numFailed == 0 ? "passed." : "FAILED!") << TestLog::EndMessage;
4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	log << TestLog::ImageSet("ComparisonResult", "Image comparison result")
4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< TestLog::Image("Result", "Result stencil buffer", result);
4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	log << TestLog::EndImageSet;
4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return numFailed == 0;
4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void stencilToUnorm8 (const tcu::TextureCube& src, tcu::TextureCube& dst)
4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int levelNdx = 0; levelNdx < src.getNumLevels(); levelNdx++)
4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int faceNdx = 0; faceNdx < tcu::CUBEFACE_LAST; faceNdx++)
4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const tcu::CubeFace face = tcu::CubeFace(faceNdx);
4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (!src.isLevelEmpty(face, levelNdx))
4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				dst.allocLevel(face, levelNdx);
4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const tcu::ConstPixelBufferAccess	srcLevel	= src.getLevelFace(levelNdx, face);
4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const tcu::PixelBufferAccess		dstLevel	= dst.getLevelFace(levelNdx, face);
4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				for (int y = 0; y < src.getSize(); y++)
4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				for (int x = 0; x < src.getSize(); x++)
4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					dstLevel.setPixel(Vec4(float(srcLevel.getPixStencil(x, y)) / 255.f, 0.f, 0.f, 1.f), x, y);
4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void checkDepthStencilFormatSupport (const glu::ContextInfo& ctxInfo, deUint32 format)
4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (format == GL_STENCIL_INDEX8)
4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const char* reqExt = "GL_OES_texture_stencil8";
4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (!ctxInfo.isExtensionSupported(reqExt))
496b2e583dfcd8aa0d4ef254f841213fcf724b2b193Jarkko Pöyry			throw tcu::NotSupportedError(glu::getTextureFormatStr(format).toString() + " requires " + reqExt);
4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	else
4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(format == GL_DEPTH32F_STENCIL8 || format == GL_DEPTH24_STENCIL8);
5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void checkFramebufferStatus (const glw::Functions& gl)
5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint32 status = gl.checkFramebufferStatus(GL_FRAMEBUFFER);
5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (status == GL_FRAMEBUFFER_UNSUPPORTED)
5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		throw tcu::NotSupportedError("Unsupported framebuffer configuration");
5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	else if (status != GL_FRAMEBUFFER_COMPLETE)
5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		throw tcu::TestError("Incomplete framebuffer: " + glu::getFramebufferStatusStr(status).toString());
5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5143c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass UploadTex2DCase : public TestCase
5153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5163c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	UploadTex2DCase (Context& context, const char* name, deUint32 format)
518b2e583dfcd8aa0d4ef254f841213fcf724b2b193Jarkko Pöyry		: TestCase	(context, name, glu::getTextureFormatName(format))
5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format	(format)
5203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IterateResult iterate (void)
5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const glu::RenderContext&	renderCtx			= m_context.getRenderContext();
5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const glw::Functions&		gl					= renderCtx.getFunctions();
5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					width				= 129;
5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					height				= 113;
5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Framebuffer			fbo					(renderCtx);
5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Renderbuffer			colorBuf			(renderCtx);
5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Texture				depthStencilTex		(renderCtx);
5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TextureLevel				uploadLevel			(glu::mapGLInternalFormat(m_format), width, height);
5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TextureLevel				readLevel			(TextureFormat(TextureFormat::RGBA, TextureFormat::UNSIGNED_INT32), width, height);
5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TextureLevel				stencilOnlyLevel	(TextureFormat(TextureFormat::S, TextureFormat::UNSIGNED_INT8), width, height);
5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkDepthStencilFormatSupport(m_context.getContextInfo(), m_format);
5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		renderTestPatternReference(uploadLevel);
5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		renderTestPatternReference(stencilOnlyLevel);
5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindTexture(GL_TEXTURE_2D, *depthStencilTex);
5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.texStorage2D(GL_TEXTURE_2D, 1, m_format, width, height);
5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::texSubImage2D(renderCtx, GL_TEXTURE_2D, 0, 0, 0, uploadLevel);
5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.getError(), "Uploading texture data failed");
5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindRenderbuffer(GL_RENDERBUFFER, *colorBuf);
5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.renderbufferStorage(GL_RENDERBUFFER, GL_R32UI, width, height);
5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindFramebuffer(GL_FRAMEBUFFER, *fbo);
5503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, *colorBuf);
5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkFramebufferStatus(gl);
5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		blitStencilToColor2D(renderCtx, *depthStencilTex, width, height);
5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::readPixels(renderCtx, 0, 0, readLevel);
5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const bool compareOk = compareStencilToRed(m_testCtx.getLog(), stencilOnlyLevel, readLevel);
5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_testCtx.setTestResult(compareOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
5593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									compareOk ? "Pass"				: "Image comparison failed");
5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return STOP;
5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint32 m_format;
5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5693c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass UploadTex2DArrayCase : public TestCase
5703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	UploadTex2DArrayCase (Context& context, const char* name, deUint32 format)
573b2e583dfcd8aa0d4ef254f841213fcf724b2b193Jarkko Pöyry		: TestCase	(context, name, glu::getTextureFormatName(format))
5743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format	(format)
5753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IterateResult iterate (void)
5793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const glu::RenderContext&	renderCtx			= m_context.getRenderContext();
5813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const glw::Functions&		gl					= renderCtx.getFunctions();
5823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					width				= 41;
5833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					height				= 13;
5843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					levels				= 7;
5853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					ptrnLevel			= 3;
5863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Framebuffer			fbo					(renderCtx);
5873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Renderbuffer			colorBuf			(renderCtx);
5883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Texture				depthStencilTex		(renderCtx);
5893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TextureLevel				uploadLevel			(glu::mapGLInternalFormat(m_format), width, height, levels);
5903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkDepthStencilFormatSupport(m_context.getContextInfo(), m_format);
5923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int levelNdx = 0; levelNdx < levels; levelNdx++)
5943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
5953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const tcu::PixelBufferAccess levelAccess = tcu::getSubregion(uploadLevel.getAccess(), 0, 0, levelNdx, width, height, 1);
5963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (levelNdx == ptrnLevel)
5983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				renderTestPatternReference(levelAccess);
5993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			else
60009037a4653649d707449463dfe9817a78ccf7d2fJarkko Pöyry				tcu::clearStencil(levelAccess, levelNdx);
6013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
6023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindTexture(GL_TEXTURE_2D_ARRAY, *depthStencilTex);
6043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.texStorage3D(GL_TEXTURE_2D_ARRAY, 1, m_format, width, height, levels);
6053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::texSubImage3D(renderCtx, GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, uploadLevel);
6063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.getError(), "Uploading texture data failed");
6073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindRenderbuffer(GL_RENDERBUFFER, *colorBuf);
6093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.renderbufferStorage(GL_RENDERBUFFER, GL_R32UI, width, height);
6103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindFramebuffer(GL_FRAMEBUFFER, *fbo);
6123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, *colorBuf);
6133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkFramebufferStatus(gl);
6143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
6163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			TextureLevel	readLevel		(TextureFormat(TextureFormat::RGBA, TextureFormat::UNSIGNED_INT32), width, height);
6173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			bool			allLevelsOk		= true;
6183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int levelNdx = 0; levelNdx < levels; levelNdx++)
6203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
6213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				tcu::ScopedLogSection section(m_testCtx.getLog(), "Level" + de::toString(levelNdx), "Level " + de::toString(levelNdx));
6223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				bool levelOk;
6233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				blitStencilToColor2DArray(renderCtx, *depthStencilTex, width, height, levelNdx);
6253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glu::readPixels(renderCtx, 0, 0, readLevel);
6263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (levelNdx == ptrnLevel)
6283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
6293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					TextureLevel reference(TextureFormat(TextureFormat::S, TextureFormat::UNSIGNED_INT8), width, height);
6303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					renderTestPatternReference(reference);
6313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					levelOk = compareStencilToRed(m_testCtx.getLog(), reference, readLevel);
6333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
6343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				else
6353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					levelOk = compareRedChannel(m_testCtx.getLog(), readLevel, levelNdx);
6363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (!levelOk)
6383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
6393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					allLevelsOk = false;
6403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					break;
6413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
6423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
6433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_testCtx.setTestResult(allLevelsOk ? QP_TEST_RESULT_PASS	: QP_TEST_RESULT_FAIL,
6453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									allLevelsOk ? "Pass"				: "Image comparison failed");
6463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
6473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return STOP;
6493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6513c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
6523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint32 m_format;
6533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
6543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6553c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass UploadTexCubeCase : public TestCase
6563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6573c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
6583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	UploadTexCubeCase (Context& context, const char* name, deUint32 format)
659b2e583dfcd8aa0d4ef254f841213fcf724b2b193Jarkko Pöyry		: TestCase	(context, name, glu::getTextureFormatName(format))
6603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format	(format)
6613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IterateResult iterate (void)
6653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const glu::RenderContext&	renderCtx			= m_context.getRenderContext();
6673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const glw::Functions&		gl					= renderCtx.getFunctions();
6683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					size				= 64;
6693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					renderWidth			= 128;
6703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					renderHeight		= 128;
6713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vector<float>				texCoord;
6723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Framebuffer			fbo					(renderCtx);
6733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Renderbuffer			colorBuf			(renderCtx);
6743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Texture				depthStencilTex		(renderCtx);
6753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureCube			texData				(glu::mapGLInternalFormat(m_format), size);
6763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureLevel			result				(TextureFormat(TextureFormat::RGBA, TextureFormat::UNORM_INT8), renderWidth, renderHeight);
6773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkDepthStencilFormatSupport(m_context.getContextInfo(), m_format);
6793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int faceNdx = 0; faceNdx < tcu::CUBEFACE_LAST; faceNdx++)
6813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
6823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const tcu::CubeFace		face		= tcu::CubeFace(faceNdx);
6833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int				stencilVal	= 42*faceNdx;
6843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			texData.allocLevel(face, 0);
68609037a4653649d707449463dfe9817a78ccf7d2fJarkko Pöyry			tcu::clearStencil(texData.getLevelFace(0, face), stencilVal);
6873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
6883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gls::TextureTestUtil::computeQuadTexCoordCube(texCoord, tcu::CUBEFACE_NEGATIVE_X, Vec2(-1.5f, -1.3f), Vec2(1.3f, 1.4f));
6903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindTexture(GL_TEXTURE_CUBE_MAP, *depthStencilTex);
6923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.texStorage2D(GL_TEXTURE_CUBE_MAP, 1, m_format, size, size);
6933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int faceNdx = 0; faceNdx < tcu::CUBEFACE_LAST; faceNdx++)
6953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glu::texSubImage2D(renderCtx, glu::getGLCubeFace(tcu::CubeFace(faceNdx)), 0, 0, 0, texData.getLevelFace(0, tcu::CubeFace(faceNdx)));
6963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.getError(), "Uploading texture data failed");
6983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindRenderbuffer(GL_RENDERBUFFER, *colorBuf);
7003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.renderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, renderWidth, renderHeight);
7013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindFramebuffer(GL_FRAMEBUFFER, *fbo);
7033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, *colorBuf);
7043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkFramebufferStatus(gl);
7053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		blitStencilToColorCube(renderCtx, *depthStencilTex, &texCoord[0], renderWidth, renderHeight);
7073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::readPixels(renderCtx, 0, 0, result);
7083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
7103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			using namespace gls::TextureTestUtil;
7113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::TextureCube		redTex			(TextureFormat(TextureFormat::R, TextureFormat::UNORM_INT8), size);
7133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const ReferenceParams	sampleParams	(TEXTURETYPE_CUBE, tcu::Sampler(tcu::Sampler::CLAMP_TO_EDGE,
7143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry																					tcu::Sampler::CLAMP_TO_EDGE,
7153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry																					tcu::Sampler::CLAMP_TO_EDGE,
7163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry																					tcu::Sampler::NEAREST,
7173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry																					tcu::Sampler::NEAREST));
7183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::LookupPrecision	lookupPrec;
7193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::LodPrecision		lodPrec;
7203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			bool					compareOk;
7213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			lookupPrec.colorMask		= tcu::BVec4(true, true, true, true);
7233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			lookupPrec.colorThreshold	= tcu::computeFixedPointThreshold(IVec4(8, 8, 8, 8));
7243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			lookupPrec.coordBits		= tcu::IVec3(22, 22, 22);
7253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			lookupPrec.uvwBits			= tcu::IVec3(5, 5, 0);
7263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			lodPrec.lodBits				= 7;
7273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			lodPrec.derivateBits		= 16;
7283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			stencilToUnorm8(texData, redTex);
7303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			compareOk = verifyTextureResult(m_testCtx, result, redTex, &texCoord[0], sampleParams, lookupPrec, lodPrec, tcu::PixelFormat(8, 8, 8, 8));
7323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_testCtx.setTestResult(compareOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
7343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									compareOk ? "Pass"				: "Image comparison failed");
7353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
7363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return STOP;
7383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
7393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7403c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
7413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint32 m_format;
7423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
7433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7443c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass RenderTex2DCase : public TestCase
7453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7463c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
7473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	RenderTex2DCase (Context& context, const char* name, deUint32 format)
748b2e583dfcd8aa0d4ef254f841213fcf724b2b193Jarkko Pöyry		: TestCase	(context, name, glu::getTextureFormatName(format))
7493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format	(format)
7503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
7513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
7523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IterateResult iterate (void)
7543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
7553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const glu::RenderContext&	renderCtx		= m_context.getRenderContext();
7563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const glw::Functions&		gl				= renderCtx.getFunctions();
7573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					width			= 117;
7583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					height			= 193;
7593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Framebuffer			fbo				(renderCtx);
7603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Renderbuffer			colorBuf		(renderCtx);
7613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Texture				depthStencilTex	(renderCtx);
7623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TextureLevel				result			(TextureFormat(TextureFormat::RGBA, TextureFormat::UNSIGNED_INT32), width, height);
7633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TextureLevel				reference		(TextureFormat(TextureFormat::S, TextureFormat::UNSIGNED_INT8), width, height);
7643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkDepthStencilFormatSupport(m_context.getContextInfo(), m_format);
7663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindRenderbuffer(GL_RENDERBUFFER, *colorBuf);
7683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.renderbufferStorage(GL_RENDERBUFFER, GL_R32UI, width, height);
7693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindTexture(GL_TEXTURE_2D, *depthStencilTex);
7713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.texStorage2D(GL_TEXTURE_2D, 1, m_format, width, height);
7723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindFramebuffer(GL_FRAMEBUFFER, *fbo);
7743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, *colorBuf);
7753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, *depthStencilTex, 0);
7763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkFramebufferStatus(gl);
7773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		drawTestPattern(renderCtx, width, height);
7793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, 0);
7813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkFramebufferStatus(gl);
7823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		blitStencilToColor2D(renderCtx, *depthStencilTex, width, height);
7843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::readPixels(renderCtx, 0, 0, result.getAccess());
7853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		renderTestPatternReference(reference);
7873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
7893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const bool compareOk = compareStencilToRed(m_testCtx.getLog(), reference, result);
7903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_testCtx.setTestResult(compareOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
7913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									compareOk ? "Pass"				: "Image comparison failed");
7923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
7933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return STOP;
7953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
7963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7973c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
7983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint32 m_format;
7993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
8003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8013c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ClearTex2DCase : public TestCase
8023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8033c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
8043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ClearTex2DCase (Context& context, const char* name, deUint32 format)
805b2e583dfcd8aa0d4ef254f841213fcf724b2b193Jarkko Pöyry		: TestCase	(context, name, glu::getTextureFormatName(format))
8063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format	(format)
8073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
8083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
8093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IterateResult iterate (void)
8113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
8123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const glu::RenderContext&	renderCtx		= m_context.getRenderContext();
8133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const glw::Functions&		gl				= renderCtx.getFunctions();
8143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					width			= 125;
8153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					height			= 117;
8163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					cellSize		= 8;
8173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Framebuffer			fbo				(renderCtx);
8183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Renderbuffer			colorBuf		(renderCtx);
8193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Texture				depthStencilTex	(renderCtx);
8203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TextureLevel				result			(TextureFormat(TextureFormat::RGBA, TextureFormat::UNSIGNED_INT32), width, height);
8213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TextureLevel				reference		(TextureFormat(TextureFormat::S, TextureFormat::UNSIGNED_INT8), width, height);
8223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkDepthStencilFormatSupport(m_context.getContextInfo(), m_format);
8243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindRenderbuffer(GL_RENDERBUFFER, *colorBuf);
8263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.renderbufferStorage(GL_RENDERBUFFER, GL_R32UI, width, height);
8273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindTexture(GL_TEXTURE_2D, *depthStencilTex);
8293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.texStorage2D(GL_TEXTURE_2D, 1, m_format, width, height);
8303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindFramebuffer(GL_FRAMEBUFFER, *fbo);
8323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, *colorBuf);
8333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, *depthStencilTex, 0);
8343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkFramebufferStatus(gl);
8353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.enable(GL_SCISSOR_TEST);
8373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int y = 0; y < height; y += cellSize)
8393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
8403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int x = 0; x < width; x += cellSize)
8413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
8423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const int		clearW		= de::min(cellSize, width-x);
8433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const int		clearH		= de::min(cellSize, height-y);
8443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const int		stencil		= int((deInt32Hash(x) ^ deInt32Hash(y)) & 0xff);
8453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				gl.clearStencil(stencil);
8473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				gl.scissor(x, y, clearW, clearH);
8483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				gl.clear(GL_STENCIL_BUFFER_BIT);
8493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
85009037a4653649d707449463dfe9817a78ccf7d2fJarkko Pöyry				tcu::clearStencil(tcu::getSubregion(reference.getAccess(), x, y, clearW, clearH), stencil);
8513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
8523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
8533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.disable(GL_SCISSOR_TEST);
8553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, 0);
8573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkFramebufferStatus(gl);
8583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		blitStencilToColor2D(renderCtx, *depthStencilTex, width, height);
8603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::readPixels(renderCtx, 0, 0, result.getAccess());
8613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
8633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const bool compareOk = compareStencilToRed(m_testCtx.getLog(), reference, result);
8643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_testCtx.setTestResult(compareOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
8653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									compareOk ? "Pass"				: "Image comparison failed");
8663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
8673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return STOP;
8693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
8703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8713c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
8723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint32 m_format;
8733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
8743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8753c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass CompareModeCase : public TestCase
8763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8773c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
8783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	CompareModeCase (Context& context, const char* name, deUint32 format)
879b2e583dfcd8aa0d4ef254f841213fcf724b2b193Jarkko Pöyry		: TestCase	(context, name, glu::getTextureFormatName(format))
8803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format	(format)
8813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
8823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
8833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IterateResult iterate (void)
8853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
8863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const glu::RenderContext&	renderCtx			= m_context.getRenderContext();
8873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const glw::Functions&		gl					= renderCtx.getFunctions();
8883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					width				= 64;
8893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					height				= 64;
8903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Framebuffer			fbo					(renderCtx);
8913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Renderbuffer			colorBuf			(renderCtx);
8923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Texture				depthStencilTex		(renderCtx);
8933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TextureLevel				uploadLevel			(glu::mapGLInternalFormat(m_format), width, height);
8943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TextureLevel				readLevel			(TextureFormat(TextureFormat::RGBA, TextureFormat::UNSIGNED_INT32), width, height);
8953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TextureLevel				stencilOnlyLevel	(TextureFormat(TextureFormat::S, TextureFormat::UNSIGNED_INT8), width, height);
8963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkDepthStencilFormatSupport(m_context.getContextInfo(), m_format);
8983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_testCtx.getLog() << TestLog::Message << "NOTE: Texture compare mode has no effect when reading stencil values." << TestLog::EndMessage;
9003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		renderTestPatternReference(uploadLevel);
9023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		renderTestPatternReference(stencilOnlyLevel);
9033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindTexture(GL_TEXTURE_2D, *depthStencilTex);
9053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.texStorage2D(GL_TEXTURE_2D, 1, m_format, width, height);
9063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
9073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LESS);
9083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::texSubImage2D(renderCtx, GL_TEXTURE_2D, 0, 0, 0, uploadLevel);
9093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.getError(), "Uploading texture data failed");
9103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindRenderbuffer(GL_RENDERBUFFER, *colorBuf);
9123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.renderbufferStorage(GL_RENDERBUFFER, GL_R32UI, width, height);
9133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindFramebuffer(GL_FRAMEBUFFER, *fbo);
9153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, *colorBuf);
9163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkFramebufferStatus(gl);
9173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		blitStencilToColor2D(renderCtx, *depthStencilTex, width, height);
9193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::readPixels(renderCtx, 0, 0, readLevel);
9203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
9223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const bool compareOk = compareStencilToRed(m_testCtx.getLog(), stencilOnlyLevel, readLevel);
9233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_testCtx.setTestResult(compareOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
9243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									compareOk ? "Pass"				: "Image comparison failed");
9253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
9263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return STOP;
9283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
9293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9303c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
9313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint32 m_format;
9323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
9333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9343c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BaseLevelCase : public TestCase
9353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
9363c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
9373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BaseLevelCase (Context& context, const char* name, deUint32 format)
938b2e583dfcd8aa0d4ef254f841213fcf724b2b193Jarkko Pöyry		: TestCase	(context, name, glu::getTextureFormatName(format))
9393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format	(format)
9403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
9413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
9423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IterateResult iterate (void)
9443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
9453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const glu::RenderContext&	renderCtx			= m_context.getRenderContext();
9463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const glw::Functions&		gl					= renderCtx.getFunctions();
9473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					width				= 128;
9483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					height				= 128;
9493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					levelNdx			= 2;
9503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					levelWidth			= width>>levelNdx;
9513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					levelHeight			= height>>levelNdx;
9523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Framebuffer			fbo					(renderCtx);
9533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Renderbuffer			colorBuf			(renderCtx);
9543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Texture				depthStencilTex		(renderCtx);
9553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TextureLevel				uploadLevel			(glu::mapGLInternalFormat(m_format), levelWidth, levelHeight);
9563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TextureLevel				readLevel			(TextureFormat(TextureFormat::RGBA, TextureFormat::UNSIGNED_INT32), levelWidth, levelHeight);
9573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TextureLevel				stencilOnlyLevel	(TextureFormat(TextureFormat::S, TextureFormat::UNSIGNED_INT8), levelWidth, levelHeight);
9583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkDepthStencilFormatSupport(m_context.getContextInfo(), m_format);
9603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_testCtx.getLog() << TestLog::Message << "GL_TEXTURE_BASE_LEVEL = " << levelNdx << TestLog::EndMessage;
9623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		renderTestPatternReference(uploadLevel);
9643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		renderTestPatternReference(stencilOnlyLevel);
9653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindTexture(GL_TEXTURE_2D, *depthStencilTex);
9673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.texStorage2D(GL_TEXTURE_2D, deLog2Floor32(de::max(width, height))+1, m_format, width, height);
9683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, levelNdx);
9693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::texSubImage2D(renderCtx, GL_TEXTURE_2D, levelNdx, 0, 0, uploadLevel);
9703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.getError(), "Uploading texture data failed");
9713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindRenderbuffer(GL_RENDERBUFFER, *colorBuf);
9733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.renderbufferStorage(GL_RENDERBUFFER, GL_R32UI, levelWidth, levelHeight);
9743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindFramebuffer(GL_FRAMEBUFFER, *fbo);
9763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, *colorBuf);
9773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkFramebufferStatus(gl);
9783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		blitStencilToColor2D(renderCtx, *depthStencilTex, levelWidth, levelHeight);
9803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::readPixels(renderCtx, 0, 0, readLevel);
9813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
9833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const bool compareOk = compareStencilToRed(m_testCtx.getLog(), stencilOnlyLevel, readLevel);
9843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_testCtx.setTestResult(compareOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
9853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									compareOk ? "Pass"				: "Image comparison failed");
9863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
9873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return STOP;
9893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
9903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9913c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
9923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint32 m_format;
9933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
9943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // anonymous
9963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9973c827367444ee418f129b2c238299f49d3264554Jarkko PoyryStencilTexturingTests::StencilTexturingTests (Context& context)
9983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TestCaseGroup(context, "stencil_texturing", "Stencil texturing tests")
9993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
10003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
10013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10023c827367444ee418f129b2c238299f49d3264554Jarkko PoyryStencilTexturingTests::~StencilTexturingTests (void)
10033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
10043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
10053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10063c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid StencilTexturingTests::init (void)
10073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
10083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// .format
10093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
10103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* const formatGroup = new tcu::TestCaseGroup(m_testCtx, "format", "Formats");
10113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(formatGroup);
10123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		formatGroup->addChild(new UploadTex2DCase		(m_context, "depth32f_stencil8_2d",			GL_DEPTH32F_STENCIL8));
10143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		formatGroup->addChild(new UploadTex2DArrayCase	(m_context, "depth32f_stencil8_2d_array",	GL_DEPTH32F_STENCIL8));
10153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		formatGroup->addChild(new UploadTexCubeCase		(m_context, "depth32f_stencil8_cube",		GL_DEPTH32F_STENCIL8));
10163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		formatGroup->addChild(new UploadTex2DCase		(m_context, "depth24_stencil8_2d",			GL_DEPTH24_STENCIL8));
10173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		formatGroup->addChild(new UploadTex2DArrayCase	(m_context, "depth24_stencil8_2d_array",	GL_DEPTH24_STENCIL8));
10183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		formatGroup->addChild(new UploadTexCubeCase		(m_context, "depth24_stencil8_cube",		GL_DEPTH24_STENCIL8));
10193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// OES_texture_stencil8
10213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		formatGroup->addChild(new UploadTex2DCase		(m_context, "stencil_index8_2d",			GL_STENCIL_INDEX8));
10223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		formatGroup->addChild(new UploadTex2DArrayCase	(m_context, "stencil_index8_2d_array",		GL_STENCIL_INDEX8));
10233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		formatGroup->addChild(new UploadTexCubeCase		(m_context, "stencil_index8_cube",			GL_STENCIL_INDEX8));
10243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
10253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// .render
10273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
10283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* const readRenderGroup = new tcu::TestCaseGroup(m_testCtx, "render", "Read rendered stencil values");
10293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(readRenderGroup);
10303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		readRenderGroup->addChild(new ClearTex2DCase	(m_context, "depth32f_stencil8_clear",	GL_DEPTH32F_STENCIL8));
10323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		readRenderGroup->addChild(new RenderTex2DCase	(m_context, "depth32f_stencil8_draw",	GL_DEPTH32F_STENCIL8));
10333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		readRenderGroup->addChild(new ClearTex2DCase	(m_context, "depth24_stencil8_clear",	GL_DEPTH24_STENCIL8));
10343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		readRenderGroup->addChild(new RenderTex2DCase	(m_context, "depth24_stencil8_draw",	GL_DEPTH24_STENCIL8));
10353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
10363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// .misc
10383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
10393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* const miscGroup = new tcu::TestCaseGroup(m_testCtx, "misc", "Misc cases");
10403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(miscGroup);
10413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		miscGroup->addChild(new CompareModeCase	(m_context, "compare_mode_effect",	GL_DEPTH24_STENCIL8));
10433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		miscGroup->addChild(new BaseLevelCase	(m_context, "base_level",			GL_DEPTH24_STENCIL8));
10443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
10453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
10463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Functional
10483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles31
10493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp
1050