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"
38 class ReferenceContextBuffers;
39 class ReferenceContext;
55 TARGET_ELEMENT_ARRAY = 0,
70 INPUTTYPE_UNSIGNED_BYTE,
71 INPUTTYPE_UNSIGNED_SHORT,
74 INPUTTYPE_UNSIGNED_INT,
76 INPUTTYPE_UNSIGNED_INT_2_10_10_10,
77 INPUTTYPE_INT_2_10_10_10,
105 USAGE_DYNAMIC_DRAW = 0,
131 PRIMITIVE_POINTS = 0,
133 PRIMITIVE_TRIANGLE_FAN,
134 PRIMITIVE_TRIANGLE_STRIP,
136 PRIMITIVE_LINE_STRIP,
139 PRIMITIVE_LINES_ADJACENCY,
140 PRIMITIVE_LINE_STRIP_ADJACENCY,
141 PRIMITIVE_TRIANGLES_ADJACENCY,
142 PRIMITIVE_TRIANGLE_STRIP_ADJACENCY,
158 DRAWMETHOD_DRAWARRAYS = 0,
159 DRAWMETHOD_DRAWARRAYS_INSTANCED,
160 DRAWMETHOD_DRAWARRAYS_INDIRECT,
161 DRAWMETHOD_DRAWELEMENTS,
162 DRAWMETHOD_DRAWELEMENTS_RANGED,
163 DRAWMETHOD_DRAWELEMENTS_INSTANCED,
164 DRAWMETHOD_DRAWELEMENTS_INDIRECT,
165 DRAWMETHOD_DRAWELEMENTS_BASEVERTEX,
166 DRAWMETHOD_DRAWELEMENTS_INSTANCED_BASEVERTEX,
167 DRAWMETHOD_DRAWELEMENTS_RANGED_BASEVERTEX,
172 enum CompatibilityTestType
174 COMPATIBILITY_NONE = 0,
175 COMPATIBILITY_UNALIGNED_OFFSET,
176 COMPATIBILITY_UNALIGNED_STRIDE,
181 static std::string targetToString (Target target);
182 static std::string inputTypeToString (InputType type);
183 static std::string outputTypeToString (OutputType type);
184 static std::string usageTypeToString (Usage usage);
185 static std::string storageToString (Storage storage);
186 static std::string primitiveToString (Primitive primitive);
187 static std::string indexTypeToString (IndexType type);
188 static std::string drawMethodToString (DrawMethod method);
189 static int inputTypeSize (InputType type);
190 static int indexTypeSize (IndexType type);
194 static AttributeSpec createAttributeArray (InputType inputType, OutputType outputType, Storage storage, Usage usage, int componentCount, int offset, int stride, bool normalize, int instanceDivisor);
195 static AttributeSpec createDefaultAttribute (InputType inputType, OutputType outputType, int componentCount); //!< allowed inputType values: INPUTTYPE_INT, INPUTTYPE_UNSIGNED_INT, INPUTTYPE_FLOAT
198 OutputType outputType;
205 int instanceDivisor; //!< used only if drawMethod = Draw*Instanced
206 bool useDefaultAttribute;
208 bool additionalPositionAttribute; //!< treat this attribute as position attribute. Attribute at index 0 is alway treated as such. False by default
209 bool bgraComponentOrder; //!< component order of this attribute is bgra, valid only for 4-component targets. False by default.
211 AttributeSpec (void);
213 int hash (void) const;
214 bool valid (glu::ApiType apiType) const;
215 bool isBufferAligned (void) const;
216 bool isBufferStrideAligned (void) const;
219 std::string getName (void) const;
220 std::string getDesc (void) const;
221 std::string getMultilineDesc (void) const;
223 glu::ApiType apiType; //!< needed in spec validation
225 int primitiveCount; //!< number of primitives to draw (per instance)
227 DrawMethod drawMethod;
228 IndexType indexType; //!< used only if drawMethod = DrawElements*
229 int indexPointerOffset; //!< used only if drawMethod = DrawElements*
230 Storage indexStorage; //!< used only if drawMethod = DrawElements*
231 int first; //!< used only if drawMethod = DrawArrays*
232 int indexMin; //!< used only if drawMethod = Draw*Ranged
233 int indexMax; //!< used only if drawMethod = Draw*Ranged
234 int instanceCount; //!< used only if drawMethod = Draw*Instanced or Draw*Indirect
235 int indirectOffset; //!< used only if drawMethod = Draw*Indirect
236 int baseVertex; //!< used only if drawMethod = DrawElementsIndirect or *BaseVertex
238 std::vector<AttributeSpec> attribs;
242 int hash (void) const;
243 bool valid (void) const;
244 CompatibilityTestType isCompatibilityTest (void) const;
247 class DrawTest : public tcu::TestCase
250 DrawTest (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const DrawTestSpec& spec, const char* name, const char* desc);
251 DrawTest (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* desc);
252 virtual ~DrawTest (void);
254 void addIteration (const DrawTestSpec& spec, const char* description = DE_NULL);
259 IterateResult iterate (void);
261 bool compare (gls::DrawTestSpec::Primitive primitiveType);
262 float getCoordScale (const DrawTestSpec& spec) const;
263 float getColorScale (const DrawTestSpec& spec) const;
265 glu::RenderContext& m_renderCtx;
267 glu::ContextInfo* m_contextInfo;
268 sglr::ReferenceContextBuffers* m_refBuffers;
269 sglr::ReferenceContext* m_refContext;
270 sglr::Context* m_glesContext;
272 AttributePack* m_glArrayPack;
273 AttributePack* m_rrArrayPack;
279 std::vector<DrawTestSpec> m_specs;
280 std::vector<std::string> m_iteration_descriptions;
282 tcu::ResultCollector m_result;
288 #endif // _GLSDRAWTEST_HPP