1 #ifndef _SGLRCONTEXT_HPP
2 #define _SGLRCONTEXT_HPP
3 /*-------------------------------------------------------------------------
4 * drawElements Quality Program OpenGL ES Utilities
5 * ------------------------------------------------
7 * Copyright 2014 The Android Open Source Project
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 * \brief Simplified GLES reference context.
24 *//*--------------------------------------------------------------------*/
26 #include "tcuDefs.hpp"
27 #include "tcuSurface.hpp"
28 #include "gluRenderContext.hpp"
29 #include "sglrShaderProgram.hpp"
32 /*--------------------------------------------------------------------*//*!
33 * \brief Reference OpenGL API implementation
34 *//*--------------------------------------------------------------------*/
38 // Abstract drawing context with GL-style API
43 Context (glu::ContextType type) : m_type(type) {}
44 virtual ~Context (void) {}
46 virtual int getWidth (void) const = DE_NULL;
47 virtual int getHeight (void) const = DE_NULL;
49 virtual void activeTexture (deUint32 texture) = DE_NULL;
50 virtual void viewport (int x, int y, int width, int height) = DE_NULL;
52 virtual void bindTexture (deUint32 target, deUint32 texture) = DE_NULL;
53 virtual void genTextures (int numTextures, deUint32* textures) = DE_NULL;
54 virtual void deleteTextures (int numTextures, const deUint32* textures) = DE_NULL;
56 virtual void bindFramebuffer (deUint32 target, deUint32 framebuffer) = DE_NULL;
57 virtual void genFramebuffers (int numFramebuffers, deUint32* framebuffers) = DE_NULL;
58 virtual void deleteFramebuffers (int numFramebuffers, const deUint32* framebuffers) = DE_NULL;
60 virtual void bindRenderbuffer (deUint32 target, deUint32 renderbuffer) = DE_NULL;
61 virtual void genRenderbuffers (int numRenderbuffers, deUint32* renderbuffers) = DE_NULL;
62 virtual void deleteRenderbuffers (int numRenderbuffers, const deUint32* renderbuffers) = DE_NULL;
64 virtual void pixelStorei (deUint32 pname, int param) = DE_NULL;
65 virtual void texImage1D (deUint32 target, int level, deUint32 internalFormat, int width, int border, deUint32 format, deUint32 type, const void* data) = DE_NULL;
66 virtual void texImage2D (deUint32 target, int level, deUint32 internalFormat, int width, int height, int border, deUint32 format, deUint32 type, const void* data) = DE_NULL;
67 virtual void texImage3D (deUint32 target, int level, deUint32 internalFormat, int width, int height, int depth, int border, deUint32 format, deUint32 type, const void* data) = DE_NULL;
68 virtual void texSubImage1D (deUint32 target, int level, int xoffset, int width, deUint32 format, deUint32 type, const void* data) = DE_NULL;
69 virtual void texSubImage2D (deUint32 target, int level, int xoffset, int yoffset, int width, int height, deUint32 format, deUint32 type, const void* data) = DE_NULL;
70 virtual void texSubImage3D (deUint32 target, int level, int xoffset, int yoffset, int zoffset, int width, int height, int depth, deUint32 format, deUint32 type, const void* data) = DE_NULL;
71 virtual void copyTexImage1D (deUint32 target, int level, deUint32 internalFormat, int x, int y, int width, int border) = DE_NULL;
72 virtual void copyTexImage2D (deUint32 target, int level, deUint32 internalFormat, int x, int y, int width, int height, int border) = DE_NULL;
73 virtual void copyTexSubImage1D (deUint32 target, int level, int xoffset, int x, int y, int width) = DE_NULL;
74 virtual void copyTexSubImage2D (deUint32 target, int level, int xoffset, int yoffset, int x, int y, int width, int height) = DE_NULL;
75 virtual void copyTexSubImage3D (deUint32 target, int level, int xoffset, int yoffset, int zoffset, int x, int y, int width, int height) = DE_NULL;
77 virtual void texStorage2D (deUint32 target, int levels, deUint32 internalFormat, int width, int height) = DE_NULL;
78 virtual void texStorage3D (deUint32 target, int levels, deUint32 internalFormat, int width, int height, int depth) = DE_NULL;
80 virtual void texParameteri (deUint32 target, deUint32 pname, int value) = DE_NULL;
82 virtual void framebufferTexture2D (deUint32 target, deUint32 attachment, deUint32 textarget, deUint32 texture, int level) = DE_NULL;
83 virtual void framebufferTextureLayer (deUint32 target, deUint32 attachment, deUint32 texture, int level, int layer) = DE_NULL;
84 virtual void framebufferRenderbuffer (deUint32 target, deUint32 attachment, deUint32 renderbuffertarget, deUint32 renderbuffer) = DE_NULL;
85 virtual deUint32 checkFramebufferStatus (deUint32 target) = DE_NULL;
87 virtual void getFramebufferAttachmentParameteriv (deUint32 target, deUint32 attachment, deUint32 pname, int* params) = DE_NULL;
89 virtual void renderbufferStorage (deUint32 target, deUint32 internalformat, int width, int height) = DE_NULL;
90 virtual void renderbufferStorageMultisample (deUint32 target, int samples, deUint32 internalFormat, int width, int height) = DE_NULL;
92 virtual void bindBuffer (deUint32 target, deUint32 buffer) = DE_NULL;
93 virtual void genBuffers (int numBuffers, deUint32* buffers) = DE_NULL;
94 virtual void deleteBuffers (int numBuffers, const deUint32* buffers) = DE_NULL;
96 virtual void bufferData (deUint32 target, deIntptr size, const void* data, deUint32 usage) = DE_NULL;
97 virtual void bufferSubData (deUint32 target, deIntptr offset, deIntptr size, const void* data) = DE_NULL;
99 virtual void clearColor (float red, float green, float blue, float alpha) = DE_NULL;
100 virtual void clearDepthf (float depth) = DE_NULL;
101 virtual void clearStencil (int stencil) = DE_NULL;
103 virtual void clear (deUint32 buffers) = DE_NULL;
104 virtual void clearBufferiv (deUint32 buffer, int drawbuffer, const int* value) = DE_NULL;
105 virtual void clearBufferfv (deUint32 buffer, int drawbuffer, const float* value) = DE_NULL;
106 virtual void clearBufferuiv (deUint32 buffer, int drawbuffer, const deUint32* value) = DE_NULL;
107 virtual void clearBufferfi (deUint32 buffer, int drawbuffer, float depth, int stencil) = DE_NULL;
108 virtual void scissor (int x, int y, int width, int height) = DE_NULL;
110 virtual void enable (deUint32 cap) = DE_NULL;
111 virtual void disable (deUint32 cap) = DE_NULL;
113 virtual void stencilFunc (deUint32 func, int ref, deUint32 mask) = DE_NULL;
114 virtual void stencilOp (deUint32 sfail, deUint32 dpfail, deUint32 dppass) = DE_NULL;
115 virtual void stencilFuncSeparate (deUint32 face, deUint32 func, int ref, deUint32 mask) = DE_NULL;
116 virtual void stencilOpSeparate (deUint32 face, deUint32 sfail, deUint32 dpfail, deUint32 dppass) = DE_NULL;
118 virtual void depthFunc (deUint32 func) = DE_NULL;
119 virtual void depthRangef (float n, float f) = DE_NULL;
120 virtual void depthRange (double n, double f) = DE_NULL;
122 virtual void polygonOffset (float factor, float units) = DE_NULL;
123 virtual void provokingVertex (deUint32 convention) = DE_NULL;
124 virtual void primitiveRestartIndex (deUint32 index) = DE_NULL;
126 virtual void blendEquation (deUint32 mode) = DE_NULL;
127 virtual void blendEquationSeparate (deUint32 modeRGB, deUint32 modeAlpha) = DE_NULL;
128 virtual void blendFunc (deUint32 src, deUint32 dst) = DE_NULL;
129 virtual void blendFuncSeparate (deUint32 srcRGB, deUint32 dstRGB, deUint32 srcAlpha, deUint32 dstAlpha) = DE_NULL;
130 virtual void blendColor (float red, float green, float blue, float alpha) = DE_NULL;
132 virtual void colorMask (deBool r, deBool g, deBool b, deBool a) = DE_NULL;
133 virtual void depthMask (deBool mask) = DE_NULL;
134 virtual void stencilMask (deUint32 mask) = DE_NULL;
135 virtual void stencilMaskSeparate (deUint32 face, deUint32 mask) = DE_NULL;
137 virtual void blitFramebuffer (int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1, deUint32 mask, deUint32 filter) = DE_NULL;
139 virtual void invalidateSubFramebuffer(deUint32 target, int numAttachments, const deUint32* attachments, int x, int y, int width, int height) = DE_NULL;
140 virtual void invalidateFramebuffer (deUint32 target, int numAttachments, const deUint32* attachments) = DE_NULL;
142 virtual void bindVertexArray (deUint32 array) = DE_NULL;
143 virtual void genVertexArrays (int numArrays, deUint32* vertexArrays) = DE_NULL;
144 virtual void deleteVertexArrays (int numArrays, const deUint32* vertexArrays) = DE_NULL;
146 virtual void vertexAttribPointer (deUint32 index, int size, deUint32 type, deBool normalized, int stride, const void *pointer) = DE_NULL;
147 virtual void vertexAttribIPointer (deUint32 index, int size, deUint32 type, int stride, const void *pointer) = DE_NULL;
148 virtual void enableVertexAttribArray (deUint32 index) = DE_NULL;
149 virtual void disableVertexAttribArray(deUint32 index) = DE_NULL;
150 virtual void vertexAttribDivisor (deUint32 index, deUint32 divisor) = DE_NULL;
152 virtual void vertexAttrib1f (deUint32 index, float) = DE_NULL;
153 virtual void vertexAttrib2f (deUint32 index, float, float) = DE_NULL;
154 virtual void vertexAttrib3f (deUint32 index, float, float, float) = DE_NULL;
155 virtual void vertexAttrib4f (deUint32 index, float, float, float, float) = DE_NULL;
156 virtual void vertexAttribI4i (deUint32 index, deInt32, deInt32, deInt32, deInt32) = DE_NULL;
157 virtual void vertexAttribI4ui (deUint32 index, deUint32, deUint32, deUint32, deUint32) = DE_NULL;
159 virtual deInt32 getAttribLocation (deUint32 program, const char *name) = DE_NULL;
161 virtual void uniform1f (deInt32 index, float) = DE_NULL;
162 virtual void uniform1i (deInt32 index, deInt32) = DE_NULL;
163 virtual void uniform1fv (deInt32 index, deInt32 count, const float*) = DE_NULL;
164 virtual void uniform2fv (deInt32 index, deInt32 count, const float*) = DE_NULL;
165 virtual void uniform3fv (deInt32 index, deInt32 count, const float*) = DE_NULL;
166 virtual void uniform4fv (deInt32 index, deInt32 count, const float*) = DE_NULL;
167 virtual void uniform1iv (deInt32 index, deInt32 count, const deInt32*) = DE_NULL;
168 virtual void uniform2iv (deInt32 index, deInt32 count, const deInt32*) = DE_NULL;
169 virtual void uniform3iv (deInt32 index, deInt32 count, const deInt32*) = DE_NULL;
170 virtual void uniform4iv (deInt32 index, deInt32 count, const deInt32*) = DE_NULL;
171 virtual void uniformMatrix3fv (deInt32 location, deInt32 count, deBool transpose, const float *value) = DE_NULL;
172 virtual void uniformMatrix4fv (deInt32 location, deInt32 count, deBool transpose, const float *value) = DE_NULL;
173 virtual deInt32 getUniformLocation (deUint32 program, const char *name) = DE_NULL;
175 virtual void lineWidth (float) = DE_NULL;
177 virtual void drawArrays (deUint32 mode, int first, int count) = DE_NULL;
178 virtual void drawArraysInstanced (deUint32 mode, int first, int count, int instanceCount) = DE_NULL;
179 virtual void drawElements (deUint32 mode, int count, deUint32 type, const void *indices) = DE_NULL;
180 virtual void drawElementsInstanced (deUint32 mode, int count, deUint32 type, const void *indices, int instanceCount) = DE_NULL;
181 virtual void drawElementsBaseVertex (deUint32 mode, int count, deUint32 type, const void *indices, int baseVertex) = DE_NULL;
182 virtual void drawElementsInstancedBaseVertex (deUint32 mode, int count, deUint32 type, const void *indices, int instanceCount, int baseVertex) = DE_NULL;
183 virtual void drawRangeElements (deUint32 mode, deUint32 start, deUint32 end, int count, deUint32 type, const void *indices) = DE_NULL;
184 virtual void drawRangeElementsBaseVertex (deUint32 mode, deUint32 start, deUint32 end, int count, deUint32 type, const void *indices, int baseVertex) = DE_NULL;
185 virtual void drawArraysIndirect (deUint32 mode, const void *indirect) = DE_NULL;
186 virtual void drawElementsIndirect (deUint32 mode, deUint32 type, const void *indirect) = DE_NULL;
188 virtual void multiDrawArrays (deUint32 mode, const int* first, const int* count, int primCount) = DE_NULL;
189 virtual void multiDrawElements (deUint32 mode, const int* count, deUint32 type, const void** indices, int primCount) = DE_NULL;
190 virtual void multiDrawElementsBaseVertex (deUint32 mode, const int* count, deUint32 type, const void** indices, int primCount, const int* baseVertex) = DE_NULL;
192 virtual deUint32 createProgram (ShaderProgram* program) = DE_NULL;
193 virtual void useProgram (deUint32 program) = DE_NULL;
194 virtual void deleteProgram (deUint32 program) = DE_NULL;
197 virtual void readPixels (int x, int y, int width, int height, deUint32 format, deUint32 type, void* data) = DE_NULL;
198 virtual deUint32 getError (void) = DE_NULL;
199 virtual void finish (void) = DE_NULL;
201 virtual void getIntegerv (deUint32 pname, int* params) = DE_NULL;
202 virtual const char* getString (deUint32 pname) = DE_NULL;
204 // Helpers implemented by Context.
205 virtual void texImage2D (deUint32 target, int level, deUint32 internalFormat, const tcu::Surface& src);
206 virtual void texImage2D (deUint32 target, int level, deUint32 internalFormat, int width, int height);
207 virtual void texSubImage2D (deUint32 target, int level, int xoffset, int yoffset, const tcu::Surface& src);
208 virtual void readPixels (tcu::Surface& dst, int x, int y, int width, int height);
210 glu::ContextType getType (void) { return m_type; }
213 const glu::ContextType m_type;
214 } DE_WARN_UNUSED_TYPE;
218 #endif // _SGLRCONTEXT_HPP