From 60bfa9889d4fea112cfddb6854087f8095d4999c Mon Sep 17 00:00:00 2001 From: Martin Stransky Date: Wed, 2 Aug 2023 11:51:09 +0200 Subject: [PATCH] Added Canvas/WebGL VA-API playback patch (D167159 / mzbz#1769747) --- D167159.diff | 132 +++++++++++++++++++++++++++++++++++++++++++++++++++ firefox.spec | 7 ++- 2 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 D167159.diff diff --git a/D167159.diff b/D167159.diff new file mode 100644 index 0000000..a9261b0 --- /dev/null +++ b/D167159.diff @@ -0,0 +1,132 @@ +diff --git a/dom/canvas/ClientWebGLContext.cpp b/dom/canvas/ClientWebGLContext.cpp +--- a/dom/canvas/ClientWebGLContext.cpp ++++ b/dom/canvas/ClientWebGLContext.cpp +@@ -4253,11 +4253,12 @@ + const auto& sd = *(desc->sd); + const auto sdType = sd.type(); + const auto& contextInfo = mNotLost->info; + + const auto fallbackReason = [&]() -> Maybe { +- auto fallbackReason = BlitPreventReason(level, offset, pi, *desc); ++ auto fallbackReason = ++ BlitPreventReason(level, offset, pi, *desc, Limits()); + if (fallbackReason) return fallbackReason; + + const bool canUploadViaSd = contextInfo.uploadableSdTypes[sdType]; + if (!canUploadViaSd) { + const nsPrintfCString msg( +diff --git a/dom/canvas/TexUnpackBlob.h b/dom/canvas/TexUnpackBlob.h +--- a/dom/canvas/TexUnpackBlob.h ++++ b/dom/canvas/TexUnpackBlob.h +@@ -41,11 +41,12 @@ + struct PackingInfo; + struct DriverUnpackInfo; + + Maybe BlitPreventReason(int32_t level, const ivec3& offset, + const webgl::PackingInfo&, +- const TexUnpackBlobDesc&); ++ const TexUnpackBlobDesc&, ++ const Limits& limits); + + class TexUnpackBlob { + public: + const TexUnpackBlobDesc& mDesc; + bool mNeedsExactUpload = true; +diff --git a/dom/canvas/TexUnpackBlob.cpp b/dom/canvas/TexUnpackBlob.cpp +--- a/dom/canvas/TexUnpackBlob.cpp ++++ b/dom/canvas/TexUnpackBlob.cpp +@@ -658,11 +658,12 @@ + return ValidateUnpackPixels(webgl, pi, fullRows, *this); + } + + Maybe BlitPreventReason(const int32_t level, const ivec3& offset, + const webgl::PackingInfo& pi, +- const TexUnpackBlobDesc& desc) { ++ const TexUnpackBlobDesc& desc, ++ const Limits& limits) { + const auto& size = desc.size; + const auto& unpacking = desc.unpacking; + + const auto ret = [&]() -> const char* { + if (size.z != 1) { +@@ -689,12 +690,16 @@ + return "UNPACK_PREMULTIPLY_ALPHA_WEBGL is not false"; + } + }(); + if (premultReason) return premultReason; + +- if (pi.format != LOCAL_GL_RGBA) { +- return "`format` is not RGBA"; ++ if (pi.format != LOCAL_GL_RGBA && pi.format != LOCAL_GL_RGB) { ++ return "`format` is not RGBA or RGB"; ++ } ++ ++ if (pi.format == LOCAL_GL_RGB && !limits.rgbColorRenderable) { ++ return "`format` is RGB, which is not color-renderable"; + } + + if (pi.type != LOCAL_GL_UNSIGNED_BYTE) { + return "`type` is not UNSIGNED_BYTE"; + } +@@ -722,12 +727,12 @@ + + const auto& gl = webgl->GL(); + + // - + +- const auto reason = +- BlitPreventReason(level, {xOffset, yOffset, zOffset}, pi, mDesc); ++ const auto reason = BlitPreventReason(level, {xOffset, yOffset, zOffset}, pi, ++ mDesc, tex->mContext->Limits()); + if (reason) { + webgl->GeneratePerfWarning( + "Failed to hit GPU-copy fast-path." + " (%s) Falling back to CPU upload.", + reason->c_str()); +diff --git a/dom/canvas/WebGLContextValidate.cpp b/dom/canvas/WebGLContextValidate.cpp +--- a/dom/canvas/WebGLContextValidate.cpp ++++ b/dom/canvas/WebGLContextValidate.cpp +@@ -239,10 +239,12 @@ + [WebGLExtensionID::WEBGL_compressed_texture_astc]) { + limits.astcHdr = gl.IsExtensionSupported( + gl::GLContext::KHR_texture_compression_astc_hdr); + } + ++ limits.rgbColorRenderable = webgl.gl->IsRGBColorRenderable(); ++ + if (webgl.IsWebGL2() || + limits.supportedExtensions[WebGLExtensionID::WEBGL_draw_buffers]) { + gl.GetUIntegerv(LOCAL_GL_MAX_DRAW_BUFFERS, &limits.maxColorDrawBuffers); + } + +diff --git a/dom/canvas/WebGLTypes.h b/dom/canvas/WebGLTypes.h +--- a/dom/canvas/WebGLTypes.h ++++ b/dom/canvas/WebGLTypes.h +@@ -663,10 +663,11 @@ + uint32_t maxUniformBufferBindings = 0; + uint32_t uniformBufferOffsetAlignment = 0; + + // Exts + bool astcHdr = false; ++ bool rgbColorRenderable = false; + uint32_t maxColorDrawBuffers = 1; + uint64_t queryCounterBitsTimeElapsed = 0; + uint64_t queryCounterBitsTimestamp = 0; + uint32_t maxMultiviewLayers = 0; + }; +diff --git a/gfx/gl/GLContext.h b/gfx/gl/GLContext.h +--- a/gfx/gl/GLContext.h ++++ b/gfx/gl/GLContext.h +@@ -290,10 +290,11 @@ + mTopError = GetError(); + return IsContextLost(); + } + + bool HasPBOState() const { return (!IsGLES() || Version() >= 300); } ++ bool IsRGBColorRenderable() { return !IsGLES() || Version() >= 300; } + + /** + * If this context is double-buffered, returns TRUE. + */ + virtual bool IsDoubleBuffered() const { return false; } + diff --git a/firefox.spec b/firefox.spec index 23c048c..8859f21 100644 --- a/firefox.spec +++ b/firefox.spec @@ -160,7 +160,7 @@ ExcludeArch: i686 Summary: Mozilla Firefox Web browser Name: firefox Version: 116.0 -Release: 2%{?pre_tag}%{?dist} +Release: 3%{?pre_tag}%{?dist} URL: https://www.mozilla.org/firefox/ License: MPLv1.1 or GPLv2+ or LGPLv2+ Source0: https://archive.mozilla.org/pub/firefox/releases/%{version}%{?pre_version}/source/firefox-%{version}%{?pre_version}.source.tar.xz @@ -234,6 +234,7 @@ Patch230: firefox-enable-vaapi.patch # Upstream patches Patch402: mozilla-1196777.patch Patch407: mozilla-1667096.patch +Patch408: D167159.diff # PGO/LTO patches Patch600: pgo.patch @@ -507,6 +508,7 @@ This package contains results of tests executed during build. %patch402 -p1 -b .1196777 %patch407 -p1 -b .1667096 +%patch408 -p1 -b .D167159 # PGO patches %if %{build_with_pgo} @@ -1064,6 +1066,9 @@ fi #--------------------------------------------------------------------- %changelog +* Wed Aug 2 2023 Martin Stransky - 116.0-3 +- Added Canvas/WebGL VA-API playback patch (D167159 / mzbz#1769747) + * Mon Jul 31 2023 Martin Stransky - 116.0-2 - Updated to 116.0 Build 2