1#ifndef _GLSRANDOMSHADERCASE_HPP 2#define _GLSRANDOMSHADERCASE_HPP 3/*------------------------------------------------------------------------- 4 * drawElements Quality Program OpenGL (ES) Module 5 * ----------------------------------------------- 6 * 7 * Copyright 2014 The Android Open Source Project 8 * 9 * Licensed under the Apache License, Version 2.0 (the "License"); 10 * you may not use this file except in compliance with the License. 11 * You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, software 16 * distributed under the License is distributed on an "AS IS" BASIS, 17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 * See the License for the specific language governing permissions and 19 * limitations under the License. 20 * 21 *//*! 22 * \file 23 * \brief Random shader test case. 24 *//*--------------------------------------------------------------------*/ 25 26#include "tcuDefs.hpp" 27#include "tcuTestCase.hpp" 28#include "gluRenderContext.hpp" 29#include "rsgParameters.hpp" 30#include "tcuSurface.hpp" 31#include "rsgShader.hpp" 32#include "rsgVariableValue.hpp" 33#include "gluTexture.hpp" 34 35#include <string> 36#include <vector> 37#include <map> 38 39namespace deqp 40{ 41namespace gls 42{ 43 44class VertexArray 45{ 46public: 47 VertexArray (const rsg::ShaderInput* input, int numVertices); 48 ~VertexArray (void) {} 49 50 const std::vector<float>& getVertices (void) const { return m_vertices; } 51 std::vector<float>& getVertices (void) { return m_vertices; } 52 const char* getName (void) const { return m_input->getVariable()->getName(); } 53 int getNumComponents (void) const { return m_input->getVariable()->getType().getNumElements(); } 54 rsg::ConstValueRangeAccess getValueRange (void) const { return m_input->getValueRange(); } 55 56private: 57 const rsg::ShaderInput* m_input; 58 std::vector<float> m_vertices; 59}; 60 61class TextureManager 62{ 63public: 64 TextureManager (void); 65 ~TextureManager (void); 66 67 void bindTexture (int unit, const glu::Texture2D* tex2D); 68 void bindTexture (int unit, const glu::TextureCube* texCube); 69 70 std::vector<std::pair<int, const glu::Texture2D*> > getBindings2D (void) const; 71 std::vector<std::pair<int, const glu::TextureCube*> > getBindingsCube (void) const; 72 73private: 74 std::map<int, const glu::Texture2D*> m_tex2D; 75 std::map<int, const glu::TextureCube*> m_texCube; 76}; 77 78class RandomShaderCase : public tcu::TestCase 79{ 80public: 81 RandomShaderCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, const rsg::ProgramParameters& params); 82 virtual ~RandomShaderCase (void); 83 84 virtual void init (void); 85 virtual void deinit (void); 86 virtual IterateResult iterate (void); 87 88protected: 89 glu::RenderContext& m_renderCtx; 90 91 // \todo [2011-12-21 pyry] Multiple textures! 92 const glu::Texture2D* getTex2D (void); 93 const glu::TextureCube* getTexCube (void); 94 95 rsg::ProgramParameters m_parameters; 96 int m_gridWidth; 97 int m_gridHeight; 98 99 rsg::Shader m_vertexShader; 100 rsg::Shader m_fragmentShader; 101 std::vector<rsg::VariableValue> m_uniforms; 102 103 std::vector<VertexArray> m_vertexArrays; 104 std::vector<deUint16> m_indices; 105 106 TextureManager m_texManager; 107 glu::Texture2D* m_tex2D; 108 glu::TextureCube* m_texCube; 109}; 110 111} // gls 112} // deqp 113 114#endif // _GLSRANDOMSHADERCASE_HPP 115