diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/rs/Android.mk | 9 | ||||
-rw-r--r-- | libs/rs/RenderScript.h | 23 | ||||
-rw-r--r-- | libs/rs/java/Fountain/res/raw/fountain2.rs | 28 | ||||
-rw-r--r-- | libs/rs/java/ImageProcessing/res/raw/threshold2.rs | 49 | ||||
-rw-r--r-- | libs/rs/rs.spec | 10 | ||||
-rw-r--r-- | libs/rs/rsAllocation.cpp | 2 | ||||
-rw-r--r-- | libs/rs/rsAnimation.cpp | 134 | ||||
-rw-r--r-- | libs/rs/rsAnimation.h | 68 | ||||
-rw-r--r-- | libs/rs/rsContext.cpp | 26 | ||||
-rw-r--r-- | libs/rs/rsContext.h | 5 | ||||
-rw-r--r-- | libs/rs/rsLocklessFifo.cpp | 92 | ||||
-rw-r--r-- | libs/rs/rsLocklessFifo.h | 24 | ||||
-rw-r--r-- | libs/rs/rsMutex.cpp | 64 | ||||
-rw-r--r-- | libs/rs/rsMutex.h | 43 | ||||
-rw-r--r-- | libs/rs/rsSignal.cpp | 98 | ||||
-rw-r--r-- | libs/rs/rsSignal.h | 46 | ||||
-rw-r--r-- | libs/rs/rsg_ScriptJavaClass.cpp | 15 | ||||
-rw-r--r-- | libs/rs/scriptc/rs_geom.rsh | 26 | ||||
-rw-r--r-- | libs/rs/scriptc/rs_graphics.rsh | 2 | ||||
-rw-r--r-- | libs/rs/scriptc/rs_math.rsh | 392 | ||||
-rw-r--r-- | libs/rs/scriptc/rs_types.rsh | 25 |
21 files changed, 843 insertions, 338 deletions
diff --git a/libs/rs/Android.mk b/libs/rs/Android.mk index 98464a0..0b06022 100644 --- a/libs/rs/Android.mk +++ b/libs/rs/Android.mk @@ -76,16 +76,18 @@ ifneq ($(TARGET_SIMULATOR),true) LOCAL_SRC_FILES:= \ rsAdapter.cpp \ rsAllocation.cpp \ + rsAnimation.cpp \ rsComponent.cpp \ rsContext.cpp \ rsDevice.cpp \ rsElement.cpp \ - rsFileA3D.cpp \ + rsFileA3D.cpp \ rsLight.cpp \ rsLocklessFifo.cpp \ rsObjectBase.cpp \ rsMatrix.cpp \ - rsMesh.cpp \ + rsMesh.cpp \ + rsMutex.cpp \ rsNoise.cpp \ rsProgram.cpp \ rsProgramFragment.cpp \ @@ -96,7 +98,8 @@ LOCAL_SRC_FILES:= \ rsScript.cpp \ rsScriptC.cpp \ rsScriptC_Lib.cpp \ - rsShaderCache.cpp \ + rsShaderCache.cpp \ + rsSignal.cpp \ rsSimpleMesh.cpp \ rsThreadIO.cpp \ rsType.cpp \ diff --git a/libs/rs/RenderScript.h b/libs/rs/RenderScript.h index d280f50..7415ba9 100644 --- a/libs/rs/RenderScript.h +++ b/libs/rs/RenderScript.h @@ -30,6 +30,7 @@ extern "C" { typedef void * RsAdapter1D; typedef void * RsAdapter2D; typedef void * RsAllocation; +typedef void * RsAnimation; typedef void * RsContext; typedef void * RsDevice; typedef void * RsElement; @@ -205,7 +206,27 @@ enum RsPrimitive { enum RsError { RS_ERROR_NONE, RS_ERROR_BAD_SHADER, - RS_ERROR_BAD_SCRIPT + RS_ERROR_BAD_SCRIPT, + RS_ERROR_BAD_VALUE, + RS_ERROR_OUT_OF_MEMORY +}; + +enum RsAnimationInterpolation { + RS_ANIMATION_INTERPOLATION_STEP, + RS_ANIMATION_INTERPOLATION_LINEAR, + RS_ANIMATION_INTERPOLATION_BEZIER, + RS_ANIMATION_INTERPOLATION_CARDINAL, + RS_ANIMATION_INTERPOLATION_HERMITE, + RS_ANIMATION_INTERPOLATION_BSPLINE +}; + +enum RsAnimationEdge { + RS_ANIMATION_EDGE_UNDEFINED, + RS_ANIMATION_EDGE_CONSTANT, + RS_ANIMATION_EDGE_GRADIENT, + RS_ANIMATION_EDGE_CYCLE, + RS_ANIMATION_EDGE_OSCILLATE, + RS_ANIMATION_EDGE_CYLE_RELATIVE }; #ifndef NO_RS_FUNCS diff --git a/libs/rs/java/Fountain/res/raw/fountain2.rs b/libs/rs/java/Fountain/res/raw/fountain2.rs index 3301140..5d36e35 100644 --- a/libs/rs/java/Fountain/res/raw/fountain2.rs +++ b/libs/rs/java/Fountain/res/raw/fountain2.rs @@ -1,9 +1,9 @@ // Fountain test script #pragma version(1) -#include "rs_types.rsh" -#include "rs_math.rsh" -#include "rs_graphics.rsh" +#include "../../../../scriptc/rs_types.rsh" +#include "../../../../scriptc/rs_math.rsh" +#include "../../../../scriptc/rs_graphics.rsh" static int newPart = 0; @@ -12,15 +12,15 @@ typedef struct Control_s { int rate; int count; float r, g, b; - rs_allocation partBuffer; rs_mesh partMesh; + rs_allocation partBuffer; } Control_t; Control_t *Control; typedef struct Point_s{ float2 delta; - float2 position; - unsigned int color; + rs_position2 pos; + rs_color4u color; } Point_t; Point_t *point; @@ -33,8 +33,6 @@ int main(int launchID) { 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 | @@ -42,9 +40,11 @@ int main(int launchID) { Point_t * np = &p[newPart]; while (rate--) { - np->delta = vec2Rand(rMax); - np->position.x = x; - np->position.y = y; + 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++; @@ -57,13 +57,13 @@ int main(int launchID) { for (ct=0; ct < count; ct++) { float dy = p->delta.y + 0.15f; - float posy = p->position.y + dy; + float posy = p->pos.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->pos.x += p->delta.x; + p->pos.y = posy; p++; } diff --git a/libs/rs/java/ImageProcessing/res/raw/threshold2.rs b/libs/rs/java/ImageProcessing/res/raw/threshold2.rs new file mode 100644 index 0000000..9f687b5 --- /dev/null +++ b/libs/rs/java/ImageProcessing/res/raw/threshold2.rs @@ -0,0 +1,49 @@ +#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; +} diff --git a/libs/rs/rs.spec b/libs/rs/rs.spec index cb9937c..08aa369 100644 --- a/libs/rs/rs.spec +++ b/libs/rs/rs.spec @@ -480,3 +480,13 @@ SimpleMeshBindVertex { param uint32_t slot } +AnimationCreate { + param const float *inValues + param const float *outValues + param uint32_t valueCount + param RsAnimationInterpolation interp + param RsAnimationEdge pre + param RsAnimationEdge post + ret RsAnimation + } + diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp index 4e8278d..e5ff1d7 100644 --- a/libs/rs/rsAllocation.cpp +++ b/libs/rs/rsAllocation.cpp @@ -170,6 +170,7 @@ void Allocation::uploadToTexture(const Context *rsc) glGenerateMipmap(GL_TEXTURE_2D); } + rsc->checkError("Allocation::uploadToTexture"); } void Allocation::deferedUploadToBufferObject(const Context *rsc) @@ -201,6 +202,7 @@ void Allocation::uploadToBufferObject(const Context *rsc) glBindBuffer(GL_ARRAY_BUFFER, mBufferID); glBufferData(GL_ARRAY_BUFFER, mType->getSizeBytes(), getPtr(), GL_DYNAMIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); + rsc->checkError("Allocation::uploadToBufferObject"); } void Allocation::uploadCheck(const Context *rsc) diff --git a/libs/rs/rsAnimation.cpp b/libs/rs/rsAnimation.cpp new file mode 100644 index 0000000..48c9334 --- /dev/null +++ b/libs/rs/rsAnimation.cpp @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "rsContext.h" +#include "rsAnimation.h" + + +using namespace android; +using namespace android::renderscript; + +/* +Animation::Animation(Context *rsc) : ObjectBase(rsc) +{ + mAllocFile = __FILE__; + mAllocLine = __LINE__; + + mValuesInput = NULL; + mValuesOutput = NULL; + mValueCount = 0; + mInterpolation = RS_ANIMATION_INTERPOLATION_STEP; + mEdgePre = RS_ANIMATION_EDGE_UNDEFINED; + mEdgePost = RS_ANIMATION_EDGE_UNDEFINED; + mInputMin = 0; + mInputMax = 0; +} + +Animation * Animation::create(Context *rsc, + const float *inValues, const float *outValues, + uint32_t valueCount, RsAnimationInterpolation interp, + RsAnimationEdge pre, RsAnimationEdge post) +{ + if (valueCount < 2) { + rsc->setError(RS_ERROR_BAD_VALUE, "Animations require more than 2 values."); + return NULL; + } + Animation *a = new Animation(rsc); + if (!a) { + rsc->setError(RS_ERROR_OUT_OF_MEMORY); + return NULL; + } + + float *vin = (float *)malloc(valueCount * sizeof(float)); + float *vout = (float *)malloc(valueCount * sizeof(float)); + a->mValuesInput = vin; + a->mValuesOutput = vout; + if (a->mValuesInput == NULL || a->mValuesOutput == NULL) { + delete a; + rsc->setError(RS_ERROR_OUT_OF_MEMORY); + return NULL; + } + + a->mEdgePre = pre; + a->mEdgePost = post; + a->mInterpolation = interp; + a->mValueCount = valueCount; + + memcpy(vin, inValues, valueCount * sizeof(float)); + memcpy(vout, outValues, valueCount * sizeof(float)); + a->mInputMin = inValues[0]; + a->mInputMax = inValues[0]; + + bool needSort = false; + for (uint32_t ct=1; ct < valueCount; ct++) { + if (a->mInputMin > vin[ct]) { + needSort = true; + a->mInputMin = vin[ct]; + } + if (a->mInputMax < vin[ct]) { + a->mInputMax = vin[ct]; + } else { + needSort = true; + } + } + + while (1) { + bool changed = false; + for (uint32_t ct=1; ct < valueCount; ct++) { + if (vin[ct-1] > vin[ct]) { + float t = vin[ct-1]; + vin[ct-1] = vin[ct]; + vin[ct] = t; + t = vout[ct-1]; + vout[ct-1] = vout[ct]; + vout[ct] = t; + changed = true; + } + } + if (!changed) break; + } + + return a; +} +*/ + + +///////////////////////////////////////// +// + +namespace android { +namespace renderscript { + +RsAnimation rsi_AnimationCreate(Context *rsc, + const float *inValues, + const float *outValues, + uint32_t valueCount, + RsAnimationInterpolation interp, + RsAnimationEdge pre, + RsAnimationEdge post) +{ + //LOGE("rsi_ElementCreate %i %i %i %i", dt, dk, norm, vecSize); + Animation *a = NULL;//Animation::create(rsc, inValues, outValues, valueCount, interp, pre, post); + if (a != NULL) { + a->incUserRef(); + } + return (RsAnimation)a; +} + + +} +} + diff --git a/libs/rs/rsAnimation.h b/libs/rs/rsAnimation.h new file mode 100644 index 0000000..b8db661 --- /dev/null +++ b/libs/rs/rsAnimation.h @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ANDROID_RS_ANIMATION_H +#define ANDROID_RS_ANIMATION_H + +#include "rsUtils.h" +#include "rsObjectBase.h" + +// --------------------------------------------------------------------------- +namespace android { +namespace renderscript { + + +class Animation : public ObjectBase +{ +public: + ~Animation(); + + static Animation * create(Context *rsc, + const float *inValues, const float *outValues, + uint32_t valueCount, RsAnimationInterpolation, + RsAnimationEdge pre, RsAnimationEdge post); + + float eval(float) const; + + +protected: + Animation(Context *rsc); + + + + float evalInRange(float) const; + + + + const float *mValuesInput; + const float *mValuesOutput; + uint32_t mValueCount; + RsAnimationInterpolation mInterpolation; + RsAnimationEdge mEdgePre; + RsAnimationEdge mEdgePost; + + // derived + float mInputMin; + float mInputMax; +}; + + + + +} +} +#endif //ANDROID_STRUCTURED_ELEMENT_H + diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp index d8a9a99..4107229 100644 --- a/libs/rs/rsContext.cpp +++ b/libs/rs/rsContext.cpp @@ -664,8 +664,7 @@ void Context::appendNameDefines(String8 *str) const bool Context::objDestroyOOBInit() { - int status = pthread_mutex_init(&mObjDestroy.mMutex, NULL); - if (status) { + if (!mObjDestroy.mMutex.init()) { LOGE("Context::ObjDestroyOOBInit mutex init failure"); return false; } @@ -675,9 +674,8 @@ bool Context::objDestroyOOBInit() void Context::objDestroyOOBRun() { if (mObjDestroy.mNeedToEmpty) { - int status = pthread_mutex_lock(&mObjDestroy.mMutex); - if (status) { - LOGE("Context::ObjDestroyOOBRun: error %i locking for OOBRun.", status); + if (!mObjDestroy.mMutex.lock()) { + LOGE("Context::ObjDestroyOOBRun: error locking for OOBRun."); return; } @@ -686,35 +684,25 @@ void Context::objDestroyOOBRun() } mObjDestroy.mDestroyList.clear(); mObjDestroy.mNeedToEmpty = false; - - status = pthread_mutex_unlock(&mObjDestroy.mMutex); - if (status) { - LOGE("Context::ObjDestroyOOBRun: error %i unlocking for set condition.", status); - } + mObjDestroy.mMutex.unlock(); } } void Context::objDestroyOOBDestroy() { rsAssert(!mObjDestroy.mNeedToEmpty); - pthread_mutex_destroy(&mObjDestroy.mMutex); } void Context::objDestroyAdd(ObjectBase *obj) { - int status = pthread_mutex_lock(&mObjDestroy.mMutex); - if (status) { - LOGE("Context::ObjDestroyOOBRun: error %i locking for OOBRun.", status); + if (!mObjDestroy.mMutex.lock()) { + LOGE("Context::ObjDestroyOOBRun: error locking for OOBRun."); return; } mObjDestroy.mNeedToEmpty = true; mObjDestroy.mDestroyList.add(obj); - - status = pthread_mutex_unlock(&mObjDestroy.mMutex); - if (status) { - LOGE("Context::ObjDestroyOOBRun: error %i unlocking for set condition.", status); - } + mObjDestroy.mMutex.unlock(); } uint32_t Context::getMessageToClient(void *data, size_t *receiveLen, size_t bufferLen, bool wait) diff --git a/libs/rs/rsContext.h b/libs/rs/rsContext.h index 82c3687..8e755a9 100644 --- a/libs/rs/rsContext.h +++ b/libs/rs/rsContext.h @@ -18,6 +18,7 @@ #define ANDROID_RS_CONTEXT_H #include "rsUtils.h" +#include "rsMutex.h" #include "rsThreadIO.h" #include "rsType.h" @@ -161,7 +162,7 @@ public: void dumpDebug() const; void checkError(const char *) const; const char * getError(RsError *); - void setError(RsError e, const char *msg); + void setError(RsError e, const char *msg = NULL); mutable const ObjectBase * mObjHead; @@ -227,7 +228,7 @@ protected: struct ObjDestroyOOB { - pthread_mutex_t mMutex; + Mutex mMutex; Vector<ObjectBase *> mDestroyList; bool mNeedToEmpty; }; diff --git a/libs/rs/rsLocklessFifo.cpp b/libs/rs/rsLocklessFifo.cpp index c796520..76ca32e 100644 --- a/libs/rs/rsLocklessFifo.cpp +++ b/libs/rs/rsLocklessFifo.cpp @@ -17,7 +17,7 @@ #include "rsLocklessFifo.h" using namespace android; - +using namespace android::renderscript; LocklessCommandFifo::LocklessCommandFifo() { @@ -128,15 +128,19 @@ void LocklessCommandFifo::flush() //dumpState("flush 2"); } +void LocklessCommandFifo::wait() +{ + while(isEmpty() && !mInShutdown) { + mSignalToControl.set(); + mSignalToWorker.wait(); + } +} + const void * LocklessCommandFifo::get(uint32_t *command, uint32_t *bytesData) { while(1) { //dumpState("get"); - while(isEmpty() && !mInShutdown) { - mSignalToControl.set(); - mSignalToWorker.wait(); - } - + wait(); if (mInShutdown) { *command = 0; *bytesData = 0; @@ -192,79 +196,3 @@ void LocklessCommandFifo::dumpState(const char *s) const LOGV("%s put %p, get %p, buf %p, end %p", s, mPut, mGet, mBuffer, mEnd); } -LocklessCommandFifo::Signal::Signal() -{ - mSet = true; -} - -LocklessCommandFifo::Signal::~Signal() -{ - pthread_mutex_destroy(&mMutex); - pthread_cond_destroy(&mCondition); -} - -bool LocklessCommandFifo::Signal::init() -{ - int status = pthread_mutex_init(&mMutex, NULL); - if (status) { - LOGE("LocklessFifo mutex init failure"); - return false; - } - - status = pthread_cond_init(&mCondition, NULL); - if (status) { - LOGE("LocklessFifo condition init failure"); - pthread_mutex_destroy(&mMutex); - return false; - } - - return true; -} - -void LocklessCommandFifo::Signal::set() -{ - int status; - - status = pthread_mutex_lock(&mMutex); - if (status) { - LOGE("LocklessCommandFifo: error %i locking for set condition.", status); - return; - } - - mSet = true; - - status = pthread_cond_signal(&mCondition); - if (status) { - LOGE("LocklessCommandFifo: error %i on set condition.", status); - } - - status = pthread_mutex_unlock(&mMutex); - if (status) { - LOGE("LocklessCommandFifo: error %i unlocking for set condition.", status); - } -} - -void LocklessCommandFifo::Signal::wait() -{ - int status; - - status = pthread_mutex_lock(&mMutex); - if (status) { - LOGE("LocklessCommandFifo: error %i locking for condition.", status); - return; - } - - if (!mSet) { - status = pthread_cond_wait(&mCondition, &mMutex); - if (status) { - LOGE("LocklessCommandFifo: error %i waiting on condition.", status); - } - } - mSet = false; - - status = pthread_mutex_unlock(&mMutex); - if (status) { - LOGE("LocklessCommandFifo: error %i unlocking for condition.", status); - } -} - diff --git a/libs/rs/rsLocklessFifo.h b/libs/rs/rsLocklessFifo.h index d0a4356..ae906ca 100644 --- a/libs/rs/rsLocklessFifo.h +++ b/libs/rs/rsLocklessFifo.h @@ -19,8 +19,10 @@ #include "rsUtils.h" +#include "rsSignal.h" namespace android { +namespace renderscript { // A simple FIFO to be used as a producer / consumer between two @@ -37,24 +39,7 @@ public: LocklessCommandFifo(); ~LocklessCommandFifo(); - protected: - class Signal { - public: - Signal(); - ~Signal(); - - bool init(); - - void set(); - void wait(); - - protected: - bool mSet; - pthread_mutex_t mMutex; - pthread_cond_t mCondition; - }; - uint8_t * volatile mPut; uint8_t * volatile mGet; uint8_t * mBuffer; @@ -65,14 +50,14 @@ protected: Signal mSignalToWorker; Signal mSignalToControl; - - public: void * reserve(uint32_t bytes); void commit(uint32_t command, uint32_t bytes); void commitSync(uint32_t command, uint32_t bytes); void flush(); + void wait(); + const void * get(uint32_t *command, uint32_t *bytesData); void next(); @@ -88,4 +73,5 @@ private: } +} #endif diff --git a/libs/rs/rsMutex.cpp b/libs/rs/rsMutex.cpp new file mode 100644 index 0000000..37752f2 --- /dev/null +++ b/libs/rs/rsMutex.cpp @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "rsMutex.h" + +using namespace android; +using namespace android::renderscript; + + +Mutex::Mutex() +{ +} + +Mutex::~Mutex() +{ + pthread_mutex_destroy(&mMutex); +} + +bool Mutex::init() +{ + int status = pthread_mutex_init(&mMutex, NULL); + if (status) { + LOGE("Mutex::Mutex init failure"); + return false; + } + return true; +} + +bool Mutex::lock() +{ + int status; + status = pthread_mutex_lock(&mMutex); + if (status) { + LOGE("Mutex: error %i locking.", status); + return false; + } + return true; +} + +bool Mutex::unlock() +{ + int status; + status = pthread_mutex_unlock(&mMutex); + if (status) { + LOGE("Mutex error %i unlocking.", status); + return false; + } + return true; +} + + diff --git a/libs/rs/rsMutex.h b/libs/rs/rsMutex.h new file mode 100644 index 0000000..47725d7 --- /dev/null +++ b/libs/rs/rsMutex.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ANDROID_RS_MUTEX_H +#define ANDROID_RS_MUTEX_H + + +#include "rsUtils.h" + +namespace android { +namespace renderscript { + +class Mutex { +public: + Mutex(); + ~Mutex(); + + bool init(); + bool lock(); + bool unlock(); + +protected: + pthread_mutex_t mMutex; +}; + +} +} + +#endif + diff --git a/libs/rs/rsSignal.cpp b/libs/rs/rsSignal.cpp new file mode 100644 index 0000000..9239bfd --- /dev/null +++ b/libs/rs/rsSignal.cpp @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "rsSignal.h" + +using namespace android; +using namespace android::renderscript; + + +Signal::Signal() +{ + mSet = true; +} + +Signal::~Signal() +{ + pthread_mutex_destroy(&mMutex); + pthread_cond_destroy(&mCondition); +} + +bool Signal::init() +{ + int status = pthread_mutex_init(&mMutex, NULL); + if (status) { + LOGE("LocklessFifo mutex init failure"); + return false; + } + + status = pthread_cond_init(&mCondition, NULL); + if (status) { + LOGE("LocklessFifo condition init failure"); + pthread_mutex_destroy(&mMutex); + return false; + } + + return true; +} + +void Signal::set() +{ + int status; + + status = pthread_mutex_lock(&mMutex); + if (status) { + LOGE("LocklessCommandFifo: error %i locking for set condition.", status); + return; + } + + mSet = true; + + status = pthread_cond_signal(&mCondition); + if (status) { + LOGE("LocklessCommandFifo: error %i on set condition.", status); + } + + status = pthread_mutex_unlock(&mMutex); + if (status) { + LOGE("LocklessCommandFifo: error %i unlocking for set condition.", status); + } +} + +void Signal::wait() +{ + int status; + + status = pthread_mutex_lock(&mMutex); + if (status) { + LOGE("LocklessCommandFifo: error %i locking for condition.", status); + return; + } + + if (!mSet) { + status = pthread_cond_wait(&mCondition, &mMutex); + if (status) { + LOGE("LocklessCommandFifo: error %i waiting on condition.", status); + } + } + mSet = false; + + status = pthread_mutex_unlock(&mMutex); + if (status) { + LOGE("LocklessCommandFifo: error %i unlocking for condition.", status); + } +} + diff --git a/libs/rs/rsSignal.h b/libs/rs/rsSignal.h new file mode 100644 index 0000000..2e760f1 --- /dev/null +++ b/libs/rs/rsSignal.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ANDROID_RS_SIGNAL_H +#define ANDROID_RS_SIGNAL_H + + +#include "rsUtils.h" + +namespace android { +namespace renderscript { + +class Signal { +public: + Signal(); + ~Signal(); + + bool init(); + + void set(); + void wait(); + +protected: + bool mSet; + pthread_mutex_t mMutex; + pthread_cond_t mCondition; +}; + +} +} + +#endif + diff --git a/libs/rs/rsg_ScriptJavaClass.cpp b/libs/rs/rsg_ScriptJavaClass.cpp index cee9f52..0169b98 100644 --- a/libs/rs/rsg_ScriptJavaClass.cpp +++ b/libs/rs/rsg_ScriptJavaClass.cpp @@ -7,8 +7,12 @@ struct Element; struct ElementField { + // An Element Field is a combination of an Element with a name assigned. + const char *name; Element *e; + + ElementField(const char *n, Element *_e) { name = n; e = _e; @@ -20,12 +24,21 @@ struct ElementField { }; struct Element { + // An Element can take one of two forms. + // 1: Basic. It contains a single basic type and vector size. + // 2: Complex. It contains a list of fields with names. Each field + // will in turn be another element. + ElementField *fields; - size_t fieldCount; + size_t fieldCount; // If field count is 0, the element is a Basic type. const char *name; bool generated; + // The basic data type from RenderScript.h RsDataType compType; + + // The vector size of the data type for float2, float3, .... + // Allowed sizes are 2,3,4,8,16 uint32_t compVectorSize; Element() { diff --git a/libs/rs/scriptc/rs_geom.rsh b/libs/rs/scriptc/rs_geom.rsh new file mode 100644 index 0000000..6e9e9fc --- /dev/null +++ b/libs/rs/scriptc/rs_geom.rsh @@ -0,0 +1,26 @@ + +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); + + + + diff --git a/libs/rs/scriptc/rs_graphics.rsh b/libs/rs/scriptc/rs_graphics.rsh index 70cd562..0f03732 100644 --- a/libs/rs/scriptc/rs_graphics.rsh +++ b/libs/rs/scriptc/rs_graphics.rsh @@ -1,5 +1,7 @@ +extern float rand(float max); + extern float2 vec2Rand(float len); extern float3 float3Norm(float3); diff --git a/libs/rs/scriptc/rs_math.rsh b/libs/rs/scriptc/rs_math.rsh index 613c7ca..fba0f8f 100644 --- a/libs/rs/scriptc/rs_math.rsh +++ b/libs/rs/scriptc/rs_math.rsh @@ -1,264 +1,262 @@ // 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); +//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); 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)) 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)) 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)) 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 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 float __attribute__((overloadable)) clamp(float, float, float); -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)) 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)) 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 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)) 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)) 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)) 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)) 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)) 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 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)) 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, 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)) 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 float __attribute__((overloadable)) mix(float, float, float); -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 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)) 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 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)) 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)) 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 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)) 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 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)) 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)) 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); @@ -268,11 +266,11 @@ extern float16 __attribute__((overloadable)) trunc(float16); // Int ops 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 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); diff --git a/libs/rs/scriptc/rs_types.rsh b/libs/rs/scriptc/rs_types.rsh index 4198a74..b710146 100644 --- a/libs/rs/scriptc/rs_types.rsh +++ b/libs/rs/scriptc/rs_types.rsh @@ -68,4 +68,29 @@ typedef int int8 __attribute__((ext_vector_type(8))); typedef int int16 __attribute__((ext_vector_type(16))); +// RS_KIND_POSITION +typedef float rs_position1; +typedef float2 rs_position2; +typedef float3 rs_position3; +typedef float4 rs_position4; + +// RS_KIND_COLOR +typedef float3 rs_color3f; +typedef float4 rs_color4f; +typedef uchar4 rs_color4u; + +// RS_KIND_NORMAL +typedef float3 rs_normal; + +// RS_KIND_POINT_SIZE +typedef float rs_point_size; + +// RS_KIND_TEXTURE +typedef float rs_texture_coord1; +typedef float2 rs_texture_coord2; +typedef float3 rs_texture_coord3; +typedef float4 rs_texture_coord4; + +// RS_KIND_INDEX +typedef ushort rs_index; |