1 #ifndef _ESEXTCTESSELLATIONSHADERERRORS_HPP 2 #define _ESEXTCTESSELLATIONSHADERERRORS_HPP 3 /*------------------------------------------------------------------------- 4 * OpenGL Conformance Test Suite 5 * ----------------------------- 6 * 7 * Copyright (c) 2014-2016 The Khronos Group Inc. 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 24 */ /*-------------------------------------------------------------------*/ 25 26 #include "gluShaderUtil.hpp" 27 #include "tcuDefs.hpp" 28 29 #include "../esextcTestCaseBase.hpp" 30 31 namespace glcts 32 { 33 34 /* Groups all building error tests */ 35 class TessellationShaderErrors : public glcts::TestCaseGroupBase 36 { 37 public: 38 /* Public methods */ 39 TessellationShaderErrors(Context &context, const ExtParameters &extParams); 40 41 virtual void init(void); 42 }; 43 44 /** Base class for all test classes that implement Tessellation Shader 45 * Test Case 4 test cases. */ 46 class TessellationShaderErrorsTestCaseBase : public TestCaseBase 47 { 48 public: 49 /* Public methods */ 50 TessellationShaderErrorsTestCaseBase(Context &context, const ExtParameters &extParams, const char *name, 51 const char *description); 52 ~TessellationShaderErrorsTestCaseBase()53 virtual ~TessellationShaderErrorsTestCaseBase() 54 { 55 } 56 57 virtual void deinit(void); 58 virtual IterateResult iterate(void); 59 60 protected: 61 /* Protected type definitions */ 62 /** Define valid compilation results. */ 63 typedef enum 64 { 65 COMPILATION_RESULT_MUST_SUCCEED, 66 COMPILATION_RESULT_CAN_FAIL, 67 COMPILATION_RESULT_MUST_FAIL, 68 69 COMPILATION_RESULT_UNKNOWN 70 } _compilation_result; 71 72 /** Define recognized stages of a rendering pipeline. Used to 73 * form a program object. 74 */ 75 typedef enum 76 { 77 PIPELINE_STAGE_FIRST = 0, 78 PIPELINE_STAGE_FRAGMENT = PIPELINE_STAGE_FIRST, 79 PIPELINE_STAGE_TESSELLATION_CONTROL, 80 PIPELINE_STAGE_TESSELLATION_EVALUATION, 81 PIPELINE_STAGE_VERTEX, 82 83 PIPELINE_STAGE_COUNT, 84 PIPELINE_STAGE_UNKNOWN = PIPELINE_STAGE_COUNT, 85 } _pipeline_stage; 86 87 /** Define valid linking operation results. */ 88 typedef enum 89 { 90 LINKING_RESULT_MUST_SUCCEED, 91 LINKING_RESULT_MUST_FAIL, 92 93 LINKING_RESULT_UNKNOWN 94 } _linking_result; 95 96 /* Protected methods */ 97 virtual unsigned int getAmountOfProgramObjects(); 98 virtual _compilation_result getCompilationResult(_pipeline_stage pipeline_stage) = 0; 99 virtual std::string getFragmentShaderCode(unsigned int n_program_object); 100 virtual _linking_result getLinkingResult() = 0; 101 virtual std::string getTessellationControlShaderCode(unsigned int n_program_object) = 0; 102 virtual std::string getTessellationEvaluationShaderCode(unsigned int n_program_object) = 0; 103 virtual std::string getVertexShaderCode(unsigned int n_program_object); 104 virtual bool isPipelineStageUsed(_pipeline_stage stage) = 0; 105 106 private: 107 /* Private methods */ 108 glw::GLenum getGLEnumForPipelineStage(_pipeline_stage stage); 109 110 /* Private variables */ 111 glw::GLuint *m_fs_ids; 112 unsigned int m_n_program_objects; 113 glw::GLuint *m_po_ids; 114 glw::GLuint *m_tc_ids; 115 glw::GLuint *m_te_ids; 116 glw::GLuint *m_vs_ids; 117 }; 118 119 /** Make sure that declaring per-vertex input blocks in 120 * a non-arrayed manner in tessellation control shaders results in 121 * a compile- or link-time error. 122 * 123 **/ 124 class TessellationShaderError1InputBlocks : public TessellationShaderErrorsTestCaseBase 125 { 126 public: 127 /* Public methods */ 128 TessellationShaderError1InputBlocks(Context &context, const ExtParameters &extParams); 129 ~TessellationShaderError1InputBlocks(void)130 virtual ~TessellationShaderError1InputBlocks(void) 131 { 132 } 133 134 protected: 135 /* Protected methods */ 136 _compilation_result getCompilationResult(_pipeline_stage pipeline_stage); 137 _linking_result getLinkingResult(); 138 std::string getTessellationControlShaderCode(unsigned int n_program_object); 139 std::string getTessellationEvaluationShaderCode(unsigned int n_program_object); 140 std::string getVertexShaderCode(unsigned int n_program_object); 141 bool isPipelineStageUsed(_pipeline_stage stage); 142 }; 143 144 /** Make sure that declaring per-vertex input variables in 145 * a non-arrayed manner in tessellation control shaders results in 146 * a compile- or link-time error. 147 * 148 **/ 149 class TessellationShaderError1InputVariables : public TessellationShaderErrorsTestCaseBase 150 { 151 public: 152 /* Public methods */ 153 TessellationShaderError1InputVariables(Context &context, const ExtParameters &extParams); 154 ~TessellationShaderError1InputVariables(void)155 virtual ~TessellationShaderError1InputVariables(void) 156 { 157 } 158 159 protected: 160 /* Protected methods */ 161 _compilation_result getCompilationResult(_pipeline_stage pipeline_stage); 162 _linking_result getLinkingResult(); 163 std::string getTessellationControlShaderCode(unsigned int n_program_object); 164 std::string getTessellationEvaluationShaderCode(unsigned int n_program_object); 165 std::string getVertexShaderCode(unsigned int n_program_object); 166 bool isPipelineStageUsed(_pipeline_stage stage); 167 }; 168 169 /* Make sure that declaring per-vertex output blocks in 170 * a non-arrayed manner in tessellation control shaders results in 171 * a compile- or link-time error. 172 */ 173 class TessellationShaderError2OutputBlocks : public TessellationShaderErrorsTestCaseBase 174 { 175 public: 176 /* Public methods */ 177 TessellationShaderError2OutputBlocks(Context &context, const ExtParameters &extParams); 178 ~TessellationShaderError2OutputBlocks(void)179 virtual ~TessellationShaderError2OutputBlocks(void) 180 { 181 } 182 183 protected: 184 /* Protected methods */ 185 _compilation_result getCompilationResult(_pipeline_stage pipeline_stage); 186 _linking_result getLinkingResult(); 187 std::string getTessellationControlShaderCode(unsigned int n_program_object); 188 std::string getTessellationEvaluationShaderCode(unsigned int n_program_object); 189 bool isPipelineStageUsed(_pipeline_stage stage); 190 }; 191 192 /* Make sure that declaring per-vertex output variables in 193 * a non-arrayed manner in tessellation control shaders results in 194 * a compile- or link-time error. 195 */ 196 class TessellationShaderError2OutputVariables : public TessellationShaderErrorsTestCaseBase 197 { 198 public: 199 /* Public methods */ 200 TessellationShaderError2OutputVariables(Context &context, const ExtParameters &extParams); 201 ~TessellationShaderError2OutputVariables(void)202 virtual ~TessellationShaderError2OutputVariables(void) 203 { 204 } 205 206 protected: 207 /* Protected methods */ 208 _compilation_result getCompilationResult(_pipeline_stage pipeline_stage); 209 _linking_result getLinkingResult(); 210 std::string getTessellationControlShaderCode(unsigned int n_program_object); 211 std::string getTessellationEvaluationShaderCode(unsigned int n_program_object); 212 bool isPipelineStageUsed(_pipeline_stage stage); 213 }; 214 215 /* Make sure that declaring per-vertex input blocks in 216 * a non-arrayed manner in tessellation evaluation shaders results 217 * in a compile- or link-time error. 218 */ 219 class TessellationShaderError3InputBlocks : public TessellationShaderErrorsTestCaseBase 220 { 221 public: 222 /* Public methods */ 223 TessellationShaderError3InputBlocks(Context &context, const ExtParameters &extParams); 224 ~TessellationShaderError3InputBlocks(void)225 virtual ~TessellationShaderError3InputBlocks(void) 226 { 227 } 228 229 protected: 230 /* Protected methods */ 231 _compilation_result getCompilationResult(_pipeline_stage pipeline_stage); 232 _linking_result getLinkingResult(); 233 std::string getTessellationControlShaderCode(unsigned int n_program_object); 234 std::string getTessellationEvaluationShaderCode(unsigned int n_program_object); 235 bool isPipelineStageUsed(_pipeline_stage stage); 236 }; 237 238 /* Make sure that declaring per-vertex input variables in 239 * a non-arrayed manner in tessellation evaluation shaders results 240 * in a compile- or link-time error. 241 */ 242 class TessellationShaderError3InputVariables : public TessellationShaderErrorsTestCaseBase 243 { 244 public: 245 /* Public methods */ 246 TessellationShaderError3InputVariables(Context &context, const ExtParameters &extParams); 247 ~TessellationShaderError3InputVariables(void)248 virtual ~TessellationShaderError3InputVariables(void) 249 { 250 } 251 252 protected: 253 /* Protected methods */ 254 _compilation_result getCompilationResult(_pipeline_stage pipeline_stage); 255 _linking_result getLinkingResult(); 256 std::string getTessellationControlShaderCode(unsigned int n_program_object); 257 std::string getTessellationEvaluationShaderCode(unsigned int n_program_object); 258 bool isPipelineStageUsed(_pipeline_stage stage); 259 }; 260 261 /* Make sure that using an array size different than gl_MaxPatchVertices for 262 * per-vertex input blocks in tessellation control shaders results in a compile- 263 * or link-time error. 264 */ 265 class TessellationShaderError4InputBlocks : public TessellationShaderErrorsTestCaseBase 266 { 267 public: 268 /* Public methods */ 269 TessellationShaderError4InputBlocks(Context &context, const ExtParameters &extParams); 270 ~TessellationShaderError4InputBlocks(void)271 virtual ~TessellationShaderError4InputBlocks(void) 272 { 273 } 274 275 protected: 276 /* Protected methods */ 277 _compilation_result getCompilationResult(_pipeline_stage pipeline_stage); 278 _linking_result getLinkingResult(); 279 std::string getTessellationControlShaderCode(unsigned int n_program_object); 280 std::string getTessellationEvaluationShaderCode(unsigned int n_program_object); 281 bool isPipelineStageUsed(_pipeline_stage stage); 282 }; 283 284 /* Make sure that using an array size different than gl_MaxPatchVertices for 285 * per-vertex input variables in tessellation control shaders results in a compile- 286 * or link-time error. 287 */ 288 class TessellationShaderError4InputVariables : public TessellationShaderErrorsTestCaseBase 289 { 290 public: 291 /* Public methods */ 292 TessellationShaderError4InputVariables(Context &context, const ExtParameters &extParams); 293 ~TessellationShaderError4InputVariables(void)294 virtual ~TessellationShaderError4InputVariables(void) 295 { 296 } 297 298 protected: 299 /* Protected methods */ 300 _compilation_result getCompilationResult(_pipeline_stage pipeline_stage); 301 _linking_result getLinkingResult(); 302 std::string getTessellationControlShaderCode(unsigned int n_program_object); 303 std::string getTessellationEvaluationShaderCode(unsigned int n_program_object); 304 bool isPipelineStageUsed(_pipeline_stage stage); 305 }; 306 307 /* Make sure that using an array size different than gl_MaxPatchVertices for 308 * per-vertex input blocks in tessellation evaluation shaders 309 * results in a compile- or link-time error. 310 */ 311 class TessellationShaderError5InputBlocks : public TessellationShaderErrorsTestCaseBase 312 { 313 public: 314 /* Public methods */ 315 TessellationShaderError5InputBlocks(Context &context, const ExtParameters &extParams); 316 ~TessellationShaderError5InputBlocks(void)317 virtual ~TessellationShaderError5InputBlocks(void) 318 { 319 } 320 321 protected: 322 /* Protected methods */ 323 _compilation_result getCompilationResult(_pipeline_stage pipeline_stage); 324 _linking_result getLinkingResult(); 325 std::string getTessellationControlShaderCode(unsigned int n_program_object); 326 std::string getTessellationEvaluationShaderCode(unsigned int n_program_object); 327 bool isPipelineStageUsed(_pipeline_stage stage); 328 }; 329 330 /* Make sure that using an array size different than gl_MaxPatchVertices for 331 * per-vertex input variables in tessellation evaluation shaders results in 332 * a compile- or link-time error. 333 */ 334 class TessellationShaderError5InputVariables : public TessellationShaderErrorsTestCaseBase 335 { 336 public: 337 /* Public methods */ 338 TessellationShaderError5InputVariables(Context &context, const ExtParameters &extParams); 339 ~TessellationShaderError5InputVariables(void)340 virtual ~TessellationShaderError5InputVariables(void) 341 { 342 } 343 344 protected: 345 /* Protected methods */ 346 _compilation_result getCompilationResult(_pipeline_stage pipeline_stage); 347 _linking_result getLinkingResult(); 348 std::string getTessellationControlShaderCode(unsigned int n_program_object); 349 std::string getTessellationEvaluationShaderCode(unsigned int n_program_object); 350 bool isPipelineStageUsed(_pipeline_stage stage); 351 }; 352 353 /* 354 * Make sure that a program object will fail to link, or that the relevant 355 * tessellation control shader object fails to compile, if the output patch 356 * vertex count specified by the tessellation control shader object attached 357 * to the program is <= 0 or > GL_MAX_PATCH_VERTICES_EXT; 358 */ 359 class TessellationShaderError6 : public TessellationShaderErrorsTestCaseBase 360 { 361 public: 362 /* Public methods */ 363 TessellationShaderError6(Context &context, const ExtParameters &extParams); 364 ~TessellationShaderError6(void)365 virtual ~TessellationShaderError6(void) 366 { 367 } 368 369 protected: 370 /* Protected methods */ 371 unsigned int getAmountOfProgramObjects(); 372 _compilation_result getCompilationResult(_pipeline_stage pipeline_stage); 373 _linking_result getLinkingResult(); 374 std::string getTessellationControlShaderCode(unsigned int n_program_object); 375 std::string getTessellationEvaluationShaderCode(unsigned int n_program_object); 376 bool isPipelineStageUsed(_pipeline_stage stage); 377 }; 378 379 /* Make sure it is a compile- or link-time error to write to a per-vertex output 380 * variable in a tessellation control shader at index which is not equal 381 * to gl_InvocationID; 382 */ 383 class TessellationShaderError7 : public TessellationShaderErrorsTestCaseBase 384 { 385 public: 386 /* Public methods */ 387 TessellationShaderError7(Context &context, const ExtParameters &extParams); 388 ~TessellationShaderError7(void)389 virtual ~TessellationShaderError7(void) 390 { 391 } 392 393 protected: 394 /* Protected methods */ 395 _compilation_result getCompilationResult(_pipeline_stage pipeline_stage); 396 _linking_result getLinkingResult(); 397 std::string getTessellationControlShaderCode(unsigned int n_program_object); 398 std::string getTessellationEvaluationShaderCode(unsigned int n_program_object); 399 bool isPipelineStageUsed(_pipeline_stage stage); 400 }; 401 402 /* Make sure it is a compile-time error to define input per-patch attributes 403 * in a tessellation control shader. 404 * 405 */ 406 class TessellationShaderError8 : public TessellationShaderErrorsTestCaseBase 407 { 408 public: 409 /* Public methods */ 410 TessellationShaderError8(Context &context, const ExtParameters &extParams); 411 ~TessellationShaderError8(void)412 virtual ~TessellationShaderError8(void) 413 { 414 } 415 416 protected: 417 /* Protected methods */ 418 _compilation_result getCompilationResult(_pipeline_stage pipeline_stage); 419 _linking_result getLinkingResult(); 420 std::string getTessellationControlShaderCode(unsigned int n_program_object); 421 std::string getTessellationEvaluationShaderCode(unsigned int n_program_object); 422 bool isPipelineStageUsed(_pipeline_stage stage); 423 }; 424 425 /* 426 * Make sure it is a compile- or link-time error to define output per-patch attributes 427 * in a tessellation evaluation shader. 428 */ 429 class TessellationShaderError9 : public TessellationShaderErrorsTestCaseBase 430 { 431 public: 432 /* Public methods */ 433 TessellationShaderError9(Context &context, const ExtParameters &extParams); 434 ~TessellationShaderError9(void)435 virtual ~TessellationShaderError9(void) 436 { 437 } 438 439 protected: 440 /* Protected methods */ 441 _compilation_result getCompilationResult(_pipeline_stage pipeline_stage); 442 _linking_result getLinkingResult(); 443 std::string getTessellationControlShaderCode(unsigned int n_program_object); 444 std::string getTessellationEvaluationShaderCode(unsigned int n_program_object); 445 bool isPipelineStageUsed(_pipeline_stage stage); 446 }; 447 448 /* Make sure that it is a link-time error to use a different type or qualification 449 * for a per-patch input variable in a tessellation evaluation shader, than was 450 * used to define a corresponding output variable in a tessellation control shader. 451 */ 452 class TessellationShaderError10 : public TessellationShaderErrorsTestCaseBase 453 { 454 public: 455 /* Public methods */ 456 TessellationShaderError10(Context &context, const ExtParameters &extParams); 457 ~TessellationShaderError10(void)458 virtual ~TessellationShaderError10(void) 459 { 460 } 461 462 protected: 463 /* Protected methods */ 464 _compilation_result getCompilationResult(_pipeline_stage pipeline_stage); 465 _linking_result getLinkingResult(); 466 std::string getTessellationControlShaderCode(unsigned int n_program_object); 467 std::string getTessellationEvaluationShaderCode(unsigned int n_program_object); 468 bool isPipelineStageUsed(_pipeline_stage stage); 469 }; 470 471 /* Make sure it is a link-time error not to declare primitive mode in 472 * input layout of a tessellation evaluation shader object. 473 */ 474 class TessellationShaderError11 : public TessellationShaderErrorsTestCaseBase 475 { 476 public: 477 /* Public methods */ 478 TessellationShaderError11(Context &context, const ExtParameters &extParams); 479 ~TessellationShaderError11(void)480 virtual ~TessellationShaderError11(void) 481 { 482 } 483 484 protected: 485 /* Protected methods */ 486 _compilation_result getCompilationResult(_pipeline_stage pipeline_stage); 487 _linking_result getLinkingResult(); 488 std::string getTessellationControlShaderCode(unsigned int n_program_object); 489 std::string getTessellationEvaluationShaderCode(unsigned int n_program_object); 490 bool isPipelineStageUsed(_pipeline_stage stage); 491 }; 492 493 /* Make sure it is a compile- or link-time error to access gl_TessCoord as if it 494 * was an array. 495 */ 496 class TessellationShaderError12 : public TessellationShaderErrorsTestCaseBase 497 { 498 public: 499 /* Public methods */ 500 TessellationShaderError12(Context &context, const ExtParameters &extParams); 501 ~TessellationShaderError12(void)502 virtual ~TessellationShaderError12(void) 503 { 504 } 505 506 protected: 507 /* Protected methods */ 508 _compilation_result getCompilationResult(_pipeline_stage pipeline_stage); 509 _linking_result getLinkingResult(); 510 std::string getTessellationControlShaderCode(unsigned int n_program_object); 511 std::string getTessellationEvaluationShaderCode(unsigned int n_program_object); 512 bool isPipelineStageUsed(_pipeline_stage stage); 513 }; 514 515 /* Make sure it is a compile- or link-time error to access gl_TessCoord as if it 516 * was a member of gl_in array. 517 */ 518 class TessellationShaderError13 : public TessellationShaderErrorsTestCaseBase 519 { 520 public: 521 /* Public methods */ 522 TessellationShaderError13(Context &context, const ExtParameters &extParams); 523 ~TessellationShaderError13(void)524 virtual ~TessellationShaderError13(void) 525 { 526 } 527 528 protected: 529 /* Protected methods */ 530 _compilation_result getCompilationResult(_pipeline_stage pipeline_stage); 531 _linking_result getLinkingResult(); 532 std::string getTessellationControlShaderCode(unsigned int n_program_object); 533 std::string getTessellationEvaluationShaderCode(unsigned int n_program_object); 534 bool isPipelineStageUsed(_pipeline_stage stage); 535 }; 536 537 } // namespace glcts 538 539 #endif // _ESEXTCTESSELLATIONSHADERERRORS_HPP 540