13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#ifndef _GLSFRAGMENTOPUTIL_HPP 23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define _GLSFRAGMENTOPUTIL_HPP 33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*------------------------------------------------------------------------- 43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL (ES) Module 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 Fragment operation test utilities. 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuDefs.hpp" 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluShaderUtil.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuVector.hpp" 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTexture.hpp" 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "rrFragmentOperations.hpp" 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace glu 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ShaderProgram; 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass RenderContext; 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gls 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace FragmentOpUtil 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct Quad 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec2 posA; 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec2 posB; 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Normalized device coordinates (range [-1, 1]). 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // In order (A.x, A.y), (A.x, B.y), (B.x, A.y), (B.x, B.y) 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4 color[4]; 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4 color1[4]; 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float depth[4]; 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Quad (void) 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : posA(-1.0f, -1.0f) 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , posB( 1.0f, 1.0f) 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int i = 0; i < DE_LENGTH_OF_ARRAY(depth); i++) 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry depth[i] = 0.0f; 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass QuadRenderer 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry QuadRenderer (const glu::RenderContext& context, glu::GLSLVersion glslVersion); 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~QuadRenderer (void); 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void render (const Quad& quad) const; 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry QuadRenderer (const QuadRenderer& other); // Not allowed! 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry QuadRenderer& operator= (const QuadRenderer& other); // Not allowed! 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glu::RenderContext& m_context; 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::ShaderProgram* m_program; 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_positionLoc; 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_colorLoc; 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_color1Loc; 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool m_blendFuncExt; 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct IntegerQuad 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::IVec2 posA; 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::IVec2 posB; 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Viewport coordinates (depth in range [0, 1]). 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // In order (A.x, A.y), (A.x, B.y), (B.x, A.y), (B.x, B.y) 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4 color[4]; 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4 color1[4]; 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float depth[4]; 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IntegerQuad (int windowWidth, int windowHeight) 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : posA(0, 0) 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , posB(windowWidth-1, windowHeight-1) 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int i = 0; i < DE_LENGTH_OF_ARRAY(depth); i++) 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry depth[i] = 0.0f; 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IntegerQuad (void) 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : posA(0, 0) 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , posB(1, 1) 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int i = 0; i < DE_LENGTH_OF_ARRAY(depth); i++) 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry depth[i] = 0.0f; 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ReferenceQuadRenderer 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ReferenceQuadRenderer (void); 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void render (const tcu::PixelBufferAccess& colorBuffer, 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::PixelBufferAccess& depthBuffer, 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::PixelBufferAccess& stencilBuffer, 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const IntegerQuad& quad, 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const rr::FragmentOperationState& state); 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MAX_FRAGMENT_BUFFER_SIZE = 1024 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void flushFragmentBuffer (const rr::MultisamplePixelBufferAccess& colorBuffer, 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const rr::MultisamplePixelBufferAccess& depthBuffer, 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const rr::MultisamplePixelBufferAccess& stencilBuffer, 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry rr::FaceType faceType, 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const rr::FragmentOperationState& state); 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry rr::Fragment m_fragmentBuffer[MAX_FRAGMENT_BUFFER_SIZE]; 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float m_fragmentDepths[MAX_FRAGMENT_BUFFER_SIZE]; 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_fragmentBufferSize; 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry rr::FragmentProcessor m_fragmentProcessor; 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// These functions take a normally-indexed 2d pixel buffer and return a pixel buffer access 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// that indexes the same memory area, but using the multisample indexing convention. 1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytcu::PixelBufferAccess getMultisampleAccess(const tcu::PixelBufferAccess& original); 1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytcu::ConstPixelBufferAccess getMultisampleAccess(const tcu::ConstPixelBufferAccess& original); 1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // FragmentOpUtil 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gls 1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp 1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#endif // _GLSFRAGMENTOPUTIL_HPP 154