Add AllocationCreateStrided to support lib CPU driver

 - Able to create Allocations with arbitrary alignment requirement,
   making Incremental Intrinsic Support able to run with different
   native GPU RS runtime.
 - Make compat mode CPU driver using an additional rs_compat.spec.
 - Add a compat mode only USAGE_INCREMENTAL_SUPPORT.
 - Add AllocationCreateStrided() to take an Alignment requirement (power
   of 2). Only enbled when detect USAGE_INCREMENTAL_SUPPORT.

Change-Id: I66f913c3a2474f93af5a244c0c84460a7a395e71
diff --git a/rsAllocation.cpp b/rsAllocation.cpp
index f024b7d..474ffda 100644
--- a/rsAllocation.cpp
+++ b/rsAllocation.cpp
@@ -59,8 +59,9 @@
     }
 }
 
-Allocation * Allocation::createAllocation(Context *rsc, const Type *type, uint32_t usages,
-                              RsAllocationMipmapControl mc, void * ptr) {
+Allocation * Allocation::createAllocationStrided(Context *rsc, const Type *type, uint32_t usages,
+                                                 RsAllocationMipmapControl mc, void * ptr,
+                                                 size_t requiredAlignment) {
     // Allocation objects must use allocator specified by the driver
     void* allocMem = rsc->mHal.funcs.allocRuntimeMem(sizeof(Allocation), 0);
 
@@ -79,6 +80,11 @@
             rsc->setError(RS_ERROR_FATAL_DRIVER, "Allocation Init called with USAGE_OEM but driver does not support it");
             return nullptr;
         }
+#ifdef RS_COMPATIBILITY_LIB
+    } else if (usages & RS_ALLOCATION_USAGE_INCREMENTAL_SUPPORT){
+        a = new (allocMem) Allocation(rsc, type, usages, mc, ptr);
+        success = rsc->mHal.funcs.allocation.initStrided(rsc, a, type->getElement()->getHasReferences(), requiredAlignment);
+#endif
     } else {
         a = new (allocMem) Allocation(rsc, type, usages, mc, ptr);
         success = rsc->mHal.funcs.allocation.init(rsc, a, type->getElement()->getHasReferences());
@@ -93,6 +99,11 @@
     return a;
 }
 
+Allocation * Allocation::createAllocation(Context *rsc, const Type *type, uint32_t usages,
+                              RsAllocationMipmapControl mc, void * ptr) {
+    return Allocation::createAllocationStrided(rsc, type, usages, mc, ptr, kMinimumRSAlignment);
+}
+
 Allocation * Allocation::createAdapter(Context *rsc, const Allocation *alloc, const Type *type) {
     // Allocation objects must use allocator specified by the driver
     void* allocMem = rsc->mHal.funcs.allocRuntimeMem(sizeof(Allocation), 0);
@@ -726,6 +737,19 @@
     return alloc;
 }
 
+RsAllocation rsi_AllocationCreateStrided(Context *rsc, RsType vtype,
+                                         RsAllocationMipmapControl mipmaps,
+                                         uint32_t usages, uintptr_t ptr,
+                                         size_t requiredAlignment) {
+    Allocation * alloc = Allocation::createAllocationStrided(rsc, static_cast<Type *>(vtype), usages, mipmaps,
+                                                             (void*)ptr, requiredAlignment);
+    if (!alloc) {
+        return nullptr;
+    }
+    alloc->incUserRef();
+    return alloc;
+}
+
 RsAllocation rsi_AllocationCreateFromBitmap(Context *rsc, RsType vtype,
                                             RsAllocationMipmapControl mipmaps,
                                             const void *data, size_t sizeBytes, uint32_t usages) {