- Vulkan Configuration Implementations - Fixed build errors on GCC and Clang
228 lines
8.7 KiB
C++
228 lines
8.7 KiB
C++
// =====================================================================================================================
|
|
// fennec, a free and open source game engine
|
|
// Copyright © 2025 - 2026 Medusa Slockbower
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
// =====================================================================================================================
|
|
|
|
///
|
|
/// \file fennec/math/relational.h
|
|
/// \brief \ref fennec_math_relational
|
|
///
|
|
///
|
|
/// \details
|
|
/// \author Medusa Slockbower
|
|
///
|
|
/// \copyright Copyright © 2025 - 2026 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html))
|
|
///
|
|
///
|
|
|
|
#ifndef FENNEC_MATH_RELATIONAL_H
|
|
#define FENNEC_MATH_RELATIONAL_H
|
|
|
|
///
|
|
/// \page fennec_math_relational Relational
|
|
///
|
|
/// \brief The Relational Functions defined in the [OpenGL 4.6 Shading Language Specification](https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.60.pdf).
|
|
///
|
|
/// \code #include <fennec/math/relational.h> \endcode
|
|
///
|
|
/// <table width="100%" class="fieldtable" id="table_fennec_math_relational_functions">
|
|
/// <tr><th style="vertical-align: top">Syntax
|
|
/// <th style="vertical-align: top">Description
|
|
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
|
/// \ref fennec::lessThan "bvec lessThan(vec x, vec y)"<br>
|
|
/// \ref fennec::lessThan "bvec lessThan(dvec x, dvec y)"<br>
|
|
/// \ref fennec::lessThan "bvec lessThan(ivec x, ivec y)"<br>
|
|
/// \ref fennec::lessThan "bvec lessThan(uvec x, uvec y)"
|
|
/// <td width="50%" style="vertical-align: top">
|
|
/// \copydetails fennec::lessThan
|
|
///
|
|
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
|
/// \ref fennec::lessThanEqual "bvec lessThanEqual(vec x, vec y)"<br>
|
|
/// \ref fennec::lessThanEqual "bvec lessThanEqual(dvec x, dvec y)"<br>
|
|
/// \ref fennec::lessThanEqual "bvec lessThanEqual(ivec x, ivec y)"<br>
|
|
/// \ref fennec::lessThanEqual "bvec lessThanEqual(uvec x, uvec y)"
|
|
/// <td width="50%" style="vertical-align: top">
|
|
/// \copydetails fennec::lessThanEqual
|
|
///
|
|
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
|
/// \ref fennec::greaterThan "bvec greaterThan(vec x, vec y)"<br>
|
|
/// \ref fennec::greaterThan "bvec greaterThan(dvec x, dvec y)"<br>
|
|
/// \ref fennec::greaterThan "bvec greaterThan(ivec x, ivec y)"<br>
|
|
/// \ref fennec::greaterThan "bvec greaterThan(uvec x, uvec y)"
|
|
/// <td width="50%" style="vertical-align: top">
|
|
/// \copydetails fennec::greaterThan
|
|
///
|
|
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
|
/// \ref fennec::greaterThanEqual "bvec greaterThanEqual(vec x, vec y)"<br>
|
|
/// \ref fennec::greaterThanEqual "bvec greaterThanEqual(dvec x, dvec y)"<br>
|
|
/// \ref fennec::greaterThanEqual "bvec greaterThanEqual(ivec x, ivec y)"<br>
|
|
/// \ref fennec::greaterThanEqual "bvec greaterThanEqual(uvec x, uvec y)"
|
|
/// <td width="50%" style="vertical-align: top">
|
|
/// \copydetails fennec::greaterThanEqual
|
|
///
|
|
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
|
/// \ref fennec::equal "bvec equal(vec x, vec y)"<br>
|
|
/// \ref fennec::equal "bvec equal(dvec x, dvec y)"<br>
|
|
/// \ref fennec::equal "bvec equal(ivec x, ivec y)"<br>
|
|
/// \ref fennec::equal "bvec equal(uvec x, uvec y)"
|
|
/// <td width="50%" style="vertical-align: top">
|
|
/// \copydetails fennec::equal
|
|
///
|
|
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
|
/// \ref fennec::notEqual "bvec notEqual(vec x, vec y)"<br>
|
|
/// \ref fennec::notEqual "bvec notEqual(dvec x, dvec y)"<br>
|
|
/// \ref fennec::notEqual "bvec notEqual(ivec x, ivec y)"<br>
|
|
/// \ref fennec::notEqual "bvec notEqual(uvec x, uvec y)"
|
|
/// <td width="50%" style="vertical-align: top">
|
|
/// \copydetails fennec::notEqual
|
|
///
|
|
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
|
/// \ref fennec::any "bool any(bvec x)"<br>
|
|
/// <td width="50%" style="vertical-align: top">
|
|
/// \copydetails fennec::any
|
|
///
|
|
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
|
/// \ref fennec::all "bool all(bvec x)"<br>
|
|
/// <td width="50%" style="vertical-align: top">
|
|
/// \copydetails fennec::all
|
|
///
|
|
/// <tr><td width="50%" style="vertical-align: top"> <br>
|
|
/// \ref fennec_vector_not "bool not(bvec x)"<br>
|
|
/// <td width="50%" style="vertical-align: top">
|
|
/// \details
|
|
/// \returns the component-wise logical complement of \math{x}. <br>
|
|
/// \param x the boolean vector to inverse <br>
|
|
///
|
|
/// </table>
|
|
///
|
|
///
|
|
///
|
|
|
|
#include <fennec/lang/types.h>
|
|
|
|
namespace fennec
|
|
{
|
|
|
|
///
|
|
/// \brief Returns the component-wise compare of x < y.
|
|
///
|
|
/// \returns the component-wise compare of x < y.
|
|
/// \param x lhs of the expression
|
|
/// \param y rhs of the expression
|
|
template<typename genType, typename genBType = bool_t, size_t...i>
|
|
constexpr vector<genBType, i...> lessThan(const vector<genType, i...>& x, const vector<genType, i...>& y) {
|
|
return vector<genBType, i...>(x[i] < y[i]...);
|
|
}
|
|
|
|
|
|
///
|
|
/// \brief Returns the component-wise compare of x <= y.
|
|
///
|
|
/// \returns the component-wise compare of x <= y.
|
|
/// \param x lhs of the expression
|
|
/// \param y rhs of the expression
|
|
template<typename genType, typename genBType = bool_t, size_t...i>
|
|
constexpr vector<genBType, i...> lessThanEqual(const vector<genType, i...>& x, const vector<genType, i...>& y) {
|
|
return vector<genBType, i...>(x[i] <= y[i]...);
|
|
}
|
|
|
|
|
|
///
|
|
/// \brief Returns the component-wise compare of x > y.
|
|
///
|
|
/// \returns the component-wise compare of x > y.
|
|
/// \param x lhs of the expression
|
|
/// \param y rhs of the expression
|
|
template<typename genType, typename genBType = bool_t, size_t...i>
|
|
constexpr vector<genBType, i...> greaterThan(const vector<genType, i...>& x, const vector<genType, i...>& y) {
|
|
return vector<genBType, i...>(x[i] > y[i]...);
|
|
}
|
|
|
|
|
|
///
|
|
/// \brief Returns the component-wise compare of x >= y.
|
|
///
|
|
/// \returns the component-wise compare of x >= y.
|
|
/// \param x lhs of the expression
|
|
/// \param y rhs of the expression
|
|
template<typename genType, typename genBType = bool_t, size_t...i>
|
|
constexpr vector<genBType, i...> greaterThanEqual(const vector<genType, i...>& x, const vector<genType, i...>& y) {
|
|
return vector<genBType, i...>(x[i] >= y[i]...);
|
|
}
|
|
|
|
|
|
///
|
|
/// \brief Returns the component-wise compare of x == y.
|
|
///
|
|
/// \returns the component-wise compare of x == y.
|
|
/// \param x lhs of the expression
|
|
/// \param y rhs of the expression
|
|
template<typename genType, typename genBType = bool_t, size_t...i>
|
|
constexpr vector<genBType, i...> equal(const vector<genType, i...>& x, const vector<genType, i...>& y) {
|
|
return vector<genBType, i...>(x[i] == y[i]...);
|
|
}
|
|
|
|
|
|
///
|
|
/// \brief Returns the component-wise compare of x != y.
|
|
///
|
|
/// \returns the component-wise compare of x != y.
|
|
/// \param x lhs of the expression
|
|
/// \param y rhs of the expression
|
|
template<typename genType, typename genBType = bool_t, size_t...i>
|
|
constexpr vector<genBType, i...> notEqual(const vector<genType, i...>& x, const vector<genType, i...>& y) {
|
|
return vector<genBType, i...>(x[i] != y[i]...);
|
|
}
|
|
|
|
|
|
///
|
|
/// \brief Returns \math{true} if any component of \math{x} is \math{true}
|
|
///
|
|
/// \returns \math{true} if any component of \math{x} is \math{true}
|
|
/// \param x the boolean vector to test
|
|
template<typename genBType = bool_t, size_t...i>
|
|
constexpr genBType any(const vector<genBType, i...>& x) {
|
|
return (x[i] || ...);
|
|
}
|
|
|
|
///
|
|
/// \brief Returns \math{true} if all components of \math{x} are \math{true}
|
|
///
|
|
/// \returns \math{true} if all components of \math{x} are \math{true}
|
|
/// \param x the boolean vector to test
|
|
template<typename genBType = bool_t, size_t...i>
|
|
constexpr genBType all(const vector<genBType, i...>& x) {
|
|
return (x[i] && ...);
|
|
}
|
|
|
|
///
|
|
/// \anchor fennec_vector_not
|
|
/// \brief Returns the component-wise logical complement of \math{x}.
|
|
///
|
|
/// \details
|
|
/// \returns the component-wise logical complement of \math{x}.
|
|
/// \param x the boolean vector to inverse
|
|
template<typename genBType = bool_t, size_t...i>
|
|
constexpr vector<genBType, i...> operator not(const vector<genBType, i...>& x) {
|
|
return vector<genBType, i...>((!x[i]) ...);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // FENNEC_MATH_RELATIONAL_H
|