summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cpp/RenderScript.cpp15
-rw-r--r--cpp/RenderScript.h2
-rw-r--r--cpp/rsCppStructs.h11
-rw-r--r--cpp/rsDispatch.h2
-rw-r--r--rs.h2
-rw-r--r--rsContext.cpp15
-rw-r--r--rsContext.h2
-rw-r--r--rsDefines.h7
8 files changed, 39 insertions, 17 deletions
diff --git a/cpp/RenderScript.cpp b/cpp/RenderScript.cpp
index fb72738f..3be195f8 100644
--- a/cpp/RenderScript.cpp
+++ b/cpp/RenderScript.cpp
@@ -66,8 +66,8 @@ RS::~RS() {
}
}
-bool RS::init(bool forceCpu, bool synchronous) {
- return RS::init(RS_VERSION, forceCpu, synchronous);
+bool RS::init(uint32_t flags) {
+ return RS::init(RS_VERSION, flags);
}
static bool loadSymbols(void* handle) {
@@ -412,7 +412,7 @@ static bool loadSO(const char* filename) {
ALOGE("%s init failed!", filename);
return false;
}
- ALOGE("Successfully loaded %s", filename);
+ //ALOGE("Successfully loaded %s", filename);
return true;
}
@@ -460,7 +460,7 @@ bool RS::initDispatch(int targetApi) {
return false;
}
-bool RS::init(int targetApi, bool forceCpu, bool synchronous) {
+bool RS::init(int targetApi, uint32_t flags) {
if (initDispatch(targetApi) == false) {
ALOGE("Couldn't initialize dispatch table");
return false;
@@ -472,7 +472,12 @@ bool RS::init(int targetApi, bool forceCpu, bool synchronous) {
return false;
}
- mContext = RS::dispatch->ContextCreate(mDev, 0, targetApi, RS_CONTEXT_TYPE_NORMAL, forceCpu, synchronous);
+ if (flags >= RS_CONTEXT_MAX) {
+ ALOGE("Invalid flags passed");
+ return false;
+ }
+
+ mContext = RS::dispatch->ContextCreate(mDev, 0, targetApi, RS_CONTEXT_TYPE_NORMAL, flags);
if (mContext == 0) {
ALOGE("Context creation failed");
return false;
diff --git a/cpp/RenderScript.h b/cpp/RenderScript.h
index 8ed8d0eb..1fe7b87f 100644
--- a/cpp/RenderScript.h
+++ b/cpp/RenderScript.h
@@ -20,7 +20,7 @@
#include "rsCppStructs.h"
#ifdef RS_SERVER
-#define RS_VERSION 18
+#define RS_VERSION 19
#endif
#endif
diff --git a/cpp/rsCppStructs.h b/cpp/rsCppStructs.h
index 9ec80767..f8a14ed9 100644
--- a/cpp/rsCppStructs.h
+++ b/cpp/rsCppStructs.h
@@ -59,13 +59,20 @@ class Sampler;
RS_YUV_MAX = 3
};
+ enum RSInitFlags {
+ RS_INIT_SYNCHRONOUS = 1,
+ RS_INIT_LOW_LATENCY = 2,
+ RS_INIT_MAX = 4
+ };
+
+
class RS : public android::RSC::LightRefBase<RS> {
public:
RS();
virtual ~RS();
- bool init(bool forceCpu = false, bool synchronous = false);
+ bool init(uint32_t flags);
void setErrorHandler(ErrorHandlerFunc_t func);
ErrorHandlerFunc_t getErrorHandler() { return mErrorFunc; }
@@ -86,7 +93,7 @@ class Sampler;
static bool usingNative;
static bool initDispatch(int targetApi);
- bool init(int targetApi, bool forceCpu, bool synchronous);
+ bool init(int targetApi, uint32_t flags);
static void * threadProc(void *);
static bool gInitialized;
diff --git a/cpp/rsDispatch.h b/cpp/rsDispatch.h
index 139ef52a..6e208f95 100644
--- a/cpp/rsDispatch.h
+++ b/cpp/rsDispatch.h
@@ -26,7 +26,7 @@ typedef void (*ElementGetSubElementsFnPtr)(RsContext, RsElement, uint32_t *ids,
typedef RsDevice (*DeviceCreateFnPtr) ();
typedef void (*DeviceDestroyFnPtr) (RsDevice dev);
typedef void (*DeviceSetConfigFnPtr) (RsDevice dev, RsDeviceParam p, int32_t value);
-typedef RsContext (*ContextCreateFnPtr)(RsDevice vdev, uint32_t version, uint32_t sdkVersion, RsContextType ct, bool forceCpu, bool synchronous);
+typedef RsContext (*ContextCreateFnPtr)(RsDevice vdev, uint32_t version, uint32_t sdkVersion, RsContextType ct, uint32_t flags);
typedef void (*GetNameFnPtr)(RsContext, void * obj, const char **name);
typedef void (*ContextDestroyFnPtr) (RsContext);
diff --git a/rs.h b/rs.h
index 8a0761a2..566d9eaf 100644
--- a/rs.h
+++ b/rs.h
@@ -55,7 +55,7 @@ extern "C" {
void rsDeviceDestroy(RsDevice dev);
void rsDeviceSetConfig(RsDevice dev, RsDeviceParam p, int32_t value);
RsContext rsContextCreate(RsDevice dev, uint32_t version, uint32_t sdkVersion,
- RsContextType ct, bool forceCpu, bool synchronous);
+ RsContextType ct, uint32_t flags);
}
#include "rsgApiFuncDecl.h"
diff --git a/rsContext.cpp b/rsContext.cpp
index 04575951..65ee4d3d 100644
--- a/rsContext.cpp
+++ b/rsContext.cpp
@@ -516,12 +516,15 @@ Context::Context() {
}
Context * Context::createContext(Device *dev, const RsSurfaceConfig *sc,
- RsContextType ct, bool forceCpu,
- bool synchronous) {
+ RsContextType ct, uint32_t flags) {
Context * rsc = new Context();
- rsc->mForceCpu = forceCpu;
- rsc->mSynchronous = synchronous;
+ if (flags & RS_CONTEXT_LOW_LATENCY) {
+ rsc->mForceCpu = true;
+ }
+ if (flags & RS_CONTEXT_SYNCHRONOUS) {
+ rsc->mSynchronous = true;
+ }
rsc->mContextType = ct;
if (!rsc->initContext(dev, sc)) {
@@ -903,10 +906,10 @@ void rsi_ContextSendMessage(Context *rsc, uint32_t id, const uint8_t *data, size
}
extern "C" RsContext rsContextCreate(RsDevice vdev, uint32_t version, uint32_t sdkVersion,
- RsContextType ct, bool forceCpu, bool synchronous) {
+ RsContextType ct, uint32_t flags) {
//ALOGV("rsContextCreate dev=%p", vdev);
Device * dev = static_cast<Device *>(vdev);
- Context *rsc = Context::createContext(dev, NULL, ct, forceCpu, synchronous);
+ Context *rsc = Context::createContext(dev, NULL, ct, flags);
if (rsc) {
rsc->setTargetSdkVersion(sdkVersion);
}
diff --git a/rsContext.h b/rsContext.h
index a29313e2..1dc7c62c 100644
--- a/rsContext.h
+++ b/rsContext.h
@@ -85,7 +85,7 @@ public:
static Context * createContext(Device *, const RsSurfaceConfig *sc,
RsContextType ct = RS_CONTEXT_TYPE_NORMAL,
- bool forceCpu = false, bool synchronous = false);
+ uint32_t flags = 0);
static Context * createContextLite();
~Context();
diff --git a/rsDefines.h b/rsDefines.h
index 0287f67c..741f67b4 100644
--- a/rsDefines.h
+++ b/rsDefines.h
@@ -395,6 +395,13 @@ typedef struct {
} RsScriptCall;
+enum RsContextFlags {
+ RS_CONTEXT_SYNCHRONOUS = 1,
+ RS_CONTEXT_LOW_LATENCY = 2,
+ RS_CONTEXT_MAX = 4
+};
+
+
#ifdef __cplusplus
};
#endif