| Line |
Branch |
Exec |
Source |
| 1 |
|
|
// SPDX-License-Identifier: BSD-3-Clause |
| 2 |
|
|
#pragma once |
| 3 |
|
|
|
| 4 |
|
|
#include <cstdint> |
| 5 |
|
|
#include <optional> |
| 6 |
|
|
#include <string> |
| 7 |
|
|
#include <utility> |
| 8 |
|
|
#include <variant> |
| 9 |
|
|
|
| 10 |
|
|
#include "chrono_batch_render/device/buffer.h" |
| 11 |
|
|
#include "chrono_batch_render/device/device.h" |
| 12 |
|
|
#include "chrono_batch_render/device/resource.h" |
| 13 |
|
|
#include "chrono_batch_render/export.h" |
| 14 |
|
|
|
| 15 |
|
|
namespace chrono::batch_render::device { |
| 16 |
|
|
|
| 17 |
|
|
struct AccelTriangles { |
| 18 |
|
|
BufferRange vertices; |
| 19 |
|
|
uint32_t stride = 12; |
| 20 |
|
|
uint32_t vertexCount = 0; |
| 21 |
|
|
std::optional<BufferRange> indices; |
| 22 |
|
|
uint32_t count = 0; |
| 23 |
|
|
bool refittable = false; |
| 24 |
|
|
}; |
| 25 |
|
|
|
| 26 |
|
|
struct AccelBoxes { |
| 27 |
|
|
BufferRange boxes; |
| 28 |
|
|
uint32_t count = 0; |
| 29 |
|
|
bool refittable = false; |
| 30 |
|
|
}; |
| 31 |
|
|
|
| 32 |
|
|
struct AccelInstances { |
| 33 |
|
|
BufferRange instances; |
| 34 |
|
|
uint32_t count = 0; |
| 35 |
|
|
}; |
| 36 |
|
|
|
| 37 |
|
|
enum class AccelLevel : uint8_t { |
| 38 |
|
|
Bottom, |
| 39 |
|
|
Top, |
| 40 |
|
|
}; |
| 41 |
|
|
|
| 42 |
|
✗ |
inline AccelLevel GetLevel(const AccelInput& input) { |
| 43 |
0/4
✗ Branch 0 not taken.
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 1 not taken.
|
✗ |
return std::holds_alternative<AccelInstances>(input) ? AccelLevel::Top : AccelLevel::Bottom; |
| 44 |
|
|
} |
| 45 |
|
|
|
| 46 |
|
121 |
inline bool Refittable(const AccelInput& input) { |
| 47 |
2/6
<unknown function 42>:
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
<unknown function 46>:
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 94 times.
|
121 |
if (const auto* triangles = std::get_if<AccelTriangles>(&input)) { |
| 48 |
|
27 |
return triangles->refittable; |
| 49 |
|
|
} |
| 50 |
3/12
<unknown function 42>:
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
<unknown function 46>:
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
✓ Branch 3 taken 120 times.
|
215 |
if (const auto* boxes = std::get_if<AccelBoxes>(&input)) { |
| 51 |
|
94 |
return boxes->refittable; |
| 52 |
|
|
} |
| 53 |
|
|
return true; |
| 54 |
|
|
} |
| 55 |
|
|
|
| 56 |
|
115 |
template <class Visit> void ForEachBuffer(const AccelTriangles& triangles, Visit visit) { |
| 57 |
|
115 |
visit(triangles.vertices); |
| 58 |
2/6
void chrono::batch_render::device::ForEachBuffer<chrono::batch_render::bvh::GeometryBuffers(std::variant<chrono::batch_render::device::AccelTriangles, chrono::batch_render::device::AccelBoxes> const&)::{lambda(chrono::batch_render::device::BufferRange)#1}>(chrono::batch_render::device::AccelTriangles const&, chrono::batch_render::bvh::GeometryBuffers(std::variant<chrono::batch_render::device::AccelTriangles, chrono::batch_render::device::AccelBoxes> const&)::{lambda(chrono::batch_render::device::BufferRange)#1}):
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 4 times.
void chrono::batch_render::device::ForEachBuffer<chrono::batch_render::device::CommandBuffer::HoldResources()::{lambda(chrono::batch_render::device::BuildAccelCommand const&)#1}::operator()(chrono::batch_render::device::BuildAccelCommand const&) const::{lambda(chrono::batch_render::device::BufferRange)#1}>(chrono::batch_render::device::AccelTriangles const&, chrono::batch_render::device::CommandBuffer::HoldResources()::{lambda(chrono::batch_render::device::BuildAccelCommand const&)#1}::operator()(chrono::batch_render::device::BuildAccelCommand const&) const::{lambda(chrono::batch_render::device::BufferRange)#1}):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
void chrono::batch_render::device::ForEachBuffer<chrono::batch_render::device::CommandEncoder::BuildAccel(chrono::batch_render::device::Accel&, std::variant<chrono::batch_render::device::AccelTriangles, chrono::batch_render::device::AccelBoxes, chrono::batch_render::device::AccelInstances> const&, chrono::batch_render::device::BufferRange, bool)::{lambda(chrono::batch_render::device::BufferRange)#1}>(chrono::batch_render::device::AccelTriangles const&, chrono::batch_render::device::CommandEncoder::BuildAccel(chrono::batch_render::device::Accel&, std::variant<chrono::batch_render::device::AccelTriangles, chrono::batch_render::device::AccelBoxes, chrono::batch_render::device::AccelInstances> const&, chrono::batch_render::device::BufferRange, bool)::{lambda(chrono::batch_render::device::BufferRange)#1}):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
115 |
if (triangles.indices) { |
| 59 |
|
111 |
visit(*triangles.indices); |
| 60 |
|
|
} |
| 61 |
|
115 |
} |
| 62 |
|
|
|
| 63 |
|
504 |
template <class Visit> void ForEachBuffer(const AccelBoxes& boxes, Visit visit) { |
| 64 |
|
504 |
visit(boxes.boxes); |
| 65 |
|
504 |
} |
| 66 |
|
|
|
| 67 |
|
✗ |
template <class Visit> void ForEachBuffer(const AccelInstances& instances, Visit visit) { |
| 68 |
|
✗ |
visit(instances.instances); |
| 69 |
|
✗ |
} |
| 70 |
|
|
|
| 71 |
|
|
template <class... Inputs, class Visit> |
| 72 |
|
619 |
void ForEachBuffer(const std::variant<Inputs...>& input, Visit visit) { |
| 73 |
|
1238 |
std::visit([&](const auto& held) { ForEachBuffer(held, visit); }, input); |
| 74 |
|
619 |
} |
| 75 |
|
|
|
| 76 |
|
✗ |
struct AccelSizes { |
| 77 |
|
|
uint64_t storage = 0; |
| 78 |
|
|
uint64_t scratch = 0; |
| 79 |
|
|
uint64_t updateScratch = 0; |
| 80 |
|
|
}; |
| 81 |
|
|
|
| 82 |
|
|
class CHRONO_BATCH_RENDER_API Accel : public Resource { |
| 83 |
|
|
public: |
| 84 |
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
✗ |
~Accel() override = default; |
| 85 |
|
|
|
| 86 |
|
✗ |
uint64_t Address() const { |
| 87 |
0/2
✗ Branch 1 not taken.
✗ Branch 1 not taken.
|
✗ |
return m_address; |
| 88 |
|
|
} |
| 89 |
|
|
|
| 90 |
|
✗ |
Buffer& Storage() const { |
| 91 |
0/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
|
✗ |
return *m_storage; |
| 92 |
|
|
} |
| 93 |
|
|
|
| 94 |
|
✗ |
AccelLevel Level() const { |
| 95 |
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
✗ |
return m_level; |
| 96 |
|
|
} |
| 97 |
|
|
|
| 98 |
|
|
const AccelSizes& Sizes() const { |
| 99 |
0/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
✗ |
return m_sizes; |
| 100 |
|
|
} |
| 101 |
|
|
|
| 102 |
|
|
protected: |
| 103 |
|
✗ |
Accel(Device& device, Ref<Buffer> storage, AccelLevel level, AccelSizes sizes, |
| 104 |
|
|
std::string label) |
| 105 |
|
✗ |
: Resource(device, std::move(label)), m_storage(std::move(storage)), m_level(level), |
| 106 |
0/1
✗ Branch 2 not taken.
|
✗ |
m_sizes(sizes) {} |
| 107 |
|
|
|
| 108 |
|
|
uint64_t m_address = 0; |
| 109 |
|
|
|
| 110 |
|
|
private: |
| 111 |
|
|
Ref<Buffer> m_storage; |
| 112 |
|
|
AccelLevel m_level; |
| 113 |
|
|
AccelSizes m_sizes; |
| 114 |
|
|
}; |
| 115 |
|
|
|
| 116 |
|
|
} |
| 117 |
|
|
|