1 #ifndef _RRFRAGMENTOPERATIONS_HPP
2 #define _RRFRAGMENTOPERATIONS_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 implementation for per-fragment operations.
25 * \note In this file, a multisample buffer means a tcu::PixelBufferAccess
26 * (or ConstPixelBufferAccess) where the x coordinate is the sample
27 * index and the y and z coordinates are the pixel's x and y
28 * coordinates, respectively. To prevent supplying a buffer in
29 * a wrong format the buffers are wrapped in rr::MultisamplePixelBufferAccess
30 * wrapper. FragmentProcessor::render() operates on
31 * this kind of buffers. The function fromSinglesampleAccess() can be
32 * used to get a one-sampled multisample access to a normal 2d
34 *//*--------------------------------------------------------------------*/
37 #include "tcuVector.hpp"
38 #include "tcuTexture.hpp"
39 #include "rrRenderState.hpp"
40 #include "rrGenericVector.hpp"
41 #include "rrMultisamplePixelBufferAccess.hpp"
48 tcu::IVec2 pixelCoord;
52 const float* sampleDepths;
54 Fragment (const tcu::IVec2& pixelCoord_, const GenericVec4& value_, deUint32 coverage_, const float* sampleDepths_)
55 : pixelCoord (pixelCoord_)
58 , coverage (coverage_)
59 , sampleDepths (sampleDepths_)
63 Fragment (const tcu::IVec2& pixelCoord_, const GenericVec4& value_, const GenericVec4& value1_, deUint32 coverage_, const float* sampleDepths_)
64 : pixelCoord (pixelCoord_)
67 , coverage (coverage_)
68 , sampleDepths (sampleDepths_)
76 , sampleDepths (DE_NULL)
79 } DE_WARN_UNUSED_TYPE;
81 // These functions are for clearing only a specific pixel rectangle in a multisample buffer.
82 // When clearing the entire buffer, tcu::clear, tcu::clearDepth and tcu::clearStencil can be used.
83 void clearMultisampleColorBuffer (const tcu::PixelBufferAccess& dst, const tcu::Vec4& value, const WindowRectangle& rect);
84 void clearMultisampleColorBuffer (const tcu::PixelBufferAccess& dst, const tcu::IVec4& value, const WindowRectangle& rect);
85 void clearMultisampleColorBuffer (const tcu::PixelBufferAccess& dst, const tcu::UVec4& value, const WindowRectangle& rect);
86 void clearMultisampleDepthBuffer (const tcu::PixelBufferAccess& dst, float value, const WindowRectangle& rect);
87 void clearMultisampleStencilBuffer (const tcu::PixelBufferAccess& dst, int value, const WindowRectangle& rect);
89 /*--------------------------------------------------------------------*//*!
90 * \brief Reference fragment renderer.
92 * FragmentProcessor.render() draws a given set of fragments. No two
93 * fragments given in one render() call should have the same pixel
94 * coordinates coordinates, and they must all have the same facing.
95 *//*--------------------------------------------------------------------*/
96 class FragmentProcessor
99 FragmentProcessor (void);
101 void render (const rr::MultisamplePixelBufferAccess& colorMultisampleBuffer,
102 const rr::MultisamplePixelBufferAccess& depthMultisampleBuffer,
103 const rr::MultisamplePixelBufferAccess& stencilMultisampleBuffer,
104 const Fragment* fragments,
106 FaceType fragmentFacing,
107 const FragmentOperationState& state);
112 SAMPLE_REGISTER_SIZE = 64
119 tcu::Vec4 clampedBlendSrcColor;
120 tcu::Vec4 clampedBlendSrc1Color;
121 tcu::Vec4 clampedBlendDstColor;
122 tcu::Vec3 blendSrcFactorRGB;
123 float blendSrcFactorA;
124 tcu::Vec3 blendDstFactorRGB;
125 float blendDstFactorA;
126 tcu::Vec3 blendedRGB;
128 tcu::Vector<deInt32, 4> signedValue; //!< integer targets
129 tcu::Vector<deUint32, 4> unsignedValue; //!< unsigned integer targets
132 // These functions operate on the values in m_sampleRegister and, in some cases, the buffers.
134 void executeScissorTest (int fragNdxOffset, int numSamplesPerFragment, const Fragment* inputFragments, const WindowRectangle& scissorRect);
135 void executeStencilCompare (int fragNdxOffset, int numSamplesPerFragment, const Fragment* inputFragments, const StencilState& stencilState, int numStencilBits, const tcu::ConstPixelBufferAccess& stencilBuffer);
136 void executeStencilSFail (int fragNdxOffset, int numSamplesPerFragment, const Fragment* inputFragments, const StencilState& stencilState, int numStencilBits, const tcu::PixelBufferAccess& stencilBuffer);
137 void executeDepthCompare (int fragNdxOffset, int numSamplesPerFragment, const Fragment* inputFragments, TestFunc depthFunc, const tcu::ConstPixelBufferAccess& depthBuffer);
138 void executeDepthWrite (int fragNdxOffset, int numSamplesPerFragment, const Fragment* inputFragments, const tcu::PixelBufferAccess& depthBuffer);
139 void executeStencilDpFailAndPass (int fragNdxOffset, int numSamplesPerFragment, const Fragment* inputFragments, const StencilState& stencilState, int numStencilBits, const tcu::PixelBufferAccess& stencilBuffer);
140 void executeBlendFactorComputeRGB (const tcu::Vec4& blendColor, const BlendState& blendRGBState);
141 void executeBlendFactorComputeA (const tcu::Vec4& blendColor, const BlendState& blendAState);
142 void executeBlend (const BlendState& blendRGBState, const BlendState& blendAState);
143 void executeAdvancedBlend (BlendEquationAdvanced equation);
145 void executeColorWrite (int fragNdxOffset, int numSamplesPerFragment, const Fragment* inputFragments, bool isSRGB, const tcu::PixelBufferAccess& colorBuffer);
146 void executeRGBA8ColorWrite (int fragNdxOffset, int numSamplesPerFragment, const Fragment* inputFragments, const tcu::PixelBufferAccess& colorBuffer);
147 void executeMaskedColorWrite (int fragNdxOffset, int numSamplesPerFragment, const Fragment* inputFragments, const tcu::Vec4& colorMaskFactor, const tcu::Vec4& colorMaskNegationFactor, bool isSRGB, const tcu::PixelBufferAccess& colorBuffer);
148 void executeSignedValueWrite (int fragNdxOffset, int numSamplesPerFragment, const Fragment* inputFragments, const tcu::BVec4& colorMask, const tcu::PixelBufferAccess& colorBuffer);
149 void executeUnsignedValueWrite (int fragNdxOffset, int numSamplesPerFragment, const Fragment* inputFragments, const tcu::BVec4& colorMask, const tcu::PixelBufferAccess& colorBuffer);
151 SampleData m_sampleRegister[SAMPLE_REGISTER_SIZE];
152 } DE_WARN_UNUSED_TYPE;
156 #endif // _RRFRAGMENTOPERATIONS_HPP