device/slang/debug.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // SPDX-License-Identifier: BSD-3-Clause | ||
| 2 | #pragma once | ||
| 3 | |||
| 4 | #include <cstdint> | ||
| 5 | #include <map> | ||
| 6 | #include <mutex> | ||
| 7 | #include <optional> | ||
| 8 | #include <span> | ||
| 9 | #include <string> | ||
| 10 | #include <utility> | ||
| 11 | #include <vector> | ||
| 12 | |||
| 13 | #include "chrono_batch_render/device/buffer.h" | ||
| 14 | #include "chrono_batch_render/device/ref.h" | ||
| 15 | |||
| 16 | namespace chrono::batch_render::device { | ||
| 17 | |||
| 18 | class Device; | ||
| 19 | |||
| 20 | class DebugRecords { | ||
| 21 | public: | ||
| 22 | static constexpr uint32_t kCapacity = 1024; | ||
| 23 | |||
| 24 | static uint64_t Bytes(); | ||
| 25 | |||
| 26 | explicit DebugRecords(Ref<Buffer> buffer); | ||
| 27 | |||
| 28 | 1137 | uint64_t Address() const { | |
| 29 | 1137 | return m_buffer->Address(); | |
| 30 | } | ||
| 31 | |||
| 32 | BufferRange Submission() const; | ||
| 33 | |||
| 34 | void AddKernel(const std::string& kernel, std::span<const std::string> strings); | ||
| 35 | |||
| 36 | void Read(uint64_t finished, bool idle); | ||
| 37 | |||
| 38 | std::optional<std::string> TakeFailures(uint64_t submission); | ||
| 39 | |||
| 40 | private: | ||
| 41 | std::string Format(const uint32_t* record) const; | ||
| 42 | |||
| 43 | void Report(const uint32_t* record, uint64_t finished); | ||
| 44 | |||
| 45 | Ref<Buffer> m_buffer; | ||
| 46 | uint32_t* m_header = nullptr; | ||
| 47 | uint32_t m_read = 0; | ||
| 48 | mutable std::mutex m_mutex; | ||
| 49 | std::map<uint32_t, std::string> m_strings; | ||
| 50 | std::map<uint32_t, std::string> m_kernels; | ||
| 51 | std::multimap<uint64_t, std::string> m_failures; | ||
| 52 | }; | ||
| 53 | |||
| 54 | uint32_t SlangStringHash(std::string_view text); | ||
| 55 | |||
| 56 | } | ||
| 57 |