rhi: Code quality - remove defaults from switch enums
On code review of previous RHI patches it was noted that many switch on enum statements contain a default. This is discouraged as it prevents the compiler from automatically identifying switch statements that do not cover all enum cases. This patch addresses rhi base classes. Further patches required for specific backend implementations. Change-Id: Ib2bb30c66fd214b65a4ca7b787c7c610f3c313f5 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
parent
035babe502
commit
5962605abb
@ -3907,9 +3907,7 @@ bool operator==(const QRhiShaderResourceBinding &a, const QRhiShaderResourceBind
|
|||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
case QRhiShaderResourceBinding::ImageLoad:
|
case QRhiShaderResourceBinding::ImageLoad:
|
||||||
Q_FALLTHROUGH();
|
|
||||||
case QRhiShaderResourceBinding::ImageStore:
|
case QRhiShaderResourceBinding::ImageStore:
|
||||||
Q_FALLTHROUGH();
|
|
||||||
case QRhiShaderResourceBinding::ImageLoadStore:
|
case QRhiShaderResourceBinding::ImageLoadStore:
|
||||||
if (da->u.simage.tex != db->u.simage.tex
|
if (da->u.simage.tex != db->u.simage.tex
|
||||||
|| da->u.simage.level != db->u.simage.level)
|
|| da->u.simage.level != db->u.simage.level)
|
||||||
@ -3918,9 +3916,7 @@ bool operator==(const QRhiShaderResourceBinding &a, const QRhiShaderResourceBind
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case QRhiShaderResourceBinding::BufferLoad:
|
case QRhiShaderResourceBinding::BufferLoad:
|
||||||
Q_FALLTHROUGH();
|
|
||||||
case QRhiShaderResourceBinding::BufferStore:
|
case QRhiShaderResourceBinding::BufferStore:
|
||||||
Q_FALLTHROUGH();
|
|
||||||
case QRhiShaderResourceBinding::BufferLoadStore:
|
case QRhiShaderResourceBinding::BufferLoadStore:
|
||||||
if (da->u.sbuf.buf != db->u.sbuf.buf
|
if (da->u.sbuf.buf != db->u.sbuf.buf
|
||||||
|| da->u.sbuf.offset != db->u.sbuf.offset
|
|| da->u.sbuf.offset != db->u.sbuf.offset
|
||||||
@ -3972,21 +3968,15 @@ size_t qHash(const QRhiShaderResourceBinding &b, size_t seed) noexcept
|
|||||||
h ^= qHash(reinterpret_cast<quintptr>(d->u.stex.texSamplers[0].sampler));
|
h ^= qHash(reinterpret_cast<quintptr>(d->u.stex.texSamplers[0].sampler));
|
||||||
break;
|
break;
|
||||||
case QRhiShaderResourceBinding::ImageLoad:
|
case QRhiShaderResourceBinding::ImageLoad:
|
||||||
Q_FALLTHROUGH();
|
|
||||||
case QRhiShaderResourceBinding::ImageStore:
|
case QRhiShaderResourceBinding::ImageStore:
|
||||||
Q_FALLTHROUGH();
|
|
||||||
case QRhiShaderResourceBinding::ImageLoadStore:
|
case QRhiShaderResourceBinding::ImageLoadStore:
|
||||||
h ^= qHash(reinterpret_cast<quintptr>(d->u.simage.tex));
|
h ^= qHash(reinterpret_cast<quintptr>(d->u.simage.tex));
|
||||||
break;
|
break;
|
||||||
case QRhiShaderResourceBinding::BufferLoad:
|
case QRhiShaderResourceBinding::BufferLoad:
|
||||||
Q_FALLTHROUGH();
|
|
||||||
case QRhiShaderResourceBinding::BufferStore:
|
case QRhiShaderResourceBinding::BufferStore:
|
||||||
Q_FALLTHROUGH();
|
|
||||||
case QRhiShaderResourceBinding::BufferLoadStore:
|
case QRhiShaderResourceBinding::BufferLoadStore:
|
||||||
h ^= qHash(reinterpret_cast<quintptr>(d->u.sbuf.buf));
|
h ^= qHash(reinterpret_cast<quintptr>(d->u.sbuf.buf));
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
@ -4769,8 +4759,6 @@ QDebug operator<<(QDebug dbg, const QRhiSwapChainHdrInfo &info)
|
|||||||
case QRhiSwapChainHdrInfo::ColorComponentValue:
|
case QRhiSwapChainHdrInfo::ColorComponentValue:
|
||||||
dbg.nospace() << " maxColorComponentValue=" << info.limits.colorComponentValue.maxColorComponentValue;
|
dbg.nospace() << " maxColorComponentValue=" << info.limits.colorComponentValue.maxColorComponentValue;
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
dbg.nospace() << ')';
|
dbg.nospace() << ')';
|
||||||
return dbg;
|
return dbg;
|
||||||
@ -4913,10 +4901,9 @@ static const char *resourceTypeStr(QRhiResource *res)
|
|||||||
return "ComputePipeline";
|
return "ComputePipeline";
|
||||||
case QRhiResource::CommandBuffer:
|
case QRhiResource::CommandBuffer:
|
||||||
return "CommandBuffer";
|
return "CommandBuffer";
|
||||||
default:
|
|
||||||
Q_UNREACHABLE();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Q_UNREACHABLE();
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5233,9 +5220,7 @@ bool QRhiImplementation::sanityCheckShaderResourceBindings(QRhiShaderResourceBin
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case QRhiShaderResourceBinding::ImageLoad:
|
case QRhiShaderResourceBinding::ImageLoad:
|
||||||
Q_FALLTHROUGH();
|
|
||||||
case QRhiShaderResourceBinding::ImageStore:
|
case QRhiShaderResourceBinding::ImageStore:
|
||||||
Q_FALLTHROUGH();
|
|
||||||
case QRhiShaderResourceBinding::ImageLoadStore:
|
case QRhiShaderResourceBinding::ImageLoadStore:
|
||||||
if (!bindingSeen[binding]) {
|
if (!bindingSeen[binding]) {
|
||||||
bindingSeen[binding] = true;
|
bindingSeen[binding] = true;
|
||||||
@ -5245,9 +5230,7 @@ bool QRhiImplementation::sanityCheckShaderResourceBindings(QRhiShaderResourceBin
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case QRhiShaderResourceBinding::BufferLoad:
|
case QRhiShaderResourceBinding::BufferLoad:
|
||||||
Q_FALLTHROUGH();
|
|
||||||
case QRhiShaderResourceBinding::BufferStore:
|
case QRhiShaderResourceBinding::BufferStore:
|
||||||
Q_FALLTHROUGH();
|
|
||||||
case QRhiShaderResourceBinding::BufferLoadStore:
|
case QRhiShaderResourceBinding::BufferLoadStore:
|
||||||
if (!bindingSeen[binding]) {
|
if (!bindingSeen[binding]) {
|
||||||
bindingSeen[binding] = true;
|
bindingSeen[binding] = true;
|
||||||
@ -5351,8 +5334,6 @@ QRhi *QRhi::create(Implementation impl, QRhiInitParams *params, Flags flags, QRh
|
|||||||
qWarning("This platform has no Metal support");
|
qWarning("This platform has no Metal support");
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r->d) {
|
if (r->d) {
|
||||||
@ -5400,9 +5381,10 @@ const char *QRhi::backendName() const
|
|||||||
return "D3D11";
|
return "D3D11";
|
||||||
case QRhi::Metal:
|
case QRhi::Metal:
|
||||||
return "Metal";
|
return "Metal";
|
||||||
default:
|
|
||||||
return "Unknown";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Q_UNREACHABLE();
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -5453,9 +5435,10 @@ static inline const char *deviceTypeStr(QRhiDriverInfo::DeviceType type)
|
|||||||
return "Virtual";
|
return "Virtual";
|
||||||
case QRhiDriverInfo::CpuDevice:
|
case QRhiDriverInfo::CpuDevice:
|
||||||
return "Cpu";
|
return "Cpu";
|
||||||
default:
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Q_UNREACHABLE();
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
QDebug operator<<(QDebug dbg, const QRhiDriverInfo &info)
|
QDebug operator<<(QDebug dbg, const QRhiDriverInfo &info)
|
||||||
{
|
{
|
||||||
|
@ -169,10 +169,10 @@ int QRhiNull::resourceLimit(QRhi::ResourceLimit limit) const
|
|||||||
return 32;
|
return 32;
|
||||||
case QRhi::MaxVertexOutputs:
|
case QRhi::MaxVertexOutputs:
|
||||||
return 32;
|
return 32;
|
||||||
default:
|
|
||||||
Q_UNREACHABLE();
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Q_UNREACHABLE();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QRhiNativeHandles *QRhiNull::nativeHandles()
|
const QRhiNativeHandles *QRhiNull::nativeHandles()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user