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

Changeset 284826 in webkit


Ignore:
Timestamp:
Oct 25, 2021, 2:50:43 PM (5 years ago)
Author:
Alan Coon
Message:

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 <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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@282627 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
branches/safari-612-branch
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-612-branch/LayoutTests/ChangeLog

    r284825 r284826  
     12021-10-25  Null  <null@apple.com>
     2
     3        Cherry-pick r282627. rdar://problem/84630078
     4
     5    webgl/2.0.y/conformance/extensions/webgl-compressed-texture-s3tc-srgb.html fails on Intel+AMD Metal
     6    https://bugs.webkit.org/show_bug.cgi?id=229941
     7   
     8    Zero-initialize compressed textures explicitly, as they aren't implicitly initalized in Metal.
     9    Reviewed by Kenneth Russell <kbr@chromium.org>.
     10   
     11    Source/ThirdParty/ANGLE:
     12   
     13    * src/libANGLE/renderer/metal/mtl_utils.h:
     14    * src/libANGLE/renderer/metal/mtl_utils.mm:
     15    (rx::mtl::GetCompressedBufferForTextureWithFormat):
     16    (rx::mtl::InitializeCompressedTextureContents):
     17    (rx::mtl::InitializeTextureContents):
     18   
     19    LayoutTests:
     20   
     21    * TestExpectations:
     22   
     23   
     24    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@282627 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     25
     26    2021-09-16  Kyle Piddington  <kpiddington@apple.com>
     27
     28            webgl/2.0.y/conformance/extensions/webgl-compressed-texture-s3tc-srgb.html fails on Intel+AMD Metal
     29            https://bugs.webkit.org/show_bug.cgi?id=229941
     30
     31            Zero-initialize compressed textures explicitly, as they aren't implicitly initalized in Metal.
     32            Reviewed by Kenneth Russell <kbr@chromium.org>.
     33
     34            * TestExpectations:
     35
    1362021-10-25  Null  <null@apple.com>
    237
  • branches/safari-612-branch/LayoutTests/TestExpectations

    r284355 r284826  
    36923692webgl/2.0.y/conformance/misc/invalid-passed-params.html [ Pass ]
    36933693webgl/2.0.y/conformance/glsl/bugs/character-set.html [ Pass ]
     3694
     3695# Explicitly turn on conformance test until all of webgl/2.0.y is enabled
     3696webgl/2.0.y/conformance/extensions/webgl-compressed-texture-s3tc-srgb.html [ Pass ]
    36943697
    36953698# WebGL 1.0.3 and 2.0.0 tests where behavior is obsolete and WebKit contains implementation
  • branches/safari-612-branch/Source/ThirdParty/ANGLE/ChangeLog

    r284825 r284826  
     12021-10-25  Null  <null@apple.com>
     2
     3        Cherry-pick r282627. rdar://problem/84630078
     4
     5    webgl/2.0.y/conformance/extensions/webgl-compressed-texture-s3tc-srgb.html fails on Intel+AMD Metal
     6    https://bugs.webkit.org/show_bug.cgi?id=229941
     7   
     8    Zero-initialize compressed textures explicitly, as they aren't implicitly initalized in Metal.
     9    Reviewed by Kenneth Russell <kbr@chromium.org>.
     10   
     11    Source/ThirdParty/ANGLE:
     12   
     13    * src/libANGLE/renderer/metal/mtl_utils.h:
     14    * src/libANGLE/renderer/metal/mtl_utils.mm:
     15    (rx::mtl::GetCompressedBufferForTextureWithFormat):
     16    (rx::mtl::InitializeCompressedTextureContents):
     17    (rx::mtl::InitializeTextureContents):
     18   
     19    LayoutTests:
     20   
     21    * TestExpectations:
     22   
     23   
     24    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@282627 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     25
     26    2021-09-16  Kyle Piddington  <kpiddington@apple.com>
     27
     28            webgl/2.0.y/conformance/extensions/webgl-compressed-texture-s3tc-srgb.html fails on Intel+AMD Metal
     29            https://bugs.webkit.org/show_bug.cgi?id=229941
     30
     31            Zero-initialize compressed textures explicitly, as they aren't implicitly initalized in Metal.
     32            Reviewed by Kenneth Russell <kbr@chromium.org>.
     33
     34            * src/libANGLE/renderer/metal/mtl_utils.h:
     35            * src/libANGLE/renderer/metal/mtl_utils.mm:
     36            (rx::mtl::GetCompressedBufferForTextureWithFormat):
     37            (rx::mtl::InitializeCompressedTextureContents):
     38            (rx::mtl::InitializeTextureContents):
     39
    1402021-10-25  Null  <null@apple.com>
    241
  • branches/safari-612-branch/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/mtl_utils.mm

    r279606 r284826  
    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.