1 /*-------------------------------------------------------------------------
2  * OpenGL Conformance Test Suite
3  * -----------------------------
4  *
5  * Copyright (c) 2022-2022 The Khronos Group Inc.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20 
21 /*!
22  * \file  esextcFragmentShadingRateComplex.cpp
23  * \brief Base test group for fragment shading rate combination tests
24  */ /*-------------------------------------------------------------------*/
25 
26 #include "esextcFragmentShadingRateComplex.hpp"
27 #include "esextcFragmentShadingRateCombinedTests.hpp"
28 #include "glw.h"
29 
30 namespace glcts
31 {
32 
33 /// Constructor
34 ///
35 /// @param context       Test context
36 /// @param extParams   extra parameters
FragmentShadingRateComplex(glcts::Context & context,const ExtParameters & extParams)37 FragmentShadingRateComplex::FragmentShadingRateComplex(glcts::Context &context, const ExtParameters &extParams)
38     : TestCaseGroupBase(context, extParams, "complex", "Fragment Shading Rate Complex Tests")
39 {
40 }
41 
42 /// Initializes test cases for fragment shading rate tests
init(void)43 void FragmentShadingRateComplex::init(void)
44 {
45     TestNode::init();
46 
47     // on/off combination list
48     // 1. ShadingRate API
49     // 2. Primitive Shading Rate
50     // 3. Attachment Shading Rate
51     // 4. op1 Enums, Keep, Replace, Min, Max, Mul
52     // 5. op2 Enums, Keep, Replace, Min, Max, Mul
53     // 6. MultiSample Enable
54     // 7. Framebuffer sizes
55 
56     struct BooleanTestParam
57     {
58         bool state;
59         std::string name;
60     };
61 
62     struct EnumTestParam
63     {
64         glw::GLenum state;
65         std::string name;
66     };
67 
68     struct IntTestParam
69     {
70         int state;
71         std::string name;
72     };
73 
74     const std::vector<BooleanTestParam> shadingRateAPIs{{false, ""}, {true, "api_"}};
75 
76     const std::vector<BooleanTestParam> shadingRatePrimitives{{false, ""}, {true, "primitive_"}};
77 
78     const std::vector<BooleanTestParam> shadingRateAttachments{{false, ""}, {true, "attachment_"}};
79 
80     const std::vector<EnumTestParam> combineAttachments{{GL_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_EXT, "keep_"},
81                                                         {GL_FRAGMENT_SHADING_RATE_COMBINER_OP_REPLACE_EXT, "replace_"},
82                                                         {GL_FRAGMENT_SHADING_RATE_COMBINER_OP_MIN_EXT, "min_"},
83                                                         {GL_FRAGMENT_SHADING_RATE_COMBINER_OP_MAX_EXT, "max_"},
84                                                         {GL_FRAGMENT_SHADING_RATE_COMBINER_OP_MUL_EXT, "mul_"}};
85 
86     const std::vector<BooleanTestParam> msaas{{false, ""}, {true, "msaa_"}};
87 
88     const std::vector<IntTestParam> sizes{
89         {6, "6x6"},
90         {37, "37x37"},
91         {256, "256x256"},
92     };
93 
94     for (const BooleanTestParam &shadingRateAPI : shadingRateAPIs)
95     {
96         for (const BooleanTestParam &shadingRatePrimitive : shadingRatePrimitives)
97         {
98             for (const BooleanTestParam &shadingRateAttachment : shadingRateAttachments)
99             {
100                 if (!shadingRateAPI.state && !shadingRatePrimitive.state && !shadingRateAttachment.state)
101                 {
102                     // fragment shading rate does not use
103                     continue;
104                 }
105 
106                 for (const EnumTestParam &op0 : combineAttachments)
107                 {
108                     for (const EnumTestParam &op1 : combineAttachments)
109                     {
110                         for (const BooleanTestParam &msaa : msaas)
111                         {
112                             for (const IntTestParam &sz : sizes)
113                             {
114                                 std::string name = shadingRateAPI.name + shadingRatePrimitive.name +
115                                                    shadingRateAttachment.name + op0.name + op1.name + msaa.name +
116                                                    sz.name;
117                                 FragmentShadingRateCombined::TestcaseParam testcaseParam = {
118                                     shadingRateAPI.state,
119                                     shadingRatePrimitive.state,
120                                     shadingRateAttachment.state,
121                                     op0.state,
122                                     op1.state,
123                                     msaa.state,
124                                     sz.state,
125                                 };
126 
127                                 addChild(new FragmentShadingRateCombined(m_context, m_extParams, testcaseParam,
128                                                                          name.c_str(), ""));
129                             }
130                         }
131                     }
132                 }
133             }
134         }
135     }
136 }
137 } // namespace glcts