• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _GLSFRAGMENTOPUTIL_HPP
2 #define _GLSFRAGMENTOPUTIL_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 Fragment operation test utilities.
24  *//*--------------------------------------------------------------------*/
25 
26 #include "tcuDefs.hpp"
27 #include "gluShaderUtil.hpp"
28 #include "tcuVector.hpp"
29 #include "tcuTexture.hpp"
30 #include "rrFragmentOperations.hpp"
31 
32 namespace glu
33 {
34 class ShaderProgram;
35 class RenderContext;
36 }
37 
38 namespace deqp
39 {
40 namespace gls
41 {
42 namespace FragmentOpUtil
43 {
44 
45 struct Quad
46 {
47 	tcu::Vec2		posA;
48 	tcu::Vec2		posB;
49 
50 	// Normalized device coordinates (range [-1, 1]).
51 	// In order (A.x, A.y), (A.x, B.y), (B.x, A.y), (B.x, B.y)
52 	tcu::Vec4		color[4];
53 	tcu::Vec4		color1[4];
54 	float			depth[4];
55 
Quaddeqp::gls::FragmentOpUtil::Quad56 	Quad (void)
57 		: posA(-1.0f, -1.0f)
58 		, posB( 1.0f,  1.0f)
59 	{
60 		for (int i = 0; i < DE_LENGTH_OF_ARRAY(depth); i++)
61 			depth[i] = 0.0f;
62 	}
63 };
64 
65 class QuadRenderer
66 {
67 public:
68 								QuadRenderer				(const glu::RenderContext& context, glu::GLSLVersion glslVersion);
69 								~QuadRenderer				(void);
70 
71 	void						render						(const Quad& quad) const;
72 
73 private:
74 								QuadRenderer				(const QuadRenderer& other); // Not allowed!
75 	QuadRenderer&				operator=					(const QuadRenderer& other); // Not allowed!
76 
77 	const glu::RenderContext&	m_context;
78 	glu::ShaderProgram*			m_program;
79 	int							m_positionLoc;
80 	int							m_colorLoc;
81 	int							m_color1Loc;
82 	const bool					m_blendFuncExt;
83 };
84 
85 struct IntegerQuad
86 {
87 	tcu::IVec2	posA;
88 	tcu::IVec2	posB;
89 
90 	// Viewport coordinates (depth in range [0, 1]).
91 	// In order (A.x, A.y), (A.x, B.y), (B.x, A.y), (B.x, B.y)
92 	tcu::Vec4	color[4];
93 	tcu::Vec4	color1[4];
94 	float		depth[4];
95 
IntegerQuaddeqp::gls::FragmentOpUtil::IntegerQuad96 	IntegerQuad (int windowWidth, int windowHeight)
97 		: posA(0,				0)
98 		, posB(windowWidth-1,	windowHeight-1)
99 	{
100 		for (int i = 0; i < DE_LENGTH_OF_ARRAY(depth); i++)
101 			depth[i] = 0.0f;
102 	}
103 
IntegerQuaddeqp::gls::FragmentOpUtil::IntegerQuad104 	IntegerQuad (void)
105 		: posA(0, 0)
106 		, posB(1, 1)
107 	{
108 		for (int i = 0; i < DE_LENGTH_OF_ARRAY(depth); i++)
109 			depth[i] = 0.0f;
110 	}
111 };
112 
113 class ReferenceQuadRenderer
114 {
115 public:
116 								ReferenceQuadRenderer	(void);
117 
118 	void						render					(const tcu::PixelBufferAccess&			colorBuffer,
119 														 const tcu::PixelBufferAccess&			depthBuffer,
120 														 const tcu::PixelBufferAccess&			stencilBuffer,
121 														 const IntegerQuad&						quad,
122 														 const rr::FragmentOperationState&		state);
123 
124 private:
125 	enum
126 	{
127 		MAX_FRAGMENT_BUFFER_SIZE = 1024
128 	};
129 
130 	void						flushFragmentBuffer (const rr::MultisamplePixelBufferAccess&	colorBuffer,
131 													 const rr::MultisamplePixelBufferAccess&	depthBuffer,
132 													 const rr::MultisamplePixelBufferAccess&	stencilBuffer,
133 													 rr::FaceType								faceType,
134 													 const rr::FragmentOperationState&			state);
135 
136 	rr::Fragment				m_fragmentBuffer[MAX_FRAGMENT_BUFFER_SIZE];
137 	float						m_fragmentDepths[MAX_FRAGMENT_BUFFER_SIZE];
138 	int							m_fragmentBufferSize;
139 
140 	rr::FragmentProcessor		m_fragmentProcessor;
141 };
142 
143 
144 // These functions take a normally-indexed 2d pixel buffer and return a pixel buffer access
145 // that indexes the same memory area, but using the multisample indexing convention.
146 tcu::PixelBufferAccess					getMultisampleAccess(const tcu::PixelBufferAccess&			original);
147 tcu::ConstPixelBufferAccess				getMultisampleAccess(const tcu::ConstPixelBufferAccess&	original);
148 
149 } // FragmentOpUtil
150 } // gls
151 } // deqp
152 
153 #endif // _GLSFRAGMENTOPUTIL_HPP
154