Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1 | /* |
Stephen Hines | 4419977 | 2012-02-21 20:13:12 -0800 | [diff] [blame] | 2 | * Copyright (C) 2009-2012 The Android Open Source Project |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 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 ANDROID_RS_SCRIPT_C_H |
| 18 | #define ANDROID_RS_SCRIPT_C_H |
| 19 | |
Jean-Luc Brouillet | 2303748 | 2014-03-25 16:27:34 -0700 | [diff] [blame] | 20 | #include "rsEnv.h" |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 21 | #include "rsScript.h" |
| 22 | |
Jean-Luc Brouillet | f4d216e | 2014-06-09 18:04:16 -0700 | [diff] [blame] | 23 | #if !defined(RS_COMPATIBILITY_LIB) && !defined(ANDROID_RS_SERIALIZE) |
Stephen Hines | cbb0b8a | 2011-08-01 15:02:34 -0700 | [diff] [blame] | 24 | #include "bcinfo/BitcodeTranslator.h" |
| 25 | #endif |
Jack Palevich | 1ef8b80 | 2009-05-28 15:53:04 -0700 | [diff] [blame] | 26 | |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 27 | // --------------------------------------------------------------------------- |
| 28 | namespace android { |
| 29 | namespace renderscript { |
| 30 | |
Jack Palevich | 1ef8b80 | 2009-05-28 15:53:04 -0700 | [diff] [blame] | 31 | |
Jean-Luc Brouillet | 2303748 | 2014-03-25 16:27:34 -0700 | [diff] [blame] | 32 | /** This class represents a script compiled from an .rs file. */ |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 33 | class ScriptC : public Script { |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 34 | public: |
Jason Sams | be36bf3 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 35 | typedef int (*RunScript_t)(); |
Jason Sams | 1d54f10 | 2009-09-03 15:43:13 -0700 | [diff] [blame] | 36 | typedef void (*VoidFunc_t)(); |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 37 | |
Jason Sams | e514b45 | 2009-09-25 14:51:22 -0700 | [diff] [blame] | 38 | ScriptC(Context *); |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 39 | virtual ~ScriptC(); |
| 40 | |
Alex Sakhartchouk | b81a0eb | 2011-06-03 10:18:01 -0700 | [diff] [blame] | 41 | virtual void Invoke(Context *rsc, uint32_t slot, const void *data, size_t len); |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 42 | |
Jason Sams | c61346b | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 43 | virtual uint32_t run(Context *); |
| 44 | |
Jason Sams | ace3e01 | 2010-07-15 17:11:13 -0700 | [diff] [blame] | 45 | virtual void runForEach(Context *rsc, |
Stephen Hines | 4419977 | 2012-02-21 20:13:12 -0800 | [diff] [blame] | 46 | uint32_t slot, |
Jason Sams | ace3e01 | 2010-07-15 17:11:13 -0700 | [diff] [blame] | 47 | const Allocation * ain, |
| 48 | Allocation * aout, |
| 49 | const void * usr, |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 50 | size_t usrBytes, |
Jason Sams | ace3e01 | 2010-07-15 17:11:13 -0700 | [diff] [blame] | 51 | const RsScriptCall *sc = NULL); |
Jason Sams | c61346b | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 52 | |
Chris Wailes | 4b3c34e | 2014-06-11 12:00:29 -0700 | [diff] [blame^] | 53 | virtual void runForEach(Context *rsc, |
| 54 | uint32_t slot, |
| 55 | const Allocation ** ains, |
| 56 | size_t inLen, |
| 57 | Allocation * aout, |
| 58 | const void * usr, |
| 59 | size_t usrBytes, |
| 60 | const RsScriptCall *sc = NULL); |
| 61 | |
Jason Sams | e3150cf | 2012-07-24 18:10:20 -0700 | [diff] [blame] | 62 | virtual void serialize(Context *rsc, OStream *stream) const { } |
Alex Sakhartchouk | b825f67 | 2010-06-04 10:06:50 -0700 | [diff] [blame] | 63 | virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_SCRIPT_C; } |
Alex Sakhartchouk | fb6b614 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 64 | static Type *createFromStream(Context *rsc, IStream *stream) { return NULL; } |
Jason Sams | c61346b | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 65 | |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 66 | bool runCompiler(Context *rsc, const char *resName, const char *cacheDir, |
| 67 | const uint8_t *bitcode, size_t bitcodeLen); |
| 68 | |
Jason Sams | cdfdb8f | 2011-03-17 16:12:47 -0700 | [diff] [blame] | 69 | //protected: |
Jason Sams | c61346b | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 70 | void setupScript(Context *); |
| 71 | void setupGLState(Context *); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 72 | private: |
Jean-Luc Brouillet | f4d216e | 2014-06-09 18:04:16 -0700 | [diff] [blame] | 73 | #if !defined(RS_COMPATIBILITY_LIB) && !defined(ANDROID_RS_SERIALIZE) |
Stephen Hines | cbb0b8a | 2011-08-01 15:02:34 -0700 | [diff] [blame] | 74 | bcinfo::BitcodeTranslator *BT; |
| 75 | #endif |
Jason Sams | 93eacc7 | 2012-12-18 14:26:57 -0800 | [diff] [blame] | 76 | |
Jean-Luc Brouillet | f4d216e | 2014-06-09 18:04:16 -0700 | [diff] [blame] | 77 | #if !defined(RS_COMPATIBILITY_LIB) |
Tim Murray | e78c14b | 2012-10-01 15:27:18 -0700 | [diff] [blame] | 78 | bool createCacheDir(const char *cacheDir); |
Jason Sams | 93eacc7 | 2012-12-18 14:26:57 -0800 | [diff] [blame] | 79 | #endif |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 80 | }; |
| 81 | |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 82 | } |
| 83 | } |
| 84 | #endif |