rhi: Add a feature flag for readback format support
Indicate that doing a QRhiResourceUpdateBatch::readBackTexture() for texture formats other than RGBA/BGRA is not necessarily supported at run time. Change-Id: Ie9ca9546a3af9bff142b875f1ecf26bf26bcc442 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>bb10
parent
a0bfa4e1f8
commit
6a8eb26bba
|
|
@ -596,6 +596,18 @@ Q_LOGGING_CATEGORY(QRHI_LOG_INFO, "qt.rhi.general")
|
|||
type attributes will be broken. In practice this feature will be unsupported
|
||||
with OpenGL ES 2.0 and OpenGL 2.x, while it will likely be supported
|
||||
everywhere else.
|
||||
|
||||
\value ScreenSpaceDerivatives Indicates that functions such as dFdx(),
|
||||
dFdy(), and fwidth() are supported in shaders.
|
||||
|
||||
\value ReadBackAnyTextureFormat Indicates that reading back texture
|
||||
contents can be expected to work for any QRhiTexture::Format. When reported
|
||||
as false, which will typically happen with OpenGL, only the formats
|
||||
QRhiTexture::RGBA8 and QRhiTexture::BGRA8 are guaranteed to be supported
|
||||
for readbacks. In addition, with OpenGL, but not OpenGL ES, reading back
|
||||
the 1 byte per component formats QRhiTexture::R8 and
|
||||
QRhiTexture::RED_OR_ALPHA8 are supported as well. Backends other than
|
||||
OpenGL can be expected to return true for this feature.
|
||||
*/
|
||||
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -1457,7 +1457,8 @@ public:
|
|||
TexelFetch,
|
||||
RenderToNonBaseMipLevel,
|
||||
UIntAttributes,
|
||||
ScreenSpaceDerivatives
|
||||
ScreenSpaceDerivatives,
|
||||
ReadBackAnyTextureFormat
|
||||
};
|
||||
|
||||
enum BeginFrameFlag {
|
||||
|
|
|
|||
|
|
@ -481,6 +481,8 @@ bool QRhiD3D11::isFeatureSupported(QRhi::Feature feature) const
|
|||
return true;
|
||||
case QRhi::ScreenSpaceDerivatives:
|
||||
return true;
|
||||
case QRhi::ReadBackAnyTextureFormat:
|
||||
return true;
|
||||
default:
|
||||
Q_UNREACHABLE();
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -875,6 +875,8 @@ bool QRhiGles2::isFeatureSupported(QRhi::Feature feature) const
|
|||
return caps.uintAttributes;
|
||||
case QRhi::ScreenSpaceDerivatives:
|
||||
return caps.screenSpaceDerivatives;
|
||||
case QRhi::ReadBackAnyTextureFormat:
|
||||
return false;
|
||||
default:
|
||||
Q_UNREACHABLE();
|
||||
return false;
|
||||
|
|
@ -2400,6 +2402,7 @@ void QRhiGles2::executeCommandBuffer(QRhiCommandBuffer *cb)
|
|||
const int h = result->pixelSize.height();
|
||||
if (mipLevel == 0 || caps.nonBaseLevelFramebufferTexture) {
|
||||
// With GLES, GL_RGBA is the only mandated readback format, so stick with it.
|
||||
// (and that's why we return false for the ReadBackAnyTextureFormat feature)
|
||||
if (result->format == QRhiTexture::R8 || result->format == QRhiTexture::RED_OR_ALPHA8) {
|
||||
result->data.resize(w * h);
|
||||
QByteArray tmpBuf;
|
||||
|
|
|
|||
|
|
@ -570,6 +570,8 @@ bool QRhiMetal::isFeatureSupported(QRhi::Feature feature) const
|
|||
return true;
|
||||
case QRhi::ScreenSpaceDerivatives:
|
||||
return true;
|
||||
case QRhi::ReadBackAnyTextureFormat:
|
||||
return true;
|
||||
default:
|
||||
Q_UNREACHABLE();
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -4052,6 +4052,8 @@ bool QRhiVulkan::isFeatureSupported(QRhi::Feature feature) const
|
|||
return true;
|
||||
case QRhi::ScreenSpaceDerivatives:
|
||||
return true;
|
||||
case QRhi::ReadBackAnyTextureFormat:
|
||||
return true;
|
||||
default:
|
||||
Q_UNREACHABLE();
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Reference in New Issue