CP: Non-compressed copy image target size (64,64,8 am: 7aff1a044f am: 8afffd6f14...
[platform/upstream/VK-GL-CTS.git] / framework / referencerenderer / rrRenderer.hpp
1 #ifndef _RRRENDERER_HPP
2 #define _RRRENDERER_HPP
3 /*-------------------------------------------------------------------------
4  * drawElements Quality Program Reference Renderer
5  * -----------------------------------------------
6  *
7  * Copyright 2014 The Android Open Source Project
8  *
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
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
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.
20  *
21  *//*!
22  * \file
23  * \brief Reference renderer interface.
24  *//*--------------------------------------------------------------------*/
25
26 #include "rrDefs.hpp"
27 #include "rrShaders.hpp"
28 #include "rrRenderState.hpp"
29 #include "rrPrimitiveTypes.hpp"
30 #include "rrMultisamplePixelBufferAccess.hpp"
31 #include "tcuTexture.hpp"
32
33 namespace rr
34 {
35
36 class RenderTarget
37 {
38 public:
39         enum
40         {
41                 MAX_COLOR_BUFFERS       = 4
42         };
43
44                                                                                         RenderTarget            (const MultisamplePixelBufferAccess& colorMultisampleBuffer,
45                                                                                                                                  const MultisamplePixelBufferAccess& depthMultisampleBuffer             = MultisamplePixelBufferAccess(),
46                                                                                                                                  const MultisamplePixelBufferAccess& stencilMultisampleBuffer   = MultisamplePixelBufferAccess());
47
48         int                                                                             getNumSamples           (void) const;
49
50         const MultisamplePixelBufferAccess&             getColorBuffer          (int ndx) const { DE_ASSERT(de::inRange(ndx, 0, m_numColorBuffers));    return m_colorBuffers[ndx];     }
51         int                                                                             getNumColorBuffers      (void) const    { return m_numColorBuffers; }
52         const MultisamplePixelBufferAccess&             getStencilBuffer        (void) const    {                                                                                                               return m_stencilBuffer;         }
53         const MultisamplePixelBufferAccess&             getDepthBuffer          (void) const    {                                                                                                               return m_depthBuffer;           }
54
55 private:
56         MultisamplePixelBufferAccess                    m_colorBuffers[MAX_COLOR_BUFFERS];
57         const int                                                               m_numColorBuffers;
58         const MultisamplePixelBufferAccess              m_depthBuffer;
59         const MultisamplePixelBufferAccess              m_stencilBuffer;
60 } DE_WARN_UNUSED_TYPE;
61
62 struct Program
63 {
64         Program (const VertexShader* vertexShader_, const FragmentShader* fragmentShader_, const GeometryShader* geometryShader_ = DE_NULL)
65                 : vertexShader          (vertexShader_)
66                 , fragmentShader        (fragmentShader_)
67                 , geometryShader        (geometryShader_)
68         {
69         }
70
71         const VertexShader*                     vertexShader;
72         const FragmentShader*           fragmentShader;
73         const GeometryShader*           geometryShader;
74 } DE_WARN_UNUSED_TYPE;
75
76 struct DrawIndices
77 {
78                                                 DrawIndices             (const deUint32*, int baseVertex = 0);
79                                                 DrawIndices             (const deUint16*, int baseVertex = 0);
80                                                 DrawIndices             (const deUint8*, int baseVertex = 0);
81                                                 DrawIndices             (const void* ptr, IndexType type, int baseVertex = 0);
82
83         const void* const       indices;
84         const IndexType         indexType;
85         const int                       baseVertex;
86 } DE_WARN_UNUSED_TYPE;
87
88 class PrimitiveList
89 {
90 public:
91                                                         PrimitiveList           (PrimitiveType primitiveType, int numElements, const int firstElement);         // !< primitive list for drawArrays-like call
92                                                         PrimitiveList           (PrimitiveType primitiveType, int numElements, const DrawIndices& indices);     // !< primitive list for drawElements-like call
93
94         size_t                                  getIndex                        (size_t elementNdx) const;
95         bool                                    isRestartIndex          (size_t elementNdx, deUint32 restartIndex) const;
96
97         inline size_t                   getNumElements          (void) const    { return m_numElements;         }
98         inline PrimitiveType    getPrimitiveType        (void) const    { return m_primitiveType;       }
99         inline IndexType                getIndexType            (void) const    { return m_indexType;           }
100
101 private:
102         const PrimitiveType             m_primitiveType;
103         const size_t                    m_numElements;
104         const void* const               m_indices;                      // !< if indices is NULL, indices is interpreted as [first (== baseVertex) + 0, first + 1, first + 2, ...]
105         const IndexType                 m_indexType;
106         const int                               m_baseVertex;
107 };
108
109 class DrawCommand
110 {
111 public:
112         DrawCommand (const RenderState& state_, const RenderTarget& renderTarget_, const Program& program_, int numVertexAttribs_, const VertexAttrib* vertexAttribs_, const PrimitiveList& primitives_)
113                 : state                         (state_)
114                 , renderTarget          (renderTarget_)
115                 , program                       (program_)
116                 , numVertexAttribs      (numVertexAttribs_)
117                 , vertexAttribs         (vertexAttribs_)
118                 , primitives            (primitives_)
119         {
120         }
121
122         const RenderState&                      state;
123         const RenderTarget&                     renderTarget;
124         const Program&                          program;
125
126         const int                                       numVertexAttribs;
127         const VertexAttrib* const       vertexAttribs;
128
129         const PrimitiveList&            primitives;
130 } DE_WARN_UNUSED_TYPE;
131
132 class Renderer
133 {
134 public:
135                                         Renderer                (void);
136                                         ~Renderer               (void);
137
138         void                    draw                    (const DrawCommand& command) const;
139         void                    drawInstanced   (const DrawCommand& command, int numInstances) const;
140 } DE_WARN_UNUSED_TYPE;
141
142 } // rr
143
144 #endif // _RRRENDERER_HPP