blob: 7bb09bbf5597fb7fa4133fc585e821bcb2e8e04e [file] [log] [blame]
Jason Samse4a06c52011-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>
21
22namespace android {
23namespace renderscript {
24
25class Context;
26class ObjectBase;
27class Element;
28class Type;
29class Allocation;
30class Script;
31class ScriptC;
Alex Sakhartchouk43850542011-05-05 16:56:27 -070032class Program;
Jason Sams48f50562011-03-18 15:03:25 -070033class ProgramStore;
Jason Sams331bf9b2011-04-06 11:23:54 -070034class ProgramRaster;
Alex Sakhartchouk4a36b452011-04-29 16:49:08 -070035class ProgramVertex;
36class ProgramFragment;
37class Mesh;
Alex Sakhartchouk43850542011-05-05 16:56:27 -070038class Sampler;
Alex Sakhartchouk2f6964f2011-05-13 14:53:34 -070039class FBOCache;
Jason Samse4a06c52011-03-16 16:29:28 -070040
Jason Samse4a06c52011-03-16 16:29:28 -070041typedef void *(*RsHalSymbolLookupFunc)(void *usrptr, char const *symbolName);
42
Jason Samse4a06c52011-03-16 16:29:28 -070043/**
44 * Script management functions
45 */
46typedef struct {
Jason Sams803626f2011-04-06 17:52:23 -070047 bool (*initGraphics)(const Context *);
48 void (*shutdownGraphics)(const Context *);
Alex Sakhartchouk6c72eec2011-05-17 12:32:47 -070049 bool (*setSurface)(const Context *, uint32_t w, uint32_t h, RsNativeWindow);
Jason Sams803626f2011-04-06 17:52:23 -070050 void (*swap)(const Context *);
51
Jason Sams55d2a252011-03-17 16:12:47 -070052 void (*shutdownDriver)(Context *);
Jason Samse4a06c52011-03-16 16:29:28 -070053 void (*getVersion)(unsigned int *major, unsigned int *minor);
Jason Sams55d2a252011-03-17 16:12:47 -070054 void (*setPriority)(const Context *, int32_t priority);
Jason Samse4a06c52011-03-16 16:29:28 -070055
56
57
58 struct {
Jason Sams48f50562011-03-18 15:03:25 -070059 bool (*init)(const Context *rsc, ScriptC *s,
60 char const *resName,
61 char const *cacheDir,
62 uint8_t const *bitcode,
63 size_t bitcodeSize,
Jason Samsfcf72312011-04-20 15:09:01 -070064 uint32_t flags);
Jason Samse4a06c52011-03-16 16:29:28 -070065
Jason Sams55d2a252011-03-17 16:12:47 -070066 void (*invokeFunction)(const Context *rsc, Script *s,
Jason Samse4a06c52011-03-16 16:29:28 -070067 uint32_t slot,
68 const void *params,
69 size_t paramLength);
Jason Sams55d2a252011-03-17 16:12:47 -070070 int (*invokeRoot)(const Context *rsc, Script *s);
71 void (*invokeForEach)(const Context *rsc,
72 Script *s,
73 const Allocation * ain,
74 Allocation * aout,
75 const void * usr,
76 uint32_t usrLen,
77 const RsScriptCall *sc);
78 void (*invokeInit)(const Context *rsc, Script *s);
Jason Samse4a06c52011-03-16 16:29:28 -070079
80 void (*setGlobalVar)(const Context *rsc, const Script *s,
81 uint32_t slot,
82 void *data,
83 size_t dataLength);
84 void (*setGlobalBind)(const Context *rsc, const Script *s,
85 uint32_t slot,
86 void *data);
87 void (*setGlobalObj)(const Context *rsc, const Script *s,
88 uint32_t slot,
89 ObjectBase *data);
90
91 void (*destroy)(const Context *rsc, Script *s);
92 } script;
93
Jason Sams48f50562011-03-18 15:03:25 -070094 struct {
Jason Sams7e8aae72011-05-26 16:33:01 -070095 bool (*init)(const Context *rsc, Allocation *alloc, bool forceZero);
96 void (*destroy)(const Context *rsc, Allocation *alloc);
97
98 void (*resize)(const Context *rsc, const Allocation *alloc, const Type *newType,
99 bool zeroNew);
100 void (*syncAll)(const Context *rsc, const Allocation *alloc, RsAllocationUsageType src);
101 void (*markDirty)(const Context *rsc, const Allocation *alloc);
102
103 void (*data1D)(const Context *rsc, const Allocation *alloc,
104 uint32_t xoff, uint32_t lod, uint32_t count,
105 const void *data, uint32_t sizeBytes);
106 void (*data2D)(const Context *rsc, const Allocation *alloc,
107 uint32_t xoff, uint32_t yoff, uint32_t lod,
108 RsAllocationCubemapFace face, uint32_t w, uint32_t h,
109 const void *data, uint32_t sizeBytes);
110 void (*data3D)(const Context *rsc, const Allocation *alloc,
111 uint32_t xoff, uint32_t yoff, uint32_t zoff,
112 uint32_t lod, RsAllocationCubemapFace face,
113 uint32_t w, uint32_t h, uint32_t d, const void *data, uint32_t sizeBytes);
114
115 void (*elementData1D)(const Context *rsc, const Allocation *alloc, uint32_t x,
116 const void *data, uint32_t elementOff, uint32_t sizeBytes);
117 void (*elementData2D)(const Context *rsc, const Allocation *alloc, uint32_t x, uint32_t y,
118 const void *data, uint32_t elementOff, uint32_t sizeBytes);
119
120
121 } allocation;
122
123 struct {
Jason Sams48f50562011-03-18 15:03:25 -0700124 bool (*init)(const Context *rsc, const ProgramStore *ps);
125 void (*setActive)(const Context *rsc, const ProgramStore *ps);
126 void (*destroy)(const Context *rsc, const ProgramStore *ps);
127 } store;
128
Jason Sams331bf9b2011-04-06 11:23:54 -0700129 struct {
130 bool (*init)(const Context *rsc, const ProgramRaster *ps);
131 void (*setActive)(const Context *rsc, const ProgramRaster *ps);
132 void (*destroy)(const Context *rsc, const ProgramRaster *ps);
133 } raster;
Jason Sams48f50562011-03-18 15:03:25 -0700134
Alex Sakhartchouk4a36b452011-04-29 16:49:08 -0700135 struct {
136 bool (*init)(const Context *rsc, const ProgramVertex *pv,
137 const char* shader, uint32_t shaderLen);
138 void (*setActive)(const Context *rsc, const ProgramVertex *pv);
139 void (*destroy)(const Context *rsc, const ProgramVertex *pv);
140 } vertex;
141
142 struct {
143 bool (*init)(const Context *rsc, const ProgramFragment *pf,
144 const char* shader, uint32_t shaderLen);
145 void (*setActive)(const Context *rsc, const ProgramFragment *pf);
146 void (*destroy)(const Context *rsc, const ProgramFragment *pf);
147 } fragment;
148
149 struct {
150 bool (*init)(const Context *rsc, const Mesh *m);
151 void (*draw)(const Context *rsc, const Mesh *m, uint32_t primIndex, uint32_t start, uint32_t len);
152 void (*destroy)(const Context *rsc, const Mesh *m);
153 } mesh;
Jason Samse4a06c52011-03-16 16:29:28 -0700154
Alex Sakhartchouk43850542011-05-05 16:56:27 -0700155 struct {
156 bool (*init)(const Context *rsc, const Sampler *m);
157 void (*destroy)(const Context *rsc, const Sampler *m);
158 } sampler;
159
Alex Sakhartchouk2f6964f2011-05-13 14:53:34 -0700160 struct {
161 bool (*init)(const Context *rsc, const FBOCache *fb);
162 void (*setActive)(const Context *rsc, const FBOCache *fb);
163 void (*destroy)(const Context *rsc, const FBOCache *fb);
164 } framebuffer;
165
Jason Samse4a06c52011-03-16 16:29:28 -0700166} RsdHalFunctions;
167
Jason Samse4a06c52011-03-16 16:29:28 -0700168
169}
170}
171
172
173bool rsdHalInit(android::renderscript::Context *, uint32_t version_major, uint32_t version_minor);
174
175#endif
176