blob: 9d8c9061987ae4cf6135498ec641de3a3ec159ae [file] [log] [blame]
Jason Samsbad80742011-03-16 16:29:28 -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 RS_HAL_H
18#define RS_HAL_H
19
20#include <RenderScriptDefines.h>
Jason Sams4b3de472011-04-06 17:52:23 -070021#include <ui/egl/android_natives.h>
Jason Samsbad80742011-03-16 16:29:28 -070022
23namespace android {
24namespace renderscript {
25
26class Context;
27class ObjectBase;
28class Element;
29class Type;
30class Allocation;
31class Script;
32class ScriptC;
Alex Sakhartchouk7f126c72011-05-05 16:56:27 -070033class Program;
Jason Sams8feea4e2011-03-18 15:03:25 -070034class ProgramStore;
Jason Sams721acc42011-04-06 11:23:54 -070035class ProgramRaster;
Alex Sakhartchouka04e30d2011-04-29 16:49:08 -070036class ProgramVertex;
37class ProgramFragment;
38class Mesh;
Alex Sakhartchouk7f126c72011-05-05 16:56:27 -070039class Sampler;
Alex Sakhartchoukda6d34a2011-05-13 14:53:34 -070040class FBOCache;
Jason Samsbad80742011-03-16 16:29:28 -070041
Jason Samsbad80742011-03-16 16:29:28 -070042typedef void *(*RsHalSymbolLookupFunc)(void *usrptr, char const *symbolName);
43
Jason Samsbad80742011-03-16 16:29:28 -070044/**
45 * Script management functions
46 */
47typedef struct {
Jason Sams4b3de472011-04-06 17:52:23 -070048 bool (*initGraphics)(const Context *);
49 void (*shutdownGraphics)(const Context *);
Alex Sakhartchouk7257c7e2011-05-17 12:32:47 -070050 bool (*setSurface)(const Context *, uint32_t w, uint32_t h, RsNativeWindow);
Jason Sams4b3de472011-04-06 17:52:23 -070051 void (*swap)(const Context *);
52
Jason Samscdfdb8f2011-03-17 16:12:47 -070053 void (*shutdownDriver)(Context *);
Jason Samsbad80742011-03-16 16:29:28 -070054 void (*getVersion)(unsigned int *major, unsigned int *minor);
Jason Samscdfdb8f2011-03-17 16:12:47 -070055 void (*setPriority)(const Context *, int32_t priority);
Jason Samsbad80742011-03-16 16:29:28 -070056
57
58
59 struct {
Jason Sams8feea4e2011-03-18 15:03:25 -070060 bool (*init)(const Context *rsc, ScriptC *s,
61 char const *resName,
62 char const *cacheDir,
63 uint8_t const *bitcode,
64 size_t bitcodeSize,
Jason Sams87fe59a2011-04-20 15:09:01 -070065 uint32_t flags);
Jason Samsbad80742011-03-16 16:29:28 -070066
Jason Samscdfdb8f2011-03-17 16:12:47 -070067 void (*invokeFunction)(const Context *rsc, Script *s,
Jason Samsbad80742011-03-16 16:29:28 -070068 uint32_t slot,
69 const void *params,
70 size_t paramLength);
Jason Samscdfdb8f2011-03-17 16:12:47 -070071 int (*invokeRoot)(const Context *rsc, Script *s);
72 void (*invokeForEach)(const Context *rsc,
73 Script *s,
74 const Allocation * ain,
75 Allocation * aout,
76 const void * usr,
77 uint32_t usrLen,
78 const RsScriptCall *sc);
79 void (*invokeInit)(const Context *rsc, Script *s);
Jason Samsbad80742011-03-16 16:29:28 -070080
81 void (*setGlobalVar)(const Context *rsc, const Script *s,
82 uint32_t slot,
83 void *data,
84 size_t dataLength);
85 void (*setGlobalBind)(const Context *rsc, const Script *s,
86 uint32_t slot,
87 void *data);
88 void (*setGlobalObj)(const Context *rsc, const Script *s,
89 uint32_t slot,
90 ObjectBase *data);
91
92 void (*destroy)(const Context *rsc, Script *s);
93 } script;
94
Jason Sams8feea4e2011-03-18 15:03:25 -070095 struct {
96 bool (*init)(const Context *rsc, const ProgramStore *ps);
97 void (*setActive)(const Context *rsc, const ProgramStore *ps);
98 void (*destroy)(const Context *rsc, const ProgramStore *ps);
99 } store;
100
Jason Sams721acc42011-04-06 11:23:54 -0700101 struct {
102 bool (*init)(const Context *rsc, const ProgramRaster *ps);
103 void (*setActive)(const Context *rsc, const ProgramRaster *ps);
104 void (*destroy)(const Context *rsc, const ProgramRaster *ps);
105 } raster;
Jason Sams8feea4e2011-03-18 15:03:25 -0700106
Alex Sakhartchouka04e30d2011-04-29 16:49:08 -0700107 struct {
108 bool (*init)(const Context *rsc, const ProgramVertex *pv,
109 const char* shader, uint32_t shaderLen);
110 void (*setActive)(const Context *rsc, const ProgramVertex *pv);
111 void (*destroy)(const Context *rsc, const ProgramVertex *pv);
112 } vertex;
113
114 struct {
115 bool (*init)(const Context *rsc, const ProgramFragment *pf,
116 const char* shader, uint32_t shaderLen);
117 void (*setActive)(const Context *rsc, const ProgramFragment *pf);
118 void (*destroy)(const Context *rsc, const ProgramFragment *pf);
119 } fragment;
120
121 struct {
122 bool (*init)(const Context *rsc, const Mesh *m);
123 void (*draw)(const Context *rsc, const Mesh *m, uint32_t primIndex, uint32_t start, uint32_t len);
124 void (*destroy)(const Context *rsc, const Mesh *m);
125 } mesh;
Jason Samsbad80742011-03-16 16:29:28 -0700126
Alex Sakhartchouk7f126c72011-05-05 16:56:27 -0700127 struct {
128 bool (*init)(const Context *rsc, const Sampler *m);
129 void (*destroy)(const Context *rsc, const Sampler *m);
130 } sampler;
131
Alex Sakhartchoukda6d34a2011-05-13 14:53:34 -0700132 struct {
133 bool (*init)(const Context *rsc, const FBOCache *fb);
134 void (*setActive)(const Context *rsc, const FBOCache *fb);
135 void (*destroy)(const Context *rsc, const FBOCache *fb);
136 } framebuffer;
137
Jason Samsbad80742011-03-16 16:29:28 -0700138} RsdHalFunctions;
139
Jason Samsbad80742011-03-16 16:29:28 -0700140
141}
142}
143
144
145bool rsdHalInit(android::renderscript::Context *, uint32_t version_major, uint32_t version_minor);
146
147#endif
148