1 #ifndef _GLSDRAWTEST_HPP 2 #define _GLSDRAWTEST_HPP 3 /*------------------------------------------------------------------------- 4 * drawElements Quality Program OpenGL (ES) Module 5 * ----------------------------------------------- 6 * 7 * Copyright 2014 The Android Open Source Project 8 * 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 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 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. 20 * 21 *//*! 22 * \file 23 * \brief Draw tests 24 *//*--------------------------------------------------------------------*/ 25 26 #include "tcuTestCase.hpp" 27 #include "tcuResultCollector.hpp" 28 #include "gluRenderContext.hpp" 29 30 namespace glu 31 { 32 class ContextInfo; 33 } 34 35 namespace sglr 36 { 37 38 class ReferenceContextBuffers; 39 class ReferenceContext; 40 class Context; 41 42 } // namespace sglr 43 44 namespace deqp 45 { 46 namespace gls 47 { 48 49 class AttributePack; 50 51 struct DrawTestSpec 52 { 53 enum Target 54 { 55 TARGET_ELEMENT_ARRAY = 0, 56 TARGET_ARRAY, 57 58 TARGET_LAST 59 }; 60 61 enum InputType 62 { 63 INPUTTYPE_FLOAT = 0, 64 INPUTTYPE_FIXED, 65 INPUTTYPE_DOUBLE, 66 67 INPUTTYPE_BYTE, 68 INPUTTYPE_SHORT, 69 70 INPUTTYPE_UNSIGNED_BYTE, 71 INPUTTYPE_UNSIGNED_SHORT, 72 73 INPUTTYPE_INT, 74 INPUTTYPE_UNSIGNED_INT, 75 INPUTTYPE_HALF, 76 INPUTTYPE_UNSIGNED_INT_2_10_10_10, 77 INPUTTYPE_INT_2_10_10_10, 78 79 INPUTTYPE_LAST 80 }; 81 82 enum OutputType 83 { 84 OUTPUTTYPE_FLOAT = 0, 85 OUTPUTTYPE_VEC2, 86 OUTPUTTYPE_VEC3, 87 OUTPUTTYPE_VEC4, 88 89 OUTPUTTYPE_INT, 90 OUTPUTTYPE_UINT, 91 92 OUTPUTTYPE_IVEC2, 93 OUTPUTTYPE_IVEC3, 94 OUTPUTTYPE_IVEC4, 95 96 OUTPUTTYPE_UVEC2, 97 OUTPUTTYPE_UVEC3, 98 OUTPUTTYPE_UVEC4, 99 100 OUTPUTTYPE_LAST 101 }; 102 103 enum Usage 104 { 105 USAGE_DYNAMIC_DRAW = 0, 106 USAGE_STATIC_DRAW, 107 USAGE_STREAM_DRAW, 108 109 USAGE_STREAM_READ, 110 USAGE_STREAM_COPY, 111 112 USAGE_STATIC_READ, 113 USAGE_STATIC_COPY, 114 115 USAGE_DYNAMIC_READ, 116 USAGE_DYNAMIC_COPY, 117 118 USAGE_LAST 119 }; 120 121 enum Storage 122 { 123 STORAGE_USER = 0, 124 STORAGE_BUFFER, 125 126 STORAGE_LAST 127 }; 128 129 enum Primitive 130 { 131 PRIMITIVE_POINTS = 0, 132 PRIMITIVE_TRIANGLES, 133 PRIMITIVE_TRIANGLE_FAN, 134 PRIMITIVE_TRIANGLE_STRIP, 135 PRIMITIVE_LINES, 136 PRIMITIVE_LINE_STRIP, 137 PRIMITIVE_LINE_LOOP, 138 139 PRIMITIVE_LINES_ADJACENCY, 140 PRIMITIVE_LINE_STRIP_ADJACENCY, 141 PRIMITIVE_TRIANGLES_ADJACENCY, 142 PRIMITIVE_TRIANGLE_STRIP_ADJACENCY, 143 144 PRIMITIVE_LAST 145 }; 146 147 enum IndexType 148 { 149 INDEXTYPE_BYTE = 0, 150 INDEXTYPE_SHORT, 151 INDEXTYPE_INT, 152 153 INDEXTYPE_LAST 154 }; 155 156 enum DrawMethod 157 { 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, 168 169 DRAWMETHOD_LAST 170 }; 171 172 enum CompatibilityTestType 173 { 174 COMPATIBILITY_NONE = 0, 175 COMPATIBILITY_UNALIGNED_OFFSET, 176 COMPATIBILITY_UNALIGNED_STRIDE, 177 178 COMPATIBILITY_LAST 179 }; 180 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); 191 192 struct AttributeSpec 193 { 194 static AttributeSpec createAttributeArray(InputType inputType, OutputType outputType, Storage storage, 195 Usage usage, int componentCount, int offset, int stride, 196 bool normalize, int instanceDivisor); 197 static AttributeSpec createDefaultAttribute( 198 InputType inputType, OutputType outputType, 199 int componentCount); //!< allowed inputType values: INPUTTYPE_INT, INPUTTYPE_UNSIGNED_INT, INPUTTYPE_FLOAT 200 201 InputType inputType; 202 OutputType outputType; 203 Storage storage; 204 Usage usage; 205 int componentCount; 206 int offset; 207 int stride; 208 bool normalize; 209 int instanceDivisor; //!< used only if drawMethod = Draw*Instanced 210 bool useDefaultAttribute; 211 212 bool 213 additionalPositionAttribute; //!< treat this attribute as position attribute. Attribute at index 0 is alway treated as such. False by default 214 bool 215 bgraComponentOrder; //!< component order of this attribute is bgra, valid only for 4-component targets. False by default. 216 217 AttributeSpec(void); 218 219 int hash(void) const; 220 bool valid(glu::ApiType apiType) const; 221 bool isBufferAligned(void) const; 222 bool isBufferStrideAligned(void) const; 223 }; 224 225 std::string getName(void) const; 226 std::string getDesc(void) const; 227 std::string getMultilineDesc(void) const; 228 229 glu::ApiType apiType; //!< needed in spec validation 230 Primitive primitive; 231 int primitiveCount; //!< number of primitives to draw (per instance) 232 233 DrawMethod drawMethod; 234 IndexType indexType; //!< used only if drawMethod = DrawElements* 235 int indexPointerOffset; //!< used only if drawMethod = DrawElements* 236 Storage indexStorage; //!< used only if drawMethod = DrawElements* 237 int first; //!< used only if drawMethod = DrawArrays* 238 int indexMin; //!< used only if drawMethod = Draw*Ranged 239 int indexMax; //!< used only if drawMethod = Draw*Ranged 240 int instanceCount; //!< used only if drawMethod = Draw*Instanced or Draw*Indirect 241 int indirectOffset; //!< used only if drawMethod = Draw*Indirect 242 int baseVertex; //!< used only if drawMethod = DrawElementsIndirect or *BaseVertex 243 244 std::vector<AttributeSpec> attribs; 245 246 DrawTestSpec(void); 247 248 int hash(void) const; 249 bool valid(void) const; 250 CompatibilityTestType isCompatibilityTest(void) const; 251 }; 252 253 class DrawTest : public tcu::TestCase 254 { 255 public: 256 DrawTest(tcu::TestContext &testCtx, glu::RenderContext &renderCtx, const DrawTestSpec &spec, const char *name, 257 const char *desc); 258 DrawTest(tcu::TestContext &testCtx, glu::RenderContext &renderCtx, const char *name, const char *desc); 259 virtual ~DrawTest(void); 260 261 void addIteration(const DrawTestSpec &spec, const char *description = DE_NULL); 262 263 private: 264 void init(void); 265 void deinit(void); 266 IterateResult iterate(void); 267 268 bool compare(gls::DrawTestSpec::Primitive primitiveType); 269 float getCoordScale(const DrawTestSpec &spec) const; 270 float getColorScale(const DrawTestSpec &spec) const; 271 272 glu::RenderContext &m_renderCtx; 273 274 glu::ContextInfo *m_contextInfo; 275 sglr::ReferenceContextBuffers *m_refBuffers; 276 sglr::ReferenceContext *m_refContext; 277 sglr::Context *m_glesContext; 278 279 AttributePack *m_glArrayPack; 280 AttributePack *m_rrArrayPack; 281 282 int m_maxDiffRed; 283 int m_maxDiffGreen; 284 int m_maxDiffBlue; 285 286 std::vector<DrawTestSpec> m_specs; 287 std::vector<std::string> m_iteration_descriptions; 288 int m_iteration; 289 tcu::ResultCollector m_result; 290 }; 291 292 } // namespace gls 293 } // namespace deqp 294 295 #endif // _GLSDRAWTEST_HPP 296