xref: /aosp_15_r20/external/deqp/modules/gles2/functional/es2fNegativeFragmentApiTests.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1 /*-------------------------------------------------------------------------
2  * drawElements Quality Program OpenGL ES 2.0 Module
3  * -------------------------------------------------
4  *
5  * Copyright 2014 The Android Open Source Project
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  * \file
21  * \brief Negative Fragment Pipe API tests.
22  *//*--------------------------------------------------------------------*/
23 
24 #include "es2fNegativeFragmentApiTests.hpp"
25 #include "es2fApiCase.hpp"
26 
27 #include "glwEnums.hpp"
28 #include "glwDefs.hpp"
29 
30 using namespace glw; // GL types
31 
32 namespace deqp
33 {
34 namespace gles2
35 {
36 namespace Functional
37 {
38 
39 using tcu::TestLog;
40 
NegativeFragmentApiTests(Context & context)41 NegativeFragmentApiTests::NegativeFragmentApiTests(Context &context)
42     : TestCaseGroup(context, "fragment", "Negative Fragment API Cases")
43 {
44 }
45 
~NegativeFragmentApiTests(void)46 NegativeFragmentApiTests::~NegativeFragmentApiTests(void)
47 {
48 }
49 
init(void)50 void NegativeFragmentApiTests::init(void)
51 {
52     ES2F_ADD_API_CASE(scissor, "Invalid glScissor() usage", {
53         m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if either width or height is negative.");
54         glScissor(0, 0, -1, 0);
55         expectError(GL_INVALID_VALUE);
56         glScissor(0, 0, 0, -1);
57         expectError(GL_INVALID_VALUE);
58         glScissor(0, 0, -1, -1);
59         expectError(GL_INVALID_VALUE);
60         m_log << TestLog::EndSection;
61     });
62     ES2F_ADD_API_CASE(depth_func, "Invalid glDepthFunc() usage", {
63         m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if func is not an accepted value.");
64         glDepthFunc(-1);
65         expectError(GL_INVALID_ENUM);
66         m_log << TestLog::EndSection;
67     });
68     ES2F_ADD_API_CASE(viewport, "Invalid glViewport() usage", {
69         m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if either width or height is negative.");
70         glViewport(0, 0, -1, 1);
71         expectError(GL_INVALID_VALUE);
72         glViewport(0, 0, 1, -1);
73         expectError(GL_INVALID_VALUE);
74         glViewport(0, 0, -1, -1);
75         expectError(GL_INVALID_VALUE);
76         m_log << TestLog::EndSection;
77     });
78 
79     // Stencil functions
80 
81     ES2F_ADD_API_CASE(stencil_func, "Invalid glStencilFunc() usage", {
82         m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if func is not one of the eight accepted values.");
83         glStencilFunc(-1, 0, 1);
84         expectError(GL_INVALID_ENUM);
85         m_log << TestLog::EndSection;
86     });
87     ES2F_ADD_API_CASE(stencil_func_separate, "Invalid glStencilFuncSeparate() usage", {
88         m_log << TestLog::Section(
89             "", "GL_INVALID_ENUM is generated if face is not GL_FRONT, GL_BACK, or GL_FRONT_AND_BACK.");
90         glStencilFuncSeparate(-1, GL_NEVER, 0, 1);
91         expectError(GL_INVALID_ENUM);
92         m_log << TestLog::EndSection;
93 
94         m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if func is not one of the eight accepted values.");
95         glStencilFuncSeparate(GL_FRONT, -1, 0, 1);
96         expectError(GL_INVALID_ENUM);
97         m_log << TestLog::EndSection;
98     });
99     ES2F_ADD_API_CASE(stencil_op, "Invalid glStencilOp() usage", {
100         m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if sfail, dpfail, or dppass is any value other "
101                                       "than the eight defined symbolic constant values.");
102         glStencilOp(-1, GL_ZERO, GL_REPLACE);
103         expectError(GL_INVALID_ENUM);
104         glStencilOp(GL_KEEP, -1, GL_REPLACE);
105         expectError(GL_INVALID_ENUM);
106         glStencilOp(GL_KEEP, GL_ZERO, -1);
107         expectError(GL_INVALID_ENUM);
108         m_log << TestLog::EndSection;
109     });
110     ES2F_ADD_API_CASE(stencil_op_separate, "Invalid glStencilOpSeparate() usage", {
111         m_log << TestLog::Section(
112             "",
113             "GL_INVALID_ENUM is generated if face is any value other than GL_FRONT, GL_BACK, or GL_FRONT_AND_BACK.");
114         glStencilOpSeparate(-1, GL_KEEP, GL_ZERO, GL_REPLACE);
115         expectError(GL_INVALID_ENUM);
116         m_log << TestLog::EndSection;
117 
118         m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if sfail, dpfail, or dppass is any value other "
119                                       "than the eight defined symbolic constant values.");
120         glStencilOpSeparate(GL_FRONT, -1, GL_ZERO, GL_REPLACE);
121         expectError(GL_INVALID_ENUM);
122         glStencilOpSeparate(GL_FRONT, GL_KEEP, -1, GL_REPLACE);
123         expectError(GL_INVALID_ENUM);
124         glStencilOpSeparate(GL_FRONT, GL_KEEP, GL_ZERO, -1);
125         expectError(GL_INVALID_ENUM);
126         m_log << TestLog::EndSection;
127     });
128     ES2F_ADD_API_CASE(stencil_mask_separate, "Invalid glStencilMaskSeparate() usage", {
129         m_log << TestLog::Section(
130             "", "GL_INVALID_ENUM is generated if face is not GL_FRONT, GL_BACK, or GL_FRONT_AND_BACK.");
131         glStencilMaskSeparate(-1, 0);
132         expectError(GL_INVALID_ENUM);
133         m_log << TestLog::EndSection;
134     });
135 
136     // Blend functions
137 
138     ES2F_ADD_API_CASE(blend_equation, "Invalid glBlendEquation() usage", {
139         m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if mode is not one of GL_FUNC_ADD, "
140                                       "GL_FUNC_SUBTRACT, or GL_FUNC_REVERSE_SUBTRACT.");
141         glBlendEquation(-1);
142         expectError(GL_INVALID_ENUM);
143         m_log << TestLog::EndSection;
144     });
145     ES2F_ADD_API_CASE(blend_equation_separate, "Invalid glBlendEquationSeparate() usage", {
146         m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if either modeRGB or modeAlpha is not one of "
147                                       "GL_FUNC_ADD, GL_FUNC_SUBTRACT, or GL_FUNC_REVERSE_SUBTRACT.");
148         glBlendEquationSeparate(-1, GL_FUNC_ADD);
149         expectError(GL_INVALID_ENUM);
150         glBlendEquationSeparate(GL_FUNC_ADD, -1);
151         expectError(GL_INVALID_ENUM);
152         m_log << TestLog::EndSection;
153     });
154     ES2F_ADD_API_CASE(blend_func_separate, "Invalid glBlendFuncSeparate() usage", {
155         m_log << TestLog::Section(
156             "", "GL_INVALID_ENUM is generated if srcRGB, dstRGB, srcAlpha, or dstAlpha is not an accepted value.");
157         glBlendFuncSeparate(-1, GL_ONE, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR);
158         expectError(GL_INVALID_ENUM);
159         glBlendFuncSeparate(GL_ZERO, -1, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR);
160         expectError(GL_INVALID_ENUM);
161         glBlendFuncSeparate(GL_ZERO, GL_ONE, -1, GL_ONE_MINUS_SRC_COLOR);
162         expectError(GL_INVALID_ENUM);
163         glBlendFuncSeparate(GL_ZERO, GL_ONE, GL_SRC_COLOR, -1);
164         expectError(GL_INVALID_ENUM);
165         m_log << TestLog::EndSection;
166     });
167     ES2F_ADD_API_CASE(blend_func, "Invalid glBlendFunc() usage", {
168         m_log << TestLog::Section(
169             "", "GL_INVALID_ENUM is generated if either sfactor or dfactor is not an accepted value.");
170         glBlendFunc(-1, GL_ONE);
171         expectError(GL_INVALID_ENUM);
172         glBlendFunc(GL_ONE, -1);
173         expectError(GL_INVALID_ENUM);
174         m_log << TestLog::EndSection;
175     });
176 
177     // Rasterization API functions
178 
179     ES2F_ADD_API_CASE(cull_face, "Invalid glCullFace() usage", {
180         m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if mode is not an accepted value.");
181         glCullFace(-1);
182         expectError(GL_INVALID_ENUM);
183         m_log << TestLog::EndSection;
184     });
185 
186     ES2F_ADD_API_CASE(front_face, "Invalid glFrontFace() usage", {
187         m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if mode is not an accepted value.");
188         glFrontFace(-1);
189         expectError(GL_INVALID_ENUM);
190         m_log << TestLog::EndSection;
191     });
192 
193     ES2F_ADD_API_CASE(line_width, "Invalid glLineWidth() usage", {
194         m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width is less than or equal to 0.");
195         glLineWidth(0);
196         expectError(GL_INVALID_VALUE);
197         glLineWidth(-1);
198         expectError(GL_INVALID_VALUE);
199         m_log << TestLog::EndSection;
200     });
201 }
202 
203 } // namespace Functional
204 } // namespace gles2
205 } // namespace deqp
206