Home | History | Annotate | Download | only in gles31
      1 /*-------------------------------------------------------------------------
      2  * OpenGL Conformance Test Suite
      3  * -----------------------------
      4  *
      5  * Copyright (c) 2014-2016 The Khronos Group Inc.
      6  *
      7  * Licensed under the Apache License, Version 2.0 (the "License");
      8  * you may not use this file except in compliance with the License.
      9  * You may obtain a copy of the License at
     10  *
     11  *      http://www.apache.org/licenses/LICENSE-2.0
     12  *
     13  * Unless required by applicable law or agreed to in writing, software
     14  * distributed under the License is distributed on an "AS IS" BASIS,
     15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     16  * See the License for the specific language governing permissions and
     17  * limitations under the License.
     18  *
     19  */ /*!
     20  * \file
     21  * \brief
     22  */ /*-------------------------------------------------------------------*/
     23 
     24 #include "es31cSampleShadingTests.hpp"
     25 #include "deRandom.hpp"
     26 #include "deStringUtil.hpp"
     27 #include "gluContextInfo.hpp"
     28 #include "gluDrawUtil.hpp"
     29 #include "gluPixelTransfer.hpp"
     30 #include "gluShaderProgram.hpp"
     31 #include "glw.h"
     32 #include "glwFunctions.hpp"
     33 #include "tcuCommandLine.hpp"
     34 #include "tcuStringTemplate.hpp"
     35 #include "tcuSurface.hpp"
     36 #include "tcuTestLog.hpp"
     37 
     38 namespace tcu
     39 {
     40 static bool operator<(tcu::Vec4 const& k1, tcu::Vec4 const& k2)
     41 {
     42 	if (k1.y() < k2.y())
     43 	{
     44 		return true;
     45 	}
     46 	else if (k1.y() == k2.y())
     47 	{
     48 		return k1.x() < k2.x();
     49 	}
     50 	else
     51 	{
     52 		return false;
     53 	}
     54 }
     55 }
     56 
     57 namespace glcts
     58 {
     59 
     60 using tcu::TestLog;
     61 using std::string;
     62 using std::vector;
     63 using glcts::Context;
     64 
     65 static std::string specializeVersion(std::string const& source, glu::GLSLVersion version, std::string const& sampler,
     66 									 std::string const& outType)
     67 {
     68 	DE_ASSERT(version == glu::GLSL_VERSION_310_ES || version >= glu::GLSL_VERSION_400);
     69 	std::map<std::string, std::string> args;
     70 	args["VERSION_DECL"] = glu::getGLSLVersionDeclaration(version);
     71 	args["SAMPLER"]		 = sampler;
     72 	args["OUT_TYPE"]	 = outType;
     73 	return tcu::StringTemplate(source.c_str()).specialize(args);
     74 }
     75 
     76 class SampleShadingApiCaseGroup : public TestCaseGroup
     77 {
     78 public:
     79 	SampleShadingApiCaseGroup(Context& context, glu::GLSLVersion glslVersion)
     80 		: TestCaseGroup(context, "api", "Basic API verification"), m_glslVersion(glslVersion)
     81 	{
     82 	}
     83 
     84 	void init(void)
     85 	{
     86 		addChild(new SampleShadingApiCase(m_context, m_glslVersion));
     87 	}
     88 
     89 private:
     90 	class SampleShadingApiCase : public deqp::TestCase
     91 	{
     92 	public:
     93 		SampleShadingApiCase(Context& context, glu::GLSLVersion glslVersion);
     94 		~SampleShadingApiCase();
     95 
     96 		IterateResult iterate();
     97 
     98 	protected:
     99 		glu::GLSLVersion			m_glslVersion;
    100 		glw::glMinSampleShadingFunc m_pGLMinSampleShading;
    101 	};
    102 
    103 	glu::GLSLVersion m_glslVersion;
    104 };
    105 
    106 SampleShadingApiCaseGroup::SampleShadingApiCase::SampleShadingApiCase(Context& context, glu::GLSLVersion glslVersion)
    107 	: TestCase(context, "verify", ""), m_glslVersion(glslVersion)
    108 {
    109 	DE_ASSERT(glslVersion == glu::GLSL_VERSION_310_ES || glslVersion >= glu::GLSL_VERSION_400);
    110 }
    111 
    112 SampleShadingApiCaseGroup::SampleShadingApiCase::~SampleShadingApiCase()
    113 {
    114 }
    115 
    116 SampleShadingApiCaseGroup::SampleShadingApiCase::IterateResult SampleShadingApiCaseGroup::SampleShadingApiCase::
    117 	iterate()
    118 {
    119 	const glw::Functions& gl   = m_context.getRenderContext().getFunctions();
    120 	bool				  isOk = true;
    121 
    122 	if (m_glslVersion == glu::GLSL_VERSION_310_ES &&
    123 		!m_context.getContextInfo().isExtensionSupported("GL_OES_sample_shading"))
    124 	{
    125 		m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "GL_OES_sample_shading");
    126 		return STOP;
    127 	}
    128 
    129 	m_pGLMinSampleShading = gl.minSampleShading;
    130 
    131 	struct Test
    132 	{
    133 		GLfloat input;
    134 		GLfloat result;
    135 	} tests[] = {
    136 		{ 0.0f, 0.0f }, { 0.5f, 0.5f }, { -1.0f, 0.0f }, { 2.0f, 1.0f },
    137 	};
    138 	for (int i = 0; i < DE_LENGTH_OF_ARRAY(tests); ++i)
    139 	{
    140 		m_pGLMinSampleShading(tests[i].input);
    141 		GLfloat result = -1.0f;
    142 		gl.getFloatv(GL_MIN_SAMPLE_SHADING_VALUE_OES, &result);
    143 		if (result != tests[i].result)
    144 		{
    145 			isOk = false;
    146 		}
    147 	}
    148 
    149 	gl.enable(GL_SAMPLE_SHADING_OES);
    150 	if (!gl.isEnabled(GL_SAMPLE_SHADING_OES))
    151 	{
    152 		isOk = false;
    153 	}
    154 	gl.disable(GL_SAMPLE_SHADING_OES);
    155 	if (gl.isEnabled(GL_SAMPLE_SHADING_OES))
    156 	{
    157 		isOk = false;
    158 	}
    159 
    160 	m_pGLMinSampleShading(0.0f);
    161 
    162 	m_testCtx.setTestResult(isOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL, isOk ? "Pass" : "Fail");
    163 	return STOP;
    164 }
    165 
    166 class SampleShadingRenderCase : public TestCase
    167 {
    168 public:
    169 	SampleShadingRenderCase(Context& context, const char* name, const char* description, glu::GLSLVersion glslVersion,
    170 							GLenum internalFormat, tcu::TextureFormat const& texFormat, const char* m_sampler,
    171 							const char* m_outType, GLfloat min, GLfloat max, const char* m_extension,
    172 							GLfloat sampleShading);
    173 	~SampleShadingRenderCase();
    174 
    175 	IterateResult iterate();
    176 
    177 protected:
    178 	glu::GLSLVersion			m_glslVersion;
    179 	glw::glMinSampleShadingFunc m_pGLMinSampleShading;
    180 	GLenum						m_internalFormat;
    181 	tcu::TextureFormat			m_texFormat;
    182 	std::string					m_sampler;
    183 	std::string					m_outType;
    184 	GLfloat						m_min;
    185 	GLfloat						m_max;
    186 	std::string					m_extension;
    187 	GLfloat						m_sampleShading;
    188 
    189 	enum
    190 	{
    191 		WIDTH		= 16,
    192 		HEIGHT		= 16,
    193 		MAX_SAMPLES = 4,
    194 	};
    195 
    196 	int countUniquePixels(tcu::ConstPixelBufferAccess const& pixels);
    197 	int countUniquePixels(const std::vector<tcu::Vec4>& pixels);
    198 };
    199 
    200 SampleShadingRenderCase::SampleShadingRenderCase(Context& context, const char* name, const char* description,
    201 												 glu::GLSLVersion glslVersion, GLenum internalFormat,
    202 												 tcu::TextureFormat const& texFormat, const char* sampler,
    203 												 const char* outType, GLfloat min, GLfloat max, const char* extension,
    204 												 GLfloat sampleShading)
    205 	: TestCase(context, name, description)
    206 	, m_glslVersion(glslVersion)
    207 	, m_internalFormat(internalFormat)
    208 	, m_texFormat(texFormat)
    209 	, m_sampler(sampler)
    210 	, m_outType(outType)
    211 	, m_min(min)
    212 	, m_max(max)
    213 	, m_extension(extension)
    214 	, m_sampleShading(sampleShading)
    215 {
    216 	DE_ASSERT(glslVersion == glu::GLSL_VERSION_310_ES || glslVersion >= glu::GLSL_VERSION_400);
    217 }
    218 
    219 SampleShadingRenderCase::~SampleShadingRenderCase()
    220 {
    221 }
    222 
    223 SampleShadingRenderCase::IterateResult SampleShadingRenderCase::iterate()
    224 {
    225 	TestLog&			  log  = m_testCtx.getLog();
    226 	const glw::Functions& gl   = m_context.getRenderContext().getFunctions();
    227 	bool				  isOk = true;
    228 
    229 	if (m_glslVersion == glu::GLSL_VERSION_310_ES &&
    230 		!m_context.getContextInfo().isExtensionSupported("GL_OES_sample_shading"))
    231 	{
    232 		m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "GL_OES_sample_shading");
    233 		return STOP;
    234 	}
    235 	if (!m_extension.empty() && !m_context.getContextInfo().isExtensionSupported(m_extension.c_str()))
    236 	{
    237 		m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, m_extension.c_str());
    238 		return STOP;
    239 	}
    240 
    241 	m_pGLMinSampleShading = gl.minSampleShading;
    242 
    243 	GLint maxSamples = 0;
    244 	if (((m_texFormat.type == tcu::TextureFormat::FLOAT) && (m_texFormat.order == tcu::TextureFormat::RGBA)) ||
    245 		((m_texFormat.type == tcu::TextureFormat::FLOAT) && (m_texFormat.order == tcu::TextureFormat::RG)) ||
    246 		((m_texFormat.type == tcu::TextureFormat::FLOAT) && (m_texFormat.order == tcu::TextureFormat::R)) ||
    247 		((m_texFormat.type == tcu::TextureFormat::HALF_FLOAT) && (m_texFormat.order == tcu::TextureFormat::RGBA)))
    248 	{
    249 		gl.getInternalformativ(GL_TEXTURE_2D_MULTISAMPLE, m_internalFormat, GL_SAMPLES, 1, &maxSamples);
    250 		if (maxSamples == 0)
    251 		{
    252 			m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Multisample is not supported on this format");
    253 			return STOP;
    254 		}
    255 	}
    256 	else if (m_texFormat.type == tcu::TextureFormat::SIGNED_INT8 ||
    257 			 m_texFormat.type == tcu::TextureFormat::UNSIGNED_INT8)
    258 	{
    259 		gl.getIntegerv(GL_MAX_INTEGER_SAMPLES, &maxSamples);
    260 	}
    261 	else
    262 	{
    263 		gl.getIntegerv(GL_MAX_SAMPLES, &maxSamples);
    264 	}
    265 	GLint samples = de::min<GLint>(maxSamples, MAX_SAMPLES);
    266 
    267 	GLuint tex;
    268 	gl.genTextures(1, &tex);
    269 	gl.bindTexture(GL_TEXTURE_2D_MULTISAMPLE, tex);
    270 	gl.texStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, samples, m_internalFormat, WIDTH, HEIGHT, GL_FALSE);
    271 
    272 	GLuint fboMs;
    273 	gl.genFramebuffers(1, &fboMs);
    274 	gl.bindFramebuffer(GL_FRAMEBUFFER, fboMs);
    275 	gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, tex, 0);
    276 	gl.viewport(0, 0, WIDTH, HEIGHT);
    277 
    278 	m_pGLMinSampleShading(m_sampleShading);
    279 	gl.enable(GL_SAMPLE_SHADING_OES);
    280 
    281 	static const deUint16 quadIndices[] = { 0, 1, 2, 2, 1, 3 };
    282 
    283 	{
    284 		static char const* vss = "${VERSION_DECL}\n"
    285 								 "in highp vec2 a_position;\n"
    286 								 "in highp vec4 a_color;\n"
    287 								 "out highp vec4 v_color;\n"
    288 								 "void main (void)\n"
    289 								 "{\n"
    290 								 "   gl_Position = vec4(a_position, 0.0, 1.0);\n"
    291 								 "   v_color = a_color;\n"
    292 								 "}\n";
    293 
    294 		static char const* fss = "${VERSION_DECL}\n"
    295 								 "in highp vec4 v_color;\n"
    296 								 "layout(location = 0) out highp ${OUT_TYPE} o_color;\n"
    297 								 "void main (void)\n"
    298 								 "{\n"
    299 								 "   o_color = ${OUT_TYPE}(v_color.x, v_color.y, 0.0, 0.0);\n"
    300 								 "}\n";
    301 
    302 		glu::ShaderProgram program(
    303 			m_context.getRenderContext(),
    304 			glu::makeVtxFragSources(specializeVersion(vss, m_glslVersion, m_sampler, m_outType).c_str(),
    305 									specializeVersion(fss, m_glslVersion, m_sampler, m_outType).c_str()));
    306 		log << program;
    307 		if (!program.isOk())
    308 		{
    309 			TCU_FAIL("Compile failed");
    310 		}
    311 
    312 		const float position[] = {
    313 			-1.0f, -1.0f, -1.0f, +1.0f, +1.0f, -1.0f, +1.0f, +1.0f,
    314 		};
    315 		const float color[] = {
    316 			m_min, m_min, 0.0f, 1.0f, m_min, m_max, 0.0f, 1.0f, m_max, m_min, 0.0f, 1.0f, m_max, m_max, 0.0f, 1.0f,
    317 		};
    318 
    319 		gl.useProgram(program.getProgram());
    320 
    321 		glu::VertexArrayBinding vertexArrays[] = {
    322 			glu::va::Float("a_position", 2, 4, 0, &position[0]), glu::va::Float("a_color", 4, 4, 0, &color[0]),
    323 		};
    324 		glu::draw(m_context.getRenderContext(), program.getProgram(), DE_LENGTH_OF_ARRAY(vertexArrays),
    325 				  &vertexArrays[0], glu::pr::TriangleStrip(DE_LENGTH_OF_ARRAY(quadIndices), &quadIndices[0]));
    326 
    327 		GLU_EXPECT_NO_ERROR(gl.getError(), "Draw quad");
    328 	}
    329 	m_pGLMinSampleShading(0.0f);
    330 	gl.disable(GL_SAMPLE_SHADING_OES);
    331 	gl.bindFramebuffer(GL_FRAMEBUFFER, m_context.getRenderContext().getDefaultFramebuffer());
    332 	gl.deleteFramebuffers(1, &fboMs);
    333 
    334 	GLsizei width = WIDTH * samples;
    335 
    336 	GLuint rbo;
    337 	gl.genRenderbuffers(1, &rbo);
    338 	gl.bindRenderbuffer(GL_RENDERBUFFER, rbo);
    339 	gl.renderbufferStorage(GL_RENDERBUFFER, m_internalFormat, width, HEIGHT);
    340 
    341 	GLuint fbo;
    342 	gl.genFramebuffers(1, &fbo);
    343 	gl.bindFramebuffer(GL_FRAMEBUFFER, fbo);
    344 	gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo);
    345 	gl.viewport(0, 0, width, HEIGHT);
    346 
    347 	{
    348 		static char const* vss = "${VERSION_DECL}\n"
    349 								 "in highp vec2 a_position;\n"
    350 								 "void main(void)\n"
    351 								 "{\n"
    352 								 "   gl_Position = vec4(a_position, 0.0, 1.0);\n"
    353 								 "}\n";
    354 
    355 		static char const* fss = "${VERSION_DECL}\n"
    356 								 "uniform highp ${SAMPLER} u_tex;\n"
    357 								 "uniform int u_samples;\n"
    358 								 "layout(location = 0) out highp ${OUT_TYPE} o_color;\n"
    359 								 "void main(void)\n"
    360 								 "{\n"
    361 								 "   ivec2 coord = ivec2(int(gl_FragCoord.x) / u_samples, gl_FragCoord.y);\n"
    362 								 "   int sampleId = int(gl_FragCoord.x) % u_samples;\n"
    363 								 "   o_color = texelFetch(u_tex, coord, sampleId);\n"
    364 								 "}\n";
    365 
    366 		glu::ShaderProgram program(
    367 			m_context.getRenderContext(),
    368 			glu::makeVtxFragSources(specializeVersion(vss, m_glslVersion, m_sampler, m_outType).c_str(),
    369 									specializeVersion(fss, m_glslVersion, m_sampler, m_outType).c_str()));
    370 		log << program;
    371 		if (!program.isOk())
    372 		{
    373 			TCU_FAIL("Compile failed");
    374 		}
    375 
    376 		float const position[] = {
    377 			-1.0f, -1.0f, -1.0f, +1.0f, +1.0f, -1.0f, +1.0f, +1.0f,
    378 		};
    379 
    380 		gl.useProgram(program.getProgram());
    381 		gl.uniform1i(gl.getUniformLocation(program.getProgram(), "u_samples"), samples);
    382 		gl.uniform1i(gl.getUniformLocation(program.getProgram(), "u_tex"), 0);
    383 
    384 		glu::VertexArrayBinding vertexArrays[] = {
    385 			glu::va::Float("a_position", 2, 4, 0, &position[0]),
    386 		};
    387 		glu::draw(m_context.getRenderContext(), program.getProgram(), DE_LENGTH_OF_ARRAY(vertexArrays),
    388 				  &vertexArrays[0], glu::pr::TriangleStrip(DE_LENGTH_OF_ARRAY(quadIndices), &quadIndices[0]));
    389 
    390 		GLU_EXPECT_NO_ERROR(gl.getError(), "Draw quad");
    391 	}
    392 
    393 	tcu::TextureLevel	  results(m_texFormat, width, HEIGHT);
    394 	tcu::PixelBufferAccess pixels = results.getAccess();
    395 	std::vector<tcu::Vec4> result(pixels.getHeight() * pixels.getWidth());
    396 	int					   uniquePixels;
    397 
    398 	if (pixels.getFormat().type == tcu::TextureFormat::SIGNED_INT8)
    399 	{
    400 		std::vector<GLint> data(pixels.getHeight() * pixels.getWidth() * 4);
    401 		gl.readPixels(0, 0, pixels.getWidth(), pixels.getHeight(), GL_RGBA_INTEGER, GL_INT, &data[0]);
    402 		for (unsigned int i = 0; i < data.size(); i += 4)
    403 		{
    404 			result[i / 4] =
    405 				tcu::Vec4((GLfloat)data[i], (GLfloat)data[i + 1], (GLfloat)data[i + 2], (GLfloat)data[i + 3]);
    406 		}
    407 		uniquePixels = countUniquePixels(result);
    408 	}
    409 	else if (pixels.getFormat().type == tcu::TextureFormat::UNSIGNED_INT8)
    410 	{
    411 		std::vector<GLuint> data(pixels.getHeight() * pixels.getWidth() * 4);
    412 		gl.readPixels(0, 0, pixels.getWidth(), pixels.getHeight(), GL_RGBA_INTEGER, GL_UNSIGNED_INT, &data[0]);
    413 		for (unsigned int i = 0; i < data.size(); i += 4)
    414 		{
    415 			result[i / 4] =
    416 				tcu::Vec4((GLfloat)data[i], (GLfloat)data[i + 1], (GLfloat)data[i + 2], (GLfloat)data[i + 3]);
    417 		}
    418 		uniquePixels = countUniquePixels(result);
    419 	}
    420 	else
    421 	{
    422 		glu::readPixels(m_context.getRenderContext(), 0, 0, pixels);
    423 		uniquePixels = countUniquePixels(pixels);
    424 	}
    425 	int expectedUnique = WIDTH * HEIGHT * (de::clamp(int(float(samples) * m_sampleShading), 1, samples));
    426 	if (uniquePixels < expectedUnique)
    427 	{
    428 		isOk = false;
    429 	}
    430 
    431 	gl.bindFramebuffer(GL_FRAMEBUFFER, m_context.getRenderContext().getDefaultFramebuffer());
    432 	gl.deleteFramebuffers(1, &fbo);
    433 
    434 	gl.bindRenderbuffer(GL_RENDERBUFFER, 0);
    435 	gl.deleteRenderbuffers(1, &rbo);
    436 
    437 	gl.bindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0);
    438 	gl.deleteTextures(1, &tex);
    439 
    440 	m_testCtx.setTestResult(isOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL, isOk ? "Pass" : "Fail");
    441 	return STOP;
    442 }
    443 
    444 int SampleShadingRenderCase::countUniquePixels(tcu::ConstPixelBufferAccess const& pixels)
    445 {
    446 	std::set<tcu::Vec4> uniquePixels;
    447 
    448 	for (int y = 0; y < pixels.getHeight(); ++y)
    449 	{
    450 		for (int x = 0; x < pixels.getWidth(); ++x)
    451 		{
    452 			uniquePixels.insert(pixels.getPixel(x, y));
    453 		}
    454 	}
    455 
    456 	return (int)uniquePixels.size();
    457 }
    458 
    459 int SampleShadingRenderCase::countUniquePixels(const std::vector<tcu::Vec4>& pixels)
    460 {
    461 	std::set<tcu::Vec4> uniquePixels;
    462 
    463 	for (unsigned int i = 0; i < pixels.size(); ++i)
    464 	{
    465 		uniquePixels.insert(pixels[i]);
    466 	}
    467 
    468 	return (int)uniquePixels.size();
    469 }
    470 
    471 class SampleShadingRenderFormatTests : public glcts::TestCaseGroup
    472 {
    473 public:
    474 	SampleShadingRenderFormatTests(glcts::Context& context, glu::GLSLVersion glslVersion, GLenum internalFormat,
    475 								   const char* format, tcu::TextureFormat const& texFormat, const char* sampler,
    476 								   const char* outType, GLfloat min, GLfloat max, const char* extension = "");
    477 	~SampleShadingRenderFormatTests(void);
    478 
    479 	void init(void);
    480 
    481 private:
    482 	SampleShadingRenderFormatTests(const SampleShadingTests& other);
    483 	SampleShadingRenderFormatTests& operator=(const SampleShadingTests& other);
    484 
    485 	glu::GLSLVersion   m_glslVersion;
    486 	GLenum			   m_internalFormat;
    487 	tcu::TextureFormat m_texFormat;
    488 	std::string		   m_sampler;
    489 	std::string		   m_outType;
    490 	GLfloat			   m_min;
    491 	GLfloat			   m_max;
    492 	std::string		   m_extension;
    493 };
    494 
    495 SampleShadingRenderFormatTests::SampleShadingRenderFormatTests(Context& context, glu::GLSLVersion glslVersion,
    496 															   GLenum internalFormat, const char* format,
    497 															   tcu::TextureFormat const& texFormat, const char* sampler,
    498 															   const char* outType, GLfloat min, GLfloat max,
    499 															   const char* extension)
    500 	: TestCaseGroup(context, format, "")
    501 	, m_glslVersion(glslVersion)
    502 	, m_internalFormat(internalFormat)
    503 	, m_texFormat(texFormat)
    504 	, m_sampler(sampler)
    505 	, m_outType(outType)
    506 	, m_min(min)
    507 	, m_max(max)
    508 	, m_extension(extension)
    509 {
    510 }
    511 
    512 SampleShadingRenderFormatTests::~SampleShadingRenderFormatTests(void)
    513 {
    514 }
    515 
    516 void SampleShadingRenderFormatTests::init(void)
    517 {
    518 	// sample_shading.render.full
    519 	addChild(new SampleShadingRenderCase(m_context, "full", "Sample shader functionality", m_glslVersion,
    520 										 m_internalFormat, m_texFormat, m_sampler.c_str(), m_outType.c_str(), m_min,
    521 										 m_max, m_extension.c_str(), 1.0));
    522 	// sample_shading.render.half
    523 	addChild(new SampleShadingRenderCase(m_context, "half", "Sample shader functionality", m_glslVersion,
    524 										 m_internalFormat, m_texFormat, m_sampler.c_str(), m_outType.c_str(), m_min,
    525 										 m_max, m_extension.c_str(), 0.5));
    526 	// sample_shading.render.none
    527 	addChild(new SampleShadingRenderCase(m_context, "none", "Sample shader functionality", m_glslVersion,
    528 										 m_internalFormat, m_texFormat, m_sampler.c_str(), m_outType.c_str(), m_min,
    529 										 m_max, m_extension.c_str(), 0.0));
    530 }
    531 
    532 class SampleShadingRenderTests : public glcts::TestCaseGroup
    533 {
    534 public:
    535 	SampleShadingRenderTests(glcts::Context& context, glu::GLSLVersion glslVersion);
    536 	~SampleShadingRenderTests(void);
    537 
    538 	void init(void);
    539 
    540 private:
    541 	SampleShadingRenderTests(const SampleShadingTests& other);
    542 	SampleShadingRenderTests& operator=(const SampleShadingTests& other);
    543 
    544 	glu::GLSLVersion m_glslVersion;
    545 };
    546 
    547 SampleShadingRenderTests::SampleShadingRenderTests(Context& context, glu::GLSLVersion glslVersion)
    548 	: TestCaseGroup(context, "render", "Sample Shading render tests"), m_glslVersion(glslVersion)
    549 {
    550 }
    551 
    552 SampleShadingRenderTests::~SampleShadingRenderTests(void)
    553 {
    554 }
    555 
    556 void SampleShadingRenderTests::init(void)
    557 {
    558 	// sample_shading.render.rgba8
    559 	addChild(new SampleShadingRenderFormatTests(
    560 		m_context, m_glslVersion, GL_RGBA8, "rgba8",
    561 		tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), "sampler2DMS", "vec4", 0.0, 1.0));
    562 	// sample_shading.render.rgba8i
    563 	addChild(new SampleShadingRenderFormatTests(
    564 		m_context, m_glslVersion, GL_RGBA8I, "rgba8i",
    565 		tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::SIGNED_INT8), "isampler2DMS", "ivec4", -128.0,
    566 		127.0));
    567 	// sample_shading.render.rgba8ui
    568 	addChild(new SampleShadingRenderFormatTests(
    569 		m_context, m_glslVersion, GL_RGBA8UI, "rgba8ui",
    570 		tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNSIGNED_INT8), "usampler2DMS", "uvec4", 0.0,
    571 		255.0));
    572 	// sample_shading.render.rgba32f
    573 	const char* extension =
    574 		(glu::isContextTypeES(m_context.getRenderContext().getType())) ? "GL_EXT_color_buffer_float" : "";
    575 	addChild(new SampleShadingRenderFormatTests(m_context, m_glslVersion, GL_RGBA32F, "rgba32f",
    576 												tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::FLOAT),
    577 												"sampler2DMS", "vec4", 0.0, 1.0, extension));
    578 }
    579 
    580 SampleShadingTests::SampleShadingTests(Context& context, glu::GLSLVersion glslVersion)
    581 	: TestCaseGroup(context, "sample_shading", "Sample Shading tests"), m_glslVersion(glslVersion)
    582 {
    583 }
    584 
    585 SampleShadingTests::~SampleShadingTests(void)
    586 {
    587 }
    588 
    589 void SampleShadingTests::init(void)
    590 {
    591 	// sample_shading.api
    592 	addChild(new SampleShadingApiCaseGroup(m_context, m_glslVersion));
    593 	// sample_shading.render
    594 	addChild(new SampleShadingRenderTests(m_context, m_glslVersion));
    595 }
    596 
    597 } // glcts
    598