blob: d2f273bc3b4181ac6637e588d74cd967d99efbb1 [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>
Jason Sams803626f2011-04-06 17:52:23 -070021#include <ui/egl/android_natives.h>
Jason Samse4a06c52011-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;
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;
Jason Samse4a06c52011-03-16 16:29:28 -070038
Jason Samse4a06c52011-03-16 16:29:28 -070039typedef void *(*RsHalSymbolLookupFunc)(void *usrptr, char const *symbolName);
40
Jason Samse4a06c52011-03-16 16:29:28 -070041/**
42 * Script management functions
43 */
44typedef struct {
Jason Sams803626f2011-04-06 17:52:23 -070045 bool (*initGraphics)(const Context *);
46 void (*shutdownGraphics)(const Context *);
47 bool (*setSurface)(const Context *, uint32_t w, uint32_t h, ANativeWindow *);
48 void (*swap)(const Context *);
49
Jason Sams55d2a252011-03-17 16:12:47 -070050 void (*shutdownDriver)(Context *);
Jason Samse4a06c52011-03-16 16:29:28 -070051 void (*getVersion)(unsigned int *major, unsigned int *minor);
Jason Sams55d2a252011-03-17 16:12:47 -070052 void (*setPriority)(const Context *, int32_t priority);
Jason Samse4a06c52011-03-16 16:29:28 -070053
54
55
56 struct {
Jason Sams48f50562011-03-18 15:03:25 -070057 bool (*init)(const Context *rsc, ScriptC *s,
58 char const *resName,
59 char const *cacheDir,
60 uint8_t const *bitcode,
61 size_t bitcodeSize,
Jason Samsfcf72312011-04-20 15:09:01 -070062 uint32_t flags);
Jason Samse4a06c52011-03-16 16:29:28 -070063
Jason Sams55d2a252011-03-17 16:12:47 -070064 void (*invokeFunction)(const Context *rsc, Script *s,
Jason Samse4a06c52011-03-16 16:29:28 -070065 uint32_t slot,
66 const void *params,
67 size_t paramLength);
Jason Sams55d2a252011-03-17 16:12:47 -070068 int (*invokeRoot)(const Context *rsc, Script *s);
69 void (*invokeForEach)(const Context *rsc,
70 Script *s,
71 const Allocation * ain,
72 Allocation * aout,
73 const void * usr,
74 uint32_t usrLen,
75 const RsScriptCall *sc);
76 void (*invokeInit)(const Context *rsc, Script *s);
Jason Samse4a06c52011-03-16 16:29:28 -070077
78 void (*setGlobalVar)(const Context *rsc, const Script *s,
79 uint32_t slot,
80 void *data,
81 size_t dataLength);
82 void (*setGlobalBind)(const Context *rsc, const Script *s,
83 uint32_t slot,
84 void *data);
85 void (*setGlobalObj)(const Context *rsc, const Script *s,
86 uint32_t slot,
87 ObjectBase *data);
88
89 void (*destroy)(const Context *rsc, Script *s);
90 } script;
91
Jason Sams48f50562011-03-18 15:03:25 -070092 struct {
93 bool (*init)(const Context *rsc, const ProgramStore *ps);
94 void (*setActive)(const Context *rsc, const ProgramStore *ps);
95 void (*destroy)(const Context *rsc, const ProgramStore *ps);
96 } store;
97
Jason Sams331bf9b2011-04-06 11:23:54 -070098 struct {
99 bool (*init)(const Context *rsc, const ProgramRaster *ps);
100 void (*setActive)(const Context *rsc, const ProgramRaster *ps);
101 void (*destroy)(const Context *rsc, const ProgramRaster *ps);
102 } raster;
Jason Sams48f50562011-03-18 15:03:25 -0700103
Alex Sakhartchouk4a36b452011-04-29 16:49:08 -0700104 struct {
105 bool (*init)(const Context *rsc, const ProgramVertex *pv,
106 const char* shader, uint32_t shaderLen);
107 void (*setActive)(const Context *rsc, const ProgramVertex *pv);
108 void (*destroy)(const Context *rsc, const ProgramVertex *pv);
109 } vertex;
110
111 struct {
112 bool (*init)(const Context *rsc, const ProgramFragment *pf,
113 const char* shader, uint32_t shaderLen);
114 void (*setActive)(const Context *rsc, const ProgramFragment *pf);
115 void (*destroy)(const Context *rsc, const ProgramFragment *pf);
116 } fragment;
117
118 struct {
119 bool (*init)(const Context *rsc, const Mesh *m);
120 void (*draw)(const Context *rsc, const Mesh *m, uint32_t primIndex, uint32_t start, uint32_t len);
121 void (*destroy)(const Context *rsc, const Mesh *m);
122 } mesh;
Jason Samse4a06c52011-03-16 16:29:28 -0700123
124} RsdHalFunctions;
125
Jason Samse4a06c52011-03-16 16:29:28 -0700126
127}
128}
129
130
131bool rsdHalInit(android::renderscript::Context *, uint32_t version_major, uint32_t version_minor);
132
133#endif
134