Merge "Convert renderscript from using ACC to LLVM for its compiler."
This commit is contained in:
@@ -138,16 +138,17 @@ public class RenderScript {
|
||||
native void nScriptSetClearDepth(int script, float depth);
|
||||
native void nScriptSetClearStencil(int script, int stencil);
|
||||
native void nScriptSetTimeZone(int script, byte[] timeZone);
|
||||
native void nScriptSetType(int type, boolean writable, String name, int slot);
|
||||
native void nScriptSetRoot(boolean isRoot);
|
||||
native void nScriptSetInvokable(String name, int slot);
|
||||
native void nScriptInvoke(int id, int slot);
|
||||
native void nScriptInvokeData(int id, int slot);
|
||||
native void nScriptInvokeV(int id, int slot, byte[] params);
|
||||
native void nScriptSetVarI(int id, int slot, int val);
|
||||
native void nScriptSetVarF(int id, int slot, float val);
|
||||
native void nScriptSetVarV(int id, int slot, byte[] val);
|
||||
|
||||
native void nScriptCBegin();
|
||||
native void nScriptCSetScript(byte[] script, int offset, int length);
|
||||
native int nScriptCCreate();
|
||||
native void nScriptCAddDefineI32(String name, int value);
|
||||
native void nScriptCAddDefineF(String name, float value);
|
||||
|
||||
native void nSamplerBegin();
|
||||
native void nSamplerSet(int param, int value);
|
||||
@@ -229,6 +230,13 @@ public class RenderScript {
|
||||
Element mElement_COLOR_U8_4;
|
||||
Element mElement_COLOR_F32_4;
|
||||
|
||||
Sampler mSampler_CLAMP_NEAREST;
|
||||
Sampler mSampler_CLAMP_LINEAR;
|
||||
Sampler mSampler_CLAMP_LINEAR_MIP_LINEAR;
|
||||
Sampler mSampler_WRAP_NEAREST;
|
||||
Sampler mSampler_WRAP_LINEAR;
|
||||
Sampler mSampler_WRAP_LINEAR_MIP_LINEAR;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
@@ -293,7 +301,6 @@ public class RenderScript {
|
||||
mRS.mMessageCallback.mID = msg;
|
||||
mRS.mMessageCallback.run();
|
||||
}
|
||||
//Log.d(LOG_TAG, "MessageThread msg " + msg + " v1 " + rbuf[0] + " v2 " + rbuf[1] + " v3 " +rbuf[2]);
|
||||
}
|
||||
Log.d(LOG_TAG, "MessageThread exiting.");
|
||||
}
|
||||
|
||||
@@ -51,6 +51,86 @@ public class Sampler extends BaseObj {
|
||||
mID = id;
|
||||
}
|
||||
|
||||
Sampler mSampler_CLAMP_NEAREST;
|
||||
Sampler mSampler_CLAMP_LINEAR;
|
||||
Sampler mSampler_CLAMP_LINEAR_MIP;
|
||||
Sampler mSampler_WRAP_NEAREST;
|
||||
Sampler mSampler_WRAP_LINEAR;
|
||||
Sampler mSampler_WRAP_LINEAR_MIP;
|
||||
|
||||
public static Sampler CLAMP_NEAREST(RenderScript rs) {
|
||||
if(rs.mSampler_CLAMP_NEAREST == null) {
|
||||
Builder b = new Builder(rs);
|
||||
b.setMin(Value.NEAREST);
|
||||
b.setMag(Value.NEAREST);
|
||||
b.setWrapS(Value.CLAMP);
|
||||
b.setWrapT(Value.CLAMP);
|
||||
rs.mSampler_CLAMP_NEAREST = b.create();
|
||||
}
|
||||
return rs.mSampler_CLAMP_NEAREST;
|
||||
}
|
||||
|
||||
public static Sampler CLAMP_LINEAR(RenderScript rs) {
|
||||
if(rs.mSampler_CLAMP_LINEAR == null) {
|
||||
Builder b = new Builder(rs);
|
||||
b.setMin(Value.LINEAR);
|
||||
b.setMag(Value.LINEAR);
|
||||
b.setWrapS(Value.CLAMP);
|
||||
b.setWrapT(Value.CLAMP);
|
||||
rs.mSampler_CLAMP_LINEAR = b.create();
|
||||
}
|
||||
return rs.mSampler_CLAMP_LINEAR;
|
||||
}
|
||||
|
||||
public static Sampler CLAMP_LINEAR_MIP_LINEAR(RenderScript rs) {
|
||||
if(rs.mSampler_CLAMP_LINEAR_MIP_LINEAR == null) {
|
||||
Builder b = new Builder(rs);
|
||||
b.setMin(Value.LINEAR_MIP_LINEAR);
|
||||
b.setMag(Value.LINEAR_MIP_LINEAR);
|
||||
b.setWrapS(Value.CLAMP);
|
||||
b.setWrapT(Value.CLAMP);
|
||||
rs.mSampler_CLAMP_LINEAR_MIP_LINEAR = b.create();
|
||||
}
|
||||
return rs.mSampler_CLAMP_LINEAR_MIP_LINEAR;
|
||||
}
|
||||
|
||||
public static Sampler WRAP_NEAREST(RenderScript rs) {
|
||||
if(rs.mSampler_WRAP_NEAREST == null) {
|
||||
Builder b = new Builder(rs);
|
||||
b.setMin(Value.NEAREST);
|
||||
b.setMag(Value.NEAREST);
|
||||
b.setWrapS(Value.WRAP);
|
||||
b.setWrapT(Value.WRAP);
|
||||
rs.mSampler_WRAP_NEAREST = b.create();
|
||||
}
|
||||
return rs.mSampler_WRAP_NEAREST;
|
||||
}
|
||||
|
||||
public static Sampler WRAP_LINEAR(RenderScript rs) {
|
||||
if(rs.mSampler_WRAP_LINEAR == null) {
|
||||
Builder b = new Builder(rs);
|
||||
b.setMin(Value.LINEAR);
|
||||
b.setMag(Value.LINEAR);
|
||||
b.setWrapS(Value.WRAP);
|
||||
b.setWrapT(Value.WRAP);
|
||||
rs.mSampler_WRAP_LINEAR = b.create();
|
||||
}
|
||||
return rs.mSampler_WRAP_LINEAR;
|
||||
}
|
||||
|
||||
public static Sampler WRAP_LINEAR_MIP_LINEAR(RenderScript rs) {
|
||||
if(rs.mSampler_WRAP_LINEAR_MIP_LINEAR == null) {
|
||||
Builder b = new Builder(rs);
|
||||
b.setMin(Value.LINEAR_MIP_LINEAR);
|
||||
b.setMag(Value.LINEAR_MIP_LINEAR);
|
||||
b.setWrapS(Value.WRAP);
|
||||
b.setWrapT(Value.WRAP);
|
||||
rs.mSampler_WRAP_LINEAR_MIP_LINEAR = b.create();
|
||||
}
|
||||
return rs.mSampler_WRAP_LINEAR_MIP_LINEAR;
|
||||
}
|
||||
|
||||
|
||||
public static class Builder {
|
||||
RenderScript mRS;
|
||||
Value mMin;
|
||||
|
||||
@@ -46,6 +46,15 @@ public class Script extends BaseObj {
|
||||
mRS.nScriptInvoke(mID, slot);
|
||||
}
|
||||
|
||||
protected void invokeData(int slot) {
|
||||
mRS.nScriptInvokeData(mID, slot);
|
||||
}
|
||||
|
||||
protected void invokeV(int slot, FieldPacker v) {
|
||||
mRS.nScriptInvokeV(mID, slot, v.getData());
|
||||
}
|
||||
|
||||
|
||||
Script(int id, RenderScript rs) {
|
||||
super(rs);
|
||||
mID = id;
|
||||
@@ -53,7 +62,23 @@ public class Script extends BaseObj {
|
||||
|
||||
public void bindAllocation(Allocation va, int slot) {
|
||||
mRS.validate();
|
||||
mRS.nScriptBindAllocation(mID, va.mID, slot);
|
||||
if (va != null) {
|
||||
mRS.nScriptBindAllocation(mID, va.mID, slot);
|
||||
} else {
|
||||
mRS.nScriptBindAllocation(mID, 0, slot);
|
||||
}
|
||||
}
|
||||
|
||||
public void setVar(int index, float v) {
|
||||
mRS.nScriptSetVarF(mID, index, v);
|
||||
}
|
||||
|
||||
public void setVar(int index, int v) {
|
||||
mRS.nScriptSetVarI(mID, index, v);
|
||||
}
|
||||
|
||||
public void setVar(int index, FieldPacker v) {
|
||||
mRS.nScriptSetVarV(mID, index, v.getData());
|
||||
}
|
||||
|
||||
public void setClearColor(float r, float g, float b, float a) {
|
||||
@@ -82,71 +107,10 @@ public class Script extends BaseObj {
|
||||
|
||||
public static class Builder {
|
||||
RenderScript mRS;
|
||||
boolean mIsRoot = false;
|
||||
Type[] mTypes;
|
||||
String[] mNames;
|
||||
boolean[] mWritable;
|
||||
int mInvokableCount = 0;
|
||||
Invokable[] mInvokables;
|
||||
|
||||
Builder(RenderScript rs) {
|
||||
mRS = rs;
|
||||
mTypes = new Type[MAX_SLOT];
|
||||
mNames = new String[MAX_SLOT];
|
||||
mWritable = new boolean[MAX_SLOT];
|
||||
mInvokables = new Invokable[MAX_SLOT];
|
||||
}
|
||||
|
||||
public void setType(Type t, int slot) {
|
||||
mTypes[slot] = t;
|
||||
mNames[slot] = null;
|
||||
}
|
||||
|
||||
public void setType(Type t, String name, int slot) {
|
||||
mTypes[slot] = t;
|
||||
mNames[slot] = name;
|
||||
}
|
||||
|
||||
public Invokable addInvokable(String func) {
|
||||
Invokable i = new Invokable();
|
||||
i.mName = func;
|
||||
i.mRS = mRS;
|
||||
i.mSlot = mInvokableCount;
|
||||
mInvokables[mInvokableCount++] = i;
|
||||
return i;
|
||||
}
|
||||
|
||||
public void setType(boolean writable, int slot) {
|
||||
mWritable[slot] = writable;
|
||||
}
|
||||
|
||||
void transferCreate() {
|
||||
mRS.nScriptSetRoot(mIsRoot);
|
||||
for(int ct=0; ct < mTypes.length; ct++) {
|
||||
if(mTypes[ct] != null) {
|
||||
mRS.nScriptSetType(mTypes[ct].mID, mWritable[ct], mNames[ct], ct);
|
||||
}
|
||||
}
|
||||
for(int ct=0; ct < mInvokableCount; ct++) {
|
||||
mRS.nScriptSetInvokable(mInvokables[ct].mName, ct);
|
||||
}
|
||||
}
|
||||
|
||||
void transferObject(Script s) {
|
||||
s.mIsRoot = mIsRoot;
|
||||
s.mTypes = mTypes;
|
||||
s.mInvokables = new Invokable[mInvokableCount];
|
||||
for(int ct=0; ct < mInvokableCount; ct++) {
|
||||
s.mInvokables[ct] = mInvokables[ct];
|
||||
s.mInvokables[ct].mScript = s;
|
||||
}
|
||||
s.mInvokables = null;
|
||||
}
|
||||
|
||||
public void setRoot(boolean r) {
|
||||
mIsRoot = r;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -81,8 +81,6 @@ public class ScriptC extends Script {
|
||||
public static class Builder extends Script.Builder {
|
||||
byte[] mProgram;
|
||||
int mProgramLength;
|
||||
HashMap<String,Integer> mIntDefines = new HashMap();
|
||||
HashMap<String,Float> mFloatDefines = new HashMap();
|
||||
|
||||
public Builder(RenderScript rs) {
|
||||
super(rs);
|
||||
@@ -133,66 +131,20 @@ public class ScriptC extends Script {
|
||||
|
||||
static synchronized ScriptC internalCreate(Builder b) {
|
||||
b.mRS.nScriptCBegin();
|
||||
b.transferCreate();
|
||||
|
||||
for (Entry<String,Integer> e: b.mIntDefines.entrySet()) {
|
||||
b.mRS.nScriptCAddDefineI32(e.getKey(), e.getValue().intValue());
|
||||
}
|
||||
for (Entry<String,Float> e: b.mFloatDefines.entrySet()) {
|
||||
b.mRS.nScriptCAddDefineF(e.getKey(), e.getValue().floatValue());
|
||||
}
|
||||
|
||||
android.util.Log.e("rs", "len = " + b.mProgramLength);
|
||||
b.mRS.nScriptCSetScript(b.mProgram, 0, b.mProgramLength);
|
||||
|
||||
int id = b.mRS.nScriptCCreate();
|
||||
ScriptC obj = new ScriptC(id, b.mRS);
|
||||
b.transferObject(obj);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
public void addDefine(String name, int value) {
|
||||
mIntDefines.put(name, value);
|
||||
}
|
||||
|
||||
public void addDefine(String name, float value) {
|
||||
mFloatDefines.put(name, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes the all public static final fields for a class, and adds defines
|
||||
* for them, using the name of the field as the name of the define.
|
||||
*/
|
||||
public void addDefines(Class cl) {
|
||||
addDefines(cl.getFields(), (Modifier.STATIC | Modifier.FINAL | Modifier.PUBLIC), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes the all public fields for an object, and adds defines
|
||||
* for them, using the name of the field as the name of the define.
|
||||
*/
|
||||
public void addDefines(Object o) {
|
||||
addDefines(o.getClass().getFields(), Modifier.PUBLIC, o);
|
||||
}
|
||||
|
||||
void addDefines(Field[] fields, int mask, Object o) {
|
||||
for (Field f: fields) {
|
||||
try {
|
||||
if ((f.getModifiers() & mask) == mask) {
|
||||
Class t = f.getType();
|
||||
if (t == int.class) {
|
||||
mIntDefines.put(f.getName(), f.getInt(o));
|
||||
}
|
||||
else if (t == float.class) {
|
||||
mFloatDefines.put(f.getName(), f.getFloat(o));
|
||||
}
|
||||
}
|
||||
} catch (IllegalAccessException ex) {
|
||||
// TODO: Do we want this log?
|
||||
Log.d(TAG, "addDefines skipping field " + f.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
public void addDefine(String name, int value) {}
|
||||
public void addDefine(String name, float value) {}
|
||||
public void addDefines(Class cl) {}
|
||||
public void addDefines(Object o) {}
|
||||
void addDefines(Field[] fields, int mask, Object o) {}
|
||||
|
||||
public ScriptC create() {
|
||||
return internalCreate(this);
|
||||
|
||||
@@ -853,6 +853,33 @@ nScriptBindAllocation(JNIEnv *_env, jobject _this, jint script, jint alloc, jint
|
||||
rsScriptBindAllocation(con, (RsScript)script, (RsAllocation)alloc, slot);
|
||||
}
|
||||
|
||||
static void
|
||||
nScriptSetVarI(JNIEnv *_env, jobject _this, jint script, jint slot, jint val)
|
||||
{
|
||||
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
||||
LOG_API("nScriptSetVarI, con(%p), s(%p), slot(%i), val(%i), b(%f), a(%f)", con, (void *)script, slot, val);
|
||||
rsScriptSetVarI(con, (RsScript)script, slot, val);
|
||||
}
|
||||
|
||||
static void
|
||||
nScriptSetVarF(JNIEnv *_env, jobject _this, jint script, jint slot, float val)
|
||||
{
|
||||
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
||||
LOG_API("nScriptSetVarI, con(%p), s(%p), slot(%i), val(%i), b(%f), a(%f)", con, (void *)script, slot, val);
|
||||
rsScriptSetVarF(con, (RsScript)script, slot, val);
|
||||
}
|
||||
|
||||
static void
|
||||
nScriptSetVarV(JNIEnv *_env, jobject _this, jint script, jint slot, jbyteArray data)
|
||||
{
|
||||
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
||||
LOG_API("nScriptSetVarV, con(%p), s(%p), slot(%i)", con, (void *)script, slot);
|
||||
jint len = _env->GetArrayLength(data);
|
||||
jbyte *ptr = _env->GetByteArrayElements(data, NULL);
|
||||
rsScriptSetVarV(con, (RsScript)script, slot, ptr, len);
|
||||
_env->ReleaseByteArrayElements(data, ptr, JNI_ABORT);
|
||||
}
|
||||
|
||||
static void
|
||||
nScriptSetClearColor(JNIEnv *_env, jobject _this, jint script, jfloat r, jfloat g, jfloat b, jfloat a)
|
||||
{
|
||||
@@ -894,36 +921,6 @@ nScriptSetTimeZone(JNIEnv *_env, jobject _this, jint script, jbyteArray timeZone
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
nScriptSetType(JNIEnv *_env, jobject _this, jint type, jboolean writable, jstring _str, jint slot)
|
||||
{
|
||||
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
||||
LOG_API("nScriptCAddType, con(%p), type(%p), writable(%i), slot(%i)", con, (RsType)type, writable, slot);
|
||||
const char* n = NULL;
|
||||
if (_str) {
|
||||
n = _env->GetStringUTFChars(_str, NULL);
|
||||
}
|
||||
rsScriptSetType(con, (RsType)type, slot, writable, n);
|
||||
if (n) {
|
||||
_env->ReleaseStringUTFChars(_str, n);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
nScriptSetInvoke(JNIEnv *_env, jobject _this, jstring _str, jint slot)
|
||||
{
|
||||
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
||||
LOG_API("nScriptSetInvoke, con(%p)", con);
|
||||
const char* n = NULL;
|
||||
if (_str) {
|
||||
n = _env->GetStringUTFChars(_str, NULL);
|
||||
}
|
||||
rsScriptSetInvoke(con, n, slot);
|
||||
if (n) {
|
||||
_env->ReleaseStringUTFChars(_str, n);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
nScriptInvoke(JNIEnv *_env, jobject _this, jint obj, jint slot)
|
||||
{
|
||||
@@ -932,6 +929,26 @@ nScriptInvoke(JNIEnv *_env, jobject _this, jint obj, jint slot)
|
||||
rsScriptInvoke(con, (RsScript)obj, slot);
|
||||
}
|
||||
|
||||
static void
|
||||
nScriptInvokeData(JNIEnv *_env, jobject _this, jint obj, jint slot)
|
||||
{
|
||||
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
||||
LOG_API("nScriptInvokeData, con(%p), script(%p)", con, (void *)obj);
|
||||
rsScriptInvokeData(con, (RsScript)obj, slot, 0);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
nScriptInvokeV(JNIEnv *_env, jobject _this, jint script, jint slot, jbyteArray data)
|
||||
{
|
||||
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
||||
LOG_API("nScriptInvokeV, con(%p), s(%p), slot(%i)", con, (void *)script, slot);
|
||||
jint len = _env->GetArrayLength(data);
|
||||
jbyte *ptr = _env->GetByteArrayElements(data, NULL);
|
||||
rsScriptInvokeV(con, (RsScript)script, slot, ptr, len);
|
||||
_env->ReleaseByteArrayElements(data, ptr, JNI_ABORT);
|
||||
}
|
||||
|
||||
static void
|
||||
nScriptSetRoot(JNIEnv *_env, jobject _this, jboolean isRoot)
|
||||
{
|
||||
@@ -1424,16 +1441,17 @@ static JNINativeMethod methods[] = {
|
||||
{"nScriptSetClearDepth", "(IF)V", (void*)nScriptSetClearDepth },
|
||||
{"nScriptSetClearStencil", "(II)V", (void*)nScriptSetClearStencil },
|
||||
{"nScriptSetTimeZone", "(I[B)V", (void*)nScriptSetTimeZone },
|
||||
{"nScriptSetType", "(IZLjava/lang/String;I)V", (void*)nScriptSetType },
|
||||
{"nScriptSetRoot", "(Z)V", (void*)nScriptSetRoot },
|
||||
{"nScriptSetInvokable", "(Ljava/lang/String;I)V", (void*)nScriptSetInvoke },
|
||||
{"nScriptInvoke", "(II)V", (void*)nScriptInvoke },
|
||||
{"nScriptInvokeData", "(II)V", (void*)nScriptInvokeData },
|
||||
{"nScriptInvokeV", "(II[B)V", (void*)nScriptInvokeV },
|
||||
{"nScriptSetVarI", "(III)V", (void*)nScriptSetVarI },
|
||||
{"nScriptSetVarF", "(IIF)V", (void*)nScriptSetVarF },
|
||||
{"nScriptSetVarV", "(II[B)V", (void*)nScriptSetVarV },
|
||||
|
||||
{"nScriptCBegin", "()V", (void*)nScriptCBegin },
|
||||
{"nScriptCSetScript", "([BII)V", (void*)nScriptCSetScript },
|
||||
{"nScriptCCreate", "()I", (void*)nScriptCCreate },
|
||||
{"nScriptCAddDefineI32", "(Ljava/lang/String;I)V", (void*)nScriptCAddDefineI32 },
|
||||
{"nScriptCAddDefineF", "(Ljava/lang/String;F)V", (void*)nScriptCAddDefineF },
|
||||
|
||||
{"nProgramFragmentStoreBegin", "(II)V", (void*)nProgramFragmentStoreBegin },
|
||||
{"nProgramFragmentStoreDepthFunc", "(I)V", (void*)nProgramFragmentStoreDepthFunc },
|
||||
|
||||
@@ -106,7 +106,7 @@ LOCAL_SRC_FILES:= \
|
||||
rsVertexArray.cpp
|
||||
|
||||
|
||||
LOCAL_SHARED_LIBRARIES += libcutils libutils libEGL libGLESv1_CM libGLESv2 libui libacc
|
||||
LOCAL_SHARED_LIBRARIES += libcutils libutils libEGL libGLESv1_CM libGLESv2 libui libbcc
|
||||
LOCAL_LDLIBS := -lpthread -ldl
|
||||
LOCAL_MODULE:= libRS
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
|
||||
@@ -217,8 +217,8 @@ public class FilmRS {
|
||||
|
||||
ScriptC.Builder sb = new ScriptC.Builder(mRS);
|
||||
sb.setScript(mRes, R.raw.filmstrip);
|
||||
sb.setRoot(true);
|
||||
sb.setType(mStripPositionType, "Pos", 1);
|
||||
//sb.setRoot(true);
|
||||
//sb.setType(mStripPositionType, "Pos", 1);
|
||||
mScriptStrip = sb.create();
|
||||
mScriptStrip.setClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
// Fountain test script
|
||||
#pragma version(1)
|
||||
|
||||
int newPart = 0;
|
||||
|
||||
int main(int launchID) {
|
||||
int ct;
|
||||
int count = Control->count;
|
||||
int rate = Control->rate;
|
||||
float height = getHeight();
|
||||
struct point_s * p = (struct point_s *)point;
|
||||
|
||||
if (rate) {
|
||||
float rMax = ((float)rate) * 0.005f;
|
||||
int x = Control->x;
|
||||
int y = Control->y;
|
||||
int color = ((int)(Control->r * 255.f)) |
|
||||
((int)(Control->g * 255.f)) << 8 |
|
||||
((int)(Control->b * 255.f)) << 16 |
|
||||
(0xf0 << 24);
|
||||
struct point_s * np = &p[newPart];
|
||||
|
||||
while (rate--) {
|
||||
vec2Rand((float *)&np->delta.x, rMax);
|
||||
np->position.x = x;
|
||||
np->position.y = y;
|
||||
np->color = color;
|
||||
newPart++;
|
||||
np++;
|
||||
if (newPart >= count) {
|
||||
newPart = 0;
|
||||
np = &p[newPart];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (ct=0; ct < count; ct++) {
|
||||
float dy = p->delta.y + 0.15f;
|
||||
float posy = p->position.y + dy;
|
||||
if ((posy > height) && (dy > 0)) {
|
||||
dy *= -0.3f;
|
||||
}
|
||||
p->delta.y = dy;
|
||||
p->position.x += p->delta.x;
|
||||
p->position.y = posy;
|
||||
p++;
|
||||
}
|
||||
|
||||
uploadToBufferObject(NAMED_PartBuffer);
|
||||
drawSimpleMesh(NAMED_PartMesh);
|
||||
return 1;
|
||||
}
|
||||
69
libs/rs/java/Fountain/res/raw/fountain.rs
Normal file
69
libs/rs/java/Fountain/res/raw/fountain.rs
Normal file
@@ -0,0 +1,69 @@
|
||||
// Fountain test script
|
||||
#pragma version(1)
|
||||
|
||||
#include "../../../../scriptc/rs_types.rsh"
|
||||
#include "../../../../scriptc/rs_math.rsh"
|
||||
#include "../../../../scriptc/rs_graphics.rsh"
|
||||
|
||||
static int newPart = 0;
|
||||
|
||||
float4 partColor;
|
||||
rs_mesh partMesh;
|
||||
rs_allocation partBuffer;
|
||||
|
||||
typedef struct __attribute__((packed, aligned(4))) Point_s {
|
||||
float2 delta;
|
||||
rs_position2 pos;
|
||||
rs_color4u color;
|
||||
} Point_t;
|
||||
Point_t *point;
|
||||
|
||||
#pragma rs export_var(point, partColor, partMesh, partBuffer)
|
||||
//#pragma rs export_type(Point_s)
|
||||
//#pragma rs export_element(point)
|
||||
|
||||
int root() {
|
||||
debugPf(1, partColor.x);
|
||||
debugPi(4, partMesh);
|
||||
debugPi(5, partBuffer);
|
||||
|
||||
float height = getHeight();
|
||||
int size = allocGetDimX(partBuffer);
|
||||
|
||||
Point_t * p = point;
|
||||
for (int ct=0; ct < size; ct++) {
|
||||
p->delta.y += 0.15f;
|
||||
p->pos += p->delta;
|
||||
if ((p->pos.y > height) && (p->delta.y > 0)) {
|
||||
p->delta.y *= -0.3f;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
|
||||
uploadToBufferObject(partBuffer);
|
||||
drawSimpleMesh(partMesh);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void addParticles(int rate, int x, int y)
|
||||
{
|
||||
float rMax = ((float)rate) * 0.005f;
|
||||
int size = allocGetDimX(partBuffer);
|
||||
|
||||
rs_color4u c = convertColorTo8888(partColor.x, partColor.y, partColor.z);
|
||||
Point_t * np = &point[newPart];
|
||||
|
||||
float2 p = {x, y};
|
||||
while (rate--) {
|
||||
np->delta = vec2Rand(rMax);
|
||||
np->pos = p;
|
||||
np->color = c;
|
||||
newPart++;
|
||||
np++;
|
||||
if (newPart >= size) {
|
||||
newPart = 0;
|
||||
np = &point[newPart];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
// Fountain test script
|
||||
#pragma version(1)
|
||||
|
||||
#include "../../../../scriptc/rs_types.rsh"
|
||||
#include "../../../../scriptc/rs_math.rsh"
|
||||
#include "../../../../scriptc/rs_graphics.rsh"
|
||||
|
||||
static int newPart = 0;
|
||||
|
||||
typedef struct Control_s {
|
||||
int x, y;
|
||||
int rate;
|
||||
int count;
|
||||
float r, g, b;
|
||||
rs_mesh partMesh;
|
||||
rs_allocation partBuffer;
|
||||
} Control_t;
|
||||
Control_t *Control;
|
||||
|
||||
typedef struct Point_s{
|
||||
float2 delta;
|
||||
rs_position2 pos;
|
||||
rs_color4u color;
|
||||
} Point_t;
|
||||
Point_t *point;
|
||||
|
||||
int main(int launchID) {
|
||||
int ct;
|
||||
int count = Control->count;
|
||||
int rate = Control->rate;
|
||||
float height = getHeight();
|
||||
Point_t * p = point;
|
||||
|
||||
if (rate) {
|
||||
float rMax = ((float)rate) * 0.005f;
|
||||
int color = ((int)(Control->r * 255.f)) |
|
||||
((int)(Control->g * 255.f)) << 8 |
|
||||
((int)(Control->b * 255.f)) << 16 |
|
||||
(0xf0 << 24);
|
||||
Point_t * np = &p[newPart];
|
||||
|
||||
while (rate--) {
|
||||
np->delta.x = rand(rMax);
|
||||
np->delta.y = rand(rMax);
|
||||
//np->delta = vec2Rand(rMax);
|
||||
np->pos.x = Control->x;
|
||||
np->pos.y = Control->y;
|
||||
np->color = color;
|
||||
newPart++;
|
||||
np++;
|
||||
if (newPart >= count) {
|
||||
newPart = 0;
|
||||
np = &p[newPart];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (ct=0; ct < count; ct++) {
|
||||
float dy = p->delta.y + 0.15f;
|
||||
float posy = p->pos.y + dy;
|
||||
if ((posy > height) && (dy > 0)) {
|
||||
dy *= -0.3f;
|
||||
}
|
||||
p->delta.y = dy;
|
||||
p->pos.x += p->delta.x;
|
||||
p->pos.y = posy;
|
||||
p++;
|
||||
}
|
||||
|
||||
uploadToBufferObject(Control->partBuffer);
|
||||
drawSimpleMesh(Control->partMesh);
|
||||
return 1;
|
||||
}
|
||||
BIN
libs/rs/java/Fountain/res/raw/fountain_bc.bc
Normal file
BIN
libs/rs/java/Fountain/res/raw/fountain_bc.bc
Normal file
Binary file not shown.
@@ -24,16 +24,6 @@ import android.util.Log;
|
||||
public class FountainRS {
|
||||
public static final int PART_COUNT = 20000;
|
||||
|
||||
static class SomeData {
|
||||
public int x;
|
||||
public int y;
|
||||
public int rate;
|
||||
public int count;
|
||||
public float r;
|
||||
public float g;
|
||||
public float b;
|
||||
}
|
||||
|
||||
public FountainRS() {
|
||||
}
|
||||
|
||||
@@ -43,21 +33,28 @@ public class FountainRS {
|
||||
initRS();
|
||||
}
|
||||
|
||||
Float4 tmpColor = new Float4();
|
||||
boolean holdingColor = false;
|
||||
public void newTouchPosition(int x, int y, int rate) {
|
||||
if (mSD.rate == 0) {
|
||||
mSD.r = ((x & 0x1) != 0) ? 0.f : 1.f;
|
||||
mSD.g = ((x & 0x2) != 0) ? 0.f : 1.f;
|
||||
mSD.b = ((x & 0x4) != 0) ? 0.f : 1.f;
|
||||
if ((mSD.r + mSD.g + mSD.b) < 0.9f) {
|
||||
mSD.r = 0.8f;
|
||||
mSD.g = 0.5f;
|
||||
mSD.b = 1.f;
|
||||
if (rate > 0) {
|
||||
if (true/*!holdingColor*/) {
|
||||
tmpColor.x = ((x & 0x1) != 0) ? 0.f : 1.f;
|
||||
tmpColor.y = ((x & 0x2) != 0) ? 0.f : 1.f;
|
||||
tmpColor.z = ((x & 0x4) != 0) ? 0.f : 1.f;
|
||||
if ((tmpColor.x + tmpColor.y + tmpColor.z) < 0.9f) {
|
||||
tmpColor.x = 0.8f;
|
||||
tmpColor.y = 0.5f;
|
||||
tmpColor.z = 1.0f;
|
||||
}
|
||||
android.util.Log.e("rs", "set color " + tmpColor.x + ", " + tmpColor.y + ", " + tmpColor.z);
|
||||
mScript.set_partColor(tmpColor);
|
||||
}
|
||||
mScript.invokable_addParticles(rate, x, y);
|
||||
holdingColor = true;
|
||||
} else {
|
||||
holdingColor = false;
|
||||
}
|
||||
mSD.rate = rate;
|
||||
mSD.x = x;
|
||||
mSD.y = y;
|
||||
mIntAlloc.data(mSD);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -65,49 +62,26 @@ public class FountainRS {
|
||||
|
||||
private Resources mRes;
|
||||
|
||||
private ScriptField_Point mPoints;
|
||||
private ScriptC_Fountain mScript;
|
||||
private RenderScriptGL mRS;
|
||||
private Allocation mIntAlloc;
|
||||
private SimpleMesh mSM;
|
||||
private SomeData mSD;
|
||||
private Type mSDType;
|
||||
|
||||
private void initRS() {
|
||||
mSD = new SomeData();
|
||||
mSDType = Type.createFromClass(mRS, SomeData.class, 1, "SomeData");
|
||||
mIntAlloc = Allocation.createTyped(mRS, mSDType);
|
||||
mSD.count = PART_COUNT;
|
||||
mIntAlloc.data(mSD);
|
||||
|
||||
Element.Builder eb = new Element.Builder(mRS);
|
||||
eb.add(Element.createVector(mRS, Element.DataType.FLOAT_32, 2), "delta");
|
||||
eb.add(Element.createAttrib(mRS, Element.DataType.FLOAT_32, Element.DataKind.POSITION, 2), "position");
|
||||
eb.add(Element.createAttrib(mRS, Element.DataType.UNSIGNED_8, Element.DataKind.COLOR, 4), "color");
|
||||
Element primElement = eb.create();
|
||||
|
||||
mPoints = new ScriptField_Point(mRS, PART_COUNT);
|
||||
|
||||
SimpleMesh.Builder smb = new SimpleMesh.Builder(mRS);
|
||||
int vtxSlot = smb.addVertexType(primElement, PART_COUNT);
|
||||
int vtxSlot = smb.addVertexType(mPoints.getType());
|
||||
smb.setPrimitive(Primitive.POINT);
|
||||
mSM = smb.create();
|
||||
mSM.setName("PartMesh");
|
||||
mSM.bindVertexAllocation(mPoints.getAllocation(), vtxSlot);
|
||||
|
||||
Allocation partAlloc = mSM.createVertexAllocation(vtxSlot);
|
||||
partAlloc.setName("PartBuffer");
|
||||
mSM.bindVertexAllocation(partAlloc, 0);
|
||||
|
||||
// All setup of named objects should be done by this point
|
||||
// because we are about to compile the script.
|
||||
ScriptC.Builder sb = new ScriptC.Builder(mRS);
|
||||
sb.setScript(mRes, R.raw.fountain);
|
||||
sb.setRoot(true);
|
||||
sb.setType(mSDType, "Control", 0);
|
||||
sb.setType(mSM.getVertexType(0), "point", 1);
|
||||
Script script = sb.create();
|
||||
script.setClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
script.bindAllocation(mIntAlloc, 0);
|
||||
script.bindAllocation(partAlloc, 1);
|
||||
mRS.contextBindRootScript(script);
|
||||
mScript = new ScriptC_Fountain(mRS, mRes, true);
|
||||
mScript.setClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
mScript.set_partMesh(mSM);
|
||||
mScript.set_partBuffer(mPoints.getAllocation());
|
||||
mScript.bind_point(mPoints);
|
||||
mRS.contextBindRootScript(mScript);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
|
||||
package com.android.fountain;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.renderscript.*;
|
||||
import android.util.Log;
|
||||
|
||||
public class ScriptC_Fountain
|
||||
extends android.renderscript.ScriptC
|
||||
{
|
||||
public ScriptC_Fountain(RenderScript rs, Resources resources, boolean isRoot) {
|
||||
super(rs, resources, R.raw.fountain_bc, isRoot);
|
||||
}
|
||||
|
||||
public void set_partColor(Float4 v) {
|
||||
FieldPacker fp = new FieldPacker(16);
|
||||
fp.addF32(v);
|
||||
setVar(0, fp);
|
||||
}
|
||||
public void set_partMesh(SimpleMesh v) {
|
||||
setVar(1, v.getID());
|
||||
}
|
||||
public void set_partBuffer(Allocation v) {
|
||||
setVar(2, v.getID());
|
||||
}
|
||||
|
||||
private ScriptField_Point mField_point;
|
||||
public void bind_point(ScriptField_Point f) {
|
||||
mField_point = f;
|
||||
if (f == null) {
|
||||
bindAllocation(null, 3);
|
||||
} else {
|
||||
bindAllocation(f.getAllocation(), 3);
|
||||
}
|
||||
}
|
||||
public ScriptField_Point get_point() {
|
||||
return mField_point;
|
||||
}
|
||||
|
||||
|
||||
public void invokable_addParticles(int count, int x, int y) {
|
||||
FieldPacker fp = new FieldPacker(12);
|
||||
fp.addI32(count);
|
||||
fp.addI32(x);
|
||||
fp.addI32(y);
|
||||
invokeV(0, fp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
|
||||
package com.android.fountain;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.renderscript.*;
|
||||
import android.util.Log;
|
||||
|
||||
public class ScriptField_Point
|
||||
extends android.renderscript.Script.FieldBase
|
||||
{
|
||||
|
||||
static public class Item {
|
||||
Item() {
|
||||
delta = new Float2();
|
||||
pos = new Float2();
|
||||
color = new Short4();
|
||||
}
|
||||
|
||||
public static final int sizeof = (5*4);
|
||||
Float2 delta;
|
||||
Float2 pos;
|
||||
Short4 color;
|
||||
}
|
||||
private Item mItemArray[];
|
||||
|
||||
|
||||
public ScriptField_Point(RenderScript rs, int count) {
|
||||
// Allocate a pack/unpack buffer
|
||||
mIOBuffer = new FieldPacker(Item.sizeof * count);
|
||||
mItemArray = new Item[count];
|
||||
|
||||
Element.Builder eb = new Element.Builder(rs);
|
||||
eb.add(Element.createVector(rs, Element.DataType.FLOAT_32, 2), "delta");
|
||||
eb.add(Element.createAttrib(rs, Element.DataType.FLOAT_32, Element.DataKind.POSITION, 2), "pos");
|
||||
eb.add(Element.createAttrib(rs, Element.DataType.UNSIGNED_8, Element.DataKind.COLOR, 4), "color");
|
||||
mElement = eb.create();
|
||||
|
||||
init(rs, count);
|
||||
}
|
||||
|
||||
private void copyToArray(Item i, int index) {
|
||||
mIOBuffer.reset(index * Item.sizeof);
|
||||
mIOBuffer.addF32(i.delta);
|
||||
mIOBuffer.addF32(i.pos);
|
||||
mIOBuffer.addU8(i.color);
|
||||
}
|
||||
|
||||
public void set(Item i, int index, boolean copyNow) {
|
||||
mItemArray[index] = i;
|
||||
if (copyNow) {
|
||||
copyToArray(i, index);
|
||||
mAllocation.subData1D(index * Item.sizeof, Item.sizeof, mIOBuffer.getData());
|
||||
}
|
||||
}
|
||||
|
||||
public void copyAll() {
|
||||
for (int ct=0; ct < mItemArray.length; ct++) {
|
||||
copyToArray(mItemArray[ct], ct);
|
||||
}
|
||||
mAllocation.data(mIOBuffer.getData());
|
||||
}
|
||||
|
||||
|
||||
private FieldPacker mIOBuffer;
|
||||
|
||||
|
||||
}
|
||||
@@ -1,62 +1,49 @@
|
||||
/*
|
||||
// block of defines matching what RS will insert at runtime.
|
||||
struct Params_s{
|
||||
int inHeight;
|
||||
int inWidth;
|
||||
int outHeight;
|
||||
int outWidth;
|
||||
float threshold;
|
||||
};
|
||||
struct Params_s * Params;
|
||||
struct InPixel_s{
|
||||
char a;
|
||||
char b;
|
||||
char g;
|
||||
char r;
|
||||
};
|
||||
struct InPixel_s * InPixel;
|
||||
struct OutPixel_s{
|
||||
char a;
|
||||
char b;
|
||||
char g;
|
||||
char r;
|
||||
};
|
||||
struct OutPixel_s * OutPixel;
|
||||
*/
|
||||
#pragma version(1)
|
||||
|
||||
struct color_s {
|
||||
char b;
|
||||
char g;
|
||||
char r;
|
||||
char a;
|
||||
};
|
||||
#include "../../../../scriptc/rs_types.rsh"
|
||||
#include "../../../../scriptc/rs_math.rsh"
|
||||
#include "../../../../scriptc/rs_graphics.rsh"
|
||||
|
||||
void main() {
|
||||
int t = uptimeMillis();
|
||||
int height;
|
||||
int width;
|
||||
float threshold;
|
||||
|
||||
struct color_s *in = (struct color_s *) InPixel;
|
||||
struct color_s *out = (struct color_s *) OutPixel;
|
||||
typedef struct c4u_s {
|
||||
char r, g, b, a;
|
||||
} c4u_t;
|
||||
|
||||
int count = Params->inWidth * Params->inHeight;
|
||||
int i;
|
||||
float threshold = (Params->threshold * 255.f);
|
||||
//rs_color4u * InPixel;
|
||||
//rs_color4u * OutPixel;
|
||||
c4u_t * InPixel;
|
||||
c4u_t * OutPixel;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
float luminance = 0.2125f * in->r +
|
||||
0.7154f * in->g +
|
||||
0.0721f * in->b;
|
||||
if (luminance > threshold) {
|
||||
*out = *in;
|
||||
} else {
|
||||
*((int *)out) = *((int *)in) & 0xff000000;
|
||||
}
|
||||
#pragma rs export_var(height, width, threshold, InPixel, OutPixel)
|
||||
|
||||
void filter() {
|
||||
debugP(0, (void *)height);
|
||||
debugP(0, (void *)width);
|
||||
debugP(0, (void *)((int)threshold));
|
||||
debugP(0, (void *)InPixel);
|
||||
debugP(0, (void *)OutPixel);
|
||||
|
||||
rs_color4u *in = (rs_color4u *)InPixel;
|
||||
rs_color4u *out = (rs_color4u *)OutPixel;
|
||||
//const rs_color4u mask = {0,0,0,0xff};
|
||||
|
||||
int count = width * height;
|
||||
int tf = threshold * 255 * 255;
|
||||
int masks[2] = {0xffffffff, 0xff000000};
|
||||
|
||||
while (count--) {
|
||||
int luminance = 54 * in->x +
|
||||
182 * in->y +
|
||||
18 * in->z;
|
||||
int idx = ((uint32_t)(luminance - tf)) >> 31;
|
||||
*((int *)out) = *((int *)in) & masks[idx];
|
||||
in++;
|
||||
out++;
|
||||
}
|
||||
|
||||
t= uptimeMillis() - t;
|
||||
debugI32("Filter time", t);
|
||||
|
||||
sendToClient(&count, 1, 4, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
#pragma version(1)
|
||||
|
||||
#include "../../../../scriptc/rs_types.rsh"
|
||||
#include "../../../../scriptc/rs_math.rsh"
|
||||
#include "../../../../scriptc/rs_graphics.rsh"
|
||||
|
||||
typedef struct Params_s{
|
||||
int inHeight;
|
||||
int inWidth;
|
||||
int outHeight;
|
||||
int outWidth;
|
||||
float threshold;
|
||||
} Params_t;
|
||||
|
||||
Params_t * Params;
|
||||
rs_color4u * InPixel;
|
||||
rs_color4u * OutPixel;
|
||||
|
||||
|
||||
int main() {
|
||||
int t = uptimeMillis();
|
||||
|
||||
rs_color4u *in = InPixel;
|
||||
rs_color4u *out = OutPixel;
|
||||
|
||||
int count = Params->inWidth * Params->inHeight;
|
||||
int i;
|
||||
float threshold = Params->threshold * 255.f;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
float luminance = 0.2125f * in->x +
|
||||
0.7154f * in->y +
|
||||
0.0721f * in->z;
|
||||
if (luminance > threshold) {
|
||||
*out = *in;
|
||||
} else {
|
||||
*((int *)out) = *((int *)in) & 0xff000000;
|
||||
}
|
||||
|
||||
in++;
|
||||
out++;
|
||||
}
|
||||
|
||||
t= uptimeMillis() - t;
|
||||
debugI32("Filter time", t);
|
||||
|
||||
sendToClient(&count, 1, 4, 0);
|
||||
return 0;
|
||||
}
|
||||
BIN
libs/rs/java/ImageProcessing/res/raw/threshold_bc.bc
Normal file
BIN
libs/rs/java/ImageProcessing/res/raw/threshold_bc.bc
Normal file
Binary file not shown.
@@ -34,19 +34,14 @@ import android.widget.SeekBar;
|
||||
import java.lang.Math;
|
||||
|
||||
public class ImageProcessingActivity extends Activity implements SurfaceHolder.Callback {
|
||||
private Bitmap mBitmap;
|
||||
private Params mParams;
|
||||
private Script.Invokable mInvokable;
|
||||
private int[] mInData;
|
||||
private int[] mOutData;
|
||||
private Bitmap mBitmapIn;
|
||||
private Bitmap mBitmapOut;
|
||||
private ScriptC_Threshold mScript;
|
||||
private float mThreshold = 0.5f;
|
||||
|
||||
@SuppressWarnings({"FieldCanBeLocal"})
|
||||
private RenderScript mRS;
|
||||
@SuppressWarnings({"FieldCanBeLocal"})
|
||||
private Type mParamsType;
|
||||
@SuppressWarnings({"FieldCanBeLocal"})
|
||||
private Allocation mParamsAllocation;
|
||||
@SuppressWarnings({"FieldCanBeLocal"})
|
||||
private Type mPixelType;
|
||||
@SuppressWarnings({"FieldCanBeLocal"})
|
||||
private Allocation mInPixelsAllocation;
|
||||
@@ -56,28 +51,9 @@ public class ImageProcessingActivity extends Activity implements SurfaceHolder.C
|
||||
private SurfaceView mSurfaceView;
|
||||
private ImageView mDisplayView;
|
||||
|
||||
static class Params {
|
||||
public int inWidth;
|
||||
public int outWidth;
|
||||
public int inHeight;
|
||||
public int outHeight;
|
||||
|
||||
public float threshold;
|
||||
}
|
||||
|
||||
static class Pixel {
|
||||
public byte a;
|
||||
public byte r;
|
||||
public byte g;
|
||||
public byte b;
|
||||
}
|
||||
|
||||
class FilterCallback extends RenderScript.RSMessage {
|
||||
private Runnable mAction = new Runnable() {
|
||||
public void run() {
|
||||
mOutPixelsAllocation.readData(mOutData);
|
||||
mBitmap.setPixels(mOutData, 0, mParams.outWidth, 0, 0,
|
||||
mParams.outWidth, mParams.outHeight);
|
||||
mDisplayView.invalidate();
|
||||
}
|
||||
};
|
||||
@@ -89,29 +65,35 @@ public class ImageProcessingActivity extends Activity implements SurfaceHolder.C
|
||||
}
|
||||
}
|
||||
|
||||
int in[];
|
||||
int out[];
|
||||
private void javaFilter() {
|
||||
long t = java.lang.System.currentTimeMillis();
|
||||
int count = mParams.inWidth * mParams.inHeight;
|
||||
float threshold = mParams.threshold * 255.f;
|
||||
final int w = mBitmapIn.getWidth();
|
||||
final int h = mBitmapIn.getHeight();
|
||||
final int count = w * h;
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
final float r = (float)((mInData[i] >> 0) & 0xff);
|
||||
final float g = (float)((mInData[i] >> 8) & 0xff);
|
||||
final float b = (float)((mInData[i] >> 16) & 0xff);
|
||||
|
||||
final float luminance = 0.2125f * r +
|
||||
0.7154f * g +
|
||||
0.0721f * b;
|
||||
if (luminance > threshold) {
|
||||
mOutData[i] = mInData[i];
|
||||
} else {
|
||||
mOutData[i] = mInData[i] & 0xff000000;
|
||||
}
|
||||
if (in == null) {
|
||||
in = new int[count];
|
||||
out = new int[count];
|
||||
mBitmapIn.getPixels(in, 0, w, 0, 0, w, h);
|
||||
}
|
||||
|
||||
t = java.lang.System.currentTimeMillis() - t;
|
||||
int threshold = (int)(mThreshold * 255.f) * 255;
|
||||
//long t = java.lang.System.currentTimeMillis();
|
||||
|
||||
android.util.Log.v("Img", "frame time ms " + t);
|
||||
for (int i = 0; i < count; i++) {
|
||||
final int luminance = 54 * ((in[i] >> 0) & 0xff) +
|
||||
182* ((in[i] >> 8) & 0xff) +
|
||||
18 * ((in[i] >> 16) & 0xff);
|
||||
if (luminance > threshold) {
|
||||
out[i] = in[i];
|
||||
} else {
|
||||
out[i] = in[i] & 0xff000000;
|
||||
}
|
||||
}
|
||||
//t = java.lang.System.currentTimeMillis() - t;
|
||||
//android.util.Log.v("Img", "frame time ms " + t);
|
||||
mBitmapOut.setPixels(out, 0, w, 0, 0, w, h);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -119,29 +101,31 @@ public class ImageProcessingActivity extends Activity implements SurfaceHolder.C
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.main);
|
||||
|
||||
mBitmap = loadBitmap(R.drawable.data);
|
||||
mBitmapIn = loadBitmap(R.drawable.data);
|
||||
mBitmapOut = loadBitmap(R.drawable.data);
|
||||
|
||||
mSurfaceView = (SurfaceView) findViewById(R.id.surface);
|
||||
mSurfaceView.getHolder().addCallback(this);
|
||||
|
||||
mDisplayView = (ImageView) findViewById(R.id.display);
|
||||
mDisplayView.setImageBitmap(mBitmap);
|
||||
mDisplayView.setImageBitmap(mBitmapOut);
|
||||
|
||||
((SeekBar) findViewById(R.id.threshold)).setOnSeekBarChangeListener(
|
||||
new SeekBar.OnSeekBarChangeListener() {
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
if (fromUser) {
|
||||
mParams.threshold = progress / 100.0f;
|
||||
mParamsAllocation.data(mParams);
|
||||
mThreshold = progress / 100.0f;
|
||||
mScript.set_threshold(mThreshold);
|
||||
|
||||
long t = java.lang.System.currentTimeMillis();
|
||||
if (true) {
|
||||
mInvokable.execute();
|
||||
mScript.invokable_Filter();
|
||||
} else {
|
||||
javaFilter();
|
||||
mBitmap.setPixels(mOutData, 0, mParams.outWidth, 0, 0,
|
||||
mParams.outWidth, mParams.outHeight);
|
||||
mDisplayView.invalidate();
|
||||
}
|
||||
t = java.lang.System.currentTimeMillis() - t;
|
||||
android.util.Log.v("Img", "frame time core ms " + t);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,10 +138,8 @@ public class ImageProcessingActivity extends Activity implements SurfaceHolder.C
|
||||
}
|
||||
|
||||
public void surfaceCreated(SurfaceHolder holder) {
|
||||
mParams = createParams();
|
||||
mInvokable = createScript();
|
||||
|
||||
mInvokable.execute();
|
||||
createScript();
|
||||
mScript.invokable_Filter();
|
||||
}
|
||||
|
||||
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
|
||||
@@ -166,54 +148,19 @@ public class ImageProcessingActivity extends Activity implements SurfaceHolder.C
|
||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||
}
|
||||
|
||||
private Script.Invokable createScript() {
|
||||
private void createScript() {
|
||||
mRS = RenderScript.create();
|
||||
mRS.mMessageCallback = new FilterCallback();
|
||||
|
||||
mParamsType = Type.createFromClass(mRS, Params.class, 1, "Parameters");
|
||||
mParamsAllocation = Allocation.createTyped(mRS, mParamsType);
|
||||
mParamsAllocation.data(mParams);
|
||||
mInPixelsAllocation = Allocation.createBitmapRef(mRS, mBitmapIn);
|
||||
mOutPixelsAllocation = Allocation.createBitmapRef(mRS, mBitmapOut);
|
||||
|
||||
final int pixelCount = mParams.inWidth * mParams.inHeight;
|
||||
|
||||
mPixelType = Type.createFromClass(mRS, Pixel.class, 1, "Pixel");
|
||||
mInPixelsAllocation = Allocation.createSized(mRS,
|
||||
Element.createUser(mRS, Element.DataType.SIGNED_32),
|
||||
pixelCount);
|
||||
mOutPixelsAllocation = Allocation.createSized(mRS,
|
||||
Element.createUser(mRS, Element.DataType.SIGNED_32),
|
||||
pixelCount);
|
||||
|
||||
mInData = new int[pixelCount];
|
||||
mBitmap.getPixels(mInData, 0, mParams.inWidth, 0, 0, mParams.inWidth, mParams.inHeight);
|
||||
mInPixelsAllocation.data(mInData);
|
||||
|
||||
mOutData = new int[pixelCount];
|
||||
mOutPixelsAllocation.data(mOutData);
|
||||
|
||||
ScriptC.Builder sb = new ScriptC.Builder(mRS);
|
||||
sb.setType(mParamsType, "Params", 0);
|
||||
sb.setType(mPixelType, "InPixel", 1);
|
||||
sb.setType(mPixelType, "OutPixel", 2);
|
||||
sb.setType(true, 2);
|
||||
Script.Invokable invokable = sb.addInvokable("main");
|
||||
sb.setScript(getResources(), R.raw.threshold);
|
||||
//sb.setRoot(true);
|
||||
|
||||
ScriptC script = sb.create();
|
||||
script.bindAllocation(mParamsAllocation, 0);
|
||||
script.bindAllocation(mInPixelsAllocation, 1);
|
||||
script.bindAllocation(mOutPixelsAllocation, 2);
|
||||
|
||||
return invokable;
|
||||
}
|
||||
|
||||
private Params createParams() {
|
||||
final Params params = new Params();
|
||||
params.inWidth = params.outWidth = mBitmap.getWidth();
|
||||
params.inHeight = params.outHeight = mBitmap.getHeight();
|
||||
params.threshold = 0.5f;
|
||||
return params;
|
||||
mScript = new ScriptC_Threshold(mRS, getResources(), false);
|
||||
mScript.set_width(mBitmapIn.getWidth());
|
||||
mScript.set_height(mBitmapIn.getHeight());
|
||||
mScript.set_threshold(mThreshold);
|
||||
mScript.bind_InPixel(mInPixelsAllocation);
|
||||
mScript.bind_OutPixel(mOutPixelsAllocation);
|
||||
}
|
||||
|
||||
private Bitmap loadBitmap(int resource) {
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
|
||||
package com.android.rs.image;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.renderscript.*;
|
||||
import android.util.Log;
|
||||
|
||||
public class ScriptC_Threshold
|
||||
extends android.renderscript.ScriptC
|
||||
{
|
||||
private final static int mFieldIndex_height = 0;
|
||||
private final static int mFieldIndex_width = 1;
|
||||
private final static int mFieldIndex_threshold = 2;
|
||||
private final static int mFieldIndex_InPixel = 3;
|
||||
private final static int mFieldIndex_OutPixel = 4;
|
||||
|
||||
private Allocation mField_InPixel;
|
||||
private Allocation mField_OutPixel;
|
||||
|
||||
public ScriptC_Threshold(RenderScript rs, Resources resources, boolean isRoot) {
|
||||
super(rs, resources, R.raw.threshold_bc, isRoot);
|
||||
}
|
||||
|
||||
public void bind_InPixel(Allocation f) {
|
||||
if (f != null) {
|
||||
//if (f.getType().getElement() != Element.ATTRIB_COLOR_U8_4(mRS)) {
|
||||
//throw new IllegalArgumentException("Element type mismatch.");
|
||||
//}
|
||||
}
|
||||
bindAllocation(f, mFieldIndex_InPixel);
|
||||
mField_InPixel = f;
|
||||
}
|
||||
public Allocation get_InPixel() {
|
||||
return mField_InPixel;
|
||||
}
|
||||
|
||||
public void bind_OutPixel(Allocation f) {
|
||||
if (f != null) {
|
||||
//if (f.getType().getElement() != Element.ATTRIB_COLOR_U8_4(mRS)) {
|
||||
//throw new IllegalArgumentException("Element type mismatch.");
|
||||
//}
|
||||
}
|
||||
bindAllocation(f, mFieldIndex_OutPixel);
|
||||
mField_OutPixel = f;
|
||||
}
|
||||
public Allocation get_OutPixel() {
|
||||
return mField_OutPixel;
|
||||
}
|
||||
|
||||
public void set_height(int v) {
|
||||
setVar(mFieldIndex_height, v);
|
||||
}
|
||||
|
||||
public void set_width(int v) {
|
||||
setVar(mFieldIndex_width, v);
|
||||
}
|
||||
|
||||
public void set_threshold(float v) {
|
||||
setVar(mFieldIndex_threshold, v);
|
||||
}
|
||||
|
||||
private final static int mInvokableIndex_Filter = 0;
|
||||
public void invokable_Filter() {
|
||||
invokeData(mInvokableIndex_Filter);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,27 +272,51 @@ ScriptSetClearStencil {
|
||||
param uint32_t stencil
|
||||
}
|
||||
|
||||
ScriptSetType {
|
||||
param RsType type
|
||||
param uint32_t slot
|
||||
param bool isWritable
|
||||
param const char * name
|
||||
}
|
||||
|
||||
ScriptSetInvoke {
|
||||
param const char * name
|
||||
param uint32_t slot
|
||||
}
|
||||
|
||||
ScriptInvoke {
|
||||
param RsScript s
|
||||
param uint32_t slot
|
||||
}
|
||||
|
||||
ScriptInvokeData {
|
||||
param RsScript s
|
||||
param uint32_t slot
|
||||
param void * data
|
||||
}
|
||||
|
||||
ScriptInvokeV {
|
||||
param RsScript s
|
||||
param uint32_t slot
|
||||
param const void * data
|
||||
param uint32_t dataLen
|
||||
handcodeApi
|
||||
togglePlay
|
||||
}
|
||||
|
||||
ScriptSetRoot {
|
||||
param bool isRoot
|
||||
}
|
||||
|
||||
ScriptSetVarI {
|
||||
param RsScript s
|
||||
param uint32_t slot
|
||||
param int value
|
||||
}
|
||||
|
||||
ScriptSetVarF {
|
||||
param RsScript s
|
||||
param uint32_t slot
|
||||
param float value
|
||||
}
|
||||
|
||||
ScriptSetVarV {
|
||||
param RsScript s
|
||||
param uint32_t slot
|
||||
param const void * data
|
||||
param uint32_t dataLen
|
||||
handcodeApi
|
||||
togglePlay
|
||||
}
|
||||
|
||||
|
||||
ScriptCSetScript {
|
||||
|
||||
@@ -154,7 +154,6 @@ void Context::checkError(const char *msg) const
|
||||
uint32_t Context::runRootScript()
|
||||
{
|
||||
timerSet(RS_TIMER_CLEAR_SWAP);
|
||||
rsAssert(mRootScript->mEnviroment.mIsRoot);
|
||||
|
||||
eglQuerySurface(mEGL.mDisplay, mEGL.mSurface, EGL_WIDTH, &mEGL.mWidth);
|
||||
eglQuerySurface(mEGL.mDisplay, mEGL.mSurface, EGL_HEIGHT, &mEGL.mHeight);
|
||||
@@ -640,28 +639,6 @@ void Context::removeName(ObjectBase *obj)
|
||||
}
|
||||
}
|
||||
|
||||
ObjectBase * Context::lookupName(const char *name) const
|
||||
{
|
||||
for(size_t ct=0; ct < mNames.size(); ct++) {
|
||||
if (!strcmp(name, mNames[ct]->getName())) {
|
||||
return mNames[ct];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void Context::appendNameDefines(String8 *str) const
|
||||
{
|
||||
char buf[256];
|
||||
for (size_t ct=0; ct < mNames.size(); ct++) {
|
||||
str->append("#define NAMED_");
|
||||
str->append(mNames[ct]->getName());
|
||||
str->append(" ");
|
||||
sprintf(buf, "%i\n", (int)mNames[ct]);
|
||||
str->append(buf);
|
||||
}
|
||||
}
|
||||
|
||||
bool Context::objDestroyOOBInit()
|
||||
{
|
||||
if (!mObjDestroy.mMutex.init()) {
|
||||
|
||||
@@ -104,8 +104,6 @@ public:
|
||||
|
||||
void assignName(ObjectBase *obj, const char *name, uint32_t len);
|
||||
void removeName(ObjectBase *obj);
|
||||
ObjectBase * lookupName(const char *name) const;
|
||||
void appendNameDefines(String8 *str) const;
|
||||
|
||||
uint32_t getMessageToClient(void *data, size_t *receiveLen, size_t bufferLen, bool wait);
|
||||
bool sendMessageToClient(void *data, uint32_t cmdID, size_t len, bool waitForSpace);
|
||||
|
||||
@@ -1,6 +1,49 @@
|
||||
|
||||
#define DATA_SYNC_SIZE 1024
|
||||
|
||||
static inline void rsHCAPI_ScriptInvokeV (RsContext rsc, RsScript va, uint32_t slot, const void * data, uint32_t sizeBytes)
|
||||
{
|
||||
ThreadIO *io = &((Context *)rsc)->mIO;
|
||||
uint32_t size = sizeof(RS_CMD_ScriptInvokeV);
|
||||
if (sizeBytes < DATA_SYNC_SIZE) {
|
||||
size += (sizeBytes + 3) & ~3;
|
||||
}
|
||||
RS_CMD_ScriptInvokeV *cmd = static_cast<RS_CMD_ScriptInvokeV *>(io->mToCore.reserve(size));
|
||||
cmd->s = va;
|
||||
cmd->slot = slot;
|
||||
cmd->dataLen = sizeBytes;
|
||||
cmd->data = data;
|
||||
if (sizeBytes < DATA_SYNC_SIZE) {
|
||||
cmd->data = (void *)(cmd+1);
|
||||
memcpy(cmd+1, data, sizeBytes);
|
||||
io->mToCore.commit(RS_CMD_ID_ScriptInvokeV, size);
|
||||
} else {
|
||||
io->mToCore.commitSync(RS_CMD_ID_ScriptInvokeV, size);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static inline void rsHCAPI_ScriptSetVarV (RsContext rsc, RsScript va, uint32_t slot, const void * data, uint32_t sizeBytes)
|
||||
{
|
||||
ThreadIO *io = &((Context *)rsc)->mIO;
|
||||
uint32_t size = sizeof(RS_CMD_ScriptSetVarV);
|
||||
if (sizeBytes < DATA_SYNC_SIZE) {
|
||||
size += (sizeBytes + 3) & ~3;
|
||||
}
|
||||
RS_CMD_ScriptSetVarV *cmd = static_cast<RS_CMD_ScriptSetVarV *>(io->mToCore.reserve(size));
|
||||
cmd->s = va;
|
||||
cmd->slot = slot;
|
||||
cmd->dataLen = sizeBytes;
|
||||
cmd->data = data;
|
||||
if (sizeBytes < DATA_SYNC_SIZE) {
|
||||
cmd->data = (void *)(cmd+1);
|
||||
memcpy(cmd+1, data, sizeBytes);
|
||||
io->mToCore.commit(RS_CMD_ID_ScriptSetVarV, size);
|
||||
} else {
|
||||
io->mToCore.commitSync(RS_CMD_ID_ScriptSetVarV, size);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void rsHCAPI_AllocationData (RsContext rsc, RsAllocation va, const void * data, uint32_t sizeBytes)
|
||||
{
|
||||
ThreadIO *io = &((Context *)rsc)->mIO;
|
||||
|
||||
@@ -328,6 +328,7 @@ RsProgramFragment rsi_ProgramFragmentCreate(Context *rsc,
|
||||
{
|
||||
ProgramFragment *pf = new ProgramFragment(rsc, params, paramLength);
|
||||
pf->incUserRef();
|
||||
LOGE("rsi_ProgramFragmentCreate %p", pf);
|
||||
return pf;
|
||||
}
|
||||
|
||||
@@ -337,6 +338,7 @@ RsProgramFragment rsi_ProgramFragmentCreate2(Context *rsc, const char * shaderTe
|
||||
{
|
||||
ProgramFragment *pf = new ProgramFragment(rsc, shaderText, shaderLength, params, paramLength);
|
||||
pf->incUserRef();
|
||||
LOGE("rsi_ProgramFragmentCreate2 %p", pf);
|
||||
return pf;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,13 +30,25 @@ Script::Script(Context *rsc) : ObjectBase(rsc)
|
||||
mEnviroment.mClearColor[3] = 1;
|
||||
mEnviroment.mClearDepth = 1;
|
||||
mEnviroment.mClearStencil = 0;
|
||||
mEnviroment.mIsRoot = false;
|
||||
}
|
||||
|
||||
Script::~Script()
|
||||
{
|
||||
}
|
||||
|
||||
void Script::setVar(uint32_t slot, const void *val, uint32_t len)
|
||||
{
|
||||
int32_t *destPtr = ((int32_t **)mEnviroment.mFieldAddress)[slot];
|
||||
if (destPtr) {
|
||||
//LOGE("setVar f1 %f", ((const float *)destPtr)[0]);
|
||||
//LOGE("setVar %p %i", destPtr, len);
|
||||
memcpy(destPtr, val, len);
|
||||
//LOGE("setVar f2 %f", ((const float *)destPtr)[0]);
|
||||
} else {
|
||||
LOGE("Calling setVar on slot = %i which is null", slot);
|
||||
}
|
||||
}
|
||||
|
||||
namespace android {
|
||||
namespace renderscript {
|
||||
|
||||
@@ -44,7 +56,9 @@ namespace renderscript {
|
||||
void rsi_ScriptBindAllocation(Context * rsc, RsScript vs, RsAllocation va, uint32_t slot)
|
||||
{
|
||||
Script *s = static_cast<Script *>(vs);
|
||||
s->mSlots[slot].set(static_cast<Allocation *>(va));
|
||||
Allocation *a = static_cast<Allocation *>(va);
|
||||
s->mSlots[slot].set(a);
|
||||
//LOGE("rsi_ScriptBindAllocation %i %p %p", slot, a, a->getPtr());
|
||||
}
|
||||
|
||||
void rsi_ScriptSetClearColor(Context * rsc, RsScript vs, float r, float g, float b, float a)
|
||||
@@ -80,35 +94,111 @@ void rsi_ScriptSetType(Context * rsc, RsType vt, uint32_t slot, bool writable, c
|
||||
const Type *t = static_cast<const Type *>(vt);
|
||||
ss->mConstantBufferTypes[slot].set(t);
|
||||
ss->mSlotWritable[slot] = writable;
|
||||
if (name) {
|
||||
ss->mSlotNames[slot].setTo(name);
|
||||
} else {
|
||||
ss->mSlotNames[slot].setTo("");
|
||||
}
|
||||
LOGE("rsi_ScriptSetType");
|
||||
}
|
||||
|
||||
void rsi_ScriptSetInvoke(Context *rsc, const char *name, uint32_t slot)
|
||||
{
|
||||
ScriptCState *ss = &rsc->mScriptC;
|
||||
ss->mInvokableNames[slot] = name;
|
||||
LOGE("rsi_ScriptSetInvoke");
|
||||
}
|
||||
|
||||
|
||||
void rsi_ScriptInvoke(Context *rsc, RsScript vs, uint32_t slot)
|
||||
{
|
||||
//LOGE("rsi_ScriptInvoke %i", slot);
|
||||
Script *s = static_cast<Script *>(vs);
|
||||
if (s->mEnviroment.mInvokables[slot] == NULL) {
|
||||
if ((slot >= s->mEnviroment.mInvokeFunctionCount) ||
|
||||
(s->mEnviroment.mInvokeFunctions[slot] == NULL)) {
|
||||
rsc->setError(RS_ERROR_BAD_SCRIPT, "Calling invoke on bad script");
|
||||
return;
|
||||
}
|
||||
s->setupScript();
|
||||
s->mEnviroment.mInvokables[slot]();
|
||||
//LOGE("invoking %i %p", slot, s->mEnviroment.mInvokeFunctions[slot]);
|
||||
s->mEnviroment.mInvokeFunctions[slot]();
|
||||
//LOGE("invoke finished");
|
||||
}
|
||||
|
||||
|
||||
void rsi_ScriptInvokeData(Context *rsc, RsScript vs, uint32_t slot, void *data)
|
||||
{
|
||||
//LOGE("rsi_ScriptInvoke %i", slot);
|
||||
Script *s = static_cast<Script *>(vs);
|
||||
if ((slot >= s->mEnviroment.mInvokeFunctionCount) ||
|
||||
(s->mEnviroment.mInvokeFunctions[slot] == NULL)) {
|
||||
rsc->setError(RS_ERROR_BAD_SCRIPT, "Calling invoke on bad script");
|
||||
return;
|
||||
}
|
||||
s->setupScript();
|
||||
//LOGE("invoking %i %p", slot, s->mEnviroment.mInvokeFunctions[slot]);
|
||||
s->mEnviroment.mInvokeFunctions[slot]();
|
||||
//LOGE("invoke finished");
|
||||
}
|
||||
|
||||
void rsi_ScriptInvokeV(Context *rsc, RsScript vs, uint32_t slot, const void *data, uint32_t len)
|
||||
{
|
||||
//LOGE("rsi_ScriptInvoke %i", slot);
|
||||
Script *s = static_cast<Script *>(vs);
|
||||
if ((slot >= s->mEnviroment.mInvokeFunctionCount) ||
|
||||
(s->mEnviroment.mInvokeFunctions[slot] == NULL)) {
|
||||
rsc->setError(RS_ERROR_BAD_SCRIPT, "Calling invoke on bad script");
|
||||
return;
|
||||
}
|
||||
s->setupScript();
|
||||
|
||||
LOGE("rsi_ScriptInvokeV, len=%i", len);
|
||||
const uint32_t * dPtr = (const uint32_t *)data;
|
||||
switch(len) {
|
||||
case 0:
|
||||
s->mEnviroment.mInvokeFunctions[slot]();
|
||||
break;
|
||||
case 4:
|
||||
((void (*)(uint32_t))
|
||||
s->mEnviroment.mInvokeFunctions[slot])(dPtr[0]);
|
||||
break;
|
||||
case 8:
|
||||
((void (*)(uint32_t, uint32_t))
|
||||
s->mEnviroment.mInvokeFunctions[slot])(dPtr[0], dPtr[1]);
|
||||
break;
|
||||
case 12:
|
||||
((void (*)(uint32_t, uint32_t, uint32_t))
|
||||
s->mEnviroment.mInvokeFunctions[slot])(dPtr[0], dPtr[1], dPtr[2]);
|
||||
break;
|
||||
case 16:
|
||||
((void (*)(uint32_t, uint32_t, uint32_t, uint32_t))
|
||||
s->mEnviroment.mInvokeFunctions[slot])(dPtr[0], dPtr[1], dPtr[2], dPtr[3]);
|
||||
break;
|
||||
case 20:
|
||||
((void (*)(uint32_t, uint32_t, uint32_t, uint32_t, uint32_t))
|
||||
s->mEnviroment.mInvokeFunctions[slot])(dPtr[0], dPtr[1], dPtr[2], dPtr[3], dPtr[4]);
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void rsi_ScriptSetRoot(Context * rsc, bool isRoot)
|
||||
{
|
||||
ScriptCState *ss = &rsc->mScriptC;
|
||||
ss->mScript->mEnviroment.mIsRoot = isRoot;
|
||||
LOGE("rsi_ScriptSetRoot");
|
||||
}
|
||||
|
||||
void rsi_ScriptSetVarI(Context *rsc, RsScript vs, uint32_t slot, int value)
|
||||
{
|
||||
Script *s = static_cast<Script *>(vs);
|
||||
s->setVar(slot, &value, sizeof(value));
|
||||
}
|
||||
|
||||
void rsi_ScriptSetVarF(Context *rsc, RsScript vs, uint32_t slot, float value)
|
||||
{
|
||||
Script *s = static_cast<Script *>(vs);
|
||||
s->setVar(slot, &value, sizeof(value));
|
||||
}
|
||||
|
||||
void rsi_ScriptSetVarV(Context *rsc, RsScript vs, uint32_t slot, const void *data, uint32_t len)
|
||||
{
|
||||
const float *fp = (const float *)data;
|
||||
Script *s = static_cast<Script *>(vs);
|
||||
s->setVar(slot, data, len);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ class ProgramFragment;
|
||||
class ProgramRaster;
|
||||
class ProgramFragmentStore;
|
||||
|
||||
#define MAX_SCRIPT_BANKS 16
|
||||
#define MAX_SCRIPT_BANKS 32
|
||||
|
||||
class Script : public ObjectBase
|
||||
{
|
||||
@@ -39,9 +39,7 @@ public:
|
||||
Script(Context *);
|
||||
virtual ~Script();
|
||||
|
||||
|
||||
struct Enviroment_t {
|
||||
bool mIsRoot;
|
||||
float mClearColor[4];
|
||||
float mClearDepth;
|
||||
uint32_t mClearStencil;
|
||||
@@ -53,21 +51,22 @@ public:
|
||||
ObjectBaseRef<ProgramFragment> mFragment;
|
||||
ObjectBaseRef<ProgramRaster> mRaster;
|
||||
ObjectBaseRef<ProgramFragmentStore> mFragmentStore;
|
||||
InvokeFunc_t mInvokables[MAX_SCRIPT_BANKS];
|
||||
|
||||
uint32_t mInvokeFunctionCount;
|
||||
InvokeFunc_t *mInvokeFunctions;
|
||||
uint32_t mFieldCount;
|
||||
void ** mFieldAddress;
|
||||
|
||||
char * mScriptText;
|
||||
uint32_t mScriptTextLength;
|
||||
};
|
||||
Enviroment_t mEnviroment;
|
||||
|
||||
uint32_t mCounstantBufferCount;
|
||||
|
||||
|
||||
ObjectBaseRef<Allocation> mSlots[MAX_SCRIPT_BANKS];
|
||||
ObjectBaseRef<const Type> mTypes[MAX_SCRIPT_BANKS];
|
||||
String8 mSlotNames[MAX_SCRIPT_BANKS];
|
||||
bool mSlotWritable[MAX_SCRIPT_BANKS];
|
||||
|
||||
|
||||
void setVar(uint32_t slot, const void *val, uint32_t len);
|
||||
|
||||
virtual void setupScript() = 0;
|
||||
virtual uint32_t run(Context *, uint32_t launchID) = 0;
|
||||
|
||||
@@ -17,8 +17,7 @@
|
||||
#include "rsContext.h"
|
||||
#include "rsScriptC.h"
|
||||
#include "rsMatrix.h"
|
||||
|
||||
#include "acc/acc.h"
|
||||
#include "../../../external/llvm/libbcc/include/bcc/bcc.h"
|
||||
#include "utils/Timers.h"
|
||||
|
||||
#include <GLES/gl.h>
|
||||
@@ -37,14 +36,14 @@ ScriptC::ScriptC(Context *rsc) : Script(rsc)
|
||||
{
|
||||
mAllocFile = __FILE__;
|
||||
mAllocLine = __LINE__;
|
||||
mAccScript = NULL;
|
||||
mBccScript = NULL;
|
||||
memset(&mProgram, 0, sizeof(mProgram));
|
||||
}
|
||||
|
||||
ScriptC::~ScriptC()
|
||||
{
|
||||
if (mAccScript) {
|
||||
accDeleteScript(mAccScript);
|
||||
if (mBccScript) {
|
||||
bccDeleteScript(mBccScript);
|
||||
}
|
||||
free(mEnviroment.mScriptText);
|
||||
mEnviroment.mScriptText = NULL;
|
||||
@@ -52,9 +51,22 @@ ScriptC::~ScriptC()
|
||||
|
||||
void ScriptC::setupScript()
|
||||
{
|
||||
for (int ct=0; ct < MAX_SCRIPT_BANKS; ct++) {
|
||||
if (mProgram.mSlotPointers[ct]) {
|
||||
*mProgram.mSlotPointers[ct] = mSlots[ct]->getPtr();
|
||||
for (uint32_t ct=0; ct < mEnviroment.mFieldCount; ct++) {
|
||||
if (!mSlots[ct].get())
|
||||
continue;
|
||||
void *ptr = mSlots[ct]->getPtr();
|
||||
void **dest = ((void ***)mEnviroment.mFieldAddress)[ct];
|
||||
//LOGE("setupScript %i %p = %p %p %i", ct, dest, ptr, mSlots[ct]->getType(), mSlots[ct]->getType()->getDimX());
|
||||
|
||||
//const uint32_t *p32 = (const uint32_t *)ptr;
|
||||
//for (uint32_t ct2=0; ct2 < mSlots[ct]->getType()->getDimX(); ct2++) {
|
||||
//LOGE(" %i = 0x%08x ", ct2, p32[ct2]);
|
||||
//}
|
||||
|
||||
if (dest) {
|
||||
*dest = ptr;
|
||||
} else {
|
||||
LOGE("ScriptC::setupScript, NULL var binding address.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -62,7 +74,7 @@ void ScriptC::setupScript()
|
||||
|
||||
uint32_t ScriptC::run(Context *rsc, uint32_t launchIndex)
|
||||
{
|
||||
if (mProgram.mScript == NULL) {
|
||||
if (mProgram.mRoot == NULL) {
|
||||
rsc->setError(RS_ERROR_BAD_SCRIPT, "Attempted to run bad script");
|
||||
return 0;
|
||||
}
|
||||
@@ -92,8 +104,10 @@ uint32_t ScriptC::run(Context *rsc, uint32_t launchIndex)
|
||||
|
||||
uint32_t ret = 0;
|
||||
tls->mScript = this;
|
||||
ret = mProgram.mScript(launchIndex);
|
||||
//LOGE("ScriptC::run %p", mProgram.mRoot);
|
||||
ret = mProgram.mRoot();
|
||||
tls->mScript = NULL;
|
||||
//LOGE("ScriptC::run ret %i", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -113,19 +127,14 @@ void ScriptCState::clear()
|
||||
{
|
||||
for (uint32_t ct=0; ct < MAX_SCRIPT_BANKS; ct++) {
|
||||
mConstantBufferTypes[ct].clear();
|
||||
mSlotNames[ct].setTo("");
|
||||
mInvokableNames[ct].setTo("");
|
||||
mSlotWritable[ct] = false;
|
||||
}
|
||||
|
||||
delete mScript;
|
||||
mScript = new ScriptC(NULL);
|
||||
|
||||
mInt32Defines.clear();
|
||||
mFloatDefines.clear();
|
||||
}
|
||||
|
||||
static ACCvoid* symbolLookup(ACCvoid* pContext, const ACCchar* name)
|
||||
static BCCvoid* symbolLookup(BCCvoid* pContext, const BCCchar* name)
|
||||
{
|
||||
const ScriptCState::SymbolTable_t *sym = ScriptCState::lookupSymbol(name);
|
||||
if (sym) {
|
||||
@@ -137,51 +146,39 @@ static ACCvoid* symbolLookup(ACCvoid* pContext, const ACCchar* name)
|
||||
|
||||
void ScriptCState::runCompiler(Context *rsc, ScriptC *s)
|
||||
{
|
||||
s->mAccScript = accCreateScript();
|
||||
String8 tmp;
|
||||
LOGE("ScriptCState::runCompiler ");
|
||||
|
||||
rsc->appendNameDefines(&tmp);
|
||||
appendDecls(&tmp);
|
||||
appendVarDefines(rsc, &tmp);
|
||||
appendTypes(rsc, &tmp);
|
||||
tmp.append("#line 1\n");
|
||||
|
||||
const char* scriptSource[] = {tmp.string(), s->mEnviroment.mScriptText};
|
||||
int scriptLength[] = {tmp.length(), s->mEnviroment.mScriptTextLength} ;
|
||||
accScriptSource(s->mAccScript, sizeof(scriptLength) / sizeof(int), scriptSource, scriptLength);
|
||||
accRegisterSymbolCallback(s->mAccScript, symbolLookup, NULL);
|
||||
accCompileScript(s->mAccScript);
|
||||
accGetScriptLabel(s->mAccScript, "main", (ACCvoid**) &s->mProgram.mScript);
|
||||
accGetScriptLabel(s->mAccScript, "init", (ACCvoid**) &s->mProgram.mInit);
|
||||
rsAssert(s->mProgram.mScript);
|
||||
|
||||
if (!s->mProgram.mScript) {
|
||||
ACCchar buf[4096];
|
||||
ACCsizei len;
|
||||
accGetScriptInfoLog(s->mAccScript, sizeof(buf), &len, buf);
|
||||
LOGE(buf);
|
||||
rsc->setError(RS_ERROR_BAD_SCRIPT, "Error compiling user script.");
|
||||
return;
|
||||
}
|
||||
s->mBccScript = bccCreateScript();
|
||||
bccScriptBitcode(s->mBccScript, s->mEnviroment.mScriptText, s->mEnviroment.mScriptTextLength);
|
||||
bccRegisterSymbolCallback(s->mBccScript, symbolLookup, NULL);
|
||||
LOGE("ScriptCState::runCompiler 3");
|
||||
bccCompileScript(s->mBccScript);
|
||||
LOGE("ScriptCState::runCompiler 4");
|
||||
bccGetScriptLabel(s->mBccScript, "root", (BCCvoid**) &s->mProgram.mRoot);
|
||||
bccGetScriptLabel(s->mBccScript, "init", (BCCvoid**) &s->mProgram.mInit);
|
||||
LOGE("root %p, init %p", s->mProgram.mRoot, s->mProgram.mInit);
|
||||
|
||||
if (s->mProgram.mInit) {
|
||||
s->mProgram.mInit();
|
||||
}
|
||||
|
||||
for (int ct=0; ct < MAX_SCRIPT_BANKS; ct++) {
|
||||
if (mSlotNames[ct].length() > 0) {
|
||||
accGetScriptLabel(s->mAccScript,
|
||||
mSlotNames[ct].string(),
|
||||
(ACCvoid**) &s->mProgram.mSlotPointers[ct]);
|
||||
}
|
||||
s->mEnviroment.mInvokeFunctions = (Script::InvokeFunc_t *)calloc(100, sizeof(void *));
|
||||
BCCchar **labels = new char*[100];
|
||||
bccGetFunctions(s->mBccScript, (BCCsizei *)&s->mEnviroment.mInvokeFunctionCount,
|
||||
100, (BCCchar **)labels);
|
||||
//LOGE("func count %i", s->mEnviroment.mInvokeFunctionCount);
|
||||
for (uint32_t i=0; i < s->mEnviroment.mInvokeFunctionCount; i++) {
|
||||
BCCsizei length;
|
||||
bccGetFunctionBinary(s->mBccScript, labels[i], (BCCvoid **)&(s->mEnviroment.mInvokeFunctions[i]), &length);
|
||||
//LOGE("func %i %p", i, s->mEnviroment.mInvokeFunctions[i]);
|
||||
}
|
||||
|
||||
for (int ct=0; ct < MAX_SCRIPT_BANKS; ct++) {
|
||||
if (mInvokableNames[ct].length() > 0) {
|
||||
accGetScriptLabel(s->mAccScript,
|
||||
mInvokableNames[ct].string(),
|
||||
(ACCvoid**) &s->mEnviroment.mInvokables[ct]);
|
||||
}
|
||||
s->mEnviroment.mFieldAddress = (void **)calloc(100, sizeof(void *));
|
||||
bccGetExportVars(s->mBccScript, (BCCsizei *)&s->mEnviroment.mFieldCount,
|
||||
100, s->mEnviroment.mFieldAddress);
|
||||
//LOGE("var count %i", s->mEnviroment.mFieldCount);
|
||||
for (uint32_t i=0; i < s->mEnviroment.mFieldCount; i++) {
|
||||
//LOGE("var %i %p", i, s->mEnviroment.mFieldAddress[i]);
|
||||
}
|
||||
|
||||
s->mEnviroment.mFragment.set(rsc->getDefaultProgramFragment());
|
||||
@@ -189,11 +186,11 @@ void ScriptCState::runCompiler(Context *rsc, ScriptC *s)
|
||||
s->mEnviroment.mFragmentStore.set(rsc->getDefaultProgramFragmentStore());
|
||||
s->mEnviroment.mRaster.set(rsc->getDefaultProgramRaster());
|
||||
|
||||
if (s->mProgram.mScript) {
|
||||
if (s->mProgram.mRoot) {
|
||||
const static int pragmaMax = 16;
|
||||
ACCsizei pragmaCount;
|
||||
ACCchar * str[pragmaMax];
|
||||
accGetPragmas(s->mAccScript, &pragmaCount, pragmaMax, &str[0]);
|
||||
BCCsizei pragmaCount;
|
||||
BCCchar * str[pragmaMax];
|
||||
bccGetPragmas(s->mBccScript, &pragmaCount, pragmaMax, &str[0]);
|
||||
|
||||
for (int ct=0; ct < pragmaCount; ct+=2) {
|
||||
if (!strcmp(str[ct], "version")) {
|
||||
@@ -208,11 +205,6 @@ void ScriptCState::runCompiler(Context *rsc, ScriptC *s)
|
||||
s->mEnviroment.mVertex.clear();
|
||||
continue;
|
||||
}
|
||||
ProgramVertex * pv = (ProgramVertex *)rsc->lookupName(str[ct+1]);
|
||||
if (pv != NULL) {
|
||||
s->mEnviroment.mVertex.set(pv);
|
||||
continue;
|
||||
}
|
||||
LOGE("Unreconized value %s passed to stateVertex", str[ct+1]);
|
||||
}
|
||||
|
||||
@@ -224,11 +216,6 @@ void ScriptCState::runCompiler(Context *rsc, ScriptC *s)
|
||||
s->mEnviroment.mRaster.clear();
|
||||
continue;
|
||||
}
|
||||
ProgramRaster * pr = (ProgramRaster *)rsc->lookupName(str[ct+1]);
|
||||
if (pr != NULL) {
|
||||
s->mEnviroment.mRaster.set(pr);
|
||||
continue;
|
||||
}
|
||||
LOGE("Unreconized value %s passed to stateRaster", str[ct+1]);
|
||||
}
|
||||
|
||||
@@ -240,11 +227,6 @@ void ScriptCState::runCompiler(Context *rsc, ScriptC *s)
|
||||
s->mEnviroment.mFragment.clear();
|
||||
continue;
|
||||
}
|
||||
ProgramFragment * pf = (ProgramFragment *)rsc->lookupName(str[ct+1]);
|
||||
if (pf != NULL) {
|
||||
s->mEnviroment.mFragment.set(pf);
|
||||
continue;
|
||||
}
|
||||
LOGE("Unreconized value %s passed to stateFragment", str[ct+1]);
|
||||
}
|
||||
|
||||
@@ -256,12 +238,6 @@ void ScriptCState::runCompiler(Context *rsc, ScriptC *s)
|
||||
s->mEnviroment.mFragmentStore.clear();
|
||||
continue;
|
||||
}
|
||||
ProgramFragmentStore * pfs =
|
||||
(ProgramFragmentStore *)rsc->lookupName(str[ct+1]);
|
||||
if (pfs != NULL) {
|
||||
s->mEnviroment.mFragmentStore.set(pfs);
|
||||
continue;
|
||||
}
|
||||
LOGE("Unreconized value %s passed to stateStore", str[ct+1]);
|
||||
}
|
||||
|
||||
@@ -273,111 +249,6 @@ void ScriptCState::runCompiler(Context *rsc, ScriptC *s)
|
||||
}
|
||||
}
|
||||
|
||||
static void appendElementBody(String8 *s, const Element *e)
|
||||
{
|
||||
s->append(" {\n");
|
||||
for (size_t ct2=0; ct2 < e->getFieldCount(); ct2++) {
|
||||
const Element *c = e->getField(ct2);
|
||||
s->append(" ");
|
||||
s->append(c->getCType());
|
||||
s->append(" ");
|
||||
s->append(e->getFieldName(ct2));
|
||||
s->append(";\n");
|
||||
}
|
||||
s->append("}");
|
||||
}
|
||||
|
||||
void ScriptCState::appendVarDefines(const Context *rsc, String8 *str)
|
||||
{
|
||||
char buf[256];
|
||||
if (rsc->props.mLogScripts) {
|
||||
LOGD("appendVarDefines mInt32Defines.size()=%d mFloatDefines.size()=%d\n",
|
||||
mInt32Defines.size(), mFloatDefines.size());
|
||||
}
|
||||
for (size_t ct=0; ct < mInt32Defines.size(); ct++) {
|
||||
str->append("#define ");
|
||||
str->append(mInt32Defines.keyAt(ct));
|
||||
str->append(" ");
|
||||
sprintf(buf, "%i\n", (int)mInt32Defines.valueAt(ct));
|
||||
str->append(buf);
|
||||
}
|
||||
for (size_t ct=0; ct < mFloatDefines.size(); ct++) {
|
||||
str->append("#define ");
|
||||
str->append(mFloatDefines.keyAt(ct));
|
||||
str->append(" ");
|
||||
sprintf(buf, "%ff\n", mFloatDefines.valueAt(ct));
|
||||
str->append(buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ScriptCState::appendTypes(const Context *rsc, String8 *str)
|
||||
{
|
||||
char buf[256];
|
||||
String8 tmp;
|
||||
|
||||
str->append("struct vecF32_2_s {float x; float y;};\n");
|
||||
str->append("struct vecF32_3_s {float x; float y; float z;};\n");
|
||||
str->append("struct vecF32_4_s {float x; float y; float z; float w;};\n");
|
||||
str->append("struct vecU8_4_s {char r; char g; char b; char a;};\n");
|
||||
str->append("#define vecF32_2_t struct vecF32_2_s\n");
|
||||
str->append("#define vecF32_3_t struct vecF32_3_s\n");
|
||||
str->append("#define vecF32_4_t struct vecF32_4_s\n");
|
||||
str->append("#define vecU8_4_t struct vecU8_4_s\n");
|
||||
str->append("#define vecI8_4_t struct vecU8_4_s\n");
|
||||
|
||||
for (size_t ct=0; ct < MAX_SCRIPT_BANKS; ct++) {
|
||||
const Type *t = mConstantBufferTypes[ct].get();
|
||||
if (!t) {
|
||||
continue;
|
||||
}
|
||||
const Element *e = t->getElement();
|
||||
if (e->getName() && (e->getFieldCount() > 1)) {
|
||||
String8 s("struct struct_");
|
||||
s.append(e->getName());
|
||||
s.append(e->getCStructBody());
|
||||
s.append(";\n");
|
||||
|
||||
s.append("#define ");
|
||||
s.append(e->getName());
|
||||
s.append("_t struct struct_");
|
||||
s.append(e->getName());
|
||||
s.append("\n\n");
|
||||
if (rsc->props.mLogScripts) {
|
||||
LOGV(s);
|
||||
}
|
||||
str->append(s);
|
||||
}
|
||||
|
||||
if (mSlotNames[ct].length() > 0) {
|
||||
String8 s;
|
||||
if (e->getName()) {
|
||||
// Use the named struct
|
||||
s.setTo(e->getName());
|
||||
} else {
|
||||
// create an struct named from the slot.
|
||||
s.setTo("struct ");
|
||||
s.append(mSlotNames[ct]);
|
||||
s.append("_s");
|
||||
s.append(e->getCStructBody());
|
||||
//appendElementBody(&s, e);
|
||||
s.append(";\n");
|
||||
s.append("struct ");
|
||||
s.append(mSlotNames[ct]);
|
||||
s.append("_s");
|
||||
}
|
||||
|
||||
s.append(" * ");
|
||||
s.append(mSlotNames[ct]);
|
||||
s.append(";\n");
|
||||
if (rsc->props.mLogScripts) {
|
||||
LOGV(s);
|
||||
}
|
||||
str->append(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace android {
|
||||
@@ -420,7 +291,6 @@ RsScript rsi_ScriptCCreate(Context * rsc)
|
||||
s->setContext(rsc);
|
||||
for (int ct=0; ct < MAX_SCRIPT_BANKS; ct++) {
|
||||
s->mTypes[ct].set(ss->mConstantBufferTypes[ct].get());
|
||||
s->mSlotNames[ct] = ss->mSlotNames[ct];
|
||||
s->mSlotWritable[ct] = ss->mSlotWritable[ct];
|
||||
}
|
||||
|
||||
@@ -430,14 +300,12 @@ RsScript rsi_ScriptCCreate(Context * rsc)
|
||||
|
||||
void rsi_ScriptCSetDefineF(Context *rsc, const char* name, float value)
|
||||
{
|
||||
ScriptCState *ss = &rsc->mScriptC;
|
||||
ss->mFloatDefines.add(String8(name), value);
|
||||
LOGE("Error rsi_ScriptCSetDefineF");
|
||||
}
|
||||
|
||||
void rsi_ScriptCSetDefineI32(Context *rsc, const char* name, int32_t value)
|
||||
{
|
||||
ScriptCState *ss = &rsc->mScriptC;
|
||||
ss->mInt32Defines.add(String8(name), value);
|
||||
LOGE("Error rsi_ScriptCSetDefineI");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
#include <utils/KeyedVector.h>
|
||||
|
||||
struct ACCscript;
|
||||
struct BCCscript;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
namespace android {
|
||||
@@ -34,7 +34,7 @@ namespace renderscript {
|
||||
class ScriptC : public Script
|
||||
{
|
||||
public:
|
||||
typedef int (*RunScript_t)(uint32_t launchIndex);
|
||||
typedef int (*RunScript_t)();
|
||||
typedef void (*VoidFunc_t)();
|
||||
|
||||
ScriptC(Context *);
|
||||
@@ -44,15 +44,13 @@ public:
|
||||
int mVersionMajor;
|
||||
int mVersionMinor;
|
||||
|
||||
RunScript_t mScript;
|
||||
RunScript_t mRoot;
|
||||
VoidFunc_t mInit;
|
||||
|
||||
void ** mSlotPointers[MAX_SCRIPT_BANKS];
|
||||
};
|
||||
|
||||
Program_t mProgram;
|
||||
|
||||
ACCscript* mAccScript;
|
||||
BCCscript* mBccScript;
|
||||
|
||||
virtual void setupScript();
|
||||
virtual uint32_t run(Context *, uint32_t launchID);
|
||||
@@ -67,27 +65,19 @@ public:
|
||||
ScriptC *mScript;
|
||||
|
||||
ObjectBaseRef<const Type> mConstantBufferTypes[MAX_SCRIPT_BANKS];
|
||||
String8 mSlotNames[MAX_SCRIPT_BANKS];
|
||||
//String8 mSlotNames[MAX_SCRIPT_BANKS];
|
||||
bool mSlotWritable[MAX_SCRIPT_BANKS];
|
||||
String8 mInvokableNames[MAX_SCRIPT_BANKS];
|
||||
//String8 mInvokableNames[MAX_SCRIPT_BANKS];
|
||||
|
||||
void clear();
|
||||
void runCompiler(Context *rsc, ScriptC *s);
|
||||
void appendVarDefines(const Context *rsc, String8 *str);
|
||||
void appendTypes(const Context *rsc, String8 *str);
|
||||
|
||||
struct SymbolTable_t {
|
||||
const char * mName;
|
||||
void * mPtr;
|
||||
const char * mRet;
|
||||
const char * mParam;
|
||||
};
|
||||
static SymbolTable_t gSyms[];
|
||||
static const SymbolTable_t * lookupSymbol(const char *);
|
||||
static void appendDecls(String8 *str);
|
||||
|
||||
KeyedVector<String8,int> mInt32Defines;
|
||||
KeyedVector<String8,float> mFloatDefines;
|
||||
};
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -41,6 +41,38 @@ namespace renderscript {
|
||||
#define rsAssert(v) while(0)
|
||||
#endif
|
||||
|
||||
typedef float rsvF_2 __attribute__ ((vector_size (8)));
|
||||
typedef float rsvF_4 __attribute__ ((vector_size (16)));
|
||||
typedef float rsvF_8 __attribute__ ((vector_size (32)));
|
||||
typedef float rsvF_16 __attribute__ ((vector_size (64)));
|
||||
typedef uint8_t rsvU8_4 __attribute__ ((vector_size (4)));
|
||||
|
||||
union float2 {
|
||||
rsvF_2 v;
|
||||
float f[2];
|
||||
};
|
||||
|
||||
union float4 {
|
||||
rsvF_4 v;
|
||||
float f[4];
|
||||
};
|
||||
|
||||
union float8 {
|
||||
rsvF_8 v;
|
||||
float f[8];
|
||||
};
|
||||
|
||||
union float16 {
|
||||
rsvF_16 v;
|
||||
float f[16];
|
||||
};
|
||||
|
||||
union uchar4 {
|
||||
rsvU8_4 v;
|
||||
uint8_t f[4];
|
||||
uint32_t packed;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
T rsMin(T in1, T in2)
|
||||
{
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
|
||||
extern float3 __attribute__((overloadable)) cross(float3, float3);
|
||||
extern float4 __attribute__((overloadable)) cross(float4, float4);
|
||||
|
||||
//extern float __attribute__((overloadable)) dot(float, float);
|
||||
extern float __attribute__((overloadable)) dot(float2, float2);
|
||||
extern float __attribute__((overloadable)) dot(float3, float3);
|
||||
extern float __attribute__((overloadable)) dot(float4, float4);
|
||||
|
||||
//extern float __attribute__((overloadable)) distance(float, float);
|
||||
extern float __attribute__((overloadable)) distance(float2, float2);
|
||||
extern float __attribute__((overloadable)) distance(float3, float3);
|
||||
extern float __attribute__((overloadable)) distance(float4, float4);
|
||||
|
||||
//extern float __attribute__((overloadable)) length(float);
|
||||
extern float __attribute__((overloadable)) length(float2);
|
||||
extern float __attribute__((overloadable)) length(float3);
|
||||
extern float __attribute__((overloadable)) length(float4);
|
||||
|
||||
extern float2 __attribute__((overloadable)) normalize(float2);
|
||||
extern float3 __attribute__((overloadable)) normalize(float3);
|
||||
extern float4 __attribute__((overloadable)) normalize(float4);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
extern float rand(float max);
|
||||
|
||||
//extern void vec2Rand(float *, float len);
|
||||
extern float2 vec2Rand(float len);
|
||||
|
||||
extern float3 float3Norm(float3);
|
||||
@@ -59,9 +60,21 @@ extern int getHeight();
|
||||
|
||||
extern int sendToClient(void *data, int cmdID, int len, int waitForSpace);
|
||||
|
||||
extern void debugF(const char *, float);
|
||||
extern void debugI32(const char *, int);
|
||||
extern void debugHexI32(const char *, int);
|
||||
|
||||
extern uint32_t allocGetDimX(rs_allocation);
|
||||
extern uint32_t allocGetDimY(rs_allocation);
|
||||
extern uint32_t allocGetDimZ(rs_allocation);
|
||||
extern uint32_t allocGetDimLOD(rs_allocation);
|
||||
extern uint32_t allocGetDimFaces(rs_allocation);
|
||||
|
||||
//
|
||||
extern float normf(float start, float stop, float value);
|
||||
extern float clampf(float amount, float low, float high);
|
||||
extern float turbulencef2(float x, float y, float octaves);
|
||||
extern float turbulencef3(float x, float y, float z, float octaves);
|
||||
|
||||
extern uchar4 __attribute__((overloadable)) convertColorTo8888(float r, float g, float b);
|
||||
extern uchar4 __attribute__((overloadable)) convertColorTo8888(float r, float g, float b, float a);
|
||||
extern uchar4 __attribute__((overloadable)) convertColorTo8888(float3);
|
||||
extern uchar4 __attribute__((overloadable)) convertColorTo8888(float4);
|
||||
|
||||
|
||||
|
||||
@@ -1,285 +1,653 @@
|
||||
// Float ops
|
||||
|
||||
extern float __attribute__((overloadable)) abs(float);
|
||||
//extern float2 __attribute__((overloadable)) abs(float2);
|
||||
//extern float3 __attribute__((overloadable)) abs(float3);
|
||||
//extern float4 __attribute__((overloadable)) abs(float4);
|
||||
//extern float8 __attribute__((overloadable)) abs(float8);
|
||||
//extern float16 __attribute__((overloadable)) abs(float16);
|
||||
// Float ops, 6.11.2
|
||||
|
||||
extern float __attribute__((overloadable)) acos(float);
|
||||
//extern float2 __attribute__((overloadable)) acos(float2);
|
||||
//extern float3 __attribute__((overloadable)) acos(float3);
|
||||
//extern float4 __attribute__((overloadable)) acos(float4);
|
||||
//extern float8 __attribute__((overloadable)) acos(float8);
|
||||
//extern float16 __attribute__((overloadable)) acos(float16);
|
||||
extern float2 __attribute__((overloadable)) acos(float2);
|
||||
extern float3 __attribute__((overloadable)) acos(float3);
|
||||
extern float4 __attribute__((overloadable)) acos(float4);
|
||||
extern float8 __attribute__((overloadable)) acos(float8);
|
||||
extern float16 __attribute__((overloadable)) acos(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) acosh(float);
|
||||
extern float2 __attribute__((overloadable)) acosh(float2);
|
||||
extern float3 __attribute__((overloadable)) acosh(float3);
|
||||
extern float4 __attribute__((overloadable)) acosh(float4);
|
||||
extern float8 __attribute__((overloadable)) acosh(float8);
|
||||
extern float16 __attribute__((overloadable)) acosh(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) acospi(float);
|
||||
extern float2 __attribute__((overloadable)) acospi(float2);
|
||||
extern float3 __attribute__((overloadable)) acospi(float3);
|
||||
extern float4 __attribute__((overloadable)) acospi(float4);
|
||||
extern float8 __attribute__((overloadable)) acospi(float8);
|
||||
extern float16 __attribute__((overloadable)) acospi(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) asin(float);
|
||||
//extern float2 __attribute__((overloadable)) asin(float2);
|
||||
//extern float3 __attribute__((overloadable)) asin(float3);
|
||||
//extern float4 __attribute__((overloadable)) asin(float4);
|
||||
//extern float8 __attribute__((overloadable)) asin(float8);
|
||||
//extern float16 __attribute__((overloadable)) asin(float16);
|
||||
extern float2 __attribute__((overloadable)) asin(float2);
|
||||
extern float3 __attribute__((overloadable)) asin(float3);
|
||||
extern float4 __attribute__((overloadable)) asin(float4);
|
||||
extern float8 __attribute__((overloadable)) asin(float8);
|
||||
extern float16 __attribute__((overloadable)) asin(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) asinh(float);
|
||||
extern float2 __attribute__((overloadable)) asinh(float2);
|
||||
extern float3 __attribute__((overloadable)) asinh(float3);
|
||||
extern float4 __attribute__((overloadable)) asinh(float4);
|
||||
extern float8 __attribute__((overloadable)) asinh(float8);
|
||||
extern float16 __attribute__((overloadable)) asinh(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) asinpi(float);
|
||||
extern float2 __attribute__((overloadable)) asinpi(float2);
|
||||
extern float3 __attribute__((overloadable)) asinpi(float3);
|
||||
extern float4 __attribute__((overloadable)) asinpi(float4);
|
||||
extern float8 __attribute__((overloadable)) asinpi(float8);
|
||||
extern float16 __attribute__((overloadable)) asinpi(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) atan(float);
|
||||
//extern float2 __attribute__((overloadable)) atan(float2);
|
||||
//extern float3 __attribute__((overloadable)) atan(float3);
|
||||
//extern float4 __attribute__((overloadable)) atan(float4);
|
||||
//extern float8 __attribute__((overloadable)) atan(float8);
|
||||
//extern float16 __attribute__((overloadable)) atan(float16);
|
||||
extern float2 __attribute__((overloadable)) atan(float2);
|
||||
extern float3 __attribute__((overloadable)) atan(float3);
|
||||
extern float4 __attribute__((overloadable)) atan(float4);
|
||||
extern float8 __attribute__((overloadable)) atan(float8);
|
||||
extern float16 __attribute__((overloadable)) atan(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) atan2(float, float);
|
||||
//extern float2 __attribute__((overloadable)) atan2(float2, float2);
|
||||
//extern float3 __attribute__((overloadable)) atan2(float3, float3);
|
||||
//extern float4 __attribute__((overloadable)) atan2(float4, float4);
|
||||
//extern float8 __attribute__((overloadable)) atan2(float8, float8);
|
||||
//extern float16 __attribute__((overloadable)) atan2(float16, float16);
|
||||
extern float2 __attribute__((overloadable)) atan2(float2, float2);
|
||||
extern float3 __attribute__((overloadable)) atan2(float3, float3);
|
||||
extern float4 __attribute__((overloadable)) atan2(float4, float4);
|
||||
extern float8 __attribute__((overloadable)) atan2(float8, float8);
|
||||
extern float16 __attribute__((overloadable)) atan2(float16, float16);
|
||||
|
||||
extern float __attribute__((overloadable)) atanh(float);
|
||||
extern float2 __attribute__((overloadable)) atanh(float2);
|
||||
extern float3 __attribute__((overloadable)) atanh(float3);
|
||||
extern float4 __attribute__((overloadable)) atanh(float4);
|
||||
extern float8 __attribute__((overloadable)) atanh(float8);
|
||||
extern float16 __attribute__((overloadable)) atanh(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) atanpi(float);
|
||||
extern float2 __attribute__((overloadable)) atanpi(float2);
|
||||
extern float3 __attribute__((overloadable)) atanpi(float3);
|
||||
extern float4 __attribute__((overloadable)) atanpi(float4);
|
||||
extern float8 __attribute__((overloadable)) atanpi(float8);
|
||||
extern float16 __attribute__((overloadable)) atanpi(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) atan2pi(float, float);
|
||||
extern float2 __attribute__((overloadable)) atan2pi(float2, float2);
|
||||
extern float3 __attribute__((overloadable)) atan2pi(float3, float3);
|
||||
extern float4 __attribute__((overloadable)) atan2pi(float4, float4);
|
||||
extern float8 __attribute__((overloadable)) atan2pi(float8, float8);
|
||||
extern float16 __attribute__((overloadable)) atan2pi(float16, float16);
|
||||
|
||||
extern float __attribute__((overloadable)) cbrt(float);
|
||||
extern float2 __attribute__((overloadable)) cbrt(float2);
|
||||
extern float3 __attribute__((overloadable)) cbrt(float3);
|
||||
extern float4 __attribute__((overloadable)) cbrt(float4);
|
||||
extern float8 __attribute__((overloadable)) cbrt(float8);
|
||||
extern float16 __attribute__((overloadable)) cbrt(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) ceil(float);
|
||||
//extern float2 __attribute__((overloadable)) ceil(float2);
|
||||
//extern float3 __attribute__((overloadable)) ceil(float3);
|
||||
//extern float4 __attribute__((overloadable)) ceil(float4);
|
||||
//extern float8 __attribute__((overloadable)) ceil(float8);
|
||||
//extern float16 __attribute__((overloadable)) ceil(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) clamp(float, float, float);
|
||||
//extern float2 __attribute__((overloadable)) clamp(float2, float2, float2);
|
||||
//extern float3 __attribute__((overloadable)) clamp(float3, float3, float3);
|
||||
//extern float4 __attribute__((overloadable)) clamp(float4, float4, float4);
|
||||
//extern float8 __attribute__((overloadable)) clamp(float8, float8, float8);
|
||||
//extern float16 __attribute__((overloadable)) clamp(float16, float16, float16);
|
||||
//extern float2 __attribute__((overloadable)) clamp(float2, float, float);
|
||||
//extern float3 __attribute__((overloadable)) clamp(float3, float, float);
|
||||
//extern float4 __attribute__((overloadable)) clamp(float4, float, float);
|
||||
//extern float8 __attribute__((overloadable)) clamp(float8, float, float);
|
||||
//extern float16 __attribute__((overloadable)) clamp(float16, float, float);
|
||||
extern float2 __attribute__((overloadable)) ceil(float2);
|
||||
extern float3 __attribute__((overloadable)) ceil(float3);
|
||||
extern float4 __attribute__((overloadable)) ceil(float4);
|
||||
extern float8 __attribute__((overloadable)) ceil(float8);
|
||||
extern float16 __attribute__((overloadable)) ceil(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) copysign(float, float);
|
||||
//extern float2 __attribute__((overloadable)) copysign(float2, float2);
|
||||
//extern float3 __attribute__((overloadable)) copysign(float3, float3);
|
||||
//extern float4 __attribute__((overloadable)) copysign(float4, float4);
|
||||
//extern float8 __attribute__((overloadable)) copysign(float8, float8);
|
||||
//extern float16 __attribute__((overloadable)) copysign(float16, float16);
|
||||
extern float2 __attribute__((overloadable)) copysign(float2, float2);
|
||||
extern float3 __attribute__((overloadable)) copysign(float3, float3);
|
||||
extern float4 __attribute__((overloadable)) copysign(float4, float4);
|
||||
extern float8 __attribute__((overloadable)) copysign(float8, float8);
|
||||
extern float16 __attribute__((overloadable)) copysign(float16, float16);
|
||||
|
||||
extern float __attribute__((overloadable)) cos(float);
|
||||
//extern float2 __attribute__((overloadable)) cos(float2);
|
||||
//extern float3 __attribute__((overloadable)) cos(float3);
|
||||
//extern float4 __attribute__((overloadable)) cos(float4);
|
||||
//extern float8 __attribute__((overloadable)) cos(float8);
|
||||
//extern float16 __attribute__((overloadable)) cos(float16);
|
||||
extern float2 __attribute__((overloadable)) cos(float2);
|
||||
extern float3 __attribute__((overloadable)) cos(float3);
|
||||
extern float4 __attribute__((overloadable)) cos(float4);
|
||||
extern float8 __attribute__((overloadable)) cos(float8);
|
||||
extern float16 __attribute__((overloadable)) cos(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) degrees(float);
|
||||
//extern float2 __attribute__((overloadable)) degrees(float2);
|
||||
//extern float3 __attribute__((overloadable)) degrees(float3);
|
||||
//extern float4 __attribute__((overloadable)) degrees(float4);
|
||||
//extern float8 __attribute__((overloadable)) degrees(float8);
|
||||
//extern float16 __attribute__((overloadable)) degrees(float16);
|
||||
extern float __attribute__((overloadable)) cosh(float);
|
||||
extern float2 __attribute__((overloadable)) cosh(float2);
|
||||
extern float3 __attribute__((overloadable)) cosh(float3);
|
||||
extern float4 __attribute__((overloadable)) cosh(float4);
|
||||
extern float8 __attribute__((overloadable)) cosh(float8);
|
||||
extern float16 __attribute__((overloadable)) cosh(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) cospi(float);
|
||||
extern float2 __attribute__((overloadable)) cospi(float2);
|
||||
extern float3 __attribute__((overloadable)) cospi(float3);
|
||||
extern float4 __attribute__((overloadable)) cospi(float4);
|
||||
extern float8 __attribute__((overloadable)) cospi(float8);
|
||||
extern float16 __attribute__((overloadable)) cospi(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) erfc(float);
|
||||
extern float2 __attribute__((overloadable)) erfc(float2);
|
||||
extern float3 __attribute__((overloadable)) erfc(float3);
|
||||
extern float4 __attribute__((overloadable)) erfc(float4);
|
||||
extern float8 __attribute__((overloadable)) erfc(float8);
|
||||
extern float16 __attribute__((overloadable)) erfc(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) erf(float);
|
||||
extern float2 __attribute__((overloadable)) erf(float2);
|
||||
extern float3 __attribute__((overloadable)) erf(float3);
|
||||
extern float4 __attribute__((overloadable)) erf(float4);
|
||||
extern float8 __attribute__((overloadable)) erf(float8);
|
||||
extern float16 __attribute__((overloadable)) erf(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) exp(float);
|
||||
//extern float2 __attribute__((overloadable)) exp(float2);
|
||||
//extern float3 __attribute__((overloadable)) exp(float3);
|
||||
//extern float4 __attribute__((overloadable)) exp(float4);
|
||||
//extern float8 __attribute__((overloadable)) exp(float8);
|
||||
//extern float16 __attribute__((overloadable)) exp(float16);
|
||||
extern float2 __attribute__((overloadable)) exp(float2);
|
||||
extern float3 __attribute__((overloadable)) exp(float3);
|
||||
extern float4 __attribute__((overloadable)) exp(float4);
|
||||
extern float8 __attribute__((overloadable)) exp(float8);
|
||||
extern float16 __attribute__((overloadable)) exp(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) exp2(float);
|
||||
//extern float2 __attribute__((overloadable)) exp2(float2);
|
||||
//extern float3 __attribute__((overloadable)) exp2(float3);
|
||||
//extern float4 __attribute__((overloadable)) exp2(float4);
|
||||
//extern float8 __attribute__((overloadable)) exp2(float8);
|
||||
//extern float16 __attribute__((overloadable)) exp2(float16);
|
||||
extern float2 __attribute__((overloadable)) exp2(float2);
|
||||
extern float3 __attribute__((overloadable)) exp2(float3);
|
||||
extern float4 __attribute__((overloadable)) exp2(float4);
|
||||
extern float8 __attribute__((overloadable)) exp2(float8);
|
||||
extern float16 __attribute__((overloadable)) exp2(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) exp10(float);
|
||||
//extern float2 __attribute__((overloadable)) exp10(float2);
|
||||
//extern float3 __attribute__((overloadable)) exp10(float3);
|
||||
//extern float4 __attribute__((overloadable)) exp10(float4);
|
||||
//extern float8 __attribute__((overloadable)) exp10(float8);
|
||||
//extern float16 __attribute__((overloadable)) exp10(float16);
|
||||
extern float2 __attribute__((overloadable)) exp10(float2);
|
||||
extern float3 __attribute__((overloadable)) exp10(float3);
|
||||
extern float4 __attribute__((overloadable)) exp10(float4);
|
||||
extern float8 __attribute__((overloadable)) exp10(float8);
|
||||
extern float16 __attribute__((overloadable)) exp10(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) expm1(float);
|
||||
extern float2 __attribute__((overloadable)) expm1(float2);
|
||||
extern float3 __attribute__((overloadable)) expm1(float3);
|
||||
extern float4 __attribute__((overloadable)) expm1(float4);
|
||||
extern float8 __attribute__((overloadable)) expm1(float8);
|
||||
extern float16 __attribute__((overloadable)) expm1(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) fabs(float);
|
||||
//extern float2 __attribute__((overloadable)) fabs(float2);
|
||||
//extern float3 __attribute__((overloadable)) fabs(float3);
|
||||
//extern float4 __attribute__((overloadable)) fabs(float4);
|
||||
//extern float8 __attribute__((overloadable)) fabs(float8);
|
||||
//extern float16 __attribute__((overloadable)) fabs(float16);
|
||||
extern float2 __attribute__((overloadable)) fabs(float2);
|
||||
extern float3 __attribute__((overloadable)) fabs(float3);
|
||||
extern float4 __attribute__((overloadable)) fabs(float4);
|
||||
extern float8 __attribute__((overloadable)) fabs(float8);
|
||||
extern float16 __attribute__((overloadable)) fabs(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) fdim(float, float);
|
||||
extern float2 __attribute__((overloadable)) fdim(float2, float2);
|
||||
extern float3 __attribute__((overloadable)) fdim(float3, float3);
|
||||
extern float4 __attribute__((overloadable)) fdim(float4, float4);
|
||||
extern float8 __attribute__((overloadable)) fdim(float8, float8);
|
||||
extern float16 __attribute__((overloadable)) fdim(float16, float16);
|
||||
|
||||
extern float __attribute__((overloadable)) floor(float);
|
||||
//extern float2 __attribute__((overloadable)) floor(float2);
|
||||
//extern float3 __attribute__((overloadable)) floor(float3);
|
||||
//extern float4 __attribute__((overloadable)) floor(float4);
|
||||
//extern float8 __attribute__((overloadable)) floor(float8);
|
||||
//extern float16 __attribute__((overloadable)) floor(float16);
|
||||
extern float2 __attribute__((overloadable)) floor(float2);
|
||||
extern float3 __attribute__((overloadable)) floor(float3);
|
||||
extern float4 __attribute__((overloadable)) floor(float4);
|
||||
extern float8 __attribute__((overloadable)) floor(float8);
|
||||
extern float16 __attribute__((overloadable)) floor(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) fma(float, float, float);
|
||||
extern float2 __attribute__((overloadable)) fma(float2, float2, float2);
|
||||
extern float3 __attribute__((overloadable)) fma(float3, float3, float3);
|
||||
extern float4 __attribute__((overloadable)) fma(float4, float4, float4);
|
||||
extern float8 __attribute__((overloadable)) fma(float8, float8, float8);
|
||||
extern float16 __attribute__((overloadable)) fma(float16, float16, float16);
|
||||
|
||||
extern float __attribute__((overloadable)) fmax(float, float);
|
||||
//extern float2 __attribute__((overloadable)) fmax(float2, float2);
|
||||
//extern float3 __attribute__((overloadable)) fmax(float3, float3);
|
||||
//extern float4 __attribute__((overloadable)) fmax(float4, float4);
|
||||
//extern float8 __attribute__((overloadable)) fmax(float8, float8);
|
||||
//extern float16 __attribute__((overloadable)) fmax(float16, float16);
|
||||
//extern float2 __attribute__((overloadable)) fmax(float2, float);
|
||||
//extern float3 __attribute__((overloadable)) fmax(float3, float);
|
||||
//extern float4 __attribute__((overloadable)) fmax(float4, float);
|
||||
//extern float8 __attribute__((overloadable)) fmax(float8, float);
|
||||
//extern float16 __attribute__((overloadable)) fmax(float16, float);
|
||||
extern float2 __attribute__((overloadable)) fmax(float2, float2);
|
||||
extern float3 __attribute__((overloadable)) fmax(float3, float3);
|
||||
extern float4 __attribute__((overloadable)) fmax(float4, float4);
|
||||
extern float8 __attribute__((overloadable)) fmax(float8, float8);
|
||||
extern float16 __attribute__((overloadable)) fmax(float16, float16);
|
||||
extern float2 __attribute__((overloadable)) fmax(float2, float);
|
||||
extern float3 __attribute__((overloadable)) fmax(float3, float);
|
||||
extern float4 __attribute__((overloadable)) fmax(float4, float);
|
||||
extern float8 __attribute__((overloadable)) fmax(float8, float);
|
||||
extern float16 __attribute__((overloadable)) fmax(float16, float);
|
||||
|
||||
extern float __attribute__((overloadable)) fmin(float, float);
|
||||
//extern float2 __attribute__((overloadable)) fmin(float2, float2);
|
||||
//extern float3 __attribute__((overloadable)) fmin(float3, float3);
|
||||
//extern float4 __attribute__((overloadable)) fmin(float4, float4);
|
||||
//extern float8 __attribute__((overloadable)) fmin(float8, float8);
|
||||
//extern float16 __attribute__((overloadable)) fmin(float16, float16);
|
||||
//extern float2 __attribute__((overloadable)) fmin(float2, float);
|
||||
//extern float3 __attribute__((overloadable)) fmin(float3, float);
|
||||
//extern float4 __attribute__((overloadable)) fmin(float4, float);
|
||||
//extern float8 __attribute__((overloadable)) fmin(float8, float);
|
||||
//extern float16 __attribute__((overloadable)) fmin(float16, float);
|
||||
extern float2 __attribute__((overloadable)) fmin(float2, float2);
|
||||
extern float3 __attribute__((overloadable)) fmin(float3, float3);
|
||||
extern float4 __attribute__((overloadable)) fmin(float4, float4);
|
||||
extern float8 __attribute__((overloadable)) fmin(float8, float8);
|
||||
extern float16 __attribute__((overloadable)) fmin(float16, float16);
|
||||
extern float2 __attribute__((overloadable)) fmin(float2, float);
|
||||
extern float3 __attribute__((overloadable)) fmin(float3, float);
|
||||
extern float4 __attribute__((overloadable)) fmin(float4, float);
|
||||
extern float8 __attribute__((overloadable)) fmin(float8, float);
|
||||
extern float16 __attribute__((overloadable)) fmin(float16, float);
|
||||
|
||||
extern float __attribute__((overloadable)) fmod(float, float);
|
||||
//extern float2 __attribute__((overloadable)) fmod(float2, float2);
|
||||
//extern float3 __attribute__((overloadable)) fmod(float3, float3);
|
||||
//extern float4 __attribute__((overloadable)) fmod(float4, float4);
|
||||
//extern float8 __attribute__((overloadable)) fmod(float8, float8);
|
||||
//extern float16 __attribute__((overloadable)) fmod(float16, float16);
|
||||
extern float2 __attribute__((overloadable)) fmod(float2, float2);
|
||||
extern float3 __attribute__((overloadable)) fmod(float3, float3);
|
||||
extern float4 __attribute__((overloadable)) fmod(float4, float4);
|
||||
extern float8 __attribute__((overloadable)) fmod(float8, float8);
|
||||
extern float16 __attribute__((overloadable)) fmod(float16, float16);
|
||||
|
||||
extern float __attribute__((overloadable)) fract(float, float *);
|
||||
extern float2 __attribute__((overloadable)) fract(float2, float2 *);
|
||||
extern float3 __attribute__((overloadable)) fract(float3, float3 *);
|
||||
extern float4 __attribute__((overloadable)) fract(float4, float4 *);
|
||||
extern float8 __attribute__((overloadable)) fract(float8, float8 *);
|
||||
extern float16 __attribute__((overloadable)) fract(float16, float16 *);
|
||||
|
||||
extern float __attribute__((overloadable)) frexp(float, float *);
|
||||
extern float2 __attribute__((overloadable)) frexp(float2, float2 *);
|
||||
extern float3 __attribute__((overloadable)) frexp(float3, float3 *);
|
||||
extern float4 __attribute__((overloadable)) frexp(float4, float4 *);
|
||||
extern float8 __attribute__((overloadable)) frexp(float8, float8 *);
|
||||
extern float16 __attribute__((overloadable)) frexp(float16, float16 *);
|
||||
|
||||
extern float __attribute__((overloadable)) hypot(float, float);
|
||||
extern float2 __attribute__((overloadable)) hypot(float2, float2);
|
||||
extern float3 __attribute__((overloadable)) hypot(float3, float3);
|
||||
extern float4 __attribute__((overloadable)) hypot(float4, float4);
|
||||
extern float8 __attribute__((overloadable)) hypot(float8, float8);
|
||||
extern float16 __attribute__((overloadable)) hypot(float16, float16);
|
||||
|
||||
extern int __attribute__((overloadable)) ilogb(float);
|
||||
extern int2 __attribute__((overloadable)) ilogb(float2);
|
||||
extern int3 __attribute__((overloadable)) ilogb(float3);
|
||||
extern int4 __attribute__((overloadable)) ilogb(float4);
|
||||
extern int8 __attribute__((overloadable)) ilogb(float8);
|
||||
extern int16 __attribute__((overloadable)) ilogb(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) ldexp(float, int);
|
||||
extern float2 __attribute__((overloadable)) ldexp(float2, int2);
|
||||
extern float3 __attribute__((overloadable)) ldexp(float3, int3);
|
||||
extern float4 __attribute__((overloadable)) ldexp(float4, int4);
|
||||
extern float8 __attribute__((overloadable)) ldexp(float8, int8);
|
||||
extern float16 __attribute__((overloadable)) ldexp(float16, int16);
|
||||
extern float2 __attribute__((overloadable)) ldexp(float2, int);
|
||||
extern float3 __attribute__((overloadable)) ldexp(float3, int);
|
||||
extern float4 __attribute__((overloadable)) ldexp(float4, int);
|
||||
extern float8 __attribute__((overloadable)) ldexp(float8, int);
|
||||
extern float16 __attribute__((overloadable)) ldexp(float16, int);
|
||||
|
||||
extern float __attribute__((overloadable)) lgamma(float);
|
||||
extern float2 __attribute__((overloadable)) lgamma(float2);
|
||||
extern float3 __attribute__((overloadable)) lgamma(float3);
|
||||
extern float4 __attribute__((overloadable)) lgamma(float4);
|
||||
extern float8 __attribute__((overloadable)) lgamma(float8);
|
||||
extern float16 __attribute__((overloadable)) lgamma(float16);
|
||||
extern float __attribute__((overloadable)) lgamma(float, float *);
|
||||
extern float2 __attribute__((overloadable)) lgamma(float2, float2 *);
|
||||
extern float3 __attribute__((overloadable)) lgamma(float3, float3 *);
|
||||
extern float4 __attribute__((overloadable)) lgamma(float4, float4 *);
|
||||
extern float8 __attribute__((overloadable)) lgamma(float8, float8 *);
|
||||
extern float16 __attribute__((overloadable)) lgamma(float16, float16 *);
|
||||
|
||||
extern float __attribute__((overloadable)) log(float);
|
||||
//extern float2 __attribute__((overloadable)) log(float2);
|
||||
//extern float3 __attribute__((overloadable)) log(float3);
|
||||
//extern float4 __attribute__((overloadable)) log(float4);
|
||||
//extern float8 __attribute__((overloadable)) log(float8);
|
||||
//extern float16 __attribute__((overloadable)) log(float16);
|
||||
extern float2 __attribute__((overloadable)) log(float2);
|
||||
extern float3 __attribute__((overloadable)) log(float3);
|
||||
extern float4 __attribute__((overloadable)) log(float4);
|
||||
extern float8 __attribute__((overloadable)) log(float8);
|
||||
extern float16 __attribute__((overloadable)) log(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) log2(float);
|
||||
//extern float2 __attribute__((overloadable)) log2(float2);
|
||||
//extern float3 __attribute__((overloadable)) log2(float3);
|
||||
//extern float4 __attribute__((overloadable)) log2(float4);
|
||||
//extern float8 __attribute__((overloadable)) log2(float8);
|
||||
//extern float16 __attribute__((overloadable)) log2(float16);
|
||||
extern float2 __attribute__((overloadable)) log2(float2);
|
||||
extern float3 __attribute__((overloadable)) log2(float3);
|
||||
extern float4 __attribute__((overloadable)) log2(float4);
|
||||
extern float8 __attribute__((overloadable)) log2(float8);
|
||||
extern float16 __attribute__((overloadable)) log2(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) log10(float);
|
||||
//extern float2 __attribute__((overloadable)) log10(float2);
|
||||
//extern float3 __attribute__((overloadable)) log10(float3);
|
||||
//extern float4 __attribute__((overloadable)) log10(float4);
|
||||
//extern float8 __attribute__((overloadable)) log10(float8);
|
||||
//extern float16 __attribute__((overloadable)) log10(float16);
|
||||
extern float2 __attribute__((overloadable)) log10(float2);
|
||||
extern float3 __attribute__((overloadable)) log10(float3);
|
||||
extern float4 __attribute__((overloadable)) log10(float4);
|
||||
extern float8 __attribute__((overloadable)) log10(float8);
|
||||
extern float16 __attribute__((overloadable)) log10(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) max(float, float);
|
||||
//extern float2 __attribute__((overloadable)) max(float2, float2);
|
||||
//extern float3 __attribute__((overloadable)) max(float3, float3);
|
||||
//extern float4 __attribute__((overloadable)) max(float4, float4);
|
||||
//extern float8 __attribute__((overloadable)) max(float8, float8);
|
||||
//extern float16 __attribute__((overloadable)) max(float16, float16);
|
||||
extern float __attribute__((overloadable)) log1p(float);
|
||||
extern float2 __attribute__((overloadable)) log1p(float2);
|
||||
extern float3 __attribute__((overloadable)) log1p(float3);
|
||||
extern float4 __attribute__((overloadable)) log1p(float4);
|
||||
extern float8 __attribute__((overloadable)) log1p(float8);
|
||||
extern float16 __attribute__((overloadable)) log1p(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) min(float, float);
|
||||
//extern float2 __attribute__((overloadable)) min(float2, float2);
|
||||
//extern float3 __attribute__((overloadable)) min(float3, float3);
|
||||
//extern float4 __attribute__((overloadable)) min(float4, float4);
|
||||
//extern float8 __attribute__((overloadable)) min(float8, float8);
|
||||
//extern float16 __attribute__((overloadable)) min(float16, float16);
|
||||
extern float __attribute__((overloadable)) logb(float);
|
||||
extern float2 __attribute__((overloadable)) logb(float2);
|
||||
extern float3 __attribute__((overloadable)) logb(float3);
|
||||
extern float4 __attribute__((overloadable)) logb(float4);
|
||||
extern float8 __attribute__((overloadable)) logb(float8);
|
||||
extern float16 __attribute__((overloadable)) logb(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) mix(float, float, float);
|
||||
//extern float2 __attribute__((overloadable)) mix(float2, float2, float2);
|
||||
//extern float3 __attribute__((overloadable)) mix(float3, float3, float3);
|
||||
//extern float4 __attribute__((overloadable)) mix(float4, float4, float4);
|
||||
//extern float8 __attribute__((overloadable)) mix(float8, float8, float8);
|
||||
//extern float16 __attribute__((overloadable)) mix(float16, float16, float16);
|
||||
//extern float2 __attribute__((overloadable)) mix(float2, float2, float);
|
||||
//extern float3 __attribute__((overloadable)) mix(float3, float3, float);
|
||||
//extern float4 __attribute__((overloadable)) mix(float4, float4, float);
|
||||
//extern float8 __attribute__((overloadable)) mix(float8, float8, float);
|
||||
//extern float16 __attribute__((overloadable)) mix(float16, float16, float);
|
||||
extern float __attribute__((overloadable)) mad(float, float, float);
|
||||
extern float2 __attribute__((overloadable)) mad(float2, float2, float2);
|
||||
extern float3 __attribute__((overloadable)) mad(float3, float3, float3);
|
||||
extern float4 __attribute__((overloadable)) mad(float4, float4, float4);
|
||||
extern float8 __attribute__((overloadable)) mad(float8, float8, float8);
|
||||
extern float16 __attribute__((overloadable)) mad(float16, float16, float16);
|
||||
|
||||
extern float __attribute__((overloadable)) modf(float, float *);
|
||||
extern float2 __attribute__((overloadable)) modf(float2, float2 *);
|
||||
extern float3 __attribute__((overloadable)) modf(float3, float3 *);
|
||||
extern float4 __attribute__((overloadable)) modf(float4, float4 *);
|
||||
extern float8 __attribute__((overloadable)) modf(float8, float8 *);
|
||||
extern float16 __attribute__((overloadable)) modf(float16, float16 *);
|
||||
|
||||
extern float __attribute__((overloadable)) nan(uint);
|
||||
extern float2 __attribute__((overloadable)) nan(uint2);
|
||||
extern float3 __attribute__((overloadable)) nan(uint3);
|
||||
extern float4 __attribute__((overloadable)) nan(uint4);
|
||||
extern float8 __attribute__((overloadable)) nan(uint8);
|
||||
extern float16 __attribute__((overloadable)) nan(uint16);
|
||||
|
||||
extern float __attribute__((overloadable)) nextafter(float, float);
|
||||
extern float2 __attribute__((overloadable)) nextafter(float2, float2);
|
||||
extern float3 __attribute__((overloadable)) nextafter(float3, float3);
|
||||
extern float4 __attribute__((overloadable)) nextafter(float4, float4);
|
||||
extern float8 __attribute__((overloadable)) nextafter(float8, float8);
|
||||
extern float16 __attribute__((overloadable)) nextafter(float16, float16);
|
||||
|
||||
extern float __attribute__((overloadable)) pow(float, float);
|
||||
//extern float2 __attribute__((overloadable)) pow(float2, float2);
|
||||
//extern float3 __attribute__((overloadable)) pow(float3, float3);
|
||||
//extern float4 __attribute__((overloadable)) pow(float4, float4);
|
||||
//extern float8 __attribute__((overloadable)) pow(float8, float8);
|
||||
//extern float16 __attribute__((overloadable)) pow(float16, float16);
|
||||
extern float2 __attribute__((overloadable)) pow(float2, float2);
|
||||
extern float3 __attribute__((overloadable)) pow(float3, float3);
|
||||
extern float4 __attribute__((overloadable)) pow(float4, float4);
|
||||
extern float8 __attribute__((overloadable)) pow(float8, float8);
|
||||
extern float16 __attribute__((overloadable)) pow(float16, float16);
|
||||
|
||||
extern float __attribute__((overloadable)) radians(float);
|
||||
//extern float2 __attribute__((overloadable)) radians(float2);
|
||||
//extern float3 __attribute__((overloadable)) radians(float3);
|
||||
//extern float4 __attribute__((overloadable)) radians(float4);
|
||||
//extern float8 __attribute__((overloadable)) radians(float8);
|
||||
//extern float16 __attribute__((overloadable)) radians(float16);
|
||||
extern float __attribute__((overloadable)) pown(float, int);
|
||||
extern float2 __attribute__((overloadable)) pown(float2, int2);
|
||||
extern float3 __attribute__((overloadable)) pown(float3, int3);
|
||||
extern float4 __attribute__((overloadable)) pown(float4, int4);
|
||||
extern float8 __attribute__((overloadable)) pown(float8, int8);
|
||||
extern float16 __attribute__((overloadable)) pown(float16, int16);
|
||||
|
||||
extern float __attribute__((overloadable)) powr(float, float);
|
||||
extern float2 __attribute__((overloadable)) powr(float2, float2);
|
||||
extern float3 __attribute__((overloadable)) powr(float3, float3);
|
||||
extern float4 __attribute__((overloadable)) powr(float4, float4);
|
||||
extern float8 __attribute__((overloadable)) powr(float8, float8);
|
||||
extern float16 __attribute__((overloadable)) powr(float16, float16);
|
||||
|
||||
extern float __attribute__((overloadable)) remainder(float, float);
|
||||
extern float2 __attribute__((overloadable)) remainder(float2, float2);
|
||||
extern float3 __attribute__((overloadable)) remainder(float3, float3);
|
||||
extern float4 __attribute__((overloadable)) remainder(float4, float4);
|
||||
extern float8 __attribute__((overloadable)) remainder(float8, float8);
|
||||
extern float16 __attribute__((overloadable)) remainder(float16, float16);
|
||||
|
||||
extern float __attribute__((overloadable)) remquo(float, float, float *);
|
||||
extern float2 __attribute__((overloadable)) remquo(float2, float2, float2 *);
|
||||
extern float3 __attribute__((overloadable)) remquo(float3, float3, float3 *);
|
||||
extern float4 __attribute__((overloadable)) remquo(float4, float4, float4 *);
|
||||
extern float8 __attribute__((overloadable)) remquo(float8, float8, float8 *);
|
||||
extern float16 __attribute__((overloadable)) remquo(float16, float16, float16 *);
|
||||
|
||||
extern float __attribute__((overloadable)) rint(float);
|
||||
//extern float2 __attribute__((overloadable)) rint(float2);
|
||||
//extern float3 __attribute__((overloadable)) rint(float3);
|
||||
//extern float4 __attribute__((overloadable)) rint(float4);
|
||||
//extern float8 __attribute__((overloadable)) rint(float8);
|
||||
//extern float16 __attribute__((overloadable)) rint(float16);
|
||||
extern float2 __attribute__((overloadable)) rint(float2);
|
||||
extern float3 __attribute__((overloadable)) rint(float3);
|
||||
extern float4 __attribute__((overloadable)) rint(float4);
|
||||
extern float8 __attribute__((overloadable)) rint(float8);
|
||||
extern float16 __attribute__((overloadable)) rint(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) rootn(float, int);
|
||||
extern float2 __attribute__((overloadable)) rootn(float2, int2);
|
||||
extern float3 __attribute__((overloadable)) rootn(float3, int3);
|
||||
extern float4 __attribute__((overloadable)) rootn(float4, int4);
|
||||
extern float8 __attribute__((overloadable)) rootn(float8, int8);
|
||||
extern float16 __attribute__((overloadable)) rootn(float16, int16);
|
||||
|
||||
extern float __attribute__((overloadable)) round(float);
|
||||
//extern float2 __attribute__((overloadable)) round(float2);
|
||||
//extern float3 __attribute__((overloadable)) round(float3);
|
||||
//extern float4 __attribute__((overloadable)) round(float4);
|
||||
//extern float8 __attribute__((overloadable)) round(float8);
|
||||
//extern float16 __attribute__((overloadable)) round(float16);
|
||||
extern float2 __attribute__((overloadable)) round(float2);
|
||||
extern float3 __attribute__((overloadable)) round(float3);
|
||||
extern float4 __attribute__((overloadable)) round(float4);
|
||||
extern float8 __attribute__((overloadable)) round(float8);
|
||||
extern float16 __attribute__((overloadable)) round(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) rsqrt(float);
|
||||
//extern float2 __attribute__((overloadable)) rsqrt(float2);
|
||||
//extern float3 __attribute__((overloadable)) rsqrt(float3);
|
||||
//extern float4 __attribute__((overloadable)) rsqrt(float4);
|
||||
//extern float8 __attribute__((overloadable)) rsqrt(float8);
|
||||
//extern float16 __attribute__((overloadable)) rsqrt(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) sign(float);
|
||||
//extern float2 __attribute__((overloadable)) sign(float2);
|
||||
//extern float3 __attribute__((overloadable)) sign(float3);
|
||||
//extern float4 __attribute__((overloadable)) sign(float4);
|
||||
//extern float8 __attribute__((overloadable)) sign(float8);
|
||||
//extern float16 __attribute__((overloadable)) sign(float16);
|
||||
extern float2 __attribute__((overloadable)) rsqrt(float2);
|
||||
extern float3 __attribute__((overloadable)) rsqrt(float3);
|
||||
extern float4 __attribute__((overloadable)) rsqrt(float4);
|
||||
extern float8 __attribute__((overloadable)) rsqrt(float8);
|
||||
extern float16 __attribute__((overloadable)) rsqrt(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) sin(float);
|
||||
//extern float2 __attribute__((overloadable)) sin(float2);
|
||||
//extern float3 __attribute__((overloadable)) sin(float3);
|
||||
//extern float4 __attribute__((overloadable)) sin(float4);
|
||||
//extern float8 __attribute__((overloadable)) sin(float8);
|
||||
//extern float16 __attribute__((overloadable)) sin(float16);
|
||||
extern float2 __attribute__((overloadable)) sin(float2);
|
||||
extern float3 __attribute__((overloadable)) sin(float3);
|
||||
extern float4 __attribute__((overloadable)) sin(float4);
|
||||
extern float8 __attribute__((overloadable)) sin(float8);
|
||||
extern float16 __attribute__((overloadable)) sin(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) sincos(float, float *);
|
||||
extern float2 __attribute__((overloadable)) sincos(float2, float2 *);
|
||||
extern float3 __attribute__((overloadable)) sincos(float3, float3 *);
|
||||
extern float4 __attribute__((overloadable)) sincos(float4, float4 *);
|
||||
extern float8 __attribute__((overloadable)) sincos(float8, float8 *);
|
||||
extern float16 __attribute__((overloadable)) sincos(float16, float16 *);
|
||||
|
||||
extern float __attribute__((overloadable)) sinh(float);
|
||||
extern float2 __attribute__((overloadable)) sinh(float2);
|
||||
extern float3 __attribute__((overloadable)) sinh(float3);
|
||||
extern float4 __attribute__((overloadable)) sinh(float4);
|
||||
extern float8 __attribute__((overloadable)) sinh(float8);
|
||||
extern float16 __attribute__((overloadable)) sinh(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) sinpi(float);
|
||||
extern float2 __attribute__((overloadable)) sinpi(float2);
|
||||
extern float3 __attribute__((overloadable)) sinpi(float3);
|
||||
extern float4 __attribute__((overloadable)) sinpi(float4);
|
||||
extern float8 __attribute__((overloadable)) sinpi(float8);
|
||||
extern float16 __attribute__((overloadable)) sinpi(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) sqrt(float);
|
||||
//extern float2 __attribute__((overloadable)) sqrt(float2);
|
||||
//extern float3 __attribute__((overloadable)) sqrt(float3);
|
||||
//extern float4 __attribute__((overloadable)) sqrt(float4);
|
||||
//extern float8 __attribute__((overloadable)) sqrt(float8);
|
||||
//extern float16 __attribute__((overloadable)) sqrt(float16);
|
||||
extern float2 __attribute__((overloadable)) sqrt(float2);
|
||||
extern float3 __attribute__((overloadable)) sqrt(float3);
|
||||
extern float4 __attribute__((overloadable)) sqrt(float4);
|
||||
extern float8 __attribute__((overloadable)) sqrt(float8);
|
||||
extern float16 __attribute__((overloadable)) sqrt(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) tan(float);
|
||||
//extern float2 __attribute__((overloadable)) tan(float2);
|
||||
//extern float3 __attribute__((overloadable)) tan(float3);
|
||||
//extern float4 __attribute__((overloadable)) tan(float4);
|
||||
//extern float8 __attribute__((overloadable)) tan(float8);
|
||||
//extern float16 __attribute__((overloadable)) tan(float16);
|
||||
extern float2 __attribute__((overloadable)) tan(float2);
|
||||
extern float3 __attribute__((overloadable)) tan(float3);
|
||||
extern float4 __attribute__((overloadable)) tan(float4);
|
||||
extern float8 __attribute__((overloadable)) tan(float8);
|
||||
extern float16 __attribute__((overloadable)) tan(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) tanh(float);
|
||||
extern float2 __attribute__((overloadable)) tanh(float2);
|
||||
extern float3 __attribute__((overloadable)) tanh(float3);
|
||||
extern float4 __attribute__((overloadable)) tanh(float4);
|
||||
extern float8 __attribute__((overloadable)) tanh(float8);
|
||||
extern float16 __attribute__((overloadable)) tanh(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) tanpi(float);
|
||||
extern float2 __attribute__((overloadable)) tanpi(float2);
|
||||
extern float3 __attribute__((overloadable)) tanpi(float3);
|
||||
extern float4 __attribute__((overloadable)) tanpi(float4);
|
||||
extern float8 __attribute__((overloadable)) tanpi(float8);
|
||||
extern float16 __attribute__((overloadable)) tanpi(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) tgamma(float);
|
||||
extern float2 __attribute__((overloadable)) tgamma(float2);
|
||||
extern float3 __attribute__((overloadable)) tgamma(float3);
|
||||
extern float4 __attribute__((overloadable)) tgamma(float4);
|
||||
extern float8 __attribute__((overloadable)) tgamma(float8);
|
||||
extern float16 __attribute__((overloadable)) tgamma(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) trunc(float);
|
||||
//extern float2 __attribute__((overloadable)) trunc(float2);
|
||||
//extern float3 __attribute__((overloadable)) trunc(float3);
|
||||
//extern float4 __attribute__((overloadable)) trunc(float4);
|
||||
//extern float8 __attribute__((overloadable)) trunc(float8);
|
||||
//extern float16 __attribute__((overloadable)) trunc(float16);
|
||||
extern float2 __attribute__((overloadable)) trunc(float2);
|
||||
extern float3 __attribute__((overloadable)) trunc(float3);
|
||||
extern float4 __attribute__((overloadable)) trunc(float4);
|
||||
extern float8 __attribute__((overloadable)) trunc(float8);
|
||||
extern float16 __attribute__((overloadable)) trunc(float16);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Int ops
|
||||
// Int ops (partial), 6.11.3
|
||||
extern uint __attribute__((overloadable)) abs(int);
|
||||
extern ushort __attribute__((overloadable)) abs(short);
|
||||
extern uchar __attribute__((overloadable)) abs(char);
|
||||
|
||||
extern int __attribute__((overloadable)) abs(int);
|
||||
//extern int2 __attribute__((overloadable)) abs(int2);
|
||||
//extern int3 __attribute__((overloadable)) abs(int3);
|
||||
//extern int4 __attribute__((overloadable)) abs(int4);
|
||||
//extern int8 __attribute__((overloadable)) abs(int8);
|
||||
//extern int16 __attribute__((overloadable)) abs(int16);
|
||||
extern uint __attribute__((overloadable)) clz(uint);
|
||||
extern int __attribute__((overloadable)) clz(int);
|
||||
extern ushort __attribute__((overloadable)) clz(ushort);
|
||||
extern short __attribute__((overloadable)) clz(short);
|
||||
extern uchar __attribute__((overloadable)) clz(uchar);
|
||||
extern char __attribute__((overloadable)) clz(char);
|
||||
|
||||
extern uint __attribute__((overloadable)) min(uint);
|
||||
extern int __attribute__((overloadable)) min(int);
|
||||
extern ushort __attribute__((overloadable)) min(ushort);
|
||||
extern short __attribute__((overloadable)) min(short);
|
||||
extern uchar __attribute__((overloadable)) min(uchar);
|
||||
extern char __attribute__((overloadable)) min(char);
|
||||
|
||||
extern uint __attribute__((overloadable)) max(uint);
|
||||
extern int __attribute__((overloadable)) max(int);
|
||||
extern ushort __attribute__((overloadable)) max(ushort);
|
||||
extern short __attribute__((overloadable)) max(short);
|
||||
extern uchar __attribute__((overloadable)) max(uchar);
|
||||
extern char __attribute__((overloadable)) max(char);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
extern float modf(float, float);
|
||||
|
||||
// 6.11.4
|
||||
|
||||
extern float __attribute__((overloadable)) clamp(float, float, float);
|
||||
extern float2 __attribute__((overloadable)) clamp(float2, float2, float2);
|
||||
extern float3 __attribute__((overloadable)) clamp(float3, float3, float3);
|
||||
extern float4 __attribute__((overloadable)) clamp(float4, float4, float4);
|
||||
extern float8 __attribute__((overloadable)) clamp(float8, float8, float8);
|
||||
extern float16 __attribute__((overloadable)) clamp(float16, float16, float16);
|
||||
extern float2 __attribute__((overloadable)) clamp(float2, float, float);
|
||||
extern float3 __attribute__((overloadable)) clamp(float3, float, float);
|
||||
extern float4 __attribute__((overloadable)) clamp(float4, float, float);
|
||||
extern float8 __attribute__((overloadable)) clamp(float8, float, float);
|
||||
extern float16 __attribute__((overloadable)) clamp(float16, float, float);
|
||||
|
||||
extern float __attribute__((overloadable)) degrees(float);
|
||||
extern float2 __attribute__((overloadable)) degrees(float2);
|
||||
extern float3 __attribute__((overloadable)) degrees(float3);
|
||||
extern float4 __attribute__((overloadable)) degrees(float4);
|
||||
extern float8 __attribute__((overloadable)) degrees(float8);
|
||||
extern float16 __attribute__((overloadable)) degrees(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) max(float, float);
|
||||
extern float2 __attribute__((overloadable)) max(float2, float2);
|
||||
extern float3 __attribute__((overloadable)) max(float3, float3);
|
||||
extern float4 __attribute__((overloadable)) max(float4, float4);
|
||||
extern float8 __attribute__((overloadable)) max(float8, float8);
|
||||
extern float16 __attribute__((overloadable)) max(float16, float16);
|
||||
extern float2 __attribute__((overloadable)) max(float2, float);
|
||||
extern float3 __attribute__((overloadable)) max(float3, float);
|
||||
extern float4 __attribute__((overloadable)) max(float4, float);
|
||||
extern float8 __attribute__((overloadable)) max(float8, float);
|
||||
extern float16 __attribute__((overloadable)) max(float16, float);
|
||||
|
||||
extern float __attribute__((overloadable)) min(float, float);
|
||||
extern float2 __attribute__((overloadable)) min(float2, float2);
|
||||
extern float3 __attribute__((overloadable)) min(float3, float3);
|
||||
extern float4 __attribute__((overloadable)) min(float4, float4);
|
||||
extern float8 __attribute__((overloadable)) min(float8, float8);
|
||||
extern float16 __attribute__((overloadable)) min(float16, float16);
|
||||
extern float2 __attribute__((overloadable)) min(float2, float);
|
||||
extern float3 __attribute__((overloadable)) min(float3, float);
|
||||
extern float4 __attribute__((overloadable)) min(float4, float);
|
||||
extern float8 __attribute__((overloadable)) min(float8, float);
|
||||
extern float16 __attribute__((overloadable)) min(float16, float);
|
||||
|
||||
extern float __attribute__((overloadable)) mix(float, float, float);
|
||||
extern float2 __attribute__((overloadable)) mix(float2, float2, float2);
|
||||
extern float3 __attribute__((overloadable)) mix(float3, float3, float3);
|
||||
extern float4 __attribute__((overloadable)) mix(float4, float4, float4);
|
||||
extern float8 __attribute__((overloadable)) mix(float8, float8, float8);
|
||||
extern float16 __attribute__((overloadable)) mix(float16, float16, float16);
|
||||
extern float2 __attribute__((overloadable)) mix(float2, float2, float);
|
||||
extern float3 __attribute__((overloadable)) mix(float3, float3, float);
|
||||
extern float4 __attribute__((overloadable)) mix(float4, float4, float);
|
||||
extern float8 __attribute__((overloadable)) mix(float8, float8, float);
|
||||
extern float16 __attribute__((overloadable)) mix(float16, float16, float);
|
||||
|
||||
extern float __attribute__((overloadable)) radians(float);
|
||||
extern float2 __attribute__((overloadable)) radians(float2);
|
||||
extern float3 __attribute__((overloadable)) radians(float3);
|
||||
extern float4 __attribute__((overloadable)) radians(float4);
|
||||
extern float8 __attribute__((overloadable)) radians(float8);
|
||||
extern float16 __attribute__((overloadable)) radians(float16);
|
||||
|
||||
extern float __attribute__((overloadable)) step(float, float);
|
||||
extern float2 __attribute__((overloadable)) step(float2, float2);
|
||||
extern float3 __attribute__((overloadable)) step(float3, float3);
|
||||
extern float4 __attribute__((overloadable)) step(float4, float4);
|
||||
extern float8 __attribute__((overloadable)) step(float8, float8);
|
||||
extern float16 __attribute__((overloadable)) step(float16, float16);
|
||||
extern float2 __attribute__((overloadable)) step(float, float2);
|
||||
extern float3 __attribute__((overloadable)) step(float, float3);
|
||||
extern float4 __attribute__((overloadable)) step(float, float4);
|
||||
extern float8 __attribute__((overloadable)) step(float, float8);
|
||||
extern float16 __attribute__((overloadable)) step(float, float16);
|
||||
|
||||
extern float __attribute__((overloadable)) smoothstep(float, float, float);
|
||||
extern float2 __attribute__((overloadable)) smoothstep(float2, float2, float2);
|
||||
extern float3 __attribute__((overloadable)) smoothstep(float3, float3, float3);
|
||||
extern float4 __attribute__((overloadable)) smoothstep(float4, float4, float4);
|
||||
extern float8 __attribute__((overloadable)) smoothstep(float8, float8, float8);
|
||||
extern float16 __attribute__((overloadable)) smoothstep(float16, float16, float16);
|
||||
extern float2 __attribute__((overloadable)) smoothstep(float, float, float2);
|
||||
extern float3 __attribute__((overloadable)) smoothstep(float, float, float3);
|
||||
extern float4 __attribute__((overloadable)) smoothstep(float, float, float4);
|
||||
extern float8 __attribute__((overloadable)) smoothstep(float, float, float8);
|
||||
extern float16 __attribute__((overloadable)) smoothstep(float, float, float16);
|
||||
|
||||
extern float __attribute__((overloadable)) sign(float);
|
||||
extern float2 __attribute__((overloadable)) sign(float2);
|
||||
extern float3 __attribute__((overloadable)) sign(float3);
|
||||
extern float4 __attribute__((overloadable)) sign(float4);
|
||||
extern float8 __attribute__((overloadable)) sign(float8);
|
||||
extern float16 __attribute__((overloadable)) sign(float16);
|
||||
|
||||
// 6.11.5
|
||||
extern float3 __attribute__((overloadable)) cross(float2, float2);
|
||||
extern float3 __attribute__((overloadable)) cross(float3, float3);
|
||||
extern float4 __attribute__((overloadable)) cross(float4, float4);
|
||||
|
||||
extern float __attribute__((overloadable)) dot(float, float);
|
||||
extern float __attribute__((overloadable)) dot(float2, float2);
|
||||
extern float __attribute__((overloadable)) dot(float3, float3);
|
||||
extern float __attribute__((overloadable)) dot(float4, float4);
|
||||
|
||||
extern float __attribute__((overloadable)) distance(float, float);
|
||||
extern float __attribute__((overloadable)) distance(float2, float2);
|
||||
extern float __attribute__((overloadable)) distance(float3, float3);
|
||||
extern float __attribute__((overloadable)) distance(float4, float4);
|
||||
|
||||
extern float __attribute__((overloadable)) length(float);
|
||||
extern float __attribute__((overloadable)) length(float2);
|
||||
extern float __attribute__((overloadable)) length(float3);
|
||||
extern float __attribute__((overloadable)) length(float4);
|
||||
|
||||
extern float __attribute__((overloadable)) normalize(float);
|
||||
extern float2 __attribute__((overloadable)) normalize(float2);
|
||||
extern float3 __attribute__((overloadable)) normalize(float3);
|
||||
extern float4 __attribute__((overloadable)) normalize(float4);
|
||||
|
||||
|
||||
// RS specific functions
|
||||
extern float randf(float);
|
||||
extern float randf2(float, float);
|
||||
extern float fracf(float);
|
||||
extern float lerpf(float, float, float);
|
||||
extern float mapf(float, float, float, float, float);
|
||||
*/
|
||||
|
||||
extern float __attribute__((overloadable)) frac(float);
|
||||
|
||||
extern void debugP(int, void *);
|
||||
extern void debugPi(int, int);
|
||||
extern void debugPf(int, float);
|
||||
extern void debugF(const char *, float);
|
||||
extern void debugI32(const char *, int);
|
||||
extern void debugHexI32(const char *, int);
|
||||
|
||||
extern void matrixLoadIdentity(void *mat);
|
||||
extern void matrixLoadFloat(void *mat, const float *f);
|
||||
extern void matrixLoadMat(void *mat, const void *newmat);
|
||||
extern void matrixLoadRotate(void *mat, float rot, float x, float y, float z);
|
||||
extern void matrixLoadScale(void *mat, float x, float y, float z);
|
||||
extern void matrixLoadTranslate(void *mat, float x, float y, float z);
|
||||
extern void matrixLoadMultiply(void *mat, const void *lhs, const void *rhs);
|
||||
extern void matrixMultiply(void *mat, const void *rhs);
|
||||
extern void matrixRotate(void *mat, float rot, float x, float y, float z);
|
||||
extern void matrixScale(void *mat, float x, float y, float z);
|
||||
extern void matrixTranslate(void *mat, float x, float y, float z);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user