1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 3.0 Module
3 * -------------------------------------------------
5 * Copyright 2014 The Android Open Source Project
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 * \brief Fragment shader output tests.
23 * \todo [2012-04-10 pyry] Missing:
24 * + non-contiguous attachments in framebuffer
25 *//*--------------------------------------------------------------------*/
27 #include "es3fFragmentOutputTests.hpp"
28 #include "gluShaderUtil.hpp"
29 #include "gluShaderProgram.hpp"
30 #include "gluTextureUtil.hpp"
31 #include "gluStrUtil.hpp"
32 #include "tcuTestLog.hpp"
33 #include "tcuTexture.hpp"
34 #include "tcuTextureUtil.hpp"
35 #include "tcuVector.hpp"
36 #include "tcuVectorUtil.hpp"
37 #include "tcuImageCompare.hpp"
38 #include "deRandom.hpp"
39 #include "deStringUtil.hpp"
42 // For getFormatName() \todo [pyry] Move to glu?
43 #include "es3fFboTestUtil.hpp"
45 #include "glwEnums.hpp"
46 #include "glwFunctions.hpp"
66 using FboTestUtil::getFormatName;
67 using FboTestUtil::getFramebufferReadFormat;
79 BufferSpec (deUint32 format_, int width_, int height_, int samples_)
96 : type (glu::TYPE_LAST)
97 , precision (glu::PRECISION_LAST)
103 FragmentOutput (glu::DataType type_, glu::Precision precision_, int location_, int arrayLength_ = 0)
105 , precision (precision_)
106 , location (location_)
107 , arrayLength (arrayLength_)
112 glu::Precision precision;
114 int arrayLength; //!< 0 if not an array.
119 vector<FragmentOutput> outputs;
121 OutputVec& operator<< (const FragmentOutput& output)
123 outputs.push_back(output);
127 vector<FragmentOutput> toVec (void) const
133 class FragmentOutputCase : public TestCase
136 FragmentOutputCase (Context& context, const char* name, const char* desc, const vector<BufferSpec>& fboSpec, const vector<FragmentOutput>& outputs);
137 ~FragmentOutputCase (void);
141 IterateResult iterate (void);
144 FragmentOutputCase (const FragmentOutputCase& other);
145 FragmentOutputCase& operator= (const FragmentOutputCase& other);
147 vector<BufferSpec> m_fboSpec;
148 vector<FragmentOutput> m_outputs;
150 glu::ShaderProgram* m_program;
151 deUint32 m_framebuffer;
152 vector<deUint32> m_renderbuffers;
155 FragmentOutputCase::FragmentOutputCase (Context& context, const char* name, const char* desc, const vector<BufferSpec>& fboSpec, const vector<FragmentOutput>& outputs)
156 : TestCase (context, name, desc)
157 , m_fboSpec (fboSpec)
158 , m_outputs (outputs)
159 , m_program (DE_NULL)
164 FragmentOutputCase::~FragmentOutputCase (void)
169 static glu::ShaderProgram* createProgram (const glu::RenderContext& context, const vector<FragmentOutput>& outputs)
171 std::ostringstream vtx;
172 std::ostringstream frag;
174 vtx << "#version 300 es\n"
175 << "in highp vec4 a_position;\n";
176 frag << "#version 300 es\n";
178 // Input-output declarations.
179 for (int outNdx = 0; outNdx < (int)outputs.size(); outNdx++)
181 const FragmentOutput& output = outputs[outNdx];
182 bool isArray = output.arrayLength > 0;
183 const char* typeName = glu::getDataTypeName(output.type);
184 const char* outputPrec = glu::getPrecisionName(output.precision);
185 bool isFloat = glu::isDataTypeFloatOrVec(output.type);
186 const char* interp = isFloat ? "smooth" : "flat";
187 const char* interpPrec = isFloat ? "highp" : outputPrec;
191 for (int elemNdx = 0; elemNdx < output.arrayLength; elemNdx++)
193 vtx << "in " << interpPrec << " " << typeName << " in" << outNdx << "_" << elemNdx << ";\n"
194 << interp << " out " << interpPrec << " " << typeName << " var" << outNdx << "_" << elemNdx << ";\n";
195 frag << interp << " in " << interpPrec << " " << typeName << " var" << outNdx << "_" << elemNdx << ";\n";
197 frag << "layout(location = " << output.location << ") out " << outputPrec << " " << typeName << " out" << outNdx << "[" << output.arrayLength << "];\n";
201 vtx << "in " << interpPrec << " " << typeName << " in" << outNdx << ";\n"
202 << interp << " out " << interpPrec << " " << typeName << " var" << outNdx << ";\n";
203 frag << interp << " in " << interpPrec << " " << typeName << " var" << outNdx << ";\n"
204 << "layout(location = " << output.location << ") out " << outputPrec << " " << typeName << " out" << outNdx << ";\n";
208 vtx << "\nvoid main()\n{\n";
209 frag << "\nvoid main()\n{\n";
211 vtx << " gl_Position = a_position;\n";
214 for (int outNdx = 0; outNdx < (int)outputs.size(); outNdx++)
216 const FragmentOutput& output = outputs[outNdx];
217 bool isArray = output.arrayLength > 0;
221 for (int elemNdx = 0; elemNdx < output.arrayLength; elemNdx++)
223 vtx << "\tvar" << outNdx << "_" << elemNdx << " = in" << outNdx << "_" << elemNdx << ";\n";
224 frag << "\tout" << outNdx << "[" << elemNdx << "] = var" << outNdx << "_" << elemNdx << ";\n";
229 vtx << "\tvar" << outNdx << " = in" << outNdx << ";\n";
230 frag << "\tout" << outNdx << " = var" << outNdx << ";\n";
237 return new glu::ShaderProgram(context, glu::makeVtxFragSources(vtx.str(), frag.str()));
240 void FragmentOutputCase::init (void)
242 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
243 TestLog& log = m_testCtx.getLog();
245 // Check that all attachments are supported
246 for (std::vector<BufferSpec>::const_iterator bufIter = m_fboSpec.begin(); bufIter != m_fboSpec.end(); ++bufIter)
248 if (!glu::isSizedFormatColorRenderable(m_context.getRenderContext(), m_context.getContextInfo(), bufIter->format))
249 throw tcu::NotSupportedError("Unsupported attachment format");
252 DE_ASSERT(!m_program);
253 m_program = createProgram(m_context.getRenderContext(), m_outputs);
256 if (!m_program->isOk())
257 TCU_FAIL("Compile failed");
259 // Print render target info to log.
260 log << TestLog::Section("Framebuffer", "Framebuffer configuration");
262 for (int ndx = 0; ndx < (int)m_fboSpec.size(); ndx++)
263 log << TestLog::Message << "COLOR_ATTACHMENT" << ndx << ": "
264 << glu::getTextureFormatStr(m_fboSpec[ndx].format) << ", "
265 << m_fboSpec[ndx].width << "x" << m_fboSpec[ndx].height << ", "
266 << m_fboSpec[ndx].samples << " samples"
267 << TestLog::EndMessage;
269 log << TestLog::EndSection;
271 // Create framebuffer.
272 m_renderbuffers.resize(m_fboSpec.size(), 0);
273 gl.genFramebuffers(1, &m_framebuffer);
274 gl.genRenderbuffers((int)m_renderbuffers.size(), &m_renderbuffers[0]);
276 gl.bindFramebuffer(GL_FRAMEBUFFER, m_framebuffer);
278 for (int bufNdx = 0; bufNdx < (int)m_renderbuffers.size(); bufNdx++)
280 deUint32 rbo = m_renderbuffers[bufNdx];
281 const BufferSpec& bufSpec = m_fboSpec[bufNdx];
282 deUint32 attachment = GL_COLOR_ATTACHMENT0+bufNdx;
284 gl.bindRenderbuffer(GL_RENDERBUFFER, rbo);
285 gl.renderbufferStorageMultisample(GL_RENDERBUFFER, bufSpec.samples, bufSpec.format, bufSpec.width, bufSpec.height);
286 gl.framebufferRenderbuffer(GL_FRAMEBUFFER, attachment, GL_RENDERBUFFER, rbo);
288 GLU_EXPECT_NO_ERROR(gl.getError(), "After framebuffer setup");
290 deUint32 fboStatus = gl.checkFramebufferStatus(GL_FRAMEBUFFER);
291 if (fboStatus == GL_FRAMEBUFFER_UNSUPPORTED)
292 throw tcu::NotSupportedError("Framebuffer not supported", "", __FILE__, __LINE__);
293 else if (fboStatus != GL_FRAMEBUFFER_COMPLETE)
294 throw tcu::TestError((string("Incomplete framebuffer: ") + glu::getFramebufferStatusStr(fboStatus).toString()).c_str(), "", __FILE__, __LINE__);
296 gl.bindFramebuffer(GL_FRAMEBUFFER, 0);
297 GLU_EXPECT_NO_ERROR(gl.getError(), "After init");
300 void FragmentOutputCase::deinit (void)
302 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
306 gl.deleteFramebuffers(1, &m_framebuffer);
310 if (!m_renderbuffers.empty())
312 gl.deleteRenderbuffers((int)m_renderbuffers.size(), &m_renderbuffers[0]);
313 m_renderbuffers.clear();
320 static IVec2 getMinSize (const vector<BufferSpec>& fboSpec)
322 IVec2 minSize(0x7fffffff, 0x7fffffff);
323 for (vector<BufferSpec>::const_iterator i = fboSpec.begin(); i != fboSpec.end(); i++)
325 minSize.x() = de::min(minSize.x(), i->width);
326 minSize.y() = de::min(minSize.y(), i->height);
331 static int getNumInputVectors (const vector<FragmentOutput>& outputs)
334 for (vector<FragmentOutput>::const_iterator i = outputs.begin(); i != outputs.end(); i++)
335 numVecs += (i->arrayLength > 0 ? i->arrayLength : 1);
339 static Vec2 getFloatRange (glu::Precision precision)
341 // \todo [2012-04-09 pyry] Not quite the full ranges.
342 static const Vec2 ranges[] =
345 Vec2(-16000.0f, 16000.0f),
348 DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(ranges) == glu::PRECISION_LAST);
349 DE_ASSERT(de::inBounds<int>(precision, 0, DE_LENGTH_OF_ARRAY(ranges)));
350 return ranges[precision];
353 static IVec2 getIntRange (glu::Precision precision)
355 static const IVec2 ranges[] =
357 IVec2(-(1<< 7), (1<< 7)-1),
358 IVec2(-(1<<15), (1<<15)-1),
359 IVec2(0x80000000, 0x7fffffff)
361 DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(ranges) == glu::PRECISION_LAST);
362 DE_ASSERT(de::inBounds<int>(precision, 0, DE_LENGTH_OF_ARRAY(ranges)));
363 return ranges[precision];
366 static UVec2 getUintRange (glu::Precision precision)
368 static const UVec2 ranges[] =
372 UVec2(0, 0xffffffffu)
374 DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(ranges) == glu::PRECISION_LAST);
375 DE_ASSERT(de::inBounds<int>(precision, 0, DE_LENGTH_OF_ARRAY(ranges)));
376 return ranges[precision];
379 static inline Vec4 readVec4 (const float* ptr, int numComponents)
381 DE_ASSERT(numComponents >= 1);
383 numComponents >= 2 ? ptr[1] : 0.0f,
384 numComponents >= 3 ? ptr[2] : 0.0f,
385 numComponents >= 4 ? ptr[3] : 0.0f);
388 static inline IVec4 readIVec4 (const int* ptr, int numComponents)
390 DE_ASSERT(numComponents >= 1);
392 numComponents >= 2 ? ptr[1] : 0,
393 numComponents >= 3 ? ptr[2] : 0,
394 numComponents >= 4 ? ptr[3] : 0);
397 static void renderFloatReference (const tcu::PixelBufferAccess& dst, int gridWidth, int gridHeight, int numComponents, const float* vertices)
399 const bool isSRGB = tcu::isSRGB(dst.getFormat());
400 const float cellW = (float)dst.getWidth() / (float)(gridWidth-1);
401 const float cellH = (float)dst.getHeight() / (float)(gridHeight-1);
403 for (int y = 0; y < dst.getHeight(); y++)
405 for (int x = 0; x < dst.getWidth(); x++)
407 const int cellX = de::clamp(deFloorFloatToInt32((float)x / cellW), 0, gridWidth-2);
408 const int cellY = de::clamp(deFloorFloatToInt32((float)y / cellH), 0, gridHeight-2);
409 const float xf = ((float)x - (float)cellX*cellW + 0.5f) / cellW;
410 const float yf = ((float)y - (float)cellY*cellH + 0.5f) / cellH;
411 const Vec4 v00 = readVec4(vertices + ((cellY+0)*gridWidth + cellX+0)*numComponents, numComponents);
412 const Vec4 v01 = readVec4(vertices + ((cellY+1)*gridWidth + cellX+0)*numComponents, numComponents);
413 const Vec4 v10 = readVec4(vertices + ((cellY+0)*gridWidth + cellX+1)*numComponents, numComponents);
414 const Vec4 v11 = readVec4(vertices + ((cellY+1)*gridWidth + cellX+1)*numComponents, numComponents);
415 const bool tri = xf + yf >= 1.0f;
416 const Vec4& v0 = tri ? v11 : v00;
417 const Vec4& v1 = tri ? v01 : v10;
418 const Vec4& v2 = tri ? v10 : v01;
419 const float s = tri ? 1.0f-xf : xf;
420 const float t = tri ? 1.0f-yf : yf;
421 const Vec4 color = v0 + (v1-v0)*s + (v2-v0)*t;
423 dst.setPixel(isSRGB ? tcu::linearToSRGB(color) : color, x, y);
428 static void renderIntReference (const tcu::PixelBufferAccess& dst, int gridWidth, int gridHeight, int numComponents, const int* vertices)
430 float cellW = (float)dst.getWidth() / (float)(gridWidth-1);
431 float cellH = (float)dst.getHeight() / (float)(gridHeight-1);
433 for (int y = 0; y < dst.getHeight(); y++)
435 for (int x = 0; x < dst.getWidth(); x++)
437 int cellX = de::clamp(deFloorFloatToInt32((float)x / cellW), 0, gridWidth-2);
438 int cellY = de::clamp(deFloorFloatToInt32((float)y / cellH), 0, gridHeight-2);
439 IVec4 c = readIVec4(vertices + (cellY*gridWidth + cellX+1)*numComponents, numComponents);
441 dst.setPixel(c, x, y);
446 static const IVec4 s_swizzles[] =
458 template <typename T>
459 inline tcu::Vector<T, 4> swizzleVec (const tcu::Vector<T, 4>& vec, int swzNdx)
461 const IVec4& swz = s_swizzles[swzNdx % DE_LENGTH_OF_ARRAY(s_swizzles)];
462 return vec.swizzle(swz[0], swz[1], swz[2], swz[3]);
468 struct AttachmentData
470 tcu::TextureFormat format; //!< Actual format of attachment.
471 tcu::TextureFormat referenceFormat; //!< Used for reference rendering.
472 tcu::TextureFormat readFormat;
473 int numWrittenChannels;
474 glu::Precision outPrecision;
475 vector<deUint8> renderedData;
476 vector<deUint8> referenceData;
479 template<typename Type>
480 string valueRangeToString (int numValidChannels, const tcu::Vector<Type, 4>& minValue, const tcu::Vector<Type, 4>& maxValue)
482 std::ostringstream stream;
486 for (int i = 0; i < 4; i++)
491 if (i < numValidChannels)
492 stream << minValue[i] << " -> " << maxValue[i];
502 void clearUndefined (const tcu::PixelBufferAccess& access, int numValidChannels)
504 for (int y = 0; y < access.getHeight(); y++)
505 for (int x = 0; x < access.getWidth(); x++)
507 switch (tcu::getTextureChannelClass(access.getFormat().type))
509 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
511 const Vec4 srcPixel = access.getPixel(x, y);
512 Vec4 dstPixel (0.0f, 0.0f, 0.0f, 1.0f);
514 for (int channelNdx = 0; channelNdx < numValidChannels; channelNdx++)
515 dstPixel[channelNdx] = srcPixel[channelNdx];
517 access.setPixel(dstPixel, x, y);
521 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
522 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
523 case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
524 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
526 const IVec4 bitDepth = tcu::getTextureFormatBitDepth(access.getFormat());
527 const IVec4 srcPixel = access.getPixelInt(x, y);
528 IVec4 dstPixel (0, 0, 0, (0x1u << (deUint64)bitDepth.w()) - 1);
530 for (int channelNdx = 0; channelNdx < numValidChannels; channelNdx++)
531 dstPixel[channelNdx] = srcPixel[channelNdx];
533 access.setPixel(dstPixel, x, y);
545 FragmentOutputCase::IterateResult FragmentOutputCase::iterate (void)
547 TestLog& log = m_testCtx.getLog();
548 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
550 // Compute grid size & index list.
551 const int minCellSize = 8;
552 const IVec2 minBufSize = getMinSize(m_fboSpec);
553 const int gridWidth = de::clamp(minBufSize.x()/minCellSize, 1, 255)+1;
554 const int gridHeight = de::clamp(minBufSize.y()/minCellSize, 1, 255)+1;
555 const int numVertices = gridWidth*gridHeight;
556 const int numQuads = (gridWidth-1)*(gridHeight-1);
557 const int numIndices = numQuads*6;
559 const int numInputVecs = getNumInputVectors(m_outputs);
560 vector<vector<deUint32> > inputs (numInputVecs);
561 vector<float> positions (numVertices*4);
562 vector<deUint16> indices (numIndices);
564 const int readAlignment = 4;
565 const int viewportW = minBufSize.x();
566 const int viewportH = minBufSize.y();
567 const int numAttachments = (int)m_fboSpec.size();
569 vector<deUint32> drawBuffers (numAttachments);
570 vector<AttachmentData> attachments (numAttachments);
572 // Initialize attachment data.
573 for (int ndx = 0; ndx < numAttachments; ndx++)
575 const tcu::TextureFormat texFmt = glu::mapGLInternalFormat(m_fboSpec[ndx].format);
576 const tcu::TextureChannelClass chnClass = tcu::getTextureChannelClass(texFmt.type);
577 const bool isFixedPoint = chnClass == tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT ||
578 chnClass == tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT;
580 // \note Fixed-point formats use float reference to enable more accurate result verification.
581 const tcu::TextureFormat refFmt = isFixedPoint ? tcu::TextureFormat(texFmt.order, tcu::TextureFormat::FLOAT) : texFmt;
582 const tcu::TextureFormat readFmt = getFramebufferReadFormat(texFmt);
583 const int attachmentW = m_fboSpec[ndx].width;
584 const int attachmentH = m_fboSpec[ndx].height;
586 drawBuffers[ndx] = GL_COLOR_ATTACHMENT0+ndx;
587 attachments[ndx].format = texFmt;
588 attachments[ndx].readFormat = readFmt;
589 attachments[ndx].referenceFormat = refFmt;
590 attachments[ndx].renderedData.resize(readFmt.getPixelSize()*attachmentW*attachmentH);
591 attachments[ndx].referenceData.resize(refFmt.getPixelSize()*attachmentW*attachmentH);
594 // Initialize indices.
595 for (int quadNdx = 0; quadNdx < numQuads; quadNdx++)
597 int quadY = quadNdx / (gridWidth-1);
598 int quadX = quadNdx - quadY*(gridWidth-1);
600 indices[quadNdx*6+0] = deUint16(quadX + quadY*gridWidth);
601 indices[quadNdx*6+1] = deUint16(quadX + (quadY+1)*gridWidth);
602 indices[quadNdx*6+2] = deUint16(quadX + quadY*gridWidth + 1);
603 indices[quadNdx*6+3] = indices[quadNdx*6+1];
604 indices[quadNdx*6+4] = deUint16(quadX + (quadY+1)*gridWidth + 1);
605 indices[quadNdx*6+5] = indices[quadNdx*6+2];
608 for (int y = 0; y < gridHeight; y++)
610 for (int x = 0; x < gridWidth; x++)
612 float xf = (float)x / (float)(gridWidth-1);
613 float yf = (float)y / (float)(gridHeight-1);
615 positions[(y*gridWidth + x)*4 + 0] = 2.0f*xf - 1.0f;
616 positions[(y*gridWidth + x)*4 + 1] = 2.0f*yf - 1.0f;
617 positions[(y*gridWidth + x)*4 + 2] = 0.0f;
618 positions[(y*gridWidth + x)*4 + 3] = 1.0f;
622 // Initialize input vectors.
625 for (int outputNdx = 0; outputNdx < (int)m_outputs.size(); outputNdx++)
627 const FragmentOutput& output = m_outputs[outputNdx];
628 bool isFloat = glu::isDataTypeFloatOrVec(output.type);
629 bool isInt = glu::isDataTypeIntOrIVec(output.type);
630 bool isUint = glu::isDataTypeUintOrUVec(output.type);
631 int numVecs = output.arrayLength > 0 ? output.arrayLength : 1;
632 int numScalars = glu::getDataTypeScalarSize(output.type);
634 for (int vecNdx = 0; vecNdx < numVecs; vecNdx++)
636 inputs[curInVec].resize(numVertices*numScalars);
638 // Record how many outputs are written in attachment.
639 DE_ASSERT(output.location+vecNdx < (int)attachments.size());
640 attachments[output.location+vecNdx].numWrittenChannels = numScalars;
641 attachments[output.location+vecNdx].outPrecision = output.precision;
645 Vec2 range = getFloatRange(output.precision);
646 Vec4 minVal (range.x());
647 Vec4 maxVal (range.y());
648 float* dst = (float*)&inputs[curInVec][0];
650 if (de::inBounds(output.location+vecNdx, 0, (int)attachments.size()))
652 // \note Floating-point precision conversion is not well-defined. For that reason we must
653 // limit value range to intersection of both data type and render target value ranges.
654 const tcu::TextureFormatInfo fmtInfo = tcu::getTextureFormatInfo(attachments[output.location+vecNdx].format);
655 minVal = tcu::max(minVal, fmtInfo.valueMin);
656 maxVal = tcu::min(maxVal, fmtInfo.valueMax);
659 m_testCtx.getLog() << TestLog::Message << "out" << curInVec << " value range: " << valueRangeToString(numScalars, minVal, maxVal) << TestLog::EndMessage;
661 for (int y = 0; y < gridHeight; y++)
663 for (int x = 0; x < gridWidth; x++)
665 float xf = (float)x / (float)(gridWidth-1);
666 float yf = (float)y / (float)(gridHeight-1);
668 float f0 = (xf + yf) * 0.5f;
669 float f1 = 0.5f + (xf - yf) * 0.5f;
670 Vec4 f = swizzleVec(Vec4(f0, f1, 1.0f-f0, 1.0f-f1), curInVec);
671 Vec4 c = minVal + (maxVal-minVal)*f;
672 float* v = dst + (y*gridWidth + x)*numScalars;
674 for (int ndx = 0; ndx < numScalars; ndx++)
681 const IVec2 range = getIntRange(output.precision);
682 IVec4 minVal (range.x());
683 IVec4 maxVal (range.y());
685 if (de::inBounds(output.location+vecNdx, 0, (int)attachments.size()))
687 // Limit to range of output format as conversion mode is not specified.
688 const IVec4 fmtBits = tcu::getTextureFormatBitDepth(attachments[output.location+vecNdx].format);
689 const BVec4 isZero = lessThanEqual(fmtBits, IVec4(0));
690 const IVec4 fmtMinVal = (-(tcu::Vector<deInt64, 4>(1) << (fmtBits-1).cast<deInt64>())).asInt();
691 const IVec4 fmtMaxVal = ((tcu::Vector<deInt64, 4>(1) << (fmtBits-1).cast<deInt64>())-deInt64(1)).asInt();
693 minVal = select(minVal, tcu::max(minVal, fmtMinVal), isZero);
694 maxVal = select(maxVal, tcu::min(maxVal, fmtMaxVal), isZero);
697 m_testCtx.getLog() << TestLog::Message << "out" << curInVec << " value range: " << valueRangeToString(numScalars, minVal, maxVal) << TestLog::EndMessage;
699 const IVec4 rangeDiv = swizzleVec((IVec4(gridWidth, gridHeight, gridWidth, gridHeight)-1), curInVec);
700 const IVec4 step = ((maxVal.cast<deInt64>() - minVal.cast<deInt64>()) / (rangeDiv.cast<deInt64>())).asInt();
701 deInt32* dst = (deInt32*)&inputs[curInVec][0];
703 for (int y = 0; y < gridHeight; y++)
705 for (int x = 0; x < gridWidth; x++)
707 int ix = gridWidth - x - 1;
708 int iy = gridHeight - y - 1;
709 IVec4 c = minVal + step*swizzleVec(IVec4(x, y, ix, iy), curInVec);
710 deInt32* v = dst + (y*gridWidth + x)*numScalars;
712 DE_ASSERT(boolAll(logicalAnd(greaterThanEqual(c, minVal), lessThanEqual(c, maxVal))));
714 for (int ndx = 0; ndx < numScalars; ndx++)
721 const UVec2 range = getUintRange(output.precision);
722 UVec4 maxVal (range.y());
724 if (de::inBounds(output.location+vecNdx, 0, (int)attachments.size()))
726 // Limit to range of output format as conversion mode is not specified.
727 const IVec4 fmtBits = tcu::getTextureFormatBitDepth(attachments[output.location+vecNdx].format);
728 const UVec4 fmtMaxVal = ((tcu::Vector<deUint64, 4>(1) << fmtBits.cast<deUint64>())-deUint64(1)).asUint();
730 maxVal = tcu::min(maxVal, fmtMaxVal);
733 m_testCtx.getLog() << TestLog::Message << "out" << curInVec << " value range: " << valueRangeToString(numScalars, UVec4(0), maxVal) << TestLog::EndMessage;
735 const IVec4 rangeDiv = swizzleVec((IVec4(gridWidth, gridHeight, gridWidth, gridHeight)-1), curInVec);
736 const UVec4 step = maxVal / rangeDiv.asUint();
737 deUint32* dst = &inputs[curInVec][0];
739 DE_ASSERT(range.x() == 0);
741 for (int y = 0; y < gridHeight; y++)
743 for (int x = 0; x < gridWidth; x++)
745 int ix = gridWidth - x - 1;
746 int iy = gridHeight - y - 1;
747 UVec4 c = step*swizzleVec(IVec4(x, y, ix, iy).asUint(), curInVec);
748 deUint32* v = dst + (y*gridWidth + x)*numScalars;
750 DE_ASSERT(boolAll(lessThanEqual(c, maxVal)));
752 for (int ndx = 0; ndx < numScalars; ndx++)
766 gl.useProgram(m_program->getProgram());
767 gl.bindFramebuffer(GL_FRAMEBUFFER, m_framebuffer);
768 gl.viewport(0, 0, viewportW, viewportH);
769 gl.drawBuffers((int)drawBuffers.size(), &drawBuffers[0]);
770 gl.disable(GL_DITHER); // Dithering causes issues with unorm formats. Those issues could be worked around in threshold, but it makes validation less accurate.
771 GLU_EXPECT_NO_ERROR(gl.getError(), "After program setup");
775 for (int outputNdx = 0; outputNdx < (int)m_outputs.size(); outputNdx++)
777 const FragmentOutput& output = m_outputs[outputNdx];
778 bool isArray = output.arrayLength > 0;
779 bool isFloat = glu::isDataTypeFloatOrVec(output.type);
780 bool isInt = glu::isDataTypeIntOrIVec(output.type);
781 bool isUint = glu::isDataTypeUintOrUVec(output.type);
782 int scalarSize = glu::getDataTypeScalarSize(output.type);
783 deUint32 glScalarType = isFloat ? GL_FLOAT :
785 isUint ? GL_UNSIGNED_INT : GL_NONE;
786 int numVecs = isArray ? output.arrayLength : 1;
788 for (int vecNdx = 0; vecNdx < numVecs; vecNdx++)
790 string name = string("in") + de::toString(outputNdx) + (isArray ? string("_") + de::toString(vecNdx) : string());
791 int loc = gl.getAttribLocation(m_program->getProgram(), name.c_str());
795 gl.enableVertexAttribArray(loc);
797 gl.vertexAttribPointer(loc, scalarSize, glScalarType, GL_FALSE, 0, &inputs[curInVec][0]);
799 gl.vertexAttribIPointer(loc, scalarSize, glScalarType, 0, &inputs[curInVec][0]);
802 log << TestLog::Message << "Warning: No location for attribute '" << name << "' found." << TestLog::EndMessage;
809 int posLoc = gl.getAttribLocation(m_program->getProgram(), "a_position");
810 TCU_CHECK(posLoc >= 0);
811 gl.enableVertexAttribArray(posLoc);
812 gl.vertexAttribPointer(posLoc, 4, GL_FLOAT, GL_FALSE, 0, &positions[0]);
814 GLU_EXPECT_NO_ERROR(gl.getError(), "After attribute setup");
816 gl.drawElements(GL_TRIANGLES, numIndices, GL_UNSIGNED_SHORT, &indices[0]);
817 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawElements");
819 // Read all attachment points.
820 for (int ndx = 0; ndx < numAttachments; ndx++)
822 const glu::TransferFormat transferFmt = glu::getTransferFormat(attachments[ndx].readFormat);
823 void* dst = &attachments[ndx].renderedData[0];
824 const int attachmentW = m_fboSpec[ndx].width;
825 const int attachmentH = m_fboSpec[ndx].height;
826 const int numValidChannels = attachments[ndx].numWrittenChannels;
827 const tcu::PixelBufferAccess rendered (attachments[ndx].readFormat, attachmentW, attachmentH, 1, deAlign32(attachments[ndx].readFormat.getPixelSize()*attachmentW, readAlignment), 0, &attachments[ndx].renderedData[0]);
829 gl.readBuffer(GL_COLOR_ATTACHMENT0+ndx);
830 gl.readPixels(0, 0, minBufSize.x(), minBufSize.y(), transferFmt.format, transferFmt.dataType, dst);
832 clearUndefined(rendered, numValidChannels);
835 // Render reference images.
838 for (int outputNdx = 0; outputNdx < (int)m_outputs.size(); outputNdx++)
840 const FragmentOutput& output = m_outputs[outputNdx];
841 const bool isArray = output.arrayLength > 0;
842 const bool isFloat = glu::isDataTypeFloatOrVec(output.type);
843 const bool isInt = glu::isDataTypeIntOrIVec(output.type);
844 const bool isUint = glu::isDataTypeUintOrUVec(output.type);
845 const int scalarSize = glu::getDataTypeScalarSize(output.type);
846 const int numVecs = isArray ? output.arrayLength : 1;
848 for (int vecNdx = 0; vecNdx < numVecs; vecNdx++)
850 const int location = output.location+vecNdx;
851 const void* inputData = &inputs[curInNdx][0];
853 DE_ASSERT(de::inBounds(location, 0, (int)m_fboSpec.size()));
855 const int bufW = m_fboSpec[location].width;
856 const int bufH = m_fboSpec[location].height;
857 const tcu::PixelBufferAccess buf (attachments[location].referenceFormat, bufW, bufH, 1, &attachments[location].referenceData[0]);
858 const tcu::PixelBufferAccess viewportBuf = getSubregion(buf, 0, 0, 0, viewportW, viewportH, 1);
861 renderIntReference(viewportBuf, gridWidth, gridHeight, scalarSize, (const int*)inputData);
863 renderFloatReference(viewportBuf, gridWidth, gridHeight, scalarSize, (const float*)inputData);
872 // Compare all images.
873 bool allLevelsOk = true;
874 for (int attachNdx = 0; attachNdx < numAttachments; attachNdx++)
876 const int attachmentW = m_fboSpec[attachNdx].width;
877 const int attachmentH = m_fboSpec[attachNdx].height;
878 const int numValidChannels = attachments[attachNdx].numWrittenChannels;
879 const tcu::BVec4 cmpMask (numValidChannels >= 1, numValidChannels >= 2, numValidChannels >= 3, numValidChannels >= 4);
880 const glu::Precision outPrecision = attachments[attachNdx].outPrecision;
881 const tcu::TextureFormat& format = attachments[attachNdx].format;
882 tcu::ConstPixelBufferAccess rendered (attachments[attachNdx].readFormat, attachmentW, attachmentH, 1, deAlign32(attachments[attachNdx].readFormat.getPixelSize()*attachmentW, readAlignment), 0, &attachments[attachNdx].renderedData[0]);
883 tcu::ConstPixelBufferAccess reference (attachments[attachNdx].referenceFormat, attachmentW, attachmentH, 1, &attachments[attachNdx].referenceData[0]);
884 tcu::TextureChannelClass texClass = tcu::getTextureChannelClass(format.type);
886 const string name = string("Attachment") + de::toString(attachNdx);
887 const string desc = string("Color attachment ") + de::toString(attachNdx);
889 log << TestLog::Message << "Attachment " << attachNdx << ": " << numValidChannels << " channels have defined values and used for comparison" << TestLog::EndMessage;
893 case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
895 const deUint32 interpThreshold = 4; //!< 4 ULP interpolation threshold (interpolation always in highp)
896 deUint32 outTypeThreshold = 0; //!< Threshold based on output type
897 UVec4 formatThreshold; //!< Threshold computed based on format.
898 UVec4 finalThreshold;
900 // 1 ULP rounding error is allowed for smaller floating-point formats
903 case tcu::TextureFormat::FLOAT: formatThreshold = UVec4(0); break;
904 case tcu::TextureFormat::HALF_FLOAT: formatThreshold = UVec4((1<<(23-10))); break;
905 case tcu::TextureFormat::UNSIGNED_INT_11F_11F_10F_REV: formatThreshold = UVec4((1<<(23-6)), (1<<(23-6)), (1<<(23-5)), 0); break;
911 // 1 ULP rounding error for highp -> output precision cast
912 switch (outPrecision)
914 case glu::PRECISION_LOWP: outTypeThreshold = (1<<(23-8)); break;
915 case glu::PRECISION_MEDIUMP: outTypeThreshold = (1<<(23-10)); break;
916 case glu::PRECISION_HIGHP: outTypeThreshold = 0; break;
921 finalThreshold = select(max(formatThreshold, UVec4(deMax32(interpThreshold, outTypeThreshold))), UVec4(~0u), cmpMask);
923 isOk = tcu::floatUlpThresholdCompare(log, name.c_str(), desc.c_str(), reference, rendered, finalThreshold, tcu::COMPARE_LOG_RESULT);
927 case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
929 // \note glReadPixels() allows only 8 bits to be read. This means that RGB10_A2 will loose some
930 // bits in the process and it must be taken into account when computing threshold.
931 const IVec4 bits = min(IVec4(8), tcu::getTextureFormatBitDepth(format));
932 const Vec4 baseThreshold = 1.0f / ((IVec4(1) << bits)-1).asFloat();
933 const Vec4 threshold = select(baseThreshold, Vec4(2.0f), cmpMask);
935 isOk = tcu::floatThresholdCompare(log, name.c_str(), desc.c_str(), reference, rendered, threshold, tcu::COMPARE_LOG_RESULT);
939 case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
940 case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
942 const tcu::UVec4 threshold = select(UVec4(0u), UVec4(~0u), cmpMask);
943 isOk = tcu::intThresholdCompare(log, name.c_str(), desc.c_str(), reference, rendered, threshold, tcu::COMPARE_LOG_RESULT);
948 TCU_FAIL("Unsupported comparison");
956 m_testCtx.setTestResult(allLevelsOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
957 allLevelsOk ? "Pass" : "Image comparison failed");
961 FragmentOutputTests::FragmentOutputTests (Context& context)
962 : TestCaseGroup(context, "fragment_out", "Fragment output tests")
966 FragmentOutputTests::~FragmentOutputTests (void)
970 static FragmentOutputCase* createRandomCase (Context& context, int minRenderTargets, int maxRenderTargets, deUint32 seed)
972 static const glu::DataType outputTypes[] =
975 glu::TYPE_FLOAT_VEC2,
976 glu::TYPE_FLOAT_VEC3,
977 glu::TYPE_FLOAT_VEC4,
987 static const glu::Precision precisions[] =
990 glu::PRECISION_MEDIUMP,
993 static const deUint32 floatFormats[] =
1012 static const deUint32 intFormats[] =
1024 static const deUint32 uintFormats[] =
1038 de::Random rnd (seed);
1039 vector<FragmentOutput> outputs;
1040 vector<BufferSpec> targets;
1041 vector<glu::DataType> outTypes;
1043 int numTargets = rnd.getInt(minRenderTargets, maxRenderTargets);
1044 const int width = 128; // \todo [2012-04-10 pyry] Separate randomized sizes per target?
1045 const int height = 64;
1046 const int samples = 0;
1050 while (curLoc < numTargets)
1052 bool useArray = rnd.getFloat() < 0.3f;
1053 int maxArrayLen = numTargets-curLoc;
1054 int arrayLen = useArray ? rnd.getInt(1, maxArrayLen) : 0;
1055 glu::DataType basicType = rnd.choose<glu::DataType>(&outputTypes[0], &outputTypes[0] + DE_LENGTH_OF_ARRAY(outputTypes));
1056 glu::Precision precision = rnd.choose<glu::Precision>(&precisions[0], &precisions[0] + DE_LENGTH_OF_ARRAY(precisions));
1057 int numLocations = useArray ? arrayLen : 1;
1059 outputs.push_back(FragmentOutput(basicType, precision, curLoc, arrayLen));
1061 for (int ndx = 0; ndx < numLocations; ndx++)
1062 outTypes.push_back(basicType);
1064 curLoc += numLocations;
1066 DE_ASSERT(curLoc == numTargets);
1067 DE_ASSERT((int)outTypes.size() == numTargets);
1070 while ((int)targets.size() < numTargets)
1072 glu::DataType outType = outTypes[targets.size()];
1073 bool isFloat = glu::isDataTypeFloatOrVec(outType);
1074 bool isInt = glu::isDataTypeIntOrIVec(outType);
1075 bool isUint = glu::isDataTypeUintOrUVec(outType);
1076 deUint32 format = 0;
1079 format = rnd.choose<deUint32>(&floatFormats[0], &floatFormats[0] + DE_LENGTH_OF_ARRAY(floatFormats));
1081 format = rnd.choose<deUint32>(&intFormats[0], &intFormats[0] + DE_LENGTH_OF_ARRAY(intFormats));
1083 format = rnd.choose<deUint32>(&uintFormats[0], &uintFormats[0] + DE_LENGTH_OF_ARRAY(uintFormats));
1087 targets.push_back(BufferSpec(format, width, height, samples));
1090 return new FragmentOutputCase(context, de::toString(seed).c_str(), "", targets, outputs);
1093 void FragmentOutputTests::init (void)
1095 static const deUint32 requiredFloatFormats[] =
1105 static const deUint32 requiredFixedFormats[] =
1117 static const deUint32 requiredIntFormats[] =
1129 static const deUint32 requiredUintFormats[] =
1143 static const glu::Precision precisions[] =
1145 glu::PRECISION_LOWP,
1146 glu::PRECISION_MEDIUMP,
1147 glu::PRECISION_HIGHP
1152 tcu::TestCaseGroup* basicGroup = new tcu::TestCaseGroup(m_testCtx, "basic", "Basic fragment output tests");
1153 addChild(basicGroup);
1155 const int width = 64;
1156 const int height = 64;
1157 const int samples = 0;
1160 tcu::TestCaseGroup* floatGroup = new tcu::TestCaseGroup(m_testCtx, "float", "Floating-point output tests");
1161 basicGroup->addChild(floatGroup);
1162 for (int fmtNdx = 0; fmtNdx < DE_LENGTH_OF_ARRAY(requiredFloatFormats); fmtNdx++)
1164 deUint32 format = requiredFloatFormats[fmtNdx];
1165 string fmtName = getFormatName(format);
1166 vector<BufferSpec> fboSpec;
1168 fboSpec.push_back(BufferSpec(format, width, height, samples));
1170 for (int precNdx = 0; precNdx < DE_LENGTH_OF_ARRAY(precisions); precNdx++)
1172 glu::Precision prec = precisions[precNdx];
1173 string precName = glu::getPrecisionName(prec);
1175 floatGroup->addChild(new FragmentOutputCase(m_context, (fmtName + "_" + precName + "_float").c_str(), "", fboSpec, (OutputVec() << FragmentOutput(glu::TYPE_FLOAT, prec, 0)).toVec()));
1176 floatGroup->addChild(new FragmentOutputCase(m_context, (fmtName + "_" + precName + "_vec2").c_str(), "", fboSpec, (OutputVec() << FragmentOutput(glu::TYPE_FLOAT_VEC2, prec, 0)).toVec()));
1177 floatGroup->addChild(new FragmentOutputCase(m_context, (fmtName + "_" + precName + "_vec3").c_str(), "", fboSpec, (OutputVec() << FragmentOutput(glu::TYPE_FLOAT_VEC3, prec, 0)).toVec()));
1178 floatGroup->addChild(new FragmentOutputCase(m_context, (fmtName + "_" + precName + "_vec4").c_str(), "", fboSpec, (OutputVec() << FragmentOutput(glu::TYPE_FLOAT_VEC4, prec, 0)).toVec()));
1183 tcu::TestCaseGroup* fixedGroup = new tcu::TestCaseGroup(m_testCtx, "fixed", "Fixed-point output tests");
1184 basicGroup->addChild(fixedGroup);
1185 for (int fmtNdx = 0; fmtNdx < DE_LENGTH_OF_ARRAY(requiredFixedFormats); fmtNdx++)
1187 deUint32 format = requiredFixedFormats[fmtNdx];
1188 string fmtName = getFormatName(format);
1189 vector<BufferSpec> fboSpec;
1191 fboSpec.push_back(BufferSpec(format, width, height, samples));
1193 for (int precNdx = 0; precNdx < DE_LENGTH_OF_ARRAY(precisions); precNdx++)
1195 glu::Precision prec = precisions[precNdx];
1196 string precName = glu::getPrecisionName(prec);
1198 fixedGroup->addChild(new FragmentOutputCase(m_context, (fmtName + "_" + precName + "_float").c_str(), "", fboSpec, (OutputVec() << FragmentOutput(glu::TYPE_FLOAT, prec, 0)).toVec()));
1199 fixedGroup->addChild(new FragmentOutputCase(m_context, (fmtName + "_" + precName + "_vec2").c_str(), "", fboSpec, (OutputVec() << FragmentOutput(glu::TYPE_FLOAT_VEC2, prec, 0)).toVec()));
1200 fixedGroup->addChild(new FragmentOutputCase(m_context, (fmtName + "_" + precName + "_vec3").c_str(), "", fboSpec, (OutputVec() << FragmentOutput(glu::TYPE_FLOAT_VEC3, prec, 0)).toVec()));
1201 fixedGroup->addChild(new FragmentOutputCase(m_context, (fmtName + "_" + precName + "_vec4").c_str(), "", fboSpec, (OutputVec() << FragmentOutput(glu::TYPE_FLOAT_VEC4, prec, 0)).toVec()));
1206 tcu::TestCaseGroup* intGroup = new tcu::TestCaseGroup(m_testCtx, "int", "Integer output tests");
1207 basicGroup->addChild(intGroup);
1208 for (int fmtNdx = 0; fmtNdx < DE_LENGTH_OF_ARRAY(requiredIntFormats); fmtNdx++)
1210 deUint32 format = requiredIntFormats[fmtNdx];
1211 string fmtName = getFormatName(format);
1212 vector<BufferSpec> fboSpec;
1214 fboSpec.push_back(BufferSpec(format, width, height, samples));
1216 for (int precNdx = 0; precNdx < DE_LENGTH_OF_ARRAY(precisions); precNdx++)
1218 glu::Precision prec = precisions[precNdx];
1219 string precName = glu::getPrecisionName(prec);
1221 intGroup->addChild(new FragmentOutputCase(m_context, (fmtName + "_" + precName + "_int").c_str(), "", fboSpec, (OutputVec() << FragmentOutput(glu::TYPE_INT, prec, 0)).toVec()));
1222 intGroup->addChild(new FragmentOutputCase(m_context, (fmtName + "_" + precName + "_ivec2").c_str(), "", fboSpec, (OutputVec() << FragmentOutput(glu::TYPE_INT_VEC2, prec, 0)).toVec()));
1223 intGroup->addChild(new FragmentOutputCase(m_context, (fmtName + "_" + precName + "_ivec3").c_str(), "", fboSpec, (OutputVec() << FragmentOutput(glu::TYPE_INT_VEC3, prec, 0)).toVec()));
1224 intGroup->addChild(new FragmentOutputCase(m_context, (fmtName + "_" + precName + "_ivec4").c_str(), "", fboSpec, (OutputVec() << FragmentOutput(glu::TYPE_INT_VEC4, prec, 0)).toVec()));
1229 tcu::TestCaseGroup* uintGroup = new tcu::TestCaseGroup(m_testCtx, "uint", "Usigned integer output tests");
1230 basicGroup->addChild(uintGroup);
1231 for (int fmtNdx = 0; fmtNdx < DE_LENGTH_OF_ARRAY(requiredUintFormats); fmtNdx++)
1233 deUint32 format = requiredUintFormats[fmtNdx];
1234 string fmtName = getFormatName(format);
1235 vector<BufferSpec> fboSpec;
1237 fboSpec.push_back(BufferSpec(format, width, height, samples));
1239 for (int precNdx = 0; precNdx < DE_LENGTH_OF_ARRAY(precisions); precNdx++)
1241 glu::Precision prec = precisions[precNdx];
1242 string precName = glu::getPrecisionName(prec);
1244 uintGroup->addChild(new FragmentOutputCase(m_context, (fmtName + "_" + precName + "_uint").c_str(), "", fboSpec, (OutputVec() << FragmentOutput(glu::TYPE_UINT, prec, 0)).toVec()));
1245 uintGroup->addChild(new FragmentOutputCase(m_context, (fmtName + "_" + precName + "_uvec2").c_str(), "", fboSpec, (OutputVec() << FragmentOutput(glu::TYPE_UINT_VEC2, prec, 0)).toVec()));
1246 uintGroup->addChild(new FragmentOutputCase(m_context, (fmtName + "_" + precName + "_uvec3").c_str(), "", fboSpec, (OutputVec() << FragmentOutput(glu::TYPE_UINT_VEC3, prec, 0)).toVec()));
1247 uintGroup->addChild(new FragmentOutputCase(m_context, (fmtName + "_" + precName + "_uvec4").c_str(), "", fboSpec, (OutputVec() << FragmentOutput(glu::TYPE_UINT_VEC4, prec, 0)).toVec()));
1254 tcu::TestCaseGroup* arrayGroup = new tcu::TestCaseGroup(m_testCtx, "array", "Array outputs");
1255 addChild(arrayGroup);
1257 const int width = 64;
1258 const int height = 64;
1259 const int samples = 0;
1260 const int numTargets = 3;
1263 tcu::TestCaseGroup* floatGroup = new tcu::TestCaseGroup(m_testCtx, "float", "Floating-point output tests");
1264 arrayGroup->addChild(floatGroup);
1265 for (int fmtNdx = 0; fmtNdx < DE_LENGTH_OF_ARRAY(requiredFloatFormats); fmtNdx++)
1267 deUint32 format = requiredFloatFormats[fmtNdx];
1268 string fmtName = getFormatName(format);
1269 vector<BufferSpec> fboSpec;
1271 for (int ndx = 0; ndx < numTargets; ndx++)
1272 fboSpec.push_back(BufferSpec(format, width, height, samples));
1274 for (int precNdx = 0; precNdx < DE_LENGTH_OF_ARRAY(precisions); precNdx++)
1276 glu::Precision prec = precisions[precNdx];
1277 string precName = glu::getPrecisionName(prec);
1279 floatGroup->addChild(new FragmentOutputCase(m_context, (fmtName + "_" + precName + "_float").c_str(), "", fboSpec, (OutputVec() << FragmentOutput(glu::TYPE_FLOAT, prec, 0, numTargets)).toVec()));
1280 floatGroup->addChild(new FragmentOutputCase(m_context, (fmtName + "_" + precName + "_vec2").c_str(), "", fboSpec, (OutputVec() << FragmentOutput(glu::TYPE_FLOAT_VEC2, prec, 0, numTargets)).toVec()));
1281 floatGroup->addChild(new FragmentOutputCase(m_context, (fmtName + "_" + precName + "_vec3").c_str(), "", fboSpec, (OutputVec() << FragmentOutput(glu::TYPE_FLOAT_VEC3, prec, 0, numTargets)).toVec()));
1282 floatGroup->addChild(new FragmentOutputCase(m_context, (fmtName + "_" + precName + "_vec4").c_str(), "", fboSpec, (OutputVec() << FragmentOutput(glu::TYPE_FLOAT_VEC4, prec, 0, numTargets)).toVec()));
1287 tcu::TestCaseGroup* fixedGroup = new tcu::TestCaseGroup(m_testCtx, "fixed", "Fixed-point output tests");
1288 arrayGroup->addChild(fixedGroup);
1289 for (int fmtNdx = 0; fmtNdx < DE_LENGTH_OF_ARRAY(requiredFixedFormats); fmtNdx++)
1291 deUint32 format = requiredFixedFormats[fmtNdx];
1292 string fmtName = getFormatName(format);
1293 vector<BufferSpec> fboSpec;
1295 for (int ndx = 0; ndx < numTargets; ndx++)
1296 fboSpec.push_back(BufferSpec(format, width, height, samples));
1298 for (int precNdx = 0; precNdx < DE_LENGTH_OF_ARRAY(precisions); precNdx++)
1300 glu::Precision prec = precisions[precNdx];
1301 string precName = glu::getPrecisionName(prec);
1303 fixedGroup->addChild(new FragmentOutputCase(m_context, (fmtName + "_" + precName + "_float").c_str(), "", fboSpec, (OutputVec() << FragmentOutput(glu::TYPE_FLOAT, prec, 0, numTargets)).toVec()));
1304 fixedGroup->addChild(new FragmentOutputCase(m_context, (fmtName + "_" + precName + "_vec2").c_str(), "", fboSpec, (OutputVec() << FragmentOutput(glu::TYPE_FLOAT_VEC2, prec, 0, numTargets)).toVec()));
1305 fixedGroup->addChild(new FragmentOutputCase(m_context, (fmtName + "_" + precName + "_vec3").c_str(), "", fboSpec, (OutputVec() << FragmentOutput(glu::TYPE_FLOAT_VEC3, prec, 0, numTargets)).toVec()));
1306 fixedGroup->addChild(new FragmentOutputCase(m_context, (fmtName + "_" + precName + "_vec4").c_str(), "", fboSpec, (OutputVec() << FragmentOutput(glu::TYPE_FLOAT_VEC4, prec, 0, numTargets)).toVec()));
1311 tcu::TestCaseGroup* intGroup = new tcu::TestCaseGroup(m_testCtx, "int", "Integer output tests");
1312 arrayGroup->addChild(intGroup);
1313 for (int fmtNdx = 0; fmtNdx < DE_LENGTH_OF_ARRAY(requiredIntFormats); fmtNdx++)
1315 deUint32 format = requiredIntFormats[fmtNdx];
1316 string fmtName = getFormatName(format);
1317 vector<BufferSpec> fboSpec;
1319 for (int ndx = 0; ndx < numTargets; ndx++)
1320 fboSpec.push_back(BufferSpec(format, width, height, samples));
1322 for (int precNdx = 0; precNdx < DE_LENGTH_OF_ARRAY(precisions); precNdx++)
1324 glu::Precision prec = precisions[precNdx];
1325 string precName = glu::getPrecisionName(prec);
1327 intGroup->addChild(new FragmentOutputCase(m_context, (fmtName + "_" + precName + "_int").c_str(), "", fboSpec, (OutputVec() << FragmentOutput(glu::TYPE_INT, prec, 0, numTargets)).toVec()));
1328 intGroup->addChild(new FragmentOutputCase(m_context, (fmtName + "_" + precName + "_ivec2").c_str(), "", fboSpec, (OutputVec() << FragmentOutput(glu::TYPE_INT_VEC2, prec, 0, numTargets)).toVec()));
1329 intGroup->addChild(new FragmentOutputCase(m_context, (fmtName + "_" + precName + "_ivec3").c_str(), "", fboSpec, (OutputVec() << FragmentOutput(glu::TYPE_INT_VEC3, prec, 0, numTargets)).toVec()));
1330 intGroup->addChild(new FragmentOutputCase(m_context, (fmtName + "_" + precName + "_ivec4").c_str(), "", fboSpec, (OutputVec() << FragmentOutput(glu::TYPE_INT_VEC4, prec, 0, numTargets)).toVec()));
1335 tcu::TestCaseGroup* uintGroup = new tcu::TestCaseGroup(m_testCtx, "uint", "Usigned integer output tests");
1336 arrayGroup->addChild(uintGroup);
1337 for (int fmtNdx = 0; fmtNdx < DE_LENGTH_OF_ARRAY(requiredUintFormats); fmtNdx++)
1339 deUint32 format = requiredUintFormats[fmtNdx];
1340 string fmtName = getFormatName(format);
1341 vector<BufferSpec> fboSpec;
1343 for (int ndx = 0; ndx < numTargets; ndx++)
1344 fboSpec.push_back(BufferSpec(format, width, height, samples));
1346 for (int precNdx = 0; precNdx < DE_LENGTH_OF_ARRAY(precisions); precNdx++)
1348 glu::Precision prec = precisions[precNdx];
1349 string precName = glu::getPrecisionName(prec);
1351 uintGroup->addChild(new FragmentOutputCase(m_context, (fmtName + "_" + precName + "_uint").c_str(), "", fboSpec, (OutputVec() << FragmentOutput(glu::TYPE_UINT, prec, 0, numTargets)).toVec()));
1352 uintGroup->addChild(new FragmentOutputCase(m_context, (fmtName + "_" + precName + "_uvec2").c_str(), "", fboSpec, (OutputVec() << FragmentOutput(glu::TYPE_UINT_VEC2, prec, 0, numTargets)).toVec()));
1353 uintGroup->addChild(new FragmentOutputCase(m_context, (fmtName + "_" + precName + "_uvec3").c_str(), "", fboSpec, (OutputVec() << FragmentOutput(glu::TYPE_UINT_VEC3, prec, 0, numTargets)).toVec()));
1354 uintGroup->addChild(new FragmentOutputCase(m_context, (fmtName + "_" + precName + "_uvec4").c_str(), "", fboSpec, (OutputVec() << FragmentOutput(glu::TYPE_UINT_VEC4, prec, 0, numTargets)).toVec()));
1361 tcu::TestCaseGroup* randomGroup = new tcu::TestCaseGroup(m_testCtx, "random", "Random fragment output cases");
1362 addChild(randomGroup);
1364 for (deUint32 seed = 0; seed < 100; seed++)
1365 randomGroup->addChild(createRandomCase(m_context, 2, 4, seed));