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 39 namespace deqp 40 { 41 namespace gls 42 { 43 44 class VertexArray 45 { 46 public: 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 56 private: 57 const rsg::ShaderInput* m_input; 58 std::vector<float> m_vertices; 59 }; 60 61 class TextureManager 62 { 63 public: 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 73 private: 74 std::map<int, const glu::Texture2D*> m_tex2D; 75 std::map<int, const glu::TextureCube*> m_texCube; 76 }; 77 78 class RandomShaderCase : public tcu::TestCase 79 { 80 public: 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 88 private: 89 void checkShaderLimits (const rsg::Shader& shader) const; 90 void checkProgramLimits (const rsg::Shader& vtxShader, const rsg::Shader& frgShader) const; 91 92 protected: 93 glu::RenderContext& m_renderCtx; 94 95 // \todo [2011-12-21 pyry] Multiple textures! 96 const glu::Texture2D* getTex2D (void); 97 const glu::TextureCube* getTexCube (void); 98 99 rsg::ProgramParameters m_parameters; 100 int m_gridWidth; 101 int m_gridHeight; 102 103 rsg::Shader m_vertexShader; 104 rsg::Shader m_fragmentShader; 105 std::vector<rsg::VariableValue> m_uniforms; 106 107 std::vector<VertexArray> m_vertexArrays; 108 std::vector<deUint16> m_indices; 109 110 TextureManager m_texManager; 111 glu::Texture2D* m_tex2D; 112 glu::TextureCube* m_texCube; 113 }; 114 115 } // gls 116 } // deqp 117 118 #endif // _GLSRANDOMSHADERCASE_HPP 119