Rhi: Add SampleVariables feature

The feature is required to check if gl_sampleID etc are available in the
fragment shaders.

Task-number: QTBUG-134999
Change-Id: Id26c75780011a7553d332ae22e69aab632891998
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
(cherry picked from commit 86e3573671ec3ea919e534957bf9dc320f853575)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Antti Määttä 2025-03-25 12:23:46 +02:00 committed by Qt Cherry-pick Bot
parent cbc2f2a6ee
commit f39b02ed4b
8 changed files with 24 additions and 0 deletions

View File

@ -1091,6 +1091,12 @@ Q_LOGGING_CATEGORY(QRHI_LOG_RUB, "qt.rhi.rub")
blending modes. In practice this can be expected to be supported everywhere blending modes. In practice this can be expected to be supported everywhere
except OpenGL ES, where it is only available with GLES 3.2 implementations. except OpenGL ES, where it is only available with GLES 3.2 implementations.
This enum value has been introduced in Qt 6.9. This enum value has been introduced in Qt 6.9.
\value SampleVariables Indicates that gl_SampleID, gl_SamplePosition,
gl_SampleMaskIn and gl_SampleMask variables are available in fragment shaders.
In practice this can be expected to be supported everywhere except OpenGL ES,
where it is only available with GLES 3.2 implementations.
This enum value has been introduced in Qt 6.9.
*/ */
/*! /*!

View File

@ -1912,6 +1912,7 @@ public:
VariableRateShadingMap, VariableRateShadingMap,
VariableRateShadingMapWithTexture, VariableRateShadingMapWithTexture,
PerRenderTargetBlending, PerRenderTargetBlending,
SampleVariables
}; };
enum BeginFrameFlag { enum BeginFrameFlag {

View File

@ -657,6 +657,7 @@ bool QRhiD3D11::isFeatureSupported(QRhi::Feature feature) const
case QRhi::VariableRateShadingMapWithTexture: case QRhi::VariableRateShadingMapWithTexture:
return false; return false;
case QRhi::PerRenderTargetBlending: case QRhi::PerRenderTargetBlending:
case QRhi::SampleVariables:
return true; return true;
default: default:
Q_UNREACHABLE(); Q_UNREACHABLE();

View File

@ -808,6 +808,7 @@ bool QRhiD3D12::isFeatureSupported(QRhi::Feature feature) const
case QRhi::VariableRateShadingMapWithTexture: case QRhi::VariableRateShadingMapWithTexture:
return caps.vrsMap; return caps.vrsMap;
case QRhi::PerRenderTargetBlending: case QRhi::PerRenderTargetBlending:
case QRhi::SampleVariables:
return true; return true;
} }
return false; return false;

View File

@ -1141,6 +1141,16 @@ bool QRhiGles2::create(QRhi::Flags flags)
else else
caps.perRenderTargetBlending = caps.ctxMajor >= 4; caps.perRenderTargetBlending = caps.ctxMajor >= 4;
if (caps.gles) {
if (caps.ctxMajor == 3 && caps.ctxMinor < 2) {
caps.sampleVariables = ctx->hasExtension("GL_OES_sample_variables");
} else {
caps.sampleVariables = caps.ctxMajor > 3 || (caps.ctxMajor == 3 && caps.ctxMinor >= 2);
}
} else {
caps.sampleVariables = caps.ctxMajor >= 4;
}
nativeHandlesStruct.context = ctx; nativeHandlesStruct.context = ctx;
contextLost = false; contextLost = false;
@ -1555,6 +1565,8 @@ bool QRhiGles2::isFeatureSupported(QRhi::Feature feature) const
return false; return false;
case QRhi::PerRenderTargetBlending: case QRhi::PerRenderTargetBlending:
return caps.perRenderTargetBlending; return caps.perRenderTargetBlending;
case QRhi::SampleVariables:
return caps.sampleVariables;
default: default:
Q_UNREACHABLE_RETURN(false); Q_UNREACHABLE_RETURN(false);
} }

View File

@ -1090,6 +1090,7 @@ public:
uint glesMultiviewMultisampleRenderToTexture : 1; uint glesMultiviewMultisampleRenderToTexture : 1;
uint unpackRowLength : 1; uint unpackRowLength : 1;
uint perRenderTargetBlending : 1; uint perRenderTargetBlending : 1;
uint sampleVariables : 1;
} caps; } caps;
QGles2SwapChain *currentSwapChain = nullptr; QGles2SwapChain *currentSwapChain = nullptr;
QSet<GLint> supportedCompressedFormats; QSet<GLint> supportedCompressedFormats;

View File

@ -868,6 +868,7 @@ bool QRhiMetal::isFeatureSupported(QRhi::Feature feature) const
case QRhi::VariableRateShadingMapWithTexture: case QRhi::VariableRateShadingMapWithTexture:
return false; return false;
case QRhi::PerRenderTargetBlending: case QRhi::PerRenderTargetBlending:
case QRhi::SampleVariables:
return true; return true;
default: default:
Q_UNREACHABLE(); Q_UNREACHABLE();

View File

@ -5252,6 +5252,7 @@ bool QRhiVulkan::isFeatureSupported(QRhi::Feature feature) const
case QRhi::VariableRateShadingMapWithTexture: case QRhi::VariableRateShadingMapWithTexture:
return caps.renderPass2KHR && caps.imageBasedShadingRate; return caps.renderPass2KHR && caps.imageBasedShadingRate;
case QRhi::PerRenderTargetBlending: case QRhi::PerRenderTargetBlending:
case QRhi::SampleVariables:
return true; return true;
default: default:
Q_UNREACHABLE_RETURN(false); Q_UNREACHABLE_RETURN(false);