diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp index 799b21ee85d..1c83f4e7907 100644 --- a/src/gui/rhi/qrhi.cpp +++ b/src/gui/rhi/qrhi.cpp @@ -883,40 +883,25 @@ QRhiDepthStencilClearValue::QRhiDepthStencilClearValue(float d, quint32 s) } /*! + \fn bool QRhiDepthStencilClearValue::operator==(const QRhiDepthStencilClearValue &a, const QRhiDepthStencilClearValue &b) noexcept + \return \c true if the values in the two QRhiDepthStencilClearValue objects \a a and \a b are equal. - - \relates QRhiDepthStencilClearValue */ -bool operator==(const QRhiDepthStencilClearValue &a, const QRhiDepthStencilClearValue &b) noexcept -{ - return a.depthClearValue() == b.depthClearValue() - && a.stencilClearValue() == b.stencilClearValue(); -} /*! + \fn bool QRhiDepthStencilClearValue::operator!=(const QRhiDepthStencilClearValue &a, const QRhiDepthStencilClearValue &b) noexcept + \return \c false if the values in the two QRhiDepthStencilClearValue objects \a a and \a b are equal; otherwise returns \c true. - \relates QRhiDepthStencilClearValue */ -bool operator!=(const QRhiDepthStencilClearValue &a, const QRhiDepthStencilClearValue &b) noexcept -{ - return !(a == b); -} /*! - \return the hash value for \a v, using \a seed to seed the calculation. + \fn size_t QRhiDepthStencilClearValue::qHash(const QRhiDepthStencilClearValue &v, size_t seed = 0) noexcept - \relates QRhiDepthStencilClearValue + \return the hash value for \a v, using \a seed to seed the calculation. */ -size_t qHash(const QRhiDepthStencilClearValue &v, size_t seed) noexcept -{ - QtPrivate::QHashCombine hash; - seed = hash(seed, v.depthClearValue()); - seed = hash(seed, v.stencilClearValue()); - return seed; -} #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug dbg, const QRhiDepthStencilClearValue &v) @@ -981,46 +966,24 @@ QRhiViewport::QRhiViewport(float x, float y, float w, float h, float minDepth, f } /*! + \fn bool QRhiViewport::operator==(const QRhiViewport &a, const QRhiViewport &b) noexcept + \return \c true if the values in the two QRhiViewport objects \a a and \a b are equal. - - \relates QRhiViewport */ -bool operator==(const QRhiViewport &a, const QRhiViewport &b) noexcept -{ - return a.viewport() == b.viewport() - && a.minDepth() == b.minDepth() - && a.maxDepth() == b.maxDepth(); -} /*! + \fn bool QRhiViewport::operator!=(const QRhiViewport &a, const QRhiViewport &b) noexcept + \return \c false if the values in the two QRhiViewport objects \a a and \a b are equal; otherwise returns \c true. - - \relates QRhiViewport */ -bool operator!=(const QRhiViewport &a, const QRhiViewport &b) noexcept -{ - return !(a == b); -} /*! - \return the hash value for \a v, using \a seed to seed the calculation. + \fn size_t QRhiViewport::qHash(const QRhiViewport &v, size_t seed = 0) noexcept - \relates QRhiViewport + \return the hash value for \a v, using \a seed to seed the calculation. */ -size_t qHash(const QRhiViewport &v, size_t seed) noexcept -{ - const std::array r = v.viewport(); - QtPrivate::QHashCombine hash; - seed = hash(seed, r[0]); - seed = hash(seed, r[1]); - seed = hash(seed, r[2]); - seed = hash(seed, r[3]); - seed = hash(seed, v.minDepth()); - seed = hash(seed, v.maxDepth()); - return seed; -} #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug dbg, const QRhiViewport &v) @@ -1080,42 +1043,24 @@ QRhiScissor::QRhiScissor(int x, int y, int w, int h) } /*! + \fn bool QRhiScissor::operator==(const QRhiScissor &a, const QRhiScissor &b) noexcept + \return \c true if the values in the two QRhiScissor objects \a a and \a b are equal. - - \relates QRhiScissor */ -bool operator==(const QRhiScissor &a, const QRhiScissor &b) noexcept -{ - return a.scissor() == b.scissor(); -} /*! + \fn bool QRhiScissor::operator!=(const QRhiScissor &a, const QRhiScissor &b) noexcept + \return \c false if the values in the two QRhiScissor objects \a a and \a b are equal; otherwise returns \c true. - - \relates QRhiScissor */ -bool operator!=(const QRhiScissor &a, const QRhiScissor &b) noexcept -{ - return !(a == b); -} /*! - \return the hash value for \a v, using \a seed to seed the calculation. + \fn size_t QRhiScissor::qHash(const QRhiScissor &v, size_t seed = 0) noexcept - \relates QRhiScissor + \return the hash value for \a v, using \a seed to seed the calculation. */ -size_t qHash(const QRhiScissor &v, size_t seed) noexcept -{ - const std::array r = v.scissor(); - QtPrivate::QHashCombine hash; - seed = hash(seed, r[0]); - seed = hash(seed, r[1]); - seed = hash(seed, r[2]); - seed = hash(seed, r[3]); - return seed; -} #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug dbg, const QRhiScissor &s) @@ -1217,41 +1162,24 @@ QRhiVertexInputBinding::QRhiVertexInputBinding(quint32 stride, Classification cl } /*! + \fn bool QRhiVertexInputBinding::operator==(const QRhiVertexInputBinding &a, const QRhiVertexInputBinding &b) noexcept + \return \c true if the values in the two QRhiVertexInputBinding objects \a a and \a b are equal. - - \relates QRhiVertexInputBinding */ -bool operator==(const QRhiVertexInputBinding &a, const QRhiVertexInputBinding &b) noexcept -{ - return a.stride() == b.stride() - && a.classification() == b.classification() - && a.instanceStepRate() == b.instanceStepRate(); -} /*! + \fn bool QRhiVertexInputBinding::operator!=(const QRhiVertexInputBinding &a, const QRhiVertexInputBinding &b) noexcept + \return \c false if the values in the two QRhiVertexInputBinding objects \a a and \a b are equal; otherwise returns \c true. - - \relates QRhiVertexInputBinding */ -bool operator!=(const QRhiVertexInputBinding &a, const QRhiVertexInputBinding &b) noexcept -{ - return !(a == b); -} /*! - \return the hash value for \a v, using \a seed to seed the calculation. + \fn size_t QRhiVertexInputBinding::qHash(const QRhiVertexInputBinding &v, size_t seed = 0) noexcept - \relates QRhiVertexInputBinding + \return the hash value for \a v, using \a seed to seed the calculation. */ -size_t qHash(const QRhiVertexInputBinding &v, size_t seed) noexcept -{ - QtPrivate::QHashCombine hash; - seed = hash(seed, v.stride()); - seed = hash(seed, v.classification()); - return seed; -} #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug dbg, const QRhiVertexInputBinding &b) @@ -1387,45 +1315,24 @@ QRhiVertexInputAttribute::QRhiVertexInputAttribute(int binding, int location, Fo } /*! + \fn bool QRhiVertexInputAttribute::operator==(const QRhiVertexInputAttribute &a, const QRhiVertexInputAttribute &b) noexcept + \return \c true if the values in the two QRhiVertexInputAttribute objects \a a and \a b are equal. - - \relates QRhiVertexInputAttribute */ -bool operator==(const QRhiVertexInputAttribute &a, const QRhiVertexInputAttribute &b) noexcept -{ - return a.binding() == b.binding() - && a.location() == b.location() - && a.format() == b.format() - && a.offset() == b.offset(); - // matrixSlice excluded intentionally -} /*! + \fn bool QRhiVertexInputAttribute::operator!=(const QRhiVertexInputAttribute &a, const QRhiVertexInputAttribute &b) noexcept + \return \c false if the values in the two QRhiVertexInputAttribute objects \a a and \a b are equal; otherwise returns \c true. - - \relates QRhiVertexInputAttribute */ -bool operator!=(const QRhiVertexInputAttribute &a, const QRhiVertexInputAttribute &b) noexcept -{ - return !(a == b); -} /*! - \return the hash value for \a v, using \a seed to seed the calculation. + \fn size_t QRhiVertexInputAttribute::qHash(const QRhiVertexInputAttribute &v, size_t seed = 0) noexcept - \relates QRhiVertexInputAttribute + \return the hash value for \a v, using \a seed to seed the calculation. */ -size_t qHash(const QRhiVertexInputAttribute &v, size_t seed) noexcept -{ - QtPrivate::QHashCombine hash; - seed = hash(seed, v.binding()); - seed = hash(seed, v.location()); - seed = hash(seed, v.format()); - seed = hash(seed, v.offset()); - return seed; -} #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug dbg, const QRhiVertexInputAttribute &a) @@ -1534,39 +1441,24 @@ quint32 QRhiImplementation::byteSizePerVertexForVertexInputFormat(QRhiVertexInpu */ /*! + \fn bool QRhiVertexInputLayout::operator==(const QRhiVertexInputLayout &a, const QRhiVertexInputLayout &b) noexcept + \return \c true if the values in the two QRhiVertexInputLayout objects \a a and \a b are equal. - - \relates QRhiVertexInputLayout */ -bool operator==(const QRhiVertexInputLayout &a, const QRhiVertexInputLayout &b) noexcept -{ - return a.m_bindings == b.m_bindings && a.m_attributes == b.m_attributes; -} /*! + \fn bool QRhiVertexInputLayout::operator!=(const QRhiVertexInputLayout &a, const QRhiVertexInputLayout &b) noexcept + \return \c false if the values in the two QRhiVertexInputLayout objects \a a and \a b are equal; otherwise returns \c true. - - \relates QRhiVertexInputLayout */ -bool operator!=(const QRhiVertexInputLayout &a, const QRhiVertexInputLayout &b) noexcept -{ - return !(a == b); -} /*! - \return the hash value for \a v, using \a seed to seed the calculation. + \fn size_t QRhiVertexInputLayout::qHash(const QRhiVertexInputLayout &v, size_t seed = 0) noexcept - \relates QRhiVertexInputLayout + \return the hash value for \a v, using \a seed to seed the calculation. */ -size_t qHash(const QRhiVertexInputLayout &v, size_t seed) noexcept -{ - QtPrivate::QHashCombine hash; - seed = hash(seed, v.m_bindings); - seed = hash(seed, v.m_attributes); - return seed; -} #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug dbg, const QRhiVertexInputLayout &v) @@ -1631,42 +1523,24 @@ QRhiShaderStage::QRhiShaderStage(Type type, const QShader &shader, QShader::Vari } /*! + \fn bool QRhiShaderStage::operator==(const QRhiShaderStage &a, const QRhiShaderStage &b) noexcept + \return \c true if the values in the two QRhiShaderStage objects \a a and \a b are equal. - - \relates QRhiShaderStage */ -bool operator==(const QRhiShaderStage &a, const QRhiShaderStage &b) noexcept -{ - return a.type() == b.type() - && a.shader() == b.shader() - && a.shaderVariant() == b.shaderVariant(); -} /*! + \fn bool QRhiShaderStage::operator!=(const QRhiShaderStage &a, const QRhiShaderStage &b) noexcept + \return \c false if the values in the two QRhiShaderStage objects \a a and \a b are equal; otherwise returns \c true. - - \relates QRhiShaderStage */ -bool operator!=(const QRhiShaderStage &a, const QRhiShaderStage &b) noexcept -{ - return !(a == b); -} /*! - \return the hash value for \a v, using \a seed to seed the calculation. + \fn size_t QRhiShaderStage::qHash(const QRhiShaderStage &v, size_t seed = 0) noexcept - \relates QRhiShaderStage + \return the hash value for \a v, using \a seed to seed the calculation. */ -size_t qHash(const QRhiShaderStage &v, size_t seed) noexcept -{ - QtPrivate::QHashCombine hash; - seed = hash(seed, v.type()); - seed = hash(seed, v.shader()); - seed = hash(seed, v.shaderVariant()); - return seed; -} #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug dbg, const QRhiShaderStage &s) diff --git a/src/gui/rhi/qrhi_p.h b/src/gui/rhi/qrhi_p.h index cc94c3b9d83..ec033fac2d9 100644 --- a/src/gui/rhi/qrhi_p.h +++ b/src/gui/rhi/qrhi_p.h @@ -56,13 +56,28 @@ public: private: float m_d = 1.0f; quint32 m_s = 0; + + friend bool operator==(const QRhiDepthStencilClearValue &a, const QRhiDepthStencilClearValue &b) noexcept + { + return a.m_d == b.m_d && a.m_s == b.m_s; + } + + friend bool operator!=(const QRhiDepthStencilClearValue &a, const QRhiDepthStencilClearValue &b) noexcept + { + return !(a == b); + } + + friend size_t qHash(const QRhiDepthStencilClearValue &v, size_t seed = 0) noexcept + { + QtPrivate::QHashCombine hash; + seed = hash(seed, v.m_d); + seed = hash(seed, v.m_s); + return seed; + } }; Q_DECLARE_TYPEINFO(QRhiDepthStencilClearValue, Q_RELOCATABLE_TYPE); -Q_GUI_EXPORT bool operator==(const QRhiDepthStencilClearValue &a, const QRhiDepthStencilClearValue &b) noexcept; -Q_GUI_EXPORT bool operator!=(const QRhiDepthStencilClearValue &a, const QRhiDepthStencilClearValue &b) noexcept; -Q_GUI_EXPORT size_t qHash(const QRhiDepthStencilClearValue &v, size_t seed = 0) noexcept; #ifndef QT_NO_DEBUG_STREAM Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiDepthStencilClearValue &); #endif @@ -88,13 +103,34 @@ private: std::array m_rect { { 0.0f, 0.0f, 0.0f, 0.0f } }; float m_minDepth = 0.0f; float m_maxDepth = 1.0f; + + friend bool operator==(const QRhiViewport &a, const QRhiViewport &b) noexcept + { + return a.m_rect == b.m_rect + && a.m_minDepth == b.m_minDepth + && a.m_maxDepth == b.m_maxDepth; + } + + friend bool operator!=(const QRhiViewport &a, const QRhiViewport &b) noexcept + { + return !(a == b); + } + + friend size_t qHash(const QRhiViewport &v, size_t seed = 0) noexcept + { + QtPrivate::QHashCombine hash; + seed = hash(seed, v.m_rect[0]); + seed = hash(seed, v.m_rect[1]); + seed = hash(seed, v.m_rect[2]); + seed = hash(seed, v.m_rect[3]); + seed = hash(seed, v.m_minDepth); + seed = hash(seed, v.m_maxDepth); + return seed; + } }; Q_DECLARE_TYPEINFO(QRhiViewport, Q_RELOCATABLE_TYPE); -Q_GUI_EXPORT bool operator==(const QRhiViewport &a, const QRhiViewport &b) noexcept; -Q_GUI_EXPORT bool operator!=(const QRhiViewport &a, const QRhiViewport &b) noexcept; -Q_GUI_EXPORT size_t qHash(const QRhiViewport &v, size_t seed = 0) noexcept; #ifndef QT_NO_DEBUG_STREAM Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiViewport &); #endif @@ -112,13 +148,30 @@ public: private: std::array m_rect { { 0, 0, 0, 0 } }; + + friend bool operator==(const QRhiScissor &a, const QRhiScissor &b) noexcept + { + return a.m_rect == b.m_rect; + } + + friend bool operator!=(const QRhiScissor &a, const QRhiScissor &b) noexcept + { + return !(a == b); + } + + friend size_t qHash(const QRhiScissor &v, size_t seed = 0) noexcept + { + QtPrivate::QHashCombine hash; + seed = hash(seed, v.m_rect[0]); + seed = hash(seed, v.m_rect[1]); + seed = hash(seed, v.m_rect[2]); + seed = hash(seed, v.m_rect[3]); + return seed; + } }; Q_DECLARE_TYPEINFO(QRhiScissor, Q_RELOCATABLE_TYPE); -Q_GUI_EXPORT bool operator==(const QRhiScissor &a, const QRhiScissor &b) noexcept; -Q_GUI_EXPORT bool operator!=(const QRhiScissor &a, const QRhiScissor &b) noexcept; -Q_GUI_EXPORT size_t qHash(const QRhiScissor &v, size_t seed = 0) noexcept; #ifndef QT_NO_DEBUG_STREAM Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiScissor &); #endif @@ -147,13 +200,31 @@ private: quint32 m_stride = 0; Classification m_classification = PerVertex; quint32 m_instanceStepRate = 1; + + friend bool operator==(const QRhiVertexInputBinding &a, const QRhiVertexInputBinding &b) noexcept + { + return a.m_stride == b.m_stride + && a.m_classification == b.m_classification + && a.m_instanceStepRate == b.m_instanceStepRate; + } + + friend bool operator!=(const QRhiVertexInputBinding &a, const QRhiVertexInputBinding &b) noexcept + { + return !(a == b); + } + + friend size_t qHash(const QRhiVertexInputBinding &v, size_t seed = 0) noexcept + { + QtPrivate::QHashCombine hash; + seed = hash(seed, v.m_stride); + seed = hash(seed, v.m_classification); + seed = hash(seed, v.m_instanceStepRate); + return seed; + } }; Q_DECLARE_TYPEINFO(QRhiVertexInputBinding, Q_RELOCATABLE_TYPE); -Q_GUI_EXPORT bool operator==(const QRhiVertexInputBinding &a, const QRhiVertexInputBinding &b) noexcept; -Q_GUI_EXPORT bool operator!=(const QRhiVertexInputBinding &a, const QRhiVertexInputBinding &b) noexcept; -Q_GUI_EXPORT size_t qHash(const QRhiVertexInputBinding &v, size_t seed = 0) noexcept; #ifndef QT_NO_DEBUG_STREAM Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiVertexInputBinding &); #endif @@ -203,13 +274,34 @@ private: Format m_format = Float4; quint32 m_offset = 0; int m_matrixSlice = -1; + + friend bool operator==(const QRhiVertexInputAttribute &a, const QRhiVertexInputAttribute &b) noexcept + { + return a.m_binding == b.m_binding + && a.m_location == b.m_location + && a.m_format == b.m_format + && a.m_offset == b.m_offset; + // matrixSlice excluded intentionally + } + + friend bool operator!=(const QRhiVertexInputAttribute &a, const QRhiVertexInputAttribute &b) noexcept + { + return !(a == b); + } + + friend size_t qHash(const QRhiVertexInputAttribute &v, size_t seed = 0) noexcept + { + QtPrivate::QHashCombine hash; + seed = hash(seed, v.m_binding); + seed = hash(seed, v.m_location); + seed = hash(seed, v.m_format); + seed = hash(seed, v.m_offset); + return seed; + } }; Q_DECLARE_TYPEINFO(QRhiVertexInputAttribute, Q_RELOCATABLE_TYPE); -Q_GUI_EXPORT bool operator==(const QRhiVertexInputAttribute &a, const QRhiVertexInputAttribute &b) noexcept; -Q_GUI_EXPORT bool operator!=(const QRhiVertexInputAttribute &a, const QRhiVertexInputAttribute &b) noexcept; -Q_GUI_EXPORT size_t qHash(const QRhiVertexInputAttribute &v, size_t seed = 0) noexcept; #ifndef QT_NO_DEBUG_STREAM Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiVertexInputAttribute &); #endif @@ -247,14 +339,27 @@ private: QVarLengthArray m_bindings; QVarLengthArray m_attributes; - friend Q_GUI_EXPORT bool operator==(const QRhiVertexInputLayout &a, const QRhiVertexInputLayout &b) noexcept; - friend Q_GUI_EXPORT size_t qHash(const QRhiVertexInputLayout &v, size_t seed) noexcept; + friend bool operator==(const QRhiVertexInputLayout &a, const QRhiVertexInputLayout &b) noexcept + { + return a.m_bindings == b.m_bindings && a.m_attributes == b.m_attributes; + } + + friend bool operator!=(const QRhiVertexInputLayout &a, const QRhiVertexInputLayout &b) noexcept + { + return !(a == b); + } + + friend size_t qHash(const QRhiVertexInputLayout &v, size_t seed = 0) noexcept + { + QtPrivate::QHashCombine hash; + seed = hash(seed, v.m_bindings); + seed = hash(seed, v.m_attributes); + return seed; + } + friend Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiVertexInputLayout &); }; -Q_GUI_EXPORT bool operator==(const QRhiVertexInputLayout &a, const QRhiVertexInputLayout &b) noexcept; -Q_GUI_EXPORT bool operator!=(const QRhiVertexInputLayout &a, const QRhiVertexInputLayout &b) noexcept; -Q_GUI_EXPORT size_t qHash(const QRhiVertexInputLayout &v, size_t seed = 0) noexcept; #ifndef QT_NO_DEBUG_STREAM Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiVertexInputLayout &); #endif @@ -288,13 +393,31 @@ private: Type m_type = Vertex; QShader m_shader; QShader::Variant m_shaderVariant = QShader::StandardShader; + + friend bool operator==(const QRhiShaderStage &a, const QRhiShaderStage &b) noexcept + { + return a.m_type == b.m_type + && a.m_shader == b.m_shader + && a.m_shaderVariant == b.m_shaderVariant; + } + + friend bool operator!=(const QRhiShaderStage &a, const QRhiShaderStage &b) noexcept + { + return !(a == b); + } + + friend size_t qHash(const QRhiShaderStage &v, size_t seed = 0) noexcept + { + QtPrivate::QHashCombine hash; + seed = hash(seed, v.m_type); + seed = hash(seed, v.m_shader); + seed = hash(seed, v.m_shaderVariant); + return seed; + } }; Q_DECLARE_TYPEINFO(QRhiShaderStage, Q_RELOCATABLE_TYPE); -Q_GUI_EXPORT bool operator==(const QRhiShaderStage &a, const QRhiShaderStage &b) noexcept; -Q_GUI_EXPORT bool operator!=(const QRhiShaderStage &a, const QRhiShaderStage &b) noexcept; -Q_GUI_EXPORT size_t qHash(const QRhiShaderStage &s, size_t seed = 0) noexcept; #ifndef QT_NO_DEBUG_STREAM Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiShaderStage &); #endif