/
redgpu
/
NVIDIA-RTX-NRD-Sample
Обзор
Документация
Войти
/
redgpu
/
NVIDIA-RTX-NRD-Sample
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
_Include/Helper.h
49 строк
2 KB
Constantine Tarasenkov
Initial commit for Ubuntu 22.04+, based on https://github.com/NVIDIA-RTX/NRD-Sample/commit/7fa4d2ad053cfc5bbd7a65c875331d670e3af1fb
02 июл 2026, 13:15
02 июл 2026, 13:15
4cc2d10
Код
Авторство
О чём код?
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. NVIDIA CORPORATION and its licensors retain all intellectual property and proprietary rights in and to this software, related documentation and any modifications thereto. Any use, reproduction, disclosure or distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited. */ #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); } }; }