1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 3.0 Module
3 * -------------------------------------------------
5 * Copyright 2014 The Android Open Source Project
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 * \brief State change call performance tests.
22 *//*--------------------------------------------------------------------*/
24 #include "es3pStateChangeCallTests.hpp"
25 #include "glsStateChangePerfTestCases.hpp"
26 #include "glwFunctions.hpp"
27 #include "glwEnums.hpp"
38 StateChangeCallTests::StateChangeCallTests (Context& context)
39 : TestCaseGroup(context, "state_change_only", "Test cost of state change calls without rendering anything")
43 StateChangeCallTests::~StateChangeCallTests (void)
47 #define ARG_LIST(...) __VA_ARGS__
49 #define ADD_ARG_CASE1(NAME, DESCRIPTION, FUNCNAME, TYPE0, ARGS0)\
51 class StateChangeCallTest_ ## NAME : public gls::StateChangeCallPerformanceCase\
54 StateChangeCallTest_ ## NAME (Context& context, const char* name, const char* description)\
55 : gls::StateChangeCallPerformanceCase(context.getTestContext(), context.getRenderContext(), name, description)\
58 virtual void execCalls (const glw::Functions& gl, int iterNdx, int callCount)\
60 const TYPE0 args0[] = ARGS0;\
61 for (int callNdx = 0; callNdx < callCount; callNdx++)\
63 const int baseNdx = iterNdx*callCount + callNdx;\
64 const TYPE0 arg0 = args0[baseNdx%DE_LENGTH_OF_ARRAY(args0)];\
69 addChild(new StateChangeCallTest_ ## NAME (m_context, #NAME, DESCRIPTION));\
72 #define ADD_ARG_CASE2(NAME, DESCRIPTION, FUNCNAME, TYPE0, ARGS0, TYPE1, ARGS1)\
74 class StateChangeCallTest_ ## NAME : public gls::StateChangeCallPerformanceCase\
77 StateChangeCallTest_ ## NAME (Context& context, const char* name, const char* description)\
78 : gls::StateChangeCallPerformanceCase(context.getTestContext(), context.getRenderContext(), name, description)\
81 virtual void execCalls (const glw::Functions& gl, int iterNdx, int callCount)\
83 const TYPE0 args0[] = ARGS0;\
84 const TYPE1 args1[] = ARGS1;\
85 for (int callNdx = 0; callNdx < callCount; callNdx++)\
87 const int baseNdx = iterNdx*callCount + callNdx;\
88 const TYPE0 arg0 = args0[baseNdx%DE_LENGTH_OF_ARRAY(args0)];\
89 const TYPE1 arg1 = args1[baseNdx%DE_LENGTH_OF_ARRAY(args1)];\
90 gl.FUNCNAME(arg0, arg1);\
94 addChild(new StateChangeCallTest_ ## NAME (m_context, #NAME, DESCRIPTION));\
97 #define ADD_ARG_CASE3(NAME, DESCRIPTION, FUNCNAME, TYPE0, ARGS0, TYPE1, ARGS1, TYPE2, ARGS2)\
99 class StateChangeCallTest_ ## NAME : public gls::StateChangeCallPerformanceCase\
102 StateChangeCallTest_ ## NAME (Context& context, const char* name, const char* description)\
103 : gls::StateChangeCallPerformanceCase(context.getTestContext(), context.getRenderContext(), name, description)\
106 virtual void execCalls (const glw::Functions& gl, int iterNdx, int callCount)\
108 const TYPE0 args0[] = ARGS0;\
109 const TYPE1 args1[] = ARGS1;\
110 const TYPE2 args2[] = ARGS2;\
111 for (int callNdx = 0; callNdx < callCount; callNdx++)\
113 const int baseNdx = iterNdx*callCount + callNdx;\
114 const TYPE0 arg0 = args0[baseNdx%DE_LENGTH_OF_ARRAY(args0)];\
115 const TYPE1 arg1 = args1[baseNdx%DE_LENGTH_OF_ARRAY(args1)];\
116 const TYPE2 arg2 = args2[baseNdx%DE_LENGTH_OF_ARRAY(args2)];\
117 gl.FUNCNAME(arg0, arg1, arg2);\
121 addChild(new StateChangeCallTest_ ## NAME (m_context, #NAME, DESCRIPTION));\
124 #define ADD_ARG_CASE4(NAME, DESCRIPTION, FUNCNAME, TYPE0, ARGS0, TYPE1, ARGS1, TYPE2, ARGS2, TYPE3, ARGS3)\
126 class StateChangeCallTest_ ## NAME : public gls::StateChangeCallPerformanceCase\
129 StateChangeCallTest_ ## NAME (Context& context, const char* name, const char* description)\
130 : gls::StateChangeCallPerformanceCase(context.getTestContext(), context.getRenderContext(), name, description)\
133 virtual void execCalls (const glw::Functions& gl, int iterNdx, int callCount)\
135 const TYPE0 args0[] = ARGS0;\
136 const TYPE1 args1[] = ARGS1;\
137 const TYPE2 args2[] = ARGS2;\
138 const TYPE3 args3[] = ARGS3;\
139 for (int callNdx = 0; callNdx < callCount; callNdx++)\
141 const int baseNdx = iterNdx*callCount + callNdx;\
142 const TYPE0 arg0 = args0[baseNdx%DE_LENGTH_OF_ARRAY(args0)];\
143 const TYPE1 arg1 = args1[baseNdx%DE_LENGTH_OF_ARRAY(args1)];\
144 const TYPE2 arg2 = args2[baseNdx%DE_LENGTH_OF_ARRAY(args2)];\
145 const TYPE3 arg3 = args3[baseNdx%DE_LENGTH_OF_ARRAY(args3)];\
146 gl.FUNCNAME(arg0, arg1, arg2, arg3);\
150 addChild(new StateChangeCallTest_ ## NAME (m_context, #NAME, DESCRIPTION));\
153 #define ADD_ARG_CASE5(NAME, DESCRIPTION, FUNCNAME, TYPE0, ARGS0, TYPE1, ARGS1, TYPE2, ARGS2, TYPE3, ARGS3, TYPE4, ARGS4)\
155 class StateChangeCallTest_ ## NAME : public gls::StateChangeCallPerformanceCase\
158 StateChangeCallTest_ ## NAME (Context& context, const char* name, const char* description)\
159 : gls::StateChangeCallPerformanceCase(context.getTestContext(), context.getRenderContext(), name, description)\
162 virtual void execCalls (const glw::Functions& gl, int iterNdx, int callCount)\
164 const TYPE0 args0[] = ARGS0;\
165 const TYPE1 args1[] = ARGS1;\
166 const TYPE2 args2[] = ARGS2;\
167 const TYPE3 args3[] = ARGS3;\
168 const TYPE4 args4[] = ARGS4;\
169 for (int callNdx = 0; callNdx < callCount; callNdx++)\
171 const int baseNdx = iterNdx*callCount + callNdx;\
172 const TYPE0 arg0 = args0[baseNdx%DE_LENGTH_OF_ARRAY(args0)];\
173 const TYPE1 arg1 = args1[baseNdx%DE_LENGTH_OF_ARRAY(args1)];\
174 const TYPE2 arg2 = args2[baseNdx%DE_LENGTH_OF_ARRAY(args2)];\
175 const TYPE3 arg3 = args3[baseNdx%DE_LENGTH_OF_ARRAY(args3)];\
176 const TYPE4 arg4 = args4[baseNdx%DE_LENGTH_OF_ARRAY(args4)];\
177 gl.FUNCNAME(arg0, arg1, arg2, arg3, arg4);\
181 addChild(new StateChangeCallTest_ ## NAME (m_context, #NAME, DESCRIPTION));\
184 #define ADD_ARG_CASE6(NAME, DESCRIPTION, FUNCNAME, TYPE0, ARGS0, TYPE1, ARGS1, TYPE2, ARGS2, TYPE3, ARGS3, TYPE4, ARGS4, TYPE5, ARGS5)\
186 class StateChangeCallTest_ ## NAME : public gls::StateChangeCallPerformanceCase\
189 StateChangeCallTest_ ## NAME (Context& context, const char* name, const char* description)\
190 : gls::StateChangeCallPerformanceCase(context.getTestContext(), context.getRenderContext(), name, description)\
193 virtual void execCalls (const glw::Functions& gl, int iterNdx, int callCount)\
195 const TYPE0 args0[] = ARGS0;\
196 const TYPE1 args1[] = ARGS1;\
197 const TYPE2 args2[] = ARGS2;\
198 const TYPE3 args3[] = ARGS3;\
199 const TYPE4 args4[] = ARGS4;\
200 const TYPE5 args5[] = ARGS5;\
201 for (int callNdx = 0; callNdx < callCount; callNdx++)\
203 const int baseNdx = iterNdx*callCount + callNdx;\
204 const TYPE0 arg0 = args0[baseNdx%DE_LENGTH_OF_ARRAY(args0)];\
205 const TYPE1 arg1 = args1[baseNdx%DE_LENGTH_OF_ARRAY(args1)];\
206 const TYPE2 arg2 = args2[baseNdx%DE_LENGTH_OF_ARRAY(args2)];\
207 const TYPE3 arg3 = args3[baseNdx%DE_LENGTH_OF_ARRAY(args3)];\
208 const TYPE4 arg4 = args4[baseNdx%DE_LENGTH_OF_ARRAY(args4)];\
209 const TYPE5 arg5 = args5[baseNdx%DE_LENGTH_OF_ARRAY(args5)];\
210 gl.FUNCNAME(arg0, arg1, arg2, arg3, arg4, arg5);\
214 addChild(new StateChangeCallTest_ ## NAME (m_context, #NAME, DESCRIPTION));\
217 void StateChangeCallTests::init (void)
219 ADD_ARG_CASE1(enable, "Test cost of glEnable() calls",
224 GL_POLYGON_OFFSET_FILL,
225 GL_SAMPLE_ALPHA_TO_COVERAGE,
232 GL_RASTERIZER_DISCARD,
233 GL_PRIMITIVE_RESTART_FIXED_INDEX
237 ADD_ARG_CASE1(disable, "Test cost of glDisable() calls",
242 GL_POLYGON_OFFSET_FILL,
243 GL_SAMPLE_ALPHA_TO_COVERAGE,
250 GL_RASTERIZER_DISCARD,
251 GL_PRIMITIVE_RESTART_FIXED_INDEX
255 ADD_ARG_CASE1(depth_func, "Test cost of glDepthFunc() calls",
270 ADD_ARG_CASE1(depth_mask, "Test cost of glDepthMask() calls",
279 ADD_ARG_CASE1(stencil_mask, "Test cost of glStencilMask() calls",
288 ADD_ARG_CASE1(clear_depth, "Test cost of glClearDepth() calls",
298 ADD_ARG_CASE1(clear_stencil, "Test cost of glClearStencil() calls",
308 ADD_ARG_CASE1(line_width, "Test cost of glLineWidth() calls",
318 ADD_ARG_CASE1(cull_face, "Test cost of glCullFace() calls",
328 ADD_ARG_CASE1(front_face, "Test cost of glFrontFace() calls",
337 ADD_ARG_CASE1(blend_equation, "Test cost of glBlendEquation() calls",
343 GL_FUNC_REVERSE_SUBTRACT
347 ADD_ARG_CASE1(enable_vertex_attrib_array, "Test cost of glEnableVertexAttribArray() calls",
348 enableVertexAttribArray,
362 ADD_ARG_CASE1(disable_vertex_attrib_array, "Test cost of glDisableVertexAttribArray() calls",
363 disableVertexAttribArray,
377 ADD_ARG_CASE1(use_program, "Test cost of glUseProgram() calls. Note: Uses only program 0.",
385 ADD_ARG_CASE1(active_texture, "Test cost of glActiveTexture() calls",
400 ADD_ARG_CASE2(depth_range, "Test cost of glDepthRangef() calls",
416 ADD_ARG_CASE2(polygon_offset, "Test cost of glPolygonOffset() calls",
434 ADD_ARG_CASE2(sample_coverage, "Test cost of glSampleCoverage() calls",
450 ADD_ARG_CASE2(blend_func, "Test cost of glBlendFunc() calls",
457 GL_ONE_MINUS_SRC_COLOR,
459 GL_ONE_MINUS_DST_COLOR,
461 GL_ONE_MINUS_SRC_ALPHA,
463 GL_ONE_MINUS_DST_ALPHA,
465 GL_ONE_MINUS_CONSTANT_COLOR,
467 GL_ONE_MINUS_CONSTANT_ALPHA
474 GL_ONE_MINUS_SRC_COLOR,
476 GL_ONE_MINUS_DST_COLOR,
478 GL_ONE_MINUS_SRC_ALPHA,
480 GL_ONE_MINUS_DST_ALPHA,
482 GL_ONE_MINUS_CONSTANT_COLOR,
484 GL_ONE_MINUS_CONSTANT_ALPHA
488 ADD_ARG_CASE2(blend_equation_separate, "Test cost of glBlendEquationSeparate() calls",
489 blendEquationSeparate,
494 GL_FUNC_REVERSE_SUBTRACT
500 GL_FUNC_REVERSE_SUBTRACT
504 ADD_ARG_CASE2(stencil_mask_separate, "Test cost of glStencilMaskSeparate() calls",
519 ADD_ARG_CASE2(bind_buffer, "Test cost of glBindBuffer() calls. Note: Uses only buffer 0",
523 GL_ELEMENT_ARRAY_BUFFER,
532 ADD_ARG_CASE2(bind_texture, "Test cost of glBindTexture() calls. Note: Uses only texture 0",
545 ADD_ARG_CASE2(bind_sampler, "Test cost of glBindSampler() calls. Note: Uses only sampler 0",
564 ADD_ARG_CASE1(bind_vertex_array, "Test cost of glBindVertexArray() calls. Note: Uses only VAO 0",
572 ADD_ARG_CASE2(hint, "Test cost of glHint() calls",
576 GL_GENERATE_MIPMAP_HINT
586 ADD_ARG_CASE3(stencil_func, "Test cost of glStencilFunc() calls",
618 ADD_ARG_CASE3(stencil_op, "Test cost of glStencilOp() calls",
655 ADD_ARG_CASE4(viewport, "Test cost of glViewport() calls",
687 ADD_ARG_CASE4(scissor, "Test cost of glScissor() calls",
719 ADD_ARG_CASE4(stencil_func_separate, "Test cost of glStencilFuncSeparate() calls",
757 ADD_ARG_CASE4(stencil_op_separatae, "Test cost of glStencilOpSeparate() calls",
800 ADD_ARG_CASE4(blend_func_separate, "Test cost of glBlendFuncSeparate() calls",
807 GL_ONE_MINUS_SRC_COLOR,
809 GL_ONE_MINUS_DST_COLOR,
811 GL_ONE_MINUS_SRC_ALPHA,
813 GL_ONE_MINUS_DST_ALPHA,
815 GL_ONE_MINUS_CONSTANT_COLOR,
817 GL_ONE_MINUS_CONSTANT_ALPHA
824 GL_ONE_MINUS_SRC_COLOR,
826 GL_ONE_MINUS_DST_COLOR,
828 GL_ONE_MINUS_SRC_ALPHA,
830 GL_ONE_MINUS_DST_ALPHA,
832 GL_ONE_MINUS_CONSTANT_COLOR,
834 GL_ONE_MINUS_CONSTANT_ALPHA
841 GL_ONE_MINUS_SRC_COLOR,
843 GL_ONE_MINUS_DST_COLOR,
845 GL_ONE_MINUS_SRC_ALPHA,
847 GL_ONE_MINUS_DST_ALPHA,
849 GL_ONE_MINUS_CONSTANT_COLOR,
851 GL_ONE_MINUS_CONSTANT_ALPHA
858 GL_ONE_MINUS_SRC_COLOR,
860 GL_ONE_MINUS_DST_COLOR,
862 GL_ONE_MINUS_SRC_ALPHA,
864 GL_ONE_MINUS_DST_ALPHA,
866 GL_ONE_MINUS_CONSTANT_COLOR,
868 GL_ONE_MINUS_CONSTANT_ALPHA
872 ADD_ARG_CASE4(color_mask, "Test cost of glColorMask() calls",
896 ADD_ARG_CASE4(clear_color, "Test cost of glClearColor() calls",
928 ADD_ARG_CASE6(vertex_attrib_pointer, "Test cost of glVertexAttribPointer() calls",
969 (void*)(deUintptr)(0x0FF),
970 (void*)(deUintptr)(0x0EF)
974 ADD_ARG_CASE2(vertex_attrib_divisor, "Test cost of glVertexAttribDivisor() calls",
999 ADD_ARG_CASE3(bind_buffer_base, "Test cost of glBindBufferBase() calls. Note: uses only buffer 0.",
1018 ADD_ARG_CASE5(bind_buffer_range, "Test cost of glBindBufferRange() calls. Note: uses only buffer 0.",