1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL (ES) 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 Attribute location tests
22 *//*--------------------------------------------------------------------*/
24 #include "glsAttributeLocationTests.hpp"
26 #include "tcuStringTemplate.hpp"
27 #include "tcuTestLog.hpp"
29 #include "gluDefs.hpp"
30 #include "gluRenderContext.hpp"
31 #include "gluShaderProgram.hpp"
32 #include "gluShaderUtil.hpp"
33 #include "gluStrUtil.hpp"
35 #include "glwFunctions.hpp"
37 #include "deStringUtil.hpp"
57 using namespace deqp::gls::AttributeLocationTestUtil;
66 deInt32 getBoundLocation (const map<string, deUint32>& bindings, const string& attrib)
68 std::map<string, deUint32>::const_iterator iter = bindings.find(attrib);
70 return (iter == bindings.end() ? (deInt32)Attribute::LOC_UNDEF : iter->second);
73 bool hasAttributeAliasing (const vector<Attribute>& attributes, const map<string, deUint32>& bindings)
75 vector<bool> reservedSpaces;
77 for (int attribNdx = 0; attribNdx < (int)attributes.size(); attribNdx++)
79 const deInt32 location = getBoundLocation(bindings, attributes[attribNdx].getName());
80 const deUint32 size = attributes[attribNdx].getType().getLocationSize();
82 if (location != Attribute::LOC_UNDEF)
84 if (reservedSpaces.size() < location + size)
85 reservedSpaces.resize(location + size, false);
87 for (int i = 0; i < (int)size; i++)
89 if (reservedSpaces[location + i])
92 reservedSpaces[location + i] = true;
100 deInt32 getMaxAttributeLocations (glu::RenderContext& renderCtx)
102 const glw::Functions& gl = renderCtx.getFunctions();
105 gl.getIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxAttribs);
106 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv()");
111 string generateAttributeDefinitions (const vector<Attribute>& attributes)
113 std::ostringstream src;
115 for (vector<Attribute>::const_iterator iter = attributes.begin(); iter != attributes.end(); ++iter)
117 if (iter->getLayoutLocation() != Attribute::LOC_UNDEF)
118 src << "layout(location = " << iter->getLayoutLocation() << ") ";
120 src << "${VTX_INPUT} mediump "
121 << iter->getType().getName() << " "
123 << (iter->getArraySize() != Attribute::NOT_ARRAY ? "[" + de::toString(iter->getArraySize()) + "]" : "") << ";\n";
129 string generateConditionUniformDefinitions (const vector<Attribute>& attributes)
131 std::ostringstream src;
132 set<string> conditions;
134 for (vector<Attribute>::const_iterator iter = attributes.begin(); iter != attributes.end(); ++iter)
136 if (iter->getCondition() != Cond::COND_NEVER && iter->getCondition() != Cond::COND_ALWAYS)
137 conditions.insert(iter->getCondition().getName());
140 for (set<string>::const_iterator iter = conditions.begin(); iter != conditions.end(); ++iter)
141 src << "uniform mediump float u_" << (*iter) << ";\n";
146 string generateToVec4Expression (const Attribute& attrib, int id=-1)
148 const string variableName(attrib.getName() + (attrib.getArraySize() != Attribute::NOT_ARRAY ? "[" + de::toString(id) + "]" : ""));
149 std::ostringstream src;
151 switch (attrib.getType().getGLTypeEnum())
154 case GL_UNSIGNED_INT_VEC2:
156 src << "vec4(" << variableName << ".xy, " << variableName << ".yx)";
160 case GL_UNSIGNED_INT_VEC3:
162 src << "vec4(" << variableName << ".xyz, " << variableName << ".x)";
166 src << "vec4(" << variableName << ")";
173 string generateOutputCode (const vector<Attribute>& attributes)
175 std::ostringstream src;
177 for (vector<Attribute>::const_iterator iter = attributes.begin(); iter != attributes.end(); ++iter)
179 if (iter->getCondition() == Cond::COND_NEVER)
185 if (iter->getArraySize() == Attribute::NOT_ARRAY)
186 src << "\t\tcolor += " << generateToVec4Expression(*iter) << ";\n";
189 for (int i = 0; i < iter->getArraySize(); i++)
190 src << "\t\tcolor += " << generateToVec4Expression(*iter, i) << ";\n";
195 else if (iter->getCondition() == Cond::COND_ALWAYS)
197 if (iter->getArraySize() == Attribute::NOT_ARRAY)
198 src << "\tcolor += " << generateToVec4Expression(*iter) << ";\n";
201 for (int i = 0; i < iter->getArraySize(); i++)
202 src << "\tcolor += " << generateToVec4Expression(*iter, i) << ";\n";
208 "\tif (u_" << iter->getCondition().getName() << (iter->getCondition().getNegate() ? " != " : " == ") << "0.0)\n"
211 if (iter->getArraySize() == Attribute::NOT_ARRAY)
212 src << "\t\tcolor += " << generateToVec4Expression(*iter) << ";\n";
215 for (int i = 0; i < iter->getArraySize(); i++)
216 src << "\t\tcolor += " << generateToVec4Expression(*iter, i) << ";\n";
227 string generateVertexShaderTemplate (const vector<Attribute>& attributes)
229 std::ostringstream src;
231 src << "${VERSION}\n"
232 "${VTX_OUTPUT} mediump vec4 v_color;\n";
234 src << generateAttributeDefinitions(attributes)
236 << generateConditionUniformDefinitions(attributes)
239 src << "void main (void)\n"
241 "\tmediump vec4 color = vec4(0.0);\n"
244 src << generateOutputCode(attributes);
247 "\tv_color = color;\n"
248 "\tgl_Position = color;\n"
254 string createVertexShaderSource (glu::RenderContext& renderCtx, const vector<Attribute>& attributes, bool attributeAliasing)
256 // \note On GLES only GLSL #version 100 supports aliasing
257 const glu::GLSLVersion contextGLSLVersion = glu::getContextTypeGLSLVersion(renderCtx.getType());
258 const glu::GLSLVersion glslVersion = (attributeAliasing && glu::glslVersionIsES(contextGLSLVersion) ? glu::GLSL_VERSION_100_ES : contextGLSLVersion);
259 const bool usesInOutQualifiers = glu::glslVersionUsesInOutQualifiers(glslVersion);
260 const tcu::StringTemplate vertexShaderTemplate(generateVertexShaderTemplate(attributes));
262 map<string, string> parameters;
264 parameters["VERSION"] = glu::getGLSLVersionDeclaration(glslVersion);
265 parameters["VTX_OUTPUT"] = (usesInOutQualifiers ? "out" : "varying");
266 parameters["VTX_INPUT"] = (usesInOutQualifiers ? "in" : "attribute");
267 parameters["FRAG_INPUT"] = (usesInOutQualifiers ? "in" : "varying");
268 parameters["FRAG_OUTPUT_VAR"] = (usesInOutQualifiers ? "dEQP_FragColor" : "gl_FragColor");
269 parameters["FRAG_OUTPUT_DECLARATION"] = (usesInOutQualifiers
270 ? "layout(location=0) out mediump vec4 dEQP_FragColor;"
273 return vertexShaderTemplate.specialize(parameters);
276 string createFragmentShaderSource (glu::RenderContext& renderCtx, bool attributeAliasing)
278 const char* const fragmentShaderSource =
280 "${FRAG_OUTPUT_DECLARATION}\n"
281 "${FRAG_INPUT} mediump vec4 v_color;\n"
284 "\t${FRAG_OUTPUT_VAR} = v_color;\n"
287 // \note On GLES only GLSL #version 100 supports aliasing
288 const glu::GLSLVersion contextGLSLVersion = glu::getContextTypeGLSLVersion(renderCtx.getType());
289 const glu::GLSLVersion glslVersion = (attributeAliasing && glu::glslVersionIsES(contextGLSLVersion) ? glu::GLSL_VERSION_100_ES : contextGLSLVersion);
290 const tcu::StringTemplate fragmentShaderTemplate(fragmentShaderSource);
291 const bool usesInOutQualifiers = glu::glslVersionUsesInOutQualifiers(glslVersion);
293 map<string, string> parameters;
295 parameters["VERSION"] = glu::getGLSLVersionDeclaration(glslVersion);
296 parameters["VTX_OUTPUT"] = (usesInOutQualifiers ? "out" : "varying");
297 parameters["VTX_INPUT"] = (usesInOutQualifiers ? "in" : "attribute");
298 parameters["FRAG_INPUT"] = (usesInOutQualifiers ? "in" : "varying");
299 parameters["FRAG_OUTPUT_VAR"] = (usesInOutQualifiers ? "dEQP_FragColor" : "gl_FragColor");
300 parameters["FRAG_OUTPUT_DECLARATION"] = (usesInOutQualifiers
301 ? "layout(location=0) out mediump vec4 dEQP_FragColor;"
304 return fragmentShaderTemplate.specialize(parameters);
307 string getShaderInfoLog (const glw::Functions& gl, deUint32 shader)
312 gl.getShaderiv(shader, GL_INFO_LOG_LENGTH, &length);
313 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv()");
315 infoLog.resize(length, '\0');
317 gl.getShaderInfoLog(shader, (glw::GLsizei)infoLog.length(), DE_NULL, &(infoLog[0]));
318 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderInfoLog()");
323 bool getShaderCompileStatus (const glw::Functions& gl, deUint32 shader)
327 gl.getShaderiv(shader, GL_COMPILE_STATUS, &status);
328 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv()");
330 return status == GL_TRUE;
333 string getProgramInfoLog (const glw::Functions& gl, deUint32 program)
338 gl.getProgramiv(program, GL_INFO_LOG_LENGTH, &length);
339 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramiv()");
341 infoLog.resize(length, '\0');
343 gl.getProgramInfoLog(program, (glw::GLsizei)infoLog.length(), DE_NULL, &(infoLog[0]));
344 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramInfoLog()");
349 bool getProgramLinkStatus (const glw::Functions& gl, deUint32 program)
353 gl.getProgramiv(program, GL_LINK_STATUS, &status);
354 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramiv()");
356 return status == GL_TRUE;
359 void logProgram (TestLog& log, const glw::Functions& gl, deUint32 program)
361 const bool programLinkOk = getProgramLinkStatus(gl, program);
362 const string programInfoLog = getProgramInfoLog(gl, program);
363 tcu::ScopedLogSection linkInfo (log, "Program Link Info", "Program Link Info");
366 tcu::ScopedLogSection infoLogSection(log, "Info Log", "Info Log");
368 log << TestLog::Message << programInfoLog << TestLog::EndMessage;
371 log << TestLog::Message << "Link result: " << (programLinkOk ? "Ok" : "Fail") << TestLog::EndMessage;
374 void logShaders (TestLog& log,
375 const string& vertexShaderSource,
376 const string& vertexShaderInfoLog,
377 bool vertexCompileOk,
378 const string& fragmentShaderSource,
379 const string& fragmentShaderInfoLog,
380 bool fragmentCompileOk)
382 // \todo [mika] Log as real shader elements. Currently not supported by TestLog.
384 tcu::ScopedLogSection shaderSection(log, "Vertex Shader Info", "Vertex Shader Info");
386 log << TestLog::KernelSource(vertexShaderSource);
389 tcu::ScopedLogSection infoLogSection(log, "Info Log", "Info Log");
391 log << TestLog::Message << vertexShaderInfoLog << TestLog::EndMessage;
394 log << TestLog::Message << "Compilation result: " << (vertexCompileOk ? "Ok" : "Failed") << TestLog::EndMessage;
398 tcu::ScopedLogSection shaderSection(log, "Fragment Shader Info", "Fragment Shader Info");
400 log << TestLog::KernelSource(fragmentShaderSource);
403 tcu::ScopedLogSection infoLogSection(log, "Info Log", "Info Log");
405 log << TestLog::Message << fragmentShaderInfoLog << TestLog::EndMessage;
408 log << TestLog::Message << "Compilation result: " << (fragmentCompileOk ? "Ok" : "Failed") << TestLog::EndMessage;
412 pair<deUint32, deUint32> createAndAttachShaders (TestLog& log, glu::RenderContext& renderCtx, deUint32 program, const vector<Attribute>& attributes, bool attributeAliasing)
414 const glw::Functions& gl = renderCtx.getFunctions();
415 const string vertexShaderSource = createVertexShaderSource(renderCtx, attributes, attributeAliasing);
416 const string fragmentShaderSource = createFragmentShaderSource(renderCtx, attributeAliasing);
418 const deUint32 vertexShader = gl.createShader(GL_VERTEX_SHADER);
419 const deUint32 fragmentShader = gl.createShader(GL_FRAGMENT_SHADER);
423 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateShader()");
426 const char* const vertexShaderString = vertexShaderSource.c_str();
427 const char* const fragmentShaderString = fragmentShaderSource.c_str();
429 gl.shaderSource(vertexShader, 1, &vertexShaderString, DE_NULL);
430 gl.shaderSource(fragmentShader, 1, &fragmentShaderString, DE_NULL);
432 GLU_EXPECT_NO_ERROR(gl.getError(), "glShaderSource()");
435 gl.compileShader(vertexShader);
436 gl.compileShader(fragmentShader);
437 GLU_EXPECT_NO_ERROR(gl.getError(), "glCompileShader()");
439 gl.attachShader(program, vertexShader);
440 gl.attachShader(program, fragmentShader);
441 GLU_EXPECT_NO_ERROR(gl.getError(), "glAttachShader()");
444 const bool vertexCompileOk = getShaderCompileStatus(gl, vertexShader);
445 const bool fragmentCompileOk = getShaderCompileStatus(gl, fragmentShader);
447 const string vertexShaderInfoLog = getShaderInfoLog(gl, vertexShader);
448 const string fragmentShaderInfoLog = getShaderInfoLog(gl, fragmentShader);
450 logShaders(log, vertexShaderSource, vertexShaderInfoLog, vertexCompileOk, fragmentShaderSource, fragmentShaderInfoLog, fragmentCompileOk);
452 TCU_CHECK_MSG(vertexCompileOk, "Vertex shader compilation failed");
453 TCU_CHECK_MSG(fragmentCompileOk, "Fragment shader compilation failed");
456 gl.deleteShader(vertexShader);
457 gl.deleteShader(fragmentShader);
459 return pair<deUint32, deUint32>(vertexShader, fragmentShader);
463 if (vertexShader != 0)
464 gl.deleteShader(vertexShader);
466 if (fragmentShader != 0)
467 gl.deleteShader(fragmentShader);
473 void bindAttributes (TestLog& log, const glw::Functions& gl, deUint32 program, const vector<Bind>& binds)
475 for (vector<Bind>::const_iterator iter = binds.begin(); iter != binds.end(); ++iter)
477 log << TestLog::Message << "Bind attribute: '" << iter->getAttributeName() << "' to " << iter->getLocation() << TestLog::EndMessage;
478 gl.bindAttribLocation(program, iter->getLocation(), iter->getAttributeName().c_str());
479 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindAttribLocation()");
483 void logAttributes (TestLog& log, const vector<Attribute>& attributes)
485 for (int attribNdx = 0; attribNdx < (int)attributes.size(); attribNdx++)
487 const Attribute& attrib = attributes[attribNdx];
489 log << TestLog::Message
490 << "Type: " << attrib.getType().getName()
491 << ", Name: " << attrib.getName()
492 << (attrib.getLayoutLocation() != Attribute::LOC_UNDEF ? ", Layout location " + de::toString(attrib.getLayoutLocation()) : "")
493 << TestLog::EndMessage;
497 bool checkActiveAttribQuery (TestLog& log, const glw::Functions& gl, deUint32 program, const vector<Attribute>& attributes)
499 deInt32 activeAttribCount = 0;
500 set<string> activeAttributes;
503 gl.getProgramiv(program, GL_ACTIVE_ATTRIBUTES, &activeAttribCount);
504 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramiv(program, GL_ACTIVE_ATTRIBUTES, &activeAttribCount)");
506 for (int activeAttribNdx = 0; activeAttribNdx < activeAttribCount; activeAttribNdx++)
509 const size_t maxNameSize = DE_LENGTH_OF_ARRAY(name) - 1;
514 std::memset(name, 0, sizeof(name));
516 gl.getActiveAttrib(program, activeAttribNdx, maxNameSize, &length, &size, &type, name);
517 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetActiveAttrib()");
519 log << TestLog::Message
520 << "glGetActiveAttrib(program"
521 << ", index=" << activeAttribNdx
522 << ", bufSize=" << maxNameSize
523 << ", length=" << length
525 << ", type=" << glu::getShaderVarTypeStr(type)
526 << ", name='" << name << "')" << TestLog::EndMessage;
531 for (int attribNdx = 0; attribNdx < (int)attributes.size(); attribNdx++)
533 const Attribute& attrib = attributes[attribNdx];
535 if (attrib.getName() == name)
537 if (type != attrib.getType().getGLTypeEnum())
539 log << TestLog::Message
540 << "Error: Wrong type " << glu::getShaderVarTypeStr(type)
541 << " expected " << glu::getShaderVarTypeStr(attrib.getType().getGLTypeEnum())
542 << TestLog::EndMessage;
547 if (attrib.getArraySize() == Attribute::NOT_ARRAY)
551 log << TestLog::Message << "Error: Wrong size " << size << " expected " << 1 << TestLog::EndMessage;
557 if (size != attrib.getArraySize())
559 log << TestLog::Message << "Error: Wrong size " << size << " expected " << attrib.getArraySize() << TestLog::EndMessage;
571 log << TestLog::Message << "Error: Unknown attribute '" << name << "' returned by glGetActiveAttrib()." << TestLog::EndMessage;
576 activeAttributes.insert(name);
579 for (int attribNdx = 0; attribNdx < (int)attributes.size(); attribNdx++)
581 const Attribute& attrib = attributes[attribNdx];
582 const bool isActive = attrib.getCondition() != Cond::COND_NEVER;
586 if (activeAttributes.find(attrib.getName()) == activeAttributes.end())
588 log << TestLog::Message << "Error: Active attribute " << attrib.getName() << " wasn't returned by glGetActiveAttrib()." << TestLog::EndMessage;
594 if (activeAttributes.find(attrib.getName()) != activeAttributes.end())
595 log << TestLog::Message << "Note: Inactive attribute " << attrib.getName() << " was returned by glGetActiveAttrib()." << TestLog::EndMessage;
602 bool checkAttribLocationQuery (TestLog& log, const glw::Functions& gl, deUint32 program, const vector<Attribute>& attributes, const map<string, deUint32>& bindings)
606 for (int attribNdx = 0; attribNdx < (int)attributes.size(); attribNdx++)
608 const Attribute& attrib = attributes[attribNdx];
609 const deInt32 expectedLocation = (attrib.getLayoutLocation() != Attribute::LOC_UNDEF ? attrib.getLayoutLocation() : getBoundLocation(bindings, attrib.getName()));
610 const deInt32 location = gl.getAttribLocation(program, attrib.getName().c_str());
612 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation()");
614 log << TestLog::Message
615 << location << " = glGetAttribLocation(program, \"" << attrib.getName() << "\")"
616 << (attrib.getCondition() != Cond::COND_NEVER && expectedLocation != Attribute::LOC_UNDEF ? ", expected " + de::toString(expectedLocation) : "")
617 << "." << TestLog::EndMessage;
619 if (attrib.getCondition() == Cond::COND_NEVER && location != -1)
620 log << TestLog::Message << "\tNote: Inactive attribute with location." << TestLog::EndMessage;
622 if (attrib.getCondition() != Cond::COND_NEVER && expectedLocation != Attribute::LOC_UNDEF && expectedLocation != location)
623 log << TestLog::Message << "\tError: Invalid attribute location." << TestLog::EndMessage;
625 isOk &= (attrib.getCondition() == Cond::COND_NEVER || expectedLocation == Attribute::LOC_UNDEF || expectedLocation == location);
631 bool checkQuery (TestLog& log, const glw::Functions& gl, deUint32 program, const vector<Attribute>& attributes, const map<string, deUint32>& bindings)
633 bool isOk = checkActiveAttribQuery(log, gl, program, attributes);
635 if (!checkAttribLocationQuery(log, gl, program, attributes, bindings))
641 string generateTestName (const AttribType& type, int arraySize)
643 return type.getName() + (arraySize != Attribute::NOT_ARRAY ? "_array_" + de::toString(arraySize) : "");
648 namespace AttributeLocationTestUtil
651 AttribType::AttribType (const string& name, deUint32 localSize, deUint32 typeEnum)
653 , m_locationSize (localSize)
654 , m_glTypeEnum (typeEnum)
658 Cond::Cond (const string& name, bool negate)
664 Cond::Cond (ConstCond cond)
665 : m_negate (cond != COND_NEVER)
666 , m_name ("__always__")
668 DE_ASSERT(cond == COND_ALWAYS || cond == COND_NEVER);
671 Attribute::Attribute (const AttribType& type, const string& name, deInt32 layoutLocation, const Cond& cond, int arraySize)
674 , m_layoutLocation (layoutLocation)
676 , m_arraySize (arraySize)
680 Bind::Bind (const std::string& attribute, deUint32 location)
681 : m_attribute (attribute)
682 , m_location (location)
686 void runTest (tcu::TestContext& testCtx,
687 glu::RenderContext& renderCtx,
688 const vector<Attribute>& attributes,
689 const vector<Bind>& preAttachBind,
690 const vector<Bind>& preLinkBind,
691 const vector<Bind>& postLinkBind,
693 bool reattach = false,
694 const vector<Attribute>& reattachAttributes = vector<Attribute>())
696 TestLog& log = testCtx.getLog();
697 const glw::Functions& gl = renderCtx.getFunctions();
698 deUint32 program = 0;
699 pair<deUint32, deUint32> shaders;
704 map<string, deUint32> activeBindings;
706 for (int bindNdx = 0; bindNdx < (int)preAttachBind.size(); bindNdx++)
707 activeBindings[preAttachBind[bindNdx].getAttributeName()] = preAttachBind[bindNdx].getLocation();
709 for (int bindNdx = 0; bindNdx < (int)preLinkBind.size(); bindNdx++)
710 activeBindings[preLinkBind[bindNdx].getAttributeName()] = preLinkBind[bindNdx].getLocation();
713 tcu::ScopedLogSection section(log, "Attributes", "Attribute information");
714 logAttributes(testCtx.getLog(), attributes);
717 log << TestLog::Message << "Create program." << TestLog::EndMessage;
718 program = gl.createProgram();
719 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateProgram()");
721 if (!preAttachBind.empty())
722 bindAttributes(log, gl, program, preAttachBind);
724 log << TestLog::Message << "Create and attach shaders to program." << TestLog::EndMessage;
725 shaders = createAndAttachShaders(log, renderCtx, program, attributes, hasAttributeAliasing(attributes, activeBindings));
727 if (!preLinkBind.empty())
728 bindAttributes(log, gl, program, preLinkBind);
730 log << TestLog::Message << "Link program." << TestLog::EndMessage;
732 gl.linkProgram(program);
733 GLU_EXPECT_NO_ERROR(gl.getError(), "glLinkProgram()");
735 logProgram(log, gl, program);
736 TCU_CHECK_MSG(getProgramLinkStatus(gl, program), "Program link failed");
738 if (!checkQuery(log, gl, program, attributes, activeBindings))
741 if (!postLinkBind.empty())
743 bindAttributes(log, gl, program, postLinkBind);
745 if (!checkQuery(log, gl, program, attributes, activeBindings))
751 log << TestLog::Message << "Relink program." << TestLog::EndMessage;
752 gl.linkProgram(program);
753 GLU_EXPECT_NO_ERROR(gl.getError(), "glLinkProgram()");
755 logProgram(log, gl, program);
756 TCU_CHECK_MSG(getProgramLinkStatus(gl, program), "Program link failed");
758 for (int bindNdx = 0; bindNdx < (int)postLinkBind.size(); bindNdx++)
759 activeBindings[postLinkBind[bindNdx].getAttributeName()] = postLinkBind[bindNdx].getLocation();
761 if (!checkQuery(log, gl, program, attributes, activeBindings))
767 gl.detachShader(program, shaders.first);
768 gl.detachShader(program, shaders.second);
769 GLU_EXPECT_NO_ERROR(gl.getError(), "glDetachShader()");
771 log << TestLog::Message << "Create and attach shaders to program." << TestLog::EndMessage;
772 createAndAttachShaders(log, renderCtx, program, reattachAttributes, hasAttributeAliasing(reattachAttributes, activeBindings));
774 log << TestLog::Message << "Relink program." << TestLog::EndMessage;
775 gl.linkProgram(program);
776 GLU_EXPECT_NO_ERROR(gl.getError(), "glLinkProgram()");
778 logProgram(log, gl, program);
779 TCU_CHECK_MSG(getProgramLinkStatus(gl, program), "Program link failed");
781 if (!checkQuery(log, gl, program, reattachAttributes, activeBindings))
785 gl.deleteProgram(program);
786 GLU_EXPECT_NO_ERROR(gl.getError(), "glDeleteProgram()");
789 testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
791 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
796 gl.deleteProgram(program);
802 } // AttributeLocationTestUtil
804 BindAttributeTest::BindAttributeTest (tcu::TestContext& testCtx,
805 glu::RenderContext& renderCtx,
806 const AttribType& type,
808 : TestCase (testCtx, generateTestName(type, arraySize).c_str(), generateTestName(type, arraySize).c_str())
809 , m_renderCtx (renderCtx)
811 , m_arraySize (arraySize)
815 tcu::TestCase::IterateResult BindAttributeTest::iterate (void)
817 const vector<Bind> noBindings;
819 vector<Attribute> attributes;
820 vector<Bind> bindings;
822 attributes.push_back(Attribute(m_type, "a_0", Attribute::LOC_UNDEF, Cond::COND_ALWAYS, m_arraySize));
823 bindings.push_back(Bind("a_0", 3));
825 runTest(m_testCtx, m_renderCtx, attributes, noBindings, bindings, noBindings, false);
829 BindMaxAttributesTest::BindMaxAttributesTest (tcu::TestContext& testCtx,
830 glu::RenderContext& renderCtx,
831 const AttribType& type,
833 : TestCase (testCtx, generateTestName(type, arraySize).c_str(), generateTestName(type, arraySize).c_str())
834 , m_renderCtx (renderCtx)
836 , m_arraySize (arraySize)
840 tcu::TestCase::IterateResult BindMaxAttributesTest::iterate (void)
842 const vector<Bind> noBindings;
843 const deInt32 maxAttributes = getMaxAttributeLocations(m_renderCtx);
844 const int arrayElementCount = (m_arraySize != Attribute::NOT_ARRAY ? m_arraySize : 1);
846 vector<Attribute> attributes;
847 vector<Bind> bindings;
850 m_testCtx.getLog() << TestLog::Message << "GL_MAX_VERTEX_ATTRIBS: " << maxAttributes << TestLog::EndMessage;
852 for (int loc = maxAttributes - (arrayElementCount * m_type.getLocationSize()); loc >= 0; loc -= (arrayElementCount * m_type.getLocationSize()))
854 attributes.push_back(Attribute(m_type, "a_" + de::toString(ndx), Attribute::LOC_UNDEF, Cond::COND_ALWAYS, m_arraySize));
855 bindings.push_back(Bind("a_" + de::toString(ndx), loc));
859 runTest(m_testCtx, m_renderCtx, attributes, noBindings, bindings, noBindings, false);
863 BindAliasingAttributeTest::BindAliasingAttributeTest (tcu::TestContext& testCtx,
864 glu::RenderContext& renderCtx,
865 const AttribType& type,
868 : TestCase (testCtx, ("cond_" + generateTestName(type, arraySize) + (offset != 0 ? "_offset_" + de::toString(offset) : "")).c_str(),
869 ("cond_" + generateTestName(type, arraySize) + (offset != 0 ? "_offset_" + de::toString(offset) : "")).c_str())
870 , m_renderCtx (renderCtx)
873 , m_arraySize (arraySize)
877 tcu::TestCase::IterateResult BindAliasingAttributeTest::iterate (void)
879 const vector<Bind> noBindings;
881 vector<Attribute> attributes;
882 vector<Bind> bindings;
884 attributes.push_back(Attribute(m_type, "a_0", Attribute::LOC_UNDEF, Cond("A", true), m_arraySize));
885 attributes.push_back(Attribute(AttribType("vec4", 1, GL_FLOAT_VEC4), "a_1", Attribute::LOC_UNDEF, Cond("A", false)));
886 bindings.push_back(Bind("a_0", 1));
887 bindings.push_back(Bind("a_1", 1 + m_offset));
889 runTest(m_testCtx, m_renderCtx, attributes, noBindings, bindings, noBindings, false);
893 BindMaxAliasingAttributeTest::BindMaxAliasingAttributeTest (tcu::TestContext& testCtx,
894 glu::RenderContext& renderCtx,
895 const AttribType& type,
897 : TestCase (testCtx, ("max_cond_" + generateTestName(type, arraySize)).c_str(), ("max_cond_" + generateTestName(type, arraySize)).c_str())
898 , m_renderCtx (renderCtx)
900 , m_arraySize (arraySize)
904 tcu::TestCase::IterateResult BindMaxAliasingAttributeTest::iterate (void)
906 const vector<Bind> noBindings;
907 const deInt32 maxAttributes = getMaxAttributeLocations(m_renderCtx);
908 const int arrayElementCount = (m_arraySize != Attribute::NOT_ARRAY ? m_arraySize : 1);
910 vector<Attribute> attributes;
911 vector<Bind> bindings;
914 m_testCtx.getLog() << TestLog::Message << "GL_MAX_VERTEX_ATTRIBS: " << maxAttributes << TestLog::EndMessage;
916 for (int loc = maxAttributes - arrayElementCount * m_type.getLocationSize(); loc >= 0; loc -= m_type.getLocationSize() * arrayElementCount)
918 attributes.push_back(Attribute(m_type, "a_" + de::toString(ndx), Attribute::LOC_UNDEF, Cond("A", true)));
919 bindings.push_back(Bind("a_" + de::toString(ndx), loc));
921 attributes.push_back(Attribute(m_type, "a_" + de::toString(ndx + maxAttributes), Attribute::LOC_UNDEF, Cond("A", false)));
922 bindings.push_back(Bind("a_" + de::toString(ndx + maxAttributes), loc));
926 runTest(m_testCtx, m_renderCtx, attributes, noBindings, bindings, noBindings, false);
930 BindHoleAttributeTest::BindHoleAttributeTest (tcu::TestContext& testCtx,
931 glu::RenderContext& renderCtx,
932 const AttribType& type,
934 : TestCase (testCtx, generateTestName(type, arraySize).c_str(), generateTestName(type, arraySize).c_str())
935 , m_renderCtx (renderCtx)
937 , m_arraySize (arraySize)
941 tcu::TestCase::IterateResult BindHoleAttributeTest::iterate (void)
943 const vector<Bind> noBindings;
944 const deInt32 maxAttributes = getMaxAttributeLocations(m_renderCtx);
945 const AttribType vec4("vec4", 1, GL_FLOAT_VEC4);
946 const int arrayElementCount = (m_arraySize != Attribute::NOT_ARRAY ? m_arraySize : 1);
948 vector<Attribute> attributes;
949 vector<Bind> bindings;
952 attributes.push_back(Attribute(vec4, "a_0"));
953 bindings.push_back(Bind("a_0", 0));
955 attributes.push_back(Attribute(m_type, "a_1", Attribute::LOC_UNDEF, Cond::COND_ALWAYS, m_arraySize));
958 for (int loc = 1 + m_type.getLocationSize() * arrayElementCount; loc < maxAttributes; loc++)
960 attributes.push_back(Attribute(vec4, "a_" + de::toString(ndx)));
961 bindings.push_back(Bind("a_" + de::toString(ndx), loc));
966 runTest(m_testCtx, m_renderCtx, attributes, noBindings, bindings, noBindings, false);
970 BindInactiveAliasingAttributeTest::BindInactiveAliasingAttributeTest (tcu::TestContext& testCtx,
971 glu::RenderContext& renderCtx,
972 const AttribType& type,
974 : TestCase (testCtx, ("max_inactive_" + generateTestName(type, arraySize)).c_str(),
975 ("max_inactive_" + generateTestName(type, arraySize)).c_str())
976 , m_renderCtx (renderCtx)
978 , m_arraySize (arraySize)
982 tcu::TestCase::IterateResult BindInactiveAliasingAttributeTest::iterate (void)
984 const vector<Bind> noBindings;
985 const deInt32 maxAttributes = getMaxAttributeLocations(m_renderCtx);
986 const int arrayElementCount = (m_arraySize != Attribute::NOT_ARRAY ? m_arraySize : 1);
988 vector<Attribute> attributes;
989 vector<Bind> bindings;
992 m_testCtx.getLog() << TestLog::Message << "GL_MAX_VERTEX_ATTRIBS: " << maxAttributes << TestLog::EndMessage;
994 for (int loc = maxAttributes - arrayElementCount * m_type.getLocationSize(); loc >= 0; loc -= m_type.getLocationSize() * arrayElementCount)
996 attributes.push_back(Attribute(m_type, "a_" + de::toString(ndx), Attribute::LOC_UNDEF, Cond("A")));
997 bindings.push_back(Bind("a_" + de::toString(ndx), loc));
999 attributes.push_back(Attribute(m_type, "a_" + de::toString(ndx + maxAttributes), Attribute::LOC_UNDEF, Cond::COND_NEVER));
1000 bindings.push_back(Bind("a_" + de::toString(ndx + maxAttributes), loc));
1004 runTest(m_testCtx, m_renderCtx, attributes, noBindings, bindings, noBindings, false);
1008 PreAttachBindAttributeTest::PreAttachBindAttributeTest (tcu::TestContext& testCtx,
1009 glu::RenderContext& renderCtx)
1010 : TestCase (testCtx, "pre_attach", "pre_attach")
1011 , m_renderCtx (renderCtx)
1015 tcu::TestCase::IterateResult PreAttachBindAttributeTest::iterate (void)
1017 const vector<Bind> noBindings;
1019 vector<Attribute> attributes;
1020 vector<Bind> bindings;
1022 attributes.push_back(Attribute(AttribType("vec4", 1, GL_FLOAT_VEC4), "a_0"));
1023 bindings.push_back(Bind("a_0", 3));
1025 runTest(m_testCtx, m_renderCtx, attributes, bindings, noBindings, noBindings, false);
1029 PreLinkBindAttributeTest::PreLinkBindAttributeTest (tcu::TestContext& testCtx,
1030 glu::RenderContext& renderCtx)
1031 : TestCase (testCtx, "pre_link", "pre_link")
1032 , m_renderCtx (renderCtx)
1036 tcu::TestCase::IterateResult PreLinkBindAttributeTest::iterate (void)
1038 const vector<Bind> noBindings;
1040 vector<Attribute> attributes;
1041 vector<Bind> bindings;
1043 attributes.push_back(Attribute(AttribType("vec4", 1, GL_FLOAT_VEC4), "a_0"));
1044 bindings.push_back(Bind("a_0", 3));
1046 runTest(m_testCtx, m_renderCtx, attributes, noBindings, bindings, noBindings, false);
1050 PostLinkBindAttributeTest::PostLinkBindAttributeTest (tcu::TestContext& testCtx,
1051 glu::RenderContext& renderCtx)
1052 : TestCase (testCtx, "post_link", "post_link")
1053 , m_renderCtx (renderCtx)
1057 tcu::TestCase::IterateResult PostLinkBindAttributeTest::iterate (void)
1059 const vector<Bind> noBindings;
1061 vector<Attribute> attributes;
1062 vector<Bind> bindings;
1064 attributes.push_back(Attribute(AttribType("vec4", 1, GL_FLOAT_VEC4), "a_0"));
1065 bindings.push_back(Bind("a_0", 3));
1067 runTest(m_testCtx, m_renderCtx, attributes, noBindings, noBindings, bindings, false);
1071 LocationAttributeTest::LocationAttributeTest (tcu::TestContext& testCtx,
1072 glu::RenderContext& renderCtx,
1073 const AttribType& type,
1075 : TestCase (testCtx, generateTestName(type, arraySize).c_str(), generateTestName(type, arraySize).c_str())
1076 , m_renderCtx (renderCtx)
1078 , m_arraySize (arraySize)
1082 tcu::TestCase::IterateResult LocationAttributeTest::iterate (void)
1084 const vector<Bind> noBindings;
1086 vector<Attribute> attributes;
1088 attributes.push_back(Attribute(m_type, "a_0", 3, Cond::COND_ALWAYS, m_arraySize));
1090 runTest(m_testCtx, m_renderCtx, attributes, noBindings, noBindings, noBindings, false);
1094 LocationMaxAttributesTest::LocationMaxAttributesTest (tcu::TestContext& testCtx,
1095 glu::RenderContext& renderCtx,
1096 const AttribType& type,
1098 : TestCase (testCtx, generateTestName(type, arraySize).c_str(), generateTestName(type, arraySize).c_str())
1099 , m_renderCtx (renderCtx)
1101 , m_arraySize (arraySize)
1105 tcu::TestCase::IterateResult LocationMaxAttributesTest::iterate (void)
1107 const vector<Bind> noBindings;
1108 const deInt32 maxAttributes = getMaxAttributeLocations(m_renderCtx);
1109 const int arrayElementCount = (m_arraySize != Attribute::NOT_ARRAY ? m_arraySize : 1);
1111 vector<Attribute> attributes;
1114 m_testCtx.getLog() << TestLog::Message << "GL_MAX_VERTEX_ATTRIBS: " << maxAttributes << TestLog::EndMessage;
1116 for (int loc = maxAttributes - (arrayElementCount * m_type.getLocationSize()); loc >= 0; loc -= (arrayElementCount * m_type.getLocationSize()))
1118 attributes.push_back(Attribute(m_type, "a_" + de::toString(ndx), loc, Cond::COND_ALWAYS, m_arraySize));
1122 runTest(m_testCtx, m_renderCtx, attributes, noBindings, noBindings, noBindings, false);
1126 LocationHoleAttributeTest::LocationHoleAttributeTest (tcu::TestContext& testCtx,
1127 glu::RenderContext& renderCtx,
1128 const AttribType& type,
1130 : TestCase (testCtx, generateTestName(type, arraySize).c_str(), generateTestName(type, arraySize).c_str())
1131 , m_renderCtx (renderCtx)
1133 , m_arraySize (arraySize)
1137 tcu::TestCase::IterateResult LocationHoleAttributeTest::iterate (void)
1139 const vector<Bind> noBindings;
1140 const deInt32 maxAttributes = getMaxAttributeLocations(m_renderCtx);
1141 const AttribType vec4("vec4", 1, GL_FLOAT_VEC4);
1142 const int arrayElementCount = (m_arraySize != Attribute::NOT_ARRAY ? m_arraySize : 1);
1144 vector<Attribute> attributes;
1147 attributes.push_back(Attribute(vec4, "a_0", 0));
1149 attributes.push_back(Attribute(m_type, "a_1", Attribute::LOC_UNDEF, Cond::COND_ALWAYS, m_arraySize));
1152 for (int loc = 1 + m_type.getLocationSize() * arrayElementCount; loc < maxAttributes; loc++)
1154 attributes.push_back(Attribute(vec4, "a_" + de::toString(ndx), loc));
1158 runTest(m_testCtx, m_renderCtx, attributes, noBindings, noBindings, noBindings, false);
1162 MixedAttributeTest::MixedAttributeTest (tcu::TestContext& testCtx,
1163 glu::RenderContext& renderCtx,
1164 const AttribType& type,
1166 : TestCase (testCtx, generateTestName(type, arraySize).c_str(), generateTestName(type, arraySize).c_str())
1167 , m_renderCtx (renderCtx)
1169 , m_arraySize (arraySize)
1173 tcu::TestCase::IterateResult MixedAttributeTest::iterate (void)
1175 const vector<Bind> noBindings;
1177 vector<Bind> bindings;
1178 vector<Attribute> attributes;
1180 attributes.push_back(Attribute(m_type, "a_0", 3, Cond::COND_ALWAYS, m_arraySize));
1181 bindings.push_back(Bind("a_0", 4));
1183 runTest(m_testCtx, m_renderCtx, attributes, noBindings, bindings, noBindings, false);
1187 MixedMaxAttributesTest::MixedMaxAttributesTest (tcu::TestContext& testCtx,
1188 glu::RenderContext& renderCtx,
1189 const AttribType& type,
1191 : TestCase (testCtx, generateTestName(type, arraySize).c_str(), generateTestName(type, arraySize).c_str())
1192 , m_renderCtx (renderCtx)
1194 , m_arraySize (arraySize)
1198 tcu::TestCase::IterateResult MixedMaxAttributesTest::iterate (void)
1200 const vector<Bind> noBindings;
1201 const deInt32 maxAttributes = getMaxAttributeLocations(m_renderCtx);
1202 const int arrayElementCount = (m_arraySize != Attribute::NOT_ARRAY ? m_arraySize : 1);
1204 vector<Bind> bindings;
1205 vector<Attribute> attributes;
1208 m_testCtx.getLog() << TestLog::Message << "GL_MAX_VERTEX_ATTRIBS: " << maxAttributes << TestLog::EndMessage;
1210 for (int loc = maxAttributes - (arrayElementCount * m_type.getLocationSize()); loc >= 0; loc -= (arrayElementCount * m_type.getLocationSize()))
1213 attributes.push_back(Attribute(m_type, "a_" + de::toString(ndx), loc, Cond::COND_ALWAYS, m_arraySize));
1216 attributes.push_back(Attribute(m_type, "a_" + de::toString(ndx), Attribute::LOC_UNDEF, Cond::COND_ALWAYS, m_arraySize));
1217 bindings.push_back(Bind("a_" + de::toString(ndx), loc));
1223 runTest(m_testCtx, m_renderCtx, attributes, noBindings, bindings, noBindings, false);
1227 MixedHoleAttributeTest::MixedHoleAttributeTest (tcu::TestContext& testCtx,
1228 glu::RenderContext& renderCtx,
1229 const AttribType& type,
1231 : TestCase (testCtx, generateTestName(type, arraySize).c_str(), generateTestName(type, arraySize).c_str())
1232 , m_renderCtx (renderCtx)
1234 , m_arraySize (arraySize)
1238 tcu::TestCase::IterateResult MixedHoleAttributeTest::iterate (void)
1240 const vector<Bind> noBindings;
1241 const deInt32 maxAttributes = getMaxAttributeLocations(m_renderCtx);
1242 const AttribType vec4("vec4", 1, GL_FLOAT_VEC4);
1243 const int arrayElementCount = (m_arraySize != Attribute::NOT_ARRAY ? m_arraySize : 1);
1245 vector<Bind> bindings;
1246 vector<Attribute> attributes;
1249 attributes.push_back(Attribute(vec4, "a_0"));
1250 bindings.push_back(Bind("a_0", 0));
1252 attributes.push_back(Attribute(m_type, "a_1", Attribute::LOC_UNDEF, Cond::COND_ALWAYS, m_arraySize));
1255 for (int loc = 1 + m_type.getLocationSize() * arrayElementCount; loc < maxAttributes; loc++)
1258 attributes.push_back(Attribute(vec4, "a_" + de::toString(ndx), loc));
1261 attributes.push_back(Attribute(vec4, "a_" + de::toString(ndx), loc));
1262 bindings.push_back(Bind("a_" + de::toString(ndx), loc));
1268 runTest(m_testCtx, m_renderCtx, attributes, noBindings, bindings, noBindings, false);
1272 BindRelinkAttributeTest::BindRelinkAttributeTest (tcu::TestContext& testCtx,
1273 glu::RenderContext& renderCtx)
1274 : TestCase (testCtx, "relink", "relink")
1275 , m_renderCtx (renderCtx)
1279 tcu::TestCase::IterateResult BindRelinkAttributeTest::iterate (void)
1281 const vector<Bind> noBindings;
1282 const AttribType vec4("vec4", 1, GL_FLOAT_VEC4);
1284 vector<Attribute> attributes;
1285 vector<Bind> preLinkBindings;
1286 vector<Bind> postLinkBindings;
1288 attributes.push_back(Attribute(vec4, "a_0"));
1289 attributes.push_back(Attribute(vec4, "a_1"));
1291 preLinkBindings.push_back(Bind("a_0", 3));
1292 preLinkBindings.push_back(Bind("a_0", 5));
1294 postLinkBindings.push_back(Bind("a_0", 6));
1296 runTest(m_testCtx, m_renderCtx, attributes, noBindings, preLinkBindings, postLinkBindings, true);
1300 BindRelinkHoleAttributeTest::BindRelinkHoleAttributeTest (tcu::TestContext& testCtx,
1301 glu::RenderContext& renderCtx,
1302 const AttribType& type,
1304 : TestCase (testCtx, generateTestName(type, arraySize).c_str(), generateTestName(type, arraySize).c_str())
1305 , m_renderCtx (renderCtx)
1307 , m_arraySize (arraySize)
1311 tcu::TestCase::IterateResult BindRelinkHoleAttributeTest::iterate (void)
1313 const vector<Bind> noBindings;
1314 const deInt32 maxAttributes = getMaxAttributeLocations(m_renderCtx);
1315 const AttribType vec4 ("vec4", 1, GL_FLOAT_VEC4);
1316 const int arrayElementCount = (m_arraySize != Attribute::NOT_ARRAY ? m_arraySize : 1);
1318 vector<Attribute> attributes;
1319 vector<Bind> preLinkBindings;
1320 vector<Bind> postLinkBindings;
1323 attributes.push_back(Attribute(vec4, "a_0"));
1324 preLinkBindings.push_back(Bind("a_0", 0));
1326 attributes.push_back(Attribute(m_type, "a_1", Attribute::LOC_UNDEF, Cond::COND_ALWAYS, m_arraySize));
1329 for (int loc = 1 + m_type.getLocationSize() * arrayElementCount; loc < maxAttributes; loc++)
1331 attributes.push_back(Attribute(vec4, "a_" + de::toString(ndx)));
1332 preLinkBindings.push_back(Bind("a_" + de::toString(ndx), loc));
1337 postLinkBindings.push_back(Bind("a_2", 1));
1339 runTest(m_testCtx, m_renderCtx, attributes, noBindings, preLinkBindings, postLinkBindings, true);
1343 MixedRelinkHoleAttributeTest::MixedRelinkHoleAttributeTest (tcu::TestContext& testCtx,
1344 glu::RenderContext& renderCtx,
1345 const AttribType& type,
1347 : TestCase (testCtx, generateTestName(type, arraySize).c_str(), generateTestName(type, arraySize).c_str())
1348 , m_renderCtx (renderCtx)
1350 , m_arraySize (arraySize)
1354 tcu::TestCase::IterateResult MixedRelinkHoleAttributeTest::iterate (void)
1356 const vector<Bind> noBindings;
1357 const deInt32 maxAttributes = getMaxAttributeLocations(m_renderCtx);
1358 const AttribType vec4 ("vec4", 1, GL_FLOAT_VEC4);
1359 const int arrayElementCount = (m_arraySize != Attribute::NOT_ARRAY ? m_arraySize : 1);
1361 vector<Bind> preLinkBindings;
1362 vector<Bind> postLinkBindings;
1363 vector<Attribute> attributes;
1366 attributes.push_back(Attribute(vec4, "a_0"));
1367 preLinkBindings.push_back(Bind("a_0", 0));
1369 attributes.push_back(Attribute(m_type, "a_1", Attribute::LOC_UNDEF, Cond::COND_ALWAYS, m_arraySize));
1372 for (int loc = 1 + m_type.getLocationSize() * arrayElementCount; loc < maxAttributes; loc++)
1375 attributes.push_back(Attribute(vec4, "a_" + de::toString(ndx), loc));
1378 attributes.push_back(Attribute(vec4, "a_" + de::toString(ndx)));
1379 preLinkBindings.push_back(Bind("a_" + de::toString(ndx), loc));
1385 postLinkBindings.push_back(Bind("a_2", 1));
1387 runTest(m_testCtx, m_renderCtx, attributes, noBindings, preLinkBindings, postLinkBindings, true);
1391 BindReattachAttributeTest::BindReattachAttributeTest (tcu::TestContext& testCtx,
1392 glu::RenderContext& renderCtx)
1393 : TestCase (testCtx, "reattach", "reattach")
1394 , m_renderCtx (renderCtx)
1398 tcu::TestCase::IterateResult BindReattachAttributeTest::iterate (void)
1400 const vector<Bind> noBindings;
1401 const AttribType vec4("vec4", 1, GL_FLOAT_VEC4);
1402 const AttribType vec2("vec2", 1, GL_FLOAT_VEC2);
1404 vector<Bind> bindings;
1405 vector<Attribute> attributes;
1406 vector<Attribute> reattachAttributes;
1408 attributes.push_back(Attribute(vec4, "a_0"));
1409 bindings.push_back(Bind("a_0", 1));
1410 bindings.push_back(Bind("a_1", 1));
1412 reattachAttributes.push_back(Attribute(vec2, "a_1"));
1414 runTest(m_testCtx, m_renderCtx, attributes, noBindings, bindings, noBindings, false, true, reattachAttributes);
1418 PreAttachMixedAttributeTest::PreAttachMixedAttributeTest (tcu::TestContext& testCtx,
1419 glu::RenderContext& renderCtx)
1420 : TestCase (testCtx, "pre_attach", "pre_attach")
1421 , m_renderCtx (renderCtx)
1425 tcu::TestCase::IterateResult PreAttachMixedAttributeTest::iterate (void)
1427 const vector<Bind> noBindings;
1429 vector<Attribute> attributes;
1430 vector<Bind> bindings;
1432 attributes.push_back(Attribute(AttribType("vec4", 1, GL_FLOAT_VEC4), "a_0", 1));
1433 bindings.push_back(Bind("a_0", 3));
1435 runTest(m_testCtx, m_renderCtx, attributes, bindings, noBindings, noBindings, false);
1439 PreLinkMixedAttributeTest::PreLinkMixedAttributeTest (tcu::TestContext& testCtx,
1440 glu::RenderContext& renderCtx)
1441 : TestCase (testCtx, "pre_link", "pre_link")
1442 , m_renderCtx (renderCtx)
1446 tcu::TestCase::IterateResult PreLinkMixedAttributeTest::iterate (void)
1448 const vector<Bind> noBindings;
1450 vector<Attribute> attributes;
1451 vector<Bind> bindings;
1453 attributes.push_back(Attribute(AttribType("vec4", 1, GL_FLOAT_VEC4), "a_0", 1));
1454 bindings.push_back(Bind("a_0", 3));
1456 runTest(m_testCtx, m_renderCtx, attributes, noBindings, bindings, noBindings, false);
1460 PostLinkMixedAttributeTest::PostLinkMixedAttributeTest (tcu::TestContext& testCtx,
1461 glu::RenderContext& renderCtx)
1462 : TestCase (testCtx, "post_link", "post_link")
1463 , m_renderCtx (renderCtx)
1467 tcu::TestCase::IterateResult PostLinkMixedAttributeTest::iterate (void)
1469 const vector<Bind> noBindings;
1471 vector<Attribute> attributes;
1472 vector<Bind> bindings;
1474 attributes.push_back(Attribute(AttribType("vec4", 1, GL_FLOAT_VEC4), "a_0", 1));
1475 bindings.push_back(Bind("a_0", 3));
1477 runTest(m_testCtx, m_renderCtx, attributes, noBindings, noBindings, bindings, false);
1481 MixedReattachAttributeTest::MixedReattachAttributeTest (tcu::TestContext& testCtx,
1482 glu::RenderContext& renderCtx)
1483 : TestCase (testCtx, "reattach", "reattach")
1484 , m_renderCtx (renderCtx)
1488 tcu::TestCase::IterateResult MixedReattachAttributeTest::iterate (void)
1490 const vector<Bind> noBindings;
1491 const AttribType vec4("vec4", 1, GL_FLOAT_VEC4);
1492 const AttribType vec2("vec2", 1, GL_FLOAT_VEC2);
1494 vector<Bind> bindings;
1495 vector<Attribute> attributes;
1496 vector<Attribute> reattachAttributes;
1498 attributes.push_back(Attribute(vec4, "a_0", 2));
1499 bindings.push_back(Bind("a_0", 1));
1500 bindings.push_back(Bind("a_1", 1));
1502 reattachAttributes.push_back(Attribute(vec2, "a_1"));
1504 runTest(m_testCtx, m_renderCtx, attributes, noBindings, bindings, noBindings, false, true, reattachAttributes);
1508 MixedRelinkAttributeTest::MixedRelinkAttributeTest (tcu::TestContext& testCtx,
1509 glu::RenderContext& renderCtx)
1510 : TestCase (testCtx, "relink", "relink")
1511 , m_renderCtx (renderCtx)
1515 tcu::TestCase::IterateResult MixedRelinkAttributeTest::iterate (void)
1517 const vector<Bind> noBindings;
1518 const AttribType vec4("vec4", 1, GL_FLOAT_VEC4);
1520 vector<Attribute> attributes;
1521 vector<Bind> preLinkBindings;
1522 vector<Bind> postLinkBindings;
1524 attributes.push_back(Attribute(vec4, "a_0", 1));
1525 attributes.push_back(Attribute(vec4, "a_1"));
1527 preLinkBindings.push_back(Bind("a_0", 3));
1528 preLinkBindings.push_back(Bind("a_0", 5));
1530 postLinkBindings.push_back(Bind("a_0", 6));
1532 runTest(m_testCtx, m_renderCtx, attributes, noBindings, preLinkBindings, postLinkBindings, true);