Modified: branches/safari-612-branch/LayoutTests/ChangeLog (284825 => 284826)
--- branches/safari-612-branch/LayoutTests/ChangeLog 2021-10-25 21:50:39 UTC (rev 284825)
+++ branches/safari-612-branch/LayoutTests/ChangeLog 2021-10-25 21:50:43 UTC (rev 284826)
@@ -1,5 +1,40 @@
2021-10-25 Null <[email protected]>
+ Cherry-pick r282627. rdar://problem/84630078
+
+ webgl/2.0.y/conformance/extensions/webgl-compressed-texture-s3tc-srgb.html fails on Intel+AMD Metal
+ https://bugs.webkit.org/show_bug.cgi?id=229941
+
+ Zero-initialize compressed textures explicitly, as they aren't implicitly initalized in Metal.
+ Reviewed by Kenneth Russell <[email protected]>.
+
+ Source/ThirdParty/ANGLE:
+
+ * src/libANGLE/renderer/metal/mtl_utils.h:
+ * src/libANGLE/renderer/metal/mtl_utils.mm:
+ (rx::mtl::GetCompressedBufferForTextureWithFormat):
+ (rx::mtl::InitializeCompressedTextureContents):
+ (rx::mtl::InitializeTextureContents):
+
+ LayoutTests:
+
+ * TestExpectations:
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@282627 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2021-09-16 Kyle Piddington <[email protected]>
+
+ webgl/2.0.y/conformance/extensions/webgl-compressed-texture-s3tc-srgb.html fails on Intel+AMD Metal
+ https://bugs.webkit.org/show_bug.cgi?id=229941
+
+ Zero-initialize compressed textures explicitly, as they aren't implicitly initalized in Metal.
+ Reviewed by Kenneth Russell <[email protected]>.
+
+ * TestExpectations:
+
+2021-10-25 Null <[email protected]>
+
Cherry-pick r281547. rdar://problem/84629691
ANGLE Metal infinities and NaNs generated with incorrect syntax
Modified: branches/safari-612-branch/Source/ThirdParty/ANGLE/ChangeLog (284825 => 284826)
--- branches/safari-612-branch/Source/ThirdParty/ANGLE/ChangeLog 2021-10-25 21:50:39 UTC (rev 284825)
+++ branches/safari-612-branch/Source/ThirdParty/ANGLE/ChangeLog 2021-10-25 21:50:43 UTC (rev 284826)
@@ -1,5 +1,44 @@
2021-10-25 Null <[email protected]>
+ Cherry-pick r282627. rdar://problem/84630078
+
+ webgl/2.0.y/conformance/extensions/webgl-compressed-texture-s3tc-srgb.html fails on Intel+AMD Metal
+ https://bugs.webkit.org/show_bug.cgi?id=229941
+
+ Zero-initialize compressed textures explicitly, as they aren't implicitly initalized in Metal.
+ Reviewed by Kenneth Russell <[email protected]>.
+
+ Source/ThirdParty/ANGLE:
+
+ * src/libANGLE/renderer/metal/mtl_utils.h:
+ * src/libANGLE/renderer/metal/mtl_utils.mm:
+ (rx::mtl::GetCompressedBufferForTextureWithFormat):
+ (rx::mtl::InitializeCompressedTextureContents):
+ (rx::mtl::InitializeTextureContents):
+
+ LayoutTests:
+
+ * TestExpectations:
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@282627 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2021-09-16 Kyle Piddington <[email protected]>
+
+ webgl/2.0.y/conformance/extensions/webgl-compressed-texture-s3tc-srgb.html fails on Intel+AMD Metal
+ https://bugs.webkit.org/show_bug.cgi?id=229941
+
+ Zero-initialize compressed textures explicitly, as they aren't implicitly initalized in Metal.
+ Reviewed by Kenneth Russell <[email protected]>.
+
+ * src/libANGLE/renderer/metal/mtl_utils.h:
+ * src/libANGLE/renderer/metal/mtl_utils.mm:
+ (rx::mtl::GetCompressedBufferForTextureWithFormat):
+ (rx::mtl::InitializeCompressedTextureContents):
+ (rx::mtl::InitializeTextureContents):
+
+2021-10-25 Null <[email protected]>
+
Cherry-pick r281547. rdar://problem/84629691
ANGLE Metal infinities and NaNs generated with incorrect syntax
Modified: branches/safari-612-branch/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/mtl_utils.mm (284825 => 284826)
--- branches/safari-612-branch/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/mtl_utils.mm 2021-10-25 21:50:39 UTC (rev 284825)
+++ branches/safari-612-branch/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/mtl_utils.mm 2021-10-25 21:50:43 UTC (rev 284826)
@@ -103,6 +103,82 @@
}
+bool GetCompressedBufferSizeAndRowLengthForTextureWithFormat(const TextureRef &texture,
+ const Format &textureObjFormat,
+ const ImageNativeIndex &index,
+ size_t *bytesPerRowOut,
+ size_t *bytesPerImageOut)
+{
+ gl::Extents size = texture->size(index);
+ GLuint bufferSizeInBytes;
+ uint32_t bufferRowLength;
+ if (!textureObjFormat.intendedInternalFormat().computeCompressedImageSize(size,
+ &bufferSizeInBytes))
+ {
+ return false;
+ }
+ if (!textureObjFormat.intendedInternalFormat().computeBufferRowLength(size.width,
+ &bufferRowLength))
+ {
+ return false;
+ }
+ *bytesPerImageOut = bufferSizeInBytes;
+ *bytesPerRowOut = bufferRowLength;
+ return true;
+}
+
+static angle::Result InitializeCompressedTextureContents(const gl::Context *context,
+ const TextureRef &texture,
+ const Format &textureObjFormat,
+ const ImageNativeIndex &index,
+ const uint layer,
+ const uint startDepth)
+{
+ assert(textureObjFormat.actualAngleFormat().isBlock);
+ size_t bytesPerRow = 0;
+ size_t bytesPerImage = 0;
+
+ if (!GetCompressedBufferSizeAndRowLengthForTextureWithFormat(texture, textureObjFormat, index,
+ &bytesPerRow, &bytesPerImage))
+ {
+ return angle::Result::Stop;
+ }
+ ContextMtl *contextMtl = mtl::GetImpl(context);
+ gl::Extents extents = texture->size(index);
+ if (texture->isCPUAccessible())
+ {
+ angle::MemoryBuffer buffer;
+ if (!buffer.resize(bytesPerImage))
+ {
+ return angle::Result::Stop;
+ }
+ buffer.fill(0);
+ for (NSUInteger d = 0; d < static_cast<NSUInteger>(extents.depth); ++d)
+ {
+ auto mtlTextureRegion = MTLRegionMake2D(0, 0, extents.width, extents.height);
+ mtlTextureRegion.origin.z = d + startDepth;
+ texture->replaceRegion(contextMtl, mtlTextureRegion, index.getNativeLevel(), layer,
+ buffer.data(), bytesPerRow, 0);
+ }
+ }
+ else
+ {
+ mtl::BufferRef zeroBuffer;
+ ANGLE_TRY(mtl::Buffer::MakeBuffer(contextMtl, bytesPerImage, nullptr, &zeroBuffer));
+ mtl::BlitCommandEncoder *blitEncoder = contextMtl->getBlitCommandEncoder();
+ for (NSUInteger d = 0; d < static_cast<NSUInteger>(extents.depth); ++d)
+ {
+ auto blitOrigin = MTLOriginMake(0, 0, d + startDepth);
+ blitEncoder->copyBufferToTexture(zeroBuffer, 0, bytesPerRow, 0,
+ MTLSizeMake(extents.width, extents.height, 1), texture,
+ layer, index.getNativeLevel(), blitOrigin, 0);
+ }
+
+ blitEncoder->endEncoding();
+ }
+ return angle::Result::Continue;
+}
+
angle::Result InitializeTextureContents(const gl::Context *context,
const TextureRef &texture,
const Format &textureObjFormat,
@@ -118,13 +194,15 @@
#if TARGET_OS_SIMULATOR
forceGPUInitialization = true;
#endif // TARGET_OS_SIMULATOR
-
+
// This function is called in many places to initialize the content of a texture.
// So it's better we do the sanity check here instead of let the callers do it themselves:
- if (!textureObjFormat.valid() || actualAngleFormat.isBlock || actualAngleFormat.depthBits > 0 ||
+ // TODO: (kpiddington) update InitializeTextureContents with an upstreamed version that handles
+ // depth/stencil textures.
+ if (!textureObjFormat.valid() || actualAngleFormat.depthBits > 0 ||
actualAngleFormat.stencilBits > 0)
{
- // If dst format is compressed, ignore.
+ // Depth or stencil textures need an updated path.
return angle::Result::Continue;
}
@@ -152,6 +230,12 @@
}
}
+ if (actualAngleFormat.isBlock)
+ {
+ return InitializeCompressedTextureContents(context, texture, textureObjFormat, index, layer,
+ startDepth);
+ }
+
if (texture->isCPUAccessible() && index.getType() != gl::TextureType::_2DMultisample &&
index.getType() != gl::TextureType::_2DMultisampleArray && !forceGPUInitialization)
{