Represents a native graphics API handle (e.g. D3D12 or Vulkan). Native handles are expected to fit into 64 bits. Type information and conversion from/to native handles is done using type traits from NativeHandleTraits.h which needs to be included when creating and accessing NativeHandle. This separation is done so we don't expose the heavy D3D12/Vulkan headers everywhere.
| 71 | /// This separation is done so we don't expose the heavy D3D12/Vulkan |
| 72 | /// headers everywhere. |
| 73 | class NativeHandle |
| 74 | { |
| 75 | public: |
| 76 | NativeHandle() = default; |
| 77 | |
| 78 | template<typename T> |
| 79 | explicit NativeHandle(T native) |
| 80 | { |
| 81 | mType = NativeHandleTrait<T>::type; |
| 82 | mValue = NativeHandleTrait<T>::pack(native); |
| 83 | } |
| 84 | |
| 85 | NativeHandleType getType() const { return mType; } |
| 86 | |
| 87 | bool isValid() const { return mType != NativeHandleType::Unknown; } |
| 88 | |
| 89 | template<typename T> |
| 90 | T as() const |
| 91 | { |
| 92 | FALCOR_ASSERT(mType == NativeHandleTrait<T>::type); |
| 93 | return NativeHandleTrait<T>::unpack(mValue); |
| 94 | } |
| 95 | |
| 96 | private: |
| 97 | NativeHandleType mType{NativeHandleType::Unknown}; |
| 98 | uint64_t mValue{0}; |
| 99 | }; |
| 100 | |
| 101 | } // namespace Falcor |
no outgoing calls