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

Changeset 281550 in webkit


Ignore:
Timestamp:
Aug 25, 2021, 12:42:34 AM (5 years ago)
Author:
commit-queue@webkit.org
Message:

ANGLE Metal index buffer restart range cache is could be maintained more consistently
https://bugs.webkit.org/show_bug.cgi?id=227451

Patch by Kimmo Kinnunen <kkinnunen@apple.com> on 2021-08-25
Reviewed by Kenneth Russell.

  • src/libANGLE/renderer/metal/BufferMtl.h:

(rx::BufferMtl::RestartRangeCache::RestartRangeCache):
Add optional<RestartRangeCache> which contains the ranges and
the index type used to build the ranges.

  • src/libANGLE/renderer/metal/BufferMtl.mm:

(rx::BufferMtl::markConversionBuffersDirty):
(rx::BufferMtl::clearConversionBuffers):
Invalidate the range cache when clearing conversion buffers.
Otherwise the cache would be left in inconsistent state vs.
the contents of the index buffer in cases of code like:
BufferMtl::setDataImpl() ...

if (...) {

markConversionBufferDirty();

} else {

clearConversionBuffers();

}

(rx::BufferMtl::getRestartIndices):

Location:
trunk/Source/ThirdParty/ANGLE
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/ThirdParty/ANGLE/ChangeLog

    r281547 r281550  
     12021-08-25  Kimmo Kinnunen  <kkinnunen@apple.com>
     2
     3        ANGLE Metal index buffer restart range cache is could be maintained more consistently
     4        https://bugs.webkit.org/show_bug.cgi?id=227451
     5
     6        Reviewed by Kenneth Russell.
     7
     8        * src/libANGLE/renderer/metal/BufferMtl.h:
     9        (rx::BufferMtl::RestartRangeCache::RestartRangeCache):
     10        Add optional<RestartRangeCache> which contains the ranges and
     11        the index type used to build the ranges.
     12
     13        * src/libANGLE/renderer/metal/BufferMtl.mm:
     14        (rx::BufferMtl::markConversionBuffersDirty):
     15        (rx::BufferMtl::clearConversionBuffers):
     16        Invalidate the range cache when clearing conversion buffers.
     17        Otherwise the cache would be left in inconsistent state vs.
     18        the contents of the index buffer in cases of code like:
     19        BufferMtl::setDataImpl() ...
     20           if (...) {
     21               markConversionBufferDirty();
     22           } else {
     23               clearConversionBuffers();
     24           }
     25        (rx::BufferMtl::getRestartIndices):
     26
    1272021-08-24  Kimmo Kinnunen  <kkinnunen@apple.com>
    228
  • trunk/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/BufferMtl.h

    r279373 r281550  
    1313#import <Metal/Metal.h>
    1414
     15#include <optional>
    1516#include <utility>
    1617
     
    211212   
    212213    std::vector<UniformConversionBufferMtl> mUniformConversionBuffers;
    213    
    214     bool mRestartIndicesDirty;
    215     std::vector<IndexRange> mRestartIndices;
    216    
     214
     215    struct RestartRangeCache
     216    {
     217        RestartRangeCache(std::vector<IndexRange>&& ranges_,  gl::DrawElementsType indexType_)
     218            : ranges(ranges_), indexType(indexType_)
     219        {}
     220        const std::vector<IndexRange> ranges;
     221        const gl::DrawElementsType indexType;
     222    };
     223    std::optional<RestartRangeCache> mRestartRangeCache;
    217224};
    218225
  • trunk/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/BufferMtl.mm

    r279373 r281550  
    402402        buffer.convertedOffset = 0;
    403403    }
    404     mRestartIndicesDirty = true;
     404    mRestartRangeCache = std::nullopt;
    405405}
    406406
     
    410410    mIndexConversionBuffers.clear();
    411411    mUniformConversionBuffers.clear();
     412    mRestartRangeCache = std::nullopt;
    412413}
    413414
     
    438439const std::vector<IndexRange> & BufferMtl::getRestartIndices(ContextMtl * ctx, gl::DrawElementsType indexType)
    439440{
    440     if(mRestartIndicesDirty)
    441     {
    442         std::vector<IndexRange>().swap(mRestartIndices);
     441    if (!mRestartRangeCache || mRestartRangeCache->indexType != indexType)
     442    {
     443        mRestartRangeCache = std::nullopt;
     444        std::vector<IndexRange> ranges;
    443445        switch(indexType)
    444446        {
    445447            case gl::DrawElementsType::UnsignedByte:
    446                 mRestartIndices = calculateRestartRanges<uint8_t>(ctx, getCurrentBuffer());
     448                ranges = calculateRestartRanges<uint8_t>(ctx, getCurrentBuffer());
    447449                break;
    448450            case gl::DrawElementsType::UnsignedShort:
    449                 mRestartIndices = calculateRestartRanges<uint16_t>(ctx, getCurrentBuffer());
     451                ranges = calculateRestartRanges<uint16_t>(ctx, getCurrentBuffer());
    450452                break;
    451453            case gl::DrawElementsType::UnsignedInt:
    452                 mRestartIndices = calculateRestartRanges<uint32_t>(ctx, getCurrentBuffer());
     454                ranges = calculateRestartRanges<uint32_t>(ctx, getCurrentBuffer());
    453455                break;
    454456            default:
    455457                ASSERT(false);
    456458        }
    457         mRestartIndicesDirty = false;
    458     }
    459     return mRestartIndices;
     459        mRestartRangeCache.emplace(std::move(ranges), indexType);
     460    }
     461    return mRestartRangeCache->ranges;
    460462}
    461463angle::Result BufferMtl::setDataImpl(const gl::Context *context,
Note: See TracChangeset for help on using the changeset viewer.