// AUTOGENERATED COPYRIGHT HEADER START // Copyright (C) 2017-2023 Michael Fabian 'Xaymar' Dirks // AUTOGENERATED COPYRIGHT HEADER END #pragma once #include "common.hpp" #include "util/util-pool.hpp" #include "util/util-singleton.hpp" #include "warning-disable.hpp" #include #include #include #include #include #include #include #include #include "warning-enable.hpp" static bool operator<(gs_sampler_info const& lhs, gs_sampler_info const& rhs) noexcept { return (lhs.address_u < rhs.address_u) || (lhs.address_v < rhs.address_v) || (lhs.address_w < rhs.address_w) || (lhs.filter < rhs.filter) || (lhs.max_anisotropy < rhs.max_anisotropy); } static bool operator==(gs_sampler_info const& lhs, gs_sampler_info const& rhs) noexcept { return (lhs.address_u == rhs.address_u) && (lhs.address_v == rhs.address_v) && (lhs.address_w == rhs.address_w) && (lhs.border_color == rhs.border_color) && (lhs.filter == rhs.filter) && (lhs.max_anisotropy == rhs.max_anisotropy); } template<> struct std::hash { std::size_t operator()(gs_sampler_info si) const noexcept { auto hash = std::hash{}(si.address_u); hash ^= std::hash{}(si.address_v); hash ^= std::hash{}(si.address_w); hash ^= std::hash{}(si.border_color); hash ^= std::hash{}(si.filter); hash ^= std::hash{}(si.max_anisotropy); return hash; } }; namespace streamfx::obs::gs { class sampler { gs_sampler_info _info; gs_sampler_state* _state; public: ~sampler(); sampler(); sampler(gs_sampler_info si); FORCE_INLINE gs_sample_filter get_filter() const { return _info.filter; } FORCE_INLINE gs_address_mode get_address_mode_u() const { return _info.address_u; } FORCE_INLINE gs_address_mode get_address_mode_v() const { return _info.address_v; } FORCE_INLINE gs_address_mode get_address_mode_w() const { return _info.address_w; } FORCE_INLINE int get_max_anisotropy() const { return _info.max_anisotropy; } FORCE_INLINE uint32_t get_border_color() const { return _info.border_color; } FORCE_INLINE uint8_t get_border_color(bool r, bool g, bool b, bool a) const { if (a) return (_info.border_color >> 24) & 0xFF; if (r) return (_info.border_color >> 16) & 0xFF; if (g) return (_info.border_color >> 8) & 0xFF; if (b) return _info.border_color & 0xFF; return 0; } FORCE_INLINE gs_sampler_info info() const { return _info; } FORCE_INLINE gs_sampler_state* update() const { return _state; } public: class pool; typedef gs_sampler_info _pool_key_t; typedef streamfx::util::multipool _pool_t; class pool : public _pool_t { friend streamfx::util::singleton; friend _pool_t; public: ~pool() {} protected: pool() : _pool_t() {} static _pool_key_t as_key(streamfx::obs::gs::sampler* to_hash); static _pool_key_t as_key(gs_sampler_info to_hash); }; }; } // namespace streamfx::obs::gs