1e5c31af7Sopenharmony_ci/*------------------------------------------------------------------------- 2e5c31af7Sopenharmony_ci * drawElements Quality Program OpenGL ES 2.0 Module 3e5c31af7Sopenharmony_ci * ------------------------------------------------- 4e5c31af7Sopenharmony_ci * 5e5c31af7Sopenharmony_ci * Copyright 2014 The Android Open Source Project 6e5c31af7Sopenharmony_ci * 7e5c31af7Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 8e5c31af7Sopenharmony_ci * you may not use this file except in compliance with the License. 9e5c31af7Sopenharmony_ci * You may obtain a copy of the License at 10e5c31af7Sopenharmony_ci * 11e5c31af7Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 12e5c31af7Sopenharmony_ci * 13e5c31af7Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 14e5c31af7Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 15e5c31af7Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16e5c31af7Sopenharmony_ci * See the License for the specific language governing permissions and 17e5c31af7Sopenharmony_ci * limitations under the License. 18e5c31af7Sopenharmony_ci * 19e5c31af7Sopenharmony_ci *//*! 20e5c31af7Sopenharmony_ci * \file 21e5c31af7Sopenharmony_ci * \brief Vertex array and buffer tests 22e5c31af7Sopenharmony_ci *//*--------------------------------------------------------------------*/ 23e5c31af7Sopenharmony_ci 24e5c31af7Sopenharmony_ci#include "es2fVertexArrayTest.hpp" 25e5c31af7Sopenharmony_ci#include "glsVertexArrayTests.hpp" 26e5c31af7Sopenharmony_ci 27e5c31af7Sopenharmony_ci#include "glwEnums.hpp" 28e5c31af7Sopenharmony_ci 29e5c31af7Sopenharmony_ciusing namespace deqp::gls; 30e5c31af7Sopenharmony_ci 31e5c31af7Sopenharmony_cinamespace deqp 32e5c31af7Sopenharmony_ci{ 33e5c31af7Sopenharmony_cinamespace gles2 34e5c31af7Sopenharmony_ci{ 35e5c31af7Sopenharmony_cinamespace Functional 36e5c31af7Sopenharmony_ci{ 37e5c31af7Sopenharmony_ci 38e5c31af7Sopenharmony_citemplate<class T> 39e5c31af7Sopenharmony_cistatic std::string typeToString (T t) 40e5c31af7Sopenharmony_ci{ 41e5c31af7Sopenharmony_ci std::stringstream strm; 42e5c31af7Sopenharmony_ci strm << t; 43e5c31af7Sopenharmony_ci return strm.str(); 44e5c31af7Sopenharmony_ci} 45e5c31af7Sopenharmony_ci 46e5c31af7Sopenharmony_ci 47e5c31af7Sopenharmony_ciclass SingleVertexArrayUsageTests : public TestCaseGroup 48e5c31af7Sopenharmony_ci{ 49e5c31af7Sopenharmony_cipublic: 50e5c31af7Sopenharmony_ci SingleVertexArrayUsageTests (Context& context); 51e5c31af7Sopenharmony_ci virtual ~SingleVertexArrayUsageTests (void); 52e5c31af7Sopenharmony_ci 53e5c31af7Sopenharmony_ci virtual void init (void); 54e5c31af7Sopenharmony_ci 55e5c31af7Sopenharmony_ciprivate: 56e5c31af7Sopenharmony_ci SingleVertexArrayUsageTests (const SingleVertexArrayUsageTests& other); 57e5c31af7Sopenharmony_ci SingleVertexArrayUsageTests& operator= (const SingleVertexArrayUsageTests& other); 58e5c31af7Sopenharmony_ci}; 59e5c31af7Sopenharmony_ci 60e5c31af7Sopenharmony_ciSingleVertexArrayUsageTests::SingleVertexArrayUsageTests (Context& context) 61e5c31af7Sopenharmony_ci : TestCaseGroup(context, "usages", "Single vertex atribute, usage") 62e5c31af7Sopenharmony_ci{ 63e5c31af7Sopenharmony_ci} 64e5c31af7Sopenharmony_ci 65e5c31af7Sopenharmony_ciSingleVertexArrayUsageTests::~SingleVertexArrayUsageTests (void) 66e5c31af7Sopenharmony_ci{ 67e5c31af7Sopenharmony_ci} 68e5c31af7Sopenharmony_ci 69e5c31af7Sopenharmony_civoid SingleVertexArrayUsageTests::init (void) 70e5c31af7Sopenharmony_ci{ 71e5c31af7Sopenharmony_ci // Test usage 72e5c31af7Sopenharmony_ci Array::Usage usages[] = {Array::USAGE_STATIC_DRAW, Array::USAGE_STREAM_DRAW, Array::USAGE_DYNAMIC_DRAW}; 73e5c31af7Sopenharmony_ci int counts[] = {1, 256}; 74e5c31af7Sopenharmony_ci int strides[] = {0, -1, 17, 32}; // Tread negative value as sizeof input. Same as 0, but done outside of GL. 75e5c31af7Sopenharmony_ci Array::InputType inputTypes[] = {Array::INPUTTYPE_FLOAT, Array::INPUTTYPE_FIXED, Array::INPUTTYPE_SHORT, Array::INPUTTYPE_BYTE}; 76e5c31af7Sopenharmony_ci 77e5c31af7Sopenharmony_ci for (int inputTypeNdx = 0; inputTypeNdx < DE_LENGTH_OF_ARRAY(inputTypes); inputTypeNdx++) 78e5c31af7Sopenharmony_ci { 79e5c31af7Sopenharmony_ci for (int countNdx = 0; countNdx < DE_LENGTH_OF_ARRAY(counts); countNdx++) 80e5c31af7Sopenharmony_ci { 81e5c31af7Sopenharmony_ci for (int strideNdx = 0; strideNdx < DE_LENGTH_OF_ARRAY(strides); strideNdx++) 82e5c31af7Sopenharmony_ci { 83e5c31af7Sopenharmony_ci for (int usageNdx = 0; usageNdx < DE_LENGTH_OF_ARRAY(usages); usageNdx++) 84e5c31af7Sopenharmony_ci { 85e5c31af7Sopenharmony_ci const int componentCount = 2; 86e5c31af7Sopenharmony_ci const int stride = (strides[strideNdx] < 0 ? Array::inputTypeSize(inputTypes[inputTypeNdx]) * componentCount : strides[strideNdx]); 87e5c31af7Sopenharmony_ci const bool aligned = (stride % Array::inputTypeSize(inputTypes[inputTypeNdx])) == 0; 88e5c31af7Sopenharmony_ci MultiVertexArrayTest::Spec::ArraySpec arraySpec(inputTypes[inputTypeNdx], 89e5c31af7Sopenharmony_ci Array::OUTPUTTYPE_VEC2, 90e5c31af7Sopenharmony_ci Array::STORAGE_BUFFER, 91e5c31af7Sopenharmony_ci usages[usageNdx], 92e5c31af7Sopenharmony_ci componentCount, 93e5c31af7Sopenharmony_ci 0, 94e5c31af7Sopenharmony_ci stride, 95e5c31af7Sopenharmony_ci false, 96e5c31af7Sopenharmony_ci GLValue::getMinValue(inputTypes[inputTypeNdx]), 97e5c31af7Sopenharmony_ci GLValue::getMaxValue(inputTypes[inputTypeNdx])); 98e5c31af7Sopenharmony_ci 99e5c31af7Sopenharmony_ci MultiVertexArrayTest::Spec spec; 100e5c31af7Sopenharmony_ci spec.primitive = Array::PRIMITIVE_TRIANGLES; 101e5c31af7Sopenharmony_ci spec.drawCount = counts[countNdx]; 102e5c31af7Sopenharmony_ci spec.first = 0; 103e5c31af7Sopenharmony_ci spec.arrays.push_back(arraySpec); 104e5c31af7Sopenharmony_ci 105e5c31af7Sopenharmony_ci std::string name = spec.getName(); 106e5c31af7Sopenharmony_ci 107e5c31af7Sopenharmony_ci if (aligned) 108e5c31af7Sopenharmony_ci addChild(new MultiVertexArrayTest(m_testCtx, m_context.getRenderContext(), spec, name.c_str(), name.c_str())); 109e5c31af7Sopenharmony_ci } 110e5c31af7Sopenharmony_ci } 111e5c31af7Sopenharmony_ci } 112e5c31af7Sopenharmony_ci } 113e5c31af7Sopenharmony_ci} 114e5c31af7Sopenharmony_ci 115e5c31af7Sopenharmony_ciclass SingleVertexArrayStrideTests : public TestCaseGroup 116e5c31af7Sopenharmony_ci{ 117e5c31af7Sopenharmony_cipublic: 118e5c31af7Sopenharmony_ci SingleVertexArrayStrideTests (Context& context); 119e5c31af7Sopenharmony_ci virtual ~SingleVertexArrayStrideTests (void); 120e5c31af7Sopenharmony_ci 121e5c31af7Sopenharmony_ci virtual void init (void); 122e5c31af7Sopenharmony_ci 123e5c31af7Sopenharmony_ciprivate: 124e5c31af7Sopenharmony_ci SingleVertexArrayStrideTests (const SingleVertexArrayStrideTests& other); 125e5c31af7Sopenharmony_ci SingleVertexArrayStrideTests& operator= (const SingleVertexArrayStrideTests& other); 126e5c31af7Sopenharmony_ci}; 127e5c31af7Sopenharmony_ci 128e5c31af7Sopenharmony_ciSingleVertexArrayStrideTests::SingleVertexArrayStrideTests (Context& context) 129e5c31af7Sopenharmony_ci : TestCaseGroup(context, "strides", "Single stride vertex atribute") 130e5c31af7Sopenharmony_ci{ 131e5c31af7Sopenharmony_ci} 132e5c31af7Sopenharmony_ci 133e5c31af7Sopenharmony_ciSingleVertexArrayStrideTests::~SingleVertexArrayStrideTests (void) 134e5c31af7Sopenharmony_ci{ 135e5c31af7Sopenharmony_ci} 136e5c31af7Sopenharmony_ci 137e5c31af7Sopenharmony_civoid SingleVertexArrayStrideTests::init (void) 138e5c31af7Sopenharmony_ci{ 139e5c31af7Sopenharmony_ci // Test strides with different input types, component counts and storage, Usage(?) 140e5c31af7Sopenharmony_ci Array::InputType inputTypes[] = {Array::INPUTTYPE_FLOAT, Array::INPUTTYPE_SHORT, Array::INPUTTYPE_BYTE, /*Array::INPUTTYPE_UNSIGNED_SHORT, Array::INPUTTYPE_UNSIGNED_BYTE,*/ Array::INPUTTYPE_FIXED}; 141e5c31af7Sopenharmony_ci Array::Storage storages[] = {Array::STORAGE_USER, Array::STORAGE_BUFFER}; 142e5c31af7Sopenharmony_ci int counts[] = {1, 256}; 143e5c31af7Sopenharmony_ci int strides[] = {/*0,*/ -1, 17, 32}; // Tread negative value as sizeof input. Same as 0, but done outside of GL. 144e5c31af7Sopenharmony_ci 145e5c31af7Sopenharmony_ci for (int inputTypeNdx = 0; inputTypeNdx < DE_LENGTH_OF_ARRAY(inputTypes); inputTypeNdx++) 146e5c31af7Sopenharmony_ci { 147e5c31af7Sopenharmony_ci for (int storageNdx = 0; storageNdx < DE_LENGTH_OF_ARRAY(storages); storageNdx++) 148e5c31af7Sopenharmony_ci { 149e5c31af7Sopenharmony_ci for (int componentCount = 2; componentCount < 5; componentCount++) 150e5c31af7Sopenharmony_ci { 151e5c31af7Sopenharmony_ci for (int countNdx = 0; countNdx < DE_LENGTH_OF_ARRAY(counts); countNdx++) 152e5c31af7Sopenharmony_ci { 153e5c31af7Sopenharmony_ci for (int strideNdx = 0; strideNdx < DE_LENGTH_OF_ARRAY(strides); strideNdx++) 154e5c31af7Sopenharmony_ci { 155e5c31af7Sopenharmony_ci const int stride = (strides[strideNdx] < 0 ? Array::inputTypeSize(inputTypes[inputTypeNdx]) * componentCount : strides[strideNdx]); 156e5c31af7Sopenharmony_ci const bool bufferAligned = (storages[storageNdx] == Array::STORAGE_BUFFER) && (stride % Array::inputTypeSize(inputTypes[inputTypeNdx])) == 0; 157e5c31af7Sopenharmony_ci 158e5c31af7Sopenharmony_ci MultiVertexArrayTest::Spec::ArraySpec arraySpec(inputTypes[inputTypeNdx], 159e5c31af7Sopenharmony_ci Array::OUTPUTTYPE_VEC4, 160e5c31af7Sopenharmony_ci storages[storageNdx], 161e5c31af7Sopenharmony_ci Array::USAGE_DYNAMIC_DRAW, 162e5c31af7Sopenharmony_ci componentCount, 163e5c31af7Sopenharmony_ci 0, 164e5c31af7Sopenharmony_ci stride, 165e5c31af7Sopenharmony_ci false, 166e5c31af7Sopenharmony_ci GLValue::getMinValue(inputTypes[inputTypeNdx]), 167e5c31af7Sopenharmony_ci GLValue::getMaxValue(inputTypes[inputTypeNdx])); 168e5c31af7Sopenharmony_ci 169e5c31af7Sopenharmony_ci MultiVertexArrayTest::Spec spec; 170e5c31af7Sopenharmony_ci spec.primitive = Array::PRIMITIVE_TRIANGLES; 171e5c31af7Sopenharmony_ci spec.drawCount = counts[countNdx]; 172e5c31af7Sopenharmony_ci spec.first = 0; 173e5c31af7Sopenharmony_ci spec.arrays.push_back(arraySpec); 174e5c31af7Sopenharmony_ci 175e5c31af7Sopenharmony_ci std::string name = spec.getName(); 176e5c31af7Sopenharmony_ci if (bufferAligned) 177e5c31af7Sopenharmony_ci addChild(new MultiVertexArrayTest(m_testCtx, m_context.getRenderContext(), spec, name.c_str(), name.c_str())); 178e5c31af7Sopenharmony_ci } 179e5c31af7Sopenharmony_ci } 180e5c31af7Sopenharmony_ci } 181e5c31af7Sopenharmony_ci } 182e5c31af7Sopenharmony_ci } 183e5c31af7Sopenharmony_ci} 184e5c31af7Sopenharmony_ci 185e5c31af7Sopenharmony_ciclass SingleVertexArrayFirstTests : public TestCaseGroup 186e5c31af7Sopenharmony_ci{ 187e5c31af7Sopenharmony_cipublic: 188e5c31af7Sopenharmony_ci SingleVertexArrayFirstTests (Context& context); 189e5c31af7Sopenharmony_ci virtual ~SingleVertexArrayFirstTests (void); 190e5c31af7Sopenharmony_ci 191e5c31af7Sopenharmony_ci virtual void init (void); 192e5c31af7Sopenharmony_ci 193e5c31af7Sopenharmony_ciprivate: 194e5c31af7Sopenharmony_ci SingleVertexArrayFirstTests (const SingleVertexArrayFirstTests& other); 195e5c31af7Sopenharmony_ci SingleVertexArrayFirstTests& operator= (const SingleVertexArrayFirstTests& other); 196e5c31af7Sopenharmony_ci}; 197e5c31af7Sopenharmony_ci 198e5c31af7Sopenharmony_ciSingleVertexArrayFirstTests::SingleVertexArrayFirstTests (Context& context) 199e5c31af7Sopenharmony_ci : TestCaseGroup(context, "first", "Single vertex atribute different first values") 200e5c31af7Sopenharmony_ci{ 201e5c31af7Sopenharmony_ci} 202e5c31af7Sopenharmony_ci 203e5c31af7Sopenharmony_ciSingleVertexArrayFirstTests::~SingleVertexArrayFirstTests (void) 204e5c31af7Sopenharmony_ci{ 205e5c31af7Sopenharmony_ci} 206e5c31af7Sopenharmony_ci 207e5c31af7Sopenharmony_civoid SingleVertexArrayFirstTests::init (void) 208e5c31af7Sopenharmony_ci{ 209e5c31af7Sopenharmony_ci // Test strides with different input types, component counts and storage, Usage(?) 210e5c31af7Sopenharmony_ci Array::InputType inputTypes[] = {Array::INPUTTYPE_FLOAT, Array::INPUTTYPE_BYTE, Array::INPUTTYPE_FIXED}; 211e5c31af7Sopenharmony_ci int counts[] = {5, 256}; 212e5c31af7Sopenharmony_ci int firsts[] = {6, 24}; 213e5c31af7Sopenharmony_ci int offsets[] = {1, 16, 17}; 214e5c31af7Sopenharmony_ci int strides[] = {/*0,*/ -1, 17, 32}; // Tread negative value as sizeof input. Same as 0, but done outside of GL. 215e5c31af7Sopenharmony_ci 216e5c31af7Sopenharmony_ci for (int inputTypeNdx = 0; inputTypeNdx < DE_LENGTH_OF_ARRAY(inputTypes); inputTypeNdx++) 217e5c31af7Sopenharmony_ci { 218e5c31af7Sopenharmony_ci for (int offsetNdx = 0; offsetNdx < DE_LENGTH_OF_ARRAY(offsets); offsetNdx++) 219e5c31af7Sopenharmony_ci { 220e5c31af7Sopenharmony_ci for (int countNdx = 0; countNdx < DE_LENGTH_OF_ARRAY(counts); countNdx++) 221e5c31af7Sopenharmony_ci { 222e5c31af7Sopenharmony_ci for (int strideNdx = 0; strideNdx < DE_LENGTH_OF_ARRAY(strides); strideNdx++) 223e5c31af7Sopenharmony_ci { 224e5c31af7Sopenharmony_ci for (int firstNdx = 0; firstNdx < DE_LENGTH_OF_ARRAY(firsts); firstNdx++) 225e5c31af7Sopenharmony_ci { 226e5c31af7Sopenharmony_ci const int stride = (strides[strideNdx] < 0 ? Array::inputTypeSize(inputTypes[inputTypeNdx]) * 2 : strides[strideNdx]); 227e5c31af7Sopenharmony_ci const bool aligned = ((stride % Array::inputTypeSize(inputTypes[inputTypeNdx])) == 0) && (offsets[offsetNdx] % Array::inputTypeSize(inputTypes[inputTypeNdx]) == 0); 228e5c31af7Sopenharmony_ci 229e5c31af7Sopenharmony_ci MultiVertexArrayTest::Spec::ArraySpec arraySpec(inputTypes[inputTypeNdx], 230e5c31af7Sopenharmony_ci Array::OUTPUTTYPE_VEC2, 231e5c31af7Sopenharmony_ci Array::STORAGE_BUFFER, 232e5c31af7Sopenharmony_ci Array::USAGE_DYNAMIC_DRAW, 233e5c31af7Sopenharmony_ci 2, 234e5c31af7Sopenharmony_ci offsets[offsetNdx], 235e5c31af7Sopenharmony_ci stride, 236e5c31af7Sopenharmony_ci false, 237e5c31af7Sopenharmony_ci GLValue::getMinValue(inputTypes[inputTypeNdx]), 238e5c31af7Sopenharmony_ci GLValue::getMaxValue(inputTypes[inputTypeNdx])); 239e5c31af7Sopenharmony_ci 240e5c31af7Sopenharmony_ci MultiVertexArrayTest::Spec spec; 241e5c31af7Sopenharmony_ci spec.primitive = Array::PRIMITIVE_TRIANGLES; 242e5c31af7Sopenharmony_ci spec.drawCount = counts[countNdx]; 243e5c31af7Sopenharmony_ci spec.first = firsts[firstNdx]; 244e5c31af7Sopenharmony_ci spec.arrays.push_back(arraySpec); 245e5c31af7Sopenharmony_ci 246e5c31af7Sopenharmony_ci std::string name = Array::inputTypeToString(inputTypes[inputTypeNdx]) + "_first" + typeToString(firsts[firstNdx]) + "_offset" + typeToString(offsets[offsetNdx]) + "_stride" + typeToString(stride) + "_quads" + typeToString(counts[countNdx]); 247e5c31af7Sopenharmony_ci if (aligned) 248e5c31af7Sopenharmony_ci addChild(new MultiVertexArrayTest(m_testCtx, m_context.getRenderContext(), spec, name.c_str(), name.c_str())); 249e5c31af7Sopenharmony_ci } 250e5c31af7Sopenharmony_ci } 251e5c31af7Sopenharmony_ci } 252e5c31af7Sopenharmony_ci } 253e5c31af7Sopenharmony_ci } 254e5c31af7Sopenharmony_ci} 255e5c31af7Sopenharmony_ci 256e5c31af7Sopenharmony_ciclass SingleVertexArrayOffsetTests : public TestCaseGroup 257e5c31af7Sopenharmony_ci{ 258e5c31af7Sopenharmony_cipublic: 259e5c31af7Sopenharmony_ci SingleVertexArrayOffsetTests (Context& context); 260e5c31af7Sopenharmony_ci virtual ~SingleVertexArrayOffsetTests (void); 261e5c31af7Sopenharmony_ci 262e5c31af7Sopenharmony_ci virtual void init (void); 263e5c31af7Sopenharmony_ci 264e5c31af7Sopenharmony_ciprivate: 265e5c31af7Sopenharmony_ci SingleVertexArrayOffsetTests (const SingleVertexArrayOffsetTests& other); 266e5c31af7Sopenharmony_ci SingleVertexArrayOffsetTests& operator= (const SingleVertexArrayOffsetTests& other); 267e5c31af7Sopenharmony_ci}; 268e5c31af7Sopenharmony_ci 269e5c31af7Sopenharmony_ciSingleVertexArrayOffsetTests::SingleVertexArrayOffsetTests (Context& context) 270e5c31af7Sopenharmony_ci : TestCaseGroup(context, "offset", "Single vertex atribute offset element") 271e5c31af7Sopenharmony_ci{ 272e5c31af7Sopenharmony_ci} 273e5c31af7Sopenharmony_ci 274e5c31af7Sopenharmony_ciSingleVertexArrayOffsetTests::~SingleVertexArrayOffsetTests (void) 275e5c31af7Sopenharmony_ci{ 276e5c31af7Sopenharmony_ci} 277e5c31af7Sopenharmony_ci 278e5c31af7Sopenharmony_civoid SingleVertexArrayOffsetTests::init (void) 279e5c31af7Sopenharmony_ci{ 280e5c31af7Sopenharmony_ci // Test strides with different input types, component counts and storage, Usage(?) 281e5c31af7Sopenharmony_ci Array::InputType inputTypes[] = {Array::INPUTTYPE_FLOAT, Array::INPUTTYPE_BYTE, Array::INPUTTYPE_FIXED}; 282e5c31af7Sopenharmony_ci int counts[] = {1, 256}; 283e5c31af7Sopenharmony_ci int offsets[] = {1, 4, 17, 32}; 284e5c31af7Sopenharmony_ci int strides[] = {/*0,*/ -1, 17, 32}; // Tread negative value as sizeof input. Same as 0, but done outside of GL. 285e5c31af7Sopenharmony_ci 286e5c31af7Sopenharmony_ci for (int inputTypeNdx = 0; inputTypeNdx < DE_LENGTH_OF_ARRAY(inputTypes); inputTypeNdx++) 287e5c31af7Sopenharmony_ci { 288e5c31af7Sopenharmony_ci for (int offsetNdx = 0; offsetNdx < DE_LENGTH_OF_ARRAY(offsets); offsetNdx++) 289e5c31af7Sopenharmony_ci { 290e5c31af7Sopenharmony_ci for (int countNdx = 0; countNdx < DE_LENGTH_OF_ARRAY(counts); countNdx++) 291e5c31af7Sopenharmony_ci { 292e5c31af7Sopenharmony_ci for (int strideNdx = 0; strideNdx < DE_LENGTH_OF_ARRAY(strides); strideNdx++) 293e5c31af7Sopenharmony_ci { 294e5c31af7Sopenharmony_ci const int stride = (strides[strideNdx] < 0 ? Array::inputTypeSize(inputTypes[inputTypeNdx]) * 2 : strides[strideNdx]); 295e5c31af7Sopenharmony_ci const bool aligned = ((stride % Array::inputTypeSize(inputTypes[inputTypeNdx])) == 0) && ((offsets[offsetNdx] % Array::inputTypeSize(inputTypes[inputTypeNdx])) == 0); 296e5c31af7Sopenharmony_ci 297e5c31af7Sopenharmony_ci MultiVertexArrayTest::Spec::ArraySpec arraySpec(inputTypes[inputTypeNdx], 298e5c31af7Sopenharmony_ci Array::OUTPUTTYPE_VEC2, 299e5c31af7Sopenharmony_ci Array::STORAGE_BUFFER, 300e5c31af7Sopenharmony_ci Array::USAGE_DYNAMIC_DRAW, 301e5c31af7Sopenharmony_ci 2, 302e5c31af7Sopenharmony_ci offsets[offsetNdx], 303e5c31af7Sopenharmony_ci stride, 304e5c31af7Sopenharmony_ci false, 305e5c31af7Sopenharmony_ci GLValue::getMinValue(inputTypes[inputTypeNdx]), 306e5c31af7Sopenharmony_ci GLValue::getMaxValue(inputTypes[inputTypeNdx])); 307e5c31af7Sopenharmony_ci 308e5c31af7Sopenharmony_ci MultiVertexArrayTest::Spec spec; 309e5c31af7Sopenharmony_ci spec.primitive = Array::PRIMITIVE_TRIANGLES; 310e5c31af7Sopenharmony_ci spec.drawCount = counts[countNdx]; 311e5c31af7Sopenharmony_ci spec.first = 0; 312e5c31af7Sopenharmony_ci spec.arrays.push_back(arraySpec); 313e5c31af7Sopenharmony_ci 314e5c31af7Sopenharmony_ci std::string name = spec.getName(); 315e5c31af7Sopenharmony_ci if (aligned) 316e5c31af7Sopenharmony_ci addChild(new MultiVertexArrayTest(m_testCtx, m_context.getRenderContext(), spec, name.c_str(), name.c_str())); 317e5c31af7Sopenharmony_ci } 318e5c31af7Sopenharmony_ci } 319e5c31af7Sopenharmony_ci } 320e5c31af7Sopenharmony_ci } 321e5c31af7Sopenharmony_ci} 322e5c31af7Sopenharmony_ci 323e5c31af7Sopenharmony_ciclass SingleVertexArrayNormalizeTests : public TestCaseGroup 324e5c31af7Sopenharmony_ci{ 325e5c31af7Sopenharmony_cipublic: 326e5c31af7Sopenharmony_ci SingleVertexArrayNormalizeTests (Context& context); 327e5c31af7Sopenharmony_ci virtual ~SingleVertexArrayNormalizeTests (void); 328e5c31af7Sopenharmony_ci 329e5c31af7Sopenharmony_ci virtual void init (void); 330e5c31af7Sopenharmony_ci 331e5c31af7Sopenharmony_ciprivate: 332e5c31af7Sopenharmony_ci SingleVertexArrayNormalizeTests (const SingleVertexArrayNormalizeTests& other); 333e5c31af7Sopenharmony_ci SingleVertexArrayNormalizeTests& operator= (const SingleVertexArrayNormalizeTests& other); 334e5c31af7Sopenharmony_ci}; 335e5c31af7Sopenharmony_ci 336e5c31af7Sopenharmony_ciSingleVertexArrayNormalizeTests::SingleVertexArrayNormalizeTests (Context& context) 337e5c31af7Sopenharmony_ci : TestCaseGroup(context, "normalize", "Single normalize vertex atribute") 338e5c31af7Sopenharmony_ci{ 339e5c31af7Sopenharmony_ci} 340e5c31af7Sopenharmony_ci 341e5c31af7Sopenharmony_ciSingleVertexArrayNormalizeTests::~SingleVertexArrayNormalizeTests (void) 342e5c31af7Sopenharmony_ci{ 343e5c31af7Sopenharmony_ci} 344e5c31af7Sopenharmony_ci 345e5c31af7Sopenharmony_civoid SingleVertexArrayNormalizeTests::init (void) 346e5c31af7Sopenharmony_ci{ 347e5c31af7Sopenharmony_ci // Test normalization with different input types, component counts and storage 348e5c31af7Sopenharmony_ci Array::InputType inputTypes[] = {Array::INPUTTYPE_FLOAT, Array::INPUTTYPE_SHORT, Array::INPUTTYPE_BYTE, Array::INPUTTYPE_UNSIGNED_SHORT, Array::INPUTTYPE_UNSIGNED_BYTE, Array::INPUTTYPE_FIXED}; 349e5c31af7Sopenharmony_ci Array::Storage storages[] = {Array::STORAGE_USER}; 350e5c31af7Sopenharmony_ci int counts[] = {1, 256}; 351e5c31af7Sopenharmony_ci 352e5c31af7Sopenharmony_ci for (int inputTypeNdx = 0; inputTypeNdx < DE_LENGTH_OF_ARRAY(inputTypes); inputTypeNdx++) 353e5c31af7Sopenharmony_ci { 354e5c31af7Sopenharmony_ci for (int storageNdx = 0; storageNdx < DE_LENGTH_OF_ARRAY(storages); storageNdx++) 355e5c31af7Sopenharmony_ci { 356e5c31af7Sopenharmony_ci for (int componentCount = 2; componentCount < 5; componentCount++) 357e5c31af7Sopenharmony_ci { 358e5c31af7Sopenharmony_ci for (int countNdx = 0; countNdx < DE_LENGTH_OF_ARRAY(counts); countNdx++) 359e5c31af7Sopenharmony_ci { 360e5c31af7Sopenharmony_ci MultiVertexArrayTest::Spec::ArraySpec arraySpec(inputTypes[inputTypeNdx], 361e5c31af7Sopenharmony_ci Array::OUTPUTTYPE_VEC4, 362e5c31af7Sopenharmony_ci storages[storageNdx], 363e5c31af7Sopenharmony_ci Array::USAGE_DYNAMIC_DRAW, 364e5c31af7Sopenharmony_ci componentCount, 365e5c31af7Sopenharmony_ci 0, 366e5c31af7Sopenharmony_ci 0, 367e5c31af7Sopenharmony_ci true, 368e5c31af7Sopenharmony_ci GLValue::getMinValue(inputTypes[inputTypeNdx]), 369e5c31af7Sopenharmony_ci GLValue::getMaxValue(inputTypes[inputTypeNdx])); 370e5c31af7Sopenharmony_ci 371e5c31af7Sopenharmony_ci MultiVertexArrayTest::Spec spec; 372e5c31af7Sopenharmony_ci spec.primitive = Array::PRIMITIVE_TRIANGLES; 373e5c31af7Sopenharmony_ci spec.drawCount = counts[countNdx]; 374e5c31af7Sopenharmony_ci spec.first = 0; 375e5c31af7Sopenharmony_ci spec.arrays.push_back(arraySpec); 376e5c31af7Sopenharmony_ci 377e5c31af7Sopenharmony_ci std::string name = spec.getName(); 378e5c31af7Sopenharmony_ci addChild(new MultiVertexArrayTest(m_testCtx, m_context.getRenderContext(), spec, name.c_str(), name.c_str())); 379e5c31af7Sopenharmony_ci } 380e5c31af7Sopenharmony_ci } 381e5c31af7Sopenharmony_ci } 382e5c31af7Sopenharmony_ci } 383e5c31af7Sopenharmony_ci} 384e5c31af7Sopenharmony_ci 385e5c31af7Sopenharmony_ciclass SingleVertexArrayOutputTypeTests : public TestCaseGroup 386e5c31af7Sopenharmony_ci{ 387e5c31af7Sopenharmony_cipublic: 388e5c31af7Sopenharmony_ci SingleVertexArrayOutputTypeTests (Context& context); 389e5c31af7Sopenharmony_ci virtual ~SingleVertexArrayOutputTypeTests (void); 390e5c31af7Sopenharmony_ci 391e5c31af7Sopenharmony_ci virtual void init (void); 392e5c31af7Sopenharmony_ci 393e5c31af7Sopenharmony_ciprivate: 394e5c31af7Sopenharmony_ci SingleVertexArrayOutputTypeTests (const SingleVertexArrayOutputTypeTests& other); 395e5c31af7Sopenharmony_ci SingleVertexArrayOutputTypeTests& operator= (const SingleVertexArrayOutputTypeTests& other); 396e5c31af7Sopenharmony_ci}; 397e5c31af7Sopenharmony_ci 398e5c31af7Sopenharmony_ciSingleVertexArrayOutputTypeTests::SingleVertexArrayOutputTypeTests (Context& context) 399e5c31af7Sopenharmony_ci : TestCaseGroup(context, "output_types", "Single output type vertex atribute") 400e5c31af7Sopenharmony_ci{ 401e5c31af7Sopenharmony_ci} 402e5c31af7Sopenharmony_ci 403e5c31af7Sopenharmony_ciSingleVertexArrayOutputTypeTests::~SingleVertexArrayOutputTypeTests (void) 404e5c31af7Sopenharmony_ci{ 405e5c31af7Sopenharmony_ci} 406e5c31af7Sopenharmony_ci 407e5c31af7Sopenharmony_civoid SingleVertexArrayOutputTypeTests::init (void) 408e5c31af7Sopenharmony_ci{ 409e5c31af7Sopenharmony_ci // Test output types with different input types, component counts and storage, Usage?, Precision?, float? 410e5c31af7Sopenharmony_ci Array::InputType inputTypes[] = {Array::INPUTTYPE_FLOAT, Array::INPUTTYPE_SHORT, Array::INPUTTYPE_BYTE, Array::INPUTTYPE_UNSIGNED_SHORT, Array::INPUTTYPE_UNSIGNED_BYTE, Array::INPUTTYPE_FIXED}; 411e5c31af7Sopenharmony_ci Array::OutputType outputTypes[] = {Array::OUTPUTTYPE_VEC2, Array::OUTPUTTYPE_VEC3, Array::OUTPUTTYPE_VEC4}; 412e5c31af7Sopenharmony_ci Array::Storage storages[] = {Array::STORAGE_USER}; 413e5c31af7Sopenharmony_ci int counts[] = {1, 256}; 414e5c31af7Sopenharmony_ci 415e5c31af7Sopenharmony_ci for (int inputTypeNdx = 0; inputTypeNdx < DE_LENGTH_OF_ARRAY(inputTypes); inputTypeNdx++) 416e5c31af7Sopenharmony_ci { 417e5c31af7Sopenharmony_ci for (int outputTypeNdx = 0; outputTypeNdx < DE_LENGTH_OF_ARRAY(outputTypes); outputTypeNdx++) 418e5c31af7Sopenharmony_ci { 419e5c31af7Sopenharmony_ci for (int storageNdx = 0; storageNdx < DE_LENGTH_OF_ARRAY(storages); storageNdx++) 420e5c31af7Sopenharmony_ci { 421e5c31af7Sopenharmony_ci for (int componentCount = 2; componentCount < 5; componentCount++) 422e5c31af7Sopenharmony_ci { 423e5c31af7Sopenharmony_ci for (int countNdx = 0; countNdx < DE_LENGTH_OF_ARRAY(counts); countNdx++) 424e5c31af7Sopenharmony_ci { 425e5c31af7Sopenharmony_ci MultiVertexArrayTest::Spec::ArraySpec arraySpec(inputTypes[inputTypeNdx], 426e5c31af7Sopenharmony_ci outputTypes[outputTypeNdx], 427e5c31af7Sopenharmony_ci storages[storageNdx], 428e5c31af7Sopenharmony_ci Array::USAGE_DYNAMIC_DRAW, 429e5c31af7Sopenharmony_ci componentCount, 430e5c31af7Sopenharmony_ci 0, 431e5c31af7Sopenharmony_ci 0, 432e5c31af7Sopenharmony_ci false, 433e5c31af7Sopenharmony_ci GLValue::getMinValue(inputTypes[inputTypeNdx]), 434e5c31af7Sopenharmony_ci GLValue::getMaxValue(inputTypes[inputTypeNdx])); 435e5c31af7Sopenharmony_ci 436e5c31af7Sopenharmony_ci MultiVertexArrayTest::Spec spec; 437e5c31af7Sopenharmony_ci spec.primitive = Array::PRIMITIVE_TRIANGLES; 438e5c31af7Sopenharmony_ci spec.drawCount = counts[countNdx]; 439e5c31af7Sopenharmony_ci spec.first = 0; 440e5c31af7Sopenharmony_ci spec.arrays.push_back(arraySpec); 441e5c31af7Sopenharmony_ci 442e5c31af7Sopenharmony_ci std::string name = spec.getName(); 443e5c31af7Sopenharmony_ci addChild(new MultiVertexArrayTest(m_testCtx, m_context.getRenderContext(), spec, name.c_str(), name.c_str())); 444e5c31af7Sopenharmony_ci } 445e5c31af7Sopenharmony_ci } 446e5c31af7Sopenharmony_ci } 447e5c31af7Sopenharmony_ci } 448e5c31af7Sopenharmony_ci } 449e5c31af7Sopenharmony_ci} 450e5c31af7Sopenharmony_ci 451e5c31af7Sopenharmony_ciclass SingleVertexArrayTestGroup : public TestCaseGroup 452e5c31af7Sopenharmony_ci{ 453e5c31af7Sopenharmony_cipublic: 454e5c31af7Sopenharmony_ci SingleVertexArrayTestGroup (Context& context); 455e5c31af7Sopenharmony_ci virtual ~SingleVertexArrayTestGroup (void); 456e5c31af7Sopenharmony_ci 457e5c31af7Sopenharmony_ci virtual void init (void); 458e5c31af7Sopenharmony_ci 459e5c31af7Sopenharmony_ciprivate: 460e5c31af7Sopenharmony_ci SingleVertexArrayTestGroup (const SingleVertexArrayTestGroup& other); 461e5c31af7Sopenharmony_ci SingleVertexArrayTestGroup& operator= (const SingleVertexArrayTestGroup& other); 462e5c31af7Sopenharmony_ci}; 463e5c31af7Sopenharmony_ci 464e5c31af7Sopenharmony_ciSingleVertexArrayTestGroup::SingleVertexArrayTestGroup (Context& context) 465e5c31af7Sopenharmony_ci : TestCaseGroup(context, "single_attribute", "Single vertex atribute") 466e5c31af7Sopenharmony_ci{ 467e5c31af7Sopenharmony_ci} 468e5c31af7Sopenharmony_ci 469e5c31af7Sopenharmony_ciSingleVertexArrayTestGroup::~SingleVertexArrayTestGroup (void) 470e5c31af7Sopenharmony_ci{ 471e5c31af7Sopenharmony_ci} 472e5c31af7Sopenharmony_ci 473e5c31af7Sopenharmony_civoid SingleVertexArrayTestGroup::init (void) 474e5c31af7Sopenharmony_ci{ 475e5c31af7Sopenharmony_ci addChild(new SingleVertexArrayStrideTests(m_context)); 476e5c31af7Sopenharmony_ci addChild(new SingleVertexArrayNormalizeTests(m_context)); 477e5c31af7Sopenharmony_ci addChild(new SingleVertexArrayOutputTypeTests(m_context)); 478e5c31af7Sopenharmony_ci addChild(new SingleVertexArrayUsageTests(m_context)); 479e5c31af7Sopenharmony_ci addChild(new SingleVertexArrayOffsetTests(m_context)); 480e5c31af7Sopenharmony_ci addChild(new SingleVertexArrayFirstTests(m_context)); 481e5c31af7Sopenharmony_ci} 482e5c31af7Sopenharmony_ci 483e5c31af7Sopenharmony_ciclass MultiVertexArrayCountTests : public TestCaseGroup 484e5c31af7Sopenharmony_ci{ 485e5c31af7Sopenharmony_cipublic: 486e5c31af7Sopenharmony_ci MultiVertexArrayCountTests (Context& context); 487e5c31af7Sopenharmony_ci virtual ~MultiVertexArrayCountTests (void); 488e5c31af7Sopenharmony_ci 489e5c31af7Sopenharmony_ci virtual void init (void); 490e5c31af7Sopenharmony_ci 491e5c31af7Sopenharmony_ciprivate: 492e5c31af7Sopenharmony_ci MultiVertexArrayCountTests (const MultiVertexArrayCountTests& other); 493e5c31af7Sopenharmony_ci MultiVertexArrayCountTests& operator= (const MultiVertexArrayCountTests& other); 494e5c31af7Sopenharmony_ci 495e5c31af7Sopenharmony_ci std::string getTestName (const MultiVertexArrayTest::Spec& spec); 496e5c31af7Sopenharmony_ci}; 497e5c31af7Sopenharmony_ci 498e5c31af7Sopenharmony_ciMultiVertexArrayCountTests::MultiVertexArrayCountTests (Context& context) 499e5c31af7Sopenharmony_ci : TestCaseGroup(context, "attribute_count", "Attribute counts") 500e5c31af7Sopenharmony_ci{ 501e5c31af7Sopenharmony_ci} 502e5c31af7Sopenharmony_ci 503e5c31af7Sopenharmony_ciMultiVertexArrayCountTests::~MultiVertexArrayCountTests (void) 504e5c31af7Sopenharmony_ci{ 505e5c31af7Sopenharmony_ci} 506e5c31af7Sopenharmony_ci 507e5c31af7Sopenharmony_cistd::string MultiVertexArrayCountTests::getTestName (const MultiVertexArrayTest::Spec& spec) 508e5c31af7Sopenharmony_ci{ 509e5c31af7Sopenharmony_ci std::stringstream name; 510e5c31af7Sopenharmony_ci name 511e5c31af7Sopenharmony_ci << spec.arrays.size(); 512e5c31af7Sopenharmony_ci 513e5c31af7Sopenharmony_ci return name.str(); 514e5c31af7Sopenharmony_ci} 515e5c31af7Sopenharmony_ci 516e5c31af7Sopenharmony_civoid MultiVertexArrayCountTests::init (void) 517e5c31af7Sopenharmony_ci{ 518e5c31af7Sopenharmony_ci // Test attribute counts 519e5c31af7Sopenharmony_ci int arrayCounts[] = {2, 3, 4, 5, 6, 7, 8}; 520e5c31af7Sopenharmony_ci 521e5c31af7Sopenharmony_ci for (int arrayCountNdx = 0; arrayCountNdx < DE_LENGTH_OF_ARRAY(arrayCounts); arrayCountNdx++) 522e5c31af7Sopenharmony_ci { 523e5c31af7Sopenharmony_ci MultiVertexArrayTest::Spec spec; 524e5c31af7Sopenharmony_ci 525e5c31af7Sopenharmony_ci spec.primitive = Array::PRIMITIVE_TRIANGLES; 526e5c31af7Sopenharmony_ci spec.drawCount = 256; 527e5c31af7Sopenharmony_ci spec.first = 0; 528e5c31af7Sopenharmony_ci 529e5c31af7Sopenharmony_ci for (int arrayNdx = 0; arrayNdx < arrayCounts[arrayCountNdx]; arrayNdx++) 530e5c31af7Sopenharmony_ci { 531e5c31af7Sopenharmony_ci MultiVertexArrayTest::Spec::ArraySpec arraySpec(Array::INPUTTYPE_FLOAT, 532e5c31af7Sopenharmony_ci Array::OUTPUTTYPE_VEC2, 533e5c31af7Sopenharmony_ci Array::STORAGE_USER, 534e5c31af7Sopenharmony_ci Array::USAGE_DYNAMIC_DRAW, 535e5c31af7Sopenharmony_ci 2, 536e5c31af7Sopenharmony_ci 0, 537e5c31af7Sopenharmony_ci 0, 538e5c31af7Sopenharmony_ci false, 539e5c31af7Sopenharmony_ci GLValue::getMinValue(Array::INPUTTYPE_FLOAT), 540e5c31af7Sopenharmony_ci GLValue::getMaxValue(Array::INPUTTYPE_FLOAT)); 541e5c31af7Sopenharmony_ci 542e5c31af7Sopenharmony_ci spec.arrays.push_back(arraySpec); 543e5c31af7Sopenharmony_ci } 544e5c31af7Sopenharmony_ci 545e5c31af7Sopenharmony_ci std::string name = getTestName(spec); 546e5c31af7Sopenharmony_ci std::string desc = getTestName(spec); 547e5c31af7Sopenharmony_ci 548e5c31af7Sopenharmony_ci addChild(new MultiVertexArrayTest(m_testCtx, m_context.getRenderContext(), spec, name.c_str(), desc.c_str())); 549e5c31af7Sopenharmony_ci } 550e5c31af7Sopenharmony_ci} 551e5c31af7Sopenharmony_ci 552e5c31af7Sopenharmony_ciclass MultiVertexArrayStorageTests : public TestCaseGroup 553e5c31af7Sopenharmony_ci{ 554e5c31af7Sopenharmony_cipublic: 555e5c31af7Sopenharmony_ci MultiVertexArrayStorageTests (Context& context); 556e5c31af7Sopenharmony_ci virtual ~MultiVertexArrayStorageTests (void); 557e5c31af7Sopenharmony_ci 558e5c31af7Sopenharmony_ci virtual void init (void); 559e5c31af7Sopenharmony_ci 560e5c31af7Sopenharmony_ciprivate: 561e5c31af7Sopenharmony_ci MultiVertexArrayStorageTests (const MultiVertexArrayStorageTests& other); 562e5c31af7Sopenharmony_ci MultiVertexArrayStorageTests& operator= (const MultiVertexArrayStorageTests& other); 563e5c31af7Sopenharmony_ci 564e5c31af7Sopenharmony_ci void addStorageCases (MultiVertexArrayTest::Spec spec, int depth); 565e5c31af7Sopenharmony_ci std::string getTestName (const MultiVertexArrayTest::Spec& spec); 566e5c31af7Sopenharmony_ci}; 567e5c31af7Sopenharmony_ci 568e5c31af7Sopenharmony_ciMultiVertexArrayStorageTests::MultiVertexArrayStorageTests (Context& context) 569e5c31af7Sopenharmony_ci : TestCaseGroup(context, "storage", "Attribute storages") 570e5c31af7Sopenharmony_ci{ 571e5c31af7Sopenharmony_ci} 572e5c31af7Sopenharmony_ci 573e5c31af7Sopenharmony_ciMultiVertexArrayStorageTests::~MultiVertexArrayStorageTests (void) 574e5c31af7Sopenharmony_ci{ 575e5c31af7Sopenharmony_ci} 576e5c31af7Sopenharmony_ci 577e5c31af7Sopenharmony_cistd::string MultiVertexArrayStorageTests::getTestName (const MultiVertexArrayTest::Spec& spec) 578e5c31af7Sopenharmony_ci{ 579e5c31af7Sopenharmony_ci std::stringstream name; 580e5c31af7Sopenharmony_ci name 581e5c31af7Sopenharmony_ci << spec.arrays.size(); 582e5c31af7Sopenharmony_ci 583e5c31af7Sopenharmony_ci for (int arrayNdx = 0; arrayNdx < (int)spec.arrays.size(); arrayNdx++) 584e5c31af7Sopenharmony_ci { 585e5c31af7Sopenharmony_ci name 586e5c31af7Sopenharmony_ci << "_" 587e5c31af7Sopenharmony_ci << Array::storageToString(spec.arrays[arrayNdx].storage); 588e5c31af7Sopenharmony_ci } 589e5c31af7Sopenharmony_ci 590e5c31af7Sopenharmony_ci return name.str(); 591e5c31af7Sopenharmony_ci} 592e5c31af7Sopenharmony_ci 593e5c31af7Sopenharmony_civoid MultiVertexArrayStorageTests::addStorageCases (MultiVertexArrayTest::Spec spec, int depth) 594e5c31af7Sopenharmony_ci{ 595e5c31af7Sopenharmony_ci if (depth == 0) 596e5c31af7Sopenharmony_ci { 597e5c31af7Sopenharmony_ci // Skip trivial case, used elsewhere 598e5c31af7Sopenharmony_ci bool ok = false; 599e5c31af7Sopenharmony_ci for (int arrayNdx = 0; arrayNdx < (int)spec.arrays.size(); arrayNdx++) 600e5c31af7Sopenharmony_ci { 601e5c31af7Sopenharmony_ci if (spec.arrays[arrayNdx].storage != Array::STORAGE_USER) 602e5c31af7Sopenharmony_ci { 603e5c31af7Sopenharmony_ci ok = true; 604e5c31af7Sopenharmony_ci break; 605e5c31af7Sopenharmony_ci } 606e5c31af7Sopenharmony_ci } 607e5c31af7Sopenharmony_ci 608e5c31af7Sopenharmony_ci if (!ok) 609e5c31af7Sopenharmony_ci return; 610e5c31af7Sopenharmony_ci 611e5c31af7Sopenharmony_ci std::string name = getTestName(spec); 612e5c31af7Sopenharmony_ci std::string desc = getTestName(spec); 613e5c31af7Sopenharmony_ci 614e5c31af7Sopenharmony_ci addChild(new MultiVertexArrayTest(m_testCtx, m_context.getRenderContext(), spec, name.c_str(), desc.c_str())); 615e5c31af7Sopenharmony_ci return; 616e5c31af7Sopenharmony_ci } 617e5c31af7Sopenharmony_ci 618e5c31af7Sopenharmony_ci Array::Storage storages[] = {Array::STORAGE_USER, Array::STORAGE_BUFFER}; 619e5c31af7Sopenharmony_ci for (int storageNdx = 0; storageNdx < DE_LENGTH_OF_ARRAY(storages); storageNdx++) 620e5c31af7Sopenharmony_ci { 621e5c31af7Sopenharmony_ci MultiVertexArrayTest::Spec::ArraySpec arraySpec(Array::INPUTTYPE_FLOAT, 622e5c31af7Sopenharmony_ci Array::OUTPUTTYPE_VEC2, 623e5c31af7Sopenharmony_ci storages[storageNdx], 624e5c31af7Sopenharmony_ci Array::USAGE_DYNAMIC_DRAW, 625e5c31af7Sopenharmony_ci 2, 626e5c31af7Sopenharmony_ci 0, 627e5c31af7Sopenharmony_ci 0, 628e5c31af7Sopenharmony_ci false, 629e5c31af7Sopenharmony_ci GLValue::getMinValue(Array::INPUTTYPE_FLOAT), 630e5c31af7Sopenharmony_ci GLValue::getMaxValue(Array::INPUTTYPE_FLOAT)); 631e5c31af7Sopenharmony_ci 632e5c31af7Sopenharmony_ci MultiVertexArrayTest::Spec _spec = spec; 633e5c31af7Sopenharmony_ci _spec.arrays.push_back(arraySpec); 634e5c31af7Sopenharmony_ci addStorageCases(_spec, depth-1); 635e5c31af7Sopenharmony_ci } 636e5c31af7Sopenharmony_ci} 637e5c31af7Sopenharmony_ci 638e5c31af7Sopenharmony_ci 639e5c31af7Sopenharmony_civoid MultiVertexArrayStorageTests::init (void) 640e5c31af7Sopenharmony_ci{ 641e5c31af7Sopenharmony_ci // Test different storages 642e5c31af7Sopenharmony_ci int arrayCounts[] = {3}; 643e5c31af7Sopenharmony_ci 644e5c31af7Sopenharmony_ci MultiVertexArrayTest::Spec spec; 645e5c31af7Sopenharmony_ci 646e5c31af7Sopenharmony_ci spec.primitive = Array::PRIMITIVE_TRIANGLES; 647e5c31af7Sopenharmony_ci spec.drawCount = 256; 648e5c31af7Sopenharmony_ci spec.first = 0; 649e5c31af7Sopenharmony_ci 650e5c31af7Sopenharmony_ci for (int arrayCountNdx = 0; arrayCountNdx < DE_LENGTH_OF_ARRAY(arrayCounts); arrayCountNdx++) 651e5c31af7Sopenharmony_ci addStorageCases(spec, arrayCounts[arrayCountNdx]); 652e5c31af7Sopenharmony_ci} 653e5c31af7Sopenharmony_ci 654e5c31af7Sopenharmony_ciclass MultiVertexArrayStrideTests : public TestCaseGroup 655e5c31af7Sopenharmony_ci{ 656e5c31af7Sopenharmony_cipublic: 657e5c31af7Sopenharmony_ci MultiVertexArrayStrideTests (Context& context); 658e5c31af7Sopenharmony_ci virtual ~MultiVertexArrayStrideTests (void); 659e5c31af7Sopenharmony_ci 660e5c31af7Sopenharmony_ci virtual void init (void); 661e5c31af7Sopenharmony_ci 662e5c31af7Sopenharmony_ciprivate: 663e5c31af7Sopenharmony_ci MultiVertexArrayStrideTests (const MultiVertexArrayStrideTests& other); 664e5c31af7Sopenharmony_ci MultiVertexArrayStrideTests& operator= (const MultiVertexArrayStrideTests& other); 665e5c31af7Sopenharmony_ci 666e5c31af7Sopenharmony_ci void addStrideCases (MultiVertexArrayTest::Spec spec, int depth); 667e5c31af7Sopenharmony_ci std::string getTestName (const MultiVertexArrayTest::Spec& spec); 668e5c31af7Sopenharmony_ci}; 669e5c31af7Sopenharmony_ci 670e5c31af7Sopenharmony_ciMultiVertexArrayStrideTests::MultiVertexArrayStrideTests (Context& context) 671e5c31af7Sopenharmony_ci : TestCaseGroup(context, "stride", "Strides") 672e5c31af7Sopenharmony_ci{ 673e5c31af7Sopenharmony_ci} 674e5c31af7Sopenharmony_ci 675e5c31af7Sopenharmony_ciMultiVertexArrayStrideTests::~MultiVertexArrayStrideTests (void) 676e5c31af7Sopenharmony_ci{ 677e5c31af7Sopenharmony_ci} 678e5c31af7Sopenharmony_ci 679e5c31af7Sopenharmony_cistd::string MultiVertexArrayStrideTests::getTestName (const MultiVertexArrayTest::Spec& spec) 680e5c31af7Sopenharmony_ci{ 681e5c31af7Sopenharmony_ci std::stringstream name; 682e5c31af7Sopenharmony_ci 683e5c31af7Sopenharmony_ci name 684e5c31af7Sopenharmony_ci << spec.arrays.size(); 685e5c31af7Sopenharmony_ci 686e5c31af7Sopenharmony_ci for (int arrayNdx = 0; arrayNdx < (int)spec.arrays.size(); arrayNdx++) 687e5c31af7Sopenharmony_ci { 688e5c31af7Sopenharmony_ci name 689e5c31af7Sopenharmony_ci << "_" 690e5c31af7Sopenharmony_ci << Array::inputTypeToString(spec.arrays[arrayNdx].inputType) 691e5c31af7Sopenharmony_ci << spec.arrays[arrayNdx].componentCount << "_" 692e5c31af7Sopenharmony_ci << spec.arrays[arrayNdx].stride; 693e5c31af7Sopenharmony_ci } 694e5c31af7Sopenharmony_ci 695e5c31af7Sopenharmony_ci return name.str(); 696e5c31af7Sopenharmony_ci} 697e5c31af7Sopenharmony_ci 698e5c31af7Sopenharmony_civoid MultiVertexArrayStrideTests::init (void) 699e5c31af7Sopenharmony_ci{ 700e5c31af7Sopenharmony_ci // Test different strides, with multiple arrays, input types?? 701e5c31af7Sopenharmony_ci int arrayCounts[] = {3}; 702e5c31af7Sopenharmony_ci 703e5c31af7Sopenharmony_ci MultiVertexArrayTest::Spec spec; 704e5c31af7Sopenharmony_ci 705e5c31af7Sopenharmony_ci spec.primitive = Array::PRIMITIVE_TRIANGLES; 706e5c31af7Sopenharmony_ci spec.drawCount = 256; 707e5c31af7Sopenharmony_ci spec.first = 0; 708e5c31af7Sopenharmony_ci 709e5c31af7Sopenharmony_ci for (int arrayCountNdx = 0; arrayCountNdx < DE_LENGTH_OF_ARRAY(arrayCounts); arrayCountNdx++) 710e5c31af7Sopenharmony_ci addStrideCases(spec, arrayCounts[arrayCountNdx]); 711e5c31af7Sopenharmony_ci} 712e5c31af7Sopenharmony_ci 713e5c31af7Sopenharmony_civoid MultiVertexArrayStrideTests::addStrideCases (MultiVertexArrayTest::Spec spec, int depth) 714e5c31af7Sopenharmony_ci{ 715e5c31af7Sopenharmony_ci if (depth == 0) 716e5c31af7Sopenharmony_ci { 717e5c31af7Sopenharmony_ci std::string name = getTestName(spec); 718e5c31af7Sopenharmony_ci std::string desc = getTestName(spec); 719e5c31af7Sopenharmony_ci addChild(new MultiVertexArrayTest(m_testCtx, m_context.getRenderContext(), spec, name.c_str(), desc.c_str())); 720e5c31af7Sopenharmony_ci return; 721e5c31af7Sopenharmony_ci } 722e5c31af7Sopenharmony_ci 723e5c31af7Sopenharmony_ci int strides[] = {0, -1, 17, 32}; 724e5c31af7Sopenharmony_ci 725e5c31af7Sopenharmony_ci for (int strideNdx = 0; strideNdx < DE_LENGTH_OF_ARRAY(strides); strideNdx++) 726e5c31af7Sopenharmony_ci { 727e5c31af7Sopenharmony_ci const int componentCount = 2; 728e5c31af7Sopenharmony_ci MultiVertexArrayTest::Spec::ArraySpec arraySpec(Array::INPUTTYPE_FLOAT, 729e5c31af7Sopenharmony_ci Array::OUTPUTTYPE_VEC2, 730e5c31af7Sopenharmony_ci Array::STORAGE_USER, 731e5c31af7Sopenharmony_ci Array::USAGE_DYNAMIC_DRAW, 732e5c31af7Sopenharmony_ci componentCount, 733e5c31af7Sopenharmony_ci 0, 734e5c31af7Sopenharmony_ci (strides[strideNdx] >= 0 ? strides[strideNdx] : componentCount * Array::inputTypeSize(Array::INPUTTYPE_FLOAT)), 735e5c31af7Sopenharmony_ci false, 736e5c31af7Sopenharmony_ci GLValue::getMinValue(Array::INPUTTYPE_FLOAT), 737e5c31af7Sopenharmony_ci GLValue::getMaxValue(Array::INPUTTYPE_FLOAT)); 738e5c31af7Sopenharmony_ci 739e5c31af7Sopenharmony_ci MultiVertexArrayTest::Spec _spec = spec; 740e5c31af7Sopenharmony_ci _spec.arrays.push_back(arraySpec); 741e5c31af7Sopenharmony_ci addStrideCases(_spec, depth-1); 742e5c31af7Sopenharmony_ci } 743e5c31af7Sopenharmony_ci} 744e5c31af7Sopenharmony_ci 745e5c31af7Sopenharmony_ciclass MultiVertexArrayOutputTests : public TestCaseGroup 746e5c31af7Sopenharmony_ci{ 747e5c31af7Sopenharmony_cipublic: 748e5c31af7Sopenharmony_ci MultiVertexArrayOutputTests (Context& context); 749e5c31af7Sopenharmony_ci virtual ~MultiVertexArrayOutputTests (void); 750e5c31af7Sopenharmony_ci 751e5c31af7Sopenharmony_ci virtual void init (void); 752e5c31af7Sopenharmony_ci 753e5c31af7Sopenharmony_ciprivate: 754e5c31af7Sopenharmony_ci MultiVertexArrayOutputTests (const MultiVertexArrayOutputTests& other); 755e5c31af7Sopenharmony_ci MultiVertexArrayOutputTests& operator= (const MultiVertexArrayOutputTests& other); 756e5c31af7Sopenharmony_ci 757e5c31af7Sopenharmony_ci void addInputTypeCases (MultiVertexArrayTest::Spec spec, int depth); 758e5c31af7Sopenharmony_ci std::string getTestName (const MultiVertexArrayTest::Spec& spec); 759e5c31af7Sopenharmony_ci}; 760e5c31af7Sopenharmony_ci 761e5c31af7Sopenharmony_ciMultiVertexArrayOutputTests::MultiVertexArrayOutputTests (Context& context) 762e5c31af7Sopenharmony_ci : TestCaseGroup(context, "input_types", "input types") 763e5c31af7Sopenharmony_ci{ 764e5c31af7Sopenharmony_ci} 765e5c31af7Sopenharmony_ci 766e5c31af7Sopenharmony_ciMultiVertexArrayOutputTests::~MultiVertexArrayOutputTests (void) 767e5c31af7Sopenharmony_ci{ 768e5c31af7Sopenharmony_ci} 769e5c31af7Sopenharmony_ci 770e5c31af7Sopenharmony_cistd::string MultiVertexArrayOutputTests::getTestName (const MultiVertexArrayTest::Spec& spec) 771e5c31af7Sopenharmony_ci{ 772e5c31af7Sopenharmony_ci std::stringstream name; 773e5c31af7Sopenharmony_ci 774e5c31af7Sopenharmony_ci name 775e5c31af7Sopenharmony_ci << spec.arrays.size(); 776e5c31af7Sopenharmony_ci 777e5c31af7Sopenharmony_ci for (int arrayNdx = 0; arrayNdx < (int)spec.arrays.size(); arrayNdx++) 778e5c31af7Sopenharmony_ci { 779e5c31af7Sopenharmony_ci name 780e5c31af7Sopenharmony_ci << "_" 781e5c31af7Sopenharmony_ci << Array::inputTypeToString(spec.arrays[arrayNdx].inputType) 782e5c31af7Sopenharmony_ci << spec.arrays[arrayNdx].componentCount << "_" 783e5c31af7Sopenharmony_ci << Array::outputTypeToString(spec.arrays[arrayNdx].outputType); 784e5c31af7Sopenharmony_ci } 785e5c31af7Sopenharmony_ci 786e5c31af7Sopenharmony_ci return name.str(); 787e5c31af7Sopenharmony_ci} 788e5c31af7Sopenharmony_ci 789e5c31af7Sopenharmony_civoid MultiVertexArrayOutputTests::init (void) 790e5c31af7Sopenharmony_ci{ 791e5c31af7Sopenharmony_ci // Test different input types, with multiple arrays 792e5c31af7Sopenharmony_ci int arrayCounts[] = {3}; 793e5c31af7Sopenharmony_ci 794e5c31af7Sopenharmony_ci MultiVertexArrayTest::Spec spec; 795e5c31af7Sopenharmony_ci 796e5c31af7Sopenharmony_ci spec.primitive = Array::PRIMITIVE_TRIANGLES; 797e5c31af7Sopenharmony_ci spec.drawCount = 256; 798e5c31af7Sopenharmony_ci spec.first = 0; 799e5c31af7Sopenharmony_ci 800e5c31af7Sopenharmony_ci for (int arrayCountNdx = 0; arrayCountNdx < DE_LENGTH_OF_ARRAY(arrayCounts); arrayCountNdx++) 801e5c31af7Sopenharmony_ci addInputTypeCases(spec, arrayCounts[arrayCountNdx]); 802e5c31af7Sopenharmony_ci} 803e5c31af7Sopenharmony_ci 804e5c31af7Sopenharmony_civoid MultiVertexArrayOutputTests::addInputTypeCases (MultiVertexArrayTest::Spec spec, int depth) 805e5c31af7Sopenharmony_ci{ 806e5c31af7Sopenharmony_ci if (depth == 0) 807e5c31af7Sopenharmony_ci { 808e5c31af7Sopenharmony_ci std::string name = getTestName(spec); 809e5c31af7Sopenharmony_ci std::string desc = getTestName(spec); 810e5c31af7Sopenharmony_ci addChild(new MultiVertexArrayTest(m_testCtx, m_context.getRenderContext(), spec, name.c_str(), desc.c_str())); 811e5c31af7Sopenharmony_ci return; 812e5c31af7Sopenharmony_ci } 813e5c31af7Sopenharmony_ci 814e5c31af7Sopenharmony_ci Array::InputType inputTypes[] = {Array::INPUTTYPE_FIXED, Array::INPUTTYPE_BYTE, Array::INPUTTYPE_SHORT, Array::INPUTTYPE_UNSIGNED_BYTE, Array::INPUTTYPE_UNSIGNED_SHORT}; 815e5c31af7Sopenharmony_ci for (int inputTypeNdx = 0; inputTypeNdx < DE_LENGTH_OF_ARRAY(inputTypes); inputTypeNdx++) 816e5c31af7Sopenharmony_ci { 817e5c31af7Sopenharmony_ci MultiVertexArrayTest::Spec::ArraySpec arraySpec(inputTypes[inputTypeNdx], 818e5c31af7Sopenharmony_ci Array::OUTPUTTYPE_VEC2, 819e5c31af7Sopenharmony_ci Array::STORAGE_USER, 820e5c31af7Sopenharmony_ci Array::USAGE_DYNAMIC_DRAW, 821e5c31af7Sopenharmony_ci 2, 822e5c31af7Sopenharmony_ci 0, 823e5c31af7Sopenharmony_ci 0, 824e5c31af7Sopenharmony_ci false, 825e5c31af7Sopenharmony_ci GLValue::getMinValue(inputTypes[inputTypeNdx]), 826e5c31af7Sopenharmony_ci GLValue::getMaxValue(inputTypes[inputTypeNdx])); 827e5c31af7Sopenharmony_ci 828e5c31af7Sopenharmony_ci MultiVertexArrayTest::Spec _spec = spec; 829e5c31af7Sopenharmony_ci _spec.arrays.push_back(arraySpec); 830e5c31af7Sopenharmony_ci addInputTypeCases(_spec, depth-1); 831e5c31af7Sopenharmony_ci } 832e5c31af7Sopenharmony_ci} 833e5c31af7Sopenharmony_ci 834e5c31af7Sopenharmony_ciclass MultiVertexArrayTestGroup : public TestCaseGroup 835e5c31af7Sopenharmony_ci{ 836e5c31af7Sopenharmony_cipublic: 837e5c31af7Sopenharmony_ci MultiVertexArrayTestGroup (Context& context); 838e5c31af7Sopenharmony_ci virtual ~MultiVertexArrayTestGroup (void); 839e5c31af7Sopenharmony_ci 840e5c31af7Sopenharmony_ci virtual void init (void); 841e5c31af7Sopenharmony_ci 842e5c31af7Sopenharmony_ciprivate: 843e5c31af7Sopenharmony_ci MultiVertexArrayTestGroup (const MultiVertexArrayTestGroup& other); 844e5c31af7Sopenharmony_ci MultiVertexArrayTestGroup& operator= (const MultiVertexArrayTestGroup& other); 845e5c31af7Sopenharmony_ci}; 846e5c31af7Sopenharmony_ci 847e5c31af7Sopenharmony_ciMultiVertexArrayTestGroup::MultiVertexArrayTestGroup (Context& context) 848e5c31af7Sopenharmony_ci : TestCaseGroup(context, "multiple_attributes", "Multiple vertex atributes") 849e5c31af7Sopenharmony_ci{ 850e5c31af7Sopenharmony_ci} 851e5c31af7Sopenharmony_ci 852e5c31af7Sopenharmony_ciMultiVertexArrayTestGroup::~MultiVertexArrayTestGroup (void) 853e5c31af7Sopenharmony_ci{ 854e5c31af7Sopenharmony_ci} 855e5c31af7Sopenharmony_ci 856e5c31af7Sopenharmony_civoid MultiVertexArrayTestGroup::init (void) 857e5c31af7Sopenharmony_ci{ 858e5c31af7Sopenharmony_ci addChild(new MultiVertexArrayCountTests(m_context)); 859e5c31af7Sopenharmony_ci addChild(new MultiVertexArrayStorageTests(m_context)); 860e5c31af7Sopenharmony_ci addChild(new MultiVertexArrayStrideTests(m_context)); 861e5c31af7Sopenharmony_ci addChild(new MultiVertexArrayOutputTests(m_context)); 862e5c31af7Sopenharmony_ci} 863e5c31af7Sopenharmony_ci 864e5c31af7Sopenharmony_ciVertexArrayTestGroup::VertexArrayTestGroup (Context& context) 865e5c31af7Sopenharmony_ci : TestCaseGroup(context, "vertex_arrays", "Vertex array and array tests") 866e5c31af7Sopenharmony_ci{ 867e5c31af7Sopenharmony_ci} 868e5c31af7Sopenharmony_ci 869e5c31af7Sopenharmony_ciVertexArrayTestGroup::~VertexArrayTestGroup (void) 870e5c31af7Sopenharmony_ci{ 871e5c31af7Sopenharmony_ci} 872e5c31af7Sopenharmony_ci 873e5c31af7Sopenharmony_civoid VertexArrayTestGroup::init (void) 874e5c31af7Sopenharmony_ci{ 875e5c31af7Sopenharmony_ci addChild(new SingleVertexArrayTestGroup(m_context)); 876e5c31af7Sopenharmony_ci addChild(new MultiVertexArrayTestGroup(m_context)); 877e5c31af7Sopenharmony_ci} 878e5c31af7Sopenharmony_ci 879e5c31af7Sopenharmony_ci} // Functional 880e5c31af7Sopenharmony_ci} // gles2 881e5c31af7Sopenharmony_ci} // deqp 882e5c31af7Sopenharmony_ci 883