- Revision
- 247930
- Author
- justin_...@apple.com
- Date
- 2019-07-29 17:06:31 -0700 (Mon, 29 Jul 2019)
Log Message
[WebGPU] Replace Vectors with HashSets for tracking resources used by GPUCommandBuffer
https://bugs.webkit.org/show_bug.cgi?id=200200
Reviewed by Myles C. Maxfield.
Resources bound to a command buffer or bind group only need be tracked once rather than once per sub-view.
This patch cuts GPUQueue.submit validation from 2-12 ms down to ~0 when drawing 12000 triangles in Animometer.
Covered by existing tests; no behavior change expected.
* Modules/webgpu/WHLSL/Metal/WHLSLTypeNamer.cpp: Removed unused variable.
* platform/graphics/gpu/GPUBindGroup.h:
(WebCore::GPUBindGroup::boundBuffers const):
(WebCore::GPUBindGroup::boundTextures const):
* platform/graphics/gpu/GPUCommandBuffer.h:
(WebCore::GPUCommandBuffer::usedBuffers const):
(WebCore::GPUCommandBuffer::usedTextures const):
(WebCore::GPUCommandBuffer::useBuffer):
(WebCore::GPUCommandBuffer::useTexture):
* platform/graphics/gpu/cocoa/GPUBindGroupMetal.mm:
(WebCore::GPUBindGroup::tryCreate):
(WebCore::GPUBindGroup::GPUBindGroup):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (247929 => 247930)
--- trunk/Source/WebCore/ChangeLog 2019-07-29 23:23:29 UTC (rev 247929)
+++ trunk/Source/WebCore/ChangeLog 2019-07-30 00:06:31 UTC (rev 247930)
@@ -1,3 +1,28 @@
+2019-07-29 Justin Fan <justin_...@apple.com>
+
+ [WebGPU] Replace Vectors with HashSets for tracking resources used by GPUCommandBuffer
+ https://bugs.webkit.org/show_bug.cgi?id=200200
+
+ Reviewed by Myles C. Maxfield.
+
+ Resources bound to a command buffer or bind group only need be tracked once rather than once per sub-view.
+ This patch cuts GPUQueue.submit validation from 2-12 ms down to ~0 when drawing 12000 triangles in Animometer.
+
+ Covered by existing tests; no behavior change expected.
+
+ * Modules/webgpu/WHLSL/Metal/WHLSLTypeNamer.cpp: Removed unused variable.
+ * platform/graphics/gpu/GPUBindGroup.h:
+ (WebCore::GPUBindGroup::boundBuffers const):
+ (WebCore::GPUBindGroup::boundTextures const):
+ * platform/graphics/gpu/GPUCommandBuffer.h:
+ (WebCore::GPUCommandBuffer::usedBuffers const):
+ (WebCore::GPUCommandBuffer::usedTextures const):
+ (WebCore::GPUCommandBuffer::useBuffer):
+ (WebCore::GPUCommandBuffer::useTexture):
+ * platform/graphics/gpu/cocoa/GPUBindGroupMetal.mm:
+ (WebCore::GPUBindGroup::tryCreate):
+ (WebCore::GPUBindGroup::GPUBindGroup):
+
2019-07-29 Zalan Bujtas <za...@apple.com>
[LFC][TFC] Introduce Box::establishesTableFormattingContext
Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroup.h (247929 => 247930)
--- trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroup.h 2019-07-29 23:23:29 UTC (rev 247929)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroup.h 2019-07-30 00:06:31 UTC (rev 247930)
@@ -29,10 +29,10 @@
#include "GPUBuffer.h"
#include "GPUTexture.h"
+#include <wtf/HashSet.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
#include <wtf/RetainPtr.h>
-#include <wtf/Vector.h>
OBJC_PROTOCOL(MTLBuffer);
@@ -49,19 +49,19 @@
const MTLBuffer *fragmentArgsBuffer() const { return m_fragmentArgsBuffer.get(); }
const MTLBuffer *computeArgsBuffer() const { return m_computeArgsBuffer.get(); }
#endif
- const Vector<Ref<GPUBuffer>>& boundBuffers() const { return m_boundBuffers; }
- const Vector<Ref<GPUTexture>>& boundTextures() const { return m_boundTextures; }
+ const HashSet<Ref<GPUBuffer>>& boundBuffers() const { return m_boundBuffers; }
+ const HashSet<Ref<GPUTexture>>& boundTextures() const { return m_boundTextures; }
private:
#if USE(METAL)
- GPUBindGroup(RetainPtr<MTLBuffer>&& vertexBuffer, RetainPtr<MTLBuffer>&& fragmentBuffer, RetainPtr<MTLBuffer>&& computeArgsBuffer, Vector<Ref<GPUBuffer>>&&, Vector<Ref<GPUTexture>>&&);
+ GPUBindGroup(RetainPtr<MTLBuffer>&& vertexBuffer, RetainPtr<MTLBuffer>&& fragmentBuffer, RetainPtr<MTLBuffer>&& computeArgsBuffer, HashSet<Ref<GPUBuffer>>&&, HashSet<Ref<GPUTexture>>&&);
RetainPtr<MTLBuffer> m_vertexArgsBuffer;
RetainPtr<MTLBuffer> m_fragmentArgsBuffer;
RetainPtr<MTLBuffer> m_computeArgsBuffer;
#endif
- Vector<Ref<GPUBuffer>> m_boundBuffers;
- Vector<Ref<GPUTexture>> m_boundTextures;
+ HashSet<Ref<GPUBuffer>> m_boundBuffers;
+ HashSet<Ref<GPUTexture>> m_boundTextures;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUCommandBuffer.h (247929 => 247930)
--- trunk/Source/WebCore/platform/graphics/gpu/GPUCommandBuffer.h 2019-07-29 23:23:29 UTC (rev 247929)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUCommandBuffer.h 2019-07-30 00:06:31 UTC (rev 247930)
@@ -30,10 +30,10 @@
#include "GPUBuffer.h"
#include "GPUOrigin3D.h"
#include "GPUTexture.h"
+#include <wtf/HashSet.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
#include <wtf/RetainPtr.h>
-#include <wtf/Vector.h>
OBJC_PROTOCOL(MTLBlitCommandEncoder);
OBJC_PROTOCOL(MTLCommandBuffer);
@@ -84,8 +84,8 @@
static RefPtr<GPUCommandBuffer> tryCreate(const GPUDevice&);
PlatformCommandBuffer* platformCommandBuffer() const { return m_platformCommandBuffer.get(); }
- const Vector<Ref<GPUBuffer>>& usedBuffers() const { return m_usedBuffers; }
- const Vector<Ref<GPUTexture>>& usedTextures() const { return m_usedTextures; }
+ const HashSet<Ref<GPUBuffer>>& usedBuffers() const { return m_usedBuffers; }
+ const HashSet<Ref<GPUTexture>>& usedTextures() const { return m_usedTextures; }
bool isEncodingPass() const { return m_isEncodingPass; }
void setIsEncodingPass(bool isEncoding) { m_isEncodingPass = isEncoding; }
@@ -99,15 +99,15 @@
void copyTextureToBuffer(GPUTextureCopyView&&, GPUBufferCopyView&&, const GPUExtent3D&);
void copyTextureToTexture(GPUTextureCopyView&&, GPUTextureCopyView&&, const GPUExtent3D&);
- void useBuffer(Ref<GPUBuffer>&& buffer) { m_usedBuffers.append(WTFMove(buffer)); }
- void useTexture(Ref<GPUTexture>&& texture) { m_usedTextures.append(WTFMove(texture)); }
+ void useBuffer(Ref<GPUBuffer>&& buffer) { m_usedBuffers.addVoid(WTFMove(buffer)); }
+ void useTexture(Ref<GPUTexture>&& texture) { m_usedTextures.addVoid(WTFMove(texture)); }
private:
GPUCommandBuffer(PlatformCommandBufferSmartPtr&&);
PlatformCommandBufferSmartPtr m_platformCommandBuffer;
- Vector<Ref<GPUBuffer>> m_usedBuffers;
- Vector<Ref<GPUTexture>> m_usedTextures;
+ HashSet<Ref<GPUBuffer>> m_usedBuffers;
+ HashSet<Ref<GPUTexture>> m_usedTextures;
bool m_isEncodingPass { false };
#if USE(METAL)
MTLBlitCommandEncoder *blitEncoder() const;
Modified: trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupMetal.mm (247929 => 247930)
--- trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupMetal.mm 2019-07-29 23:23:29 UTC (rev 247929)
+++ trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupMetal.mm 2019-07-30 00:06:31 UTC (rev 247930)
@@ -160,8 +160,8 @@
return nullptr;
}
- Vector<Ref<GPUBuffer>> boundBuffers;
- Vector<Ref<GPUTexture>> boundTextures;
+ HashSet<Ref<GPUBuffer>> boundBuffers;
+ HashSet<Ref<GPUTexture>> boundTextures;
// Set each resource on each MTLArgumentEncoder it should be visible on.
const auto& layoutBindingsMap = descriptor.layout->bindingsMap();
@@ -203,7 +203,7 @@
setBufferOnEncoder(fragmentEncoder, *bufferResource, layoutBinding.internalName, internalLengthName);
if (isForCompute)
setBufferOnEncoder(computeEncoder, *bufferResource, layoutBinding.internalName, internalLengthName);
- boundBuffers.append(bufferResource->buffer.copyRef());
+ boundBuffers.addVoid(bufferResource->buffer.copyRef());
return true;
};
@@ -232,7 +232,7 @@
setTextureOnEncoder(fragmentEncoder, textureResource->platformTexture(), layoutBinding.internalName);
if (isForCompute)
setTextureOnEncoder(computeEncoder, textureResource->platformTexture(), layoutBinding.internalName);
- boundTextures.append(textureResource.releaseNonNull());
+ boundTextures.addVoid(textureResource.releaseNonNull());
return true;
}, [&](GPUBindGroupLayout::StorageBuffer& storageBuffer) -> bool {
return handleBuffer(storageBuffer.internalLengthName);
@@ -246,7 +246,7 @@
return adoptRef(new GPUBindGroup(WTFMove(vertexArgsBuffer), WTFMove(fragmentArgsBuffer), WTFMove(computeArgsBuffer), WTFMove(boundBuffers), WTFMove(boundTextures)));
}
-GPUBindGroup::GPUBindGroup(RetainPtr<MTLBuffer>&& vertexBuffer, RetainPtr<MTLBuffer>&& fragmentBuffer, RetainPtr<MTLBuffer>&& computeBuffer, Vector<Ref<GPUBuffer>>&& buffers, Vector<Ref<GPUTexture>>&& textures)
+GPUBindGroup::GPUBindGroup(RetainPtr<MTLBuffer>&& vertexBuffer, RetainPtr<MTLBuffer>&& fragmentBuffer, RetainPtr<MTLBuffer>&& computeBuffer, HashSet<Ref<GPUBuffer>>&& buffers, HashSet<Ref<GPUTexture>>&& textures)
: m_vertexArgsBuffer(WTFMove(vertexBuffer))
, m_fragmentArgsBuffer(WTFMove(fragmentBuffer))
, m_computeArgsBuffer(WTFMove(computeBuffer))