chrono_batch_render/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
12 / 12
100.0%
Branches:
14 / 19
73.7%
Functions:
1 / 1, 3 excl
100.0%

stage/columns/device_heap.h
Line Branch Exec Source
1 // SPDX-License-Identifier: BSD-3-Clause
2 #pragma once
3
4 #include <cstdint>
5 #include <map>
6 #include <string>
7 #include <vector>
8
9 #include "chrono_batch_render/device/buffer.h"
10 #include "chrono_batch_render/device/device.h"
11 #include "chrono_batch_render/device/ref.h"
12
13 namespace chrono::batch_render {
14
15 struct HeapBlock {
16 device::Buffer* buffer = nullptr;
17 uint64_t offset = 0;
18 uint64_t bytes = 0;
19
20 346 explicit operator bool() const {
21
2/2
✓ Branch 0 taken 345 times.
✓ Branch 1 taken 1 time.
346 return buffer != nullptr;
22 }
23
24 43961 uint64_t Address() const {
25
3/4
✓ Branch 1 taken 1 time.
✗ Branch 1 not taken.
✓ Branch 4 taken 37860 times.
✓ Branch 7 taken 3 times.
40917 return buffer->Address() + offset;
26 }
27
28 127568 device::BufferRange Range() const {
29 127568 return buffer->Slice(offset, bytes);
30 }
31 };
32
33 class DeviceHeap {
34 public:
35 DeviceHeap(device::Device& device, std::string label);
36
37 15313089 device::Device& GetDevice() const {
38
5/5
<unknown function 24>:
✓ Branch 1 taken 1535 times.
chrono::batch_render::HeapBlock::Range() const:
✓ Branch 1 taken 1179 times.
✓ Branch 3 taken 6342 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 6340 times.
15313089 return m_device;
39 }
40
41 uint64_t Bytes() const;
42 HeapBlock Allocate(uint64_t bytes, uint64_t alignment);
43 void Free(const HeapBlock& block);
44
45 private:
46
4/8
<unknown function 20>:
✓ Branch 0 taken 289 times.
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 524 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
<unknown function 46>:
✓ Branch 0 taken 235 times.
✗ Branch 1 not taken.
2098 struct Chunk {
47 Ref<device::Buffer> buffer;
48 uint64_t used = 0;
49 };
50
51 device::Device& m_device;
52 std::string m_label;
53 std::vector<Chunk> m_chunks;
54 std::map<uint64_t, std::vector<HeapBlock>> m_free;
55 uint64_t m_nextChunk;
56 };
57
58 }
59