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 //! Viewport Orientation of renderer this will be compared against
67 enum ViewportOrientation
69 VIEWPORTORIENTATION_LOWER_LEFT = 0, //<! Corresponds to GL
70 VIEWPORTORIENTATION_UPPER_LEFT, //<! Corresponds to Vulkan
72 VIEWPORTORIENTATION_LAST
75 struct RasterizationState
77 RasterizationState (void)
78 : winding (WINDING_CCW)
79 , horizontalFill (FILL_LEFT)
80 , verticalFill (FILL_BOTTOM)
81 , viewportOrientation (VIEWPORTORIENTATION_LAST)
86 HorizontalFill horizontalFill;
87 VerticalFill verticalFill;
88 ViewportOrientation viewportOrientation;
110 STENCILOP_INCR, //!< Increment with saturation.
111 STENCILOP_DECR, //!< Decrement with saturation.
121 BLENDMODE_NONE = 0, //!< No blending.
122 BLENDMODE_STANDARD, //!< Standard blending.
123 BLENDMODE_ADVANCED, //!< Advanced blending mode, as defined in GL_KHR_blend_equation_advanced.
130 BLENDEQUATION_ADD = 0,
131 BLENDEQUATION_SUBTRACT,
132 BLENDEQUATION_REVERSE_SUBTRACT,
139 enum BlendEquationAdvanced
141 BLENDEQUATION_ADVANCED_MULTIPLY = 0,
142 BLENDEQUATION_ADVANCED_SCREEN,
143 BLENDEQUATION_ADVANCED_OVERLAY,
144 BLENDEQUATION_ADVANCED_DARKEN,
145 BLENDEQUATION_ADVANCED_LIGHTEN,
146 BLENDEQUATION_ADVANCED_COLORDODGE,
147 BLENDEQUATION_ADVANCED_COLORBURN,
148 BLENDEQUATION_ADVANCED_HARDLIGHT,
149 BLENDEQUATION_ADVANCED_SOFTLIGHT,
150 BLENDEQUATION_ADVANCED_DIFFERENCE,
151 BLENDEQUATION_ADVANCED_EXCLUSION,
152 BLENDEQUATION_ADVANCED_HSL_HUE,
153 BLENDEQUATION_ADVANCED_HSL_SATURATION,
154 BLENDEQUATION_ADVANCED_HSL_COLOR,
155 BLENDEQUATION_ADVANCED_HSL_LUMINOSITY,
157 BLENDEQUATION_ADVANCED_LAST
165 BLENDFUNC_ONE_MINUS_SRC_COLOR,
167 BLENDFUNC_ONE_MINUS_DST_COLOR,
169 BLENDFUNC_ONE_MINUS_SRC_ALPHA,
171 BLENDFUNC_ONE_MINUS_DST_ALPHA,
172 BLENDFUNC_CONSTANT_COLOR,
173 BLENDFUNC_ONE_MINUS_CONSTANT_COLOR,
174 BLENDFUNC_CONSTANT_ALPHA,
175 BLENDFUNC_ONE_MINUS_CONSTANT_ALPHA,
176 BLENDFUNC_SRC_ALPHA_SATURATE,
177 BLENDFUNC_SRC1_COLOR,
178 BLENDFUNC_ONE_MINUS_SRC1_COLOR,
179 BLENDFUNC_SRC1_ALPHA,
180 BLENDFUNC_ONE_MINUS_SRC1_ALPHA,
196 : func (TESTFUNC_ALWAYS)
199 , sFail (STENCILOP_KEEP)
200 , dpFail (STENCILOP_KEEP)
201 , dpPass (STENCILOP_KEEP)
209 BlendEquation equation;
214 : equation (BLENDEQUATION_ADD)
215 , srcFunc (BLENDFUNC_ONE)
216 , dstFunc (BLENDFUNC_ZERO)
221 struct WindowRectangle
228 WindowRectangle (int left_, int bottom_, int width_, int height_)
237 struct FragmentOperationState
239 // Variables corresponding to GL state variables.
241 bool scissorTestEnabled;
242 WindowRectangle scissorRectangle;
244 bool stencilTestEnabled;
245 StencilState stencilStates[2]; //!< Indexed with FACETYPE_FRONT and FACETYPE_BACK.
247 bool depthTestEnabled;
253 // Standard blending state
254 BlendState blendRGBState;
255 BlendState blendAState;
256 tcu::Vec4 blendColor; //!< Components should be in range [0, 1].
258 BlendEquationAdvanced blendEquationAdvaced;
262 bool depthClampEnabled;
264 bool polygonOffsetEnabled;
265 float polygonOffsetFactor;
266 float polygonOffsetUnits;
268 tcu::BVec4 colorMask;
270 // Variables not corresponding to configurable GL state, but other GL variables.
274 FragmentOperationState (void)
275 : scissorTestEnabled (false)
276 , scissorRectangle (0, 0, 1, 1)
278 , stencilTestEnabled (false)
279 // \note stencilStates[] members get default-constructed.
281 , depthTestEnabled (false)
282 , depthFunc (TESTFUNC_LESS)
285 , blendMode (BLENDMODE_NONE)
289 , blendEquationAdvaced (BLENDEQUATION_ADVANCED_LAST)
293 , depthClampEnabled (false)
295 , polygonOffsetEnabled (false)
296 , polygonOffsetFactor (0.0f)
297 , polygonOffsetUnits (0.0f)
329 WindowRectangle rect;
333 explicit ViewportState (const WindowRectangle& rect_)
340 explicit ViewportState (const rr::MultisampleConstPixelBufferAccess& multisampleBuffer)
341 : rect (0, 0, multisampleBuffer.raw().getHeight(), multisampleBuffer.raw().getDepth())
351 deUint32 restartIndex;
355 , restartIndex (0xFFFFFFFFul)
362 explicit RenderState (const ViewportState& viewport_, ViewportOrientation viewportOrientation_ = VIEWPORTORIENTATION_LOWER_LEFT)
363 : cullMode (CULLMODE_NONE)
364 , provokingVertexConvention (PROVOKINGVERTEX_LAST)
365 , viewport (viewport_)
366 , viewportOrientation (viewportOrientation_)
368 rasterization.viewportOrientation = viewportOrientation;
372 ProvokingVertex provokingVertexConvention;
373 RasterizationState rasterization;
374 FragmentOperationState fragOps;
376 ViewportState viewport;
378 RestartState restart;
379 ViewportOrientation viewportOrientation;
384 #endif // _RRRENDERSTATE_HPP