summaryrefslogtreecommitdiffstats
path: root/libs/rs/rsComponent.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libs/rs/rsComponent.cpp')
-rw-r--r--libs/rs/rsComponent.cpp156
1 files changed, 77 insertions, 79 deletions
diff --git a/libs/rs/rsComponent.cpp b/libs/rs/rsComponent.cpp
index 15a56f7..f51b23e 100644
--- a/libs/rs/rsComponent.cpp
+++ b/libs/rs/rsComponent.cpp
@@ -16,7 +16,11 @@
#include "rsComponent.h"
+#ifndef ANDROID_RS_BUILD_FOR_HOST
#include <GLES/gl.h>
+#else
+#include <OpenGL/gl.h>
+#endif
using namespace android;
using namespace android::renderscript;
@@ -91,6 +95,26 @@ void Component::set(RsDataType dt, RsDataKind dk, bool norm, uint32_t vecSize)
mNormalized = true;
rsAssert(mKind == RS_KIND_PIXEL_RGBA);
return;
+
+ case RS_TYPE_MATRIX_4X4:
+ mTypeBits = 16 * 32;
+ rsAssert(mVectorSize == 1);
+ rsAssert(mNormalized == false);
+ rsAssert(mKind == RS_KIND_USER);
+ break;
+ case RS_TYPE_MATRIX_3X3:
+ mTypeBits = 9 * 32;
+ rsAssert(mVectorSize == 1);
+ rsAssert(mNormalized == false);
+ rsAssert(mKind == RS_KIND_USER);
+ break;
+ case RS_TYPE_MATRIX_2X2:
+ mTypeBits = 4 * 32;
+ rsAssert(mVectorSize == 1);
+ rsAssert(mNormalized == false);
+ rsAssert(mKind == RS_KIND_USER);
+ break;
+
case RS_TYPE_ELEMENT:
case RS_TYPE_TYPE:
case RS_TYPE_ALLOCATION:
@@ -148,11 +172,19 @@ void Component::set(RsDataType dt, RsDataKind dk, bool norm, uint32_t vecSize)
case RS_TYPE_UNSIGNED_64:
mTypeBits = 64;
break;
+
+ case RS_TYPE_BOOLEAN:
+ mTypeBits = 8;
+ break;
}
mBits = mTypeBits * mVectorSize;
}
+bool Component::isReference() const
+{
+ return (mType >= RS_TYPE_ELEMENT);
+}
@@ -188,82 +220,6 @@ uint32_t Component::getGLFormat() const
return 0;
}
-static const char * gCTypeStrings[] = {
- 0,
- 0,//"F16",
- "float",
- "double",
- "char",
- "short",
- "int",
- 0,//"S64",
- "char",//U8",
- "short",//U16",
- "int",//U32",
- 0,//"U64",
- 0,//"UP_565",
- 0,//"UP_5551",
- 0,//"UP_4444",
- 0,//"ELEMENT",
- 0,//"TYPE",
- 0,//"ALLOCATION",
- 0,//"SAMPLER",
- 0,//"SCRIPT",
- 0,//"MESH",
- 0,//"PROGRAM_FRAGMENT",
- 0,//"PROGRAM_VERTEX",
- 0,//"PROGRAM_RASTER",
- 0,//"PROGRAM_STORE",
-};
-
-static const char * gCVecTypeStrings[] = {
- 0,
- 0,//"F16",
- "vecF32",
- "vecF64",
- "vecI8",
- "vecI16",
- "vecI32",
- 0,//"S64",
- "vecU8",//U8",
- "vecU16",//U16",
- "vecU32",//U32",
- 0,//"U64",
- 0,//"UP_565",
- 0,//"UP_5551",
- 0,//"UP_4444",
- 0,//"ELEMENT",
- 0,//"TYPE",
- 0,//"ALLOCATION",
- 0,//"SAMPLER",
- 0,//"SCRIPT",
- 0,//"MESH",
- 0,//"PROGRAM_FRAGMENT",
- 0,//"PROGRAM_VERTEX",
- 0,//"PROGRAM_RASTER",
- 0,//"PROGRAM_STORE",
-};
-
-String8 Component::getCType() const
-{
- char buf[64];
- if (mVectorSize == 1) {
- return String8(gCTypeStrings[mType]);
- }
-
- // Yuck, acc WAR
- // Appears to have problems packing chars
- if (mVectorSize == 4 && mType == RS_TYPE_UNSIGNED_8) {
- return String8("int");
- }
-
-
- String8 s(gCVecTypeStrings[mType]);
- sprintf(buf, "_%i_t", mVectorSize);
- s.append(buf);
- return s;
-}
-
String8 Component::getGLSLType() const
{
if (mType == RS_TYPE_SIGNED_32) {
@@ -282,10 +238,19 @@ String8 Component::getGLSLType() const
case 4: return String8("vec4");
}
}
+ if ((mType == RS_TYPE_MATRIX_4X4) && (mVectorSize == 1)) {
+ return String8("mat4");
+ }
+ if ((mType == RS_TYPE_MATRIX_3X3) && (mVectorSize == 1)) {
+ return String8("mat3");
+ }
+ if ((mType == RS_TYPE_MATRIX_2X2) && (mVectorSize == 1)) {
+ return String8("mat2");
+ }
return String8();
}
-static const char * gTypeStrings[] = {
+static const char * gTypeBasicStrings[] = {
"NONE",
"F16",
"F32",
@@ -298,9 +263,16 @@ static const char * gTypeStrings[] = {
"U16",
"U32",
"U64",
+ "BOOLEAN",
"UP_565",
"UP_5551",
"UP_4444",
+ "MATRIX_4X4",
+ "MATRIX_3X3",
+ "MATRIX_2X2",
+};
+
+static const char * gTypeObjStrings[] = {
"ELEMENT",
"TYPE",
"ALLOCATION",
@@ -330,8 +302,34 @@ static const char * gKindStrings[] = {
void Component::dumpLOGV(const char *prefix) const
{
- LOGV("%s Component: %s, %s, vectorSize=%i, bits=%i",
- prefix, gTypeStrings[mType], gKindStrings[mKind], mVectorSize, mBits);
+ if (mType >= RS_TYPE_ELEMENT) {
+ LOGV("%s Component: %s, %s, vectorSize=%i, bits=%i",
+ prefix, gTypeObjStrings[mType - RS_TYPE_ELEMENT], gKindStrings[mKind], mVectorSize, mBits);
+ } else {
+ LOGV("%s Component: %s, %s, vectorSize=%i, bits=%i",
+ prefix, gTypeBasicStrings[mType], gKindStrings[mKind], mVectorSize, mBits);
+ }
+}
+
+void Component::serialize(OStream *stream) const
+{
+ stream->addU8((uint8_t)mType);
+ stream->addU8((uint8_t)mKind);
+ stream->addU8((uint8_t)(mNormalized ? 1 : 0));
+ stream->addU32(mVectorSize);
}
+void Component::loadFromStream(IStream *stream)
+{
+ mType = (RsDataType)stream->loadU8();
+ mKind = (RsDataKind)stream->loadU8();
+ uint8_t temp = stream->loadU8();
+ mNormalized = temp != 0;
+ mVectorSize = stream->loadU32();
+
+ set(mType, mKind, mNormalized, mVectorSize);
+}
+
+
+