summaryrefslogtreecommitdiff
path: root/libs/vr/libbufferhub/buffer_hub_base.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix code style violation in the variables in BufferHubDefs::MetadataHeaderTianyu Jiang2019-02-131-3/+3
| | | | | | | | | | Violation: variables should be lowerCaseCamel in the following directories: frameworks/native/libs/ui and frameworks/native/services/bufferhub Test: m, mma Bug: 68273829 Change-Id: I7dc56ec17089456f98b018032f04f779b12632b2
* Merge "Remove unused BufferHubBase::GetBlobFds method"TreeHugger Robot2019-02-051-7/+0
|\
| * Remove unused BufferHubBase::GetBlobFds methodTianyu Jiang2019-01-311-7/+0
| | | | | | | | | | | | | | | | | | | | | | This method is not used in DVR buffering system. BufferHubBuffer may consider having it later when it meets an use case when the buffer contains multiple fds in buffer handle, and directly have it implemented in BufferHubBuffer class. Test: build Bug: None Change-Id: I95cd71d936695eeb77bd049f43fe350fb60d9154
* | Remove BufferHubBase::Poll methodTianyu Jiang2019-02-011-6/+0
|/ | | | | | | | | | | | because the eventfd should not be polled directly after Consumer/ProducerBuffer are backed by BufferHubBuffer. The only current instances of BufferHubBase::Poll being used are in buffer_hub-test Bug: None Test: m, mma, buffer_hub-test Change-Id: Iac586086aed54510c1a8bae020e5ca24d8fd065e
* Change atomics in ashmem from uint64_t to uint32_tTianyu Jiang2018-12-151-4/+4
| | | | | | | | | | | | | | | | | Fix: 117849512 Test: Blueline: atest AHardwareBufferTest BufferHub_test buffer_hub_queue_producer-test libgui_test libsensor_test vrflinger_test buffer_hub-test buffer_hub_queue-test dvr_buffer_queue-test dvr_api-test dvr_display-test Test: in libui_test InputSurfacesTest are segfault on top of master already. Test: Vega: AHardwareBufferTest BufferHubBuffer_test BufferHubMetadata_test buffer_hub_queue_producer-test buffer_hub-test dvr_buffer_queue-test buffer_hub_queue-test dvr_api-test libdvrtracking-test Change-Id: I55f91c21f7ac07615b5451b5413521d7938cf591
* Change the definition of buffer state and client state bits.Tianyu2018-12-031-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Please refer to go/bufferhub-buffer-state-redesign for more information. In this change: 1. Every clients takes up two bits in the buffer_state. One from the higher 32 bits, one from the lower 32 bits. For details: go/bufferhub-buffer-state-redesign 2. Upon the creation of a new buffer, the buffer is in released state. Previously, only producer creates buffer, and upon creation, the buffer was in gained state. Now, producer needs to specifically gain the buffer before trying to produce and post it. 3. If there is no other clients when a client post a buffer, the buffer will actually be in released state instead of posted state. This is because the posted buffer does not have readers and can be reused immediately. 4. If a new client is added to the buffer when the buffer is in acquired or posted state, the buffer state of the new client will be set to posted state and able to acquire the same buffer content as posted. In the next change: variables of type std::atomic<uint64_t> in metadata header in shared memory will be replaced by std::atomic<uint32_t> Test: marlin-eng passing AHardwareBufferTest BufferHubBuffer_test BufferHubMetadata_test buffer_hub_binder_service-test buffer_hub_queue_producer-test dvr_api-test libgui_test libsensor_test vrflinger_test buffer_hub-test dvr_buffer_queue-test dvr_display-test buffer_hub_queue-test Test: smartphone VR works on blueline-eng Test: vega_xr passing AHardwareBufferTest BufferHubBuffer_test BufferHubMetadata_test buffer_hub_queue_producer-test buffer_hub-test buffer_hub_queue-test dvr_buffer_queue-test dvr_api-test Cherrypicking this changelist to oc-dr1-daydream-dev branch requires ag/5514563 to be merged at the same time to make Vega actually work. Bug: 112007999 Change-Id: I86393818ad922a91c709fe22f8e99b0667d2e9ef
* Load with memory_order_acquireTianyu Jiang2018-11-011-3/+3
| | | | | | | | | | | | | | | | std::atomic::load operation is with std::memory_order_seq_cst by default. However, load operation in bufferhubd and buffer hub client does not need sequentially-consistent ordering which is provided by std::memory_order_seq_cst. This change changes our load operation with std::memory_order_acquire so that no reads or writes in the current thread can be reordered before this load, all writes in other threads that release the same atomic variable are visible in the current thread. Test: all tests are still passing. Test: vega still working. Bug: 112007999 Bug: 118718713 Change-Id: I2ac75cc306c3de35bf3d953b353f9a9442bdebbc
* Change the variable name "buffer_state_bit" into "client_state_mask".Tianyu Jiang2018-10-261-4/+4
| | | | | | | | | | | | | | | | | | | Reasons: 1. This variable is not refering to a property of the buffer. It refers to a client of the buffer. 2. The original "buffer_state_bit" of a producer/consumer is actually the client state bit mask for both buffer_state and fence_state in shared memory. Thus, "buffer_state_bit" does not make sense for the fence state. 3. In the future, Every clients takes up two bits in the buffer_state. For simpler bit manipulation, there will be a future change making the client_state_bits two bits as well. Please refer to ag/5236978 for an early look at the future bit manipulation. Thus, this change replaces "bit" with "mask". Test: build Bug: 112007999 Change-Id: I72f59ab9491bd2f135da068f578195fbf5e6c2b6
* Merge "Move active clients mask to an atomic uint64_t in shared memory."TreeHugger Robot2018-10-121-3/+10
|\
| * Move active clients mask to an atomic uint64_t in shared memory.Tianyu2018-10-111-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, the active_consumer_bit_mask_ was a private member of producer channel for creating new consumer buffers with unique buffer_state_bit_ so that newly added consumer can be uniquely identified amoung its siblings. It was a union of all consumer's buffer_state_bit_. In the re-design of buffer state, every consumer/producer/client buffers need to know the location of every other consumer/producer/client in buffer_state in order to post a buffer: when a client posts a buffer, it changes its own buffer_state to 00 and others' buffer_state to 10. Thus, it need to know where the other siblings locates in buffer_state atomic uint64_t. active_consumer_bit_mask_ suffices this need. This change moves the active_consumer_bit_mask_ from producer channel to an uint64_t atomic variable in shared memory, and rename it as active_clients_bit_mask_ (because it contain both consumers and producers buffer_state_bit). Test: marlin-eng on master branch Test: vega_xr-eng on oc-dr1-daydream-dev branch Test: buffer_hub-test buffer_hub_queue-test buffer_hub_queue_producer-test Bug: 112007999 Change-Id: I1ae562701545c7504fd9367c8c8c63a2fd609264
* | Remove GetBlobReadOnlyPointer.Tianyu2018-10-111-4/+0
|/ | | | | | | | | | | | | It is actually the same as GetBlobReadWritePointer. It is better not to make the user of this function think that this function provide immutable contents, and accidentally do something unexpected. Tested on master branch with Marlin and oc-dr1-daydream-dev branch with Vega Test: buffer_hub_queue-test buffer_hub_queue_producer-test dvr_api-test dvr_buffer_queue-test buffer_hub-test Bug: None. Change-Id: I1e6fd4ed1d7a1bbb611db910d35dc022bb4067a5
* Break up and rename buffer_hub_cilent.{h, cpp}Jiwen 'Steve' Cai2018-09-281-0/+224
Code in buffer_hub_cilent.{h,cpp} was the main client side implementation of bufferhub. With years of developements, the content of it was complicated enough to deserved separated files. Also rename stuff for clarification. old names: +-------------------+ | BufferHubBuffer | +---------^---------+ | +------------------+ | +------------------+ | BufferProducer +----+-----+ BufferConsumer | +------------------+ +------------------+ new names: +-----------------+ | BufferHubBase | +--------^--------+ | +------------------+ | +------------------+ | ProducerBuffer +----+-----+ ConsumerBuffer | +------------------+ +------------------+ Rename rationale: 1/ BufferProducer was originally poorly named and gets easily confused with IGraphicBufferProducer. Actually, BufferProducer is a single buffer that can produce (i.e. write) data into a buffer, but it doesn't produce buffer. On the other hand, IGraphicBufferProducer is the producer end of a BufferQueue and it is used to produce buffers. 2/ BufferConsumer was originally poorly named and gets easily confused with IGraphicBufferConsumer. Actually, BufferConsumer is a single buffer that can consume (i.e. read) data from a buffer, but it doesn't consume buffer. On the other hand, IGraphicBufferConsumer is the consumer end of a BufferQueue and it is used to consume buffers. 3/ BufferHubBuffer is a pure base class and cannot be used standalone. The old name suggests that it's a buffer object backed by BufferHub, which might leads to confusion. Also, this rename is in preparation of rename DetachedBuffer to BufferHubBuffer. Bug: 116855254 Test: Build system Change-Id: Id545648f5bdc7660e58f7bb49722651ae3bcca70