diff --git a/Telegram/SourceFiles/ui/effects/premium_3d_support.cpp b/Telegram/SourceFiles/ui/effects/premium_3d_support.cpp index 408ae9993d..46d21dd334 100644 --- a/Telegram/SourceFiles/ui/effects/premium_3d_support.cpp +++ b/Telegram/SourceFiles/ui/effects/premium_3d_support.cpp @@ -9,16 +9,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/gl/gl_detection.h" #include "ui/power_saving.h" -#include "base/debug_log.h" -#include "base/platform/base_platform_info.h" - -#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0) -#include -#if !defined(Q_OS_MAC) && !defined(Q_OS_WIN) -#include -#include -#endif // !Q_OS_MAC && !Q_OS_WIN -#endif // Qt >= 6.7 namespace Ui::Premium { namespace { @@ -26,55 +16,6 @@ namespace { constexpr auto kBezierIterations = 40; constexpr auto kBezierEpsilon = 0.00001; -#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0) -[[nodiscard]] bool ProbeGraphicsSupport() { - auto rhi = std::unique_ptr(); -#ifdef Q_OS_MAC - if (::Platform::MetalSupported()) { - auto params = QRhiMetalInitParams(); - rhi.reset(QRhi::create(QRhi::Metal, ¶ms)); - } - if (!rhi) { - LOG(("Premium3d: probe failed — no Metal RHI")); - return false; - } -#elif defined(Q_OS_WIN) - auto params = QRhiD3D11InitParams(); - rhi.reset(QRhi::create(QRhi::D3D11, ¶ms)); - if (!rhi) { - LOG(("Premium3d: probe failed — no D3D11 RHI")); - return false; - } -#else - auto format = QSurfaceFormat::defaultFormat(); - auto offscreen = std::unique_ptr( - QRhiGles2InitParams::newFallbackSurface(format)); - if (!offscreen) { - LOG(("Premium3d: probe failed — no offscreen surface")); - return false; - } - auto params = QRhiGles2InitParams(); - params.format = format; - params.fallbackSurface = offscreen.get(); - rhi.reset(QRhi::create(QRhi::OpenGLES2, ¶ms)); - if (!rhi) { - LOG(("Premium3d: probe failed — no GL RHI")); - return false; - } -#endif - LOG(("Premium3d: probe backend=%1 device=%2" - ).arg(rhi->backendName() - ).arg(rhi->driverInfo().deviceName)); - rhi.reset(); - return true; -} - -[[nodiscard]] bool RhiGraphicsSupportedCached() { - static const auto cached = ProbeGraphicsSupport(); - return cached; -} -#endif // Qt >= 6.7 - } // namespace float64 CubicBezier( @@ -118,7 +59,7 @@ bool Object3dSupported() { if (!GL::WidgetsRhiEnabled()) { return false; } - return RhiGraphicsSupportedCached(); + return GL::CheckRhiCapabilities().supported; #else return false; #endif diff --git a/Telegram/SourceFiles/ui/effects/thanos_effect.cpp b/Telegram/SourceFiles/ui/effects/thanos_effect.cpp index 021c6f778e..868fe02c9f 100644 --- a/Telegram/SourceFiles/ui/effects/thanos_effect.cpp +++ b/Telegram/SourceFiles/ui/effects/thanos_effect.cpp @@ -13,90 +13,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/power_saving.h" #include "ui/rp_widget.h" #include "ui/ui_utility.h" -#include "base/debug_log.h" -#include "base/platform/base_platform_info.h" #include "base/qt_signal_producer.h" #include -#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0) -#include -#if !defined(Q_OS_MAC) && !defined(Q_OS_WIN) -#include -#include -#endif -#endif - namespace Ui { -namespace { - -#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0) -[[nodiscard]] bool ProbeComputeSupport() { - // Create a throw-away QRhi with the same backend SurfaceRhi will use - // in production, ask whether GPU compute is available, then destroy. - // This is real hardware/driver capability detection — no OS version - // guards. On older Metal-capable Macs the answer is "no", which - // is exactly what makes the surface render uninitialized (Y-flipped) - // garbage and triggers the mirror bug elsewhere. - auto rhi = std::unique_ptr(); -#ifdef Q_OS_MAC - if (::Platform::MetalSupported()) { - auto params = QRhiMetalInitParams(); - rhi.reset(QRhi::create(QRhi::Metal, ¶ms)); - } - if (!rhi) { - LOG(("ThanosEffect: probe failed — no Metal RHI")); - return false; - } -#elif defined(Q_OS_WIN) - auto params = QRhiD3D11InitParams(); - rhi.reset(QRhi::create(QRhi::D3D11, ¶ms)); - if (!rhi) { - LOG(("ThanosEffect: probe failed — no D3D11 RHI")); - return false; - } -#else - // Linux/Unix: probe the OpenGL backend with an offscreen surface. - // Matches what SurfaceRhi uses in production so the result is - // representative of what the real widget would get. If anything - // here fails (no GL context, software fallback without compute, - // driver bug), treat compute as unsupported and refuse the effect - // rather than show an uninitialized swap-chain. - auto format = QSurfaceFormat::defaultFormat(); - // Compute shaders require OpenGL 4.3 core. - format.setVersion(4, 3); - format.setProfile(QSurfaceFormat::CoreProfile); - auto offscreen = std::unique_ptr( - QRhiGles2InitParams::newFallbackSurface(format)); - if (!offscreen) { - LOG(("ThanosEffect: probe failed — no offscreen surface")); - return false; - } - auto params = QRhiGles2InitParams(); - params.format = format; - params.fallbackSurface = offscreen.get(); - rhi.reset(QRhi::create(QRhi::OpenGLES2, ¶ms)); - if (!rhi) { - LOG(("ThanosEffect: probe failed — no GL RHI")); - return false; - } -#endif - const auto supported = rhi->isFeatureSupported(QRhi::Compute); - LOG(("ThanosEffect: probe backend=%1 device=%2 compute=%3" - ).arg(rhi->backendName() - ).arg(rhi->driverInfo().deviceName - ).arg(supported ? "yes" : "no")); - rhi.reset(); - return supported; -} - -[[nodiscard]] bool RhiComputeSupportedCached() { - static const auto cached = ProbeComputeSupport(); - return cached; -} -#endif // Qt >= 6.7 - -} // namespace bool ThanosEffect::Supported() { #if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0) @@ -107,7 +28,7 @@ bool ThanosEffect::Supported() { if (!GL::WidgetsRhiEnabled()) { return false; } - return RhiComputeSupportedCached(); + return GL::CheckRhiCapabilities().compute; #else return false; #endif @@ -122,7 +43,7 @@ void ThanosEffect::WarmUp() { if (!GL::WidgetsRhiEnabled()) { return; } - (void)RhiComputeSupportedCached(); + (void)GL::CheckRhiCapabilities(); #endif } diff --git a/Telegram/lib_ui b/Telegram/lib_ui index afdf8b06fe..e0e6e7d01c 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit afdf8b06fed48f54ee64f9e7b8dd97710c44a130 +Subproject commit e0e6e7d01c65cef834f61f96f8925591ae7f0b73