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