summaryrefslogtreecommitdiff
path: root/libs/vr/libbufferhub/buffer_hub-test.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix non camelCase function namesTianyu Jiang2019-02-081-23/+23
| | | | | | | | | 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
* Remove BufferHubBase::Poll methodTianyu Jiang2019-02-011-44/+54
| | | | | | | | | | | | 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
* Replace the use of helper function IsBufferReleased to member functionTianyu Jiang2019-01-301-9/+8
| | | | | | | | | | IsReleased() or is_released(). Fix: 122854791 Test: BufferHub_test BufferHubServer_test VtsHalBufferHubV1_0TargetTest buffer_hub-test buffer_hub_queue-test dvr_buffer_queue-test on walleye_xr Change-Id: I2431a4ddd78cb2eef9bdeafc0d9048571f7a0c61
* Refactor BufferHubBuffer to use hwbinderFan Xu2019-01-111-89/+4
| | | | | | | | | | | | | | | | Entirely move BufferHubBuffer off pdx dependency and using hwbinder backend and rewrite test cases to fit in current behavior. Remove duplicated test cases in buffer_hub-test. Commented out BufferHubBuffer related parts and remove related include and using statement. Add hidl interface dependency to libs/gui build file to avoid compile errors. Test: BufferHub_test, GraphicBuffer_test, buffer_hub-test Bug: 116681016 Change-Id: I9d8f734f681e04d3d50b7a02c27b17df8c66cbad
* Post to all existing and non-existing consumers of the bufferTianyu Jiang2019-01-081-17/+9
| | | | | | | | | | | | | | | | Previously, producer only post to all current clients of the buffer except for the producer itself. In this change, producer post to all existing and non-existing clients of the buffer except for the producer itself. Fix: 120869419 Test: Vega is able to recover itself during DON after killing vrcore or compositor process. Test: on vega_xr and blueline_xr with the following tests buffer_hub-test buffer_hub_queue-test dvr_buffer_queue-test dvr_api-test libdvrtracking-test(vega only) buffer_hub_queue_producer-test Change-Id: I29f24268b7704fbeb06a4302b11dcd89dd13c133
* Remove the deprecated buffer_hub_client.hTianyu Jiang2018-12-181-1/+2
| | | | | | Test: build Bug: 116855254 Change-Id: I1a736a9d64f51bec7baa85e0c35c39b153bbb354
* 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
* Replace android::dvr::BufferHubDefs with android::BufferHubDefsTianyu Jiang2018-12-131-10/+11
| | | | | | | | | | | | | | | | New libraries in libui and bufferhub shall be using android::BufferHubDefs instead of android::dvr::BufferHubDefs. Bug: None Test: atest AHardwareBufferTest BufferHubBuffer_test BufferHubMetadata_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. tested on Blueline and Vega Change-Id: Ia755022c96147969a401ed32544082a8c76936a0
* Allow the same producer to gain a buffer twice.Tianyu Jiang2018-12-031-8/+12
| | | | | | | | | | | | | | This change makes the same producer gaining the same buffer the second time a no-op, and prevent other clients of the buffer from gaining it. Currently, EALREADY error will return if a producer gain a buffer which is already gained by the producer. Problem: there is an actual use case in passthrough processor that a producer may need to gain a buffer to mimic a "release" of a buffer in the consumer point of view. Test: buffer_hub-test Bug: 118718713 Change-Id: If958c95165a5ad62f51c46b01fa43b576d3b20ae
* Change the definition of buffer state and client state bits.Tianyu2018-12-031-111/+168
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Merge "Remove DetachedBufferHandle from libui"Jiwen Cai2018-11-011-1/+0
|\
| * Remove DetachedBufferHandle from libuiJiwen 'Steve' Cai2018-11-011-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DetachedBufferHandle was a temporary measure introduced in Android P to bridge BufferHub and GraphicBuffer. In Android Q however, GraphicBuffer will be directly backed by BufferHub, thus DetachedBufferHandle becomes redundant. Also note that removing DetachedBufferHandle from libui should bare no impact on vendors for two reasons: 1. BufferHub in P is only enabled for Daydream ready devices (i.e. Pixel lines and VR AIO devices). No other vendors should have BufferHub enabled. 2. DetachedBufferHandle.h was hidden from vndk and thus vendors shouldn't get access to it anyway. Bug: 117522732 Test: Build system Change-Id: I3828eaa9499051e5ad5e4e270b5c26bae5f2c707
* | Replace kProducerStateBit with kFirstClientBitMask.Tianyu Jiang2018-10-311-10/+8
|/ | | | | | | | | | | | | | | 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
* Merge "Rename and fix comments and typo."Tianyu Jiang2018-10-311-5/+5
|\
| * Rename and fix comments and typo.Tianyu Jiang2018-10-311-5/+5
| | | | | | | | | | | | | | Test: all tests are still passing. Bug: None Change-Id: I931d299525f03f06693ebbcb1a74a027a92808c2
* | Improve test readabilityTianyu Jiang2018-10-311-1/+4
|/ | | | | | | | | | Add kMaxNumberOfClients to BufferHubDef. This variable will also be needed when buffer state is changed according to go/bufferhub-buffer-state-redesign Test: BufferHubBuffer_test buffer_hub-test buffer_node-test Bug: 112007999 Change-Id: I453438f3e2defa1fc93d1e74a282a38360f27694
* Change the variable name "buffer_state_bit" into "client_state_mask".Tianyu Jiang2018-10-261-26/+26
| | | | | | | | | | | | | | | | | | | 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
* Allow ProducerBuffer gain posted buffer.Tianyu2018-10-251-0/+30
| | | | | | | | | | | | | | | | Say there are 3 buffers allocated in buffer queue or some sort of containers of the buffers, and all of the three buffers are in posted state. Consumers are taking their time to do other things. In this case, the producer who is using the buffers from this buffer container would not be able to produce image because there is no buffer available (unless the container of the buffer decide to allocate new buffers). This change allows the container of the buffer decide whether to reuse an old posted buffer, or to allocate new buffer, for the producer side of the buffer container to produce image into. Bug: 80164475 Test: buffer_hub-test on Taimen and Vega Change-Id: I8c3d10a3b32ffa4bbf24da176a694b12c4dc3a5d
* Remove Acquire(LocalHandle* ready_fence, Meta* meta)Tianyu Jiang2018-10-241-9/+8
| | | | | | | | | | | | | | This function is useless for now and in foreseeable future because user metadata will be in ashmen, and there won't be custom metadata on the Acquire() interface. Test: buffer_hub-test buffer_hub_queue-test buffer_hub_queue_producer-test dvr_api-test dvr_buffer_queue-test Test: master branch with Marlin Test: oc-dr1-daydream-dev branch with Vega Bug: 70048475 Change-Id: I5222ea1034d1fc011055d75a4b814a005913bbd1
* Remove the functionality of promoting a BufferHubBuffer to ProducerBuffer.Tianyu2018-10-171-41/+64
| | | | | | | | Test: buffer_hub-test buffer_hub_queue-test dvr_api-test dvr_buffer_queue-test on marlin-eng Bug: 77153033 Change-Id: I155fa5c5740243d84207f37e6a2fe37d6331628f
* Move BufferHubBuffer_test to libuiJiwen 'Steve' Cai2018-10-151-85/+0
| | | | | | | Bug: 111976433 Bug: 112940221 Test: BufferHubBuffer_test Change-Id: Ice3507666f3b99184276c36262aab33d0f295d64
* Format BufferHub{Buffer,Metadata}.{h,cpp} to match libui styleJiwen 'Steve' Cai2018-10-121-21/+23
| | | | | | | | | | | | | 1/ Run clang-format 2/ Rename variables to use camel case 3/ 100 column per line 4/ Rename DetachedBuffer to BufferHubBuffer Bug: 68273829 Bug: 112010261 Bug: 112940221 Test: BufferHubMetadata_test, buffer_hub-test Change-Id: Iaf0dbbe797daf8b61864dc2e3ea1693703ef9d7f
* Move detached buffer to libuiJiwen 'Steve' Cai2018-10-121-2/+2
| | | | | | | | | | | | | | | | | | | | Move it into libui early so that new modifications towards it can be coded in the libui style This CL only moves the file and updates Android.bp with proper dependencies. Will re-format the coding style in a follow up CL. The reason behind this is to keep this CL small enough so that the "git mv" operation will be considered as an renaming rather than a complete rewrite. Note that DetachedBuffer is not exposed to VNDK, so that we won't need to worry about ABI compatibility. Also, it temporarily introduces some clang warning exceptions, we should be able to remove them very soon once pdx to binder refactor is done for detached buffer. Bug: 112010261 Test: atest BufferHubMetadata_test Change-Id: I63659b9a9b7cb56f30fc2ae8cc5b87977d79b59c
* Remove Post(const LocalHandle& ready_fence, const Meta& meta)Tianyu2018-10-111-22/+14
| | | | | | | | | | | | | | This function is useless for now and in foreseeable future because user metadata will be in ashmen, and there won't be custom metadata on the Post() interface. Tested on master branch with Marlin and oc-dr1-daydream-dev branch with Vega Test: buffer_hub-test buffer_hub_queue-test buffer_hub_queue_producer-test dvr_api-test dvr_buffer_queue-test Bug: 70048475 Change-Id: I58590e4a1358afdf784968bac65a48b98fd0f4fc
* Move detached buffer off IonBufferJiwen 'Steve' Cai2018-10-091-0/+4
| | | | | | | | | | | | | | | | | | | 1/ Migration DetachedBuffer's metadata to use ashmem-based BufferHubMetadata. 2/ Avoid import the actual gralloc buffer into the IonBuffer. Instead, just store the native_handle_t of the gralloc buffer in DetachedBuffer. 3/ Replace the usage of BufferDescription/NativeBufferHandle with BufferTraits/NativeHandleWrapper, as they both depend on IonBuffer. Currently dvr::ProdcuerBuffer and dvr::ConsumerBuffer are still using BufferDescription/NativeBufferHandle so that we are reimplementing them for DetachedBuffer to avoid chaning dvr::ProdcuerBuffer and dvr::ConsumerBuffer at this point. Bug: 112940221 Bug: 112011098 Bug: 70048475 Test: atest buffer_hub-test Change-Id: I435180ba80a27b0ff35f0d95fcdbc23412978e22
* Rename BufferConsumer/BufferProducer to ConsumerBuffer/ProducerBuffer in ↵Tianyu2018-10-081-73/+73
| | | | | | | | | | libbufferhub directory. Now naming under libbufferhub is consistent. Test: buffer_hub-test Bug: 116855254 Change-Id: I996b65ec307871af4cf58c1f95eee3f945ba7959
* Temporarily disable detach and promoteFan Xu2018-10-081-0/+12
| | | | | | | | | | | | | | | | | After disccusion, we decided that our migrationg will start with detached buffer. Therefore, until we refractor both producer buffer and detached buffer to use binder, it makes no sense to write a converter between pdx and binder backend. As detached buffer is neither used outside nor exposed via API, this change should not have any negative effect. Some tests are also disabled since after refractoring the behavior might change, which means we have to rewrite them after refracting. Put TODOs above them. Change-Id: I937403a4a8ae9f3ea94718211e12326ace9060bf Test: 'atest buffer_hub-test': passed
* Remove GraphicBuffer accessor from DetachedBufferJiwen 'Steve' Cai2018-09-261-40/+0
| | | | | | | | | | | Those accessor are not used outside of buffer_hub-test. Moreover, in the new design, GraphicBuffer will depend on DetachedBuffer rather than DetachedBuffer depending on GraphicBuffer. Bug: 112010261 Bug: 112940221 Test: atest buffer_hub-test Change-Id: I78b5ea8b195b8502fc8bdcda48ca600f6408897a
* Remove unused templateTianyu2018-09-141-1/+1
| | | | | | | | | | | | Previously, code does not compile if using Post(fence) method. Error message is no matching member function for call to 'Post', frameworks/native/libs/vr/libbufferhub/include/private/dvr/buffer_hub_client.h:217:7: note: candidate template ignored: couldn't infer template argument 'Meta'. Test: use Post method in test and build on oc-dr1-daydream-dev branch. Bug: None Change-Id: Icc6977ec6b805d062cb3d0289c73fbf8b43ec940
* Enabled shared memory for DetachedBufferJiwen 'Steve' Cai2018-08-091-1/+12
| | | | | | | | | Bug: 112011098 Bug: 112012812 Bug: 111976433 Bug: 70046255 Test: buffer_hub-test Change-Id: I5111d08c1de1d1386e6896d3f7aba4e068d1adc4
* Move core data structure of DetachedBuffer into BufferNodeJiwen 'Steve' Cai2018-07-311-0/+32
| | | | | | | | | | | | | | | | | | | 1/ Supports mutiple DetachedBuffer(s) to be created from a single BufferNode. 2/ Separate core data structure and logic (i.e. BufferNode) out of the IPC layer (i.e. DetachedBufferChannel). 3/ DetachedBufferChannel will be renamed to BufferChannel in future and becomes the universal backend of GraphicBuffer. Thus we are naming the new class BufferNode instead of DetachedBufferNode. 4/ Move BufferHubDefs out of bufferhub_rpc.h, as BufferHubDefs is not directly related to the PDX IPCm echanism. Bug: 112011098 Bug: 112012812 Bug: 111976433 Bug: 70046255 Test: buffer_hub-test Change-Id: Ieba19329a0e823c78f21611462dedacdad3aab85
* Implement DetachedBuffer::PromoteJiwen 'Steve' Cai2018-04-271-10/+90
| | | | | | | | | | | | | | 1/ This enables a BufferHub-backed DetachedBuffer to be promoted into the ProducerBuffer. 2/ Add DetachedBuffer::IsConnected in addition to DetachedBuffer::IsValid. 3/ Cleaned up some using pdx:: namespace statements. Bug: 69982239 Bug: 69981968 Bug: 70046255 Test: buffer_hub-test Change-Id: I6ee99507b190d142647455532cdce0c2c780b2b0
* bufferhubd: Implement more DetachedBuffer logicJiwen 'Steve' Cai2018-04-041-2/+87
| | | | | | | | | | | | | | | | | | 1/ Separate DetachedBuffer related logic into a dedicated subclass of BufferHubRPC. This actually is the right thing to do as it utilizes the PDX's client/service programming pattern better. 2/ Add IsValid() check for the DetachedBufferChannel object. 3/ Add BufferHubClient to handle general PDX operations. 4/ Add DetachedBuffer which composites a BufferHubClient. 5/ Fully functional logic of allocating a DetachedBuffer, converting it to a BufferHub-backed GraphicBuffer, then converting it back to a DetachedBuffer. Bug: 38137191 Bug: 70046255 Bug: 70912269 Test: buffer_hub-test Change-Id: I81bf9259cbbaeb29a6df2769363b5a03464e7864
* Fix broken BufferHubQueueTest.TestRemoveBufferJiwen 'Steve' Cai2018-03-271-1/+6
| | | | | | | | | | | Under certain condition, it's unsafe to nullify the consumer channel within producer channel's destructor. Bug: 38137191 Bug: 70046255 Bug: 70912269 Test: buffer_hub-test, buffer_hub_queue-tests, buffer_hub_queue_producer-tesst Change-Id: Ifbed85e687e71340f6876e4e85c792ae1d6b06f6
* bufferhubd: Add DetachedBufferChannelJiwen 'Steve' Cai2018-03-201-0/+58
| | | | | | | | | | | | | 1/ Introduces four new BufferHub RPC operations. 2/ Implements the ProducerBufferDetach with test case. 3/ Also fixes a bug that Hangup signal wasn't propogated to the client when bufferhubd closes a producer channel. Bug: 38137191 Bug: 70046255 Bug: 70912269 Test: buffer_hub-test Change-Id: Ia2ba0e95abd3c1b960670c505c6fdb9c9de3a6dd
* Remove legacy persistent BufferHub use caseJiwen 'Steve' Cai2018-02-261-68/+0
| | | | | | | | | | | | | | | | | | | | | This CL cleans up unused BufferHub code path. The motivation of doing this is multifold: 1. Reduces future maintainace cost (e.g. when moving to libgui, there will be less code to rename and re-style). 2. Removes unnecessary code complexity so that the code base is easier and cleaner for future new reader to understand. 3. Prepares future work for supporting standalone GraphicBuffer in BufferHub by avoid future logical and naming conflicts between legacy PersistentBuffer/Detach/Attach and newly proposed detached GraphicBuffer in BufferHub. Bug: 70046255 Bug: 70912269 Test: buffer_hub-test, buffer_hub_queue-test, buffer_hub_queue_producer-test, dvr_api-test, libgui_test Change-Id: Ie9a0f55e3f620769bac58c81439d840402451b82
* Fix a flaky test in buffer_hub-testJiwen 'Steve' Cai2017-12-071-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | UDS-based PDX guarantees commands execution on the same channel. However, where there are incoming commands from different channels, the execution order can no longer be guaranteed as the service basical holds a epoll on sockets from different FDs. The original test we put up is flaky for the following commands: c1->ReleaseAsync p->CreateConsumer Not that the ReleaseAsync call may actually happen after a new consumer gets created, which prevents the buffer from being fulling released back to the producer. To de-flaky the test, simplily poll the producer after the release to confirm that the buffer is indeed released before moving on. Bug: 70298522 Bug: 70046255 Test: buffer_hub-test Change-Id: Ia3987642a40f62e7d151edbdf0f11dd9bee57223
* Reduce buffer_hub-test flakinessJiwen 'Steve' Cai2017-11-081-54/+61
| | | | | | | | | | | Increase the poll() timeout to 100ms to reduce test flakiness. Also update to use glocal const kPollTimeoutMs so that we can easily tune it in future. This also fix some compiler warnings around EXPECT_EQ. Bug: 63909629 Bug: 68152849 Test: buffer_hub-test Change-Id: I4e0e891125e0a1763b0f319bf47e71bc59213024
* Add more unit test for bufferhubJiwen 'Steve' Cai2017-10-241-0/+774
TestAsyncStateTransitions TestZeroConsumer TestMaxConsumers TestCreateConsumerWhenBufferGained TestCreateConsumerWhenBufferPosted TestCreateConsumerWhenBufferReleased This also renames the test to buffer_hub-test to match the name scheme we are using elsewhere (i.e. buffer_hub_xxx instead of bufferhub_xxx and yyy-test vs yyy_tests). Bug: 68152849 Test: buffer_hub-test Change-Id: I18ed32862bbee207e2751139599eff4f6f6e8618