• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 {
operator <(tcu::Vec4 const & k1,tcu::Vec4 const & k2)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 
specializeVersion(std::string const & source,glu::GLSLVersion version,std::string const & sampler,std::string const & outType)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:
SampleShadingApiCaseGroup(Context & context,glu::GLSLVersion glslVersion)79 	SampleShadingApiCaseGroup(Context& context, glu::GLSLVersion glslVersion)
80 		: TestCaseGroup(context, "api", "Basic API verification"), m_glslVersion(glslVersion)
81 	{
82 	}
83 
init(void)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 
SampleShadingApiCase(Context & context,glu::GLSLVersion glslVersion)106 SampleShadingApiCaseGroup::SampleShadingApiCase::SampleShadingApiCase(Context& context, glu::GLSLVersion glslVersion)
107 	: TestCase(context, "verify", ""), m_glslVersion(glslVersion), m_pGLMinSampleShading(0)
108 {
109 	DE_ASSERT(glslVersion == glu::GLSL_VERSION_310_ES || glslVersion >= glu::GLSL_VERSION_400);
110 }
111 
~SampleShadingApiCase()112 SampleShadingApiCaseGroup::SampleShadingApiCase::~SampleShadingApiCase()
113 {
114 }
115 
116 SampleShadingApiCaseGroup::SampleShadingApiCase::IterateResult SampleShadingApiCaseGroup::SampleShadingApiCase::
iterate()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 
SampleShadingRenderCase(Context & context,const char * name,const char * description,glu::GLSLVersion glslVersion,GLenum internalFormat,tcu::TextureFormat const & texFormat,const char * sampler,const char * outType,GLfloat min,GLfloat max,const char * extension,GLfloat sampleShading)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_pGLMinSampleShading(0)
208 	, m_internalFormat(internalFormat)
209 	, m_texFormat(texFormat)
210 	, m_sampler(sampler)
211 	, m_outType(outType)
212 	, m_min(min)
213 	, m_max(max)
214 	, m_extension(extension)
215 	, m_sampleShading(sampleShading)
216 {
217 	DE_ASSERT(glslVersion == glu::GLSL_VERSION_310_ES || glslVersion >= glu::GLSL_VERSION_400);
218 }
219 
~SampleShadingRenderCase()220 SampleShadingRenderCase::~SampleShadingRenderCase()
221 {
222 }
223 
iterate()224 SampleShadingRenderCase::IterateResult SampleShadingRenderCase::iterate()
225 {
226 	TestLog&			  log  = m_testCtx.getLog();
227 	const glw::Functions& gl   = m_context.getRenderContext().getFunctions();
228 	bool				  isOk = true;
229 
230 	if (m_glslVersion == glu::GLSL_VERSION_310_ES &&
231 		!m_context.getContextInfo().isExtensionSupported("GL_OES_sample_shading"))
232 	{
233 		m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "GL_OES_sample_shading");
234 		return STOP;
235 	}
236 	if (!m_extension.empty() && !m_context.getContextInfo().isExtensionSupported(m_extension.c_str()))
237 	{
238 		m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, m_extension.c_str());
239 		return STOP;
240 	}
241 
242 	m_pGLMinSampleShading = gl.minSampleShading;
243 
244 	GLint maxSamples = 0;
245 	if (((m_texFormat.type == tcu::TextureFormat::FLOAT) && (m_texFormat.order == tcu::TextureFormat::RGBA)) ||
246 		((m_texFormat.type == tcu::TextureFormat::FLOAT) && (m_texFormat.order == tcu::TextureFormat::RG)) ||
247 		((m_texFormat.type == tcu::TextureFormat::FLOAT) && (m_texFormat.order == tcu::TextureFormat::R)) ||
248 		((m_texFormat.type == tcu::TextureFormat::HALF_FLOAT) && (m_texFormat.order == tcu::TextureFormat::RGBA)))
249 	{
250 		gl.getInternalformativ(GL_TEXTURE_2D_MULTISAMPLE, m_internalFormat, GL_SAMPLES, 1, &maxSamples);
251 		if (maxSamples == 0)
252 		{
253 			m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Multisample is not supported on this format");
254 			return STOP;
255 		}
256 	}
257 	else if (m_texFormat.type == tcu::TextureFormat::SIGNED_INT8 ||
258 			 m_texFormat.type == tcu::TextureFormat::UNSIGNED_INT8)
259 	{
260 		gl.getIntegerv(GL_MAX_INTEGER_SAMPLES, &maxSamples);
261 	}
262 	else
263 	{
264 		gl.getIntegerv(GL_MAX_SAMPLES, &maxSamples);
265 	}
266 	GLint samples = de::min<GLint>(maxSamples, MAX_SAMPLES);
267 
268 	GLuint tex;
269 	gl.genTextures(1, &tex);
270 	gl.bindTexture(GL_TEXTURE_2D_MULTISAMPLE, tex);
271 	gl.texStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, samples, m_internalFormat, WIDTH, HEIGHT, GL_FALSE);
272 
273 	GLuint fboMs;
274 	gl.genFramebuffers(1, &fboMs);
275 	gl.bindFramebuffer(GL_FRAMEBUFFER, fboMs);
276 	gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, tex, 0);
277 	gl.viewport(0, 0, WIDTH, HEIGHT);
278 
279 	m_pGLMinSampleShading(m_sampleShading);
280 	gl.enable(GL_SAMPLE_SHADING_OES);
281 
282 	static const deUint16 quadIndices[] = { 0, 1, 2, 2, 1, 3 };
283 
284 	{
285 		static char const* vss = "${VERSION_DECL}\n"
286 								 "in highp vec2 a_position;\n"
287 								 "in highp vec4 a_color;\n"
288 								 "out highp vec4 v_color;\n"
289 								 "void main (void)\n"
290 								 "{\n"
291 								 "   gl_Position = vec4(a_position, 0.0, 1.0);\n"
292 								 "   v_color = a_color;\n"
293 								 "}\n";
294 
295 		static char const* fss = "${VERSION_DECL}\n"
296 								 "in highp vec4 v_color;\n"
297 								 "layout(location = 0) out highp ${OUT_TYPE} o_color;\n"
298 								 "void main (void)\n"
299 								 "{\n"
300 								 "   o_color = ${OUT_TYPE}(v_color.x, v_color.y, 0.0, 0.0);\n"
301 								 "}\n";
302 
303 		glu::ShaderProgram program(
304 			m_context.getRenderContext(),
305 			glu::makeVtxFragSources(specializeVersion(vss, m_glslVersion, m_sampler, m_outType).c_str(),
306 									specializeVersion(fss, m_glslVersion, m_sampler, m_outType).c_str()));
307 		log << program;
308 		if (!program.isOk())
309 		{
310 			TCU_FAIL("Compile failed");
311 		}
312 
313 		const float position[] = {
314 			-1.0f, -1.0f, -1.0f, +1.0f, +1.0f, -1.0f, +1.0f, +1.0f,
315 		};
316 		const float color[] = {
317 			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,
318 		};
319 
320 		gl.useProgram(program.getProgram());
321 
322 		glu::VertexArrayBinding vertexArrays[] = {
323 			glu::va::Float("a_position", 2, 4, 0, &position[0]), glu::va::Float("a_color", 4, 4, 0, &color[0]),
324 		};
325 		glu::draw(m_context.getRenderContext(), program.getProgram(), DE_LENGTH_OF_ARRAY(vertexArrays),
326 				  &vertexArrays[0], glu::pr::TriangleStrip(DE_LENGTH_OF_ARRAY(quadIndices), &quadIndices[0]));
327 
328 		GLU_EXPECT_NO_ERROR(gl.getError(), "Draw quad");
329 	}
330 	m_pGLMinSampleShading(0.0f);
331 	gl.disable(GL_SAMPLE_SHADING_OES);
332 	gl.bindFramebuffer(GL_FRAMEBUFFER, m_context.getRenderContext().getDefaultFramebuffer());
333 	gl.deleteFramebuffers(1, &fboMs);
334 
335 	GLsizei width = WIDTH * samples;
336 
337 	GLuint rbo;
338 	gl.genRenderbuffers(1, &rbo);
339 	gl.bindRenderbuffer(GL_RENDERBUFFER, rbo);
340 	gl.renderbufferStorage(GL_RENDERBUFFER, m_internalFormat, width, HEIGHT);
341 
342 	GLuint fbo;
343 	gl.genFramebuffers(1, &fbo);
344 	gl.bindFramebuffer(GL_FRAMEBUFFER, fbo);
345 	gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo);
346 	gl.viewport(0, 0, width, HEIGHT);
347 
348 	{
349 		static char const* vss = "${VERSION_DECL}\n"
350 								 "in highp vec2 a_position;\n"
351 								 "void main(void)\n"
352 								 "{\n"
353 								 "   gl_Position = vec4(a_position, 0.0, 1.0);\n"
354 								 "}\n";
355 
356 		static char const* fss = "${VERSION_DECL}\n"
357 								 "uniform highp ${SAMPLER} u_tex;\n"
358 								 "uniform int u_samples;\n"
359 								 "layout(location = 0) out highp ${OUT_TYPE} o_color;\n"
360 								 "void main(void)\n"
361 								 "{\n"
362 								 "   ivec2 coord = ivec2(int(gl_FragCoord.x) / u_samples, gl_FragCoord.y);\n"
363 								 "   int sampleId = int(gl_FragCoord.x) % u_samples;\n"
364 								 "   o_color = texelFetch(u_tex, coord, sampleId);\n"
365 								 "}\n";
366 
367 		glu::ShaderProgram program(
368 			m_context.getRenderContext(),
369 			glu::makeVtxFragSources(specializeVersion(vss, m_glslVersion, m_sampler, m_outType).c_str(),
370 									specializeVersion(fss, m_glslVersion, m_sampler, m_outType).c_str()));
371 		log << program;
372 		if (!program.isOk())
373 		{
374 			TCU_FAIL("Compile failed");
375 		}
376 
377 		float const position[] = {
378 			-1.0f, -1.0f, -1.0f, +1.0f, +1.0f, -1.0f, +1.0f, +1.0f,
379 		};
380 
381 		gl.useProgram(program.getProgram());
382 		gl.uniform1i(gl.getUniformLocation(program.getProgram(), "u_samples"), samples);
383 		gl.uniform1i(gl.getUniformLocation(program.getProgram(), "u_tex"), 0);
384 
385 		glu::VertexArrayBinding vertexArrays[] = {
386 			glu::va::Float("a_position", 2, 4, 0, &position[0]),
387 		};
388 		glu::draw(m_context.getRenderContext(), program.getProgram(), DE_LENGTH_OF_ARRAY(vertexArrays),
389 				  &vertexArrays[0], glu::pr::TriangleStrip(DE_LENGTH_OF_ARRAY(quadIndices), &quadIndices[0]));
390 
391 		GLU_EXPECT_NO_ERROR(gl.getError(), "Draw quad");
392 	}
393 
394 	tcu::TextureLevel	  results(m_texFormat, width, HEIGHT);
395 	tcu::PixelBufferAccess pixels = results.getAccess();
396 	std::vector<tcu::Vec4> result(pixels.getHeight() * pixels.getWidth());
397 	int					   uniquePixels;
398 
399 	if (pixels.getFormat().type == tcu::TextureFormat::SIGNED_INT8)
400 	{
401 		std::vector<GLint> data(pixels.getHeight() * pixels.getWidth() * 4);
402 		gl.readPixels(0, 0, pixels.getWidth(), pixels.getHeight(), GL_RGBA_INTEGER, GL_INT, &data[0]);
403 		for (unsigned int i = 0; i < data.size(); i += 4)
404 		{
405 			result[i / 4] =
406 				tcu::Vec4((GLfloat)data[i], (GLfloat)data[i + 1], (GLfloat)data[i + 2], (GLfloat)data[i + 3]);
407 		}
408 		uniquePixels = countUniquePixels(result);
409 	}
410 	else if (pixels.getFormat().type == tcu::TextureFormat::UNSIGNED_INT8)
411 	{
412 		std::vector<GLuint> data(pixels.getHeight() * pixels.getWidth() * 4);
413 		gl.readPixels(0, 0, pixels.getWidth(), pixels.getHeight(), GL_RGBA_INTEGER, GL_UNSIGNED_INT, &data[0]);
414 		for (unsigned int i = 0; i < data.size(); i += 4)
415 		{
416 			result[i / 4] =
417 				tcu::Vec4((GLfloat)data[i], (GLfloat)data[i + 1], (GLfloat)data[i + 2], (GLfloat)data[i + 3]);
418 		}
419 		uniquePixels = countUniquePixels(result);
420 	}
421 	else
422 	{
423 		glu::readPixels(m_context.getRenderContext(), 0, 0, pixels);
424 		uniquePixels = countUniquePixels(pixels);
425 	}
426 	int expectedUnique = WIDTH * HEIGHT * (de::clamp(int(float(samples) * m_sampleShading), 1, samples));
427 	if (uniquePixels < expectedUnique)
428 	{
429 		isOk = false;
430 	}
431 
432 	gl.bindFramebuffer(GL_FRAMEBUFFER, m_context.getRenderContext().getDefaultFramebuffer());
433 	gl.deleteFramebuffers(1, &fbo);
434 
435 	gl.bindRenderbuffer(GL_RENDERBUFFER, 0);
436 	gl.deleteRenderbuffers(1, &rbo);
437 
438 	gl.bindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0);
439 	gl.deleteTextures(1, &tex);
440 
441 	m_testCtx.setTestResult(isOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL, isOk ? "Pass" : "Fail");
442 	return STOP;
443 }
444 
countUniquePixels(tcu::ConstPixelBufferAccess const & pixels)445 int SampleShadingRenderCase::countUniquePixels(tcu::ConstPixelBufferAccess const& pixels)
446 {
447 	std::set<tcu::Vec4> uniquePixels;
448 
449 	for (int y = 0; y < pixels.getHeight(); ++y)
450 	{
451 		for (int x = 0; x < pixels.getWidth(); ++x)
452 		{
453 			uniquePixels.insert(pixels.getPixel(x, y));
454 		}
455 	}
456 
457 	return (int)uniquePixels.size();
458 }
459 
countUniquePixels(const std::vector<tcu::Vec4> & pixels)460 int SampleShadingRenderCase::countUniquePixels(const std::vector<tcu::Vec4>& pixels)
461 {
462 	std::set<tcu::Vec4> uniquePixels;
463 
464 	for (unsigned int i = 0; i < pixels.size(); ++i)
465 	{
466 		uniquePixels.insert(pixels[i]);
467 	}
468 
469 	return (int)uniquePixels.size();
470 }
471 
472 class SampleShadingRenderFormatTests : public glcts::TestCaseGroup
473 {
474 public:
475 	SampleShadingRenderFormatTests(glcts::Context& context, glu::GLSLVersion glslVersion, GLenum internalFormat,
476 								   const char* format, tcu::TextureFormat const& texFormat, const char* sampler,
477 								   const char* outType, GLfloat min, GLfloat max, const char* extension = "");
478 	~SampleShadingRenderFormatTests(void);
479 
480 	void init(void);
481 
482 private:
483 	SampleShadingRenderFormatTests(const SampleShadingTests& other);
484 	SampleShadingRenderFormatTests& operator=(const SampleShadingTests& other);
485 
486 	glu::GLSLVersion   m_glslVersion;
487 	GLenum			   m_internalFormat;
488 	tcu::TextureFormat m_texFormat;
489 	std::string		   m_sampler;
490 	std::string		   m_outType;
491 	GLfloat			   m_min;
492 	GLfloat			   m_max;
493 	std::string		   m_extension;
494 };
495 
SampleShadingRenderFormatTests(Context & context,glu::GLSLVersion glslVersion,GLenum internalFormat,const char * format,tcu::TextureFormat const & texFormat,const char * sampler,const char * outType,GLfloat min,GLfloat max,const char * extension)496 SampleShadingRenderFormatTests::SampleShadingRenderFormatTests(Context& context, glu::GLSLVersion glslVersion,
497 															   GLenum internalFormat, const char* format,
498 															   tcu::TextureFormat const& texFormat, const char* sampler,
499 															   const char* outType, GLfloat min, GLfloat max,
500 															   const char* extension)
501 	: TestCaseGroup(context, format, "")
502 	, m_glslVersion(glslVersion)
503 	, m_internalFormat(internalFormat)
504 	, m_texFormat(texFormat)
505 	, m_sampler(sampler)
506 	, m_outType(outType)
507 	, m_min(min)
508 	, m_max(max)
509 	, m_extension(extension)
510 {
511 }
512 
~SampleShadingRenderFormatTests(void)513 SampleShadingRenderFormatTests::~SampleShadingRenderFormatTests(void)
514 {
515 }
516 
init(void)517 void SampleShadingRenderFormatTests::init(void)
518 {
519 	// sample_shading.render.full
520 	addChild(new SampleShadingRenderCase(m_context, "full", "Sample shader functionality", m_glslVersion,
521 										 m_internalFormat, m_texFormat, m_sampler.c_str(), m_outType.c_str(), m_min,
522 										 m_max, m_extension.c_str(), 1.0));
523 	// sample_shading.render.half
524 	addChild(new SampleShadingRenderCase(m_context, "half", "Sample shader functionality", m_glslVersion,
525 										 m_internalFormat, m_texFormat, m_sampler.c_str(), m_outType.c_str(), m_min,
526 										 m_max, m_extension.c_str(), 0.5));
527 	// sample_shading.render.none
528 	addChild(new SampleShadingRenderCase(m_context, "none", "Sample shader functionality", m_glslVersion,
529 										 m_internalFormat, m_texFormat, m_sampler.c_str(), m_outType.c_str(), m_min,
530 										 m_max, m_extension.c_str(), 0.0));
531 }
532 
533 class SampleShadingRenderTests : public glcts::TestCaseGroup
534 {
535 public:
536 	SampleShadingRenderTests(glcts::Context& context, glu::GLSLVersion glslVersion);
537 	~SampleShadingRenderTests(void);
538 
539 	void init(void);
540 
541 private:
542 	SampleShadingRenderTests(const SampleShadingTests& other);
543 	SampleShadingRenderTests& operator=(const SampleShadingTests& other);
544 
545 	glu::GLSLVersion m_glslVersion;
546 };
547 
SampleShadingRenderTests(Context & context,glu::GLSLVersion glslVersion)548 SampleShadingRenderTests::SampleShadingRenderTests(Context& context, glu::GLSLVersion glslVersion)
549 	: TestCaseGroup(context, "render", "Sample Shading render tests"), m_glslVersion(glslVersion)
550 {
551 }
552 
~SampleShadingRenderTests(void)553 SampleShadingRenderTests::~SampleShadingRenderTests(void)
554 {
555 }
556 
init(void)557 void SampleShadingRenderTests::init(void)
558 {
559 	// sample_shading.render.rgba8
560 	addChild(new SampleShadingRenderFormatTests(
561 		m_context, m_glslVersion, GL_RGBA8, "rgba8",
562 		tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), "sampler2DMS", "vec4", 0.0, 1.0));
563 	// sample_shading.render.rgba8i
564 	addChild(new SampleShadingRenderFormatTests(
565 		m_context, m_glslVersion, GL_RGBA8I, "rgba8i",
566 		tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::SIGNED_INT8), "isampler2DMS", "ivec4", -128.0,
567 		127.0));
568 	// sample_shading.render.rgba8ui
569 	addChild(new SampleShadingRenderFormatTests(
570 		m_context, m_glslVersion, GL_RGBA8UI, "rgba8ui",
571 		tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNSIGNED_INT8), "usampler2DMS", "uvec4", 0.0,
572 		255.0));
573 	// sample_shading.render.rgba32f
574 	const char* extension =
575 		(glu::isContextTypeES(m_context.getRenderContext().getType())) ? "GL_EXT_color_buffer_float" : "";
576 	addChild(new SampleShadingRenderFormatTests(m_context, m_glslVersion, GL_RGBA32F, "rgba32f",
577 												tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::FLOAT),
578 												"sampler2DMS", "vec4", 0.0, 1.0, extension));
579 }
580 
SampleShadingTests(Context & context,glu::GLSLVersion glslVersion)581 SampleShadingTests::SampleShadingTests(Context& context, glu::GLSLVersion glslVersion)
582 	: TestCaseGroup(context, "sample_shading", "Sample Shading tests"), m_glslVersion(glslVersion)
583 {
584 }
585 
~SampleShadingTests(void)586 SampleShadingTests::~SampleShadingTests(void)
587 {
588 }
589 
init(void)590 void SampleShadingTests::init(void)
591 {
592 	// sample_shading.api
593 	addChild(new SampleShadingApiCaseGroup(m_context, m_glslVersion));
594 	// sample_shading.render
595 	addChild(new SampleShadingRenderTests(m_context, m_glslVersion));
596 }
597 
598 } // glcts
599