diff options
author | Antti Määttä <[email protected]> | 2025-03-25 12:23:46 +0200 |
---|---|---|
committer | Antti Määttä <[email protected]> | 2025-03-26 15:33:39 +0200 |
commit | 86e3573671ec3ea919e534957bf9dc320f853575 (patch) | |
tree | d5a11f7347cc2160f89ceca099770362593d700d | |
parent | 7929852c1d39e12b7c586b5c6d257c9df27c01df (diff) |
Rhi: Add SampleVariables feature
The feature is required to check if gl_sampleID etc are available in the
fragment shaders.
Task-number: QTBUG-134999
Pick-to: 6.9
Change-Id: Id26c75780011a7553d332ae22e69aab632891998
Reviewed-by: Laszlo Agocs <[email protected]>
-rw-r--r-- | src/gui/rhi/qrhi.cpp | 6 | ||||
-rw-r--r-- | src/gui/rhi/qrhi.h | 1 | ||||
-rw-r--r-- | src/gui/rhi/qrhid3d11.cpp | 1 | ||||
-rw-r--r-- | src/gui/rhi/qrhid3d12.cpp | 1 | ||||
-rw-r--r-- | src/gui/rhi/qrhigles2.cpp | 12 | ||||
-rw-r--r-- | src/gui/rhi/qrhigles2_p.h | 1 | ||||
-rw-r--r-- | src/gui/rhi/qrhimetal.mm | 1 | ||||
-rw-r--r-- | src/gui/rhi/qrhivulkan.cpp | 1 |
8 files changed, 24 insertions, 0 deletions
diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp index 82cef0affef..192128b5ee8 100644 --- a/src/gui/rhi/qrhi.cpp +++ b/src/gui/rhi/qrhi.cpp @@ -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 except OpenGL ES, where it is only available with GLES 3.2 implementations. 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. */ /*! diff --git a/src/gui/rhi/qrhi.h b/src/gui/rhi/qrhi.h index 5593b328535..576defe469f 100644 --- a/src/gui/rhi/qrhi.h +++ b/src/gui/rhi/qrhi.h @@ -1931,6 +1931,7 @@ public: VariableRateShadingMap, VariableRateShadingMapWithTexture, PerRenderTargetBlending, + SampleVariables }; enum BeginFrameFlag { diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index aba35055ce8..da27500995b 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -705,6 +705,7 @@ bool QRhiD3D11::isFeatureSupported(QRhi::Feature feature) const case QRhi::VariableRateShadingMapWithTexture: return false; case QRhi::PerRenderTargetBlending: + case QRhi::SampleVariables: return true; default: Q_UNREACHABLE(); diff --git a/src/gui/rhi/qrhid3d12.cpp b/src/gui/rhi/qrhid3d12.cpp index f9ce88c63b8..d605693bad8 100644 --- a/src/gui/rhi/qrhid3d12.cpp +++ b/src/gui/rhi/qrhid3d12.cpp @@ -857,6 +857,7 @@ bool QRhiD3D12::isFeatureSupported(QRhi::Feature feature) const case QRhi::VariableRateShadingMapWithTexture: return caps.vrsMap; case QRhi::PerRenderTargetBlending: + case QRhi::SampleVariables: return true; } return false; diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index 8585556d4f5..8d2002f68a0 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -1169,6 +1169,16 @@ bool QRhiGles2::create(QRhi::Flags flags) else 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; contextLost = false; @@ -1611,6 +1621,8 @@ bool QRhiGles2::isFeatureSupported(QRhi::Feature feature) const return false; case QRhi::PerRenderTargetBlending: return caps.perRenderTargetBlending; + case QRhi::SampleVariables: + return caps.sampleVariables; default: Q_UNREACHABLE_RETURN(false); } diff --git a/src/gui/rhi/qrhigles2_p.h b/src/gui/rhi/qrhigles2_p.h index ee01f3a6681..7908c3e222c 100644 --- a/src/gui/rhi/qrhigles2_p.h +++ b/src/gui/rhi/qrhigles2_p.h @@ -1092,6 +1092,7 @@ public: uint glesMultiviewMultisampleRenderToTexture : 1; uint unpackRowLength : 1; uint perRenderTargetBlending : 1; + uint sampleVariables : 1; } caps; QGles2SwapChain *currentSwapChain = nullptr; QSet<GLint> supportedCompressedFormats; diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index 3059c0a8008..4375f123e93 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -868,6 +868,7 @@ bool QRhiMetal::isFeatureSupported(QRhi::Feature feature) const case QRhi::VariableRateShadingMapWithTexture: return false; case QRhi::PerRenderTargetBlending: + case QRhi::SampleVariables: return true; default: Q_UNREACHABLE(); diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index a1e78680323..f94f27a79e1 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -5327,6 +5327,7 @@ bool QRhiVulkan::isFeatureSupported(QRhi::Feature feature) const case QRhi::VariableRateShadingMapWithTexture: return caps.renderPass2KHR && caps.imageBasedShadingRate; case QRhi::PerRenderTargetBlending: + case QRhi::SampleVariables: return true; default: Q_UNREACHABLE_RETURN(false); |