13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#ifndef _ES2FBUFFERTESTUTIL_HPP 23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define _ES2FBUFFERTESTUTIL_HPP 33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*------------------------------------------------------------------------- 43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL ES 2.0 Module 53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * ------------------------------------------------- 63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project 83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License"); 103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License. 113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at 123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * http://www.apache.org/licenses/LICENSE-2.0 143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software 163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS, 173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and 193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License. 203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*! 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Buffer test utilities. 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuDefs.hpp" 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestLog.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluCallLogWrapper.hpp" 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tes2TestCase.hpp" 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <vector> 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <set> 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace glu 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ShaderProgram; 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles2 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Functional 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace BufferTestUtil 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Helper functions. 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid fillWithRandomBytes (deUint8* ptr, int numBytes, deUint32 seed); 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool compareByteArrays (tcu::TestLog& log, const deUint8* resPtr, const deUint8* refPtr, int numBytes); 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyryconst char* getBufferTargetName (deUint32 target); 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyryconst char* getUsageHintName (deUint32 hint); 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Base class for buffer cases. 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BufferCase : public TestCase, public glu::CallLogWrapper 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BufferCase (Context& context, const char* name, const char* description); 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual ~BufferCase (void); 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void deinit (void); 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 genBuffer (void); 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void deleteBuffer (deUint32 buffer); 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void checkError (void); 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Resource handles for cleanup in case of unexpected iterate() termination. 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::set<deUint32> m_allocatedBuffers; 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Reference buffer. 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ReferenceBuffer 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ReferenceBuffer (void) {} 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~ReferenceBuffer (void) {} 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void setSize (int numBytes); 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void setData (int numBytes, const deUint8* bytes); 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void setSubData (int offset, int numBytes, const deUint8* bytes); 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint8* getPtr (int offset = 0) { return &m_data[offset]; } 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint8* getPtr (int offset = 0) const { return &m_data[offset]; } 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<deUint8> m_data; 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Buffer verifier system. 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum VerifyType 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry VERIFY_AS_VERTEX_ARRAY = 0, 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry VERIFY_AS_INDEX_ARRAY, 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry VERIFY_LAST 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BufferVerifierBase : public glu::CallLogWrapper 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BufferVerifierBase (Context& context); 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual ~BufferVerifierBase (void) {} 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual int getMinSize (void) const = DE_NULL; 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual int getAlignment (void) const = DE_NULL; 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual bool verify (deUint32 buffer, const deUint8* reference, int offset, int numBytes) = DE_NULL; 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected: 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Context& m_context; 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BufferVerifierBase (const BufferVerifierBase& other); 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BufferVerifierBase& operator= (const BufferVerifierBase& other); 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BufferVerifier 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BufferVerifier (Context& context, VerifyType verifyType); 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~BufferVerifier (void); 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getMinSize (void) const { return m_verifier->getMinSize(); } 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getAlignment (void) const { return m_verifier->getAlignment(); } 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // \note Offset is applied to reference pointer as well. 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool verify (deUint32 buffer, const deUint8* reference, int offset, int numBytes); 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BufferVerifier (const BufferVerifier& other); 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BufferVerifier& operator= (const BufferVerifier& other); 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BufferVerifierBase* m_verifier; 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass VertexArrayVerifier : public BufferVerifierBase 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry VertexArrayVerifier (Context& context); 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~VertexArrayVerifier (void); 1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getMinSize (void) const { return 3*4; } 1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getAlignment (void) const { return 1; } 1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool verify (deUint32 buffer, const deUint8* reference, int offset, int numBytes); 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::ShaderProgram* m_program; 1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_posLoc; 1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_byteVecLoc; 1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass IndexArrayVerifier : public BufferVerifierBase 1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IndexArrayVerifier (Context& context); 1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~IndexArrayVerifier (void); 1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getMinSize (void) const { return 2; } 1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getAlignment (void) const { return 1; } 1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool verify (deUint32 buffer, const deUint8* reference, int offset, int numBytes); 1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::ShaderProgram* m_program; 1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_posLoc; 1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_colorLoc; 1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // BufferTestUtil 1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Functional 1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles2 1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp 1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#endif // _ES2FBUFFERTESTUTIL_HPP 179