Shader Model Versions
Functions
-
constexpr d3d::shadermodel::Version operator""_sm(const char *text)
User literal operator for
_sm
to generate shader model versions. This is a raw operator, valid input is <digit>.<digit>, any other literals will result in undefined behavior.text
Literal text to process. Format has to be <digit>.<digit>- Returns:
A valid version value should the input match the format. Otherwise undefined behavior.
-
template<>
struct DebugConverter<d3d::shadermodel::VersionWithName> - #include <dag_shaderModelVersion.h>
Public Static Functions
-
static inline const char *getDebugType(const d3d::shadermodel::VersionWithName &version)
-
static inline const char *getDebugType(const d3d::shadermodel::VersionWithName &version)
-
template<>
struct DebugConverter<d3d::shadermodel::Version> - #include <dag_shaderModelVersion.h>
Public Static Functions
-
static inline unsigned int getDebugType(const d3d::shadermodel::Version &version)
-
static inline unsigned int getDebugType(const d3d::shadermodel::Version &version)
-
template<unsigned Major, unsigned Minor>
struct DebugConverter<d3d::shadermodel::VersionConstant<Major, Minor>> - #include <dag_shaderModelVersion.h>
Public Static Functions
-
static inline unsigned int getDebugType(const d3d::shadermodel::VersionConstant<Major, Minor> &version)
-
static inline unsigned int getDebugType(const d3d::shadermodel::VersionConstant<Major, Minor> &version)
-
namespace d3d
Functions
-
inline const char *as_string(d3d::shadermodel::Version v)
Returns the “<major>.<minor>” string representation of a Version value that is part of d3d::smAny.
v
Version for which string it should be returned.- Returns:
A valid constant string for versions included in d3d::smAny.
-
inline const char *as_string(d3d::shadermodel::VersionWithName v)
Returns the “<major>.<minor>” string representation of a VersionWithName value.
v
Version for which string it should be returned.- Returns:
versionName
member ofv
.
-
inline const char *as_ps_string(d3d::shadermodel::Version v)
Returns the “ps<major><minor>” string representation of a Version value that is part of d3d::smAny.
v
Version for which string it should be returned.- Returns:
A valid constant string for versions included in d3d::smAny.
-
inline const char *as_ps_string(d3d::shadermodel::VersionWithName v)
Returns the “ps<major><minor>” string representation of a VersionWithName value.
v
Version for which string it should be returned.- Returns:
psName
member ofv
.
Variables
-
constexpr shadermodel::VersionConstant<0, 0> smNone
Shader model constant that represents no shader model.
-
constexpr shadermodel::VersionConstant<4, 0> sm40
Version constant of the 4.0 shader model.
-
constexpr shadermodel::VersionConstant<4, 1> sm41
Version constant of the 4.1 shader model.
-
constexpr shadermodel::VersionConstant<5, 0> sm50
Version constant of the 5.0 shader model.
-
constexpr shadermodel::VersionConstant<6, 0> sm60
Version constant of the 6.0 shader model.
-
constexpr shadermodel::VersionConstant<6, 6> sm66
Version constant of the 6.6 shader model.
-
constexpr shadermodel::AnyVersion smAny
Version constant that will match true to any shader model version.
-
constexpr auto smMax = max(shadermodel::AllVersionsList{})
Latest supported shader model version of the list defined by shadermodel::AllVersionsList.
-
constexpr auto smMin = min(shadermodel::AllVersionsList{})
Earliest supported shader model version of the list defined by shadermodel::AllVersionsList.
-
constexpr shadermodel::VersionRange<shadermodel::AllVersionsList> smAll
This value is a version range over all listed versions, to extend the list, alter the type d3d::shadermodel::AllVersionsList. This value supports begin / end and can be used as a range for range based for loops.
-
namespace shadermodel
This namespace hold all shader model version related types and utilities.
Typedefs
Functions
-
constexpr bool operator==(const Version &l, const Version &r)
Compares two version numbers and returns true when the first one equal to the second one.
- Parameters:
l – First value to compare.
r – Second value to compare.
- Returns:
True when \l equal to
r
.
-
constexpr bool operator!=(const Version &l, const Version &r)
Compares two version numbers and returns true when the first one not equal to the second one.
- Parameters:
l – First value to compare.
r – Second value to compare.
- Returns:
True when \l not equal to
r
.
-
constexpr bool operator<(const Version &l, const Version &r)
Compares two version numbers and returns true when the first less than the second one.
- Parameters:
l – First value to compare.
r – Second value to compare.
- Returns:
True when \l less than
r
.
-
constexpr bool operator>(const Version &l, const Version &r)
Compares two version numbers and returns true when the first one greater the second one.
- Parameters:
l – First value to compare.
r – Second value to compare.
- Returns:
True when \l greater than
r
.
-
constexpr bool operator<=(const Version &l, const Version &r)
Compares two version numbers and returns true when the first one less or equal to the second one.
- Parameters:
l – First value to compare.
r – Second value to compare.
- Returns:
True when \l less or equal to
r
.
-
constexpr bool operator>=(const Version &l, const Version &r)
Compares two version numbers and returns true when the first greater or equal the second one.
- Parameters:
l – First value to compare.
r – Second value to compare.
- Returns:
True when \l greater or equal to
r
.
-
constexpr bool operator==(const AnyVersion &l, const Version &r)
Compares a version to any version.
- Parameters:
l – First value to compare.
r – Second value to compare.
- Returns:
True.
-
constexpr bool operator==(const Version &l, const AnyVersion &r)
Compares a version to any version.
- Parameters:
l – First value to compare.
r – Second value to compare.
- Returns:
true.
-
constexpr bool operator!=(const AnyVersion &l, const Version &r)
Compares a version to any version.
- Parameters:
l – First value to compare.
r – Second value to compare.
- Returns:
False.
-
constexpr bool operator!=(const Version &l, const AnyVersion &r)
Compares a version to any version.
- Parameters:
l – First value to compare.
r – Second value to compare.
- Returns:
False.
-
constexpr bool operator>(const AnyVersion &l, const Version &r)
Compares a version to any version.
- Parameters:
l – First value to compare.
r – Second value to compare.
- Returns:
True.
-
constexpr bool operator>(const Version &l, const AnyVersion &r)
Compares a version to any version.
- Parameters:
l – First value to compare.
r – Second value to compare.
- Returns:
False.
-
constexpr bool operator<(const AnyVersion &l, const Version &r)
Compares a version to any version.
- Parameters:
l – First value to compare.
r – Second value to compare.
- Returns:
False.
-
constexpr bool operator<(const Version &l, const AnyVersion &r)
Compares a version to any version.
- Parameters:
l – First value to compare.
r – Second value to compare.
- Returns:
True.
-
constexpr bool operator>=(const AnyVersion &l, const Version &r)
Compares a version to any version.
- Parameters:
l – First value to compare.
r – Second value to compare.
- Returns:
True when \l is larger or equal to
r
.
-
constexpr bool operator>=(const Version &l, const AnyVersion &r)
Compares a version to any version.
- Parameters:
l – First value to compare.
r – Second value to compare.
- Returns:
True when \l is larger or equal to
r
.
-
constexpr bool operator<=(const AnyVersion &l, const Version &r)
Compares a version to any version.
- Parameters:
l – First value to compare.
r – Second value to compare.
- Returns:
True when \l is less or equal to
r
.
-
constexpr bool operator<=(const Version &l, const AnyVersion &r)
Compares a version to any version.
- Parameters:
l – First value to compare.
r – Second value to compare.
- Returns:
True when \l is less or equal to
r
.
-
template<unsigned int mj1, unsigned int mi1, unsigned int mj2, unsigned int mi2>
constexpr bool operator==(const VersionConstant<mj1, mi1> &l, const VersionConstant<mj2, mi2> &r) Compares two constant version numbers and returns true when the first one equal to the second one.
- Parameters:
l – First value to compare.
r – Second value to compare.
- Returns:
True when \l equal to
r
.
-
template<unsigned int mj1, unsigned int mi1, unsigned int mj2, unsigned int mi2>
constexpr bool operator!=(const VersionConstant<mj1, mi1> &l, const VersionConstant<mj2, mi2> &r) Compares two constant version numbers and returns true when the first one not equal to the second one.
- Parameters:
l – First value to compare.
r – Second value to compare.
- Returns:
True when \l not equal to
r
.
-
template<unsigned int mj1, unsigned int mi1, unsigned int mj2, unsigned int mi2>
constexpr bool operator<(const VersionConstant<mj1, mi1> &l, const VersionConstant<mj2, mi2> &r) Compares two constant version numbers and returns true when the first one is smaller than the second one.
- Parameters:
l – First value to compare.
r – Second value to compare.
- Returns:
True when \l is smaller than
r
.
-
template<unsigned int mj1, unsigned int mi1, unsigned int mj2, unsigned int mi2>
constexpr bool operator>(const VersionConstant<mj1, mi1> &l, const VersionConstant<mj2, mi2> &r) Compares two constant version numbers and returns true when the first one is larger than the second one.
- Parameters:
l – First value to compare.
r – Second value to compare.
- Returns:
True when \l is larger than
r
.
-
template<unsigned int mj1, unsigned int mi1, unsigned int mj2, unsigned int mi2>
constexpr bool operator<=(const VersionConstant<mj1, mi1> &l, const VersionConstant<mj2, mi2> &r) Compares two constant version numbers and returns true when the first one is less or equal to the second one.
- Parameters:
l – First value to compare.
r – Second value to compare.
- Returns:
True when \l is less or equal to
r
.
-
template<unsigned int mj1, unsigned int mi1, unsigned int mj2, unsigned int mi2>
constexpr bool operator>=(const VersionConstant<mj1, mi1> &l, const VersionConstant<mj2, mi2> &r) Compares two constant version numbers and returns true when the first one is larger or equal to the second one.
- Parameters:
l – First value to compare.
r – Second value to compare.
- Returns:
True when \l is larger or equal to
r
.
-
template<typename A, typename B>
inline constexpr auto max(VersionList<A, B>) Finds the latest version in the given version list.
- Parameters:
l – Version list to extract the latest version from.
- Returns:
The earlier version of
A
orB
.
-
template<typename A, typename B, typename C, typename ...Versions>
inline constexpr auto max(VersionList<A, B, C, Versions...>) Finds the latest version in the given version list.
- Parameters:
l – Version list to extract the latest version from.
- Returns:
The latest version (and its exact type) in the given list.
-
template<typename A, typename B>
inline constexpr auto min(VersionList<A, B> l) Finds the earliest version in the given version list.
- Parameters:
l – Version list to extract the earliest version from.
- Returns:
The earlier version of
A
orB
.
-
template<typename A, typename B, typename C, typename ...Versions>
inline constexpr auto min(VersionList<A, B, C, Versions...> l) Finds the earliest version in the given version list.
- Parameters:
l – Version list to extract the earliest version from.
- Returns:
The earliest version (and its exact type) in the given list.
-
template<typename VC, typename ...Vs>
inline unsigned int index_of(VersionList<Vs...> l, VC current) Finds the index of the version of
current
in the version listl
.
-
template<typename R, typename ...Vs>
inline R at(VersionList<Vs...> l, int index) Returns the
R
representation of the type inl
at the indexindex
.- Parameters:
l – Version list type to index into.
index – Index into
l
.
- Returns:
When index is in range of the version list, then it will return the
R
representation of that type at that index, otherwise t will return the default value ofR
.
-
struct AnyVersion
- #include <dag_shaderModelVersion.h>
This version type compares always true to any other shader model version.
-
struct Version
- #include <dag_shaderModelVersion.h>
Represents a shader model version.
Note
To add new supported shader models, you need to define a constant of the shader model and add this constant to the shader model list. See definition / uses of sm50 as example. It is also important to keep the order of versions in the list of AllVersionsList, otherwise other algorithms may fail to work properly.
Subclassed by d3d::shadermodel::VersionWithName
Public Functions
-
inline constexpr Version()
Default constructor, sets version values to 0.
-
inline constexpr Version(unsigned int ma, unsigned int mi)
Initializes the version with the given values. \ma Major version that should be stored. \mi Minor version that should be stored.
-
inline constexpr Version(const AnyVersion &v)
Constructor that stores a representation of AnyVersion, which sets major and minor version the max possible value.
-
template<typename T>
inline matcher::Map<T, Version> map(const Version &version, T &&value) const Begins a map from versions over this version to a value.
- Parameters:
version – The matcher of the first value matcher pair.
value – The value that should be stored when
version
should match.
- Returns:
Map to map versions to values.
-
template<unsigned int N>
inline matcher::Map<const char*, Version> map(const Version &version, const char (&str)[N]) const Begins a map from versions over this version to a value.
- Parameters:
version – The matcher of the first value matcher pair.
value – The value that should be stored when
version
should match.
- Returns:
Map to map versions to values.
-
inline constexpr Version()
-
template<unsigned int MajorVersion, unsigned int MinorVersion>
struct VersionConstant - #include <dag_shaderModelVersion.h>
A shader model version type.
- Template Parameters:
MajorVersion – Major version of this constant.
MinorVersion – Minor version of this constant.
Public Functions
-
inline operator VersionWithName() const
Conversion operator to convert to #VersionWithName.
-
template<typename T>
inline matcher::Map<T, Version> map(const Version &version, T &&value) const Begins a map from versions over this version to a value.
- Parameters:
version – The matcher of the first value matcher pair.
value – The value that should be stored when
version
should match.
- Returns:
Map to map versions to values.
-
template<unsigned int N>
inline matcher::Map<const char*, Version> map(const Version &version, const char (&str)[N]) const Begins a map from versions over this version to a value.
- Parameters:
version – The matcher of the first value matcher pair.
value – The value that should be stored when
version
should match.
- Returns:
Map to map versions to values.
Public Static Attributes
-
static constexpr unsigned int major = MajorVersion
Major version member / constant to make access uniform to #Version.
-
static constexpr unsigned int minor = MinorVersion
Minor version member / constant to make access uniform to #Version.
-
static constexpr char as_string[4] = {'0' + MajorVersion, '.', '0' + MinorVersion, '\0'}
String representation of this version in <major>.<minor> format.
-
static constexpr char as_ps_string[5] = {'p', 's', '0' + MajorVersion, '0' + MinorVersion, '\0'}
String representation of this version in ps<major><minor> format.
-
template<typename ...Versions>
struct VersionList - #include <dag_shaderModelVersion.h>
A list type of a set of versions.
- Template Parameters:
List – of versions.
-
template<typename ...Versions>
struct VersionRange<VersionList<Versions...>> - #include <dag_shaderModelVersion.h>
Represents a range of shader model versions that can be iterated over.
- Template Parameters:
Versions – The list of versions to iterate over.
Public Types
-
using ListOfVersions = VersionList<Versions...>
Helper type to cut down repeat code.
-
using Iterator = VersionRangeIterator<VersionWithName, VersionList<Versions...>>
Iterator type of this range.
Public Functions
-
inline Iterator begin() const
Returns the beginning of the version range, as in the most recent version.
- Returns:
Iterator representing the most recent version of this range.
-
inline Iterator cbegin() const
Returns the beginning of the version range, as in the most recent version.
- Returns:
Iterator representing the most recent version of this range.
-
inline Iterator end() const
Returns a iterator past the last (oldest) version of this range.
- Returns:
Iterator past the last (oldest) version of this range.
-
inline Iterator cend() const
Returns a iterator past the last (oldest) version of this range.
- Returns:
Iterator past the last (oldest) version of this range.
-
inline auto size() const
Returns the number of versions in this range.
- Returns:
Number of versions of this range.
-
template<typename V, typename VersionList>
class VersionRangeIterator - #include <dag_shaderModelVersion.h>
Version range iterator.
- Template Parameters:
V – Value type that the iterator represents. \pparam VersionList List of versions that this iterator iterates over.
Public Functions
-
constexpr VersionRangeIterator() = default
Default constructor, leaves type in uninitialized state.
-
constexpr VersionRangeIterator(const VersionRangeIterator&) = default
Basic copy constructor.
-
inline constexpr VersionRangeIterator(int idx)
Constructor which initializes the state with an given index into the list of
VersionList
.- Parameters:
idx – Index that should be stored in this iterator.
-
inline V operator*() const
Dereference operator that will return a value of
V
.- Returns:
A representation of the value at the
VersionList
at the currently stored index.
-
inline VersionRangeIterator &operator++()
Increment operator, moves the current index to the previous entry of the
VersionList
type.- Returns:
Reference to an altered this.
-
inline constexpr VersionRangeIterator operator++(int) const
Increment operator, moves the current index to the previous entry of the
VersionList
type.- Returns:
Copy of this advanced by one.
-
inline VersionRangeIterator &operator--()
Increment operator, moves the current index to the next entry of the
VersionList
type.- Returns:
Reference to an altered this.
-
inline constexpr VersionRangeIterator operator--(int) const
Increment operator, moves the current index to the previous entry of the
VersionList
type.- Returns:
Copy of this reversed one.
Private Members
-
int index
Index into the VersionList list of versions.
Friends
-
inline friend constexpr bool operator==(const VersionRangeIterator &l, const VersionRangeIterator &r)
Equal compare operator for to VersionRangeIterator.
l
First value to compare.r
Second value to compare.- Returns:
Returns true when
l
andr
do represent the same version value.
-
inline friend constexpr bool operator!=(const VersionRangeIterator &l, const VersionRangeIterator &r)
Not equal compare operator for to VersionRangeIterator.
l
First value to compare.r
Second value to compare.- Returns:
Returns true when
l
andr
do not represent the same version value.
-
struct VersionWithName : public d3d::shadermodel::Version
- #include <dag_shaderModelVersion.h>
Represents a shader model version with paired version name string and ps name string.
-
namespace matcher
This namespace holds all match / mapping utility functionality.
-
template<typename V, typename T, typename FinalMapType, typename Cmp = EqualCompare<V>>
class BasicMap : protected d3d::shadermodel::matcher::EqualCompare<V> - #include <dag_shaderModelVersion.h>
Basic map type, that allows mapping of matchers to values.
- Template Parameters:
V – Type of the value that is matched with the input matchers on each matching attempt.
T – Type of the stored value.
finalMapType – Type of the terminating mapping. This acts as a default and returns the value instead of a map.
Cmp – Comparison type that should be used to determine if anything was matched.
Public Functions
-
BasicMap() = default
Basic default constructor.
-
inline BasicMap(BasicMap &&other)
Basic move constructor that moves internal state from
other
to this.- Parameters:
other – Other instance that is used to initialize this, should a value be stored, it is moved to this.
-
BasicMap &operator=(const BasicMap&) = delete
Copy is not allowed as we don’t want users to copy maps around.
-
BasicMap &operator=(BasicMap&&) = delete
Move is not allowed as we don’t want users to move maps around.
-
inline BasicMap(const V &v)
Constructor that initializes the compare value state.
- Parameters:
v – Value that should be used with matchers.
-
template<typename OV>
inline BasicMap(const V &v, const OV &cmp, T &&t) Constructor that initializes the compare value state and does one map operation.
- Parameters:
v – Value that should be used with matchers.
cmp – Matcher that should be compared to the compare value.
t – Value that is stored should the compare of the matcher to the value yield true.
-
template<typename OV, typename C>
inline BasicMap(const V &v, const OV &cmp, C &&c) Constructor that initializes the compare value state and does one map operation.
- Parameters:
v – Value that should be used with matchers.
cmp – Matcher that should be compared to the compare value.
c – A generator that is used to generate input to the constructor of
T
should the compare of the matcher to the value yield true.
-
template<typename OV, typename ...Vs>
inline BasicMap(const V &v, const OV &cmp, Vs&&... vs) Constructor that initializes the compare value state and does one map operation.
- Parameters:
v – Value that should be used with matchers.
cmp – Matcher that should be compared to the compare value.
vs – Values that should be passed to the constructor of
T
should the compare of the matcher to the value yield true.
-
template<typename OV>
inline BasicMap &map(const OV &cmp, T &&t) Maps a matcher to a value.
- Parameters:
cmp – Value matcher.
t – Value that is stored in this if no value is stored in stored.
- Returns:
Reference to this.
-
template<typename OV, typename C>
inline BasicMap &map(const OV &cmp, C &&c) Maps a matcher to a value.
- Parameters:
cmp – Value matcher.
c – Generator that generates input passed to the constructor of
T
should no value be stored in this.
- Returns:
Reference to this.
-
template<typename OV, typename ...Vs>
inline BasicMap &map(const OV &cmp, Vs&&... vs) Maps a matcher to a value.
- Parameters:
cmp – Value matcher.
vs – Parameters passed to the constructor of
T
should no value be stored in this.
- Returns:
Reference to this.
-
inline T &&map(const FinalMapType &cmp, T &&t)
Maps final type to a value.
- Parameters:
cmp – Final value matcher.
t – Value that is stored in this if no value is stored in stored.
- Returns:
Stored valued of
T
.
-
template<typename C>
inline T &&map(const FinalMapType &cmp, C &&c) Maps final type to a value.
- Parameters:
cmp – Final value matcher.
c – Generator that generates input passed to the constructor of
T
should no value be stored in this.
- Returns:
Stored valued of
T
.
-
template<typename ...Vs>
inline T &&map(const FinalMapType &cmp, Vs&&... vs) Maps final type to a value.
- Parameters:
cmp – Final value matcher.
vs – Parameters passed to the constructor of
T
should no value be stored in this.
- Returns:
Stored valued of
T
.
Private Functions
-
inline T &object()
Helper to retrieve the stored instance of
T
.- Returns:
Reference to the store instance of
T
.
-
inline void cMove(bool should_construct, T &&v)
Conditional move constructor helper.
A new instance of
T
is going to be instantiated whenshould_construct
is true and the internal state indicates that there is no instance stored yet. In this casev
will be moved into the parameter of the move constructor ofT
for the new instance.- Parameters:
should_construct – Indicates if a instance of
T
should be instantiated or not.v – May be used as a input for the move constructor of
T
.
-
template<typename C>
inline void cContruct(bool should_construct, C &&generator) Conditional constructor helper.
A new instance of
T
is going to be instantiated whenshould_construct
is true and the internal state indicates that there is no instance stored yet. In this casegenerator
will be invoked to generate the input of the constructor ofT
for the new instance.- Parameters:
should_construct – Indicates if a instance of
T
should be instantiated or not.generator – When invoked it should generate valid input for the constructor of
T
.
-
template<typename ...Vs>
inline void cEmplace(bool should_construct, Vs&&... vs) Conditional emplace constructor helper.
A new instance of
T
is going to be instantiated whenshould_construct
is true and the internal state indicates that there is no instance stored yet. In this casevs
will be moved into the parameter of the constructor ofT
for the new instance.- Parameters:
should_construct – Indicates if a instance of
T
should be instantiated or not.vs – May be used as a input for the constructor of
T
.
-
template<typename T>
struct EqualCompare - #include <dag_shaderModelVersion.h>
Simple equal comparison compare type.
- Template Parameters:
T – Type of the compared type.
Subclassed by d3d::shadermodel::matcher::BasicMap< V, T, AnyVersion >, d3d::shadermodel::matcher::BasicMap< V, T, FinalMapType, Cmp >
-
template<typename T, typename V>
class Map : protected d3d::shadermodel::matcher::BasicMap<V, T, AnyVersion> - #include <dag_shaderModelVersion.h>
Map type that exactly matches values versions.
- Template Parameters:
T – Type of the stored value.
V – Type of the value that is matched with the input matchers on each matching attempt.
Private Types
-
using BaseType = BasicMap<V, T, AnyVersion>
Type shorthand to reduce typing.
-
template<typename V, typename T, typename FinalMapType, typename Cmp = EqualCompare<V>>
-
constexpr bool operator==(const Version &l, const Version &r)
-
inline const char *as_string(d3d::shadermodel::Version v)