device/stream.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // SPDX-License-Identifier: BSD-3-Clause | ||
| 2 | #pragma once | ||
| 3 | |||
| 4 | #include <cstdint> | ||
| 5 | |||
| 6 | namespace chrono::batch_render { | ||
| 7 | |||
| 8 | class Stream { | ||
| 9 | public: | ||
| 10 | ✗ | static constexpr Stream Compute(void* handle) { | |
| 11 | ✗ | return Stream(Kind::Compute, handle); | |
| 12 | } | ||
| 13 | |||
| 14 | static constexpr Stream Default() { | ||
| 15 | return Stream(Kind::Compute, nullptr); | ||
| 16 | } | ||
| 17 | |||
| 18 | static constexpr Stream Host() { | ||
| 19 | return Stream(Kind::Host, nullptr); | ||
| 20 | } | ||
| 21 | |||
| 22 | static constexpr Stream None() { | ||
| 23 | return Stream(Kind::None, nullptr); | ||
| 24 | } | ||
| 25 | |||
| 26 | constexpr bool IsHost() const { | ||
| 27 | return m_kind == Kind::Host; | ||
| 28 | } | ||
| 29 | |||
| 30 | 5935 | constexpr bool IsNone() const { | |
| 31 | 5935 | return m_kind == Kind::None; | |
| 32 | } | ||
| 33 | |||
| 34 | 139532 | constexpr bool IsCompute() const { | |
| 35 | 139532 | return m_kind == Kind::Compute; | |
| 36 | } | ||
| 37 | |||
| 38 | ✗ | constexpr bool IsDefault() const { | |
| 39 | ✗ | return m_kind == Kind::Compute && m_handle == nullptr; | |
| 40 | } | ||
| 41 | |||
| 42 | ✗ | constexpr void* Handle() const { | |
| 43 | ✗ | return m_handle; | |
| 44 | } | ||
| 45 | |||
| 46 | private: | ||
| 47 | enum class Kind : uint8_t { None, Host, Compute }; | ||
| 48 | |||
| 49 | ✗ | constexpr Stream(Kind kind, void* handle) : m_kind(kind), m_handle(handle) {} | |
| 50 | |||
| 51 | Kind m_kind; | ||
| 52 | void* m_handle; | ||
| 53 | }; | ||
| 54 | |||
| 55 | } | ||
| 56 |