KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_rhi_deferred_release.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#include <boost/test/unit_test.hpp>
22
23#include <vector>
24
25
26namespace
27{
28std::vector<uint32_t> retire( RHI_DEFERRED_RELEASE_QUEUE& aQueue, uint64_t aCompletedFrame )
29{
30 std::vector<uint32_t> freed;
31
32 aQueue.ProcessRetired( aCompletedFrame,
33 [&]( const RHI_DEFERRED_RELEASE_ENTRY& aEntry )
34 {
35 freed.push_back( aEntry.handleValue );
36 } );
37
38 return freed;
39}
40} // namespace
41
42
43BOOST_AUTO_TEST_SUITE( RhiDeferredRelease )
44
45
46BOOST_AUTO_TEST_CASE( HeldForFramesInFlight )
47{
50
51 BOOST_CHECK( !queue.HasRetired( 10 + RHI_FRAMES_IN_FLIGHT - 1 ) );
52 BOOST_CHECK( retire( queue, 10 + RHI_FRAMES_IN_FLIGHT - 1 ).empty() );
53
54 BOOST_CHECK( queue.HasRetired( 10 + RHI_FRAMES_IN_FLIGHT ) );
55 BOOST_CHECK( retire( queue, 10 + RHI_FRAMES_IN_FLIGHT ) == std::vector<uint32_t>{ 1 } );
56 BOOST_CHECK( !queue.HasRetired( 1000 ) );
57}
58
59
60BOOST_AUTO_TEST_CASE( RetiresInOrderAndKeepsTheRest )
61{
63
64 // Interleaved so that retiring has to pick entries out of the middle
70
71 BOOST_CHECK( ( retire( queue, 2 + RHI_FRAMES_IN_FLIGHT ) == std::vector<uint32_t>{ 1, 3, 5 } ) );
72
73 std::vector<uint32_t> flushed;
74
75 queue.FlushAll(
76 [&]( const RHI_DEFERRED_RELEASE_ENTRY& aEntry )
77 {
78 flushed.push_back( aEntry.handleValue );
79 } );
80
81 BOOST_CHECK( ( flushed == std::vector<uint32_t>{ 2, 4 } ) );
82 BOOST_CHECK( retire( queue, 1000 ).empty() );
83}
84
85
Holds destroyed GPU resource handles until no in-flight command buffer can still reference them.
void Enqueue(RHI_DEFERRED_RESOURCE_TYPE aType, uint32_t aHandleValue, uint64_t aCurrentFrame)
bool HasRetired(uint64_t aCompletedFrame) const
void FlushAll(Func &&aFreeFunc)
void ProcessRetired(uint64_t aCompletedFrame, Func &&aFreeFunc)
static bool empty(const wxTextEntryBase *aCtrl)
constexpr uint64_t RHI_FRAMES_IN_FLIGHT
uint32_t handleValue
generation and index
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(HeldForFramesInFlight)