firefox/D167159.diff

133 lines
4.6 KiB
Diff
Raw Normal View History

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<std::string> {
- 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<std::string> 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<std::string> 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; }