/
redgpu
/
nv_rt
Обзор
Документация
Войти
/
redgpu
/
nv_rt
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
External/NRIFramework/Include/Helper.h
41 строка
1 KB
Constantine Tarasenkov
NRDSample commit 3dd5136f292ad958c698627d2ee19959a4117f7e, NRI commit b5cfe2c4161ccc39421041ba9ec55331af9221d1
19 апр 2024, 05:54
19 апр 2024, 05:54
491b2d5
Код
Авторство
О чём код?
// © 2021 NVIDIA Corporation #pragma once #include <vector> #include <array> namespace helper { template<typename T, typename A> constexpr T Align(T x, A alignment) { return (T)((size_t(x) + (size_t)alignment - 1) & ~((size_t)alignment - 1)); } template <typename T, uint32_t N> constexpr uint32_t GetCountOf(T const (&)[N]) { return N; } template <typename T> constexpr uint32_t GetCountOf(const std::vector<T>& v) { return (uint32_t)v.size(); } template <typename T, size_t N> constexpr uint32_t GetCountOf(const std::array<T, N>& v) { return (uint32_t)v.size(); } template<typename T, typename U> constexpr uint32_t GetOffsetOf(U T::*member) { return (uint32_t)((char*)&((T*)nullptr->*member) - (char*)nullptr); } template<typename T> constexpr size_t GetByteSizeOf(const std::vector<T>& v) { return v.size() * sizeof(decltype(v.back())); } struct Annotation { const nri::CoreInterface& m_NRI; nri::CommandBuffer& m_CommandBuffer; inline Annotation(const nri::CoreInterface& NRI, nri::CommandBuffer& commandBuffer, const char* name) : m_NRI(NRI), m_CommandBuffer(commandBuffer) { m_NRI.CmdBeginAnnotation(m_CommandBuffer, name); } inline ~Annotation() { m_NRI.CmdEndAnnotation(m_CommandBuffer); } }; }