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

Changeset 268766 in webkit


Ignore:
Timestamp:
Oct 20, 2020, 3:20:52 PM (6 years ago)
Author:
don.olmstead@sony.com
Message:

[WebGPU] Increase portability of GPUBindGroup
https://bugs.webkit.org/show_bug.cgi?id=217978

Reviewed by Myles C. Maxfield.

Remove more uses of USE(METAL) around the GPUBindGroup related constructs to increase
portability. Introduce a platform specific type for an offset into the GPU Buffer.

No new tests. No change in behavior.

  • platform/graphics/gpu/GPUBindGroup.h:

(WebCore::GPUBindGroup::argumentBuffer const):

  • platform/graphics/gpu/GPUBindGroupAllocator.h:

(WebCore::GPUBindGroupAllocator::argumentBuffer const):

  • platform/graphics/gpu/cocoa/GPUBindGroupAllocatorMetal.mm:
  • platform/graphics/gpu/cocoa/GPUPlatformTypesMetal.h:
Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r268764 r268766  
     12020-10-20  Don Olmstead  <don.olmstead@sony.com>
     2
     3        [WebGPU] Increase portability of GPUBindGroup
     4        https://bugs.webkit.org/show_bug.cgi?id=217978
     5
     6        Reviewed by Myles C. Maxfield.
     7
     8        Remove more uses of USE(METAL) around the GPUBindGroup related constructs to increase
     9        portability. Introduce a platform specific type for an offset into the GPU Buffer.
     10
     11        No new tests. No change in behavior.
     12
     13        * platform/graphics/gpu/GPUBindGroup.h:
     14        (WebCore::GPUBindGroup::argumentBuffer const):
     15        * platform/graphics/gpu/GPUBindGroupAllocator.h:
     16        (WebCore::GPUBindGroupAllocator::argumentBuffer const):
     17        * platform/graphics/gpu/cocoa/GPUBindGroupAllocatorMetal.mm:
     18        * platform/graphics/gpu/cocoa/GPUPlatformTypesMetal.h:
     19
    1202020-10-20  Don Olmstead  <don.olmstead@sony.com>
    221
  • trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroup.h

    r268603 r268766  
    4141struct GPUBindGroupDescriptor;
    4242
    43 #if USE(METAL)
    44 using ArgumentBuffer = std::pair<const MTLBuffer *, const GPUBindGroupAllocator::ArgumentBufferOffsets&>;
    45 #endif
     43using ArgumentBuffer = std::pair<const PlatformBuffer*, const GPUBindGroupAllocator::ArgumentBufferOffsets&>;
    4644
    4745class GPUBindGroup : public RefCounted<GPUBindGroup> {
     
    5149    ~GPUBindGroup();
    5250   
    53 #if USE(METAL)
    5451    const ArgumentBuffer argumentBuffer() const { return { m_allocator->argumentBuffer(), m_argumentBufferOffsets }; }
    55 #endif
    5652    const HashSet<Ref<GPUBuffer>>& boundBuffers() const { return m_boundBuffers; }
    5753    const HashSet<Ref<GPUTexture>>& boundTextures() const { return m_boundTextures; }
    5854
    5955private:
    60 #if USE(METAL)
    6156    GPUBindGroup(GPUBindGroupAllocator::ArgumentBufferOffsets&&, GPUBindGroupAllocator&, HashSet<Ref<GPUBuffer>>&&, HashSet<Ref<GPUTexture>>&&);
    6257   
    6358    GPUBindGroupAllocator::ArgumentBufferOffsets m_argumentBufferOffsets;
    6459    Ref<GPUBindGroupAllocator> m_allocator;
    65 #endif
    6660    HashSet<Ref<GPUBuffer>> m_boundBuffers;
    6761    HashSet<Ref<GPUTexture>> m_boundTextures;
  • trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroupAllocator.h

    r268603 r268766  
    4242    static Ref<GPUBindGroupAllocator> create(GPUErrorScopes&);
    4343
    44 #if USE(METAL)
    4544    struct ArgumentBufferOffsets {
    46         Optional<NSUInteger> vertex;
    47         Optional<NSUInteger> fragment;
    48         Optional<NSUInteger> compute;
     45        Optional<PlatformGPUBufferOffset> vertex;
     46        Optional<PlatformGPUBufferOffset> fragment;
     47        Optional<PlatformGPUBufferOffset> compute;
    4948    };
    5049
     50#if USE(METAL)
    5151    Optional<ArgumentBufferOffsets> allocateAndSetEncoders(MTLArgumentEncoder *vertex, MTLArgumentEncoder *fragment, MTLArgumentEncoder *compute);
     52#endif
    5253
    5354    void tryReset();
    5455
    55     const MTLBuffer *argumentBuffer() const { return m_argumentBuffer.get(); }
    56 #endif
     56    const PlatformBuffer* argumentBuffer() const { return m_argumentBuffer.get(); }
    5757
    5858private:
    5959    explicit GPUBindGroupAllocator(GPUErrorScopes&);
    6060
    61 #if USE(METAL)
    62     bool reallocate(NSUInteger);
     61    bool reallocate(PlatformGPUBufferOffset);
    6362
    64     RetainPtr<MTLBuffer> m_argumentBuffer;
    65     NSUInteger m_lastOffset { 0 };
    66 #endif
     63    PlatformBufferSmartPtr m_argumentBuffer;
     64    PlatformGPUBufferOffset m_lastOffset { 0 };
    6765
    6866    Ref<GPUErrorScopes> m_errorScopes;
  • trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupAllocatorMetal.mm

    r264006 r268766  
    122122}
    123123
     124#endif // USE(METAL)
     125
    124126// FIXME: https://bugs.webkit.org/show_bug.cgi?id=200657, https://bugs.webkit.org/show_bug.cgi?id=200658 Optimize reallocation and reset behavior.
    125127bool GPUBindGroupAllocator::reallocate(NSUInteger newOffset)
     
    165167}
    166168
    167 #endif // USE(METAL)
    168 
    169169} // namespace WebCore
    170170
  • trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUPlatformTypesMetal.h

    r268603 r268766  
    5151namespace WebCore {
    5252
     53using PlatformGPUBufferOffset = NSUInteger;
     54
     55// Metal types
    5356using PlatformBuffer = MTLBuffer;
    5457using PlatformBufferSmartPtr = RetainPtr<PlatformBuffer>;
Note: See TracChangeset for help on using the changeset viewer.