Title: [268766] trunk/Source/WebCore
Revision
268766
Author
[email protected]
Date
2020-10-20 15:20:52 -0700 (Tue, 20 Oct 2020)

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

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (268765 => 268766)


--- trunk/Source/WebCore/ChangeLog	2020-10-20 22:12:10 UTC (rev 268765)
+++ trunk/Source/WebCore/ChangeLog	2020-10-20 22:20:52 UTC (rev 268766)
@@ -1,5 +1,24 @@
 2020-10-20  Don Olmstead  <[email protected]>
 
+        [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:
+
+2020-10-20  Don Olmstead  <[email protected]>
+
         Non-unified build fixes, late October 2020 edition
         https://bugs.webkit.org/show_bug.cgi?id=217983
 

Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroup.h (268765 => 268766)


--- trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroup.h	2020-10-20 22:12:10 UTC (rev 268765)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroup.h	2020-10-20 22:20:52 UTC (rev 268766)
@@ -40,9 +40,7 @@
 
 struct GPUBindGroupDescriptor;
 
-#if USE(METAL)
-using ArgumentBuffer = std::pair<const MTLBuffer *, const GPUBindGroupAllocator::ArgumentBufferOffsets&>;
-#endif
+using ArgumentBuffer = std::pair<const PlatformBuffer*, const GPUBindGroupAllocator::ArgumentBufferOffsets&>;
 
 class GPUBindGroup : public RefCounted<GPUBindGroup> {
 public:
@@ -50,19 +48,15 @@
 
     ~GPUBindGroup();
     
-#if USE(METAL)
     const ArgumentBuffer argumentBuffer() const { return { m_allocator->argumentBuffer(), m_argumentBufferOffsets }; }
-#endif
     const HashSet<Ref<GPUBuffer>>& boundBuffers() const { return m_boundBuffers; }
     const HashSet<Ref<GPUTexture>>& boundTextures() const { return m_boundTextures; }
 
 private:
-#if USE(METAL)
     GPUBindGroup(GPUBindGroupAllocator::ArgumentBufferOffsets&&, GPUBindGroupAllocator&, HashSet<Ref<GPUBuffer>>&&, HashSet<Ref<GPUTexture>>&&);
     
     GPUBindGroupAllocator::ArgumentBufferOffsets m_argumentBufferOffsets;
     Ref<GPUBindGroupAllocator> m_allocator;
-#endif
     HashSet<Ref<GPUBuffer>> m_boundBuffers;
     HashSet<Ref<GPUTexture>> m_boundTextures;
 };

Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroupAllocator.h (268765 => 268766)


--- trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroupAllocator.h	2020-10-20 22:12:10 UTC (rev 268765)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroupAllocator.h	2020-10-20 22:20:52 UTC (rev 268766)
@@ -41,29 +41,27 @@
 public:
     static Ref<GPUBindGroupAllocator> create(GPUErrorScopes&);
 
-#if USE(METAL)
     struct ArgumentBufferOffsets {
-        Optional<NSUInteger> vertex;
-        Optional<NSUInteger> fragment;
-        Optional<NSUInteger> compute;
+        Optional<PlatformGPUBufferOffset> vertex;
+        Optional<PlatformGPUBufferOffset> fragment;
+        Optional<PlatformGPUBufferOffset> compute;
     };
 
+#if USE(METAL)
     Optional<ArgumentBufferOffsets> allocateAndSetEncoders(MTLArgumentEncoder *vertex, MTLArgumentEncoder *fragment, MTLArgumentEncoder *compute);
+#endif
 
     void tryReset();
 
-    const MTLBuffer *argumentBuffer() const { return m_argumentBuffer.get(); }
-#endif
+    const PlatformBuffer* argumentBuffer() const { return m_argumentBuffer.get(); }
 
 private:
     explicit GPUBindGroupAllocator(GPUErrorScopes&);
 
-#if USE(METAL)
-    bool reallocate(NSUInteger);
+    bool reallocate(PlatformGPUBufferOffset);
 
-    RetainPtr<MTLBuffer> m_argumentBuffer;
-    NSUInteger m_lastOffset { 0 };
-#endif
+    PlatformBufferSmartPtr m_argumentBuffer;
+    PlatformGPUBufferOffset m_lastOffset { 0 };
 
     Ref<GPUErrorScopes> m_errorScopes;
     int m_numBindGroups { 0 };

Modified: trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupAllocatorMetal.mm (268765 => 268766)


--- trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupAllocatorMetal.mm	2020-10-20 22:12:10 UTC (rev 268765)
+++ trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupAllocatorMetal.mm	2020-10-20 22:20:52 UTC (rev 268766)
@@ -121,6 +121,8 @@
     return offsets;
 }
 
+#endif // USE(METAL)
+
 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=200657, https://bugs.webkit.org/show_bug.cgi?id=200658 Optimize reallocation and reset behavior.
 bool GPUBindGroupAllocator::reallocate(NSUInteger newOffset)
 {
@@ -164,8 +166,6 @@
     }
 }
 
-#endif // USE(METAL)
-
 } // namespace WebCore
 
 #endif // ENABLE(WEBGPU)

Modified: trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUPlatformTypesMetal.h (268765 => 268766)


--- trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUPlatformTypesMetal.h	2020-10-20 22:12:10 UTC (rev 268765)
+++ trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUPlatformTypesMetal.h	2020-10-20 22:20:52 UTC (rev 268766)
@@ -50,6 +50,9 @@
 
 namespace WebCore {
 
+using PlatformGPUBufferOffset = NSUInteger;
+
+// Metal types
 using PlatformBuffer = MTLBuffer;
 using PlatformBufferSmartPtr = RetainPtr<PlatformBuffer>;
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to