Add USAGE_SHARED to driver.
Change-Id: Ie04f8ee2d6080729660dbe82b3a09af5cd40e239
diff --git a/driver/rsdAllocation.cpp b/driver/rsdAllocation.cpp
index da010b3..b41880a 100644
--- a/driver/rsdAllocation.cpp
+++ b/driver/rsdAllocation.cpp
@@ -286,8 +286,8 @@
} else if (alloc->mHal.state.userProvidedPtr != NULL) {
// user-provided allocation
// limitations: no faces, no LOD, USAGE_SCRIPT only
- if (alloc->mHal.state.usageFlags != RS_ALLOCATION_USAGE_SCRIPT) {
- ALOGE("Can't use user-allocated buffers if usage is not USAGE_SCRIPT");
+ if (alloc->mHal.state.usageFlags != (RS_ALLOCATION_USAGE_SCRIPT | RS_ALLOCATION_USAGE_SHARED)) {
+ ALOGE("Can't use user-allocated buffers if usage is not USAGE_SCRIPT and USAGE_SHARED");
return false;
}
if (alloc->getType()->getDimLOD() || alloc->getType()->getDimFaces()) {
@@ -358,7 +358,7 @@
if (alloc->mHal.drvState.lod[0].mallocPtr) {
// don't free user-allocated ptrs
- if (!alloc->mHal.state.userProvidedPtr) {
+ if (!(alloc->mHal.state.usageFlags & RS_ALLOCATION_USAGE_SHARED)) {
free(alloc->mHal.drvState.lod[0].mallocPtr);
}
alloc->mHal.drvState.lod[0].mallocPtr = NULL;
@@ -373,6 +373,11 @@
void rsdAllocationResize(const Context *rsc, const Allocation *alloc,
const Type *newType, bool zeroNew) {
+ // can't resize Allocations with user-allocated buffers
+ if (alloc->mHal.state.usageFlags & RS_ALLOCATION_USAGE_SHARED) {
+ ALOGE("Resize cannot be called on a USAGE_SHARED allocation");
+ return;
+ }
void * oldPtr = alloc->mHal.drvState.lod[0].mallocPtr;
// Calculate the object size
size_t s = AllocationBuildPointerTable(rsc, alloc, newType, NULL);