1 #ifndef _ES31FFBOTESTUTIL_HPP
2 #define _ES31FFBOTESTUTIL_HPP
3 /*-------------------------------------------------------------------------
4 * drawElements Quality Program OpenGL ES 3.1 Module
5 * -------------------------------------------------
7 * Copyright 2014 The Android Open Source Project
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 * \brief FBO test utilities.
24 *//*--------------------------------------------------------------------*/
26 #include "tcuDefs.hpp"
27 #include "sglrContext.hpp"
28 #include "gluShaderUtil.hpp"
29 #include "tcuTexture.hpp"
30 #include "tcuMatrix.hpp"
31 #include "tcuRenderTarget.hpp"
44 // \todo [2012-04-29 pyry] Clean up and name as SglrUtil
46 // Helper class for constructing DataType vectors.
49 std::vector<glu::DataType> vec;
50 DataTypes& operator<< (glu::DataType type) { vec.push_back(type); return *this; }
55 class Texture2DShader : public sglr::ShaderProgram
58 Texture2DShader (const DataTypes& samplerTypes, glu::DataType outputType, const tcu::Vec4& outScale = tcu::Vec4(1.0f), const tcu::Vec4& outBias = tcu::Vec4(0.0f));
59 ~Texture2DShader (void) {}
61 void setUnit (int samplerNdx, int unitNdx);
62 void setTexScaleBias (int samplerNdx, const tcu::Vec4& scale, const tcu::Vec4& bias);
63 void setOutScaleBias (const tcu::Vec4& scale, const tcu::Vec4& bias);
65 void setUniforms (sglr::Context& context, deUint32 program) const;
67 void shadeVertices (const rr::VertexAttrib* inputs, rr::VertexPacket* const* packets, const int numPackets) const;
68 void shadeFragments (rr::FragmentPacket* packets, const int numPackets, const rr::FragmentShadingContext& context) const;
78 std::vector<Input> m_inputs;
82 const glu::DataType m_outputType;
85 class TextureCubeArrayShader : public sglr::ShaderProgram
88 TextureCubeArrayShader (glu::DataType samplerType, glu::DataType outputType, glu::GLSLVersion glslVersion);
89 ~TextureCubeArrayShader (void) {}
91 void setLayer (int layer);
92 void setFace (tcu::CubeFace face);
93 void setTexScaleBias (const tcu::Vec4& scale, const tcu::Vec4& bias);
95 void setUniforms (sglr::Context& context, deUint32 program) const;
97 void shadeVertices (const rr::VertexAttrib* inputs, rr::VertexPacket* const* packets, const int numPackets) const;
98 void shadeFragments (rr::FragmentPacket* packets, const int numPackets, const rr::FragmentShadingContext& context) const;
101 tcu::Vec4 m_texScale;
104 tcu::Mat3 m_coordMat;
106 const glu::DataType m_outputType;
109 // Framebuffer incomplete exception.
110 class FboIncompleteException : public tcu::TestError
113 FboIncompleteException (deUint32 reason, const char* file, int line);
114 virtual ~FboIncompleteException (void) throw() {}
116 deUint32 getReason (void) const { return m_reason; }
124 glu::DataType getFragmentOutputType (const tcu::TextureFormat& format);
125 tcu::TextureFormat getFramebufferReadFormat (const tcu::TextureFormat& format);
127 const char* getFormatName (deUint32 format);
129 void clearColorBuffer (sglr::Context& ctx, const tcu::TextureFormat& format, const tcu::Vec4& value);
130 void readPixels (sglr::Context& ctx, tcu::Surface& dst, int x, int y, int width, int height, const tcu::TextureFormat& format, const tcu::Vec4& scale, const tcu::Vec4& bias);
132 tcu::RGBA getFormatThreshold (const tcu::TextureFormat& format);
133 tcu::RGBA getFormatThreshold (const deUint32 glFormat);
140 #endif // _ES31FFBOTESTUTIL_HPP