summaryrefslogtreecommitdiff
path: root/libs/vr/libbufferhub/consumer_buffer.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Reduce debug level log from libbufferhubTianyu Jiang2019-05-221-12/+0
| | | | | | | | | | | | Logs that indicates possible racing between consumers and producers of a buffer are removed because they are expected to race each other. Log that indicates possible racing in bufferhubd is moved from info level to verbose level. Test: vega runs without libbufferhub log spam Bug: 129544259 Change-Id: I9307602797ff9c1bbc774264682a83bf4ddd0240 (cherry picked from commit b9d077f9be584114c39ac8417452cd20817c0236)
* Fix non camelCase function namesTianyu Jiang2019-02-081-3/+3
| | | | | | | | | Android Framework C++ Code Style Guidelines says that function names should be camelCase: http://go/droidcppstyle Test: m, mma in frameworks/native Bug: 68273829 Change-Id: I2f661c06b31b2e72cd0eee3d91b95531b60ec939
* Change atomics in ashmem from uint64_t to uint32_tTianyu Jiang2018-12-151-11/+11
| | | | | | | | | | | | | | | | | 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-18/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Replace kProducerStateBit with kFirstClientBitMask.Tianyu Jiang2018-10-311-1/+2
| | | | | | | | | | | | | | | kProducerStateBit covers the MSB of the buffer/fence state. kFirstClientBitMask covers the LSB of the buffer/fence state. This change replaces the kProducerStateBit with kFirstClientBitMask, and update the kConsumerStateBit to be the inverse of kFirstClientBitMask. Test: AHardwareBufferTest BufferHubBuffer_test BufferHubMetadata_test buffer_hub-test buffer_hub_binder_service-test buffer_hub_queue-test buffer_hub_queue_producer-test buffer_node-test dvr_api-test dvr_buffer_queue-test dvr_display-test libgui_test libdvrcommon_test pdx_tests GraphicBuffer_test Bug: 118718713 Change-Id: I647f36ee3fb2eb5dc996b781ed0ff71f7f72c112
* 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
* Disable ignored consumers.Tianyu2018-10-031-5/+0
| | | | | | | | | | Removed everything around ignored consumer because it is not used anywhere in the code base, or in foreseeable future. Test: build in frameworks/native directory Bug: 117225895 Fixes: 117225895 Change-Id: I9bc3d868110408a0ebb8c96215d7d4588f9cfd2e
* Break up and rename buffer_hub_cilent.{h, cpp}Jiwen 'Steve' Cai2018-09-281-0/+183
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