Add Chromium-only Blender WebEngine parity work
This commit is contained in:
32
blender-5.2.0/source/blender/blenlib/BLI_unroll.hh
Normal file
32
blender-5.2.0/source/blender/blenlib/BLI_unroll.hh
Normal file
@@ -0,0 +1,32 @@
|
||||
/* SPDX-FileCopyrightText: 2024 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/** \file
|
||||
* \ingroup bli
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdlib>
|
||||
#include <utility>
|
||||
|
||||
namespace blender {
|
||||
|
||||
template<class Fn, size_t... I>
|
||||
constexpr void unroll_impl(Fn fn, std::index_sequence<I...> /*indices*/)
|
||||
{
|
||||
(fn(I), ...);
|
||||
}
|
||||
|
||||
/**
|
||||
* Variadic templates are used to unroll loops manually. This helps GCC avoid branching during math
|
||||
* operations and makes the code generation more explicit and predictable. Unrolling should always
|
||||
* be worth it because the vector size is expected to be small.
|
||||
*/
|
||||
template<int N, class Fn> constexpr void unroll(Fn fn)
|
||||
{
|
||||
unroll_impl(fn, std::make_index_sequence<N>());
|
||||
}
|
||||
|
||||
} // namespace blender
|
||||
Reference in New Issue
Block a user