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 <laszlo.agocs@qt.io>
This commit is contained in:
Antti Määttä 2025-03-25 12:23:46 +02:00
parent 7929852c1d
commit 86e3573671
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

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

View File

@ -705,6 +705,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

@ -857,6 +857,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

@ -1169,6 +1169,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;
@ -1611,6 +1621,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

@ -1092,6 +1092,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

@ -5327,6 +5327,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);