dvrapi: Pass layer_count down
* We were missing layer count, which would prevent multiview
from working
Bug: 37245304
Test: MultiLayerBufferQueue
Change-Id: I88b41f1aa7665df01e89a7386cbc23b15c9a79b0
diff --git a/services/vr/bufferhubd/buffer_hub.cpp b/services/vr/bufferhubd/buffer_hub.cpp
index 2b2a843..d27f274 100644
--- a/services/vr/bufferhubd/buffer_hub.cpp
+++ b/services/vr/bufferhubd/buffer_hub.cpp
@@ -71,8 +71,9 @@
std::string size = std::to_string(info.width) + " B";
stream << std::setw(14) << size;
} else {
- std::string dimensions =
- std::to_string(info.width) + "x" + std::to_string(info.height);
+ std::string dimensions = std::to_string(info.width) + "x" +
+ std::to_string(info.height) + "x" +
+ std::to_string(info.layer_count);
stream << std::setw(14) << dimensions;
}
stream << " ";
@@ -117,8 +118,9 @@
std::string size = std::to_string(info.width) + " B";
stream << std::setw(14) << size;
} else {
- std::string dimensions =
- std::to_string(info.width) + "x" + std::to_string(info.height);
+ std::string dimensions = std::to_string(info.width) + "x" +
+ std::to_string(info.height) + "x" +
+ std::to_string(info.layer_count);
stream << std::setw(14) << dimensions;
}
stream << " ";
@@ -254,9 +256,10 @@
buffer_id);
return ErrorStatus(EALREADY);
}
-
- auto status = ProducerChannel::Create(this, buffer_id, width, height, format,
- usage, meta_size_bytes);
+ const uint32_t kDefaultLayerCount = 1;
+ auto status = ProducerChannel::Create(this, buffer_id, width, height,
+ kDefaultLayerCount, format, usage,
+ meta_size_bytes);
if (status) {
message.SetChannel(status.take());
return {};
@@ -271,6 +274,7 @@
Message& message, const std::string& name, int user_id, int group_id,
uint32_t width, uint32_t height, uint32_t format, uint64_t usage,
size_t meta_size_bytes) {
+ const uint32_t kDefaultLayerCount = 1;
const int channel_id = message.GetChannelId();
ALOGD_IF(TRACE,
"BufferHubService::OnCreatePersistentBuffer: channel_id=%d name=%s "
@@ -298,8 +302,8 @@
"not have permission to access named buffer: name=%s euid=%d egid=%d",
name.c_str(), euid, euid);
return ErrorStatus(EPERM);
- } else if (!buffer->CheckParameters(width, height, format, usage,
- meta_size_bytes)) {
+ } else if (!buffer->CheckParameters(width, height, kDefaultLayerCount,
+ format, usage, meta_size_bytes)) {
ALOGE(
"BufferHubService::OnCreatePersistentBuffer: Requested an existing "
"buffer with different parameters: name=%s",
@@ -318,7 +322,8 @@
}
} else {
auto status = ProducerChannel::Create(this, channel_id, width, height,
- format, usage, meta_size_bytes);
+ kDefaultLayerCount, format, usage,
+ meta_size_bytes);
if (!status) {
ALOGE("BufferHubService::OnCreateBuffer: Failed to create producer!!");
return status.error_status();
diff --git a/services/vr/bufferhubd/buffer_hub.h b/services/vr/bufferhubd/buffer_hub.h
index e4cdd08..3bc2635 100644
--- a/services/vr/bufferhubd/buffer_hub.h
+++ b/services/vr/bufferhubd/buffer_hub.h
@@ -50,6 +50,7 @@
// Data field for buffer producer.
uint32_t width = 0;
uint32_t height = 0;
+ uint32_t layer_count = 0;
uint32_t format = 0;
uint64_t usage = 0;
std::string name;
@@ -59,12 +60,13 @@
UsagePolicy usage_policy{0, 0, 0, 0};
BufferInfo(int id, size_t consumer_count, uint32_t width, uint32_t height,
- uint32_t format, uint64_t usage, const std::string& name)
+ uint32_t layer_count, uint32_t format, uint64_t usage, const std::string& name)
: id(id),
type(kProducerType),
consumer_count(consumer_count),
width(width),
height(height),
+ layer_count(layer_count),
format(format),
usage(usage),
name(name) {}
diff --git a/services/vr/bufferhubd/producer_channel.cpp b/services/vr/bufferhubd/producer_channel.cpp
index 4005f7e..b9984a0 100644
--- a/services/vr/bufferhubd/producer_channel.cpp
+++ b/services/vr/bufferhubd/producer_channel.cpp
@@ -26,14 +26,15 @@
ProducerChannel::ProducerChannel(BufferHubService* service, int channel_id,
uint32_t width, uint32_t height,
- uint32_t format, uint64_t usage,
- size_t meta_size_bytes, int* error)
+ uint32_t layer_count, uint32_t format,
+ uint64_t usage, size_t meta_size_bytes,
+ int* error)
: BufferHubChannel(service, channel_id, channel_id, kProducerType),
pending_consumers_(0),
producer_owns_(true),
meta_size_bytes_(meta_size_bytes),
meta_(meta_size_bytes ? new uint8_t[meta_size_bytes] : nullptr) {
- const int ret = buffer_.Alloc(width, height, format, usage);
+ const int ret = buffer_.Alloc(width, height, layer_count, format, usage);
if (ret < 0) {
ALOGE("ProducerChannel::ProducerChannel: Failed to allocate buffer: %s",
strerror(-ret));
@@ -47,11 +48,12 @@
Status<std::shared_ptr<ProducerChannel>> ProducerChannel::Create(
BufferHubService* service, int channel_id, uint32_t width, uint32_t height,
- uint32_t format, uint64_t usage, size_t meta_size_bytes) {
+ uint32_t layer_count, uint32_t format, uint64_t usage,
+ size_t meta_size_bytes) {
int error;
std::shared_ptr<ProducerChannel> producer(
- new ProducerChannel(service, channel_id, width, height, format, usage,
- meta_size_bytes, &error));
+ new ProducerChannel(service, channel_id, width, height, layer_count,
+ format, usage, meta_size_bytes, &error));
if (error < 0)
return ErrorStatus(-error);
else
@@ -68,7 +70,8 @@
BufferHubChannel::BufferInfo ProducerChannel::GetBufferInfo() const {
return BufferInfo(buffer_id(), consumer_channels_.size(), buffer_.width(),
- buffer_.height(), buffer_.format(), buffer_.usage(), name_);
+ buffer_.height(), buffer_.layer_count(), buffer_.format(),
+ buffer_.usage(), name_);
}
void ProducerChannel::HandleImpulse(Message& message) {
@@ -346,11 +349,11 @@
// Returns true if the given parameters match the underlying buffer parameters.
bool ProducerChannel::CheckParameters(uint32_t width, uint32_t height,
- uint32_t format, uint64_t usage,
- size_t meta_size_bytes) {
+ uint32_t layer_count, uint32_t format,
+ uint64_t usage, size_t meta_size_bytes) {
return meta_size_bytes == meta_size_bytes_ && buffer_.width() == width &&
- buffer_.height() == height && buffer_.format() == format &&
- buffer_.usage() == usage;
+ buffer_.height() == height && buffer_.layer_count() == layer_count &&
+ buffer_.format() == format && buffer_.usage() == usage;
}
} // namespace dvr
diff --git a/services/vr/bufferhubd/producer_channel.h b/services/vr/bufferhubd/producer_channel.h
index ef1ac80..5ada478 100644
--- a/services/vr/bufferhubd/producer_channel.h
+++ b/services/vr/bufferhubd/producer_channel.h
@@ -32,7 +32,8 @@
static pdx::Status<std::shared_ptr<ProducerChannel>> Create(
BufferHubService* service, int channel_id, uint32_t width,
- uint32_t height, uint32_t format, uint64_t usage, size_t meta_size_bytes);
+ uint32_t height, uint32_t layer_count, uint32_t format, uint64_t usage,
+ size_t meta_size_bytes);
~ProducerChannel() override;
@@ -57,8 +58,8 @@
void RemoveConsumer(ConsumerChannel* channel);
bool CheckAccess(int euid, int egid);
- bool CheckParameters(uint32_t width, uint32_t height, uint32_t format,
- uint64_t usage, size_t meta_size_bytes);
+ bool CheckParameters(uint32_t width, uint32_t height, uint32_t layer_count,
+ uint32_t format, uint64_t usage, size_t meta_size_bytes);
pdx::Status<void> OnProducerMakePersistent(Message& message,
const std::string& name,
@@ -90,8 +91,8 @@
std::string name_;
ProducerChannel(BufferHubService* service, int channel, uint32_t width,
- uint32_t height, uint32_t format, uint64_t usage,
- size_t meta_size_bytes, int* error);
+ uint32_t height, uint32_t layer_count, uint32_t format,
+ uint64_t usage, size_t meta_size_bytes, int* error);
pdx::Status<void> OnProducerPost(
Message& message, LocalFence acquire_fence,
diff --git a/services/vr/bufferhubd/producer_queue_channel.cpp b/services/vr/bufferhubd/producer_queue_channel.cpp
index f052243..886e621 100644
--- a/services/vr/bufferhubd/producer_queue_channel.cpp
+++ b/services/vr/bufferhubd/producer_queue_channel.cpp
@@ -39,14 +39,12 @@
const UsagePolicy& usage_policy) {
// Configuration between |usage_deny_set_mask| and |usage_deny_clear_mask|
// should be mutually exclusive.
- if ((usage_policy.usage_deny_set_mask &
- usage_policy.usage_deny_clear_mask)) {
+ if ((usage_policy.usage_deny_set_mask & usage_policy.usage_deny_clear_mask)) {
ALOGE(
"BufferHubService::OnCreateProducerQueue: illegal usage mask "
"configuration: usage_deny_set_mask=%" PRIx64
" usage_deny_clear_mask=%" PRIx64,
- usage_policy.usage_deny_set_mask,
- usage_policy.usage_deny_clear_mask);
+ usage_policy.usage_deny_set_mask, usage_policy.usage_deny_clear_mask);
return ErrorStatus(EINVAL);
}
@@ -141,8 +139,8 @@
Status<std::vector<std::pair<RemoteChannelHandle, size_t>>>
ProducerQueueChannel::OnProducerQueueAllocateBuffers(
- Message& message, uint32_t width, uint32_t height, uint32_t format,
- uint64_t usage, size_t buffer_count) {
+ Message& message, uint32_t width, uint32_t height, uint32_t layer_count,
+ uint32_t format, uint64_t usage, size_t buffer_count) {
ATRACE_NAME("ProducerQueueChannel::OnProducerQueueAllocateBuffers");
ALOGD_IF(TRACE,
"ProducerQueueChannel::OnProducerQueueAllocateBuffers: "
@@ -176,7 +174,7 @@
(usage & ~usage_policy_.usage_clear_mask) | usage_policy_.usage_set_mask;
for (size_t i = 0; i < buffer_count; i++) {
- auto status = AllocateBuffer(message, width, height, format,
+ auto status = AllocateBuffer(message, width, height, layer_count, format,
effective_usage);
if (!status) {
ALOGE(
@@ -192,8 +190,8 @@
Status<std::pair<RemoteChannelHandle, size_t>>
ProducerQueueChannel::AllocateBuffer(Message& message, uint32_t width,
- uint32_t height, uint32_t format,
- uint64_t usage) {
+ uint32_t height, uint32_t layer_count,
+ uint32_t format, uint64_t usage) {
ATRACE_NAME("ProducerQueueChannel::AllocateBuffer");
ALOGD_IF(TRACE,
"ProducerQueueChannel::AllocateBuffer: producer_channel_id=%d",
@@ -218,13 +216,13 @@
ALOGD_IF(TRACE,
"ProducerQueueChannel::AllocateBuffer: buffer_id=%d width=%u "
- "height=%u format=%u usage=%" PRIx64,
- buffer_id, width, height, format, usage);
+ "height=%u layer_count=%u format=%u usage=%" PRIx64,
+ buffer_id, width, height, layer_count, format, usage);
auto buffer_handle = status.take();
auto producer_channel_status =
- ProducerChannel::Create(service(), buffer_id, width, height, format,
- usage, meta_size_bytes_);
+ ProducerChannel::Create(service(), buffer_id, width, height, layer_count,
+ format, usage, meta_size_bytes_);
if (!producer_channel_status) {
ALOGE(
"ProducerQueueChannel::AllocateBuffer: Failed to create producer "
diff --git a/services/vr/bufferhubd/producer_queue_channel.h b/services/vr/bufferhubd/producer_queue_channel.h
index b43bbf9..28c74cd 100644
--- a/services/vr/bufferhubd/producer_queue_channel.h
+++ b/services/vr/bufferhubd/producer_queue_channel.h
@@ -34,8 +34,8 @@
// handle this as if a new producer is created through kOpCreateBuffer.
pdx::Status<std::vector<std::pair<pdx::RemoteChannelHandle, size_t>>>
OnProducerQueueAllocateBuffers(pdx::Message& message, uint32_t width,
- uint32_t height, uint32_t format,
- uint64_t usage,
+ uint32_t height, uint32_t layer_count,
+ uint32_t format, uint64_t usage,
size_t buffer_count);
// Detach a BufferHubProducer indicated by |slot|. Note that the buffer must
@@ -57,8 +57,8 @@
// Returns the remote channel handle and the slot number for the newly
// allocated buffer.
pdx::Status<std::pair<pdx::RemoteChannelHandle, size_t>> AllocateBuffer(
- pdx::Message& message, uint32_t width, uint32_t height, uint32_t format,
- uint64_t usage);
+ pdx::Message& message, uint32_t width, uint32_t height,
+ uint32_t layer_count, uint32_t format, uint64_t usage);
// Size of the meta data associated with all the buffers allocated from the
// queue. Now we assume the metadata size is immutable once the queue is