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
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		indices[rectNdx*6 + 0] = rectNdx*4 + 0;
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		indices[rectNdx*6 + 1] = rectNdx*4 + 1;
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		indices[rectNdx*6 + 2] = rectNdx*4 + 2;
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		indices[rectNdx*6 + 3] = rectNdx*4 + 2;
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		indices[rectNdx*6 + 4] = rectNdx*4 + 1;
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		indices[rectNdx*6 + 5] = 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{
1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int		stencilBits		= tcu::getTextureFormatBitDepth(dst.getFormat()).w();
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
1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::clear(dst, IVec4(0));
1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	genTestRects(rects, dst.getWidth(), dst.getHeight());
1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (vector<IVec4>::const_iterator rectIter = rects.begin(); rectIter != rects.end(); ++rectIter)
1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int	x0		= rectIter->x();
1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int	y0		= rectIter->y();
1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int	x1		= x0+rectIter->z();
1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int	y1		= y0+rectIter->w();
1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int y = y0; y < y1; y++)
1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int x = x0; x < x1; x++)
1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const int oldVal	= dst.getPixStencil(x, y);
1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const int newVal	= (oldVal+1)&stencilMask;
1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				dst.setPixStencil(newVal, x, y);
1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void blitStencilToColor2D (const glu::RenderContext& renderCtx, deUint32 srcTex, int width, int height)
1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glu::ShaderProgram program(renderCtx, glu::ProgramSources()
1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< glu::VertexSource(
2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"#version 300 es\n"
2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"in highp vec4 a_position;\n"
2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"in highp vec2 a_texCoord;\n"
2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"out highp vec2 v_texCoord;\n"
2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	gl_Position = a_position;\n"
2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	v_texCoord = a_texCoord;\n"
2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n")
2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< glu::FragmentSource(
2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"#version 300 es\n"
2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp usampler2D u_sampler;\n"
2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"in highp vec2 v_texCoord;\n"
2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"layout(location = 0) out highp uint o_stencil;\n"
2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	o_stencil = texture(u_sampler, v_texCoord).x;\n"
2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n"));
2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const float positions[] =
2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		-1.0f, -1.0f,
2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		+1.0f, -1.0f,
2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		-1.0f, +1.0f,
2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		+1.0f, +1.0f
2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const float texCoord[] =
2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		0.0f, 0.0f,
2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		1.0f, 0.0f,
2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		0.0f, 1.0f,
2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		1.0f, 1.0f
2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glu::VertexArrayBinding vertexArrays[] =
2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::va::Float("a_position", 2, 4, 0, &positions[0]),
2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::va::Float("a_texCoord", 2, 4, 0, &texCoord[0])
2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint8 indices[] = { 0, 1, 2, 2, 1, 3 };
2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glw::Functions& gl = renderCtx.getFunctions();
2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!program.isOk())
2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		throw tcu::TestError("Compile failed");
2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.activeTexture(GL_TEXTURE0);
2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.bindTexture(GL_TEXTURE_2D, srcTex);
2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.texParameteri(GL_TEXTURE_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, GL_STENCIL_INDEX);
2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_EXPECT_NO_ERROR(gl.getError(), "Texture state setup failed");
2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.useProgram(program.getProgram());
2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.uniform1i(gl.getUniformLocation(program.getProgram(), "u_sampler"), 0);
2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_EXPECT_NO_ERROR(gl.getError(), "Program setup failed");
2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.viewport(0, 0, width, height);
2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::draw(renderCtx, program.getProgram(), DE_LENGTH_OF_ARRAY(vertexArrays), &vertexArrays[0],
2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			  glu::pr::Triangles(DE_LENGTH_OF_ARRAY(indices), &indices[0]));
2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void blitStencilToColor2DArray (const glu::RenderContext& renderCtx, deUint32 srcTex, int width, int height, int level)
2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glu::ShaderProgram program(renderCtx, glu::ProgramSources()
2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< glu::VertexSource(
2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"#version 300 es\n"
2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"in highp vec4 a_position;\n"
2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"in highp vec3 a_texCoord;\n"
2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"out highp vec3 v_texCoord;\n"
2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	gl_Position = a_position;\n"
2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	v_texCoord = a_texCoord;\n"
2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n")
2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< glu::FragmentSource(
2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"#version 300 es\n"
2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp usampler2DArray u_sampler;\n"
2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"in highp vec3 v_texCoord;\n"
2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"layout(location = 0) out highp uint o_stencil;\n"
2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	o_stencil = texture(u_sampler, v_texCoord).x;\n"
2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n"));
2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const float positions[] =
2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		-1.0f, -1.0f,
2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		+1.0f, -1.0f,
2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		-1.0f, +1.0f,
2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		+1.0f, +1.0f
2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const float texCoord[] =
2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		0.0f, 0.0f, float(level),
2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		1.0f, 0.0f, float(level),
2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		0.0f, 1.0f, float(level),
2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		1.0f, 1.0f, float(level)
2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glu::VertexArrayBinding vertexArrays[] =
2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::va::Float("a_position", 2, 4, 0, &positions[0]),
3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::va::Float("a_texCoord", 3, 4, 0, &texCoord[0])
3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint8 indices[] = { 0, 1, 2, 2, 1, 3 };
3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glw::Functions& gl = renderCtx.getFunctions();
3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!program.isOk())
3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		throw tcu::TestError("Compile failed");
3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.activeTexture(GL_TEXTURE0);
3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.bindTexture(GL_TEXTURE_2D_ARRAY, srcTex);
3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.texParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.texParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.texParameteri(GL_TEXTURE_2D_ARRAY, GL_DEPTH_STENCIL_TEXTURE_MODE, GL_STENCIL_INDEX);
3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_EXPECT_NO_ERROR(gl.getError(), "Texture state setup failed");
3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.useProgram(program.getProgram());
3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.uniform1i(gl.getUniformLocation(program.getProgram(), "u_sampler"), 0);
3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_EXPECT_NO_ERROR(gl.getError(), "Program setup failed");
3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.viewport(0, 0, width, height);
3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::draw(renderCtx, program.getProgram(), DE_LENGTH_OF_ARRAY(vertexArrays), &vertexArrays[0],
3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			  glu::pr::Triangles(DE_LENGTH_OF_ARRAY(indices), &indices[0]));
3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void blitStencilToColorCube (const glu::RenderContext& renderCtx, deUint32 srcTex, const float* texCoord, int width, int height)
3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glu::ShaderProgram program(renderCtx, glu::ProgramSources()
3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< glu::VertexSource(
3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"#version 300 es\n"
3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"in highp vec4 a_position;\n"
3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"in highp vec3 a_texCoord;\n"
3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"out highp vec3 v_texCoord;\n"
3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	gl_Position = a_position;\n"
3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	v_texCoord = a_texCoord;\n"
3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n")
3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< glu::FragmentSource(
3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"#version 300 es\n"
3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uniform highp usamplerCube u_sampler;\n"
3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"in highp vec3 v_texCoord;\n"
3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"layout(location = 0) out highp vec4 o_color;\n"
3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	o_color.x = float(texture(u_sampler, v_texCoord).x) / 255.0;\n"
3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	o_color.yzw = vec3(0.0, 0.0, 1.0);\n"
3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n"));
3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const float positions[] =
3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		-1.0f, -1.0f,
3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		-1.0f, +1.0f,
3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		+1.0f, -1.0f,
3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		+1.0f, +1.0f
3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glu::VertexArrayBinding vertexArrays[] =
3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::va::Float("a_position", 2, 4, 0, &positions[0]),
3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::va::Float("a_texCoord", 3, 4, 0, texCoord)
3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint8 indices[] = { 0, 1, 2, 2, 1, 3 };
3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glw::Functions& gl = renderCtx.getFunctions();
3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!program.isOk())
3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		throw tcu::TestError("Compile failed");
3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.activeTexture(GL_TEXTURE0);
3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.bindTexture(GL_TEXTURE_CUBE_MAP, srcTex);
3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_DEPTH_STENCIL_TEXTURE_MODE, GL_STENCIL_INDEX);
3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_EXPECT_NO_ERROR(gl.getError(), "Texture state setup failed");
3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.useProgram(program.getProgram());
3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.uniform1i(gl.getUniformLocation(program.getProgram(), "u_sampler"), 0);
3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_EXPECT_NO_ERROR(gl.getError(), "Program setup failed");
3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.viewport(0, 0, width, height);
3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::draw(renderCtx, program.getProgram(), DE_LENGTH_OF_ARRAY(vertexArrays), &vertexArrays[0],
3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			  glu::pr::Triangles(DE_LENGTH_OF_ARRAY(indices), &indices[0]));
3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic inline tcu::ConstPixelBufferAccess stencilToRedAccess (const tcu::ConstPixelBufferAccess& access)
3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT(access.getFormat() == TextureFormat(TextureFormat::S, TextureFormat::UNSIGNED_INT8));
3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return tcu::ConstPixelBufferAccess(TextureFormat(TextureFormat::R, TextureFormat::UNSIGNED_INT8),
3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									   access.getWidth(), access.getHeight(), access.getDepth(), access.getRowPitch(), access.getSlicePitch(), access.getDataPtr());
3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic bool compareStencilToRed (tcu::TestLog& log, const tcu::ConstPixelBufferAccess& stencilRef, const tcu::ConstPixelBufferAccess& result)
3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int		maxPrints		= 10;
3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int				numFailed		= 0;
3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT(stencilRef.getFormat().order == TextureFormat::S);
3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT(stencilRef.getWidth() == result.getWidth() && stencilRef.getHeight() == result.getHeight());
3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int y = 0; y < stencilRef.getHeight(); y++)
4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int x = 0; x < stencilRef.getWidth(); x++)
4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int		ref		= stencilRef.getPixStencil(x, y);
4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int		res		= result.getPixelInt(x, y).x();
4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (ref != res)
4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (numFailed < maxPrints)
4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					log << TestLog::Message << "ERROR: Expected " << ref << ", got " << res << " at (" << x << ", " << y << ")" << TestLog::EndMessage;
4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				else if (numFailed == maxPrints)
4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					log << TestLog::Message << "..." << TestLog::EndMessage;
4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				numFailed += 1;
4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	log << TestLog::Message << "Found " << numFailed << " faulty pixels, comparison " << (numFailed == 0 ? "passed." : "FAILED!") << TestLog::EndMessage;
4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	log << TestLog::ImageSet("ComparisonResult", "Image comparison result")
4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< TestLog::Image("Result", "Result stencil buffer", result);
4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (numFailed > 0)
4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		log << TestLog::Image("Reference", "Reference stencil buffer", stencilToRedAccess(stencilRef));
4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	log << TestLog::EndImageSet;
4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return numFailed == 0;
4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic bool compareRedChannel (tcu::TestLog& log, const tcu::ConstPixelBufferAccess& result, int reference)
4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int		maxPrints		= 10;
4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int				numFailed		= 0;
4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int y = 0; y < result.getHeight(); y++)
4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int x = 0; x < result.getWidth(); x++)
4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int res = result.getPixelInt(x, y).x();
4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (reference != res)
4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (numFailed < maxPrints)
4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					log << TestLog::Message << "ERROR: Expected " << reference << ", got " << res << " at (" << x << ", " << y << ")" << TestLog::EndMessage;
4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				else if (numFailed == maxPrints)
4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					log << TestLog::Message << "..." << TestLog::EndMessage;
4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				numFailed += 1;
4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	log << TestLog::Message << "Found " << numFailed << " faulty pixels, comparison " << (numFailed == 0 ? "passed." : "FAILED!") << TestLog::EndMessage;
4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	log << TestLog::ImageSet("ComparisonResult", "Image comparison result")
4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< TestLog::Image("Result", "Result stencil buffer", result);
4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	log << TestLog::EndImageSet;
4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return numFailed == 0;
4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void stencilToUnorm8 (const tcu::TextureCube& src, tcu::TextureCube& dst)
4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int levelNdx = 0; levelNdx < src.getNumLevels(); levelNdx++)
4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int faceNdx = 0; faceNdx < tcu::CUBEFACE_LAST; faceNdx++)
4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const tcu::CubeFace face = tcu::CubeFace(faceNdx);
4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (!src.isLevelEmpty(face, levelNdx))
4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				dst.allocLevel(face, levelNdx);
4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const tcu::ConstPixelBufferAccess	srcLevel	= src.getLevelFace(levelNdx, face);
4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const tcu::PixelBufferAccess		dstLevel	= dst.getLevelFace(levelNdx, face);
4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				for (int y = 0; y < src.getSize(); y++)
4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				for (int x = 0; x < src.getSize(); x++)
4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					dstLevel.setPixel(Vec4(float(srcLevel.getPixStencil(x, y)) / 255.f, 0.f, 0.f, 1.f), x, y);
4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void checkDepthStencilFormatSupport (const glu::ContextInfo& ctxInfo, deUint32 format)
4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (format == GL_STENCIL_INDEX8)
4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const char* reqExt = "GL_OES_texture_stencil8";
4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (!ctxInfo.isExtensionSupported(reqExt))
4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			throw tcu::NotSupportedError(glu::getPixelFormatStr(format).toString() + " requires " + reqExt);
4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	else
4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(format == GL_DEPTH32F_STENCIL8 || format == GL_DEPTH24_STENCIL8);
4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void checkFramebufferStatus (const glw::Functions& gl)
5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint32 status = gl.checkFramebufferStatus(GL_FRAMEBUFFER);
5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (status == GL_FRAMEBUFFER_UNSUPPORTED)
5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		throw tcu::NotSupportedError("Unsupported framebuffer configuration");
5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	else if (status != GL_FRAMEBUFFER_COMPLETE)
5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		throw tcu::TestError("Incomplete framebuffer: " + glu::getFramebufferStatusStr(status).toString());
5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass UploadTex2DCase : public TestCase
5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5143c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
5153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	UploadTex2DCase (Context& context, const char* name, deUint32 format)
5163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TestCase	(context, name, glu::getPixelFormatName(format))
5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format	(format)
5183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IterateResult iterate (void)
5223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const glu::RenderContext&	renderCtx			= m_context.getRenderContext();
5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const glw::Functions&		gl					= renderCtx.getFunctions();
5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					width				= 129;
5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					height				= 113;
5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Framebuffer			fbo					(renderCtx);
5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Renderbuffer			colorBuf			(renderCtx);
5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Texture				depthStencilTex		(renderCtx);
5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TextureLevel				uploadLevel			(glu::mapGLInternalFormat(m_format), width, height);
5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TextureLevel				readLevel			(TextureFormat(TextureFormat::RGBA, TextureFormat::UNSIGNED_INT32), width, height);
5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TextureLevel				stencilOnlyLevel	(TextureFormat(TextureFormat::S, TextureFormat::UNSIGNED_INT8), width, height);
5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkDepthStencilFormatSupport(m_context.getContextInfo(), m_format);
5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		renderTestPatternReference(uploadLevel);
5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		renderTestPatternReference(stencilOnlyLevel);
5383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindTexture(GL_TEXTURE_2D, *depthStencilTex);
5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.texStorage2D(GL_TEXTURE_2D, 1, m_format, width, height);
5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::texSubImage2D(renderCtx, GL_TEXTURE_2D, 0, 0, 0, uploadLevel);
5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.getError(), "Uploading texture data failed");
5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindRenderbuffer(GL_RENDERBUFFER, *colorBuf);
5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.renderbufferStorage(GL_RENDERBUFFER, GL_R32UI, width, height);
5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindFramebuffer(GL_FRAMEBUFFER, *fbo);
5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, *colorBuf);
5493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkFramebufferStatus(gl);
5503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		blitStencilToColor2D(renderCtx, *depthStencilTex, width, height);
5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::readPixels(renderCtx, 0, 0, readLevel);
5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const bool compareOk = compareStencilToRed(m_testCtx.getLog(), stencilOnlyLevel, readLevel);
5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_testCtx.setTestResult(compareOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									compareOk ? "Pass"				: "Image comparison failed");
5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
5593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return STOP;
5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint32 m_format;
5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass UploadTex2DArrayCase : public TestCase
5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5693c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
5703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	UploadTex2DArrayCase (Context& context, const char* name, deUint32 format)
5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TestCase	(context, name, glu::getPixelFormatName(format))
5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format	(format)
5733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IterateResult iterate (void)
5773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const glu::RenderContext&	renderCtx			= m_context.getRenderContext();
5793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const glw::Functions&		gl					= renderCtx.getFunctions();
5803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					width				= 41;
5813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					height				= 13;
5823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					levels				= 7;
5833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					ptrnLevel			= 3;
5843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Framebuffer			fbo					(renderCtx);
5853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Renderbuffer			colorBuf			(renderCtx);
5863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Texture				depthStencilTex		(renderCtx);
5873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TextureLevel				uploadLevel			(glu::mapGLInternalFormat(m_format), width, height, levels);
5883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkDepthStencilFormatSupport(m_context.getContextInfo(), m_format);
5903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int levelNdx = 0; levelNdx < levels; levelNdx++)
5923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
5933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const tcu::PixelBufferAccess levelAccess = tcu::getSubregion(uploadLevel.getAccess(), 0, 0, levelNdx, width, height, 1);
5943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (levelNdx == ptrnLevel)
5963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				renderTestPatternReference(levelAccess);
5973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			else
5983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				tcu::clear(levelAccess, IVec4(0, 0, 0, levelNdx));
5993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
6003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindTexture(GL_TEXTURE_2D_ARRAY, *depthStencilTex);
6023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.texStorage3D(GL_TEXTURE_2D_ARRAY, 1, m_format, width, height, levels);
6033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::texSubImage3D(renderCtx, GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, uploadLevel);
6043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.getError(), "Uploading texture data failed");
6053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindRenderbuffer(GL_RENDERBUFFER, *colorBuf);
6073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.renderbufferStorage(GL_RENDERBUFFER, GL_R32UI, width, height);
6083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindFramebuffer(GL_FRAMEBUFFER, *fbo);
6103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, *colorBuf);
6113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkFramebufferStatus(gl);
6123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
6143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			TextureLevel	readLevel		(TextureFormat(TextureFormat::RGBA, TextureFormat::UNSIGNED_INT32), width, height);
6153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			bool			allLevelsOk		= true;
6163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int levelNdx = 0; levelNdx < levels; levelNdx++)
6183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
6193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				tcu::ScopedLogSection section(m_testCtx.getLog(), "Level" + de::toString(levelNdx), "Level " + de::toString(levelNdx));
6203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				bool levelOk;
6213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				blitStencilToColor2DArray(renderCtx, *depthStencilTex, width, height, levelNdx);
6233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glu::readPixels(renderCtx, 0, 0, readLevel);
6243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (levelNdx == ptrnLevel)
6263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
6273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					TextureLevel reference(TextureFormat(TextureFormat::S, TextureFormat::UNSIGNED_INT8), width, height);
6283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					renderTestPatternReference(reference);
6293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					levelOk = compareStencilToRed(m_testCtx.getLog(), reference, readLevel);
6313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
6323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				else
6333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					levelOk = compareRedChannel(m_testCtx.getLog(), readLevel, levelNdx);
6343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (!levelOk)
6363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
6373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					allLevelsOk = false;
6383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					break;
6393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
6403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
6413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_testCtx.setTestResult(allLevelsOk ? QP_TEST_RESULT_PASS	: QP_TEST_RESULT_FAIL,
6433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									allLevelsOk ? "Pass"				: "Image comparison failed");
6443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
6453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return STOP;
6473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6493c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
6503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint32 m_format;
6513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
6523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6533c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass UploadTexCubeCase : public TestCase
6543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6553c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
6563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	UploadTexCubeCase (Context& context, const char* name, deUint32 format)
6573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TestCase	(context, name, glu::getPixelFormatName(format))
6583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format	(format)
6593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IterateResult iterate (void)
6633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const glu::RenderContext&	renderCtx			= m_context.getRenderContext();
6653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const glw::Functions&		gl					= renderCtx.getFunctions();
6663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					size				= 64;
6673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					renderWidth			= 128;
6683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					renderHeight		= 128;
6693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vector<float>				texCoord;
6703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Framebuffer			fbo					(renderCtx);
6713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Renderbuffer			colorBuf			(renderCtx);
6723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Texture				depthStencilTex		(renderCtx);
6733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureCube			texData				(glu::mapGLInternalFormat(m_format), size);
6743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureLevel			result				(TextureFormat(TextureFormat::RGBA, TextureFormat::UNORM_INT8), renderWidth, renderHeight);
6753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkDepthStencilFormatSupport(m_context.getContextInfo(), m_format);
6773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int faceNdx = 0; faceNdx < tcu::CUBEFACE_LAST; faceNdx++)
6793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
6803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const tcu::CubeFace		face		= tcu::CubeFace(faceNdx);
6813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int				stencilVal	= 42*faceNdx;
6823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			texData.allocLevel(face, 0);
6843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::clear(texData.getLevelFace(0, face), IVec4(0, 0, 0, stencilVal));
6853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
6863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gls::TextureTestUtil::computeQuadTexCoordCube(texCoord, tcu::CUBEFACE_NEGATIVE_X, Vec2(-1.5f, -1.3f), Vec2(1.3f, 1.4f));
6883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindTexture(GL_TEXTURE_CUBE_MAP, *depthStencilTex);
6903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.texStorage2D(GL_TEXTURE_CUBE_MAP, 1, m_format, size, size);
6913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int faceNdx = 0; faceNdx < tcu::CUBEFACE_LAST; faceNdx++)
6933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glu::texSubImage2D(renderCtx, glu::getGLCubeFace(tcu::CubeFace(faceNdx)), 0, 0, 0, texData.getLevelFace(0, tcu::CubeFace(faceNdx)));
6943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.getError(), "Uploading texture data failed");
6963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindRenderbuffer(GL_RENDERBUFFER, *colorBuf);
6983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.renderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, renderWidth, renderHeight);
6993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindFramebuffer(GL_FRAMEBUFFER, *fbo);
7013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, *colorBuf);
7023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkFramebufferStatus(gl);
7033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		blitStencilToColorCube(renderCtx, *depthStencilTex, &texCoord[0], renderWidth, renderHeight);
7053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::readPixels(renderCtx, 0, 0, result);
7063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
7083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			using namespace gls::TextureTestUtil;
7093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::TextureCube		redTex			(TextureFormat(TextureFormat::R, TextureFormat::UNORM_INT8), size);
7113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const ReferenceParams	sampleParams	(TEXTURETYPE_CUBE, tcu::Sampler(tcu::Sampler::CLAMP_TO_EDGE,
7123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry																					tcu::Sampler::CLAMP_TO_EDGE,
7133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry																					tcu::Sampler::CLAMP_TO_EDGE,
7143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry																					tcu::Sampler::NEAREST,
7153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry																					tcu::Sampler::NEAREST));
7163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::LookupPrecision	lookupPrec;
7173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::LodPrecision		lodPrec;
7183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			bool					compareOk;
7193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			lookupPrec.colorMask		= tcu::BVec4(true, true, true, true);
7213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			lookupPrec.colorThreshold	= tcu::computeFixedPointThreshold(IVec4(8, 8, 8, 8));
7223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			lookupPrec.coordBits		= tcu::IVec3(22, 22, 22);
7233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			lookupPrec.uvwBits			= tcu::IVec3(5, 5, 0);
7243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			lodPrec.lodBits				= 7;
7253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			lodPrec.derivateBits		= 16;
7263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			stencilToUnorm8(texData, redTex);
7283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			compareOk = verifyTextureResult(m_testCtx, result, redTex, &texCoord[0], sampleParams, lookupPrec, lodPrec, tcu::PixelFormat(8, 8, 8, 8));
7303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_testCtx.setTestResult(compareOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
7323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									compareOk ? "Pass"				: "Image comparison failed");
7333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
7343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return STOP;
7363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
7373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7383c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
7393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint32 m_format;
7403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
7413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7423c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass RenderTex2DCase : public TestCase
7433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7443c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
7453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	RenderTex2DCase (Context& context, const char* name, deUint32 format)
7463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TestCase	(context, name, glu::getPixelFormatName(format))
7473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format	(format)
7483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
7493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
7503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IterateResult iterate (void)
7523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
7533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const glu::RenderContext&	renderCtx		= m_context.getRenderContext();
7543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const glw::Functions&		gl				= renderCtx.getFunctions();
7553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					width			= 117;
7563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					height			= 193;
7573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Framebuffer			fbo				(renderCtx);
7583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Renderbuffer			colorBuf		(renderCtx);
7593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Texture				depthStencilTex	(renderCtx);
7603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TextureLevel				result			(TextureFormat(TextureFormat::RGBA, TextureFormat::UNSIGNED_INT32), width, height);
7613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TextureLevel				reference		(TextureFormat(TextureFormat::S, TextureFormat::UNSIGNED_INT8), width, height);
7623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkDepthStencilFormatSupport(m_context.getContextInfo(), m_format);
7643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindRenderbuffer(GL_RENDERBUFFER, *colorBuf);
7663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.renderbufferStorage(GL_RENDERBUFFER, GL_R32UI, width, height);
7673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindTexture(GL_TEXTURE_2D, *depthStencilTex);
7693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.texStorage2D(GL_TEXTURE_2D, 1, m_format, width, height);
7703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindFramebuffer(GL_FRAMEBUFFER, *fbo);
7723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, *colorBuf);
7733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, *depthStencilTex, 0);
7743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkFramebufferStatus(gl);
7753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		drawTestPattern(renderCtx, width, height);
7773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, 0);
7793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkFramebufferStatus(gl);
7803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		blitStencilToColor2D(renderCtx, *depthStencilTex, width, height);
7823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::readPixels(renderCtx, 0, 0, result.getAccess());
7833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		renderTestPatternReference(reference);
7853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
7873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const bool compareOk = compareStencilToRed(m_testCtx.getLog(), reference, result);
7883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_testCtx.setTestResult(compareOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
7893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									compareOk ? "Pass"				: "Image comparison failed");
7903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
7913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return STOP;
7933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
7943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7953c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
7963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint32 m_format;
7973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
7983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7993c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ClearTex2DCase : public TestCase
8003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8013c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
8023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ClearTex2DCase (Context& context, const char* name, deUint32 format)
8033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TestCase	(context, name, glu::getPixelFormatName(format))
8043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format	(format)
8053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
8063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
8073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IterateResult iterate (void)
8093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
8103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const glu::RenderContext&	renderCtx		= m_context.getRenderContext();
8113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const glw::Functions&		gl				= renderCtx.getFunctions();
8123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					width			= 125;
8133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					height			= 117;
8143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					cellSize		= 8;
8153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Framebuffer			fbo				(renderCtx);
8163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Renderbuffer			colorBuf		(renderCtx);
8173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Texture				depthStencilTex	(renderCtx);
8183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TextureLevel				result			(TextureFormat(TextureFormat::RGBA, TextureFormat::UNSIGNED_INT32), width, height);
8193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TextureLevel				reference		(TextureFormat(TextureFormat::S, TextureFormat::UNSIGNED_INT8), width, height);
8203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkDepthStencilFormatSupport(m_context.getContextInfo(), m_format);
8223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindRenderbuffer(GL_RENDERBUFFER, *colorBuf);
8243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.renderbufferStorage(GL_RENDERBUFFER, GL_R32UI, width, height);
8253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindTexture(GL_TEXTURE_2D, *depthStencilTex);
8273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.texStorage2D(GL_TEXTURE_2D, 1, m_format, width, height);
8283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindFramebuffer(GL_FRAMEBUFFER, *fbo);
8303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, *colorBuf);
8313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, *depthStencilTex, 0);
8323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkFramebufferStatus(gl);
8333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.enable(GL_SCISSOR_TEST);
8353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int y = 0; y < height; y += cellSize)
8373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
8383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int x = 0; x < width; x += cellSize)
8393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
8403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const int		clearW		= de::min(cellSize, width-x);
8413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const int		clearH		= de::min(cellSize, height-y);
8423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const int		stencil		= int((deInt32Hash(x) ^ deInt32Hash(y)) & 0xff);
8433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				gl.clearStencil(stencil);
8453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				gl.scissor(x, y, clearW, clearH);
8463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				gl.clear(GL_STENCIL_BUFFER_BIT);
8473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				tcu::clear(tcu::getSubregion(reference.getAccess(), x, y, clearW, clearH), IVec4(0, 0, 0, stencil));
8493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
8503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
8513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.disable(GL_SCISSOR_TEST);
8533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, 0);
8553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkFramebufferStatus(gl);
8563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		blitStencilToColor2D(renderCtx, *depthStencilTex, width, height);
8583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::readPixels(renderCtx, 0, 0, result.getAccess());
8593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
8613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const bool compareOk = compareStencilToRed(m_testCtx.getLog(), reference, result);
8623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_testCtx.setTestResult(compareOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
8633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									compareOk ? "Pass"				: "Image comparison failed");
8643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
8653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return STOP;
8673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
8683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8693c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
8703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint32 m_format;
8713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
8723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8733c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass CompareModeCase : public TestCase
8743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8753c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
8763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	CompareModeCase (Context& context, const char* name, deUint32 format)
8773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TestCase	(context, name, glu::getPixelFormatName(format))
8783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format	(format)
8793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
8803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
8813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IterateResult iterate (void)
8833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
8843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const glu::RenderContext&	renderCtx			= m_context.getRenderContext();
8853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const glw::Functions&		gl					= renderCtx.getFunctions();
8863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					width				= 64;
8873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					height				= 64;
8883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Framebuffer			fbo					(renderCtx);
8893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Renderbuffer			colorBuf			(renderCtx);
8903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Texture				depthStencilTex		(renderCtx);
8913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TextureLevel				uploadLevel			(glu::mapGLInternalFormat(m_format), width, height);
8923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TextureLevel				readLevel			(TextureFormat(TextureFormat::RGBA, TextureFormat::UNSIGNED_INT32), width, height);
8933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TextureLevel				stencilOnlyLevel	(TextureFormat(TextureFormat::S, TextureFormat::UNSIGNED_INT8), width, height);
8943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkDepthStencilFormatSupport(m_context.getContextInfo(), m_format);
8963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_testCtx.getLog() << TestLog::Message << "NOTE: Texture compare mode has no effect when reading stencil values." << TestLog::EndMessage;
8983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		renderTestPatternReference(uploadLevel);
9003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		renderTestPatternReference(stencilOnlyLevel);
9013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindTexture(GL_TEXTURE_2D, *depthStencilTex);
9033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.texStorage2D(GL_TEXTURE_2D, 1, m_format, width, height);
9043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
9053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LESS);
9063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::texSubImage2D(renderCtx, GL_TEXTURE_2D, 0, 0, 0, uploadLevel);
9073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.getError(), "Uploading texture data failed");
9083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindRenderbuffer(GL_RENDERBUFFER, *colorBuf);
9103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.renderbufferStorage(GL_RENDERBUFFER, GL_R32UI, width, height);
9113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindFramebuffer(GL_FRAMEBUFFER, *fbo);
9133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, *colorBuf);
9143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkFramebufferStatus(gl);
9153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		blitStencilToColor2D(renderCtx, *depthStencilTex, width, height);
9173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::readPixels(renderCtx, 0, 0, readLevel);
9183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
9203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const bool compareOk = compareStencilToRed(m_testCtx.getLog(), stencilOnlyLevel, readLevel);
9213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_testCtx.setTestResult(compareOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
9223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									compareOk ? "Pass"				: "Image comparison failed");
9233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
9243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return STOP;
9263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
9273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9283c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
9293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint32 m_format;
9303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
9313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9323c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BaseLevelCase : public TestCase
9333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
9343c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
9353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BaseLevelCase (Context& context, const char* name, deUint32 format)
9363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TestCase	(context, name, glu::getPixelFormatName(format))
9373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format	(format)
9383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
9393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
9403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IterateResult iterate (void)
9423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
9433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const glu::RenderContext&	renderCtx			= m_context.getRenderContext();
9443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const glw::Functions&		gl					= renderCtx.getFunctions();
9453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					width				= 128;
9463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					height				= 128;
9473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					levelNdx			= 2;
9483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					levelWidth			= width>>levelNdx;
9493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					levelHeight			= height>>levelNdx;
9503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Framebuffer			fbo					(renderCtx);
9513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Renderbuffer			colorBuf			(renderCtx);
9523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Texture				depthStencilTex		(renderCtx);
9533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TextureLevel				uploadLevel			(glu::mapGLInternalFormat(m_format), levelWidth, levelHeight);
9543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TextureLevel				readLevel			(TextureFormat(TextureFormat::RGBA, TextureFormat::UNSIGNED_INT32), levelWidth, levelHeight);
9553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TextureLevel				stencilOnlyLevel	(TextureFormat(TextureFormat::S, TextureFormat::UNSIGNED_INT8), levelWidth, levelHeight);
9563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkDepthStencilFormatSupport(m_context.getContextInfo(), m_format);
9583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_testCtx.getLog() << TestLog::Message << "GL_TEXTURE_BASE_LEVEL = " << levelNdx << TestLog::EndMessage;
9603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		renderTestPatternReference(uploadLevel);
9623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		renderTestPatternReference(stencilOnlyLevel);
9633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindTexture(GL_TEXTURE_2D, *depthStencilTex);
9653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.texStorage2D(GL_TEXTURE_2D, deLog2Floor32(de::max(width, height))+1, m_format, width, height);
9663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, levelNdx);
9673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::texSubImage2D(renderCtx, GL_TEXTURE_2D, levelNdx, 0, 0, uploadLevel);
9683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.getError(), "Uploading texture data failed");
9693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindRenderbuffer(GL_RENDERBUFFER, *colorBuf);
9713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.renderbufferStorage(GL_RENDERBUFFER, GL_R32UI, levelWidth, levelHeight);
9723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindFramebuffer(GL_FRAMEBUFFER, *fbo);
9743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, *colorBuf);
9753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkFramebufferStatus(gl);
9763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		blitStencilToColor2D(renderCtx, *depthStencilTex, levelWidth, levelHeight);
9783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::readPixels(renderCtx, 0, 0, readLevel);
9793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
9813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const bool compareOk = compareStencilToRed(m_testCtx.getLog(), stencilOnlyLevel, readLevel);
9823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_testCtx.setTestResult(compareOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
9833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									compareOk ? "Pass"				: "Image comparison failed");
9843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
9853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return STOP;
9873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
9883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9893c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
9903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint32 m_format;
9913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
9923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // anonymous
9943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9953c827367444ee418f129b2c238299f49d3264554Jarkko PoyryStencilTexturingTests::StencilTexturingTests (Context& context)
9963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TestCaseGroup(context, "stencil_texturing", "Stencil texturing tests")
9973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
9983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
9993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10003c827367444ee418f129b2c238299f49d3264554Jarkko PoyryStencilTexturingTests::~StencilTexturingTests (void)
10013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
10023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
10033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10043c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid StencilTexturingTests::init (void)
10053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
10063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// .format
10073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
10083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* const formatGroup = new tcu::TestCaseGroup(m_testCtx, "format", "Formats");
10093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(formatGroup);
10103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		formatGroup->addChild(new UploadTex2DCase		(m_context, "depth32f_stencil8_2d",			GL_DEPTH32F_STENCIL8));
10123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		formatGroup->addChild(new UploadTex2DArrayCase	(m_context, "depth32f_stencil8_2d_array",	GL_DEPTH32F_STENCIL8));
10133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		formatGroup->addChild(new UploadTexCubeCase		(m_context, "depth32f_stencil8_cube",		GL_DEPTH32F_STENCIL8));
10143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		formatGroup->addChild(new UploadTex2DCase		(m_context, "depth24_stencil8_2d",			GL_DEPTH24_STENCIL8));
10153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		formatGroup->addChild(new UploadTex2DArrayCase	(m_context, "depth24_stencil8_2d_array",	GL_DEPTH24_STENCIL8));
10163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		formatGroup->addChild(new UploadTexCubeCase		(m_context, "depth24_stencil8_cube",		GL_DEPTH24_STENCIL8));
10173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// OES_texture_stencil8
10193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		formatGroup->addChild(new UploadTex2DCase		(m_context, "stencil_index8_2d",			GL_STENCIL_INDEX8));
10203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		formatGroup->addChild(new UploadTex2DArrayCase	(m_context, "stencil_index8_2d_array",		GL_STENCIL_INDEX8));
10213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		formatGroup->addChild(new UploadTexCubeCase		(m_context, "stencil_index8_cube",			GL_STENCIL_INDEX8));
10223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
10233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// .render
10253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
10263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* const readRenderGroup = new tcu::TestCaseGroup(m_testCtx, "render", "Read rendered stencil values");
10273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(readRenderGroup);
10283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		readRenderGroup->addChild(new ClearTex2DCase	(m_context, "depth32f_stencil8_clear",	GL_DEPTH32F_STENCIL8));
10303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		readRenderGroup->addChild(new RenderTex2DCase	(m_context, "depth32f_stencil8_draw",	GL_DEPTH32F_STENCIL8));
10313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		readRenderGroup->addChild(new ClearTex2DCase	(m_context, "depth24_stencil8_clear",	GL_DEPTH24_STENCIL8));
10323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		readRenderGroup->addChild(new RenderTex2DCase	(m_context, "depth24_stencil8_draw",	GL_DEPTH24_STENCIL8));
10333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
10343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// .misc
10363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
10373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* const miscGroup = new tcu::TestCaseGroup(m_testCtx, "misc", "Misc cases");
10383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(miscGroup);
10393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		miscGroup->addChild(new CompareModeCase	(m_context, "compare_mode_effect",	GL_DEPTH24_STENCIL8));
10413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		miscGroup->addChild(new BaseLevelCase	(m_context, "base_level",			GL_DEPTH24_STENCIL8));
10423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
10433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
10443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Functional
10463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles31
10473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp
1048