Title: [282627] trunk
Revision
282627
Author
[email protected]
Date
2021-09-16 18:59:06 -0700 (Thu, 16 Sep 2021)

Log Message

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:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (282626 => 282627)


--- trunk/LayoutTests/ChangeLog	2021-09-17 01:54:28 UTC (rev 282626)
+++ trunk/LayoutTests/ChangeLog	2021-09-17 01:59:06 UTC (rev 282627)
@@ -1,3 +1,13 @@
+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-09-16  Cameron McCormack  <[email protected]>
 
         Support drawImage with a wide gamut image painting into a display-p3 canvas

Modified: trunk/LayoutTests/TestExpectations (282626 => 282627)


--- trunk/LayoutTests/TestExpectations	2021-09-17 01:54:28 UTC (rev 282626)
+++ trunk/LayoutTests/TestExpectations	2021-09-17 01:59:06 UTC (rev 282627)
@@ -3697,6 +3697,9 @@
 webgl/2.0.y/conformance2/vertex_arrays/vertex-array-object.html [ Pass ]
 webgl/1.0.x/conformance/extensions/oes-vertex-array-object.html [ Pass ]
 
+# Explicitly turn on conformance test until all of webgl/2.0.y is enabled
+webgl/2.0.y/conformance/extensions/webgl-compressed-texture-s3tc-srgb.html [ Pass ]
+
 # WebGL 1.0.3 and 2.0.0 tests where behavior is obsolete and WebKit contains implementation
 # and tests for the new behavior. Should be removed once 1.0.3 and 2.0.0 are retired.
 fast/canvas/webgl/invalid-passed-params.html [ Skip ]

Modified: trunk/Source/ThirdParty/ANGLE/ChangeLog (282626 => 282627)


--- trunk/Source/ThirdParty/ANGLE/ChangeLog	2021-09-17 01:54:28 UTC (rev 282626)
+++ trunk/Source/ThirdParty/ANGLE/ChangeLog	2021-09-17 01:59:06 UTC (rev 282627)
@@ -1,3 +1,17 @@
+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-08-31  Kimmo Kinnunen  <[email protected]>
 
         webgl/1.0.x/conformance/glsl/misc/fragcolor-fragdata-invariant.html fails

Modified: trunk/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/mtl_utils.mm (282626 => 282627)


--- trunk/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/mtl_utils.mm	2021-09-17 01:54:28 UTC (rev 282626)
+++ trunk/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/mtl_utils.mm	2021-09-17 01:59:06 UTC (rev 282627)
@@ -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)
     {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to