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); ~VertexArray(void)48 ~VertexArray(void) 49 { 50 } 51 getVertices(void) const52 const std::vector<float> &getVertices(void) const 53 { 54 return m_vertices; 55 } getVertices(void)56 std::vector<float> &getVertices(void) 57 { 58 return m_vertices; 59 } getName(void) const60 const char *getName(void) const 61 { 62 return m_input->getVariable()->getName(); 63 } getNumComponents(void) const64 int getNumComponents(void) const 65 { 66 return m_input->getVariable()->getType().getNumElements(); 67 } getValueRange(void) const68 rsg::ConstValueRangeAccess getValueRange(void) const 69 { 70 return m_input->getValueRange(); 71 } 72 73 private: 74 const rsg::ShaderInput *m_input; 75 std::vector<float> m_vertices; 76 }; 77 78 class TextureManager 79 { 80 public: 81 TextureManager(void); 82 ~TextureManager(void); 83 84 void bindTexture(int unit, const glu::Texture2D *tex2D); 85 void bindTexture(int unit, const glu::TextureCube *texCube); 86 87 std::vector<std::pair<int, const glu::Texture2D *>> getBindings2D(void) const; 88 std::vector<std::pair<int, const glu::TextureCube *>> getBindingsCube(void) const; 89 90 private: 91 std::map<int, const glu::Texture2D *> m_tex2D; 92 std::map<int, const glu::TextureCube *> m_texCube; 93 }; 94 95 class RandomShaderCase : public tcu::TestCase 96 { 97 public: 98 RandomShaderCase(tcu::TestContext &testCtx, glu::RenderContext &renderCtx, const char *name, 99 const char *description, const rsg::ProgramParameters ¶ms); 100 virtual ~RandomShaderCase(void); 101 102 virtual void init(void); 103 virtual void deinit(void); 104 virtual IterateResult iterate(void); 105 106 private: 107 void checkShaderLimits(const rsg::Shader &shader) const; 108 void checkProgramLimits(const rsg::Shader &vtxShader, const rsg::Shader &frgShader) const; 109 110 protected: 111 glu::RenderContext &m_renderCtx; 112 113 // \todo [2011-12-21 pyry] Multiple textures! 114 const glu::Texture2D *getTex2D(void); 115 const glu::TextureCube *getTexCube(void); 116 117 rsg::ProgramParameters m_parameters; 118 int m_gridWidth; 119 int m_gridHeight; 120 121 rsg::Shader m_vertexShader; 122 rsg::Shader m_fragmentShader; 123 std::vector<rsg::VariableValue> m_uniforms; 124 125 std::vector<VertexArray> m_vertexArrays; 126 std::vector<uint16_t> m_indices; 127 128 TextureManager m_texManager; 129 glu::Texture2D *m_tex2D; 130 glu::TextureCube *m_texCube; 131 }; 132 133 } // namespace gls 134 } // namespace deqp 135 136 #endif // _GLSRANDOMSHADERCASE_HPP 137