⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 282627 in webkit


Ignore:
Timestamp:
Sep 16, 2021, 6:59:06 PM (5 years ago)
Author:
Kyle Piddington
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 <kbr@chromium.org>.

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:

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r282626 r282627  
     12021-09-16  Kyle Piddington  <kpiddington@apple.com>
     2
     3        webgl/2.0.y/conformance/extensions/webgl-compressed-texture-s3tc-srgb.html fails on Intel+AMD Metal
     4        https://bugs.webkit.org/show_bug.cgi?id=229941
     5
     6        Zero-initialize compressed textures explicitly, as they aren't implicitly initalized in Metal.
     7        Reviewed by Kenneth Russell <kbr@chromium.org>.
     8
     9        * TestExpectations:
     10
    1112021-09-16  Cameron McCormack  <heycam@apple.com>
    212
  • trunk/LayoutTests/TestExpectations

    r282626 r282627  
    36973697webgl/2.0.y/conformance2/vertex_arrays/vertex-array-object.html [ Pass ]
    36983698webgl/1.0.x/conformance/extensions/oes-vertex-array-object.html [ Pass ]
     3699
     3700# Explicitly turn on conformance test until all of webgl/2.0.y is enabled
     3701webgl/2.0.y/conformance/extensions/webgl-compressed-texture-s3tc-srgb.html [ Pass ]
    36993702
    37003703# WebGL 1.0.3 and 2.0.0 tests where behavior is obsolete and WebKit contains implementation
  • trunk/Source/ThirdParty/ANGLE/ChangeLog

    r281794 r282627  
     12021-09-16  Kyle Piddington  <kpiddington@apple.com>
     2
     3        webgl/2.0.y/conformance/extensions/webgl-compressed-texture-s3tc-srgb.html fails on Intel+AMD Metal
     4        https://bugs.webkit.org/show_bug.cgi?id=229941
     5
     6        Zero-initialize compressed textures explicitly, as they aren't implicitly initalized in Metal.
     7        Reviewed by Kenneth Russell <kbr@chromium.org>.
     8
     9        * src/libANGLE/renderer/metal/mtl_utils.h:
     10        * src/libANGLE/renderer/metal/mtl_utils.mm:
     11        (rx::mtl::GetCompressedBufferForTextureWithFormat):
     12        (rx::mtl::InitializeCompressedTextureContents):
     13        (rx::mtl::InitializeTextureContents):
     14
    1152021-08-31  Kimmo Kinnunen  <kkinnunen@apple.com>
    216
  • trunk/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/mtl_utils.mm

    r279606 r282627  
    104104}
    105105
     106bool GetCompressedBufferSizeAndRowLengthForTextureWithFormat(const TextureRef &texture,
     107                                                             const Format &textureObjFormat,
     108                                                             const ImageNativeIndex &index,
     109                                                             size_t *bytesPerRowOut,
     110                                                             size_t *bytesPerImageOut)
     111{
     112    gl::Extents size = texture->size(index);
     113    GLuint bufferSizeInBytes;
     114    uint32_t bufferRowLength;
     115    if (!textureObjFormat.intendedInternalFormat().computeCompressedImageSize(size,
     116                                                                              &bufferSizeInBytes))
     117    {
     118        return false;
     119    }
     120    if (!textureObjFormat.intendedInternalFormat().computeBufferRowLength(size.width,
     121                                                                          &bufferRowLength))
     122    {
     123        return false;
     124    }
     125    *bytesPerImageOut = bufferSizeInBytes;
     126    *bytesPerRowOut   = bufferRowLength;
     127    return true;
     128}
     129
     130static angle::Result InitializeCompressedTextureContents(const gl::Context *context,
     131                                                         const TextureRef &texture,
     132                                                         const Format &textureObjFormat,
     133                                                         const ImageNativeIndex &index,
     134                                                         const uint layer,
     135                                                         const uint startDepth)
     136{
     137    assert(textureObjFormat.actualAngleFormat().isBlock);
     138    size_t bytesPerRow   = 0;
     139    size_t bytesPerImage = 0;
     140
     141    if (!GetCompressedBufferSizeAndRowLengthForTextureWithFormat(texture, textureObjFormat, index,
     142                                                                 &bytesPerRow, &bytesPerImage))
     143    {
     144        return angle::Result::Stop;
     145    }
     146    ContextMtl *contextMtl = mtl::GetImpl(context);
     147    gl::Extents extents    = texture->size(index);
     148    if (texture->isCPUAccessible())
     149    {
     150        angle::MemoryBuffer buffer;
     151        if (!buffer.resize(bytesPerImage))
     152        {
     153            return angle::Result::Stop;
     154        }
     155        buffer.fill(0);
     156        for (NSUInteger d = 0; d < static_cast<NSUInteger>(extents.depth); ++d)
     157        {
     158            auto mtlTextureRegion     = MTLRegionMake2D(0, 0, extents.width, extents.height);
     159            mtlTextureRegion.origin.z = d + startDepth;
     160            texture->replaceRegion(contextMtl, mtlTextureRegion, index.getNativeLevel(), layer,
     161                                   buffer.data(), bytesPerRow, 0);
     162        }
     163    }
     164    else
     165    {
     166        mtl::BufferRef zeroBuffer;
     167        ANGLE_TRY(mtl::Buffer::MakeBuffer(contextMtl, bytesPerImage, nullptr, &zeroBuffer));
     168        mtl::BlitCommandEncoder *blitEncoder = contextMtl->getBlitCommandEncoder();
     169        for (NSUInteger d = 0; d < static_cast<NSUInteger>(extents.depth); ++d)
     170        {
     171            auto blitOrigin = MTLOriginMake(0, 0, d + startDepth);
     172            blitEncoder->copyBufferToTexture(zeroBuffer, 0, bytesPerRow, 0,
     173                                             MTLSizeMake(extents.width, extents.height, 1), texture,
     174                                             layer, index.getNativeLevel(), blitOrigin, 0);
     175        }
     176
     177        blitEncoder->endEncoding();
     178    }
     179    return angle::Result::Continue;
     180}
     181
    106182angle::Result InitializeTextureContents(const gl::Context *context,
    107183                                        const TextureRef &texture,
     
    119195    forceGPUInitialization = true;
    120196#endif // TARGET_OS_SIMULATOR
    121    
     197
    122198    // This function is called in many places to initialize the content of a texture.
    123199    // So it's better we do the sanity check here instead of let the callers do it themselves:
    124     if (!textureObjFormat.valid() || actualAngleFormat.isBlock || actualAngleFormat.depthBits > 0 ||
     200    // TODO: (kpiddington) update InitializeTextureContents with an upstreamed version that handles
     201    // depth/stencil textures.
     202    if (!textureObjFormat.valid() || actualAngleFormat.depthBits > 0 ||
    125203        actualAngleFormat.stencilBits > 0)
    126204    {
    127         // If dst format is compressed, ignore.
     205        // Depth or stencil textures need an updated path.
    128206        return angle::Result::Continue;
    129207    }
     
    151229                break;
    152230        }
     231    }
     232
     233    if (actualAngleFormat.isBlock)
     234    {
     235        return InitializeCompressedTextureContents(context, texture, textureObjFormat, index, layer,
     236                                                   startDepth);
    153237    }
    154238
Note: See TracChangeset for help on using the changeset viewer.