gralloc1: Support GPU_DATA_BUFFER and SENSOR_DIRECT_DATA
* These buffers can have any RGB format * Should not use UBWC * Should be uncached * 4k aligned CRs-Fixed: 2037674 Change-Id: I49c88b1914f8a4247137ae5b64276f0346977a71
This commit is contained in:
@@ -96,7 +96,7 @@ Allocator::~Allocator() {
|
||||
int Allocator::AllocateMem(AllocData *alloc_data, gralloc1_producer_usage_t prod_usage,
|
||||
gralloc1_consumer_usage_t cons_usage) {
|
||||
int ret;
|
||||
alloc_data->uncached = UseUncached(prod_usage);
|
||||
alloc_data->uncached = UseUncached(prod_usage, cons_usage);
|
||||
|
||||
// After this point we should have the right heap set, there is no fallback
|
||||
GetIonHeapInfo(prod_usage, cons_usage, &alloc_data->heap_id, &alloc_data->alloc_type,
|
||||
@@ -158,7 +158,8 @@ bool Allocator::CheckForBufferSharing(uint32_t num_descriptors,
|
||||
*max_index = -1;
|
||||
for (uint32_t i = 0; i < num_descriptors; i++) {
|
||||
// Check Cached vs non-cached and all the ION flags
|
||||
cur_uncached = UseUncached(descriptors[i]->GetProducerUsage());
|
||||
cur_uncached = UseUncached(descriptors[i]->GetProducerUsage(),
|
||||
descriptors[i]->GetConsumerUsage());
|
||||
GetIonHeapInfo(descriptors[i]->GetProducerUsage(), descriptors[i]->GetConsumerUsage(),
|
||||
&cur_heap_id, &cur_alloc_type, &cur_ion_flags);
|
||||
|
||||
@@ -225,22 +226,27 @@ int Allocator::GetImplDefinedFormat(gralloc1_producer_usage_t prod_usage,
|
||||
/* The default policy is to return cached buffers unless the client explicity
|
||||
* sets the PRIVATE_UNCACHED flag or indicates that the buffer will be rarely
|
||||
* read or written in software. */
|
||||
// TODO(user) : As of now relying only on producer usage
|
||||
bool Allocator::UseUncached(gralloc1_producer_usage_t usage) {
|
||||
if ((usage & GRALLOC1_PRODUCER_USAGE_PRIVATE_UNCACHED) ||
|
||||
(usage & GRALLOC1_PRODUCER_USAGE_PROTECTED)) {
|
||||
bool Allocator::UseUncached(gralloc1_producer_usage_t prod_usage,
|
||||
gralloc1_consumer_usage_t cons_usage) {
|
||||
if ((prod_usage & GRALLOC1_PRODUCER_USAGE_PRIVATE_UNCACHED) ||
|
||||
(prod_usage & GRALLOC1_PRODUCER_USAGE_PROTECTED)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// CPU read rarely
|
||||
if ((usage & GRALLOC1_PRODUCER_USAGE_CPU_READ) &&
|
||||
!(usage & GRALLOC1_PRODUCER_USAGE_CPU_READ_OFTEN)) {
|
||||
if ((prod_usage & GRALLOC1_PRODUCER_USAGE_CPU_READ) &&
|
||||
!(prod_usage & GRALLOC1_PRODUCER_USAGE_CPU_READ_OFTEN)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// CPU write rarely
|
||||
if ((usage & GRALLOC1_PRODUCER_USAGE_CPU_WRITE) &&
|
||||
!(usage & GRALLOC1_PRODUCER_USAGE_CPU_WRITE_OFTEN)) {
|
||||
if ((prod_usage & GRALLOC1_PRODUCER_USAGE_CPU_WRITE) &&
|
||||
!(prod_usage & GRALLOC1_PRODUCER_USAGE_CPU_WRITE_OFTEN)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((prod_usage & GRALLOC1_PRODUCER_USAGE_SENSOR_DIRECT_DATA) ||
|
||||
(cons_usage & GRALLOC1_CONSUMER_USAGE_GPU_DATA_BUFFER)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -302,5 +308,4 @@ void Allocator::GetIonHeapInfo(gralloc1_producer_usage_t prod_usage,
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
} // namespace gralloc1
|
||||
|
||||
@@ -61,7 +61,7 @@ class Allocator {
|
||||
ssize_t *max_index);
|
||||
int GetImplDefinedFormat(gralloc1_producer_usage_t prod_usage,
|
||||
gralloc1_consumer_usage_t cons_usage, int format);
|
||||
bool UseUncached(gralloc1_producer_usage_t usage);
|
||||
bool UseUncached(gralloc1_producer_usage_t prod_usage, gralloc1_consumer_usage_t cons_usage);
|
||||
|
||||
private:
|
||||
void GetIonHeapInfo(gralloc1_producer_usage_t prod_usage, gralloc1_consumer_usage_t cons_usage,
|
||||
|
||||
@@ -454,7 +454,7 @@ int BufferManager::GetHandleFlags(int format, gralloc1_producer_usage_t prod_usa
|
||||
flags |= private_handle_t::PRIV_FLAGS_DISP_CONSUMER;
|
||||
}
|
||||
|
||||
if (!allocator_->UseUncached(prod_usage)) {
|
||||
if (!allocator_->UseUncached(prod_usage, cons_usage)) {
|
||||
flags |= private_handle_t::PRIV_FLAGS_CACHED;
|
||||
}
|
||||
|
||||
@@ -499,7 +499,7 @@ int BufferManager::AllocateBuffer(const BufferDescriptor &descriptor, buffer_han
|
||||
data.align = GetDataAlignment(format, prod_usage, cons_usage);
|
||||
data.size = ALIGN(size, data.align);
|
||||
data.handle = (uintptr_t) handle;
|
||||
data.uncached = allocator_->UseUncached(prod_usage);
|
||||
data.uncached = allocator_->UseUncached(prod_usage, cons_usage);
|
||||
|
||||
// Allocate buffer memory
|
||||
err = allocator_->AllocateMem(&data, prod_usage, cons_usage);
|
||||
|
||||
Reference in New Issue
Block a user