Jason Sams | 4b3de47 | 2011-04-06 17:52:23 -0700 | [diff] [blame] | 1 | /* |
| 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 Sakhartchouk | 7257c7e | 2011-05-17 12:32:47 -0700 | [diff] [blame] | 21 | #include <EGL/egl.h> |
Jason Sams | 4b3de47 | 2011-04-06 17:52:23 -0700 | [diff] [blame] | 22 | |
Jason Sams | 2382aba | 2011-09-13 15:41:01 -0700 | [diff] [blame] | 23 | #define RSD_CALL_GL(x, ...) rsc->setWatchdogGL(#x, __LINE__, __FILE__); x(__VA_ARGS__); rsc->setWatchdogGL(NULL, 0, NULL) |
| 24 | |
Alex Sakhartchouk | a04e30d | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 25 | class RsdShaderCache; |
| 26 | class RsdVertexArrayState; |
Alex Sakhartchouk | a949524 | 2011-06-16 11:05:13 -0700 | [diff] [blame] | 27 | class RsdFrameBufferObj; |
Jason Sams | 4b3de47 | 2011-04-06 17:52:23 -0700 | [diff] [blame] | 28 | |
| 29 | typedef void (* InvokeFunc_t)(void); |
| 30 | typedef void (*WorkerCallback_t)(void *usr, uint32_t idx); |
| 31 | |
| 32 | typedef struct RsdGLRec { |
| 33 | struct { |
| 34 | EGLint numConfigs; |
| 35 | EGLint majorVersion; |
| 36 | EGLint minorVersion; |
| 37 | EGLConfig config; |
| 38 | EGLContext context; |
| 39 | EGLSurface surface; |
| 40 | EGLSurface surfaceDefault; |
| 41 | EGLDisplay display; |
| 42 | } egl; |
| 43 | |
| 44 | struct { |
| 45 | const uint8_t * vendor; |
| 46 | const uint8_t * renderer; |
| 47 | const uint8_t * version; |
| 48 | const uint8_t * extensions; |
| 49 | |
| 50 | uint32_t majorVersion; |
| 51 | uint32_t minorVersion; |
| 52 | |
| 53 | int32_t maxVaryingVectors; |
| 54 | int32_t maxTextureImageUnits; |
| 55 | |
| 56 | int32_t maxFragmentTextureImageUnits; |
| 57 | int32_t maxFragmentUniformVectors; |
| 58 | |
| 59 | int32_t maxVertexAttribs; |
| 60 | int32_t maxVertexUniformVectors; |
| 61 | int32_t maxVertexTextureUnits; |
| 62 | |
| 63 | bool OES_texture_npot; |
Mathias Agopian | 9170275 | 2012-01-29 22:20:50 -0800 | [diff] [blame] | 64 | bool IMG_texture_npot; |
| 65 | bool NV_texture_npot_2D_mipmap; |
Jason Sams | 4b3de47 | 2011-04-06 17:52:23 -0700 | [diff] [blame] | 66 | float EXT_texture_max_aniso; |
| 67 | } gl; |
| 68 | |
| 69 | ANativeWindow *wndSurface; |
Jason Sams | b322033 | 2012-04-02 14:41:54 -0700 | [diff] [blame] | 70 | ANativeWindow *currentWndSurface; |
| 71 | |
Alex Sakhartchouk | a04e30d | 2011-04-29 16:49:08 -0700 | [diff] [blame] | 72 | RsdShaderCache *shaderCache; |
| 73 | RsdVertexArrayState *vertexArrayState; |
Alex Sakhartchouk | a949524 | 2011-06-16 11:05:13 -0700 | [diff] [blame] | 74 | RsdFrameBufferObj *currentFrameBuffer; |
Jason Sams | 4b3de47 | 2011-04-06 17:52:23 -0700 | [diff] [blame] | 75 | } RsdGL; |
| 76 | |
Jason Sams | b322033 | 2012-04-02 14:41:54 -0700 | [diff] [blame] | 77 | bool rsdGLSetInternalSurface(const android::renderscript::Context *rsc, |
| 78 | RsNativeWindow sur); |
Jason Sams | 4b3de47 | 2011-04-06 17:52:23 -0700 | [diff] [blame] | 79 | bool rsdGLInit(const android::renderscript::Context *rsc); |
| 80 | void rsdGLShutdown(const android::renderscript::Context *rsc); |
| 81 | bool rsdGLSetSurface(const android::renderscript::Context *rsc, |
Alex Sakhartchouk | 7257c7e | 2011-05-17 12:32:47 -0700 | [diff] [blame] | 82 | uint32_t w, uint32_t h, RsNativeWindow sur); |
Jason Sams | 4b3de47 | 2011-04-06 17:52:23 -0700 | [diff] [blame] | 83 | void rsdGLSwap(const android::renderscript::Context *rsc); |
Alex Sakhartchouk | c19ff01 | 2011-05-06 14:59:45 -0700 | [diff] [blame] | 84 | void rsdGLCheckError(const android::renderscript::Context *rsc, |
| 85 | const char *msg, bool isFatal = false); |
Jason Sams | 9719bd4 | 2012-01-12 14:22:21 -0800 | [diff] [blame] | 86 | void rsdGLSetPriority(const android::renderscript::Context *rsc, |
| 87 | int32_t priority); |
Alex Sakhartchouk | 653b53e | 2012-02-24 14:22:34 -0800 | [diff] [blame] | 88 | void rsdGLClearColor(const android::renderscript::Context *rsc, |
| 89 | float r, float g, float b, float a); |
| 90 | void rsdGLClearDepth(const android::renderscript::Context *rsc, float v); |
| 91 | void rsdGLFinish(const android::renderscript::Context *rsc); |
| 92 | void rsdGLDrawQuadTexCoords(const android::renderscript::Context *rsc, |
| 93 | float x1, float y1, float z1, float u1, float v1, |
| 94 | float x2, float y2, float z2, float u2, float v2, |
| 95 | float x3, float y3, float z3, float u3, float v3, |
| 96 | float x4, float y4, float z4, float u4, float v4); |
Jason Sams | 4b3de47 | 2011-04-06 17:52:23 -0700 | [diff] [blame] | 97 | |
| 98 | #endif |
| 99 | |