Element restructuring. Add support for new basic Element types including the RS objects and vectors(2-4). In theory this paves the way for maintaining type info for RS objects, passing elements for GLSL uiforms/attribs/varyings, and supporting nested structures.
This will break some apps, checkings for other projects will follow to unbreak them.
diff --git a/libs/rs/rsScriptC.cpp b/libs/rs/rsScriptC.cpp
index 3fa9813..9db3127 100644
--- a/libs/rs/rsScriptC.cpp
+++ b/libs/rs/rsScriptC.cpp
@@ -311,9 +311,15 @@
char buf[256];
String8 tmp;
- str->append("struct vec2_s {float x; float y;};");
- str->append("struct vec3_s {float x; float y; float z;};");
- str->append("struct vec4_s {float x; float y; float z; float w;};");
+ 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();
@@ -324,8 +330,9 @@
if (e->getName() && (e->getFieldCount() > 1)) {
String8 s("struct struct_");
s.append(e->getName());
- appendElementBody(&s, e);
+ s.append(e->getCStructBody());
s.append(";\n");
+
s.append("#define ");
s.append(e->getName());
s.append("_t struct struct_");
@@ -337,45 +344,25 @@
str->append(s);
}
- if (t->getName()) {
- for (size_t ct2=0; ct2 < e->getFieldCount(); ct2++) {
- const Element *c = e->getField(ct2);
- tmp.setTo("#define OFFSETOF_");
- tmp.append(t->getName());
- tmp.append("_");
- tmp.append(e->getFieldName(ct2));
- sprintf(buf, " %i\n", ct2);
- tmp.append(buf);
- if (rsc->props.mLogScripts) {
- LOGV(tmp);
- }
- str->append(tmp);
- }
- }
-
if (mSlotNames[ct].length() > 0) {
String8 s;
- if (e->getFieldCount() > 1) {
- if (e->getName()) {
- // Use the named struct
- s.setTo(e->getName());
- s.append("_t *");
- } else {
- // create an struct named from the slot.
- s.setTo("struct ");
- s.append(mSlotNames[ct]);
- s.append("_s");
- appendElementBody(&s, e);
- s.append(";\n");
- s.append("struct ");
- s.append(mSlotNames[ct]);
- s.append("_s * ");
- }
+ if (e->getName()) {
+ // Use the named struct
+ s.setTo(e->getName());
} else {
- // Just make an array
- s.setTo(e->getField(0)->getCType());
- s.append("_t *");
+ // 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) {