1 #ifndef _RRRENDERSTATE_HPP
2 #define _RRRENDERSTATE_HPP
3 /*-------------------------------------------------------------------------
4 * drawElements Quality Program Reference Renderer
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 Reference renderer render state.
24 *//*--------------------------------------------------------------------*/
27 #include "rrMultisamplePixelBufferAccess.hpp"
28 #include "tcuTexture.hpp"
33 //! Horizontal fill rule
40 //! Vertical fill rule
50 WINDING_CCW = 0, //!< Counter-clockwise winding
51 WINDING_CW, //!< Clockwise winding
56 //! Triangle cull mode
66 struct RasterizationState
68 RasterizationState (void)
69 : winding (WINDING_CCW)
70 , horizontalFill (FILL_LEFT)
71 , verticalFill (FILL_BOTTOM)
76 HorizontalFill horizontalFill;
77 VerticalFill verticalFill;
99 STENCILOP_INCR, //!< Increment with saturation.
100 STENCILOP_DECR, //!< Decrement with saturation.
110 BLENDMODE_NONE = 0, //!< No blending.
111 BLENDMODE_STANDARD, //!< Standard blending.
112 BLENDMODE_ADVANCED, //!< Advanced blending mode, as defined in GL_KHR_blend_equation_advanced.
119 BLENDEQUATION_ADD = 0,
120 BLENDEQUATION_SUBTRACT,
121 BLENDEQUATION_REVERSE_SUBTRACT,
128 enum BlendEquationAdvanced
130 BLENDEQUATION_ADVANCED_MULTIPLY = 0,
131 BLENDEQUATION_ADVANCED_SCREEN,
132 BLENDEQUATION_ADVANCED_OVERLAY,
133 BLENDEQUATION_ADVANCED_DARKEN,
134 BLENDEQUATION_ADVANCED_LIGHTEN,
135 BLENDEQUATION_ADVANCED_COLORDODGE,
136 BLENDEQUATION_ADVANCED_COLORBURN,
137 BLENDEQUATION_ADVANCED_HARDLIGHT,
138 BLENDEQUATION_ADVANCED_SOFTLIGHT,
139 BLENDEQUATION_ADVANCED_DIFFERENCE,
140 BLENDEQUATION_ADVANCED_EXCLUSION,
141 BLENDEQUATION_ADVANCED_HSL_HUE,
142 BLENDEQUATION_ADVANCED_HSL_SATURATION,
143 BLENDEQUATION_ADVANCED_HSL_COLOR,
144 BLENDEQUATION_ADVANCED_HSL_LUMINOSITY,
146 BLENDEQUATION_ADVANCED_LAST
154 BLENDFUNC_ONE_MINUS_SRC_COLOR,
156 BLENDFUNC_ONE_MINUS_DST_COLOR,
158 BLENDFUNC_ONE_MINUS_SRC_ALPHA,
160 BLENDFUNC_ONE_MINUS_DST_ALPHA,
161 BLENDFUNC_CONSTANT_COLOR,
162 BLENDFUNC_ONE_MINUS_CONSTANT_COLOR,
163 BLENDFUNC_CONSTANT_ALPHA,
164 BLENDFUNC_ONE_MINUS_CONSTANT_ALPHA,
165 BLENDFUNC_SRC_ALPHA_SATURATE,
166 BLENDFUNC_SRC1_COLOR,
167 BLENDFUNC_ONE_MINUS_SRC1_COLOR,
168 BLENDFUNC_SRC1_ALPHA,
169 BLENDFUNC_ONE_MINUS_SRC1_ALPHA,
185 : func (TESTFUNC_ALWAYS)
188 , sFail (STENCILOP_KEEP)
189 , dpFail (STENCILOP_KEEP)
190 , dpPass (STENCILOP_KEEP)
198 BlendEquation equation;
203 : equation (BLENDEQUATION_ADD)
204 , srcFunc (BLENDFUNC_ONE)
205 , dstFunc (BLENDFUNC_ZERO)
210 struct WindowRectangle
217 WindowRectangle (int left_, int bottom_, int width_, int height_)
226 struct FragmentOperationState
228 // Variables corresponding to GL state variables.
230 bool scissorTestEnabled;
231 WindowRectangle scissorRectangle;
233 bool stencilTestEnabled;
234 StencilState stencilStates[2]; //!< Indexed with FACETYPE_FRONT and FACETYPE_BACK.
236 bool depthTestEnabled;
242 // Standard blending state
243 BlendState blendRGBState;
244 BlendState blendAState;
245 tcu::Vec4 blendColor; //!< Components should be in range [0, 1].
247 BlendEquationAdvanced blendEquationAdvaced;
251 bool depthClampEnabled;
253 bool polygonOffsetEnabled;
254 float polygonOffsetFactor;
255 float polygonOffsetUnits;
257 tcu::BVec4 colorMask;
259 // Variables not corresponding to configurable GL state, but other GL variables.
263 FragmentOperationState (void)
264 : scissorTestEnabled (false)
265 , scissorRectangle (0, 0, 1, 1)
267 , stencilTestEnabled (false)
268 // \note stencilStates[] members get default-constructed.
270 , depthTestEnabled (false)
271 , depthFunc (TESTFUNC_LESS)
274 , blendMode (BLENDMODE_NONE)
278 , blendEquationAdvaced (BLENDEQUATION_ADVANCED_LAST)
282 , depthClampEnabled (false)
284 , polygonOffsetEnabled (false)
285 , polygonOffsetFactor (0.0f)
286 , polygonOffsetUnits (0.0f)
318 WindowRectangle rect;
322 explicit ViewportState (const WindowRectangle& rect_)
329 explicit ViewportState (const rr::MultisampleConstPixelBufferAccess& multisampleBuffer)
330 : rect (0, 0, multisampleBuffer.raw().getHeight(), multisampleBuffer.raw().getDepth())
340 deUint32 restartIndex;
344 , restartIndex (0xFFFFFFFFul)
351 explicit RenderState (const ViewportState& viewport_)
352 : cullMode (CULLMODE_NONE)
353 , provokingVertexConvention (PROVOKINGVERTEX_LAST)
354 , viewport (viewport_)
359 ProvokingVertex provokingVertexConvention;
360 RasterizationState rasterization;
361 FragmentOperationState fragOps;
363 ViewportState viewport;
365 RestartState restart;
370 #endif // _RRRENDERSTATE_HPP