1 #ifndef _GLSATTRIBUTELOCATIONTESTS_HPP 2 #define _GLSATTRIBUTELOCATIONTESTS_HPP 3 /*------------------------------------------------------------------------- 4 * drawElements Quality Program OpenGL (ES) Module 5 * ----------------------------------------------- 6 * 7 * Copyright 2014 The Android Open Source Project 8 * 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 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 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. 20 * 21 *//*! 22 * \file 23 * \brief Attribute location tests 24 *//*--------------------------------------------------------------------*/ 25 26 #include "tcuDefs.hpp" 27 #include "tcuTestCase.hpp" 28 29 #include <string> 30 #include <vector> 31 32 namespace glu 33 { 34 class ShaderProgram; 35 class RenderContext; 36 } // namespace glu 37 38 namespace deqp 39 { 40 namespace gls 41 { 42 namespace AttributeLocationTestUtil 43 { 44 45 class AttribType 46 { 47 public: 48 AttribType(const std::string &name, uint32_t locationSize, uint32_t typeEnum); 49 getName(void) const50 const std::string &getName(void) const 51 { 52 return m_name; 53 } getLocationSize(void) const54 uint32_t getLocationSize(void) const 55 { 56 return m_locationSize; 57 } getGLTypeEnum(void) const58 uint32_t getGLTypeEnum(void) const 59 { 60 return m_glTypeEnum; 61 } 62 63 private: 64 std::string m_name; 65 uint32_t m_locationSize; 66 uint32_t m_glTypeEnum; 67 }; 68 69 class Cond 70 { 71 public: 72 enum ConstCond 73 { 74 COND_ALWAYS, 75 COND_NEVER 76 }; 77 78 Cond(ConstCond cond); 79 explicit Cond(const std::string &name, bool negate = true); operator ==(const Cond & other) const80 bool operator==(const Cond &other) const 81 { 82 return m_negate == other.m_negate && m_name == other.m_name; 83 } operator !=(const Cond & other) const84 bool operator!=(const Cond &other) const 85 { 86 return !(*this == other); 87 } getName(void) const88 const std::string getName(void) const 89 { 90 return m_name; 91 } getNegate(void) const92 bool getNegate(void) const 93 { 94 return m_negate; 95 } 96 97 private: 98 bool m_negate; 99 std::string m_name; 100 }; 101 102 class Attribute 103 { 104 public: 105 enum 106 { 107 // Location is not defined 108 LOC_UNDEF = -1 109 }; 110 111 enum 112 { 113 // Not an array 114 NOT_ARRAY = -1 115 }; 116 117 Attribute(const AttribType &type, const std::string &name, int32_t layoutLocation = LOC_UNDEF, 118 const Cond &cond = Cond::COND_ALWAYS, int arraySize = NOT_ARRAY); 119 getType(void) const120 const AttribType getType(void) const 121 { 122 return m_type; 123 } getName(void) const124 const std::string &getName(void) const 125 { 126 return m_name; 127 } getLayoutLocation(void) const128 int32_t getLayoutLocation(void) const 129 { 130 return m_layoutLocation; 131 } getCondition(void) const132 const Cond &getCondition(void) const 133 { 134 return m_cond; 135 } getArraySize(void) const136 int getArraySize(void) const 137 { 138 return m_arraySize; 139 } 140 141 private: 142 AttribType m_type; 143 std::string m_name; 144 int32_t m_layoutLocation; 145 Cond m_cond; 146 int m_arraySize; 147 }; 148 149 class Bind 150 { 151 public: 152 Bind(const std::string &attribute, uint32_t location); 153 getAttributeName(void) const154 const std::string &getAttributeName(void) const 155 { 156 return m_attribute; 157 } getLocation(void) const158 uint32_t getLocation(void) const 159 { 160 return m_location; 161 } 162 163 private: 164 std::string m_attribute; 165 uint32_t m_location; 166 }; 167 168 } // namespace AttributeLocationTestUtil 169 170 // Simple bind attribute test 171 class BindAttributeTest : public tcu::TestCase 172 { 173 public: 174 typedef AttributeLocationTestUtil::AttribType AttribType; 175 176 BindAttributeTest(tcu::TestContext &testCtx, glu::RenderContext &renderCtx, const AttribType &type, 177 int arraySize = AttributeLocationTestUtil::Attribute::NOT_ARRAY); 178 179 virtual IterateResult iterate(void); 180 181 private: 182 glu::RenderContext &m_renderCtx; 183 const AttribType m_type; 184 const int m_arraySize; 185 }; 186 187 // Bind maximum number of attributes 188 class BindMaxAttributesTest : public tcu::TestCase 189 { 190 public: 191 typedef AttributeLocationTestUtil::AttribType AttribType; 192 193 BindMaxAttributesTest(tcu::TestContext &testCtx, glu::RenderContext &renderCtx, const AttribType &type, 194 int arraySize = AttributeLocationTestUtil::Attribute::NOT_ARRAY); 195 196 virtual IterateResult iterate(void); 197 198 private: 199 glu::RenderContext &m_renderCtx; 200 const AttribType m_type; 201 const int m_arraySize; 202 }; 203 204 class BindAliasingAttributeTest : public tcu::TestCase 205 { 206 public: 207 typedef AttributeLocationTestUtil::AttribType AttribType; 208 209 BindAliasingAttributeTest(tcu::TestContext &testCtx, glu::RenderContext &renderCtx, const AttribType &type, 210 int offset = 0, int arraySize = AttributeLocationTestUtil::Attribute::NOT_ARRAY); 211 212 virtual IterateResult iterate(void); 213 214 private: 215 glu::RenderContext &m_renderCtx; 216 const AttribType m_type; 217 const int m_offset; 218 const int m_arraySize; 219 }; 220 221 class BindMaxAliasingAttributeTest : public tcu::TestCase 222 { 223 public: 224 typedef AttributeLocationTestUtil::AttribType AttribType; 225 226 BindMaxAliasingAttributeTest(tcu::TestContext &testCtx, glu::RenderContext &renderCtx, const AttribType &type, 227 int arraySize = AttributeLocationTestUtil::Attribute::NOT_ARRAY); 228 229 virtual IterateResult iterate(void); 230 231 private: 232 glu::RenderContext &m_renderCtx; 233 const AttribType m_type; 234 const int m_arraySize; 235 }; 236 237 class BindInactiveAliasingAttributeTest : public tcu::TestCase 238 { 239 public: 240 typedef AttributeLocationTestUtil::AttribType AttribType; 241 242 BindInactiveAliasingAttributeTest(tcu::TestContext &testCtx, glu::RenderContext &renderCtx, const AttribType &type, 243 int arraySize = AttributeLocationTestUtil::Attribute::NOT_ARRAY); 244 245 virtual IterateResult iterate(void); 246 247 private: 248 glu::RenderContext &m_renderCtx; 249 const AttribType m_type; 250 const int m_arraySize; 251 }; 252 253 class BindHoleAttributeTest : public tcu::TestCase 254 { 255 public: 256 typedef AttributeLocationTestUtil::AttribType AttribType; 257 258 BindHoleAttributeTest(tcu::TestContext &testCtx, glu::RenderContext &renderCtx, const AttribType &type, 259 int arraySize = AttributeLocationTestUtil::Attribute::NOT_ARRAY); 260 261 virtual IterateResult iterate(void); 262 263 private: 264 glu::RenderContext &m_renderCtx; 265 const AttribType m_type; 266 const int m_arraySize; 267 }; 268 269 class PreAttachBindAttributeTest : public tcu::TestCase 270 { 271 public: 272 PreAttachBindAttributeTest(tcu::TestContext &testCtx, glu::RenderContext &renderCtx); 273 274 virtual IterateResult iterate(void); 275 276 private: 277 glu::RenderContext &m_renderCtx; 278 }; 279 280 class PreLinkBindAttributeTest : public tcu::TestCase 281 { 282 public: 283 typedef AttributeLocationTestUtil::AttribType AttribType; 284 285 PreLinkBindAttributeTest(tcu::TestContext &testCtx, glu::RenderContext &renderCtx); 286 287 virtual IterateResult iterate(void); 288 289 private: 290 glu::RenderContext &m_renderCtx; 291 }; 292 293 class PostLinkBindAttributeTest : public tcu::TestCase 294 { 295 public: 296 typedef AttributeLocationTestUtil::AttribType AttribType; 297 298 PostLinkBindAttributeTest(tcu::TestContext &testCtx, glu::RenderContext &renderCtx); 299 300 virtual IterateResult iterate(void); 301 302 private: 303 glu::RenderContext &m_renderCtx; 304 }; 305 306 class BindReattachAttributeTest : public tcu::TestCase 307 { 308 public: 309 typedef AttributeLocationTestUtil::AttribType AttribType; 310 311 BindReattachAttributeTest(tcu::TestContext &testCtx, glu::RenderContext &renderCtx); 312 313 virtual IterateResult iterate(void); 314 315 private: 316 glu::RenderContext &m_renderCtx; 317 }; 318 319 class LocationAttributeTest : public tcu::TestCase 320 { 321 public: 322 typedef AttributeLocationTestUtil::AttribType AttribType; 323 324 LocationAttributeTest(tcu::TestContext &testCtx, glu::RenderContext &renderCtx, const AttribType &type, 325 int arraySize = AttributeLocationTestUtil::Attribute::NOT_ARRAY); 326 327 virtual IterateResult iterate(void); 328 329 private: 330 glu::RenderContext &m_renderCtx; 331 const AttribType m_type; 332 const int m_arraySize; 333 }; 334 335 class LocationMaxAttributesTest : public tcu::TestCase 336 { 337 public: 338 typedef AttributeLocationTestUtil::AttribType AttribType; 339 340 LocationMaxAttributesTest(tcu::TestContext &testCtx, glu::RenderContext &renderCtx, const AttribType &type, 341 int arraySize = AttributeLocationTestUtil::Attribute::NOT_ARRAY); 342 343 virtual IterateResult iterate(void); 344 345 private: 346 glu::RenderContext &m_renderCtx; 347 const AttribType m_type; 348 const int m_arraySize; 349 }; 350 351 class LocationHoleAttributeTest : public tcu::TestCase 352 { 353 public: 354 typedef AttributeLocationTestUtil::AttribType AttribType; 355 356 LocationHoleAttributeTest(tcu::TestContext &testCtx, glu::RenderContext &renderCtx, const AttribType &type, 357 int arraySize = AttributeLocationTestUtil::Attribute::NOT_ARRAY); 358 359 virtual IterateResult iterate(void); 360 361 private: 362 glu::RenderContext &m_renderCtx; 363 const AttribType m_type; 364 const int m_arraySize; 365 }; 366 367 class MixedAttributeTest : public tcu::TestCase 368 { 369 public: 370 typedef AttributeLocationTestUtil::AttribType AttribType; 371 372 MixedAttributeTest(tcu::TestContext &testCtx, glu::RenderContext &renderCtx, const AttribType &type, 373 int arraySize = AttributeLocationTestUtil::Attribute::NOT_ARRAY); 374 375 virtual IterateResult iterate(void); 376 377 private: 378 glu::RenderContext &m_renderCtx; 379 const AttribType m_type; 380 const int m_arraySize; 381 }; 382 383 class MixedMaxAttributesTest : public tcu::TestCase 384 { 385 public: 386 typedef AttributeLocationTestUtil::AttribType AttribType; 387 388 MixedMaxAttributesTest(tcu::TestContext &testCtx, glu::RenderContext &renderCtx, const AttribType &type, 389 int arraySize = AttributeLocationTestUtil::Attribute::NOT_ARRAY); 390 391 virtual IterateResult iterate(void); 392 393 private: 394 glu::RenderContext &m_renderCtx; 395 const AttribType m_type; 396 const int m_arraySize; 397 }; 398 399 class MixedHoleAttributeTest : public tcu::TestCase 400 { 401 public: 402 typedef AttributeLocationTestUtil::AttribType AttribType; 403 404 MixedHoleAttributeTest(tcu::TestContext &testCtx, glu::RenderContext &renderCtx, const AttribType &type, 405 int arraySize = AttributeLocationTestUtil::Attribute::NOT_ARRAY); 406 407 virtual IterateResult iterate(void); 408 409 private: 410 glu::RenderContext &m_renderCtx; 411 const AttribType m_type; 412 const int m_arraySize; 413 }; 414 415 class BindRelinkAttributeTest : public tcu::TestCase 416 { 417 public: 418 typedef AttributeLocationTestUtil::AttribType AttribType; 419 420 BindRelinkAttributeTest(tcu::TestContext &testCtx, glu::RenderContext &renderCtx); 421 422 virtual IterateResult iterate(void); 423 424 private: 425 glu::RenderContext &m_renderCtx; 426 }; 427 428 class BindRelinkHoleAttributeTest : public tcu::TestCase 429 { 430 public: 431 typedef AttributeLocationTestUtil::AttribType AttribType; 432 433 BindRelinkHoleAttributeTest(tcu::TestContext &testCtx, glu::RenderContext &renderCtx, const AttribType &type, 434 int arraySize = AttributeLocationTestUtil::Attribute::NOT_ARRAY); 435 436 virtual IterateResult iterate(void); 437 438 private: 439 glu::RenderContext &m_renderCtx; 440 const AttribType m_type; 441 const int m_arraySize; 442 }; 443 444 class MixedRelinkHoleAttributeTest : public tcu::TestCase 445 { 446 public: 447 typedef AttributeLocationTestUtil::AttribType AttribType; 448 449 MixedRelinkHoleAttributeTest(tcu::TestContext &testCtx, glu::RenderContext &renderCtx, const AttribType &type, 450 int arraySize = AttributeLocationTestUtil::Attribute::NOT_ARRAY); 451 452 virtual IterateResult iterate(void); 453 454 private: 455 glu::RenderContext &m_renderCtx; 456 const AttribType m_type; 457 const int m_arraySize; 458 }; 459 460 class PreAttachMixedAttributeTest : public tcu::TestCase 461 { 462 public: 463 typedef AttributeLocationTestUtil::AttribType AttribType; 464 465 PreAttachMixedAttributeTest(tcu::TestContext &testCtx, glu::RenderContext &renderCtx); 466 467 virtual IterateResult iterate(void); 468 469 private: 470 glu::RenderContext &m_renderCtx; 471 }; 472 473 class PreLinkMixedAttributeTest : public tcu::TestCase 474 { 475 public: 476 typedef AttributeLocationTestUtil::AttribType AttribType; 477 478 PreLinkMixedAttributeTest(tcu::TestContext &testCtx, glu::RenderContext &renderCtx); 479 480 virtual IterateResult iterate(void); 481 482 private: 483 glu::RenderContext &m_renderCtx; 484 }; 485 486 class PostLinkMixedAttributeTest : public tcu::TestCase 487 { 488 public: 489 typedef AttributeLocationTestUtil::AttribType AttribType; 490 491 PostLinkMixedAttributeTest(tcu::TestContext &testCtx, glu::RenderContext &renderCtx); 492 493 virtual IterateResult iterate(void); 494 495 private: 496 glu::RenderContext &m_renderCtx; 497 }; 498 499 class MixedReattachAttributeTest : public tcu::TestCase 500 { 501 public: 502 typedef AttributeLocationTestUtil::AttribType AttribType; 503 504 MixedReattachAttributeTest(tcu::TestContext &testCtx, glu::RenderContext &renderCtx); 505 506 virtual IterateResult iterate(void); 507 508 private: 509 glu::RenderContext &m_renderCtx; 510 }; 511 512 class MixedRelinkAttributeTest : public tcu::TestCase 513 { 514 public: 515 typedef AttributeLocationTestUtil::AttribType AttribType; 516 517 MixedRelinkAttributeTest(tcu::TestContext &testCtx, glu::RenderContext &renderCtx); 518 519 virtual IterateResult iterate(void); 520 521 private: 522 glu::RenderContext &m_renderCtx; 523 }; 524 525 } // namespace gls 526 } // namespace deqp 527 528 #endif // _GLSATTRIBUTELOCATIONTESTS_HPP 529