blob: 0d5b7e7b8bdf68ccde713fc4c55236502d1d625e [file] [log] [blame]
Jason Sams4b3de472011-04-06 17:52:23 -07001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef RSD_GL_H
18#define RSD_GL_H
19
20#include <rs_hal.h>
Alex Sakhartchouk7257c7e2011-05-17 12:32:47 -070021#include <EGL/egl.h>
Jason Sams4b3de472011-04-06 17:52:23 -070022
Alex Sakhartchouka04e30d2011-04-29 16:49:08 -070023class RsdShaderCache;
24class RsdVertexArrayState;
Alex Sakhartchouka9495242011-06-16 11:05:13 -070025class RsdFrameBufferObj;
Jason Sams4b3de472011-04-06 17:52:23 -070026
27typedef void (* InvokeFunc_t)(void);
28typedef void (*WorkerCallback_t)(void *usr, uint32_t idx);
29
30typedef struct RsdGLRec {
31 struct {
32 EGLint numConfigs;
33 EGLint majorVersion;
34 EGLint minorVersion;
35 EGLConfig config;
36 EGLContext context;
37 EGLSurface surface;
38 EGLSurface surfaceDefault;
39 EGLDisplay display;
40 } egl;
41
42 struct {
43 const uint8_t * vendor;
44 const uint8_t * renderer;
45 const uint8_t * version;
46 const uint8_t * extensions;
47
48 uint32_t majorVersion;
49 uint32_t minorVersion;
50
51 int32_t maxVaryingVectors;
52 int32_t maxTextureImageUnits;
53
54 int32_t maxFragmentTextureImageUnits;
55 int32_t maxFragmentUniformVectors;
56
57 int32_t maxVertexAttribs;
58 int32_t maxVertexUniformVectors;
59 int32_t maxVertexTextureUnits;
60
61 bool OES_texture_npot;
62 bool GL_IMG_texture_npot;
63 bool GL_NV_texture_npot_2D_mipmap;
64 float EXT_texture_max_aniso;
65 } gl;
66
67 ANativeWindow *wndSurface;
68 uint32_t width;
69 uint32_t height;
Alex Sakhartchouka04e30d2011-04-29 16:49:08 -070070 RsdShaderCache *shaderCache;
71 RsdVertexArrayState *vertexArrayState;
Alex Sakhartchouka9495242011-06-16 11:05:13 -070072 RsdFrameBufferObj *currentFrameBuffer;
Jason Sams4b3de472011-04-06 17:52:23 -070073} RsdGL;
74
75
76
77bool rsdGLInit(const android::renderscript::Context *rsc);
78void rsdGLShutdown(const android::renderscript::Context *rsc);
79bool rsdGLSetSurface(const android::renderscript::Context *rsc,
Alex Sakhartchouk7257c7e2011-05-17 12:32:47 -070080 uint32_t w, uint32_t h, RsNativeWindow sur);
Jason Sams4b3de472011-04-06 17:52:23 -070081void rsdGLSwap(const android::renderscript::Context *rsc);
Alex Sakhartchoukc19ff012011-05-06 14:59:45 -070082void rsdGLCheckError(const android::renderscript::Context *rsc,
83 const char *msg, bool isFatal = false);
Jason Sams4b3de472011-04-06 17:52:23 -070084
85#endif
86