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 | |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 23 | // --------------------------------------------------------------------------- |
| 24 | namespace android { |
| 25 | namespace renderscript { |
| 26 | |
Jack Palevich | 1ef8b80 | 2009-05-28 15:53:04 -0700 | [diff] [blame] | 27 | |
Jean-Luc Brouillet | 2303748 | 2014-03-25 16:27:34 -0700 | [diff] [blame] | 28 | /** This class represents a script compiled from an .rs file. */ |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 29 | class ScriptC : public Script { |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 30 | public: |
Jason Sams | be36bf3 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 31 | typedef int (*RunScript_t)(); |
Jason Sams | 1d54f10 | 2009-09-03 15:43:13 -0700 | [diff] [blame] | 32 | typedef void (*VoidFunc_t)(); |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 33 | |
Jason Sams | e514b45 | 2009-09-25 14:51:22 -0700 | [diff] [blame] | 34 | ScriptC(Context *); |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 35 | virtual ~ScriptC(); |
| 36 | |
David Gross | 6c1876b | 2016-01-15 11:52:14 -0800 | [diff] [blame] | 37 | void Invoke(Context *rsc, uint32_t slot, const void *data, size_t len) override; |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 38 | |
Jason Sams | c61346b | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 39 | virtual uint32_t run(Context *); |
| 40 | |
David Gross | 6c1876b | 2016-01-15 11:52:14 -0800 | [diff] [blame] | 41 | void runForEach(Context *rsc, |
| 42 | uint32_t slot, |
| 43 | const Allocation ** ains, |
| 44 | size_t inLen, |
| 45 | Allocation * aout, |
| 46 | const void * usr, |
| 47 | size_t usrBytes, |
| 48 | const RsScriptCall *sc = nullptr) override; |
Chris Wailes | 4b3c34e | 2014-06-11 12:00:29 -0700 | [diff] [blame] | 49 | |
David Gross | 6c1876b | 2016-01-15 11:52:14 -0800 | [diff] [blame] | 50 | void runReduce(Context *rsc, uint32_t slot, const Allocation *ain, |
| 51 | Allocation *aout, const RsScriptCall *sc) override; |
| 52 | |
| 53 | void runReduceNew(Context *rsc, uint32_t slot, |
| 54 | const Allocation ** ains, size_t inLen, |
| 55 | Allocation *aout, const RsScriptCall *sc) override; |
Matt Wala | 14ce007 | 2015-07-30 17:30:25 -0700 | [diff] [blame] | 56 | |
Jason Sams | e3150cf | 2012-07-24 18:10:20 -0700 | [diff] [blame] | 57 | virtual void serialize(Context *rsc, OStream *stream) const { } |
Alex Sakhartchouk | b825f67 | 2010-06-04 10:06:50 -0700 | [diff] [blame] | 58 | virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_SCRIPT_C; } |
Chris Wailes | 44bef6f | 2014-08-12 13:51:10 -0700 | [diff] [blame] | 59 | static Type *createFromStream(Context *rsc, IStream *stream) { return nullptr; } |
Jason Sams | c61346b | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 60 | |
Jason Sams | bad8074 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 61 | bool runCompiler(Context *rsc, const char *resName, const char *cacheDir, |
| 62 | const uint8_t *bitcode, size_t bitcodeLen); |
| 63 | |
Jason Sams | cdfdb8f | 2011-03-17 16:12:47 -0700 | [diff] [blame] | 64 | //protected: |
Jason Sams | c61346b | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 65 | void setupScript(Context *); |
| 66 | void setupGLState(Context *); |
Stephen Hines | f6af3bd | 2014-12-23 17:47:43 -0800 | [diff] [blame] | 67 | |
| 68 | #if !defined(RS_COMPATIBILITY_LIB) |
| 69 | static bool createCacheDir(const char *cacheDir); |
| 70 | #endif |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 71 | }; |
| 72 | |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 73 | } |
| 74 | } |
| 75 | #endif |