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 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RenderTarget (const MultisamplePixelBufferAccess& colorMultisampleBuffer, 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const MultisamplePixelBufferAccess& depthMultisampleBuffer = MultisamplePixelBufferAccess(), 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const MultisamplePixelBufferAccess& stencilMultisampleBuffer = MultisamplePixelBufferAccess()) 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : numColorBuffers (1) 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , depthBuffer (depthMultisampleBuffer) 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , stencilBuffer (stencilMultisampleBuffer) 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry colorBuffers[0] = colorMultisampleBuffer; 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MultisamplePixelBufferAccess colorBuffers[MAX_COLOR_BUFFERS]; 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int numColorBuffers; 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const MultisamplePixelBufferAccess depthBuffer; 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const MultisamplePixelBufferAccess stencilBuffer; 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct Program 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Program (const VertexShader* vertexShader_, const FragmentShader* fragmentShader_, const GeometryShader* geometryShader_ = DE_NULL) 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : vertexShader (vertexShader_) 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , fragmentShader (fragmentShader_) 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , geometryShader (geometryShader_) 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const VertexShader* vertexShader; 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const FragmentShader* fragmentShader; 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const GeometryShader* geometryShader; 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct DrawIndices 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DrawIndices (const deUint32*, int baseVertex = 0); 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DrawIndices (const deUint16*, int baseVertex = 0); 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DrawIndices (const deUint8*, int baseVertex = 0); 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DrawIndices (const void* ptr, IndexType type, int baseVertex = 0); 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const void* const indices; 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const IndexType indexType; 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int baseVertex; 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass PrimitiveList 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry PrimitiveList (PrimitiveType primitiveType, int numElements, const int firstElement); // !< primitive list for drawArrays-like call 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry PrimitiveList (PrimitiveType primitiveType, int numElements, const DrawIndices& indices); // !< primitive list for drawElements-like call 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry size_t getIndex (size_t elementNdx) const; 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool isRestartIndex (size_t elementNdx, deUint32 restartIndex) const; 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline size_t getNumElements (void) const { return m_numElements; } 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline PrimitiveType getPrimitiveType (void) const { return m_primitiveType; } 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry inline IndexType getIndexType (void) const { return m_indexType; } 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const PrimitiveType m_primitiveType; 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const size_t m_numElements; 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const void* const m_indices; // !< if indices is NULL, indices is interpreted as [first (== baseVertex) + 0, first + 1, first + 2, ...] 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const IndexType m_indexType; 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int m_baseVertex; 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass DrawCommand 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DrawCommand (const RenderState& state_, const RenderTarget& renderTarget_, const Program& program_, int numVertexAttribs_, const VertexAttrib* vertexAttribs_, const PrimitiveList& primitives_) 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : state (state_) 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , renderTarget (renderTarget_) 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , program (program_) 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , numVertexAttribs (numVertexAttribs_) 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , vertexAttribs (vertexAttribs_) 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , primitives (primitives_) 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const RenderState& state; 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const RenderTarget& renderTarget; 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const Program& program; 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int numVertexAttribs; 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const VertexAttrib* const vertexAttribs; 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const PrimitiveList& primitives; 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Renderer 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Renderer (void); 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~Renderer (void); 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void draw (const DrawCommand& command) const; 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void drawInstanced (const DrawCommand& command, int numInstances) const; 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // rr 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#endif // _RRRENDERER_HPP 143