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