1 #ifndef _GLSDRAWTEST_HPP
2 #define _GLSDRAWTEST_HPP
3 /*-------------------------------------------------------------------------
4 * drawElements Quality Program OpenGL (ES) Module
5 * -----------------------------------------------
7 * Copyright 2014 The Android Open Source Project
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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.
24 *//*--------------------------------------------------------------------*/
26 #include "tcuTestCase.hpp"
27 #include "tcuResultCollector.hpp"
28 #include "gluRenderContext.hpp"
33 class ReferenceContextBuffers;
34 class ReferenceContext;
50 TARGET_ELEMENT_ARRAY = 0,
65 INPUTTYPE_UNSIGNED_BYTE,
66 INPUTTYPE_UNSIGNED_SHORT,
69 INPUTTYPE_UNSIGNED_INT,
71 INPUTTYPE_UNSIGNED_INT_2_10_10_10,
72 INPUTTYPE_INT_2_10_10_10,
100 USAGE_DYNAMIC_DRAW = 0,
126 PRIMITIVE_POINTS = 0,
128 PRIMITIVE_TRIANGLE_FAN,
129 PRIMITIVE_TRIANGLE_STRIP,
131 PRIMITIVE_LINE_STRIP,
134 PRIMITIVE_LINES_ADJACENCY,
135 PRIMITIVE_LINE_STRIP_ADJACENCY,
136 PRIMITIVE_TRIANGLES_ADJACENCY,
137 PRIMITIVE_TRIANGLE_STRIP_ADJACENCY,
153 DRAWMETHOD_DRAWARRAYS = 0,
154 DRAWMETHOD_DRAWARRAYS_INSTANCED,
155 DRAWMETHOD_DRAWARRAYS_INDIRECT,
156 DRAWMETHOD_DRAWELEMENTS,
157 DRAWMETHOD_DRAWELEMENTS_RANGED,
158 DRAWMETHOD_DRAWELEMENTS_INSTANCED,
159 DRAWMETHOD_DRAWELEMENTS_INDIRECT,
160 DRAWMETHOD_DRAWELEMENTS_BASEVERTEX,
161 DRAWMETHOD_DRAWELEMENTS_INSTANCED_BASEVERTEX,
162 DRAWMETHOD_DRAWELEMENTS_RANGED_BASEVERTEX,
167 enum CompatibilityTestType
169 COMPATIBILITY_NONE = 0,
170 COMPATIBILITY_UNALIGNED_OFFSET,
171 COMPATIBILITY_UNALIGNED_STRIDE,
176 static std::string targetToString (Target target);
177 static std::string inputTypeToString (InputType type);
178 static std::string outputTypeToString (OutputType type);
179 static std::string usageTypeToString (Usage usage);
180 static std::string storageToString (Storage storage);
181 static std::string primitiveToString (Primitive primitive);
182 static std::string indexTypeToString (IndexType type);
183 static std::string drawMethodToString (DrawMethod method);
184 static int inputTypeSize (InputType type);
185 static int indexTypeSize (IndexType type);
189 static AttributeSpec createAttributeArray (InputType inputType, OutputType outputType, Storage storage, Usage usage, int componentCount, int offset, int stride, bool normalize, int instanceDivisor);
190 static AttributeSpec createDefaultAttribute (InputType inputType, OutputType outputType, int componentCount); //!< allowed inputType values: INPUTTYPE_INT, INPUTTYPE_UNSIGNED_INT, INPUTTYPE_FLOAT
193 OutputType outputType;
200 int instanceDivisor; //!< used only if drawMethod = Draw*Instanced
201 bool useDefaultAttribute;
203 bool additionalPositionAttribute; //!< treat this attribute as position attribute. Attribute at index 0 is alway treated as such. False by default
204 bool bgraComponentOrder; //!< component order of this attribute is bgra, valid only for 4-component targets. False by default.
206 AttributeSpec (void);
208 int hash (void) const;
209 bool valid (glu::ApiType apiType) const;
210 bool isBufferAligned (void) const;
211 bool isBufferStrideAligned (void) const;
214 std::string getName (void) const;
215 std::string getDesc (void) const;
216 std::string getMultilineDesc (void) const;
218 glu::ApiType apiType; //!< needed in spec validation
220 int primitiveCount; //!< number of primitives to draw (per instance)
222 DrawMethod drawMethod;
223 IndexType indexType; //!< used only if drawMethod = DrawElements*
224 int indexPointerOffset; //!< used only if drawMethod = DrawElements*
225 Storage indexStorage; //!< used only if drawMethod = DrawElements*
226 int first; //!< used only if drawMethod = DrawArrays*
227 int indexMin; //!< used only if drawMethod = Draw*Ranged
228 int indexMax; //!< used only if drawMethod = Draw*Ranged
229 int instanceCount; //!< used only if drawMethod = Draw*Instanced or Draw*Indirect
230 int indirectOffset; //!< used only if drawMethod = Draw*Indirect
231 int baseVertex; //!< used only if drawMethod = DrawElementsIndirect or *BaseVertex
233 std::vector<AttributeSpec> attribs;
237 int hash (void) const;
238 bool valid (void) const;
239 CompatibilityTestType isCompatibilityTest (void) const;
242 class DrawTest : public tcu::TestCase
245 DrawTest (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const DrawTestSpec& spec, const char* name, const char* desc);
246 DrawTest (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* desc);
247 virtual ~DrawTest (void);
249 void addIteration (const DrawTestSpec& spec, const char* description = DE_NULL);
254 IterateResult iterate (void);
256 bool compare (gls::DrawTestSpec::Primitive primitiveType);
257 float getCoordScale (const DrawTestSpec& spec) const;
258 float getColorScale (const DrawTestSpec& spec) const;
260 glu::RenderContext& m_renderCtx;
262 sglr::ReferenceContextBuffers* m_refBuffers;
263 sglr::ReferenceContext* m_refContext;
264 sglr::Context* m_glesContext;
266 AttributePack* m_glArrayPack;
267 AttributePack* m_rrArrayPack;
273 std::vector<DrawTestSpec> m_specs;
274 std::vector<std::string> m_iteration_descriptions;
276 tcu::ResultCollector m_result;
282 #endif // _GLSDRAWTEST_HPP