rs_hal.h revision a04e30dbb5ab11592b03666bb3d102070759c58e
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 RS_HAL_H
18#define RS_HAL_H
19
20#include <RenderScriptDefines.h>
21#include <ui/egl/android_natives.h>
22
23namespace android {
24namespace renderscript {
25
26class Context;
27class ObjectBase;
28class Element;
29class Type;
30class Allocation;
31class Script;
32class ScriptC;
33class ProgramStore;
34class ProgramRaster;
35class ProgramVertex;
36class ProgramFragment;
37class Mesh;
38
39typedef void *(*RsHalSymbolLookupFunc)(void *usrptr, char const *symbolName);
40
41/**
42 * Script management functions
43 */
44typedef struct {
45    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
50    void (*shutdownDriver)(Context *);
51    void (*getVersion)(unsigned int *major, unsigned int *minor);
52    void (*setPriority)(const Context *, int32_t priority);
53
54
55
56    struct {
57        bool (*init)(const Context *rsc, ScriptC *s,
58                     char const *resName,
59                     char const *cacheDir,
60                     uint8_t const *bitcode,
61                     size_t bitcodeSize,
62                     uint32_t flags);
63
64        void (*invokeFunction)(const Context *rsc, Script *s,
65                               uint32_t slot,
66                               const void *params,
67                               size_t paramLength);
68        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);
77
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
92    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
98    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;
103
104    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;
123
124} RsdHalFunctions;
125
126
127}
128}
129
130
131bool rsdHalInit(android::renderscript::Context *, uint32_t version_major, uint32_t version_minor);
132
133#endif
134
135