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