1*35238bceSAndroid Build Coastguard Worker #ifndef _GLSLIFETIMETESTS_HPP 2*35238bceSAndroid Build Coastguard Worker #define _GLSLIFETIMETESTS_HPP 3*35238bceSAndroid Build Coastguard Worker /*------------------------------------------------------------------------- 4*35238bceSAndroid Build Coastguard Worker * drawElements Quality Program OpenGL (ES) Module 5*35238bceSAndroid Build Coastguard Worker * ----------------------------------------------- 6*35238bceSAndroid Build Coastguard Worker * 7*35238bceSAndroid Build Coastguard Worker * Copyright 2014 The Android Open Source Project 8*35238bceSAndroid Build Coastguard Worker * 9*35238bceSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 10*35238bceSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 11*35238bceSAndroid Build Coastguard Worker * You may obtain a copy of the License at 12*35238bceSAndroid Build Coastguard Worker * 13*35238bceSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 14*35238bceSAndroid Build Coastguard Worker * 15*35238bceSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 16*35238bceSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 17*35238bceSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18*35238bceSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 19*35238bceSAndroid Build Coastguard Worker * limitations under the License. 20*35238bceSAndroid Build Coastguard Worker * 21*35238bceSAndroid Build Coastguard Worker *//*! 22*35238bceSAndroid Build Coastguard Worker * \file 23*35238bceSAndroid Build Coastguard Worker * \brief Common object lifetime tests. 24*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/ 25*35238bceSAndroid Build Coastguard Worker 26*35238bceSAndroid Build Coastguard Worker #include "deRandom.hpp" 27*35238bceSAndroid Build Coastguard Worker #include "deUniquePtr.hpp" 28*35238bceSAndroid Build Coastguard Worker #include "tcuSurface.hpp" 29*35238bceSAndroid Build Coastguard Worker #include "tcuTestCase.hpp" 30*35238bceSAndroid Build Coastguard Worker #include "tcuTestContext.hpp" 31*35238bceSAndroid Build Coastguard Worker #include "gluCallLogWrapper.hpp" 32*35238bceSAndroid Build Coastguard Worker #include "gluRenderContext.hpp" 33*35238bceSAndroid Build Coastguard Worker #include "glwDefs.hpp" 34*35238bceSAndroid Build Coastguard Worker #include "glwEnums.hpp" 35*35238bceSAndroid Build Coastguard Worker 36*35238bceSAndroid Build Coastguard Worker #include <vector> 37*35238bceSAndroid Build Coastguard Worker 38*35238bceSAndroid Build Coastguard Worker namespace deqp 39*35238bceSAndroid Build Coastguard Worker { 40*35238bceSAndroid Build Coastguard Worker namespace gls 41*35238bceSAndroid Build Coastguard Worker { 42*35238bceSAndroid Build Coastguard Worker namespace LifetimeTests 43*35238bceSAndroid Build Coastguard Worker { 44*35238bceSAndroid Build Coastguard Worker namespace details 45*35238bceSAndroid Build Coastguard Worker { 46*35238bceSAndroid Build Coastguard Worker 47*35238bceSAndroid Build Coastguard Worker using de::MovePtr; 48*35238bceSAndroid Build Coastguard Worker using de::Random; 49*35238bceSAndroid Build Coastguard Worker using glu::CallLogWrapper; 50*35238bceSAndroid Build Coastguard Worker using glu::RenderContext; 51*35238bceSAndroid Build Coastguard Worker using std::vector; 52*35238bceSAndroid Build Coastguard Worker using tcu::Surface; 53*35238bceSAndroid Build Coastguard Worker using tcu::TestCaseGroup; 54*35238bceSAndroid Build Coastguard Worker using tcu::TestContext; 55*35238bceSAndroid Build Coastguard Worker using tcu::TestLog; 56*35238bceSAndroid Build Coastguard Worker using namespace glw; 57*35238bceSAndroid Build Coastguard Worker 58*35238bceSAndroid Build Coastguard Worker typedef void (CallLogWrapper::*BindFunc)(GLenum target, GLuint name); 59*35238bceSAndroid Build Coastguard Worker typedef void (CallLogWrapper::*GenFunc)(GLsizei n, GLuint *names); 60*35238bceSAndroid Build Coastguard Worker typedef void (CallLogWrapper::*DeleteFunc)(GLsizei n, const GLuint *names); 61*35238bceSAndroid Build Coastguard Worker typedef GLboolean (CallLogWrapper::*ExistsFunc)(GLuint name); 62*35238bceSAndroid Build Coastguard Worker 63*35238bceSAndroid Build Coastguard Worker class Context 64*35238bceSAndroid Build Coastguard Worker { 65*35238bceSAndroid Build Coastguard Worker public: Context(const RenderContext & renderCtx,TestContext & testCtx)66*35238bceSAndroid Build Coastguard Worker Context(const RenderContext &renderCtx, TestContext &testCtx) : m_renderCtx(renderCtx), m_testCtx(testCtx) 67*35238bceSAndroid Build Coastguard Worker { 68*35238bceSAndroid Build Coastguard Worker } getRenderContext(void) const69*35238bceSAndroid Build Coastguard Worker const RenderContext &getRenderContext(void) const 70*35238bceSAndroid Build Coastguard Worker { 71*35238bceSAndroid Build Coastguard Worker return m_renderCtx; 72*35238bceSAndroid Build Coastguard Worker } getTestContext(void) const73*35238bceSAndroid Build Coastguard Worker TestContext &getTestContext(void) const 74*35238bceSAndroid Build Coastguard Worker { 75*35238bceSAndroid Build Coastguard Worker return m_testCtx; 76*35238bceSAndroid Build Coastguard Worker } gl(void) const77*35238bceSAndroid Build Coastguard Worker const Functions &gl(void) const 78*35238bceSAndroid Build Coastguard Worker { 79*35238bceSAndroid Build Coastguard Worker return m_renderCtx.getFunctions(); 80*35238bceSAndroid Build Coastguard Worker } log(void) const81*35238bceSAndroid Build Coastguard Worker TestLog &log(void) const 82*35238bceSAndroid Build Coastguard Worker { 83*35238bceSAndroid Build Coastguard Worker return m_testCtx.getLog(); 84*35238bceSAndroid Build Coastguard Worker } 85*35238bceSAndroid Build Coastguard Worker 86*35238bceSAndroid Build Coastguard Worker private: 87*35238bceSAndroid Build Coastguard Worker const RenderContext &m_renderCtx; 88*35238bceSAndroid Build Coastguard Worker TestContext &m_testCtx; 89*35238bceSAndroid Build Coastguard Worker }; 90*35238bceSAndroid Build Coastguard Worker 91*35238bceSAndroid Build Coastguard Worker class ContextWrapper : public CallLogWrapper 92*35238bceSAndroid Build Coastguard Worker { 93*35238bceSAndroid Build Coastguard Worker public: getContext(void) const94*35238bceSAndroid Build Coastguard Worker const Context &getContext(void) const 95*35238bceSAndroid Build Coastguard Worker { 96*35238bceSAndroid Build Coastguard Worker return m_ctx; 97*35238bceSAndroid Build Coastguard Worker } getRenderContext(void) const98*35238bceSAndroid Build Coastguard Worker const RenderContext &getRenderContext(void) const 99*35238bceSAndroid Build Coastguard Worker { 100*35238bceSAndroid Build Coastguard Worker return m_ctx.getRenderContext(); 101*35238bceSAndroid Build Coastguard Worker } getTestContext(void) const102*35238bceSAndroid Build Coastguard Worker TestContext &getTestContext(void) const 103*35238bceSAndroid Build Coastguard Worker { 104*35238bceSAndroid Build Coastguard Worker return m_ctx.getTestContext(); 105*35238bceSAndroid Build Coastguard Worker } gl(void) const106*35238bceSAndroid Build Coastguard Worker const Functions &gl(void) const 107*35238bceSAndroid Build Coastguard Worker { 108*35238bceSAndroid Build Coastguard Worker return m_ctx.gl(); 109*35238bceSAndroid Build Coastguard Worker } log(void) const110*35238bceSAndroid Build Coastguard Worker TestLog &log(void) const 111*35238bceSAndroid Build Coastguard Worker { 112*35238bceSAndroid Build Coastguard Worker return m_ctx.log(); 113*35238bceSAndroid Build Coastguard Worker } enableLogging(bool enable)114*35238bceSAndroid Build Coastguard Worker void enableLogging(bool enable) 115*35238bceSAndroid Build Coastguard Worker { 116*35238bceSAndroid Build Coastguard Worker CallLogWrapper::enableLogging(enable); 117*35238bceSAndroid Build Coastguard Worker } 118*35238bceSAndroid Build Coastguard Worker 119*35238bceSAndroid Build Coastguard Worker protected: 120*35238bceSAndroid Build Coastguard Worker ContextWrapper(const Context &ctx); 121*35238bceSAndroid Build Coastguard Worker const Context m_ctx; 122*35238bceSAndroid Build Coastguard Worker }; 123*35238bceSAndroid Build Coastguard Worker 124*35238bceSAndroid Build Coastguard Worker class Binder : public ContextWrapper 125*35238bceSAndroid Build Coastguard Worker { 126*35238bceSAndroid Build Coastguard Worker public: ~Binder(void)127*35238bceSAndroid Build Coastguard Worker virtual ~Binder(void) 128*35238bceSAndroid Build Coastguard Worker { 129*35238bceSAndroid Build Coastguard Worker } 130*35238bceSAndroid Build Coastguard Worker virtual void bind(GLuint name) = 0; 131*35238bceSAndroid Build Coastguard Worker virtual GLuint getBinding(void) = 0; genRequired(void) const132*35238bceSAndroid Build Coastguard Worker virtual bool genRequired(void) const 133*35238bceSAndroid Build Coastguard Worker { 134*35238bceSAndroid Build Coastguard Worker return true; 135*35238bceSAndroid Build Coastguard Worker } 136*35238bceSAndroid Build Coastguard Worker 137*35238bceSAndroid Build Coastguard Worker protected: Binder(const Context & ctx)138*35238bceSAndroid Build Coastguard Worker Binder(const Context &ctx) : ContextWrapper(ctx) 139*35238bceSAndroid Build Coastguard Worker { 140*35238bceSAndroid Build Coastguard Worker } 141*35238bceSAndroid Build Coastguard Worker }; 142*35238bceSAndroid Build Coastguard Worker 143*35238bceSAndroid Build Coastguard Worker class SimpleBinder : public Binder 144*35238bceSAndroid Build Coastguard Worker { 145*35238bceSAndroid Build Coastguard Worker public: SimpleBinder(const Context & ctx,BindFunc bindFunc,GLenum bindTarget,GLenum bindingParam,bool genRequired_=false)146*35238bceSAndroid Build Coastguard Worker SimpleBinder(const Context &ctx, BindFunc bindFunc, GLenum bindTarget, GLenum bindingParam, 147*35238bceSAndroid Build Coastguard Worker bool genRequired_ = false) 148*35238bceSAndroid Build Coastguard Worker : Binder(ctx) 149*35238bceSAndroid Build Coastguard Worker , m_bindFunc(bindFunc) 150*35238bceSAndroid Build Coastguard Worker , m_bindTarget(bindTarget) 151*35238bceSAndroid Build Coastguard Worker , m_bindingParam(bindingParam) 152*35238bceSAndroid Build Coastguard Worker , m_genRequired(genRequired_) 153*35238bceSAndroid Build Coastguard Worker { 154*35238bceSAndroid Build Coastguard Worker } 155*35238bceSAndroid Build Coastguard Worker 156*35238bceSAndroid Build Coastguard Worker void bind(GLuint name); 157*35238bceSAndroid Build Coastguard Worker GLuint getBinding(void); genRequired(void) const158*35238bceSAndroid Build Coastguard Worker bool genRequired(void) const 159*35238bceSAndroid Build Coastguard Worker { 160*35238bceSAndroid Build Coastguard Worker return m_genRequired; 161*35238bceSAndroid Build Coastguard Worker } 162*35238bceSAndroid Build Coastguard Worker 163*35238bceSAndroid Build Coastguard Worker private: 164*35238bceSAndroid Build Coastguard Worker const BindFunc m_bindFunc; 165*35238bceSAndroid Build Coastguard Worker const GLenum m_bindTarget; 166*35238bceSAndroid Build Coastguard Worker const GLenum m_bindingParam; 167*35238bceSAndroid Build Coastguard Worker const bool m_genRequired; 168*35238bceSAndroid Build Coastguard Worker }; 169*35238bceSAndroid Build Coastguard Worker 170*35238bceSAndroid Build Coastguard Worker class Type : public ContextWrapper 171*35238bceSAndroid Build Coastguard Worker { 172*35238bceSAndroid Build Coastguard Worker public: ~Type(void)173*35238bceSAndroid Build Coastguard Worker virtual ~Type(void) 174*35238bceSAndroid Build Coastguard Worker { 175*35238bceSAndroid Build Coastguard Worker } 176*35238bceSAndroid Build Coastguard Worker virtual GLuint gen(void) = 0; 177*35238bceSAndroid Build Coastguard Worker virtual void release(GLuint name) = 0; 178*35238bceSAndroid Build Coastguard Worker virtual bool exists(GLuint name) = 0; isDeleteFlagged(GLuint name)179*35238bceSAndroid Build Coastguard Worker virtual bool isDeleteFlagged(GLuint name) 180*35238bceSAndroid Build Coastguard Worker { 181*35238bceSAndroid Build Coastguard Worker DE_UNREF(name); 182*35238bceSAndroid Build Coastguard Worker return false; 183*35238bceSAndroid Build Coastguard Worker } binder(void) const184*35238bceSAndroid Build Coastguard Worker virtual Binder *binder(void) const 185*35238bceSAndroid Build Coastguard Worker { 186*35238bceSAndroid Build Coastguard Worker return DE_NULL; 187*35238bceSAndroid Build Coastguard Worker } 188*35238bceSAndroid Build Coastguard Worker virtual const char *getName(void) const = 0; nameLingers(void) const189*35238bceSAndroid Build Coastguard Worker virtual bool nameLingers(void) const 190*35238bceSAndroid Build Coastguard Worker { 191*35238bceSAndroid Build Coastguard Worker return false; 192*35238bceSAndroid Build Coastguard Worker } genCreates(void) const193*35238bceSAndroid Build Coastguard Worker virtual bool genCreates(void) const 194*35238bceSAndroid Build Coastguard Worker { 195*35238bceSAndroid Build Coastguard Worker return false; 196*35238bceSAndroid Build Coastguard Worker } 197*35238bceSAndroid Build Coastguard Worker 198*35238bceSAndroid Build Coastguard Worker protected: Type(const Context & ctx)199*35238bceSAndroid Build Coastguard Worker Type(const Context &ctx) : ContextWrapper(ctx) 200*35238bceSAndroid Build Coastguard Worker { 201*35238bceSAndroid Build Coastguard Worker } 202*35238bceSAndroid Build Coastguard Worker }; 203*35238bceSAndroid Build Coastguard Worker 204*35238bceSAndroid Build Coastguard Worker class SimpleType : public Type 205*35238bceSAndroid Build Coastguard Worker { 206*35238bceSAndroid Build Coastguard Worker public: SimpleType(const Context & ctx,const char * name,GenFunc genFunc,DeleteFunc deleteFunc,ExistsFunc existsFunc,Binder * binder_=DE_NULL,bool genCreates_=false)207*35238bceSAndroid Build Coastguard Worker SimpleType(const Context &ctx, const char *name, GenFunc genFunc, DeleteFunc deleteFunc, ExistsFunc existsFunc, 208*35238bceSAndroid Build Coastguard Worker Binder *binder_ = DE_NULL, bool genCreates_ = false) 209*35238bceSAndroid Build Coastguard Worker : Type(ctx) 210*35238bceSAndroid Build Coastguard Worker , m_getName(name) 211*35238bceSAndroid Build Coastguard Worker , m_genFunc(genFunc) 212*35238bceSAndroid Build Coastguard Worker , m_deleteFunc(deleteFunc) 213*35238bceSAndroid Build Coastguard Worker , m_existsFunc(existsFunc) 214*35238bceSAndroid Build Coastguard Worker , m_binder(binder_) 215*35238bceSAndroid Build Coastguard Worker , m_genCreates(genCreates_) 216*35238bceSAndroid Build Coastguard Worker { 217*35238bceSAndroid Build Coastguard Worker } 218*35238bceSAndroid Build Coastguard Worker 219*35238bceSAndroid Build Coastguard Worker GLuint gen(void); release(GLuint name)220*35238bceSAndroid Build Coastguard Worker void release(GLuint name) 221*35238bceSAndroid Build Coastguard Worker { 222*35238bceSAndroid Build Coastguard Worker (this->*m_deleteFunc)(1, &name); 223*35238bceSAndroid Build Coastguard Worker } exists(GLuint name)224*35238bceSAndroid Build Coastguard Worker bool exists(GLuint name) 225*35238bceSAndroid Build Coastguard Worker { 226*35238bceSAndroid Build Coastguard Worker return (this->*m_existsFunc)(name) != GL_FALSE; 227*35238bceSAndroid Build Coastguard Worker } binder(void) const228*35238bceSAndroid Build Coastguard Worker Binder *binder(void) const 229*35238bceSAndroid Build Coastguard Worker { 230*35238bceSAndroid Build Coastguard Worker return m_binder; 231*35238bceSAndroid Build Coastguard Worker } getName(void) const232*35238bceSAndroid Build Coastguard Worker const char *getName(void) const 233*35238bceSAndroid Build Coastguard Worker { 234*35238bceSAndroid Build Coastguard Worker return m_getName; 235*35238bceSAndroid Build Coastguard Worker } nameLingers(void) const236*35238bceSAndroid Build Coastguard Worker bool nameLingers(void) const 237*35238bceSAndroid Build Coastguard Worker { 238*35238bceSAndroid Build Coastguard Worker return false; 239*35238bceSAndroid Build Coastguard Worker } genCreates(void) const240*35238bceSAndroid Build Coastguard Worker bool genCreates(void) const 241*35238bceSAndroid Build Coastguard Worker { 242*35238bceSAndroid Build Coastguard Worker return m_genCreates; 243*35238bceSAndroid Build Coastguard Worker } 244*35238bceSAndroid Build Coastguard Worker 245*35238bceSAndroid Build Coastguard Worker private: 246*35238bceSAndroid Build Coastguard Worker const char *const m_getName; 247*35238bceSAndroid Build Coastguard Worker const GenFunc m_genFunc; 248*35238bceSAndroid Build Coastguard Worker const DeleteFunc m_deleteFunc; 249*35238bceSAndroid Build Coastguard Worker const ExistsFunc m_existsFunc; 250*35238bceSAndroid Build Coastguard Worker Binder *const m_binder; 251*35238bceSAndroid Build Coastguard Worker const bool m_genCreates; 252*35238bceSAndroid Build Coastguard Worker }; 253*35238bceSAndroid Build Coastguard Worker 254*35238bceSAndroid Build Coastguard Worker class ProgramType : public Type 255*35238bceSAndroid Build Coastguard Worker { 256*35238bceSAndroid Build Coastguard Worker public: ProgramType(const Context & ctx)257*35238bceSAndroid Build Coastguard Worker ProgramType(const Context &ctx) : Type(ctx) 258*35238bceSAndroid Build Coastguard Worker { 259*35238bceSAndroid Build Coastguard Worker } nameLingers(void) const260*35238bceSAndroid Build Coastguard Worker bool nameLingers(void) const 261*35238bceSAndroid Build Coastguard Worker { 262*35238bceSAndroid Build Coastguard Worker return true; 263*35238bceSAndroid Build Coastguard Worker } genCreates(void) const264*35238bceSAndroid Build Coastguard Worker bool genCreates(void) const 265*35238bceSAndroid Build Coastguard Worker { 266*35238bceSAndroid Build Coastguard Worker return true; 267*35238bceSAndroid Build Coastguard Worker } getName(void) const268*35238bceSAndroid Build Coastguard Worker const char *getName(void) const 269*35238bceSAndroid Build Coastguard Worker { 270*35238bceSAndroid Build Coastguard Worker return "program"; 271*35238bceSAndroid Build Coastguard Worker } gen(void)272*35238bceSAndroid Build Coastguard Worker GLuint gen(void) 273*35238bceSAndroid Build Coastguard Worker { 274*35238bceSAndroid Build Coastguard Worker return glCreateProgram(); 275*35238bceSAndroid Build Coastguard Worker } release(GLuint name)276*35238bceSAndroid Build Coastguard Worker void release(GLuint name) 277*35238bceSAndroid Build Coastguard Worker { 278*35238bceSAndroid Build Coastguard Worker glDeleteProgram(name); 279*35238bceSAndroid Build Coastguard Worker } exists(GLuint name)280*35238bceSAndroid Build Coastguard Worker bool exists(GLuint name) 281*35238bceSAndroid Build Coastguard Worker { 282*35238bceSAndroid Build Coastguard Worker return glIsProgram(name) != GL_FALSE; 283*35238bceSAndroid Build Coastguard Worker } 284*35238bceSAndroid Build Coastguard Worker bool isDeleteFlagged(GLuint name); 285*35238bceSAndroid Build Coastguard Worker }; 286*35238bceSAndroid Build Coastguard Worker 287*35238bceSAndroid Build Coastguard Worker class ShaderType : public Type 288*35238bceSAndroid Build Coastguard Worker { 289*35238bceSAndroid Build Coastguard Worker public: ShaderType(const Context & ctx)290*35238bceSAndroid Build Coastguard Worker ShaderType(const Context &ctx) : Type(ctx) 291*35238bceSAndroid Build Coastguard Worker { 292*35238bceSAndroid Build Coastguard Worker } nameLingers(void) const293*35238bceSAndroid Build Coastguard Worker bool nameLingers(void) const 294*35238bceSAndroid Build Coastguard Worker { 295*35238bceSAndroid Build Coastguard Worker return true; 296*35238bceSAndroid Build Coastguard Worker } genCreates(void) const297*35238bceSAndroid Build Coastguard Worker bool genCreates(void) const 298*35238bceSAndroid Build Coastguard Worker { 299*35238bceSAndroid Build Coastguard Worker return true; 300*35238bceSAndroid Build Coastguard Worker } getName(void) const301*35238bceSAndroid Build Coastguard Worker const char *getName(void) const 302*35238bceSAndroid Build Coastguard Worker { 303*35238bceSAndroid Build Coastguard Worker return "shader"; 304*35238bceSAndroid Build Coastguard Worker } gen(void)305*35238bceSAndroid Build Coastguard Worker GLuint gen(void) 306*35238bceSAndroid Build Coastguard Worker { 307*35238bceSAndroid Build Coastguard Worker return glCreateShader(GL_FRAGMENT_SHADER); 308*35238bceSAndroid Build Coastguard Worker } release(GLuint name)309*35238bceSAndroid Build Coastguard Worker void release(GLuint name) 310*35238bceSAndroid Build Coastguard Worker { 311*35238bceSAndroid Build Coastguard Worker glDeleteShader(name); 312*35238bceSAndroid Build Coastguard Worker } exists(GLuint name)313*35238bceSAndroid Build Coastguard Worker bool exists(GLuint name) 314*35238bceSAndroid Build Coastguard Worker { 315*35238bceSAndroid Build Coastguard Worker return glIsShader(name) != GL_FALSE; 316*35238bceSAndroid Build Coastguard Worker } 317*35238bceSAndroid Build Coastguard Worker bool isDeleteFlagged(GLuint name); 318*35238bceSAndroid Build Coastguard Worker }; 319*35238bceSAndroid Build Coastguard Worker 320*35238bceSAndroid Build Coastguard Worker class Attacher : public ContextWrapper 321*35238bceSAndroid Build Coastguard Worker { 322*35238bceSAndroid Build Coastguard Worker public: 323*35238bceSAndroid Build Coastguard Worker virtual void initAttachment(GLuint seed, GLuint attachment) = 0; 324*35238bceSAndroid Build Coastguard Worker virtual void attach(GLuint element, GLuint container) = 0; 325*35238bceSAndroid Build Coastguard Worker virtual void detach(GLuint element, GLuint container) = 0; 326*35238bceSAndroid Build Coastguard Worker virtual GLuint getAttachment(GLuint container) = 0; canAttachDeleted(void) const327*35238bceSAndroid Build Coastguard Worker virtual bool canAttachDeleted(void) const 328*35238bceSAndroid Build Coastguard Worker { 329*35238bceSAndroid Build Coastguard Worker return true; 330*35238bceSAndroid Build Coastguard Worker } 331*35238bceSAndroid Build Coastguard Worker getElementType(void) const332*35238bceSAndroid Build Coastguard Worker Type &getElementType(void) const 333*35238bceSAndroid Build Coastguard Worker { 334*35238bceSAndroid Build Coastguard Worker return m_elementType; 335*35238bceSAndroid Build Coastguard Worker } getContainerType(void) const336*35238bceSAndroid Build Coastguard Worker Type &getContainerType(void) const 337*35238bceSAndroid Build Coastguard Worker { 338*35238bceSAndroid Build Coastguard Worker return m_containerType; 339*35238bceSAndroid Build Coastguard Worker } ~Attacher(void)340*35238bceSAndroid Build Coastguard Worker virtual ~Attacher(void) 341*35238bceSAndroid Build Coastguard Worker { 342*35238bceSAndroid Build Coastguard Worker } 343*35238bceSAndroid Build Coastguard Worker 344*35238bceSAndroid Build Coastguard Worker protected: Attacher(const Context & ctx,Type & elementType,Type & containerType)345*35238bceSAndroid Build Coastguard Worker Attacher(const Context &ctx, Type &elementType, Type &containerType) 346*35238bceSAndroid Build Coastguard Worker : ContextWrapper(ctx) 347*35238bceSAndroid Build Coastguard Worker , m_elementType(elementType) 348*35238bceSAndroid Build Coastguard Worker , m_containerType(containerType) 349*35238bceSAndroid Build Coastguard Worker { 350*35238bceSAndroid Build Coastguard Worker } 351*35238bceSAndroid Build Coastguard Worker 352*35238bceSAndroid Build Coastguard Worker private: 353*35238bceSAndroid Build Coastguard Worker Type &m_elementType; 354*35238bceSAndroid Build Coastguard Worker Type &m_containerType; 355*35238bceSAndroid Build Coastguard Worker }; 356*35238bceSAndroid Build Coastguard Worker 357*35238bceSAndroid Build Coastguard Worker class InputAttacher : public ContextWrapper 358*35238bceSAndroid Build Coastguard Worker { 359*35238bceSAndroid Build Coastguard Worker public: getAttacher(void) const360*35238bceSAndroid Build Coastguard Worker Attacher &getAttacher(void) const 361*35238bceSAndroid Build Coastguard Worker { 362*35238bceSAndroid Build Coastguard Worker return m_attacher; 363*35238bceSAndroid Build Coastguard Worker } 364*35238bceSAndroid Build Coastguard Worker virtual void drawContainer(GLuint container, Surface &dst) = 0; 365*35238bceSAndroid Build Coastguard Worker 366*35238bceSAndroid Build Coastguard Worker protected: InputAttacher(Attacher & attacher)367*35238bceSAndroid Build Coastguard Worker InputAttacher(Attacher &attacher) : ContextWrapper(attacher.getContext()), m_attacher(attacher) 368*35238bceSAndroid Build Coastguard Worker { 369*35238bceSAndroid Build Coastguard Worker } 370*35238bceSAndroid Build Coastguard Worker Attacher &m_attacher; 371*35238bceSAndroid Build Coastguard Worker }; 372*35238bceSAndroid Build Coastguard Worker 373*35238bceSAndroid Build Coastguard Worker class OutputAttacher : public ContextWrapper 374*35238bceSAndroid Build Coastguard Worker { 375*35238bceSAndroid Build Coastguard Worker public: getAttacher(void) const376*35238bceSAndroid Build Coastguard Worker Attacher &getAttacher(void) const 377*35238bceSAndroid Build Coastguard Worker { 378*35238bceSAndroid Build Coastguard Worker return m_attacher; 379*35238bceSAndroid Build Coastguard Worker } 380*35238bceSAndroid Build Coastguard Worker virtual void setupContainer(GLuint seed, GLuint container) = 0; 381*35238bceSAndroid Build Coastguard Worker virtual void drawAttachment(GLuint attachment, Surface &dst) = 0; 382*35238bceSAndroid Build Coastguard Worker 383*35238bceSAndroid Build Coastguard Worker protected: OutputAttacher(Attacher & attacher)384*35238bceSAndroid Build Coastguard Worker OutputAttacher(Attacher &attacher) : ContextWrapper(attacher.getContext()), m_attacher(attacher) 385*35238bceSAndroid Build Coastguard Worker { 386*35238bceSAndroid Build Coastguard Worker } 387*35238bceSAndroid Build Coastguard Worker Attacher &m_attacher; 388*35238bceSAndroid Build Coastguard Worker }; 389*35238bceSAndroid Build Coastguard Worker 390*35238bceSAndroid Build Coastguard Worker class Types : public ContextWrapper 391*35238bceSAndroid Build Coastguard Worker { 392*35238bceSAndroid Build Coastguard Worker public: Types(const Context & ctx)393*35238bceSAndroid Build Coastguard Worker Types(const Context &ctx) : ContextWrapper(ctx) 394*35238bceSAndroid Build Coastguard Worker { 395*35238bceSAndroid Build Coastguard Worker } 396*35238bceSAndroid Build Coastguard Worker virtual Type &getProgramType(void) = 0; getTypes(void)397*35238bceSAndroid Build Coastguard Worker const vector<Type *> &getTypes(void) 398*35238bceSAndroid Build Coastguard Worker { 399*35238bceSAndroid Build Coastguard Worker return m_types; 400*35238bceSAndroid Build Coastguard Worker } getAttachers(void)401*35238bceSAndroid Build Coastguard Worker const vector<Attacher *> &getAttachers(void) 402*35238bceSAndroid Build Coastguard Worker { 403*35238bceSAndroid Build Coastguard Worker return m_attachers; 404*35238bceSAndroid Build Coastguard Worker } getInputAttachers(void)405*35238bceSAndroid Build Coastguard Worker const vector<InputAttacher *> &getInputAttachers(void) 406*35238bceSAndroid Build Coastguard Worker { 407*35238bceSAndroid Build Coastguard Worker return m_inAttachers; 408*35238bceSAndroid Build Coastguard Worker } getOutputAttachers(void)409*35238bceSAndroid Build Coastguard Worker const vector<OutputAttacher *> &getOutputAttachers(void) 410*35238bceSAndroid Build Coastguard Worker { 411*35238bceSAndroid Build Coastguard Worker return m_outAttachers; 412*35238bceSAndroid Build Coastguard Worker } ~Types(void)413*35238bceSAndroid Build Coastguard Worker virtual ~Types(void) 414*35238bceSAndroid Build Coastguard Worker { 415*35238bceSAndroid Build Coastguard Worker } 416*35238bceSAndroid Build Coastguard Worker 417*35238bceSAndroid Build Coastguard Worker protected: 418*35238bceSAndroid Build Coastguard Worker vector<Type *> m_types; 419*35238bceSAndroid Build Coastguard Worker vector<Attacher *> m_attachers; 420*35238bceSAndroid Build Coastguard Worker vector<InputAttacher *> m_inAttachers; 421*35238bceSAndroid Build Coastguard Worker vector<OutputAttacher *> m_outAttachers; 422*35238bceSAndroid Build Coastguard Worker }; 423*35238bceSAndroid Build Coastguard Worker 424*35238bceSAndroid Build Coastguard Worker class FboAttacher : public Attacher 425*35238bceSAndroid Build Coastguard Worker { 426*35238bceSAndroid Build Coastguard Worker public: 427*35238bceSAndroid Build Coastguard Worker void initAttachment(GLuint seed, GLuint element); 428*35238bceSAndroid Build Coastguard Worker 429*35238bceSAndroid Build Coastguard Worker protected: FboAttacher(const Context & ctx,Type & elementType,Type & containerType)430*35238bceSAndroid Build Coastguard Worker FboAttacher(const Context &ctx, Type &elementType, Type &containerType) : Attacher(ctx, elementType, containerType) 431*35238bceSAndroid Build Coastguard Worker { 432*35238bceSAndroid Build Coastguard Worker } 433*35238bceSAndroid Build Coastguard Worker virtual void initStorage(void) = 0; 434*35238bceSAndroid Build Coastguard Worker }; 435*35238bceSAndroid Build Coastguard Worker 436*35238bceSAndroid Build Coastguard Worker class FboInputAttacher : public InputAttacher 437*35238bceSAndroid Build Coastguard Worker { 438*35238bceSAndroid Build Coastguard Worker public: FboInputAttacher(FboAttacher & attacher)439*35238bceSAndroid Build Coastguard Worker FboInputAttacher(FboAttacher &attacher) : InputAttacher(attacher) 440*35238bceSAndroid Build Coastguard Worker { 441*35238bceSAndroid Build Coastguard Worker } 442*35238bceSAndroid Build Coastguard Worker void drawContainer(GLuint container, Surface &dst); 443*35238bceSAndroid Build Coastguard Worker }; 444*35238bceSAndroid Build Coastguard Worker 445*35238bceSAndroid Build Coastguard Worker class FboOutputAttacher : public OutputAttacher 446*35238bceSAndroid Build Coastguard Worker { 447*35238bceSAndroid Build Coastguard Worker public: FboOutputAttacher(FboAttacher & attacher)448*35238bceSAndroid Build Coastguard Worker FboOutputAttacher(FboAttacher &attacher) : OutputAttacher(attacher) 449*35238bceSAndroid Build Coastguard Worker { 450*35238bceSAndroid Build Coastguard Worker } 451*35238bceSAndroid Build Coastguard Worker void setupContainer(GLuint seed, GLuint container); 452*35238bceSAndroid Build Coastguard Worker void drawAttachment(GLuint attachment, Surface &dst); 453*35238bceSAndroid Build Coastguard Worker }; 454*35238bceSAndroid Build Coastguard Worker 455*35238bceSAndroid Build Coastguard Worker class TextureFboAttacher : public FboAttacher 456*35238bceSAndroid Build Coastguard Worker { 457*35238bceSAndroid Build Coastguard Worker public: TextureFboAttacher(const Context & ctx,Type & elementType,Type & containerType)458*35238bceSAndroid Build Coastguard Worker TextureFboAttacher(const Context &ctx, Type &elementType, Type &containerType) 459*35238bceSAndroid Build Coastguard Worker : FboAttacher(ctx, elementType, containerType) 460*35238bceSAndroid Build Coastguard Worker { 461*35238bceSAndroid Build Coastguard Worker } 462*35238bceSAndroid Build Coastguard Worker 463*35238bceSAndroid Build Coastguard Worker void initStorage(void); 464*35238bceSAndroid Build Coastguard Worker void attach(GLuint element, GLuint container); 465*35238bceSAndroid Build Coastguard Worker void detach(GLuint element, GLuint container); 466*35238bceSAndroid Build Coastguard Worker GLuint getAttachment(GLuint container); 467*35238bceSAndroid Build Coastguard Worker }; 468*35238bceSAndroid Build Coastguard Worker 469*35238bceSAndroid Build Coastguard Worker class RboFboAttacher : public FboAttacher 470*35238bceSAndroid Build Coastguard Worker { 471*35238bceSAndroid Build Coastguard Worker public: RboFboAttacher(const Context & ctx,Type & elementType,Type & containerType)472*35238bceSAndroid Build Coastguard Worker RboFboAttacher(const Context &ctx, Type &elementType, Type &containerType) 473*35238bceSAndroid Build Coastguard Worker : FboAttacher(ctx, elementType, containerType) 474*35238bceSAndroid Build Coastguard Worker { 475*35238bceSAndroid Build Coastguard Worker } 476*35238bceSAndroid Build Coastguard Worker 477*35238bceSAndroid Build Coastguard Worker void initStorage(void); 478*35238bceSAndroid Build Coastguard Worker void attach(GLuint element, GLuint container); 479*35238bceSAndroid Build Coastguard Worker void detach(GLuint element, GLuint container); 480*35238bceSAndroid Build Coastguard Worker GLuint getAttachment(GLuint container); 481*35238bceSAndroid Build Coastguard Worker }; 482*35238bceSAndroid Build Coastguard Worker 483*35238bceSAndroid Build Coastguard Worker class ShaderProgramAttacher : public Attacher 484*35238bceSAndroid Build Coastguard Worker { 485*35238bceSAndroid Build Coastguard Worker public: ShaderProgramAttacher(const Context & ctx,Type & elementType,Type & containerType)486*35238bceSAndroid Build Coastguard Worker ShaderProgramAttacher(const Context &ctx, Type &elementType, Type &containerType) 487*35238bceSAndroid Build Coastguard Worker : Attacher(ctx, elementType, containerType) 488*35238bceSAndroid Build Coastguard Worker { 489*35238bceSAndroid Build Coastguard Worker } 490*35238bceSAndroid Build Coastguard Worker 491*35238bceSAndroid Build Coastguard Worker void initAttachment(GLuint seed, GLuint element); 492*35238bceSAndroid Build Coastguard Worker void attach(GLuint element, GLuint container); 493*35238bceSAndroid Build Coastguard Worker void detach(GLuint element, GLuint container); 494*35238bceSAndroid Build Coastguard Worker GLuint getAttachment(GLuint container); 495*35238bceSAndroid Build Coastguard Worker }; 496*35238bceSAndroid Build Coastguard Worker 497*35238bceSAndroid Build Coastguard Worker class ShaderProgramInputAttacher : public InputAttacher 498*35238bceSAndroid Build Coastguard Worker { 499*35238bceSAndroid Build Coastguard Worker public: ShaderProgramInputAttacher(Attacher & attacher)500*35238bceSAndroid Build Coastguard Worker ShaderProgramInputAttacher(Attacher &attacher) : InputAttacher(attacher) 501*35238bceSAndroid Build Coastguard Worker { 502*35238bceSAndroid Build Coastguard Worker } 503*35238bceSAndroid Build Coastguard Worker 504*35238bceSAndroid Build Coastguard Worker void drawContainer(GLuint container, Surface &dst); 505*35238bceSAndroid Build Coastguard Worker }; 506*35238bceSAndroid Build Coastguard Worker 507*35238bceSAndroid Build Coastguard Worker class ES2Types : public Types 508*35238bceSAndroid Build Coastguard Worker { 509*35238bceSAndroid Build Coastguard Worker public: 510*35238bceSAndroid Build Coastguard Worker ES2Types(const Context &ctx); getProgramType(void)511*35238bceSAndroid Build Coastguard Worker Type &getProgramType(void) 512*35238bceSAndroid Build Coastguard Worker { 513*35238bceSAndroid Build Coastguard Worker return m_programType; 514*35238bceSAndroid Build Coastguard Worker } 515*35238bceSAndroid Build Coastguard Worker 516*35238bceSAndroid Build Coastguard Worker protected: 517*35238bceSAndroid Build Coastguard Worker SimpleBinder m_bufferBind; 518*35238bceSAndroid Build Coastguard Worker SimpleType m_bufferType; 519*35238bceSAndroid Build Coastguard Worker SimpleBinder m_textureBind; 520*35238bceSAndroid Build Coastguard Worker SimpleType m_textureType; 521*35238bceSAndroid Build Coastguard Worker SimpleBinder m_rboBind; 522*35238bceSAndroid Build Coastguard Worker SimpleType m_rboType; 523*35238bceSAndroid Build Coastguard Worker SimpleBinder m_fboBind; 524*35238bceSAndroid Build Coastguard Worker SimpleType m_fboType; 525*35238bceSAndroid Build Coastguard Worker ShaderType m_shaderType; 526*35238bceSAndroid Build Coastguard Worker ProgramType m_programType; 527*35238bceSAndroid Build Coastguard Worker TextureFboAttacher m_texFboAtt; 528*35238bceSAndroid Build Coastguard Worker FboInputAttacher m_texFboInAtt; 529*35238bceSAndroid Build Coastguard Worker FboOutputAttacher m_texFboOutAtt; 530*35238bceSAndroid Build Coastguard Worker RboFboAttacher m_rboFboAtt; 531*35238bceSAndroid Build Coastguard Worker FboInputAttacher m_rboFboInAtt; 532*35238bceSAndroid Build Coastguard Worker FboOutputAttacher m_rboFboOutAtt; 533*35238bceSAndroid Build Coastguard Worker ShaderProgramAttacher m_shaderAtt; 534*35238bceSAndroid Build Coastguard Worker ShaderProgramInputAttacher m_shaderInAtt; 535*35238bceSAndroid Build Coastguard Worker }; 536*35238bceSAndroid Build Coastguard Worker 537*35238bceSAndroid Build Coastguard Worker MovePtr<TestCaseGroup> createGroup(TestContext &testCtx, Type &type); 538*35238bceSAndroid Build Coastguard Worker void addTestCases(TestCaseGroup &group, Types &types); 539*35238bceSAndroid Build Coastguard Worker 540*35238bceSAndroid Build Coastguard Worker struct Rectangle 541*35238bceSAndroid Build Coastguard Worker { Rectangledeqp::gls::LifetimeTests::details::Rectangle542*35238bceSAndroid Build Coastguard Worker Rectangle(GLint x_, GLint y_, GLint width_, GLint height_) : x(x_), y(y_), width(width_), height(height_) 543*35238bceSAndroid Build Coastguard Worker { 544*35238bceSAndroid Build Coastguard Worker } 545*35238bceSAndroid Build Coastguard Worker GLint x; 546*35238bceSAndroid Build Coastguard Worker GLint y; 547*35238bceSAndroid Build Coastguard Worker GLint width; 548*35238bceSAndroid Build Coastguard Worker GLint height; 549*35238bceSAndroid Build Coastguard Worker }; 550*35238bceSAndroid Build Coastguard Worker 551*35238bceSAndroid Build Coastguard Worker Rectangle randomViewport(const RenderContext &ctx, GLint maxWidth, GLint maxHeight, Random &rnd); 552*35238bceSAndroid Build Coastguard Worker void setViewport(const RenderContext &renderCtx, const Rectangle &rect); 553*35238bceSAndroid Build Coastguard Worker void readRectangle(const RenderContext &renderCtx, const Rectangle &rect, Surface &dst); 554*35238bceSAndroid Build Coastguard Worker 555*35238bceSAndroid Build Coastguard Worker } // namespace details 556*35238bceSAndroid Build Coastguard Worker 557*35238bceSAndroid Build Coastguard Worker using details::BindFunc; 558*35238bceSAndroid Build Coastguard Worker using details::DeleteFunc; 559*35238bceSAndroid Build Coastguard Worker using details::ExistsFunc; 560*35238bceSAndroid Build Coastguard Worker using details::GenFunc; 561*35238bceSAndroid Build Coastguard Worker 562*35238bceSAndroid Build Coastguard Worker using details::Attacher; 563*35238bceSAndroid Build Coastguard Worker using details::Binder; 564*35238bceSAndroid Build Coastguard Worker using details::Context; 565*35238bceSAndroid Build Coastguard Worker using details::ES2Types; 566*35238bceSAndroid Build Coastguard Worker using details::InputAttacher; 567*35238bceSAndroid Build Coastguard Worker using details::OutputAttacher; 568*35238bceSAndroid Build Coastguard Worker using details::SimpleBinder; 569*35238bceSAndroid Build Coastguard Worker using details::SimpleType; 570*35238bceSAndroid Build Coastguard Worker using details::Type; 571*35238bceSAndroid Build Coastguard Worker using details::Types; 572*35238bceSAndroid Build Coastguard Worker 573*35238bceSAndroid Build Coastguard Worker using details::addTestCases; 574*35238bceSAndroid Build Coastguard Worker using details::createGroup; 575*35238bceSAndroid Build Coastguard Worker 576*35238bceSAndroid Build Coastguard Worker using details::randomViewport; 577*35238bceSAndroid Build Coastguard Worker using details::readRectangle; 578*35238bceSAndroid Build Coastguard Worker using details::Rectangle; 579*35238bceSAndroid Build Coastguard Worker using details::setViewport; 580*35238bceSAndroid Build Coastguard Worker 581*35238bceSAndroid Build Coastguard Worker } // namespace LifetimeTests 582*35238bceSAndroid Build Coastguard Worker } // namespace gls 583*35238bceSAndroid Build Coastguard Worker } // namespace deqp 584*35238bceSAndroid Build Coastguard Worker 585*35238bceSAndroid Build Coastguard Worker #endif // _GLSLIFETIMETESTS_HPP 586