Commit f8a1f630 authored by Laszlo Agocs's avatar Laszlo Agocs

Make QRhiShaderResourceBinding comparable

parent 0aa966d4
......@@ -1922,6 +1922,59 @@ QRhiShaderResourceBinding QRhiShaderResourceBinding::sampledTexture(
return b;
}
/*!
Returns \c true if all the bindings in the two QRhiShaderResourceBinding
objects \a a and \a b are equal.
\relates QRhiShaderResourceBinding
*/
bool operator==(const QRhiShaderResourceBinding &a, const QRhiShaderResourceBinding &b)
{
if (a.d == b.d)
return true;
if (a.d->binding != b.d->binding
|| a.d->stage != b.d->stage
|| a.d->type != b.d->type)
{
return false;
}
switch (a.d->type) {
case QRhiShaderResourceBinding::UniformBuffer:
if (a.d->u.ubuf.buf != b.d->u.ubuf.buf
|| a.d->u.ubuf.offset != b.d->u.ubuf.offset
|| a.d->u.ubuf.maybeSize != b.d->u.ubuf.maybeSize)
{
return false;
}
break;
case QRhiShaderResourceBinding::SampledTexture:
if (a.d->u.stex.tex != b.d->u.stex.tex
|| a.d->u.stex.sampler != b.d->u.stex.sampler)
{
return false;
}
break;
default:
Q_UNREACHABLE();
return false;
}
return true;
}
/*!
Returns \c false if all the bindings in the two QRhiShaderResourceBinding
objects \a a and \a b are equal; otherwise returns \c true.
\relates QRhiShaderResourceBinding
*/
bool operator!=(const QRhiShaderResourceBinding &a, const QRhiShaderResourceBinding &b)
{
return !(a == b);
}
/*!
\class QRhiGraphicsPipeline
\inmodule QtRhi
......
......@@ -277,10 +277,15 @@ public:
private:
QRhiShaderResourceBindingPrivate *d;
friend class QRhiShaderResourceBindingPrivate;
friend Q_RHI_EXPORT bool operator==(const QRhiShaderResourceBinding &, const QRhiShaderResourceBinding &);
friend Q_RHI_EXPORT bool operator!=(const QRhiShaderResourceBinding &, const QRhiShaderResourceBinding &);
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiShaderResourceBinding::StageFlags)
Q_RHI_EXPORT bool operator==(const QRhiShaderResourceBinding &a, const QRhiShaderResourceBinding &b);
Q_RHI_EXPORT bool operator!=(const QRhiShaderResourceBinding &a, const QRhiShaderResourceBinding &b);
class Q_RHI_EXPORT QRhiColorAttachment
{
public:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment