diff options
22 files changed, 148 insertions, 289 deletions
diff --git a/libs/vr/libbufferhub/buffer_hub_client.cpp b/libs/vr/libbufferhub/buffer_hub_client.cpp index 07c921fefe..0326084364 100644 --- a/libs/vr/libbufferhub/buffer_hub_client.cpp +++ b/libs/vr/libbufferhub/buffer_hub_client.cpp @@ -53,44 +53,36 @@ Status<LocalChannelHandle> BufferHubBuffer::CreateConsumer() { int BufferHubBuffer::ImportBuffer() { ATRACE_NAME("BufferHubBuffer::ImportBuffer"); - Status<std::vector<NativeBufferHandle<LocalHandle>>> status = - InvokeRemoteMethod<BufferHubRPC::GetBuffers>(); + Status<NativeBufferHandle<LocalHandle>> status = + InvokeRemoteMethod<BufferHubRPC::GetBuffer>(); if (!status) { - ALOGE("BufferHubBuffer::ImportBuffer: Failed to get buffers: %s", + ALOGE("BufferHubBuffer::ImportBuffer: Failed to get buffer: %s", status.GetErrorMessage().c_str()); return -status.error(); - } else if (status.get().empty()) { + } else if (status.get().id() >= 0) { ALOGE( - "BufferHubBuffer::ImportBuffer: Expected to receive at least one " - "buffer handle but got zero!"); + "BufferHubBuffer::ImportBuffer: Expected to receive a buffer handle " + "but got null!"); return -EIO; } - auto buffer_handles = status.take(); + auto buffer_handle = status.take(); - // Stash the buffer id to replace the value in id_. All sub-buffers of a - // buffer hub buffer have the same id. - const int new_id = buffer_handles[0].id(); + // Stash the buffer id to replace the value in id_. + const int new_id = buffer_handle.id(); - // Import all of the buffers. - std::vector<IonBuffer> ion_buffers; - for (auto& handle : buffer_handles) { - const size_t i = &handle - buffer_handles.data(); - ALOGD_IF( - TRACE, - "BufferHubBuffer::ImportBuffer: i=%zu id=%d FdCount=%zu IntCount=%zu", - i, handle.id(), handle.FdCount(), handle.IntCount()); + // Import the buffer. + IonBuffer ion_buffer; + ALOGD_IF( + TRACE, "BufferHubBuffer::ImportBuffer: id=%d FdCount=%zu IntCount=%zu", + buffer_handle.id(), buffer_handle.FdCount(), buffer_handle.IntCount()); - IonBuffer buffer; - const int ret = handle.Import(&buffer); - if (ret < 0) - return ret; + const int ret = buffer_handle.Import(&ion_buffer); + if (ret < 0) + return ret; - ion_buffers.emplace_back(std::move(buffer)); - } - - // If all imports succeed, replace the previous buffers and id. - slices_ = std::move(ion_buffers); + // If the import succeeds, replace the previous buffer and id. + buffer_ = std::move(ion_buffer); id_ = new_id; return 0; } @@ -102,11 +94,11 @@ int BufferHubBuffer::Poll(int timeout_ms) { } int BufferHubBuffer::Lock(int usage, int x, int y, int width, int height, - void** address, size_t index) { - return slices_[index].Lock(usage, x, y, width, height, address); + void** address) { + return buffer_.Lock(usage, x, y, width, height, address); } -int BufferHubBuffer::Unlock(size_t index) { return slices_[index].Unlock(); } +int BufferHubBuffer::Unlock() { return buffer_.Unlock(); } int BufferHubBuffer::GetBlobReadWritePointer(size_t size, void** addr) { int width = static_cast<int>(size); @@ -199,27 +191,24 @@ int BufferConsumer::SetIgnore(bool ignore) { } BufferProducer::BufferProducer(uint32_t width, uint32_t height, uint32_t format, - uint32_t usage, size_t metadata_size, - size_t slice_count) - : BufferProducer(width, height, format, usage, usage, metadata_size, - slice_count) {} + uint32_t usage, size_t metadata_size) + : BufferProducer(width, height, format, usage, usage, metadata_size) {} BufferProducer::BufferProducer(uint32_t width, uint32_t height, uint32_t format, uint64_t producer_usage, uint64_t consumer_usage, - size_t metadata_size, size_t slice_count) + size_t metadata_size) : BASE(BufferHubRPC::kClientPath) { ATRACE_NAME("BufferProducer::BufferProducer"); ALOGD_IF(TRACE, "BufferProducer::BufferProducer: fd=%d width=%u height=%u format=%u " "producer_usage=%" PRIx64 " consumer_usage=%" PRIx64 - " metadata_size=%zu slice_count=%zu", + " metadata_size=%zu", event_fd(), width, height, format, producer_usage, consumer_usage, - metadata_size, slice_count); + metadata_size); // (b/37881101) Deprecate producer/consumer usage auto status = InvokeRemoteMethod<BufferHubRPC::CreateBuffer>( - width, height, format, (producer_usage | consumer_usage), metadata_size, - slice_count); + width, height, format, (producer_usage | consumer_usage), metadata_size); if (!status) { ALOGE( "BufferProducer::BufferProducer: Failed to create producer buffer: %s", @@ -240,28 +229,27 @@ BufferProducer::BufferProducer(uint32_t width, uint32_t height, uint32_t format, BufferProducer::BufferProducer(const std::string& name, int user_id, int group_id, uint32_t width, uint32_t height, uint32_t format, uint32_t usage, - size_t meta_size_bytes, size_t slice_count) + size_t meta_size_bytes) : BufferProducer(name, user_id, group_id, width, height, format, usage, - usage, meta_size_bytes, slice_count) {} + usage, meta_size_bytes) {} BufferProducer::BufferProducer(const std::string& name, int user_id, int group_id, uint32_t width, uint32_t height, uint32_t format, uint64_t producer_usage, - uint64_t consumer_usage, size_t meta_size_bytes, - size_t slice_count) + uint64_t consumer_usage, size_t meta_size_bytes) : BASE(BufferHubRPC::kClientPath) { ATRACE_NAME("BufferProducer::BufferProducer"); ALOGD_IF(TRACE, "BufferProducer::BufferProducer: fd=%d name=%s user_id=%d " "group_id=%d width=%u height=%u format=%u producer_usage=%" PRIx64 - " consumer_usage=%" PRIx64 " meta_size_bytes=%zu slice_count=%zu", + " consumer_usage=%" PRIx64 " meta_size_bytes=%zu", event_fd(), name.c_str(), user_id, group_id, width, height, format, - producer_usage, consumer_usage, meta_size_bytes, slice_count); + producer_usage, consumer_usage, meta_size_bytes); // (b/37881101) Deprecate producer/consumer usage auto status = InvokeRemoteMethod<BufferHubRPC::CreatePersistentBuffer>( name, user_id, group_id, width, height, format, - (producer_usage | consumer_usage), meta_size_bytes, slice_count); + (producer_usage | consumer_usage), meta_size_bytes); if (!status) { ALOGE( "BufferProducer::BufferProducer: Failed to create/get persistent " @@ -296,12 +284,11 @@ BufferProducer::BufferProducer(uint64_t producer_usage, uint64_t consumer_usage, const int height = 1; const int format = HAL_PIXEL_FORMAT_BLOB; const size_t meta_size_bytes = 0; - const size_t slice_count = 1; // (b/37881101) Deprecate producer/consumer usage auto status = InvokeRemoteMethod<BufferHubRPC::CreateBuffer>( - width, height, format, (producer_usage | consumer_usage), meta_size_bytes, - slice_count); + width, height, format, (producer_usage | consumer_usage), + meta_size_bytes); if (!status) { ALOGE("BufferProducer::BufferProducer: Failed to create blob: %s", status.GetErrorMessage().c_str()); @@ -336,12 +323,11 @@ BufferProducer::BufferProducer(const std::string& name, int user_id, const int height = 1; const int format = HAL_PIXEL_FORMAT_BLOB; const size_t meta_size_bytes = 0; - const size_t slice_count = 1; // (b/37881101) Deprecate producer/consumer usage auto status = InvokeRemoteMethod<BufferHubRPC::CreatePersistentBuffer>( name, user_id, group_id, width, height, format, - (producer_usage | consumer_usage), meta_size_bytes, slice_count); + (producer_usage | consumer_usage), meta_size_bytes); if (!status) { ALOGE( "BufferProducer::BufferProducer: Failed to create persistent " diff --git a/libs/vr/libbufferhub/include/private/dvr/buffer_hub_client.h b/libs/vr/libbufferhub/include/private/dvr/buffer_hub_client.h index dbd4110da6..83e9255240 100644 --- a/libs/vr/libbufferhub/include/private/dvr/buffer_hub_client.h +++ b/libs/vr/libbufferhub/include/private/dvr/buffer_hub_client.h @@ -32,20 +32,11 @@ class BufferHubBuffer : public pdx::Client { // the usage is software then |addr| will be updated to point to the address // of the buffer in virtual memory. The caller should only access/modify the // pixels in the specified area. anything else is undefined behavior. - int Lock(int usage, int x, int y, int width, int height, void** addr, - size_t index); + int Lock(int usage, int x, int y, int width, int height, void** addr); // Must be called after Lock() when the caller has finished changing the // buffer. - int Unlock(size_t index); - - // Helper for when index is 0. - int Lock(int usage, int x, int y, int width, int height, void** addr) { - return Lock(usage, x, y, width, height, addr, 0); - } - - // Helper for when index is 0. - int Unlock() { return Unlock(0); } + int Unlock(); // Gets a blob buffer that was created with BufferProducer::CreateBlob. // Locking and Unlocking is handled internally. There's no need to Unlock @@ -85,38 +76,27 @@ class BufferHubBuffer : public pdx::Client { } native_handle_t* native_handle() const { - return const_cast<native_handle_t*>(slices_[0].handle()); + return const_cast<native_handle_t*>(buffer_.handle()); } - // If index is greater than or equal to slice_count(), the result is - // undefined. - native_handle_t* native_handle(size_t index) const { - return const_cast<native_handle_t*>(slices_[index].handle()); - } - - IonBuffer* buffer() { return &slices_[0]; } - const IonBuffer* buffer() const { return &slices_[0]; } - // If index is greater than or equal to slice_count(), the result is - // undefined. - IonBuffer* slice(size_t index) { return &slices_[index]; } - const IonBuffer* slice(size_t index) const { return &slices_[index]; } + IonBuffer* buffer() { return &buffer_; } + const IonBuffer* buffer() const { return &buffer_; } - int slice_count() const { return static_cast<int>(slices_.size()); } int id() const { return id_; } // The following methods return settings of the first buffer. Currently, // it is only possible to create multi-buffer BufferHubBuffers with the same // settings. - uint32_t width() const { return slices_[0].width(); } - uint32_t height() const { return slices_[0].height(); } - uint32_t stride() const { return slices_[0].stride(); } - uint32_t format() const { return slices_[0].format(); } - uint32_t usage() const { return slices_[0].usage(); } - uint32_t layer_count() const { return slices_[0].layer_count(); } + uint32_t width() const { return buffer_.width(); } + uint32_t height() const { return buffer_.height(); } + uint32_t stride() const { return buffer_.stride(); } + uint32_t format() const { return buffer_.format(); } + uint32_t usage() const { return buffer_.usage(); } + uint32_t layer_count() const { return buffer_.layer_count(); } // TODO(b/37881101) Clean up producer/consumer usage. - uint64_t producer_usage() const { return slices_[0].usage(); } - uint64_t consumer_usage() const { return slices_[0].usage(); } + uint64_t producer_usage() const { return buffer_.usage(); } + uint64_t consumer_usage() const { return buffer_.usage(); } protected: explicit BufferHubBuffer(LocalChannelHandle channel); @@ -135,9 +115,7 @@ class BufferHubBuffer : public pdx::Client { // or any other functional purpose as a security precaution. int id_; - // A BufferHubBuffer may contain multiple slices of IonBuffers with same - // configurations. - std::vector<IonBuffer> slices_; + IonBuffer buffer_; }; // This represents a writable buffer. Calling Post notifies all clients and @@ -224,11 +202,10 @@ class BufferProducer : public pdx::ClientBase<BufferProducer, BufferHubBuffer> { // Constructs a buffer with the given geometry and parameters. BufferProducer(uint32_t width, uint32_t height, uint32_t format, - uint32_t usage, size_t metadata_size = 0, - size_t slice_count = 1); + uint32_t usage, size_t metadata_size = 0); BufferProducer(uint32_t width, uint32_t height, uint32_t format, uint64_t producer_usage, uint64_t consumer_usage, - size_t metadata_size, size_t slice_count); + size_t metadata_size); // Constructs a persistent buffer with the given geometry and parameters and // binds it to |name| in one shot. If a persistent buffer with the same name @@ -244,12 +221,11 @@ class BufferProducer : public pdx::ClientBase<BufferProducer, BufferHubBuffer> { // effective user or group id of the calling process. BufferProducer(const std::string& name, int user_id, int group_id, uint32_t width, uint32_t height, uint32_t format, - uint32_t usage, size_t metadata_size = 0, - size_t slice_count = 1); + uint32_t usage, size_t metadata_size = 0); BufferProducer(const std::string& name, int user_id, int group_id, uint32_t width, uint32_t height, uint32_t format, uint64_t producer_usage, uint64_t consumer_usage, - size_t metadata_size, size_t slice_count); + size_t meta_size_bytes); // Constructs a blob (flat) buffer with the given usage flags. BufferProducer(uint32_t usage, size_t size); diff --git a/libs/vr/libbufferhub/include/private/dvr/bufferhub_rpc.h b/libs/vr/libbufferhub/include/private/dvr/bufferhub_rpc.h index c6f0e1e01d..6fee7a0c18 100644 --- a/libs/vr/libbufferhub/include/private/dvr/bufferhub_rpc.h +++ b/libs/vr/libbufferhub/include/private/dvr/bufferhub_rpc.h @@ -166,7 +166,6 @@ struct BufferHubRPC { kOpCreatePersistentBuffer, kOpGetPersistentBuffer, kOpGetBuffer, - kOpGetBuffers, kOpNewConsumer, kOpProducerMakePersistent, kOpProducerRemovePersistence, @@ -192,19 +191,15 @@ struct BufferHubRPC { // Methods. PDX_REMOTE_METHOD(CreateBuffer, kOpCreateBuffer, void(uint32_t width, uint32_t height, uint32_t format, - uint64_t usage, size_t meta_size_bytes, - size_t slice_count)); + uint64_t usage, size_t meta_size_bytes)); PDX_REMOTE_METHOD(CreatePersistentBuffer, kOpCreatePersistentBuffer, void(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, - size_t slice_count)); + uint64_t usage, size_t meta_size_bytes)); PDX_REMOTE_METHOD(GetPersistentBuffer, kOpGetPersistentBuffer, void(const std::string& name)); PDX_REMOTE_METHOD(GetBuffer, kOpGetBuffer, - NativeBufferHandle<LocalHandle>(unsigned index)); - PDX_REMOTE_METHOD(GetBuffers, kOpGetBuffers, - std::vector<NativeBufferHandle<LocalHandle>>(Void)); + NativeBufferHandle<LocalHandle>(Void)); PDX_REMOTE_METHOD(NewConsumer, kOpNewConsumer, LocalChannelHandle(Void)); PDX_REMOTE_METHOD(ProducerMakePersistent, kOpProducerMakePersistent, void(const std::string& name, int user_id, int group_id)); @@ -230,8 +225,7 @@ struct BufferHubRPC { kOpProducerQueueAllocateBuffers, std::vector<std::pair<LocalChannelHandle, size_t>>( uint32_t width, uint32_t height, uint32_t format, - uint64_t usage, size_t slice_count, - size_t buffer_count)); + uint64_t usage, size_t buffer_count)); PDX_REMOTE_METHOD(ProducerQueueDetachBuffer, kOpProducerQueueDetachBuffer, void(size_t slot)); PDX_REMOTE_METHOD(ConsumerQueueImportBuffers, kOpConsumerQueueImportBuffers, diff --git a/libs/vr/libbufferhub/include/private/dvr/native_buffer.h b/libs/vr/libbufferhub/include/private/dvr/native_buffer.h index f9b69750ac..b4ef2f50d7 100644 --- a/libs/vr/libbufferhub/include/private/dvr/native_buffer.h +++ b/libs/vr/libbufferhub/include/private/dvr/native_buffer.h @@ -52,40 +52,11 @@ class NativeBuffer void operator=(NativeBuffer&) = delete; }; -// NativeBufferProducerSlice is an implementation of ANativeWindowBuffer backed -// by a buffer slice of a BufferProducer. -class NativeBufferProducerSlice - : public android::ANativeObjectBase< - ANativeWindowBuffer, NativeBufferProducerSlice, - android::LightRefBase<NativeBufferProducerSlice>> { - public: - NativeBufferProducerSlice(const std::shared_ptr<BufferProducer>& buffer, - int buffer_index) - : BASE(), buffer_(buffer) { - ANativeWindowBuffer::width = buffer_->width(); - ANativeWindowBuffer::height = buffer_->height(); - ANativeWindowBuffer::stride = buffer_->stride(); - ANativeWindowBuffer::format = buffer_->format(); - ANativeWindowBuffer::usage = buffer_->usage(); - handle = buffer_->native_handle(buffer_index); - } - - virtual ~NativeBufferProducerSlice() {} - - private: - friend class android::LightRefBase<NativeBufferProducerSlice>; - - std::shared_ptr<BufferProducer> buffer_; - - NativeBufferProducerSlice(const NativeBufferProducerSlice&) = delete; - void operator=(NativeBufferProducerSlice&) = delete; -}; - // NativeBufferProducer is an implementation of ANativeWindowBuffer backed by a // BufferProducer. class NativeBufferProducer : public android::ANativeObjectBase< - ANativeWindowBuffer, NativeBufferProducer, - android::LightRefBase<NativeBufferProducer>> { + ANativeWindowBuffer, NativeBufferProducer, + android::LightRefBase<NativeBufferProducer>> { public: static constexpr int kEmptyFence = -1; @@ -101,19 +72,6 @@ class NativeBufferProducer : public android::ANativeObjectBase< ANativeWindowBuffer::format = buffer_->format(); ANativeWindowBuffer::usage = buffer_->usage(); handle = buffer_->native_handle(); - for (int i = 0; i < buffer->slice_count(); ++i) { - // display == null means don't create an EGL image. This is used by our - // Vulkan code. - slices_.push_back(new NativeBufferProducerSlice(buffer, i)); - if (display_ != nullptr) { - egl_images_.push_back(eglCreateImageKHR( - display_, EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID, - static_cast<ANativeWindowBuffer*>(slices_.back().get()), nullptr)); - if (egl_images_.back() == EGL_NO_IMAGE_KHR) { - ALOGE("NativeBufferProducer: eglCreateImageKHR failed"); - } - } - } } explicit NativeBufferProducer(const std::shared_ptr<BufferProducer>& buffer) @@ -154,7 +112,6 @@ class NativeBufferProducer : public android::ANativeObjectBase< std::shared_ptr<BufferProducer> buffer_; pdx::LocalHandle release_fence_; - std::vector<android::sp<NativeBufferProducerSlice>> slices_; std::vector<EGLImageKHR> egl_images_; uint32_t surface_buffer_index_; EGLDisplay display_; @@ -171,21 +128,16 @@ class NativeBufferConsumer : public android::ANativeObjectBase< public: static constexpr int kEmptyFence = -1; - explicit NativeBufferConsumer(const std::shared_ptr<BufferConsumer>& buffer, - int index) + explicit NativeBufferConsumer(const std::shared_ptr<BufferConsumer>& buffer) : BASE(), buffer_(buffer), acquire_fence_(kEmptyFence), sequence_(0) { ANativeWindowBuffer::width = buffer_->width(); ANativeWindowBuffer::height = buffer_->height(); ANativeWindowBuffer::stride = buffer_->stride(); ANativeWindowBuffer::format = buffer_->format(); ANativeWindowBuffer::usage = buffer_->usage(); - LOG_ALWAYS_FATAL_IF(buffer_->slice_count() <= index); - handle = buffer_->slice(index)->handle(); + handle = buffer_->native_handle(); } - explicit NativeBufferConsumer(const std::shared_ptr<BufferConsumer>& buffer) - : NativeBufferConsumer(buffer, 0) {} - virtual ~NativeBufferConsumer() {} std::shared_ptr<BufferConsumer> buffer() const { return buffer_; } diff --git a/libs/vr/libbufferhubqueue/buffer_hub_queue_client.cpp b/libs/vr/libbufferhubqueue/buffer_hub_queue_client.cpp index b381d22467..a081af0197 100644 --- a/libs/vr/libbufferhubqueue/buffer_hub_queue_client.cpp +++ b/libs/vr/libbufferhubqueue/buffer_hub_queue_client.cpp @@ -2,8 +2,8 @@ #include <inttypes.h> #include <log/log.h> -#include <sys/epoll.h> #include <poll.h> +#include <sys/epoll.h> #include <array> @@ -390,7 +390,7 @@ ProducerQueue::ProducerQueue(size_t meta_size, uint64_t usage_set_mask, int ProducerQueue::AllocateBuffer(uint32_t width, uint32_t height, uint32_t format, uint64_t usage, - size_t slice_count, size_t* out_slot) { + size_t* out_slot) { if (out_slot == nullptr) { ALOGE("ProducerQueue::AllocateBuffer: Parameter out_slot cannot be null."); return -EINVAL; @@ -405,7 +405,7 @@ int ProducerQueue::AllocateBuffer(uint32_t width, uint32_t height, const size_t kBufferCount = 1U; Status<std::vector<std::pair<LocalChannelHandle, size_t>>> status = InvokeRemoteMethod<BufferHubRPC::ProducerQueueAllocateBuffers>( - width, height, format, usage, slice_count, kBufferCount); + width, height, format, usage, kBufferCount); if (!status) { ALOGE("ProducerQueue::AllocateBuffer failed to create producer buffer: %s", status.GetErrorMessage().c_str()); diff --git a/libs/vr/libbufferhubqueue/buffer_hub_queue_core.cpp b/libs/vr/libbufferhubqueue/buffer_hub_queue_core.cpp index 00ff1374c2..8e9501a9da 100644 --- a/libs/vr/libbufferhubqueue/buffer_hub_queue_core.cpp +++ b/libs/vr/libbufferhubqueue/buffer_hub_queue_core.cpp @@ -33,14 +33,13 @@ BufferHubQueueCore::BufferHubQueueCore() unique_id_(getUniqueId()) {} status_t BufferHubQueueCore::AllocateBuffer(uint32_t width, uint32_t height, - PixelFormat format, uint32_t usage, - size_t slice_count) { + PixelFormat format, + uint32_t usage) { size_t slot; // Allocate new buffer through BufferHub and add it into |producer_| queue for // bookkeeping. - if (producer_->AllocateBuffer(width, height, format, usage, slice_count, - &slot) < 0) { + if (producer_->AllocateBuffer(width, height, format, usage, &slot) < 0) { ALOGE("Failed to allocate new buffer in BufferHub."); return NO_MEMORY; } diff --git a/libs/vr/libbufferhubqueue/buffer_hub_queue_producer.cpp b/libs/vr/libbufferhubqueue/buffer_hub_queue_producer.cpp index 435cba44ba..81e1669da7 100644 --- a/libs/vr/libbufferhubqueue/buffer_hub_queue_producer.cpp +++ b/libs/vr/libbufferhubqueue/buffer_hub_queue_producer.cpp @@ -128,7 +128,7 @@ status_t BufferHubQueueProducer::dequeueBuffer( // |max_dequeued_buffer_count_|, allocate new buffer. // TODO(jwcai) To save memory, the really reasonable thing to do is to go // over existing slots and find first existing one to dequeue. - ret = core_->AllocateBuffer(width, height, format, usage, 1); + ret = core_->AllocateBuffer(width, height, format, usage); if (ret < 0) return ret; } @@ -138,7 +138,7 @@ status_t BufferHubQueueProducer::dequeueBuffer( for (size_t retry = 0; retry < BufferHubQueue::kMaxQueueCapacity; retry++) { LocalHandle fence; - auto buffer_status = + auto buffer_status = core_->producer_->Dequeue(core_->dequeue_timeout_ms_, &slot, &fence); buffer_producer = buffer_status.take(); @@ -172,7 +172,7 @@ status_t BufferHubQueueProducer::dequeueBuffer( // there are already multiple buffers in the queue, the next one returned // from |core_->producer_->Dequeue| may not be the new buffer we just // reallocated. Retry up to BufferHubQueue::kMaxQueueCapacity times. - ret = core_->AllocateBuffer(width, height, format, usage, 1); + ret = core_->AllocateBuffer(width, height, format, usage); if (ret < 0) return ret; } @@ -534,7 +534,8 @@ String8 BufferHubQueueProducer::getConsumerName() const { status_t BufferHubQueueProducer::setSharedBufferMode(bool shared_buffer_mode) { if (shared_buffer_mode) { - ALOGE("BufferHubQueueProducer::setSharedBufferMode(true) is not supported."); + ALOGE( + "BufferHubQueueProducer::setSharedBufferMode(true) is not supported."); // TODO(b/36373181) Front buffer mode for buffer hub queue as ANativeWindow. return INVALID_OPERATION; } diff --git a/libs/vr/libbufferhubqueue/include/private/dvr/buffer_hub_queue_client.h b/libs/vr/libbufferhubqueue/include/private/dvr/buffer_hub_queue_client.h index c5dbbde439..f9f742e85e 100644 --- a/libs/vr/libbufferhubqueue/include/private/dvr/buffer_hub_queue_client.h +++ b/libs/vr/libbufferhubqueue/include/private/dvr/buffer_hub_queue_client.h @@ -337,7 +337,7 @@ class ProducerQueue : public pdx::ClientBase<ProducerQueue, BufferHubQueue> { // Returns Zero on success and negative error code when buffer allocation // fails. int AllocateBuffer(uint32_t width, uint32_t height, uint32_t format, - uint64_t usage, size_t slice_count, size_t* out_slot); + uint64_t usage, size_t* out_slot); // Add a producer buffer to populate the queue. Once added, a producer buffer // is available to use (i.e. in |Gain|'ed mode). diff --git a/libs/vr/libbufferhubqueue/include/private/dvr/buffer_hub_queue_core.h b/libs/vr/libbufferhubqueue/include/private/dvr/buffer_hub_queue_core.h index 9a8a2c9f1b..e48b0143ab 100644 --- a/libs/vr/libbufferhubqueue/include/private/dvr/buffer_hub_queue_core.h +++ b/libs/vr/libbufferhubqueue/include/private/dvr/buffer_hub_queue_core.h @@ -119,7 +119,7 @@ class BufferHubQueueCore { // Allocate a new buffer producer through BufferHub. int AllocateBuffer(uint32_t width, uint32_t height, PixelFormat format, - uint32_t usage, size_t slice_count); + uint32_t usage); // Detach a buffer producer through BufferHub. int DetachBuffer(size_t slot); diff --git a/libs/vr/libbufferhubqueue/include/private/dvr/buffer_hub_queue_producer.h b/libs/vr/libbufferhubqueue/include/private/dvr/buffer_hub_queue_producer.h index b34549858f..bf916bad2d 100644 --- a/libs/vr/libbufferhubqueue/include/private/dvr/buffer_hub_queue_producer.h +++ b/libs/vr/libbufferhubqueue/include/private/dvr/buffer_hub_queue_producer.h @@ -29,8 +29,7 @@ class BufferHubQueueProducer : public BnInterface<IGraphicBufferProducer> { // See |IGraphicBufferProducer::dequeueBuffer| status_t dequeueBuffer(int* out_slot, sp<Fence>* out_fence, uint32_t width, - uint32_t height, PixelFormat format, - uint32_t usage, + uint32_t height, PixelFormat format, uint32_t usage, FrameEventHistoryDelta* outTimestamps) override; // See |IGraphicBufferProducer::detachBuffer| @@ -41,7 +40,8 @@ class BufferHubQueueProducer : public BnInterface<IGraphicBufferProducer> { sp<Fence>* out_fence) override; // See |IGraphicBufferProducer::attachBuffer| - status_t attachBuffer(int* out_slot, const sp<GraphicBuffer>& buffer) override; + status_t attachBuffer(int* out_slot, + const sp<GraphicBuffer>& buffer) override; // See |IGraphicBufferProducer::queueBuffer| status_t queueBuffer(int slot, const QueueBufferInput& input, @@ -59,7 +59,8 @@ class BufferHubQueueProducer : public BnInterface<IGraphicBufferProducer> { QueueBufferOutput* output) override; // See |IGraphicBufferProducer::disconnect| - status_t disconnect(int api, DisconnectMode mode = DisconnectMode::Api) override; + status_t disconnect(int api, + DisconnectMode mode = DisconnectMode::Api) override; // See |IGraphicBufferProducer::setSidebandStream| status_t setSidebandStream(const sp<NativeHandle>& stream) override; diff --git a/libs/vr/libbufferhubqueue/tests/buffer_hub_queue-test.cpp b/libs/vr/libbufferhubqueue/tests/buffer_hub_queue-test.cpp index ba9c179ddf..dcfefa4533 100644 --- a/libs/vr/libbufferhubqueue/tests/buffer_hub_queue-test.cpp +++ b/libs/vr/libbufferhubqueue/tests/buffer_hub_queue-test.cpp @@ -17,7 +17,6 @@ constexpr int kBufferWidth = 100; constexpr int kBufferHeight = 1; constexpr int kBufferFormat = HAL_PIXEL_FORMAT_BLOB; constexpr int kBufferUsage = GRALLOC_USAGE_SW_READ_RARELY; -constexpr int kBufferSliceCount = 1; // number of slices in each buffer class BufferHubQueueTest : public ::testing::Test { public: @@ -55,8 +54,7 @@ class BufferHubQueueTest : public ::testing::Test { // Create producer buffer. size_t slot; int ret = producer_queue_->AllocateBuffer(kBufferWidth, kBufferHeight, - kBufferFormat, kBufferUsage, - kBufferSliceCount, &slot); + kBufferFormat, kBufferUsage, &slot); ASSERT_EQ(ret, 0); } @@ -349,7 +347,7 @@ TEST_F(BufferHubQueueTest, TestUsageSetMask) { size_t slot; int ret = producer_queue_->AllocateBuffer( kBufferWidth, kBufferHeight, kBufferFormat, kBufferUsage & ~set_mask, - kBufferSliceCount, &slot); + &slot); ASSERT_EQ(0, ret); LocalHandle fence; @@ -367,7 +365,7 @@ TEST_F(BufferHubQueueTest, TestUsageClearMask) { size_t slot; int ret = producer_queue_->AllocateBuffer( kBufferWidth, kBufferHeight, kBufferFormat, kBufferUsage | clear_mask, - kBufferSliceCount, &slot); + &slot); ASSERT_EQ(0, ret); LocalHandle fence; @@ -386,13 +384,13 @@ TEST_F(BufferHubQueueTest, TestUsageDenySetMask) { size_t slot; int ret = producer_queue_->AllocateBuffer( kBufferWidth, kBufferHeight, kBufferFormat, kBufferUsage & ~deny_set_mask, - kBufferSliceCount, &slot); + &slot); ASSERT_EQ(ret, 0); // While allocation with those bits should fail. ret = producer_queue_->AllocateBuffer( kBufferWidth, kBufferHeight, kBufferFormat, kBufferUsage | deny_set_mask, - kBufferSliceCount, &slot); + &slot); ASSERT_EQ(ret, -EINVAL); } @@ -405,13 +403,13 @@ TEST_F(BufferHubQueueTest, TestUsageDenyClearMask) { size_t slot; int ret = producer_queue_->AllocateBuffer( kBufferWidth, kBufferHeight, kBufferFormat, - kBufferUsage | deny_clear_mask, kBufferSliceCount, &slot); + kBufferUsage | deny_clear_mask, &slot); ASSERT_EQ(ret, 0); // While allocation without those bits should fail. ret = producer_queue_->AllocateBuffer( kBufferWidth, kBufferHeight, kBufferFormat, - kBufferUsage & ~deny_clear_mask, kBufferSliceCount, &slot); + kBufferUsage & ~deny_clear_mask, &slot); ASSERT_EQ(ret, -EINVAL); } diff --git a/libs/vr/libdisplay/display_client.cpp b/libs/vr/libdisplay/display_client.cpp index dbee9f2bb5..eaf919e296 100644 --- a/libs/vr/libdisplay/display_client.cpp +++ b/libs/vr/libdisplay/display_client.cpp @@ -141,9 +141,8 @@ Status<std::unique_ptr<ProducerQueue>> Surface::CreateQueue(uint32_t width, ALOGD_IF(TRACE, "Surface::CreateQueue: Allocating %zu buffers...", capacity); for (size_t i = 0; i < capacity; i++) { size_t slot; - const size_t kSliceCount = 1; - const int ret = producer_queue->AllocateBuffer(width, height, format, usage, - kSliceCount, &slot); + const int ret = + producer_queue->AllocateBuffer(width, height, format, usage, &slot); if (ret < 0) { ALOGE( "Surface::CreateQueue: Failed to allocate buffer on queue_id=%d: %s", diff --git a/libs/vr/libdisplay/graphics.cpp b/libs/vr/libdisplay/graphics.cpp index f0e37f8704..58a906e443 100644 --- a/libs/vr/libdisplay/graphics.cpp +++ b/libs/vr/libdisplay/graphics.cpp @@ -809,8 +809,7 @@ int dvrGraphicsContextCreate(struct DvrSurfaceParameter* parameters, // so that anyone who tries to bind an FBO to context->texture_id // will not get an incomplete buffer. context->current_buffer = context->buffer_queue->Dequeue(); - LOG_ALWAYS_FATAL_IF(context->gl.texture_count != - context->current_buffer->buffer()->slice_count()); + LOG_ALWAYS_FATAL_IF(context->gl.texture_count != 1); for (int i = 0; i < context->gl.texture_count; ++i) { glBindTexture(context->gl.texture_target_type, context->gl.texture_id[i]); glEGLImageTargetTexture2DOES(context->gl.texture_target_type, @@ -1277,8 +1276,7 @@ int dvrSetEdsPose(DvrGraphicsContext* graphics_context, float32x4_t is_late_latch = DVR_POSE_LATE_LATCH; if (render_pose_orientation[0] != is_late_latch[0]) { volatile DisplaySurfaceMetadata* data = graphics_context->surface_metadata; - uint32_t buffer_index = - graphics_context->current_buffer->surface_buffer_index(); + uint32_t buffer_index = 0; ALOGE_IF(TRACE, "write pose index %d %f %f", buffer_index, render_pose_orientation[0], render_pose_orientation[1]); data->orientation[buffer_index] = render_pose_orientation; diff --git a/libs/vr/libdisplay/native_buffer_queue.cpp b/libs/vr/libdisplay/native_buffer_queue.cpp index 762db326dc..6d819753ee 100644 --- a/libs/vr/libdisplay/native_buffer_queue.cpp +++ b/libs/vr/libdisplay/native_buffer_queue.cpp @@ -28,7 +28,7 @@ NativeBufferQueue::NativeBufferQueue( size_t slot; // TODO(jwcai) Should change to use BufferViewPort's spec to config. const int ret = producer_queue_->AllocateBuffer(width_, height_, format_, - usage_, 1, &slot); + usage_, &slot); if (ret < 0) { ALOGE( "NativeBufferQueue::NativeBufferQueue: Failed to allocate buffer: %s", diff --git a/libs/vr/libdvr/tests/dvr_buffer_queue-test.cpp b/libs/vr/libdvr/tests/dvr_buffer_queue-test.cpp index 5f7f1bf7e9..c38a1b862e 100644 --- a/libs/vr/libdvr/tests/dvr_buffer_queue-test.cpp +++ b/libs/vr/libdvr/tests/dvr_buffer_queue-test.cpp @@ -17,7 +17,6 @@ static constexpr int kBufferWidth = 100; static constexpr int kBufferHeight = 1; static constexpr int kBufferFormat = HAL_PIXEL_FORMAT_BLOB; static constexpr int kBufferUsage = GRALLOC_USAGE_SW_READ_RARELY; -static constexpr int kBufferSliceCount = 1; // number of slices in each buffer static constexpr size_t kQueueCapacity = 3; typedef uint64_t TestMeta; @@ -40,10 +39,9 @@ class DvrBufferQueueTest : public ::testing::Test { void AllocateBuffers(size_t buffer_count) { size_t out_slot; for (size_t i = 0; i < buffer_count; i++) { - int ret = - GetProducerQueueFromDvrWriteBufferQueue(write_queue_) - ->AllocateBuffer(kBufferWidth, kBufferHeight, kBufferFormat, - kBufferUsage, kBufferSliceCount, &out_slot); + int ret = GetProducerQueueFromDvrWriteBufferQueue(write_queue_) + ->AllocateBuffer(kBufferWidth, kBufferHeight, kBufferFormat, + kBufferUsage, &out_slot); ASSERT_EQ(0, ret); } } diff --git a/services/vr/bufferhubd/buffer_hub.cpp b/services/vr/bufferhubd/buffer_hub.cpp index debcc73b0e..2b2a843118 100644 --- a/services/vr/bufferhubd/buffer_hub.cpp +++ b/services/vr/bufferhubd/buffer_hub.cpp @@ -71,9 +71,8 @@ std::string BufferHubService::DumpState(size_t /*max_length*/) { 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) + "x" + - std::to_string(info.slice_count); + std::string dimensions = + std::to_string(info.width) + "x" + std::to_string(info.height); stream << std::setw(14) << dimensions; } stream << " "; @@ -118,9 +117,8 @@ std::string BufferHubService::DumpState(size_t /*max_length*/) { 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) + "x" + - std::to_string(info.slice_count); + std::string dimensions = + std::to_string(info.width) + "x" + std::to_string(info.height); stream << std::setw(14) << dimensions; } stream << " "; @@ -242,15 +240,13 @@ void BufferHubService::OnChannelClose(Message&, Status<void> BufferHubService::OnCreateBuffer(Message& message, uint32_t width, uint32_t height, uint32_t format, uint64_t usage, - size_t meta_size_bytes, - size_t slice_count) { + size_t meta_size_bytes) { // Use the producer channel id as the global buffer id. const int buffer_id = message.GetChannelId(); ALOGD_IF(TRACE, "BufferHubService::OnCreateBuffer: buffer_id=%d width=%u height=%u " - "format=%u usage=%" PRIx64 " meta_size_bytes=%zu slice_count=%zu", - buffer_id, width, height, format, usage, meta_size_bytes, - slice_count); + "format=%u usage=%" PRIx64 " meta_size_bytes=%zu", + buffer_id, width, height, format, usage, meta_size_bytes); // See if this channel is already attached to a buffer. if (const auto channel = message.GetChannel<BufferHubChannel>()) { @@ -260,7 +256,7 @@ Status<void> BufferHubService::OnCreateBuffer(Message& message, uint32_t width, } auto status = ProducerChannel::Create(this, buffer_id, width, height, format, - usage, meta_size_bytes, slice_count); + usage, meta_size_bytes); if (status) { message.SetChannel(status.take()); return {}; @@ -274,14 +270,14 @@ Status<void> BufferHubService::OnCreateBuffer(Message& message, uint32_t width, Status<void> BufferHubService::OnCreatePersistentBuffer( 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, size_t slice_count) { + size_t meta_size_bytes) { const int channel_id = message.GetChannelId(); ALOGD_IF(TRACE, "BufferHubService::OnCreatePersistentBuffer: channel_id=%d name=%s " "user_id=%d group_id=%d width=%u height=%u format=%u " - "usage=%" PRIx64 " meta_size_bytes=%zu slice_count=%zu", + "usage=%" PRIx64 " meta_size_bytes=%zu", channel_id, name.c_str(), user_id, group_id, width, height, format, - usage, meta_size_bytes, slice_count); + usage, meta_size_bytes); // See if this channel is already attached to a buffer. if (const auto channel = message.GetChannel<BufferHubChannel>()) { @@ -303,7 +299,7 @@ Status<void> BufferHubService::OnCreatePersistentBuffer( name.c_str(), euid, euid); return ErrorStatus(EPERM); } else if (!buffer->CheckParameters(width, height, format, usage, - meta_size_bytes, slice_count)) { + meta_size_bytes)) { ALOGE( "BufferHubService::OnCreatePersistentBuffer: Requested an existing " "buffer with different parameters: name=%s", @@ -321,9 +317,8 @@ Status<void> BufferHubService::OnCreatePersistentBuffer( return {}; } } else { - auto status = - ProducerChannel::Create(this, channel_id, width, height, format, usage, - meta_size_bytes, slice_count); + auto status = ProducerChannel::Create(this, channel_id, width, height, + 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 817b01e4a1..e4cdd088e5 100644 --- a/services/vr/bufferhubd/buffer_hub.h +++ b/services/vr/bufferhubd/buffer_hub.h @@ -52,7 +52,6 @@ class BufferHubChannel : public pdx::Channel { uint32_t height = 0; uint32_t format = 0; uint64_t usage = 0; - size_t slice_count = 0; std::string name; // Data filed for producer queue. @@ -60,8 +59,7 @@ class BufferHubChannel : public pdx::Channel { 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, size_t slice_count, - const std::string& name) + uint32_t format, uint64_t usage, const std::string& name) : id(id), type(kProducerType), consumer_count(consumer_count), @@ -69,7 +67,6 @@ class BufferHubChannel : public pdx::Channel { height(height), format(format), usage(usage), - slice_count(slice_count), name(name) {} BufferInfo(int id, size_t consumer_count, size_t capacity, @@ -158,12 +155,13 @@ class BufferHubService : public pdx::ServiceBase<BufferHubService> { pdx::Status<void> OnCreateBuffer(pdx::Message& message, uint32_t width, uint32_t height, uint32_t format, - uint64_t usage, size_t meta_size_bytes, - size_t slice_count); - pdx::Status<void> OnCreatePersistentBuffer( - pdx::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, size_t slice_count); + uint64_t usage, size_t meta_size_bytes); + pdx::Status<void> OnCreatePersistentBuffer(pdx::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); pdx::Status<void> OnGetPersistentBuffer(pdx::Message& message, const std::string& name); pdx::Status<QueueInfo> OnCreateProducerQueue(pdx::Message& message, diff --git a/services/vr/bufferhubd/consumer_channel.cpp b/services/vr/bufferhubd/consumer_channel.cpp index 311f5c6ab4..08b27905f7 100644 --- a/services/vr/bufferhubd/consumer_channel.cpp +++ b/services/vr/bufferhubd/consumer_channel.cpp @@ -75,11 +75,6 @@ bool ConsumerChannel::HandleMessage(Message& message) { *producer, &ProducerChannel::OnGetBuffer, message); return true; - case BufferHubRPC::GetBuffers::Opcode: - DispatchRemoteMethod<BufferHubRPC::GetBuffers>( - *producer, &ProducerChannel::OnGetBuffers, message); - return true; - case BufferHubRPC::NewConsumer::Opcode: DispatchRemoteMethod<BufferHubRPC::NewConsumer>( *producer, &ProducerChannel::OnNewConsumer, message); diff --git a/services/vr/bufferhubd/producer_channel.cpp b/services/vr/bufferhubd/producer_channel.cpp index 398aa1252b..4005f7eed7 100644 --- a/services/vr/bufferhubd/producer_channel.cpp +++ b/services/vr/bufferhubd/producer_channel.cpp @@ -27,22 +27,18 @@ namespace dvr { ProducerChannel::ProducerChannel(BufferHubService* service, int channel_id, uint32_t width, uint32_t height, uint32_t format, uint64_t usage, - size_t meta_size_bytes, size_t slice_count, - int* error) + size_t meta_size_bytes, int* error) : BufferHubChannel(service, channel_id, channel_id, kProducerType), pending_consumers_(0), - slices_(std::max(static_cast<size_t>(1), slice_count)), producer_owns_(true), meta_size_bytes_(meta_size_bytes), meta_(meta_size_bytes ? new uint8_t[meta_size_bytes] : nullptr) { - for (auto& ion_buffer : slices_) { - const int ret = ion_buffer.Alloc(width, height, format, usage); - if (ret < 0) { - ALOGE("ProducerChannel::ProducerChannel: Failed to allocate buffer: %s", - strerror(-ret)); - *error = ret; - return; - } + const int ret = buffer_.Alloc(width, height, format, usage); + if (ret < 0) { + ALOGE("ProducerChannel::ProducerChannel: Failed to allocate buffer: %s", + strerror(-ret)); + *error = ret; + return; } // Success. @@ -51,12 +47,11 @@ ProducerChannel::ProducerChannel(BufferHubService* service, int channel_id, 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, - size_t slice_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, slice_count, &error)); + meta_size_bytes, &error)); if (error < 0) return ErrorStatus(-error); else @@ -72,9 +67,8 @@ ProducerChannel::~ProducerChannel() { } BufferHubChannel::BufferInfo ProducerChannel::GetBufferInfo() const { - return BufferInfo(buffer_id(), consumer_channels_.size(), slices_[0].width(), - slices_[0].height(), slices_[0].format(), - slices_[0].usage(), slices_.size(), name_); + return BufferInfo(buffer_id(), consumer_channels_.size(), buffer_.width(), + buffer_.height(), buffer_.format(), buffer_.usage(), name_); } void ProducerChannel::HandleImpulse(Message& message) { @@ -94,11 +88,6 @@ bool ProducerChannel::HandleMessage(Message& message) { *this, &ProducerChannel::OnGetBuffer, message); return true; - case BufferHubRPC::GetBuffers::Opcode: - DispatchRemoteMethod<BufferHubRPC::GetBuffers>( - *this, &ProducerChannel::OnGetBuffers, message); - return true; - case BufferHubRPC::NewConsumer::Opcode: DispatchRemoteMethod<BufferHubRPC::NewConsumer>( *this, &ProducerChannel::OnNewConsumer, message); @@ -130,24 +119,10 @@ bool ProducerChannel::HandleMessage(Message& message) { } Status<NativeBufferHandle<BorrowedHandle>> ProducerChannel::OnGetBuffer( - Message& message, unsigned index) { + Message& message) { ATRACE_NAME("ProducerChannel::OnGetBuffer"); ALOGD_IF(TRACE, "ProducerChannel::OnGetBuffer: buffer=%d", buffer_id()); - if (index < slices_.size()) { - return {NativeBufferHandle<BorrowedHandle>(slices_[index], buffer_id())}; - } else { - return ErrorStatus(EINVAL); - } -} - -Status<std::vector<NativeBufferHandle<BorrowedHandle>>> -ProducerChannel::OnGetBuffers(Message&) { - ATRACE_NAME("ProducerChannel::OnGetBuffers"); - ALOGD_IF(TRACE, "ProducerChannel::OnGetBuffers: buffer_id=%d", buffer_id()); - std::vector<NativeBufferHandle<BorrowedHandle>> buffer_handles; - for (const auto& buffer : slices_) - buffer_handles.emplace_back(buffer, buffer_id()); - return {std::move(buffer_handles)}; + return {NativeBufferHandle<BorrowedHandle>(buffer_, buffer_id())}; } Status<RemoteChannelHandle> ProducerChannel::CreateConsumer(Message& message) { @@ -372,11 +347,10 @@ bool ProducerChannel::CheckAccess(int euid, int egid) { // 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, - size_t slice_count) { - return slices_.size() == slice_count && meta_size_bytes == meta_size_bytes_ && - slices_[0].width() == width && slices_[0].height() == height && - slices_[0].format() == format && slices_[0].usage() == 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; } } // namespace dvr diff --git a/services/vr/bufferhubd/producer_channel.h b/services/vr/bufferhubd/producer_channel.h index 6de619d157..ef1ac80b9a 100644 --- a/services/vr/bufferhubd/producer_channel.h +++ b/services/vr/bufferhubd/producer_channel.h @@ -32,8 +32,7 @@ class ProducerChannel : public BufferHubChannel { 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, - size_t slice_count); + uint32_t height, uint32_t format, uint64_t usage, size_t meta_size_bytes); ~ProducerChannel() override; @@ -42,10 +41,7 @@ class ProducerChannel : public BufferHubChannel { BufferInfo GetBufferInfo() const override; - pdx::Status<NativeBufferHandle<BorrowedHandle>> OnGetBuffer(Message& message, - unsigned index); - pdx::Status<std::vector<NativeBufferHandle<BorrowedHandle>>> OnGetBuffers( - Message& message); + pdx::Status<NativeBufferHandle<BorrowedHandle>> OnGetBuffer(Message& message); pdx::Status<RemoteChannelHandle> CreateConsumer(Message& message); pdx::Status<RemoteChannelHandle> OnNewConsumer(Message& message); @@ -62,8 +58,7 @@ class ProducerChannel : public BufferHubChannel { 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, - size_t slice_count); + uint64_t usage, size_t meta_size_bytes); pdx::Status<void> OnProducerMakePersistent(Message& message, const std::string& name, @@ -76,7 +71,7 @@ class ProducerChannel : public BufferHubChannel { // zero then the producer can re-acquire ownership. int pending_consumers_; - std::vector<IonBuffer> slices_; + IonBuffer buffer_; bool producer_owns_; LocalFence post_fence_; @@ -96,7 +91,7 @@ class ProducerChannel : public BufferHubChannel { ProducerChannel(BufferHubService* service, int channel, uint32_t width, uint32_t height, uint32_t format, uint64_t usage, - size_t meta_size_bytes, size_t slice_count, int* error); + 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 843277eda8..f052243064 100644 --- a/services/vr/bufferhubd/producer_queue_channel.cpp +++ b/services/vr/bufferhubd/producer_queue_channel.cpp @@ -142,7 +142,7 @@ Status<QueueInfo> ProducerQueueChannel::OnGetQueueInfo(Message&) { 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 slice_count, size_t buffer_count) { + uint64_t usage, size_t buffer_count) { ATRACE_NAME("ProducerQueueChannel::OnProducerQueueAllocateBuffers"); ALOGD_IF(TRACE, "ProducerQueueChannel::OnProducerQueueAllocateBuffers: " @@ -177,7 +177,7 @@ ProducerQueueChannel::OnProducerQueueAllocateBuffers( for (size_t i = 0; i < buffer_count; i++) { auto status = AllocateBuffer(message, width, height, format, - effective_usage, slice_count); + effective_usage); if (!status) { ALOGE( "ProducerQueueChannel::OnProducerQueueAllocateBuffers: Failed to " @@ -193,7 +193,7 @@ ProducerQueueChannel::OnProducerQueueAllocateBuffers( Status<std::pair<RemoteChannelHandle, size_t>> ProducerQueueChannel::AllocateBuffer(Message& message, uint32_t width, uint32_t height, uint32_t format, - uint64_t usage, size_t slice_count) { + uint64_t usage) { ATRACE_NAME("ProducerQueueChannel::AllocateBuffer"); ALOGD_IF(TRACE, "ProducerQueueChannel::AllocateBuffer: producer_channel_id=%d", @@ -218,13 +218,13 @@ ProducerQueueChannel::AllocateBuffer(Message& message, uint32_t width, ALOGD_IF(TRACE, "ProducerQueueChannel::AllocateBuffer: buffer_id=%d width=%u " - "height=%u format=%u usage=%" PRIx64 " slice_count=%zu", - buffer_id, width, height, format, usage, slice_count); + "height=%u format=%u usage=%" PRIx64, + buffer_id, width, height, format, usage); auto buffer_handle = status.take(); auto producer_channel_status = ProducerChannel::Create(service(), buffer_id, width, height, format, - usage, meta_size_bytes_, slice_count); + 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 13c9ddc5b1..b43bbf93b1 100644 --- a/services/vr/bufferhubd/producer_queue_channel.h +++ b/services/vr/bufferhubd/producer_queue_channel.h @@ -35,7 +35,7 @@ class ProducerQueueChannel : public BufferHubChannel { 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, size_t slice_count, + uint64_t usage, size_t buffer_count); // Detach a BufferHubProducer indicated by |slot|. Note that the buffer must @@ -58,7 +58,7 @@ class ProducerQueueChannel : public BufferHubChannel { // 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, size_t slice_count); + 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 |