Adding USAGE_IO_OUTPUT support for RS Compat lib.
- In allocation driver header, added window buffer struct for compat lib.
- dlopen IO related functions in driver layer.
- Add function to load symbols in rsDispatch.
bug 12924018
Change-Id: I9156a28e458a72db077fe000bd324a369767fc4d
diff --git a/driver/rsdAllocation.cpp b/driver/rsdAllocation.cpp
index 413f1ad..33649c3 100644
--- a/driver/rsdAllocation.cpp
+++ b/driver/rsdAllocation.cpp
@@ -47,7 +47,6 @@
using namespace android;
using namespace android::renderscript;
-
#ifndef RS_COMPATIBILITY_LIB
const static GLenum gFaceOrder[] = {
GL_TEXTURE_CUBE_MAP_POSITIVE_X,
diff --git a/driver/rsdAllocation.h b/driver/rsdAllocation.h
index 510b497..9f13c98 100644
--- a/driver/rsdAllocation.h
+++ b/driver/rsdAllocation.h
@@ -35,6 +35,7 @@
class RsdFrameBufferObj;
struct ANativeWindow;
struct ANativeWindowBuffer;
+struct ANativeWindow_Buffer;
struct DrvAllocation {
// Is this a legal structure to be used as a texture source.
@@ -54,12 +55,14 @@
GLenum glType;
GLenum glFormat;
- ANativeWindow *wndSurface;
+ ANativeWindowBuffer *wndBuffer;
android::GLConsumer *surfaceTexture;
#else
int glTarget;
int glType;
int glFormat;
+
+ ANativeWindow_Buffer *wndBuffer;
#endif
bool useUserProvidedPtr;
@@ -67,7 +70,7 @@
RsdFrameBufferObj * readBackFBO;
ANativeWindow *wnd;
- ANativeWindowBuffer *wndBuffer;
+ ANativeWindow *wndSurface;
};
#ifndef RS_COMPATIBILITY_LIB
diff --git a/driver/rsdCore.cpp b/driver/rsdCore.cpp
index 48959fd..9f1640b 100644
--- a/driver/rsdCore.cpp
+++ b/driver/rsdCore.cpp
@@ -31,6 +31,8 @@
#include "rsdProgramFragment.h"
#include "rsdMesh.h"
#include "rsdFrameBuffer.h"
+#else
+ #include <dlfcn.h>
#endif
#include "rsdSampler.h"
#include "rsdScriptGroup.h"
@@ -56,7 +58,6 @@
#define NATIVE_FUNC(a) nullptr
#endif
-
static RsdHalFunctions FunctionTable = {
NATIVE_FUNC(rsdGLInit),
NATIVE_FUNC(rsdGLShutdown),
@@ -193,11 +194,51 @@
return (RsdCpuReference::CpuScript *)s->mHal.drv;
}
+#ifdef RS_COMPATIBILITY_LIB
+typedef void (*sAllocationDestroyFnPtr) (const Context *rsc, Allocation *alloc);
+typedef void (*sAllocationIoSendFnPtr) (const Context *rsc, Allocation *alloc);
+typedef void (*sAllocationSetSurfaceFnPtr) (const Context *rsc, Allocation *alloc, ANativeWindow *nw);
+static sAllocationDestroyFnPtr sAllocationDestroy;
+static sAllocationIoSendFnPtr sAllocationIoSend;
+static sAllocationSetSurfaceFnPtr sAllocationSetSurface;
+
+static bool loadIOSuppLibSyms() {
+ void* handleIO = nullptr;
+ handleIO = dlopen("libRSSupportIO.so", RTLD_LAZY | RTLD_LOCAL);
+ if (handleIO == nullptr) {
+ ALOGE("Couldn't load libRSSupportIO.so");
+ return false;
+ }
+ sAllocationDestroy = (sAllocationDestroyFnPtr)dlsym(handleIO, "rscAllocationDestroy");
+ if (sAllocationDestroy==nullptr) {
+ ALOGE("Failed to initialize sAllocationDestroy");
+ return false;
+ }
+ sAllocationIoSend = (sAllocationIoSendFnPtr)dlsym(handleIO, "rscAllocationIoSend");
+ if (sAllocationIoSend==nullptr) {
+ ALOGE("Failed to initialize sAllocationIoSend");
+ return false;
+ }
+ sAllocationSetSurface = (sAllocationSetSurfaceFnPtr)dlsym(handleIO, "rscAllocationSetSurface");
+ if (sAllocationSetSurface==nullptr) {
+ ALOGE("Failed to initialize sAllocationIoSend");
+ return false;
+ }
+ return true;
+}
+#endif
+
extern "C" bool rsdHalInit(RsContext c, uint32_t version_major,
uint32_t version_minor) {
Context *rsc = (Context*) c;
+#ifdef RS_COMPATIBILITY_LIB
+ if (loadIOSuppLibSyms()) {
+ FunctionTable.allocation.destroy = sAllocationDestroy;
+ FunctionTable.allocation.ioSend = sAllocationIoSend;
+ FunctionTable.allocation.setSurface = sAllocationSetSurface;
+ }
+#endif
rsc->mHal.funcs = FunctionTable;
-
RsdHal *dc = (RsdHal *)calloc(1, sizeof(RsdHal));
if (!dc) {
ALOGE("Calloc for driver hal failed.");