1 /*------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
5 * Copyright (c) 2015 The Khronos Group Inc.
6 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
7 * Copyright (c) 2016 The Android Open Source Project
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
23 * \brief Shader indexing (arrays, vector, matrices) tests.
24 *//*--------------------------------------------------------------------*/
26 #include "vktShaderRenderIndexingTests.hpp"
27 #include "vktShaderRender.hpp"
28 #include "gluShaderUtil.hpp"
29 #include "tcuStringTemplate.hpp"
47 INDEXACCESS_STATIC = 0,
49 INDEXACCESS_STATIC_LOOP,
50 INDEXACCESS_DYNAMIC_LOOP,
55 static const char* getIndexAccessTypeName (IndexAccessType accessType)
57 static const char* s_names[INDEXACCESS_LAST] =
65 DE_ASSERT(deInBounds32((int)accessType, 0, INDEXACCESS_LAST));
66 return s_names[(int)accessType];
75 SUBSCRIPT_STATIC_LOOP,
76 SUBSCRIPT_DYNAMIC_LOOP,
81 static const char* getVectorAccessTypeName (VectorAccessType accessType)
83 static const char* s_names[VECTORACCESS_LAST] =
89 "static_loop_subscript",
90 "dynamic_loop_subscript"
93 DE_ASSERT(deInBounds32((int)accessType, 0, VECTORACCESS_LAST));
94 return s_names[(int)accessType];
97 void evalArrayCoordsFloat (ShaderEvalContext& c) { c.color.x() = 1.875f * c.coords.x(); }
98 void evalArrayCoordsVec2 (ShaderEvalContext& c) { c.color.xy() = 1.875f * c.coords.swizzle(0,1); }
99 void evalArrayCoordsVec3 (ShaderEvalContext& c) { c.color.xyz() = 1.875f * c.coords.swizzle(0,1,2); }
100 void evalArrayCoordsVec4 (ShaderEvalContext& c) { c.color = 1.875f * c.coords; }
102 static ShaderEvalFunc getArrayCoordsEvalFunc (DataType dataType)
104 if (dataType == TYPE_FLOAT) return evalArrayCoordsFloat;
105 else if (dataType == TYPE_FLOAT_VEC2) return evalArrayCoordsVec2;
106 else if (dataType == TYPE_FLOAT_VEC3) return evalArrayCoordsVec3;
107 else if (dataType == TYPE_FLOAT_VEC4) return evalArrayCoordsVec4;
109 DE_FATAL("Invalid data type.");
113 void evalArrayUniformFloat (ShaderEvalContext& c) { c.color.x() = 1.875f * c.constCoords.x(); }
114 void evalArrayUniformVec2 (ShaderEvalContext& c) { c.color.xy() = 1.875f * c.constCoords.swizzle(0,1); }
115 void evalArrayUniformVec3 (ShaderEvalContext& c) { c.color.xyz() = 1.875f * c.constCoords.swizzle(0,1,2); }
116 void evalArrayUniformVec4 (ShaderEvalContext& c) { c.color = 1.875f * c.constCoords; }
118 static ShaderEvalFunc getArrayUniformEvalFunc (DataType dataType)
120 if (dataType == TYPE_FLOAT) return evalArrayUniformFloat;
121 else if (dataType == TYPE_FLOAT_VEC2) return evalArrayUniformVec2;
122 else if (dataType == TYPE_FLOAT_VEC3) return evalArrayUniformVec3;
123 else if (dataType == TYPE_FLOAT_VEC4) return evalArrayUniformVec4;
125 DE_FATAL("Invalid data type.");
129 static const char* getIntUniformName (int number)
133 case 0: return "ui_zero";
134 case 1: return "ui_one";
135 case 2: return "ui_two";
136 case 3: return "ui_three";
137 case 4: return "ui_four";
138 case 5: return "ui_five";
139 case 6: return "ui_six";
140 case 7: return "ui_seven";
141 case 8: return "ui_eight";
142 case 101: return "ui_oneHundredOne";
149 class IndexingTestUniformSetup : public UniformSetup
152 IndexingTestUniformSetup (const DataType varType, bool usesArray)
154 , m_usesArray(usesArray)
156 virtual ~IndexingTestUniformSetup (void)
159 virtual void setup (ShaderRenderCaseInstance& instance, const tcu::Vec4& constCoords) const;
162 const DataType m_varType;
163 const bool m_usesArray;
166 void IndexingTestUniformSetup::setup (ShaderRenderCaseInstance& instance, const tcu::Vec4& constCoords) const
168 instance.useUniform(0u, UI_ZERO);
169 instance.useUniform(1u, UI_ONE);
170 instance.useUniform(2u, UI_TWO);
171 instance.useUniform(3u, UI_THREE);
172 instance.useUniform(4u, UI_FOUR);
177 if (m_varType == TYPE_FLOAT)
179 arr[0] = Vec4(constCoords.x());
180 arr[1] = Vec4(constCoords.x() * 0.5f);
181 arr[2] = Vec4(constCoords.x() * 0.25f);
182 arr[3] = Vec4(constCoords.x() * 0.125f);
184 else if (m_varType == TYPE_FLOAT_VEC2)
186 arr[0] = constCoords.swizzle(0, 1).toWidth<4>();
187 arr[1] = (constCoords.swizzle(0, 1) * 0.5f).toWidth<4>();
188 arr[2] = (constCoords.swizzle(0, 1) * 0.25f).toWidth<4>();
189 arr[3] = (constCoords.swizzle(0, 1) * 0.125f).toWidth<4>();
191 else if (m_varType == TYPE_FLOAT_VEC3)
193 arr[0] = constCoords.swizzle(0, 1, 2).toWidth<4>();
194 arr[1] = (constCoords.swizzle(0, 1, 2) * 0.5f).toWidth<4>();
195 arr[2] = (constCoords.swizzle(0, 1, 2) * 0.25f).toWidth<4>();
196 arr[3] = (constCoords.swizzle(0, 1, 2) * 0.125f).toWidth<4>();
198 else if (m_varType == TYPE_FLOAT_VEC4)
200 arr[0] = constCoords;
201 arr[1] = constCoords * 0.5f;
202 arr[2] = constCoords * 0.25f;
203 arr[3] = constCoords * 0.125f;
206 throw tcu::TestError("invalid data type for u_arr");
208 instance.addUniform(5u, vk::VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, sizeof(Vec4) * 4, arr[0].getPtr());
212 // ShaderIndexingCase
214 class ShaderIndexingCase : public ShaderRenderCase
217 ShaderIndexingCase (tcu::TestContext& testCtx,
218 const std::string& name,
219 const std::string& description,
221 const ShaderEvalFunc evalFunc,
222 const std::string& vertShaderSource,
223 const std::string& fragShaderSource,
224 const DataType varType,
225 const bool usesArray);
226 virtual ~ShaderIndexingCase (void);
229 ShaderIndexingCase (const ShaderIndexingCase&); // not allowed!
230 ShaderIndexingCase& operator= (const ShaderIndexingCase&); // not allowed!
233 ShaderIndexingCase::ShaderIndexingCase (tcu::TestContext& testCtx,
234 const std::string& name,
235 const std::string& description,
236 const bool isVertexCase,
237 const ShaderEvalFunc evalFunc,
238 const std::string& vertShaderSource,
239 const std::string& fragShaderSource,
240 const DataType varType,
241 const bool usesArray)
242 : ShaderRenderCase(testCtx, name, description, isVertexCase, evalFunc, new IndexingTestUniformSetup(varType, usesArray), DE_NULL)
244 m_vertShaderSource = vertShaderSource;
245 m_fragShaderSource = fragShaderSource;
248 ShaderIndexingCase::~ShaderIndexingCase (void)
252 // Test case builders.
254 static de::MovePtr<ShaderIndexingCase> createVaryingArrayCase (tcu::TestContext& context,
255 const std::string& caseName,
256 const std::string& description,
258 IndexAccessType vertAccess,
259 IndexAccessType fragAccess)
261 std::ostringstream vtx;
262 vtx << "#version 310 es\n";
263 vtx << "layout(location = 0) in highp vec4 a_position;\n";
264 vtx << "layout(location = 1) in highp vec4 a_coords;\n";
265 if (vertAccess == INDEXACCESS_DYNAMIC)
267 vtx << "layout(std140, binding = 0) uniform something0 { mediump int ui_zero; };\n";
268 vtx << "layout(std140, binding = 1) uniform something1 { mediump int ui_one; };\n";
269 vtx << "layout(std140, binding = 2) uniform something2 { mediump int ui_two; };\n";
270 vtx << "layout(std140, binding = 3) uniform something3 { mediump int ui_three; };\n";
272 else if (vertAccess == INDEXACCESS_DYNAMIC_LOOP)
273 vtx << "layout(std140, binding = 4) uniform something { mediump int ui_four; };\n";
274 vtx << "layout(location = 0) out ${PRECISION} ${VAR_TYPE} var[${ARRAY_LEN}];\n";
276 vtx << "void main()\n";
278 vtx << " gl_Position = a_position;\n";
279 if (vertAccess == INDEXACCESS_STATIC)
281 vtx << " var[0] = ${VAR_TYPE}(a_coords);\n";
282 vtx << " var[1] = ${VAR_TYPE}(a_coords) * 0.5;\n";
283 vtx << " var[2] = ${VAR_TYPE}(a_coords) * 0.25;\n";
284 vtx << " var[3] = ${VAR_TYPE}(a_coords) * 0.125;\n";
286 else if (vertAccess == INDEXACCESS_DYNAMIC)
288 vtx << " var[ui_zero] = ${VAR_TYPE}(a_coords);\n";
289 vtx << " var[ui_one] = ${VAR_TYPE}(a_coords) * 0.5;\n";
290 vtx << " var[ui_two] = ${VAR_TYPE}(a_coords) * 0.25;\n";
291 vtx << " var[ui_three] = ${VAR_TYPE}(a_coords) * 0.125;\n";
293 else if (vertAccess == INDEXACCESS_STATIC_LOOP)
295 vtx << " ${PRECISION} ${VAR_TYPE} coords = ${VAR_TYPE}(a_coords);\n";
296 vtx << " for (int i = 0; i < 4; i++)\n";
298 vtx << " var[i] = ${VAR_TYPE}(coords);\n";
299 vtx << " coords = coords * 0.5;\n";
304 DE_ASSERT(vertAccess == INDEXACCESS_DYNAMIC_LOOP);
305 vtx << " ${PRECISION} ${VAR_TYPE} coords = ${VAR_TYPE}(a_coords);\n";
306 vtx << " for (int i = 0; i < ui_four; i++)\n";
308 vtx << " var[i] = ${VAR_TYPE}(coords);\n";
309 vtx << " coords = coords * 0.5;\n";
314 std::ostringstream frag;
315 frag << "#version 310 es\n";
316 frag << "precision mediump int;\n";
317 frag << "layout(location = 0) out mediump vec4 o_color;\n";
318 if (fragAccess == INDEXACCESS_DYNAMIC)
320 frag << "layout(std140, binding = 0) uniform something0 { mediump int ui_zero; };\n";
321 frag << "layout(std140, binding = 1) uniform something1 { mediump int ui_one; };\n";
322 frag << "layout(std140, binding = 2) uniform something2 { mediump int ui_two; };\n";
323 frag << "layout(std140, binding = 3) uniform something3 { mediump int ui_three; };\n";
325 else if (fragAccess == INDEXACCESS_DYNAMIC_LOOP)
326 frag << "layout(std140, binding = 4) uniform something4 { mediump int ui_four; };\n";
327 frag << "layout(location = 0) in ${PRECISION} ${VAR_TYPE} var[${ARRAY_LEN}];\n";
329 frag << "void main()\n";
331 frag << " ${PRECISION} ${VAR_TYPE} res = ${VAR_TYPE}(0.0);\n";
332 if (fragAccess == INDEXACCESS_STATIC)
334 frag << " res += var[0];\n";
335 frag << " res += var[1];\n";
336 frag << " res += var[2];\n";
337 frag << " res += var[3];\n";
339 else if (fragAccess == INDEXACCESS_DYNAMIC)
341 frag << " res += var[ui_zero];\n";
342 frag << " res += var[ui_one];\n";
343 frag << " res += var[ui_two];\n";
344 frag << " res += var[ui_three];\n";
346 else if (fragAccess == INDEXACCESS_STATIC_LOOP)
348 frag << " for (int i = 0; i < 4; i++)\n";
349 frag << " res += var[i];\n";
353 DE_ASSERT(fragAccess == INDEXACCESS_DYNAMIC_LOOP);
354 frag << " for (int i = 0; i < ui_four; i++)\n";
355 frag << " res += var[i];\n";
357 frag << " o_color = vec4(res${PADDING});\n";
360 // Fill in shader templates.
361 map<string, string> params;
362 params.insert(pair<string, string>("VAR_TYPE", getDataTypeName(varType)));
363 params.insert(pair<string, string>("ARRAY_LEN", "4"));
364 params.insert(pair<string, string>("PRECISION", "mediump"));
366 if (varType == TYPE_FLOAT)
367 params.insert(pair<string, string>("PADDING", ", 0.0, 0.0, 1.0"));
368 else if (varType == TYPE_FLOAT_VEC2)
369 params.insert(pair<string, string>("PADDING", ", 0.0, 1.0"));
370 else if (varType == TYPE_FLOAT_VEC3)
371 params.insert(pair<string, string>("PADDING", ", 1.0"));
373 params.insert(pair<string, string>("PADDING", ""));
375 StringTemplate vertTemplate(vtx.str());
376 StringTemplate fragTemplate(frag.str());
377 string vertexShaderSource = vertTemplate.specialize(params);
378 string fragmentShaderSource = fragTemplate.specialize(params);
380 ShaderEvalFunc evalFunc = getArrayCoordsEvalFunc(varType);
381 return de::MovePtr<ShaderIndexingCase>(new ShaderIndexingCase(context, caseName, description, true, evalFunc, vertexShaderSource, fragmentShaderSource, varType, false));
384 static de::MovePtr<ShaderIndexingCase> createUniformArrayCase (tcu::TestContext& context,
385 const std::string& caseName,
386 const std::string& description,
389 IndexAccessType readAccess)
391 std::ostringstream vtx;
392 std::ostringstream frag;
393 std::ostringstream& op = isVertexCase ? vtx : frag;
395 vtx << "#version 310 es\n";
396 frag << "#version 310 es\n";
398 vtx << "layout(location = 0) in highp vec4 a_position;\n";
399 vtx << "layout(location = 1) in highp vec4 a_coords;\n";
400 frag << "layout(location = 0) out mediump vec4 o_color;\n";
404 vtx << "layout(location = 0) out mediump vec4 v_color;\n";
405 frag << "layout(location = 0) in mediump vec4 v_color;\n";
409 vtx << "layout(location = 0) out mediump vec4 v_coords;\n";
410 frag << "layout(location = 0) in mediump vec4 v_coords;\n";
413 if (readAccess == INDEXACCESS_DYNAMIC)
415 op << "layout(std140, binding = 0) uniform something0 { mediump int ui_zero; };\n";
416 op << "layout(std140, binding = 1) uniform something1 { mediump int ui_one; };\n";
417 op << "layout(std140, binding = 2) uniform something2 { mediump int ui_two; };\n";
418 op << "layout(std140, binding = 3) uniform something3 { mediump int ui_three; };\n";
420 else if (readAccess == INDEXACCESS_DYNAMIC_LOOP)
421 op << "layout(std140, binding = 4) uniform something4 { mediump int ui_four; };\n";
423 op << "layout(std140, binding = 5) uniform something5 { ${PRECISION} ${VAR_TYPE} u_arr[${ARRAY_LEN}]; };\n";
426 vtx << "void main()\n";
428 vtx << " gl_Position = a_position;\n";
431 frag << "void main()\n";
435 op << " ${PRECISION} ${VAR_TYPE} res = ${VAR_TYPE}(0.0);\n";
436 if (readAccess == INDEXACCESS_STATIC)
438 op << " res += u_arr[0];\n";
439 op << " res += u_arr[1];\n";
440 op << " res += u_arr[2];\n";
441 op << " res += u_arr[3];\n";
443 else if (readAccess == INDEXACCESS_DYNAMIC)
445 op << " res += u_arr[ui_zero];\n";
446 op << " res += u_arr[ui_one];\n";
447 op << " res += u_arr[ui_two];\n";
448 op << " res += u_arr[ui_three];\n";
450 else if (readAccess == INDEXACCESS_STATIC_LOOP)
452 op << " for (int i = 0; i < 4; i++)\n";
453 op << " res += u_arr[i];\n";
457 DE_ASSERT(readAccess == INDEXACCESS_DYNAMIC_LOOP);
458 op << " for (int i = 0; i < ui_four; i++)\n";
459 op << " res += u_arr[i];\n";
464 vtx << " v_color = vec4(res${PADDING});\n";
465 frag << " o_color = v_color;\n";
469 vtx << " v_coords = a_coords;\n";
470 frag << " o_color = vec4(res${PADDING});\n";
476 // Fill in shader templates.
477 map<string, string> params;
478 params.insert(pair<string, string>("VAR_TYPE", getDataTypeName(varType)));
479 params.insert(pair<string, string>("ARRAY_LEN", "4"));
480 params.insert(pair<string, string>("PRECISION", "mediump"));
482 if (varType == TYPE_FLOAT)
483 params.insert(pair<string, string>("PADDING", ", 0.0, 0.0, 1.0"));
484 else if (varType == TYPE_FLOAT_VEC2)
485 params.insert(pair<string, string>("PADDING", ", 0.0, 1.0"));
486 else if (varType == TYPE_FLOAT_VEC3)
487 params.insert(pair<string, string>("PADDING", ", 1.0"));
489 params.insert(pair<string, string>("PADDING", ""));
491 StringTemplate vertTemplate(vtx.str());
492 StringTemplate fragTemplate(frag.str());
493 string vertexShaderSource = vertTemplate.specialize(params);
494 string fragmentShaderSource = fragTemplate.specialize(params);
496 ShaderEvalFunc evalFunc = getArrayUniformEvalFunc(varType);
497 return de::MovePtr<ShaderIndexingCase>(new ShaderIndexingCase(context, caseName, description, isVertexCase, evalFunc, vertexShaderSource, fragmentShaderSource, varType, true));
500 static de::MovePtr<ShaderIndexingCase> createTmpArrayCase (tcu::TestContext& context,
501 const std::string& caseName,
502 const std::string& description,
505 IndexAccessType writeAccess,
506 IndexAccessType readAccess)
508 std::ostringstream vtx;
509 std::ostringstream frag;
510 std::ostringstream& op = isVertexCase ? vtx : frag;
512 vtx << "#version 310 es\n";
513 frag << "#version 310 es\n";
515 vtx << "layout(location = 0) in highp vec4 a_position;\n";
516 vtx << "layout(location = 1) in highp vec4 a_coords;\n";
517 frag << "layout(location = 0) out mediump vec4 o_color;\n";
521 vtx << "layout(location = 0) out mediump vec4 v_color;\n";
522 frag << "layout(location = 0) in mediump vec4 v_color;\n";
526 vtx << "layout(location = 0) out mediump vec4 v_coords;\n";
527 frag << "layout(location = 0) in mediump vec4 v_coords;\n";
530 if (writeAccess == INDEXACCESS_DYNAMIC || readAccess == INDEXACCESS_DYNAMIC)
532 op << "layout(std140, binding = 0) uniform something0 { mediump int ui_zero; };\n";
533 op << "layout(std140, binding = 1) uniform something1 { mediump int ui_one; };\n";
534 op << "layout(std140, binding = 2) uniform something2 { mediump int ui_two; };\n";
535 op << "layout(std140, binding = 3) uniform something3 { mediump int ui_three; };\n";
538 if (writeAccess == INDEXACCESS_DYNAMIC_LOOP || readAccess == INDEXACCESS_DYNAMIC_LOOP)
539 op << "layout(std140, binding = 4) uniform something4 { mediump int ui_four; };\n";
542 vtx << "void main()\n";
544 vtx << " gl_Position = a_position;\n";
547 frag << "void main()\n";
552 op << " ${PRECISION} ${VAR_TYPE} coords = ${VAR_TYPE}(a_coords);\n";
554 op << " ${PRECISION} ${VAR_TYPE} coords = ${VAR_TYPE}(v_coords);\n";
556 op << " ${PRECISION} ${VAR_TYPE} arr[${ARRAY_LEN}];\n";
557 if (writeAccess == INDEXACCESS_STATIC)
559 op << " arr[0] = ${VAR_TYPE}(coords);\n";
560 op << " arr[1] = ${VAR_TYPE}(coords) * 0.5;\n";
561 op << " arr[2] = ${VAR_TYPE}(coords) * 0.25;\n";
562 op << " arr[3] = ${VAR_TYPE}(coords) * 0.125;\n";
564 else if (writeAccess == INDEXACCESS_DYNAMIC)
566 op << " arr[ui_zero] = ${VAR_TYPE}(coords);\n";
567 op << " arr[ui_one] = ${VAR_TYPE}(coords) * 0.5;\n";
568 op << " arr[ui_two] = ${VAR_TYPE}(coords) * 0.25;\n";
569 op << " arr[ui_three] = ${VAR_TYPE}(coords) * 0.125;\n";
571 else if (writeAccess == INDEXACCESS_STATIC_LOOP)
573 op << " for (int i = 0; i < 4; i++)\n";
575 op << " arr[i] = ${VAR_TYPE}(coords);\n";
576 op << " coords = coords * 0.5;\n";
581 DE_ASSERT(writeAccess == INDEXACCESS_DYNAMIC_LOOP);
582 op << " for (int i = 0; i < ui_four; i++)\n";
584 op << " arr[i] = ${VAR_TYPE}(coords);\n";
585 op << " coords = coords * 0.5;\n";
590 op << " ${PRECISION} ${VAR_TYPE} res = ${VAR_TYPE}(0.0);\n";
591 if (readAccess == INDEXACCESS_STATIC)
593 op << " res += arr[0];\n";
594 op << " res += arr[1];\n";
595 op << " res += arr[2];\n";
596 op << " res += arr[3];\n";
598 else if (readAccess == INDEXACCESS_DYNAMIC)
600 op << " res += arr[ui_zero];\n";
601 op << " res += arr[ui_one];\n";
602 op << " res += arr[ui_two];\n";
603 op << " res += arr[ui_three];\n";
605 else if (readAccess == INDEXACCESS_STATIC_LOOP)
607 op << " for (int i = 0; i < 4; i++)\n";
608 op << " res += arr[i];\n";
612 DE_ASSERT(readAccess == INDEXACCESS_DYNAMIC_LOOP);
613 op << " for (int i = 0; i < ui_four; i++)\n";
614 op << " res += arr[i];\n";
619 vtx << " v_color = vec4(res${PADDING});\n";
620 frag << " o_color = v_color;\n";
624 vtx << " v_coords = a_coords;\n";
625 frag << " o_color = vec4(res${PADDING});\n";
631 // Fill in shader templates.
632 map<string, string> params;
633 params.insert(pair<string, string>("VAR_TYPE", getDataTypeName(varType)));
634 params.insert(pair<string, string>("ARRAY_LEN", "4"));
635 params.insert(pair<string, string>("PRECISION", "mediump"));
637 if (varType == TYPE_FLOAT)
638 params.insert(pair<string, string>("PADDING", ", 0.0, 0.0, 1.0"));
639 else if (varType == TYPE_FLOAT_VEC2)
640 params.insert(pair<string, string>("PADDING", ", 0.0, 1.0"));
641 else if (varType == TYPE_FLOAT_VEC3)
642 params.insert(pair<string, string>("PADDING", ", 1.0"));
644 params.insert(pair<string, string>("PADDING", ""));
646 StringTemplate vertTemplate(vtx.str());
647 StringTemplate fragTemplate(frag.str());
648 string vertexShaderSource = vertTemplate.specialize(params);
649 string fragmentShaderSource = fragTemplate.specialize(params);
651 ShaderEvalFunc evalFunc = getArrayCoordsEvalFunc(varType);
652 return de::MovePtr<ShaderIndexingCase>(new ShaderIndexingCase(context, caseName, description, isVertexCase, evalFunc, vertexShaderSource, fragmentShaderSource, varType, false));
657 void evalSubscriptVec2 (ShaderEvalContext& c) { c.color.xyz() = Vec3(c.coords.x() + 0.5f*c.coords.y()); }
658 void evalSubscriptVec3 (ShaderEvalContext& c) { c.color.xyz() = Vec3(c.coords.x() + 0.5f*c.coords.y() + 0.25f*c.coords.z()); }
659 void evalSubscriptVec4 (ShaderEvalContext& c) { c.color.xyz() = Vec3(c.coords.x() + 0.5f*c.coords.y() + 0.25f*c.coords.z() + 0.125f*c.coords.w()); }
661 static ShaderEvalFunc getVectorSubscriptEvalFunc (DataType dataType)
663 if (dataType == TYPE_FLOAT_VEC2) return evalSubscriptVec2;
664 else if (dataType == TYPE_FLOAT_VEC3) return evalSubscriptVec3;
665 else if (dataType == TYPE_FLOAT_VEC4) return evalSubscriptVec4;
667 DE_FATAL("Invalid data type.");
671 static de::MovePtr<ShaderIndexingCase> createVectorSubscriptCase (tcu::TestContext& context,
672 const std::string& caseName,
673 const std::string& description,
676 VectorAccessType writeAccess,
677 VectorAccessType readAccess)
679 std::ostringstream vtx;
680 std::ostringstream frag;
681 std::ostringstream& op = isVertexCase ? vtx : frag;
683 int vecLen = getDataTypeScalarSize(varType);
684 const char* vecLenName = getIntUniformName(vecLen);
686 vtx << "#version 310 es\n";
687 frag << "#version 310 es\n";
689 vtx << "layout(location = 0) in highp vec4 a_position;\n";
690 vtx << "layout(location = 1) in highp vec4 a_coords;\n";
691 frag << "layout(location = 0) out mediump vec4 o_color;\n";
695 vtx << "layout(location = 0) out mediump vec3 v_color;\n";
696 frag << "layout(location = 0) in mediump vec3 v_color;\n";
700 vtx << "layout(location = 0) out mediump vec4 v_coords;\n";
701 frag << "layout(location = 0) in mediump vec4 v_coords;\n";
704 if (writeAccess == SUBSCRIPT_DYNAMIC || readAccess == SUBSCRIPT_DYNAMIC)
706 op << "layout(std140, binding = 0) uniform something0 { mediump int ui_zero; };\n";
707 if (vecLen >= 2) op << "layout(std140, binding = 1) uniform something1 { mediump int ui_one; };\n";
708 if (vecLen >= 3) op << "layout(std140, binding = 2) uniform something2 { mediump int ui_two; };\n";
709 if (vecLen >= 4) op << "layout(std140, binding = 3) uniform something3 { mediump int ui_three; };\n";
712 if (writeAccess == SUBSCRIPT_DYNAMIC_LOOP || readAccess == SUBSCRIPT_DYNAMIC_LOOP)
713 op << "layout(std140, binding = " << vecLen << ") uniform something" << vecLen << " { mediump int " << vecLenName << "; };\n";
716 vtx << "void main()\n";
718 vtx << " gl_Position = a_position;\n";
721 frag << "void main()\n";
726 op << " ${PRECISION} ${VAR_TYPE} coords = ${VAR_TYPE}(a_coords);\n";
728 op << " ${PRECISION} ${VAR_TYPE} coords = ${VAR_TYPE}(v_coords);\n";
730 op << " ${PRECISION} ${VAR_TYPE} tmp;\n";
731 if (writeAccess == DIRECT)
732 op << " tmp = coords.${SWIZZLE} * vec4(1.0, 0.5, 0.25, 0.125).${SWIZZLE};\n";
733 else if (writeAccess == COMPONENT)
735 op << " tmp.x = coords.x;\n";
736 if (vecLen >= 2) op << " tmp.y = coords.y * 0.5;\n";
737 if (vecLen >= 3) op << " tmp.z = coords.z * 0.25;\n";
738 if (vecLen >= 4) op << " tmp.w = coords.w * 0.125;\n";
740 else if (writeAccess == SUBSCRIPT_STATIC)
742 op << " tmp[0] = coords.x;\n";
743 if (vecLen >= 2) op << " tmp[1] = coords.y * 0.5;\n";
744 if (vecLen >= 3) op << " tmp[2] = coords.z * 0.25;\n";
745 if (vecLen >= 4) op << " tmp[3] = coords.w * 0.125;\n";
747 else if (writeAccess == SUBSCRIPT_DYNAMIC)
749 op << " tmp[ui_zero] = coords.x;\n";
750 if (vecLen >= 2) op << " tmp[ui_one] = coords.y * 0.5;\n";
751 if (vecLen >= 3) op << " tmp[ui_two] = coords.z * 0.25;\n";
752 if (vecLen >= 4) op << " tmp[ui_three] = coords.w * 0.125;\n";
754 else if (writeAccess == SUBSCRIPT_STATIC_LOOP)
756 op << " for (int i = 0; i < " << vecLen << "; i++)\n";
758 op << " tmp[i] = coords.x;\n";
759 op << " coords = coords.${ROT_SWIZZLE} * 0.5;\n";
764 DE_ASSERT(writeAccess == SUBSCRIPT_DYNAMIC_LOOP);
765 op << " for (int i = 0; i < " << vecLenName << "; i++)\n";
767 op << " tmp[i] = coords.x;\n";
768 op << " coords = coords.${ROT_SWIZZLE} * 0.5;\n";
773 op << " ${PRECISION} float res = 0.0;\n";
774 if (readAccess == DIRECT)
775 op << " res = dot(tmp, ${VAR_TYPE}(1.0));\n";
776 else if (readAccess == COMPONENT)
778 op << " res += tmp.x;\n";
779 if (vecLen >= 2) op << " res += tmp.y;\n";
780 if (vecLen >= 3) op << " res += tmp.z;\n";
781 if (vecLen >= 4) op << " res += tmp.w;\n";
783 else if (readAccess == SUBSCRIPT_STATIC)
785 op << " res += tmp[0];\n";
786 if (vecLen >= 2) op << " res += tmp[1];\n";
787 if (vecLen >= 3) op << " res += tmp[2];\n";
788 if (vecLen >= 4) op << " res += tmp[3];\n";
790 else if (readAccess == SUBSCRIPT_DYNAMIC)
792 op << " res += tmp[ui_zero];\n";
793 if (vecLen >= 2) op << " res += tmp[ui_one];\n";
794 if (vecLen >= 3) op << " res += tmp[ui_two];\n";
795 if (vecLen >= 4) op << " res += tmp[ui_three];\n";
797 else if (readAccess == SUBSCRIPT_STATIC_LOOP)
799 op << " for (int i = 0; i < " << vecLen << "; i++)\n";
800 op << " res += tmp[i];\n";
804 DE_ASSERT(readAccess == SUBSCRIPT_DYNAMIC_LOOP);
805 op << " for (int i = 0; i < " << vecLenName << "; i++)\n";
806 op << " res += tmp[i];\n";
811 vtx << " v_color = vec3(res);\n";
812 frag << " o_color = vec4(v_color.rgb, 1.0);\n";
816 vtx << " v_coords = a_coords;\n";
817 frag << " o_color = vec4(vec3(res), 1.0);\n";
823 // Fill in shader templates.
824 static const char* s_swizzles[5] = { "", "x", "xy", "xyz", "xyzw" };
825 static const char* s_rotSwizzles[5] = { "", "x", "yx", "yzx", "yzwx" };
827 map<string, string> params;
828 params.insert(pair<string, string>("VAR_TYPE", getDataTypeName(varType)));
829 params.insert(pair<string, string>("PRECISION", "mediump"));
830 params.insert(pair<string, string>("SWIZZLE", s_swizzles[vecLen]));
831 params.insert(pair<string, string>("ROT_SWIZZLE", s_rotSwizzles[vecLen]));
833 StringTemplate vertTemplate(vtx.str());
834 StringTemplate fragTemplate(frag.str());
835 string vertexShaderSource = vertTemplate.specialize(params);
836 string fragmentShaderSource = fragTemplate.specialize(params);
838 ShaderEvalFunc evalFunc = getVectorSubscriptEvalFunc(varType);
839 return de::MovePtr<ShaderIndexingCase>(new ShaderIndexingCase(context, caseName, description, isVertexCase, evalFunc, vertexShaderSource, fragmentShaderSource, varType, false));
844 void evalSubscriptMat2 (ShaderEvalContext& c) { c.color.xy() = c.coords.swizzle(0,1) + 0.5f*c.coords.swizzle(1,2); }
845 void evalSubscriptMat2x3 (ShaderEvalContext& c) { c.color.xyz() = c.coords.swizzle(0,1,2) + 0.5f*c.coords.swizzle(1,2,3); }
846 void evalSubscriptMat2x4 (ShaderEvalContext& c) { c.color = c.coords.swizzle(0,1,2,3) + 0.5f*c.coords.swizzle(1,2,3,0); }
848 void evalSubscriptMat3x2 (ShaderEvalContext& c) { c.color.xy() = c.coords.swizzle(0,1) + 0.5f*c.coords.swizzle(1,2) + 0.25f*c.coords.swizzle(2,3); }
849 void evalSubscriptMat3 (ShaderEvalContext& c) { c.color.xyz() = c.coords.swizzle(0,1,2) + 0.5f*c.coords.swizzle(1,2,3) + 0.25f*c.coords.swizzle(2,3,0); }
850 void evalSubscriptMat3x4 (ShaderEvalContext& c) { c.color = c.coords.swizzle(0,1,2,3) + 0.5f*c.coords.swizzle(1,2,3,0) + 0.25f*c.coords.swizzle(2,3,0,1); }
852 void evalSubscriptMat4x2 (ShaderEvalContext& c) { c.color.xy() = c.coords.swizzle(0,1) + 0.5f*c.coords.swizzle(1,2) + 0.25f*c.coords.swizzle(2,3) + 0.125f*c.coords.swizzle(3,0); }
853 void evalSubscriptMat4x3 (ShaderEvalContext& c) { c.color.xyz() = c.coords.swizzle(0,1,2) + 0.5f*c.coords.swizzle(1,2,3) + 0.25f*c.coords.swizzle(2,3,0) + 0.125f*c.coords.swizzle(3,0,1); }
854 void evalSubscriptMat4 (ShaderEvalContext& c) { c.color = c.coords + 0.5f*c.coords.swizzle(1,2,3,0) + 0.25f*c.coords.swizzle(2,3,0,1) + 0.125f*c.coords.swizzle(3,0,1,2); }
856 static ShaderEvalFunc getMatrixSubscriptEvalFunc (DataType dataType)
860 case TYPE_FLOAT_MAT2: return evalSubscriptMat2;
861 case TYPE_FLOAT_MAT2X3: return evalSubscriptMat2x3;
862 case TYPE_FLOAT_MAT2X4: return evalSubscriptMat2x4;
863 case TYPE_FLOAT_MAT3X2: return evalSubscriptMat3x2;
864 case TYPE_FLOAT_MAT3: return evalSubscriptMat3;
865 case TYPE_FLOAT_MAT3X4: return evalSubscriptMat3x4;
866 case TYPE_FLOAT_MAT4X2: return evalSubscriptMat4x2;
867 case TYPE_FLOAT_MAT4X3: return evalSubscriptMat4x3;
868 case TYPE_FLOAT_MAT4: return evalSubscriptMat4;
871 DE_FATAL("Invalid data type.");
876 static de::MovePtr<ShaderIndexingCase> createMatrixSubscriptCase (tcu::TestContext& context,
877 const std::string& caseName,
878 const std::string& description,
881 IndexAccessType writeAccess,
882 IndexAccessType readAccess)
884 std::ostringstream vtx;
885 std::ostringstream frag;
886 std::ostringstream& op = isVertexCase ? vtx : frag;
888 int numCols = getDataTypeMatrixNumColumns(varType);
889 int numRows = getDataTypeMatrixNumRows(varType);
890 const char* matSizeName = getIntUniformName(numCols);
891 DataType vecType = getDataTypeFloatVec(numRows);
893 vtx << "#version 310 es\n";
894 frag << "#version 310 es\n";
896 vtx << "layout(location = 0) in highp vec4 a_position;\n";
897 vtx << "layout(location = 1) in highp vec4 a_coords;\n";
898 frag << "layout(location = 0) out mediump vec4 o_color;\n";
902 vtx << "layout(location = 0) out mediump vec4 v_color;\n";
903 frag << "layout(location = 0) in mediump vec4 v_color;\n";
907 vtx << "layout(location = 0) out mediump vec4 v_coords;\n";
908 frag << "layout(location = 0) in mediump vec4 v_coords;\n";
911 if (writeAccess == INDEXACCESS_DYNAMIC || readAccess == INDEXACCESS_DYNAMIC)
913 op << "layout(std140, binding = 0) uniform something0 { mediump int ui_zero; };\n";
914 if (numCols >= 2) op << "layout(std140, binding = 1) uniform something1 { mediump int ui_one; };\n";
915 if (numCols >= 3) op << "layout(std140, binding = 2) uniform something2 { mediump int ui_two; };\n";
916 if (numCols >= 4) op << "layout(std140, binding = 3) uniform something3 { mediump int ui_three; };\n";
919 if (writeAccess == INDEXACCESS_DYNAMIC_LOOP || readAccess == INDEXACCESS_DYNAMIC_LOOP)
920 op << "layout(std140, binding = " << numCols << ") uniform something" << numCols << " { mediump int " << matSizeName << "; };\n";
923 vtx << "void main()\n";
925 vtx << " gl_Position = a_position;\n";
928 frag << "void main()\n";
933 op << " ${PRECISION} vec4 coords = a_coords;\n";
935 op << " ${PRECISION} vec4 coords = v_coords;\n";
937 op << " ${PRECISION} ${MAT_TYPE} tmp;\n";
938 if (writeAccess == INDEXACCESS_STATIC)
940 op << " tmp[0] = ${VEC_TYPE}(coords);\n";
941 if (numCols >= 2) op << " tmp[1] = ${VEC_TYPE}(coords.yzwx) * 0.5;\n";
942 if (numCols >= 3) op << " tmp[2] = ${VEC_TYPE}(coords.zwxy) * 0.25;\n";
943 if (numCols >= 4) op << " tmp[3] = ${VEC_TYPE}(coords.wxyz) * 0.125;\n";
945 else if (writeAccess == INDEXACCESS_DYNAMIC)
947 op << " tmp[ui_zero] = ${VEC_TYPE}(coords);\n";
948 if (numCols >= 2) op << " tmp[ui_one] = ${VEC_TYPE}(coords.yzwx) * 0.5;\n";
949 if (numCols >= 3) op << " tmp[ui_two] = ${VEC_TYPE}(coords.zwxy) * 0.25;\n";
950 if (numCols >= 4) op << " tmp[ui_three] = ${VEC_TYPE}(coords.wxyz) * 0.125;\n";
952 else if (writeAccess == INDEXACCESS_STATIC_LOOP)
954 op << " for (int i = 0; i < " << numCols << "; i++)\n";
956 op << " tmp[i] = ${VEC_TYPE}(coords);\n";
957 op << " coords = coords.yzwx * 0.5;\n";
962 DE_ASSERT(writeAccess == INDEXACCESS_DYNAMIC_LOOP);
963 op << " for (int i = 0; i < " << matSizeName << "; i++)\n";
965 op << " tmp[i] = ${VEC_TYPE}(coords);\n";
966 op << " coords = coords.yzwx * 0.5;\n";
971 op << " ${PRECISION} ${VEC_TYPE} res = ${VEC_TYPE}(0.0);\n";
972 if (readAccess == INDEXACCESS_STATIC)
974 op << " res += tmp[0];\n";
975 if (numCols >= 2) op << " res += tmp[1];\n";
976 if (numCols >= 3) op << " res += tmp[2];\n";
977 if (numCols >= 4) op << " res += tmp[3];\n";
979 else if (readAccess == INDEXACCESS_DYNAMIC)
981 op << " res += tmp[ui_zero];\n";
982 if (numCols >= 2) op << " res += tmp[ui_one];\n";
983 if (numCols >= 3) op << " res += tmp[ui_two];\n";
984 if (numCols >= 4) op << " res += tmp[ui_three];\n";
986 else if (readAccess == INDEXACCESS_STATIC_LOOP)
988 op << " for (int i = 0; i < " << numCols << "; i++)\n";
989 op << " res += tmp[i];\n";
993 DE_ASSERT(readAccess == INDEXACCESS_DYNAMIC_LOOP);
994 op << " for (int i = 0; i < " << matSizeName << "; i++)\n";
995 op << " res += tmp[i];\n";
1000 vtx << " v_color = vec4(res${PADDING});\n";
1001 frag << " o_color = v_color;\n";
1005 vtx << " v_coords = a_coords;\n";
1006 frag << " o_color = vec4(res${PADDING});\n";
1012 // Fill in shader templates.
1013 map<string, string> params;
1014 params.insert(pair<string, string>("MAT_TYPE", getDataTypeName(varType)));
1015 params.insert(pair<string, string>("VEC_TYPE", getDataTypeName(vecType)));
1016 params.insert(pair<string, string>("PRECISION", "mediump"));
1019 params.insert(pair<string, string>("PADDING", ", 0.0, 1.0"));
1020 else if (numRows == 3)
1021 params.insert(pair<string, string>("PADDING", ", 1.0"));
1023 params.insert(pair<string, string>("PADDING", ""));
1025 StringTemplate vertTemplate(vtx.str());
1026 StringTemplate fragTemplate(frag.str());
1027 string vertexShaderSource = vertTemplate.specialize(params);
1028 string fragmentShaderSource = fragTemplate.specialize(params);
1030 ShaderEvalFunc evalFunc = getMatrixSubscriptEvalFunc(varType);
1031 return de::MovePtr<ShaderIndexingCase>(new ShaderIndexingCase(context, caseName, description, isVertexCase, evalFunc, vertexShaderSource, fragmentShaderSource, varType, false));
1034 // ShaderIndexingTests.
1036 class ShaderIndexingTests : public tcu::TestCaseGroup
1039 ShaderIndexingTests (tcu::TestContext& context);
1040 virtual ~ShaderIndexingTests (void);
1042 virtual void init (void);
1045 ShaderIndexingTests (const ShaderIndexingTests&); // not allowed!
1046 ShaderIndexingTests& operator= (const ShaderIndexingTests&); // not allowed!
1049 ShaderIndexingTests::ShaderIndexingTests(tcu::TestContext& context)
1050 : TestCaseGroup(context, "indexing", "Indexing Tests")
1054 ShaderIndexingTests::~ShaderIndexingTests (void)
1058 void ShaderIndexingTests::init (void)
1060 static const ShaderType s_shaderTypes[] =
1066 static const DataType s_floatAndVecTypes[] =
1074 // Varying array access cases.
1076 de::MovePtr<TestCaseGroup> varyingGroup(new TestCaseGroup(m_testCtx, "varying_array", "Varying array access tests."));
1078 for (int typeNdx = 0; typeNdx < DE_LENGTH_OF_ARRAY(s_floatAndVecTypes); typeNdx++)
1080 DataType varType = s_floatAndVecTypes[typeNdx];
1081 for (int vertAccess = 0; vertAccess < INDEXACCESS_LAST; vertAccess++)
1083 for (int fragAccess = 0; fragAccess < INDEXACCESS_LAST; fragAccess++)
1085 const char* vertAccessName = getIndexAccessTypeName((IndexAccessType)vertAccess);
1086 const char* fragAccessName = getIndexAccessTypeName((IndexAccessType)fragAccess);
1087 string name = string(getDataTypeName(varType)) + "_" + vertAccessName + "_write_" + fragAccessName + "_read";
1088 string desc = string("Varying array with ") + vertAccessName + " write in vertex shader and " + fragAccessName + " read in fragment shader.";
1089 de::MovePtr<ShaderIndexingCase> testCase(createVaryingArrayCase(m_testCtx, name, desc, varType, (IndexAccessType)vertAccess, (IndexAccessType)fragAccess));
1090 varyingGroup->addChild(testCase.release());
1095 addChild(varyingGroup.release());
1098 // Uniform array access cases.
1100 de::MovePtr<TestCaseGroup> uniformGroup(new TestCaseGroup(m_testCtx, "uniform_array", "Uniform array access tests."));
1102 for (int typeNdx = 0; typeNdx < DE_LENGTH_OF_ARRAY(s_floatAndVecTypes); typeNdx++)
1104 DataType varType = s_floatAndVecTypes[typeNdx];
1105 for (int readAccess = 0; readAccess < INDEXACCESS_LAST; readAccess++)
1107 const char* readAccessName = getIndexAccessTypeName((IndexAccessType)readAccess);
1108 for (int shaderTypeNdx = 0; shaderTypeNdx < DE_LENGTH_OF_ARRAY(s_shaderTypes); shaderTypeNdx++)
1110 ShaderType shaderType = s_shaderTypes[shaderTypeNdx];
1111 const char* shaderTypeName = getShaderTypeName(shaderType);
1112 string name = string(getDataTypeName(varType)) + "_" + readAccessName + "_read_" + shaderTypeName;
1113 string desc = string("Uniform array with ") + readAccessName + " read in " + shaderTypeName + " shader.";
1114 bool isVertexCase = ((ShaderType)shaderType == SHADERTYPE_VERTEX);
1115 de::MovePtr<ShaderIndexingCase> testCase(createUniformArrayCase(m_testCtx, name, desc, isVertexCase, varType, (IndexAccessType)readAccess));
1116 uniformGroup->addChild(testCase.release());
1121 addChild(uniformGroup.release());
1124 // Temporary array access cases.
1126 de::MovePtr<TestCaseGroup> tmpGroup(new TestCaseGroup(m_testCtx, "tmp_array", "Temporary array access tests."));
1128 for (int typeNdx = 0; typeNdx < DE_LENGTH_OF_ARRAY(s_floatAndVecTypes); typeNdx++)
1130 DataType varType = s_floatAndVecTypes[typeNdx];
1131 for (int writeAccess = 0; writeAccess < INDEXACCESS_LAST; writeAccess++)
1133 for (int readAccess = 0; readAccess < INDEXACCESS_LAST; readAccess++)
1135 const char* writeAccessName = getIndexAccessTypeName((IndexAccessType)writeAccess);
1136 const char* readAccessName = getIndexAccessTypeName((IndexAccessType)readAccess);
1138 for (int shaderTypeNdx = 0; shaderTypeNdx < DE_LENGTH_OF_ARRAY(s_shaderTypes); shaderTypeNdx++)
1140 ShaderType shaderType = s_shaderTypes[shaderTypeNdx];
1141 const char* shaderTypeName = getShaderTypeName(shaderType);
1142 string name = string(getDataTypeName(varType)) + "_" + writeAccessName + "_write_" + readAccessName + "_read_" + shaderTypeName;
1143 string desc = string("Temporary array with ") + writeAccessName + " write and " + readAccessName + " read in " + shaderTypeName + " shader.";
1144 bool isVertexCase = ((ShaderType)shaderType == SHADERTYPE_VERTEX);
1145 de::MovePtr<ShaderIndexingCase> testCase(createTmpArrayCase(m_testCtx, name, desc, isVertexCase, varType, (IndexAccessType)writeAccess, (IndexAccessType)readAccess));
1146 tmpGroup->addChild(testCase.release());
1152 addChild(tmpGroup.release());
1155 // Vector indexing with subscripts.
1157 de::MovePtr<TestCaseGroup> vecGroup(new TestCaseGroup(m_testCtx, "vector_subscript", "Vector subscript indexing."));
1159 static const DataType s_vectorTypes[] =
1166 for (int typeNdx = 0; typeNdx < DE_LENGTH_OF_ARRAY(s_vectorTypes); typeNdx++)
1168 DataType varType = s_vectorTypes[typeNdx];
1169 for (int writeAccess = 0; writeAccess < VECTORACCESS_LAST; writeAccess++)
1171 for (int readAccess = 0; readAccess < VECTORACCESS_LAST; readAccess++)
1173 const char* writeAccessName = getVectorAccessTypeName((VectorAccessType)writeAccess);
1174 const char* readAccessName = getVectorAccessTypeName((VectorAccessType)readAccess);
1176 for (int shaderTypeNdx = 0; shaderTypeNdx < DE_LENGTH_OF_ARRAY(s_shaderTypes); shaderTypeNdx++)
1178 ShaderType shaderType = s_shaderTypes[shaderTypeNdx];
1179 const char* shaderTypeName = getShaderTypeName(shaderType);
1180 string name = string(getDataTypeName(varType)) + "_" + writeAccessName + "_write_" + readAccessName + "_read_" + shaderTypeName;
1181 string desc = string("Vector subscript access with ") + writeAccessName + " write and " + readAccessName + " read in " + shaderTypeName + " shader.";
1182 bool isVertexCase = ((ShaderType)shaderType == SHADERTYPE_VERTEX);
1183 de::MovePtr<ShaderIndexingCase> testCase(createVectorSubscriptCase(m_testCtx, name.c_str(), desc.c_str(), isVertexCase, varType, (VectorAccessType)writeAccess, (VectorAccessType)readAccess));
1184 vecGroup->addChild(testCase.release());
1190 addChild(vecGroup.release());
1193 // Matrix indexing with subscripts.
1195 de::MovePtr<TestCaseGroup> matGroup(new TestCaseGroup(m_testCtx, "matrix_subscript", "Matrix subscript indexing."));
1197 static const DataType s_matrixTypes[] =
1210 for (int typeNdx = 0; typeNdx < DE_LENGTH_OF_ARRAY(s_matrixTypes); typeNdx++)
1212 DataType varType = s_matrixTypes[typeNdx];
1213 for (int writeAccess = 0; writeAccess < INDEXACCESS_LAST; writeAccess++)
1215 for (int readAccess = 0; readAccess < INDEXACCESS_LAST; readAccess++)
1217 const char* writeAccessName = getIndexAccessTypeName((IndexAccessType)writeAccess);
1218 const char* readAccessName = getIndexAccessTypeName((IndexAccessType)readAccess);
1220 for (int shaderTypeNdx = 0; shaderTypeNdx < DE_LENGTH_OF_ARRAY(s_shaderTypes); shaderTypeNdx++)
1222 ShaderType shaderType = s_shaderTypes[shaderTypeNdx];
1223 const char* shaderTypeName = getShaderTypeName(shaderType);
1224 string name = string(getDataTypeName(varType)) + "_" + writeAccessName + "_write_" + readAccessName + "_read_" + shaderTypeName;
1225 string desc = string("Vector subscript access with ") + writeAccessName + " write and " + readAccessName + " read in " + shaderTypeName + " shader.";
1226 bool isVertexCase = ((ShaderType)shaderType == SHADERTYPE_VERTEX);
1227 de::MovePtr<ShaderIndexingCase> testCase(createMatrixSubscriptCase(m_testCtx, name.c_str(), desc.c_str(), isVertexCase, varType, (IndexAccessType)writeAccess, (IndexAccessType)readAccess));
1228 matGroup->addChild(testCase.release());
1234 addChild(matGroup.release());
1240 tcu::TestCaseGroup* createIndexingTests (tcu::TestContext& testCtx)
1242 return new ShaderIndexingTests(testCtx);