Building with full librs
Change-Id: I0ccb24e97095978c0052cb1af735966bbfa740e7
diff --git a/tools/a3dconvert/Android.mk b/tools/a3dconvert/Android.mk
index 7bc634e..2b09fbf 100644
--- a/tools/a3dconvert/Android.mk
+++ b/tools/a3dconvert/Android.mk
@@ -29,12 +29,19 @@
ColladaGeometry.cpp \
ColladaLoader.cpp
+# Needed to maintain libRS dependencies
+intermediates := $(call intermediates-dir-for,STATIC_LIBRARIES,libRS,HOST,)
+librs_generated_headers := \
+ $(intermediates)/rsgApiStructs.h \
+ $(intermediates)/rsgApiFuncDecl.h
+LOCAL_GENERATED_SOURCES := $(librs_generated_headers)
LOCAL_C_INCLUDES += external/collada/include
LOCAL_C_INCLUDES += external/collada/include/1.4
LOCAL_C_INCLUDES += frameworks/base/libs/rs
+LOCAL_C_INCLUDES += $(intermediates)
LOCAL_LDLIBS := -lpthread
-LOCAL_STATIC_LIBRARIES += libRSserialize libutils libcutils
+LOCAL_STATIC_LIBRARIES += libRS libutils libcutils
LOCAL_STATIC_LIBRARIES += colladadom libtinyxml libpcrecpp libpcre
include $(BUILD_HOST_EXECUTABLE)
diff --git a/tools/a3dconvert/a3dconvert.cpp b/tools/a3dconvert/a3dconvert.cpp
index 893df10..6094473 100644
--- a/tools/a3dconvert/a3dconvert.cpp
+++ b/tools/a3dconvert/a3dconvert.cpp
@@ -19,24 +19,67 @@
#include "ColladaLoader.h"
#include "ObjLoader.h"
-#include "rsContext.h"
-#include "rsFileA3D.h"
+#include <rsContext.h>
+#include <rsFileA3D.h>
+
+bool rsdAllocationInit(const Context *rsc, Allocation *alloc, bool forceZero) {
+ void * ptr = malloc(alloc->mHal.state.type->getSizeBytes());
+ if (!ptr) {
+ return false;
+ }
+
+ alloc->mHal.drvState.mallocPtr = ptr;
+ if (forceZero) {
+ memset(ptr, 0, alloc->mHal.state.type->getSizeBytes());
+ }
+ return true;
+}
+
+void rsdAllocationDestroy(const Context *rsc, Allocation *alloc) {
+ if (alloc->mHal.drvState.mallocPtr) {
+ free(alloc->mHal.drvState.mallocPtr);
+ alloc->mHal.drvState.mallocPtr = NULL;
+ }
+}
+
+// We only care to implement allocation memory initialization and destruction
+// because we need no other renderscript hal features for serialization
+static RsdHalFunctions FunctionTable = {
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,NULL },
+ {
+ rsdAllocationInit,
+ rsdAllocationDestroy,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
+ },
+ { NULL, NULL, NULL }, { NULL, NULL, NULL }, { NULL, NULL, NULL },
+ { NULL, NULL, NULL }, { NULL, NULL, NULL }, { NULL, NULL },
+ { NULL, NULL, NULL},
+};
+
+// No-op initizlizer for rs context hal since we only
+bool rsdHalInit(Context *rsc, uint32_t version_major, uint32_t version_minor) {
+ rsc->mHal.funcs = FunctionTable;
+ return true;
+}
bool convertToA3D(GeometryLoader *loader, const char *a3dFile) {
if (!loader->getNumMeshes()) {
return false;
}
// Now write all this stuff out
- Context rsc;
- FileA3D file(&rsc);
+ Context *rsc = Context::createContextLite();
+ rsdHalInit(rsc, 0, 0);
+ FileA3D file(rsc);
for (uint32_t i = 0; i < loader->getNumMeshes(); i ++) {
- Mesh *exportedMesh = loader->getMesh(i)->getRsMesh(&rsc);
+ Mesh *exportedMesh = loader->getMesh(i)->getRsMesh(rsc);
file.appendToFile(exportedMesh);
delete exportedMesh;
}
file.writeFile(a3dFile);
+ delete rsc;
return true;
}