13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#ifndef _RRFRAGMENTOPERATIONS_HPP 23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define _RRFRAGMENTOPERATIONS_HPP 33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*------------------------------------------------------------------------- 43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program Reference Renderer 53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * ----------------------------------------------- 63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project 83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License"); 103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License. 113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at 123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * http://www.apache.org/licenses/LICENSE-2.0 143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software 163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS, 173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and 193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License. 203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*! 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Reference implementation for per-fragment operations. 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \note In this file, a multisample buffer means a tcu::PixelBufferAccess 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * (or ConstPixelBufferAccess) where the x coordinate is the sample 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * index and the y and z coordinates are the pixel's x and y 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * coordinates, respectively. To prevent supplying a buffer in 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * a wrong format the buffers are wrapped in rr::MultisamplePixelBufferAccess 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * wrapper. FragmentProcessor::render() operates on 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * this kind of buffers. The function fromSinglesampleAccess() can be 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * used to get a one-sampled multisample access to a normal 2d 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * buffer. 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "rrDefs.hpp" 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuVector.hpp" 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTexture.hpp" 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "rrRenderState.hpp" 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "rrGenericVector.hpp" 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "rrMultisamplePixelBufferAccess.hpp" 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace rr 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct Fragment 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::IVec2 pixelCoord; 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GenericVec4 value; 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GenericVec4 value1; 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 coverage; 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float* sampleDepths; 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Fragment (const tcu::IVec2& pixelCoord_, const GenericVec4& value_, deUint32 coverage_, const float* sampleDepths_) 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : pixelCoord (pixelCoord_) 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , value (value_) 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , value1 () 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , coverage (coverage_) 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , sampleDepths (sampleDepths_) 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Fragment (const tcu::IVec2& pixelCoord_, const GenericVec4& value_, const GenericVec4& value1_, deUint32 coverage_, const float* sampleDepths_) 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : pixelCoord (pixelCoord_) 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , value (value_) 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , value1 (value1_) 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , coverage (coverage_) 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , sampleDepths (sampleDepths_) 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Fragment (void) 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : pixelCoord (0) 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , value () 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , coverage (0) 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , sampleDepths (DE_NULL) 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7993df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE; 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// These functions are for clearing only a specific pixel rectangle in a multisample buffer. 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// When clearing the entire buffer, tcu::clear, tcu::clearDepth and tcu::clearStencil can be used. 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid clearMultisampleColorBuffer (const tcu::PixelBufferAccess& dst, const tcu::Vec4& value, const WindowRectangle& rect); 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid clearMultisampleColorBuffer (const tcu::PixelBufferAccess& dst, const tcu::IVec4& value, const WindowRectangle& rect); 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid clearMultisampleColorBuffer (const tcu::PixelBufferAccess& dst, const tcu::UVec4& value, const WindowRectangle& rect); 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid clearMultisampleDepthBuffer (const tcu::PixelBufferAccess& dst, float value, const WindowRectangle& rect); 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid clearMultisampleStencilBuffer (const tcu::PixelBufferAccess& dst, int value, const WindowRectangle& rect); 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*! 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Reference fragment renderer. 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * FragmentProcessor.render() draws a given set of fragments. No two 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * fragments given in one render() call should have the same pixel 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * coordinates coordinates, and they must all have the same facing. 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass FragmentProcessor 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FragmentProcessor (void); 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void render (const rr::MultisamplePixelBufferAccess& colorMultisampleBuffer, 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const rr::MultisamplePixelBufferAccess& depthMultisampleBuffer, 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const rr::MultisamplePixelBufferAccess& stencilMultisampleBuffer, 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const Fragment* fragments, 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numFragments, 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FaceType fragmentFacing, 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const FragmentOperationState& state); 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SAMPLE_REGISTER_SIZE = 64 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry struct SampleData 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool isAlive; 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool stencilPassed; 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool depthPassed; 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4 clampedBlendSrcColor; 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4 clampedBlendSrc1Color; 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4 clampedBlendDstColor; 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec3 blendSrcFactorRGB; 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float blendSrcFactorA; 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec3 blendDstFactorRGB; 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float blendDstFactorA; 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec3 blendedRGB; 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float blendedA; 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vector<deInt32, 4> signedValue; //!< integer targets 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vector<deUint32, 4> unsignedValue; //!< unsigned integer targets 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // These functions operate on the values in m_sampleRegister and, in some cases, the buffers. 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void executeScissorTest (int fragNdxOffset, int numSamplesPerFragment, const Fragment* inputFragments, const WindowRectangle& scissorRect); 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void executeStencilCompare (int fragNdxOffset, int numSamplesPerFragment, const Fragment* inputFragments, const StencilState& stencilState, int numStencilBits, const tcu::ConstPixelBufferAccess& stencilBuffer); 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void executeStencilSFail (int fragNdxOffset, int numSamplesPerFragment, const Fragment* inputFragments, const StencilState& stencilState, int numStencilBits, const tcu::PixelBufferAccess& stencilBuffer); 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void executeDepthCompare (int fragNdxOffset, int numSamplesPerFragment, const Fragment* inputFragments, TestFunc depthFunc, const tcu::ConstPixelBufferAccess& depthBuffer); 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void executeDepthWrite (int fragNdxOffset, int numSamplesPerFragment, const Fragment* inputFragments, const tcu::PixelBufferAccess& depthBuffer); 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void executeStencilDpFailAndPass (int fragNdxOffset, int numSamplesPerFragment, const Fragment* inputFragments, const StencilState& stencilState, int numStencilBits, const tcu::PixelBufferAccess& stencilBuffer); 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void executeBlendFactorComputeRGB (const tcu::Vec4& blendColor, const BlendState& blendRGBState); 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void executeBlendFactorComputeA (const tcu::Vec4& blendColor, const BlendState& blendAState); 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void executeBlend (const BlendState& blendRGBState, const BlendState& blendAState); 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void executeAdvancedBlend (BlendEquationAdvanced equation); 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void executeColorWrite (int fragNdxOffset, int numSamplesPerFragment, const Fragment* inputFragments, bool isSRGB, const tcu::PixelBufferAccess& colorBuffer); 1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void executeRGBA8ColorWrite (int fragNdxOffset, int numSamplesPerFragment, const Fragment* inputFragments, const tcu::PixelBufferAccess& colorBuffer); 1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void executeMaskedColorWrite (int fragNdxOffset, int numSamplesPerFragment, const Fragment* inputFragments, const tcu::Vec4& colorMaskFactor, const tcu::Vec4& colorMaskNegationFactor, bool isSRGB, const tcu::PixelBufferAccess& colorBuffer); 1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void executeSignedValueWrite (int fragNdxOffset, int numSamplesPerFragment, const Fragment* inputFragments, const tcu::BVec4& colorMask, const tcu::PixelBufferAccess& colorBuffer); 1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void executeUnsignedValueWrite (int fragNdxOffset, int numSamplesPerFragment, const Fragment* inputFragments, const tcu::BVec4& colorMask, const tcu::PixelBufferAccess& colorBuffer); 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SampleData m_sampleRegister[SAMPLE_REGISTER_SIZE]; 15293df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE; 1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // rr 1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#endif // _RRFRAGMENTOPERATIONS_HPP 157