13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#ifndef _RRRENDERER_HPP 23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define _RRRENDERER_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 renderer interface. 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "rrDefs.hpp" 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "rrShaders.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "rrRenderState.hpp" 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "rrPrimitiveTypes.hpp" 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "rrMultisamplePixelBufferAccess.hpp" 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTexture.hpp" 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace rr 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass RenderTarget 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MAX_COLOR_BUFFERS = 4 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 44f0ed58441d167a6f524cc9ba2e71d220a20d8384Jarkko Pöyry RenderTarget (const MultisamplePixelBufferAccess& colorMultisampleBuffer, 45f0ed58441d167a6f524cc9ba2e71d220a20d8384Jarkko Pöyry const MultisamplePixelBufferAccess& depthMultisampleBuffer = MultisamplePixelBufferAccess(), 46f0ed58441d167a6f524cc9ba2e71d220a20d8384Jarkko Pöyry const MultisamplePixelBufferAccess& stencilMultisampleBuffer = MultisamplePixelBufferAccess()); 47f0ed58441d167a6f524cc9ba2e71d220a20d8384Jarkko Pöyry 48a15e7d7f566d93c76ca90171eb728e3d1cd82378Pyry Haulos int getNumSamples (void) const; 49f0ed58441d167a6f524cc9ba2e71d220a20d8384Jarkko Pöyry 50f0ed58441d167a6f524cc9ba2e71d220a20d8384Jarkko Pöyry const MultisamplePixelBufferAccess& getColorBuffer (int ndx) const { DE_ASSERT(de::inRange(ndx, 0, m_numColorBuffers)); return m_colorBuffers[ndx]; } 51f0ed58441d167a6f524cc9ba2e71d220a20d8384Jarkko Pöyry int getNumColorBuffers (void) const { return m_numColorBuffers; } 52f0ed58441d167a6f524cc9ba2e71d220a20d8384Jarkko Pöyry const MultisamplePixelBufferAccess& getStencilBuffer (void) const { return m_stencilBuffer; } 53f0ed58441d167a6f524cc9ba2e71d220a20d8384Jarkko Pöyry const MultisamplePixelBufferAccess& getDepthBuffer (void) const { return m_depthBuffer; } 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 55f0ed58441d167a6f524cc9ba2e71d220a20d8384Jarkko Pöyryprivate: 56f0ed58441d167a6f524cc9ba2e71d220a20d8384Jarkko Pöyry MultisamplePixelBufferAccess m_colorBuffers[MAX_COLOR_BUFFERS]; 57f0ed58441d167a6f524cc9ba2e71d220a20d8384Jarkko Pöyry const int m_numColorBuffers; 58f0ed58441d167a6f524cc9ba2e71d220a20d8384Jarkko Pöyry const MultisamplePixelBufferAccess m_depthBuffer; 59f0ed58441d167a6f524cc9ba2e71d220a20d8384Jarkko Pöyry const MultisamplePixelBufferAccess m_stencilBuffer; 6093df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE; 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct Program 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Program (const VertexShader* vertexShader_, const FragmentShader* fragmentShader_, const GeometryShader* geometryShader_ = DE_NULL) 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : vertexShader (vertexShader_) 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , fragmentShader (fragmentShader_) 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , geometryShader (geometryShader_) 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const VertexShader* vertexShader; 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const FragmentShader* fragmentShader; 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const GeometryShader* geometryShader; 7493df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE; 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct DrawIndices 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DrawIndices (const deUint32*, int baseVertex = 0); 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DrawIndices (const deUint16*, int baseVertex = 0); 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DrawIndices (const deUint8*, int baseVertex = 0); 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DrawIndices (const void* ptr, IndexType type, int baseVertex = 0); 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const void* const indices; 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const IndexType indexType; 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int baseVertex; 8693df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE; 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass PrimitiveList 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry PrimitiveList (PrimitiveType primitiveType, int numElements, const int firstElement); // !< primitive list for drawArrays-like call 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry PrimitiveList (PrimitiveType primitiveType, int numElements, const DrawIndices& indices); // !< primitive list for drawElements-like call 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry size_t getIndex (size_t elementNdx) const; 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool isRestartIndex (size_t elementNdx, deUint32 restartIndex) const; 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline size_t getNumElements (void) const { return m_numElements; } 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline PrimitiveType getPrimitiveType (void) const { return m_primitiveType; } 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline IndexType getIndexType (void) const { return m_indexType; } 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const PrimitiveType m_primitiveType; 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const size_t m_numElements; 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const void* const m_indices; // !< if indices is NULL, indices is interpreted as [first (== baseVertex) + 0, first + 1, first + 2, ...] 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const IndexType m_indexType; 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int m_baseVertex; 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass DrawCommand 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DrawCommand (const RenderState& state_, const RenderTarget& renderTarget_, const Program& program_, int numVertexAttribs_, const VertexAttrib* vertexAttribs_, const PrimitiveList& primitives_) 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : state (state_) 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , renderTarget (renderTarget_) 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , program (program_) 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , numVertexAttribs (numVertexAttribs_) 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , vertexAttribs (vertexAttribs_) 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , primitives (primitives_) 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const RenderState& state; 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const RenderTarget& renderTarget; 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const Program& program; 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int numVertexAttribs; 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const VertexAttrib* const vertexAttribs; 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const PrimitiveList& primitives; 13093df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE; 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Renderer 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Renderer (void); 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~Renderer (void); 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void draw (const DrawCommand& command) const; 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void drawInstanced (const DrawCommand& command, int numInstances) const; 14093df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE; 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // rr 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#endif // _RRRENDERER_HPP 145