1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 2.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 "es2pStateChangeCallTests.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_CASE6(NAME, DESCRIPTION, FUNCNAME, TYPE0, ARGS0, TYPE1, ARGS1, TYPE2, ARGS2, TYPE3, ARGS3, TYPE4, ARGS4, TYPE5, ARGS5)\
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 const TYPE5 args5[] = ARGS5;\
170 for (int callNdx = 0; callNdx < callCount; callNdx++)\
172 const int baseNdx = iterNdx*callCount + callNdx;\
173 const TYPE0 arg0 = args0[baseNdx%DE_LENGTH_OF_ARRAY(args0)];\
174 const TYPE1 arg1 = args1[baseNdx%DE_LENGTH_OF_ARRAY(args1)];\
175 const TYPE2 arg2 = args2[baseNdx%DE_LENGTH_OF_ARRAY(args2)];\
176 const TYPE3 arg3 = args3[baseNdx%DE_LENGTH_OF_ARRAY(args3)];\
177 const TYPE4 arg4 = args4[baseNdx%DE_LENGTH_OF_ARRAY(args4)];\
178 const TYPE5 arg5 = args5[baseNdx%DE_LENGTH_OF_ARRAY(args5)];\
179 gl.FUNCNAME(arg0, arg1, arg2, arg3, arg4, arg5);\
183 addChild(new StateChangeCallTest_ ## NAME (m_context, #NAME, DESCRIPTION));\
186 void StateChangeCallTests::init (void)
188 ADD_ARG_CASE1(enable, "Test cost of glEnable() calls",
193 GL_POLYGON_OFFSET_FILL,
194 GL_SAMPLE_ALPHA_TO_COVERAGE,
204 ADD_ARG_CASE1(disable, "Test cost of glDisable() calls",
209 GL_POLYGON_OFFSET_FILL,
210 GL_SAMPLE_ALPHA_TO_COVERAGE,
220 ADD_ARG_CASE1(depth_func, "Test cost of glDepthFunc() calls",
235 ADD_ARG_CASE1(depth_mask, "Test cost of glDepthMask() calls",
244 ADD_ARG_CASE1(stencil_mask, "Test cost of glStencilMask() calls",
253 ADD_ARG_CASE1(clear_depth, "Test cost of glClearDepth() calls",
263 ADD_ARG_CASE1(clear_stencil, "Test cost of glClearStencil() calls",
273 ADD_ARG_CASE1(line_width, "Test cost of glLineWidth() calls",
283 ADD_ARG_CASE1(cull_face, "Test cost of glCullFace() calls",
293 ADD_ARG_CASE1(front_face, "Test cost of glFrontFace() calls",
302 ADD_ARG_CASE1(blend_equation, "Test cost of glBlendEquation() calls",
308 GL_FUNC_REVERSE_SUBTRACT
312 ADD_ARG_CASE1(enable_vertex_attrib_array, "Test cost of glEnableVertexAttribArray() calls",
313 enableVertexAttribArray,
327 ADD_ARG_CASE1(disable_vertex_attrib_array, "Test cost of glDisableVertexAttribArray() calls",
328 disableVertexAttribArray,
342 ADD_ARG_CASE1(use_program, "Test cost of glUseProgram() calls. Note: Uses only program 0.",
350 ADD_ARG_CASE1(active_texture, "Test cost of glActiveTexture() calls",
365 ADD_ARG_CASE2(depth_range, "Test cost of glDepthRangef() calls",
381 ADD_ARG_CASE2(polygon_offset, "Test cost of glPolygonOffset() calls",
399 ADD_ARG_CASE2(sample_coverage, "Test cost of glSampleCoverage() calls",
415 ADD_ARG_CASE2(blend_func, "Test cost of glBlendFunc() calls",
422 GL_ONE_MINUS_SRC_COLOR,
424 GL_ONE_MINUS_DST_COLOR,
426 GL_ONE_MINUS_SRC_ALPHA,
428 GL_ONE_MINUS_DST_ALPHA,
430 GL_ONE_MINUS_CONSTANT_COLOR,
432 GL_ONE_MINUS_CONSTANT_ALPHA
439 GL_ONE_MINUS_SRC_COLOR,
441 GL_ONE_MINUS_DST_COLOR,
443 GL_ONE_MINUS_SRC_ALPHA,
445 GL_ONE_MINUS_DST_ALPHA,
447 GL_ONE_MINUS_CONSTANT_COLOR,
449 GL_ONE_MINUS_CONSTANT_ALPHA
453 ADD_ARG_CASE2(blend_equation_separate, "Test cost of glBlendEquationSeparate() calls",
454 blendEquationSeparate,
459 GL_FUNC_REVERSE_SUBTRACT
465 GL_FUNC_REVERSE_SUBTRACT
469 ADD_ARG_CASE2(stencil_mask_separate, "Test cost of glStencilMaskSeparate() calls",
484 ADD_ARG_CASE2(bind_buffer, "Test cost of glBindBuffer() calls. Note: Uses only buffer 0",
488 GL_ELEMENT_ARRAY_BUFFER,
497 ADD_ARG_CASE2(bind_texture, "Test cost of glBindTexture() calls. Note: Uses only texture 0",
510 ADD_ARG_CASE2(hint, "Test cost of glHint() calls",
514 GL_GENERATE_MIPMAP_HINT
524 ADD_ARG_CASE3(stencil_func, "Test cost of glStencilFunc() calls",
556 ADD_ARG_CASE3(stencil_op, "Test cost of glStencilOp() calls",
593 ADD_ARG_CASE4(viewport, "Test cost of glViewport() calls",
625 ADD_ARG_CASE4(scissor, "Test cost of glScissor() calls",
657 ADD_ARG_CASE4(stencil_func_separate, "Test cost of glStencilFuncSeparate() calls",
695 ADD_ARG_CASE4(stencil_op_separatae, "Test cost of glStencilOpSeparate() calls",
738 ADD_ARG_CASE4(blend_func_separate, "Test cost of glBlendFuncSeparate() calls",
745 GL_ONE_MINUS_SRC_COLOR,
747 GL_ONE_MINUS_DST_COLOR,
749 GL_ONE_MINUS_SRC_ALPHA,
751 GL_ONE_MINUS_DST_ALPHA,
753 GL_ONE_MINUS_CONSTANT_COLOR,
755 GL_ONE_MINUS_CONSTANT_ALPHA
762 GL_ONE_MINUS_SRC_COLOR,
764 GL_ONE_MINUS_DST_COLOR,
766 GL_ONE_MINUS_SRC_ALPHA,
768 GL_ONE_MINUS_DST_ALPHA,
770 GL_ONE_MINUS_CONSTANT_COLOR,
772 GL_ONE_MINUS_CONSTANT_ALPHA
779 GL_ONE_MINUS_SRC_COLOR,
781 GL_ONE_MINUS_DST_COLOR,
783 GL_ONE_MINUS_SRC_ALPHA,
785 GL_ONE_MINUS_DST_ALPHA,
787 GL_ONE_MINUS_CONSTANT_COLOR,
789 GL_ONE_MINUS_CONSTANT_ALPHA
796 GL_ONE_MINUS_SRC_COLOR,
798 GL_ONE_MINUS_DST_COLOR,
800 GL_ONE_MINUS_SRC_ALPHA,
802 GL_ONE_MINUS_DST_ALPHA,
804 GL_ONE_MINUS_CONSTANT_COLOR,
806 GL_ONE_MINUS_CONSTANT_ALPHA
810 ADD_ARG_CASE4(color_mask, "Test cost of glColorMask() calls",
834 ADD_ARG_CASE4(clear_color, "Test cost of glClearColor() calls",
866 ADD_ARG_CASE6(vertex_attrib_pointer, "Test cost of glVertexAttribPointer() calls",
907 (void*)(deUintptr)(0x0FF),
908 (void*)(deUintptr)(0x0EF)