WebKit Bugzilla
Attachment 345817 Details for
Bug 187333
: Improve WebGPU implementation, including using Metal Objective-C protocols more simply and correctly
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-187333-20180725210644.patch (text/plain), 375.54 KB, created by
Darin Adler
on 2018-07-25 21:06:50 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Darin Adler
Created:
2018-07-25 21:06:50 PDT
Size:
375.54 KB
patch
obsolete
>Subversion Revision: 234228 >diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index 52ada99d91168683a2742f4ead1d1df42aaa74d3..91f459deff261efeb84a899db345a1946d5cf94a 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,17 @@ >+2018-07-04 Darin Adler <darin@apple.com> >+ >+ Improve WebGPU implementation, including using Metal Objective-C protocols more simply and correctly >+ https://bugs.webkit.org/show_bug.cgi?id=187333 >+ >+ Reviewed by Sam Weinig. >+ >+ * wtf/Compiler.h: Added OBJC_PROTOCOL, a macro for convieniently treating an >+ Objective-C protocol in a way that lets it be mentioned in a C++ source file. >+ This is the rough equivalent of OBJC_CLASS, but for protocols. >+ >+ * wtf/Platform.h: Added USE(METAL), alongside USE(OPENGL) and the like. >+ Now used in the WebGPU platform layer to guard the Metal-specific code. >+ > 2018-07-25 Tomas Popela <tpopela@redhat.com> > > Correctly close the variable argument list >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index e16c2a630fba747f0f52ebd07183f6e7cca57d3f..30442474fe192fe535aca66967144723ca2c0803 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,507 @@ >+2018-07-04 Darin Adler <darin@apple.com> >+ >+ Improve WebGPU implementation, including using Metal Objective-C protocols more simply and correctly >+ https://bugs.webkit.org/show_bug.cgi?id=187333 >+ >+ Reviewed by Sam Weinig. >+ >+ - Used a new OBJC_PROTOCOL macro to handle things in the Metal API that are protocols. >+ The code previously had used OBJC_CLASS, but that created unrelated classes. >+ Fixing this allows removing many typecasts that were in the existing code, makes it >+ ARC-compatible, and also allowed the compiler to detect a couple mistakes where we >+ were calling methods that don't exist. >+ >+ - Nearly eliminated use of separate heap-allocated, reference-counted objects to >+ hold pointers to Metal objects. Only needed to keep it in one case, GPUCommandBuffer, >+ where we use it to make the lifetime for a DOM promise work. >+ >+ - Reduced the use of the WebGPU wrappers to pass around arguments inside the code. >+ They are now used only as part of the DOM binding; the inner GPU objects are used >+ whenever possible. This cuts down the number of separate functions needed a bit, >+ since we don't always need accessors for the things inside the wrappers. >+ >+ - Used references rather than pointers in many cases. >+ >+ - Took out three kinds of null checks: 1) Unneeded ones since Objective-C has the >+ "do nothing and return 0" behavior for methods without return values and that return >+ integer scalars. 2) Checks that aren't needed because the code has clear, invariant >+ guarantees that the pointer won't be null. 3) The simplest variant of (2), checks >+ that can be obviated by using reference types instead of pointer types. >+ >+ - For Metal-specific functions and data members, used the function name metal() and >+ the data member name m_metal rather than longer wordier names with the word "platform" >+ in them. We could use "platform" if these objects were platform-specific objects used >+ in a cross-platform way that needed a common name. But in this case it's clearer to >+ call them "metal" since we are dropping down to the metal with Metal API, and >+ shared platform-independent code will not be accessing these. >+ >+ - Fixed the common mistake of using "unsigned long" in our C++ code to match IDL. >+ The "unsigned long" type in IDL correponds to the "unsigned" type in WebKit code. >+ >+ - Used "const" more in the GPU functions that are wrappers around Metal objects to >+ reflect the fact that these have semantics of smart pointers; most operations can be >+ done without changing which object is pointed to. This allows us to use const >+ references to pass things around without reference count churn. >+ >+ - Reduced includes. >+ >+ - Added "explicit" keywords where appropriate. >+ >+ - Removed unused functions. In particular, removed non-Metal stub versions of the >+ functions in the GPU classes: the right way to start a new port is to clone the >+ Metal-specific files and turn the into stubs if needed, it does not make it >+ significantly more convenient to have stubs in the platform independent files, >+ especially ones that are not compiled for any platform. >+ >+ - Removed most the WEBCORE_EXPORT in the GPU headers; left only what's needed to >+ support testing with TestWebKitAPI. >+ >+ - Fixed two storage leaks in GPUDevice by adding missing adoptNS. >+ >+ * PlatformMac.cmake: Moved files from platform/graphics/cocoa to platform/graphics/metal. >+ * SourcesCocoa.txt: Ditto. >+ * WebCore.xcodeproj/project.pbxproj: Ditto. Fixed paths on some files and groups/directories. >+ Made the platform files that abstract GPU all be "project" visible, not "private", since >+ they don't need to be visible outside WebCore. Removed reference to FontSelectionKeywordValues.h, >+ which does not seem to be a source file, a derived source file, or mentioned in any change log. >+ >+ * bindings/js/JSWebGPURenderPassAttachmentDescriptorCustom.cpp: >+ (WebCore::toJSNewlyCreated): Create the correct wrapper for a >+ WebGPURenderPassDepthAttachmentDescriptor. The old code would instead >+ create a WebGPURenderPassAttachmentDescriptor wrapper, which can't be >+ used to access the clearDepth attribute. >+ >+ * html/canvas/WebGPUBuffer.cpp: >+ (WebCore::WebGPUBuffer::create): Use more references rather than pointers for things >+ that are never null. Added comment about possibly returning null on failure in future. >+ (WebCore::WebGPUBuffer::WebGPUBuffer): Updated to store the GPUBuffer inside the class >+ instead of in a separate reference counted object. >+ * html/canvas/WebGPUBuffer.h: Ditto. >+ >+ * html/canvas/WebGPUCommandBuffer.cpp: >+ (WebCore::WebGPUCommandBuffer::create): Use references and lower level types. >+ (WebCore::WebGPUCommandBuffer::WebGPUCommandBuffer): Store the GPUCommandBuffer >+ inside the class. >+ (WebCore::WebGPUCommandBuffer::commit): Removed unneeded null checks. >+ (WebCore::WebGPUCommandBuffer::presentDrawable): Ditto. >+ (WebCore::WebGPUCommandBuffer::createRenderCommandEncoderWithDescriptor): >+ Removed unneeded local variable. >+ (WebCore::WebGPUCommandBuffer::createComputeCommandEncoder): Ditto. >+ (WebCore::WebGPUCommandBuffer::completed): Store the DOMPromiseProxy in this >+ class, not in GPUCommandBuffer. >+ * html/canvas/WebGPUCommandBuffer.h: Ditto. >+ >+ * html/canvas/WebGPUCommandQueue.cpp: >+ (WebCore::WebGPUCommandQueue::create): Use references and lower level types. >+ (WebCore::WebGPUCommandQueue::WebGPUCommandQueue): Store the GPUCommandQueue >+ inside the class. >+ (WebCore::WebGPUCommandQueue::createCommandBuffer): Ditto. >+ * html/canvas/WebGPUCommandQueue.h: Ditto. >+ * html/canvas/WebGPUCommandQueue.idl: The return value of createCommandBuffer >+ is no longer nullable. >+ >+ * html/canvas/WebGPUComputeCommandEncoder.cpp: >+ (WebCore::WebGPUComputeCommandEncoder::create): More of the same. >+ (WebCore::WebGPUComputeCommandEncoder::WebGPUComputeCommandEncoder): Ditto. >+ (WebCore::WebGPUComputeCommandEncoder::setComputePipelineState): Ditto. >+ (WebCore::WebGPUComputeCommandEncoder::setBuffer): Ditto. >+ (WebCore::WebGPUComputeCommandEncoder::dispatch): Ditto. >+ (WebCore::WebGPUComputeCommandEncoder::endEncoding): Ditto. >+ * html/canvas/WebGPUComputeCommandEncoder.h: Ditto. >+ >+ * html/canvas/WebGPUComputePipelineState.cpp: >+ (WebCore::WebGPUComputePipelineState::create): More of the same. >+ (WebCore::WebGPUComputePipelineState::WebGPUComputePipelineState): Ditto. >+ * html/canvas/WebGPUComputePipelineState.h: Ditto. >+ >+ * html/canvas/WebGPUDepthStencilDescriptor.cpp: >+ (WebCore::WebGPUDepthStencilDescriptor::create): More of the same. >+ (WebCore::WebGPUDepthStencilDescriptor::depthWriteEnabled const): Ditto. >+ (WebCore::WebGPUDepthStencilDescriptor::setDepthWriteEnabled): Ditto. >+ (WebCore::WebGPUDepthStencilDescriptor::depthCompareFunction const): Ditto. >+ (WebCore::WebGPUDepthStencilDescriptor::setDepthCompareFunction): Ditto. >+ * html/canvas/WebGPUDepthStencilDescriptor.h: Ditto. Also fixed a bug >+ where m_depthCompareFunction was uninitialized in newly created objects. >+ >+ * html/canvas/WebGPUDepthStencilState.cpp: >+ (WebCore::WebGPUDepthStencilState::create): More of the same. >+ (WebCore::WebGPUDepthStencilState::WebGPUDepthStencilState): Ditto. >+ (WebCore::WebGPUDepthStencilState::label const): Ditto. >+ (WebCore::WebGPUDepthStencilState::setLabel): Ditto. >+ * html/canvas/WebGPUDepthStencilState.h: Ditto. >+ >+ * html/canvas/WebGPUDrawable.cpp: >+ (WebCore::WebGPUDrawable::create): More of the same. >+ (WebCore::WebGPUDrawable::WebGPUDrawable): Ditto. >+ * html/canvas/WebGPUDrawable.h: Ditto. >+ >+ * html/canvas/WebGPUEnums.cpp: Removed some stray const. >+ * html/canvas/WebGPUEnums.h: Ditto. >+ >+ * html/canvas/WebGPUFunction.cpp: >+ (WebCore::WebGPUFunction::create): More of the same. >+ (WebCore::WebGPUFunction::WebGPUFunction): Ditto. >+ * html/canvas/WebGPUFunction.h: Ditto. >+ >+ * html/canvas/WebGPULibrary.cpp: >+ (WebCore::WebGPULibrary::create): More of the same. >+ (WebCore::WebGPULibrary::WebGPULibrary): Ditto. >+ (WebCore::WebGPULibrary::functionNames const): Ditto. >+ (WebCore::WebGPULibrary::functionWithName const): Ditto. >+ * html/canvas/WebGPULibrary.h: Ditto. >+ >+ * html/canvas/WebGPUObject.cpp: >+ (WebCore::WebGPUObject::WebGPUObject): >+ (WebCore::WebGPUObject::deleteObject): Deleted this unused function. >+ We can bring it back later if we find we need it the way we did with the >+ WebGL implementation, but currently it's a never-called stub. Also >+ deleted the isDeleted and m_deleted for the same reason. >+ * html/canvas/WebGPUObject.h: Ditto. >+ >+ * html/canvas/WebGPURenderCommandEncoder.cpp: >+ (WebCore::WebGPURenderCommandEncoder::create): More of the same. >+ (WebCore::WebGPURenderCommandEncoder::WebGPURenderCommandEncoder): Ditto. >+ (WebCore::WebGPURenderCommandEncoder::setRenderPipelineState): Ditto. >+ (WebCore::WebGPURenderCommandEncoder::setDepthStencilState): Ditto. >+ (WebCore::WebGPURenderCommandEncoder::setVertexBuffer): Ditto. >+ (WebCore::WebGPURenderCommandEncoder::setFragmentBuffer): Ditto. >+ (WebCore::WebGPURenderCommandEncoder::drawPrimitives): Ditto. >+ (WebCore::WebGPURenderCommandEncoder::endEncoding): Ditto. >+ * html/canvas/WebGPURenderCommandEncoder.h: Ditto. >+ >+ * html/canvas/WebGPURenderPassAttachmentDescriptor.cpp: >+ (WebCore::WebGPURenderPassAttachmentDescriptor::WebGPURenderPassAttachmentDescriptor): >+ More of the same. >+ (WebCore::WebGPURenderPassAttachmentDescriptor::loadAction const): Ditto. >+ (WebCore::WebGPURenderPassAttachmentDescriptor::setLoadAction): Ditto. >+ (WebCore::WebGPURenderPassAttachmentDescriptor::storeAction const): Ditto. >+ (WebCore::WebGPURenderPassAttachmentDescriptor::setStoreAction): Ditto. >+ (WebCore::WebGPURenderPassAttachmentDescriptor::texture const): Ditto. >+ (WebCore::WebGPURenderPassAttachmentDescriptor::setTexture): Ditto. >+ * html/canvas/WebGPURenderPassAttachmentDescriptor.h: Ditto. >+ >+ * html/canvas/WebGPURenderPassColorAttachmentDescriptor.cpp: >+ (WebCore::WebGPURenderPassColorAttachmentDescriptor::create): More of the same. >+ (WebCore::WebGPURenderPassColorAttachmentDescriptor::WebGPURenderPassColorAttachmentDescriptor): Ditto. >+ (WebCore::WebGPURenderPassColorAttachmentDescriptor::descriptor const): Ditto. >+ (WebCore::WebGPURenderPassColorAttachmentDescriptor::clearColor const): Ditto. >+ (WebCore::WebGPURenderPassColorAttachmentDescriptor::setClearColor): Ditto. >+ * html/canvas/WebGPURenderPassColorAttachmentDescriptor.h: Ditto. >+ >+ * html/canvas/WebGPURenderPassDepthAttachmentDescriptor.cpp: >+ (WebCore::WebGPURenderPassDepthAttachmentDescriptor::create): More of the same. >+ (WebCore::WebGPURenderPassDepthAttachmentDescriptor::WebGPURenderPassDepthAttachmentDescriptor): Ditto. >+ (WebCore::WebGPURenderPassDepthAttachmentDescriptor::clearDepth const): Ditto. >+ (WebCore::WebGPURenderPassDepthAttachmentDescriptor::setClearDepth): Ditto. >+ (WebCore::WebGPURenderPassDepthAttachmentDescriptor::descriptor const): Ditto. >+ * html/canvas/WebGPURenderPassDepthAttachmentDescriptor.h: Ditto. >+ >+ * html/canvas/WebGPURenderPassDescriptor.cpp: >+ (WebCore::WebGPURenderPassDescriptor::create): More of the same. >+ (WebCore::WebGPURenderPassDescriptor::depthAttachment): Ditto. >+ (WebCore::WebGPURenderPassDescriptor::colorAttachments): Ditto. >+ * html/canvas/WebGPURenderPassDescriptor.h: Ditto. >+ >+ * html/canvas/WebGPURenderPipelineColorAttachmentDescriptor.cpp: >+ (WebCore::WebGPURenderPipelineColorAttachmentDescriptor::create): More of the same. >+ (WebCore::WebGPURenderPipelineColorAttachmentDescriptor::WebGPURenderPipelineColorAttachmentDescriptor): Ditto. >+ (WebCore::WebGPURenderPipelineColorAttachmentDescriptor::pixelFormat const): Ditto. >+ (WebCore::WebGPURenderPipelineColorAttachmentDescriptor::setPixelFormat): Ditto. >+ * html/canvas/WebGPURenderPipelineColorAttachmentDescriptor.h: Ditto. >+ >+ * html/canvas/WebGPURenderPipelineDescriptor.cpp: >+ (WebCore::WebGPURenderPipelineDescriptor::create): More of the same. >+ (WebCore::WebGPURenderPipelineDescriptor::vertexFunction const): Ditto. >+ (WebCore::WebGPURenderPipelineDescriptor::setVertexFunction): Ditto. >+ (WebCore::WebGPURenderPipelineDescriptor::fragmentFunction const): Ditto. >+ (WebCore::WebGPURenderPipelineDescriptor::setFragmentFunction): Ditto. >+ (WebCore::WebGPURenderPipelineDescriptor::colorAttachments): Ditto. >+ (WebCore::WebGPURenderPipelineDescriptor::depthAttachmentPixelFormat const): Ditto. >+ (WebCore::WebGPURenderPipelineDescriptor::setDepthAttachmentPixelFormat): Ditto. >+ (WebCore::WebGPURenderPipelineDescriptor::reset): Ditto. >+ * html/canvas/WebGPURenderPipelineDescriptor.h: Ditto. >+ >+ * html/canvas/WebGPURenderPipelineState.cpp: >+ (WebCore::WebGPURenderPipelineState::create): More of the same. >+ (WebCore::WebGPURenderPipelineState::WebGPURenderPipelineState): Ditto. >+ (WebCore::WebGPURenderPipelineState::label const): Ditto. >+ (WebCore::WebGPURenderPipelineState::setLabel): Ditto. >+ * html/canvas/WebGPURenderPipelineState.h: Ditto. >+ >+ * html/canvas/WebGPURenderingContext.cpp: >+ (WebCore::WebGPURenderingContext::create): More of the same. >+ (WebCore::WebGPURenderingContext::WebGPURenderingContext): Ditto. >+ (WebCore::WebGPURenderingContext::initializeNewContext): Ditto. >+ (WebCore::WebGPURenderingContext::platformLayer const): Ditto. >+ (WebCore::WebGPURenderingContext::markLayerComposited): Ditto. >+ (WebCore::WebGPURenderingContext::reshape): Ditto. >+ (WebCore::WebGPURenderingContext::createLibrary): Ditto. >+ (WebCore::WebGPURenderingContext::createRenderPipelineState): Ditto. >+ (WebCore::WebGPURenderingContext::createDepthStencilState): Ditto. >+ (WebCore::WebGPURenderingContext::createComputePipelineState): Ditto. >+ (WebCore::WebGPURenderingContext::createCommandQueue): Ditto. >+ (WebCore::WebGPURenderingContext::nextDrawable): Ditto. >+ (WebCore::WebGPURenderingContext::createBuffer): Ditto. >+ (WebCore::WebGPURenderingContext::createTexture): Ditto. >+ * html/canvas/WebGPURenderingContext.h: Made many functions final and >+ private. >+ * html/canvas/WebGPURenderingContext.idl: The return value of most of >+ the create functions are no longer nullable. >+ >+ * html/canvas/WebGPUSize.h: Use "unsigned" instead of "unsigned long". >+ >+ * html/canvas/WebGPUTexture.cpp: >+ (WebCore::WebGPUTexture::createFromDrawableTexture): More of the same. >+ (WebCore::WebGPUTexture::create): Ditto. >+ (WebCore::WebGPUTexture::WebGPUTexture): Ditto. >+ * html/canvas/WebGPUTexture.h: Ditto. >+ >+ * html/canvas/WebGPUTextureDescriptor.cpp: >+ (WebCore::WebGPUTextureDescriptor::create): More of the same. >+ (WebCore::WebGPUTextureDescriptor::WebGPUTextureDescriptor): Ditto. >+ (WebCore::WebGPUTextureDescriptor::width const): Ditto. >+ (WebCore::WebGPUTextureDescriptor::setWidth): Ditto. >+ (WebCore::WebGPUTextureDescriptor::height const): Ditto. >+ (WebCore::WebGPUTextureDescriptor::setHeight): Ditto. >+ (WebCore::WebGPUTextureDescriptor::sampleCount const): Ditto. >+ (WebCore::WebGPUTextureDescriptor::setSampleCount): Ditto. >+ (WebCore::WebGPUTextureDescriptor::textureType const): Ditto. >+ (WebCore::WebGPUTextureDescriptor::setTextureType): Ditto. >+ (WebCore::WebGPUTextureDescriptor::storageMode const): Ditto. >+ (WebCore::WebGPUTextureDescriptor::setStorageMode): Ditto. >+ (WebCore::WebGPUTextureDescriptor::usage const): Ditto. >+ (WebCore::WebGPUTextureDescriptor::setUsage): Ditto. >+ * html/canvas/WebGPUTextureDescriptor.h: Ditto. >+ >+ * platform/graphics/metal/GPUBufferMetal.mm: Moved from "cocoa" directory. >+ (WebCore::GPUBuffer::GPUBuffer): Simplify code using references and the >+ "metal" naming. >+ >+ * platform/graphics/metal/GPUCommandBufferMetal.mm: >+ (WebCore::GPUCommandBuffer::GPUCommandBuffer): Take a function to be called as the >+ completed handler and set it up. >+ (WebCore::GPUCommandBuffer::presentDrawable const): Ditto. >+ (WebCore::GPUCommandBuffer::commit const): Ditto. >+ (WebCore::GPUCommandBuffer::addCompletedHandler): Deleted. >+ >+ * platform/graphics/metal/GPUCommandQueueMetal.mm: >+ (WebCore::GPUCommandQueue::GPUCommandQueue): Ditto. Also rewrote label handling a bit. >+ (WebCore::GPUCommandQueue::label const): Ditto. >+ (WebCore::GPUCommandQueue::setLabel const): Ditto. >+ >+ * platform/graphics/metal/GPUComputeCommandEncoderMetal.mm: >+ (WebCore::GPUComputeCommandEncoder::GPUComputeCommandEncoder): Ditto. >+ (WebCore::GPUComputeCommandEncoder::setComputePipelineState const): Ditto. >+ (WebCore::GPUComputeCommandEncoder::setBuffer const): Ditto. >+ (WebCore::GPUComputeCommandEncoder::dispatch const): Ditto. >+ (WebCore::GPUComputeCommandEncoder::endEncoding const): Ditto. >+ >+ * platform/graphics/metal/GPUComputePipelineStateMetal.mm: >+ (WebCore::GPUComputePipelineState::GPUComputePipelineState): Ditto. >+ >+ * platform/graphics/metal/GPUDepthStencilDescriptorMetal.mm: >+ (WebCore::GPUDepthStencilDescriptor::GPUDepthStencilDescriptor): Ditto. >+ (WebCore::GPUDepthStencilDescriptor::depthWriteEnabled const): Ditto. >+ (WebCore::GPUDepthStencilDescriptor::setDepthWriteEnabled const): Ditto. >+ (WebCore::GPUDepthStencilDescriptor::depthCompareFunction const): Ditto. >+ (WebCore::GPUDepthStencilDescriptor::setDepthCompareFunction const): Ditto. >+ >+ * platform/graphics/metal/GPUDepthStencilStateMetal.mm: >+ (WebCore::GPUDepthStencilState::GPUDepthStencilState): Ditto. >+ (WebCore::GPUDepthStencilState::label const): Ditto. >+ (WebCore::GPUDepthStencilState::setLabel const): Ditto. This is one of the >+ functions that was calling a method that does not exist. Added a comment. >+ >+ * platform/graphics/metal/GPUDeviceMetal.mm: >+ (WebCore::GPUDevice::GPUDevice): Ditto. Also fixed two storage leaks where >+ we neglected to do adoptNS on the result of MTLCreateSystemDefaultDevice and >+ on the result of -[[WebGPULayer alloc] initWithGPUDevice:]. >+ (WebCore::GPUDevice::reshape const): Ditto. >+ (WebCore::GPUDevice::platformLayer const): Ditto. >+ (WebCore::GPUDevice::operator! const): Ditto. >+ >+ * platform/graphics/metal/GPUDrawableMetal.mm: >+ (WebCore::GPUDrawable::GPUDrawable): Ditto. >+ (WebCore::GPUDrawable::release): Ditto. >+ (WebCore::GPUDrawable::metal const): Ditto. >+ (WebCore::GPUDrawable::texture const): Ditto. >+ >+ * platform/graphics/metal/GPUFunctionMetal.mm: >+ (WebCore::GPUFunction::GPUFunction): Ditto. >+ (WebCore::GPUFunction::name const): Ditto. >+ (WebCore::GPUFunction::metal const): Ditto. >+ (WebCore::GPUFunction::operator! const): Ditto. >+ >+ * platform/graphics/metal/GPULibraryMetal.mm: >+ (WebCore::GPULibrary::GPULibrary): Ditto. >+ (WebCore::GPULibrary::label const): Ditto. >+ (WebCore::GPULibrary::setLabel const): Ditto. >+ (WebCore::GPULibrary::functionNames const): Ditto. >+ (WebCore::GPULibrary::metal const): Ditto. >+ >+ * platform/graphics/metal/GPURenderCommandEncoderMetal.mm: >+ (WebCore::GPURenderCommandEncoder::GPURenderCommandEncoder): Ditto. >+ (WebCore::GPURenderCommandEncoder::setRenderPipelineState const): Ditto. >+ (WebCore::GPURenderCommandEncoder::setDepthStencilState const): Ditto. >+ (WebCore::GPURenderCommandEncoder::setVertexBuffer const): Ditto. >+ (WebCore::GPURenderCommandEncoder::setFragmentBuffer const): Ditto. >+ (WebCore::GPURenderCommandEncoder::drawPrimitives const): Ditto. >+ (WebCore::GPURenderCommandEncoder::endEncoding const): Ditto. >+ >+ * platform/graphics/metal/GPURenderPassAttachmentDescriptorMetal.mm: >+ (WebCore::GPURenderPassAttachmentDescriptor::GPURenderPassAttachmentDescriptor): Ditto. >+ (WebCore::GPURenderPassAttachmentDescriptor::loadAction const): Ditto. >+ (WebCore::GPURenderPassAttachmentDescriptor::setLoadAction const): Ditto. >+ (WebCore::GPURenderPassAttachmentDescriptor::storeAction const): Ditto. >+ (WebCore::GPURenderPassAttachmentDescriptor::setStoreAction const): Ditto. >+ (WebCore::GPURenderPassAttachmentDescriptor::setTexture const): Ditto. >+ >+ * platform/graphics/metal/GPURenderPassColorAttachmentDescriptorMetal.mm: >+ (WebCore::GPURenderPassColorAttachmentDescriptor::GPURenderPassColorAttachmentDescriptor): Ditto. >+ (WebCore::GPURenderPassColorAttachmentDescriptor::clearColor const): Ditto. >+ (WebCore::GPURenderPassColorAttachmentDescriptor::setClearColor const): Ditto. >+ (WebCore::GPURenderPassColorAttachmentDescriptor::metal const): Ditto. >+ >+ * platform/graphics/metal/GPURenderPassDepthAttachmentDescriptorMetal.mm: >+ (WebCore::GPURenderPassDepthAttachmentDescriptor::GPURenderPassDepthAttachmentDescriptor): Ditto. >+ (WebCore::GPURenderPassDepthAttachmentDescriptor::clearDepth const): Ditto. >+ (WebCore::GPURenderPassDepthAttachmentDescriptor::setClearDepth const): Ditto. >+ (WebCore::GPURenderPassDepthAttachmentDescriptor::metal const): Ditto. >+ >+ * platform/graphics/metal/GPURenderPassDescriptorMetal.mm: >+ (WebCore::GPURenderPassDescriptor::GPURenderPassDescriptor): Ditto. >+ (WebCore::GPURenderPassDescriptor::colorAttachments const): Ditto. >+ (WebCore::GPURenderPassDescriptor::depthAttachment const): Ditto. >+ (WebCore::GPURenderPassDescriptor::metal const): Ditto. >+ >+ * platform/graphics/metal/GPURenderPipelineColorAttachmentDescriptorMetal.mm: >+ (WebCore::GPURenderPipelineColorAttachmentDescriptor::GPURenderPipelineColorAttachmentDescriptor): Ditto. >+ (WebCore::GPURenderPipelineColorAttachmentDescriptor::pixelFormat const): Ditto. >+ (WebCore::GPURenderPipelineColorAttachmentDescriptor::setPixelFormat const): Ditto. >+ (WebCore::GPURenderPipelineColorAttachmentDescriptor::metal const): Ditto. >+ >+ * platform/graphics/metal/GPURenderPipelineDescriptorMetal.mm: >+ (WebCore::GPURenderPipelineDescriptor::GPURenderPipelineDescriptor): Ditto. >+ (WebCore::GPURenderPipelineDescriptor::depthAttachmentPixelFormat const): Ditto. >+ (WebCore::GPURenderPipelineDescriptor::setDepthAttachmentPixelFormat const): Ditto. >+ (WebCore::GPURenderPipelineDescriptor::setVertexFunction const): Ditto. >+ (WebCore::GPURenderPipelineDescriptor::setFragmentFunction const): Ditto. >+ (WebCore::GPURenderPipelineDescriptor::colorAttachments const): Ditto. >+ (WebCore::GPURenderPipelineDescriptor::reset const): Ditto. >+ (WebCore::GPURenderPipelineDescriptor::metal const): Ditto. >+ >+ * platform/graphics/metal/GPURenderPipelineStateMetal.mm: >+ (WebCore::GPURenderPipelineState::GPURenderPipelineState): Ditto. >+ (WebCore::GPURenderPipelineState::label const): Ditto. >+ (WebCore::GPURenderPipelineState::setLabel const): Ditto. This is one of the >+ functions that was calling a method that does not exist. Added a comment. >+ (WebCore::GPURenderPipelineState::metal const): Ditto. >+ >+ * platform/graphics/metal/GPUTextureDescriptorMetal.mm: >+ (WebCore::GPUTextureDescriptor::GPUTextureDescriptor): Ditto. >+ (WebCore::GPUTextureDescriptor::width const): Ditto. >+ (WebCore::GPUTextureDescriptor::setWidth const): Ditto. >+ (WebCore::GPUTextureDescriptor::height const): Ditto. >+ (WebCore::GPUTextureDescriptor::setHeight const): Ditto. >+ (WebCore::GPUTextureDescriptor::sampleCount const): Ditto. >+ (WebCore::GPUTextureDescriptor::setSampleCount const): Ditto. >+ (WebCore::GPUTextureDescriptor::textureType const): Ditto. >+ (WebCore::GPUTextureDescriptor::setTextureType const): Ditto. >+ (WebCore::GPUTextureDescriptor::storageMode const): Ditto. >+ (WebCore::GPUTextureDescriptor::setStorageMode const): Ditto. >+ (WebCore::GPUTextureDescriptor::usage const): Ditto. >+ (WebCore::GPUTextureDescriptor::setUsage const): Ditto. >+ (WebCore::GPUTextureDescriptor::metal const): Ditto. >+ >+ * platform/graphics/metal/GPUTextureMetal.mm: >+ (WebCore::GPUTexture::GPUTexture): Ditto. >+ (WebCore::GPUTexture::width const): Ditto. >+ (WebCore::GPUTexture::height const): Ditto. >+ (WebCore::GPUTexture::metal const): Ditto. >+ >+ * platform/graphics/gpu/GPUBuffer.cpp: Removed unused stubs. >+ (WebCore::GPUBuffer::length const): Moved this function here since it has >+ a useful platform-independent implementation. >+ >+ * platform/graphics/gpu/GPUBuffer.h: Use OBJC_PROTOCOL for MTLBuffer. >+ Did the other thigs mentioned above: USE(METAL), remove WEBCORE_EXPORT, >+ no longer be RefCounted, etc. >+ >+ * platform/graphics/gpu/GPUCommandBuffer.cpp: Ditto. >+ * platform/graphics/gpu/GPUCommandBuffer.h: Ditto. Use OBJC_PROTOCOL >+ for MTLCommandBuffer. >+ >+ * platform/graphics/gpu/GPUCommandQueue.cpp: Ditto. >+ * platform/graphics/gpu/GPUCommandQueue.h: Ditto. Use OBJC_PROTOCOL for >+ MTLCommandQueue. >+ >+ * platform/graphics/gpu/GPUComputeCommandEncoder.cpp: Ditto. >+ * platform/graphics/gpu/GPUComputeCommandEncoder.h: Ditto. Use OBJC_PROTOCOL for >+ MTLComputeCommandEncoder. >+ >+ * platform/graphics/gpu/GPUComputePipelineState.cpp: Ditto. >+ * platform/graphics/gpu/GPUComputePipelineState.h: Ditto. Use OBJC_PROTOCOL for >+ MTLComputePipelineState. >+ >+ * platform/graphics/gpu/GPUDepthStencilDescriptor.cpp: Ditto. >+ * platform/graphics/gpu/GPUDepthStencilDescriptor.h: Ditto. >+ >+ * platform/graphics/gpu/GPUDepthStencilState.cpp: Ditto. >+ * platform/graphics/gpu/GPUDepthStencilState.h: Ditto. Use OBJC_PROTOCOL for >+ MTLDepthStencilState. >+ >+ * platform/graphics/gpu/GPUDevice.cpp: Ditto. >+ * platform/graphics/gpu/GPUDevice.h: Ditto. Use OBJC_PROTOCOL for MTLDevice. >+ >+ * platform/graphics/gpu/GPUDrawable.cpp: Ditto. >+ * platform/graphics/gpu/GPUDrawable.h: Ditto. Use OBJC_PROTOCOL for >+ MTLDrawable and MTLTexture. >+ >+ * platform/graphics/gpu/GPUEnums.h: Tweaked formatting. >+ >+ * platform/graphics/gpu/GPUFunction.cpp: Ditto. >+ * platform/graphics/gpu/GPUFunction.h: Ditto. Use OBJC_PROTOCOL for >+ MTLFunction. >+ >+ * platform/graphics/gpu/GPULibrary.cpp: Ditto. >+ * platform/graphics/gpu/GPULibrary.h: Ditto. Use OBJC_PROTOCOL for >+ MTLLibrary. >+ >+ * platform/graphics/gpu/GPURenderCommandEncoder.cpp: Ditto. >+ * platform/graphics/gpu/GPURenderCommandEncoder.h: Ditto. >+ Use OBJC_PROTOCOL for MTLRenderCommandEncoder. >+ >+ * platform/graphics/gpu/GPURenderPassAttachmentDescriptor.cpp: Ditto. >+ * platform/graphics/gpu/GPURenderPassAttachmentDescriptor.h: Ditto. >+ >+ * platform/graphics/gpu/GPURenderPassColorAttachmentDescriptor.cpp: Ditto. >+ * platform/graphics/gpu/GPURenderPassColorAttachmentDescriptor.h: Ditto. >+ >+ * platform/graphics/gpu/GPURenderPassDepthAttachmentDescriptor.cpp: Ditto. >+ * platform/graphics/gpu/GPURenderPassDepthAttachmentDescriptor.h: Ditto. >+ >+ * platform/graphics/gpu/GPURenderPassDescriptor.cpp: Ditto. >+ * platform/graphics/gpu/GPURenderPassDescriptor.h: Ditto. >+ >+ * platform/graphics/gpu/GPURenderPipelineColorAttachmentDescriptor.cpp: Ditto. >+ * platform/graphics/gpu/GPURenderPipelineColorAttachmentDescriptor.h: Ditto. >+ >+ * platform/graphics/gpu/GPURenderPipelineDescriptor.cpp: Ditto. >+ * platform/graphics/gpu/GPURenderPipelineDescriptor.h: Ditto. >+ >+ * platform/graphics/gpu/GPURenderPipelineState.cpp: Ditto. >+ * platform/graphics/gpu/GPURenderPipelineState.h: Ditto. Use OBJC_PROTOCOL >+ for MTLRenderPipelineState. >+ >+ * platform/graphics/gpu/GPUSize.h: Use "unsigned" instead of "unsigned long". >+ >+ * platform/graphics/gpu/GPUTexture.cpp: Ditto. >+ * platform/graphics/gpu/GPUTexture.h: Ditto. Use OBJC_PROTOCOL for >+ MTLTexture. >+ >+ * platform/graphics/gpu/GPUTextureDescriptor.cpp: Ditto. >+ * platform/graphics/gpu/GPUTextureDescriptor.h: Ditto. >+ > 2018-07-25 Chris Dumez <cdumez@apple.com> > > Allow ActiveDOMObject's canSuspend / suspend / resume overrides to destroy ActiveDOMObjects >diff --git a/Source/WTF/wtf/Compiler.h b/Source/WTF/wtf/Compiler.h >index 77f271ec315c92517b5bf642066a5a197b38b3ea..798c3090c9b1c18580a3a6be6fab65bdace6ffaa 100644 >--- a/Source/WTF/wtf/Compiler.h >+++ b/Source/WTF/wtf/Compiler.h >@@ -296,6 +296,18 @@ > #define OBJC_CLASS class > #endif > >+/* OBJC_PROTOCOL */ >+ >+#if !defined(OBJC_PROTOCOL) && defined(__OBJC__) >+/* This forward-declares a protocol, then also creates a type of the same name based on NSObject. >+ * This allows us to use "NSObject<MyProtocol> *" or "MyProtocol *" more-or-less interchangably. */ >+#define OBJC_PROTOCOL(protocolName) @protocol protocolName; using protocolName = NSObject<protocolName> >+#endif >+ >+#if !defined(OBJC_PROTOCOL) >+#define OBJC_PROTOCOL(protocolName) class protocolName >+#endif >+ > /* PURE_FUNCTION */ > > #if !defined(PURE_FUNCTION) && COMPILER(GCC_OR_CLANG) >diff --git a/Source/WTF/wtf/Platform.h b/Source/WTF/wtf/Platform.h >index 18fa82ff3580b872402143ad0b7c52887fba2816..8397fab5b43d89e358ceb9898fba9ede31af605f 100644 >--- a/Source/WTF/wtf/Platform.h >+++ b/Source/WTF/wtf/Platform.h >@@ -1067,6 +1067,8 @@ > #endif > #endif > >+#define USE_METAL 1 >+ > #if HAVE(ACCESSIBILITY) > #define USE_ACCESSIBILITY_CONTEXT_MENUS 1 > #endif >diff --git a/Source/WebCore/PlatformMac.cmake b/Source/WebCore/PlatformMac.cmake >index 80520ab0fce0df4832f787b45c110a8af38781ba..f3d8d028cfd1e061f9f2c6f302bdf9b95d1d4949 100644 >--- a/Source/WebCore/PlatformMac.cmake >+++ b/Source/WebCore/PlatformMac.cmake >@@ -293,27 +293,6 @@ list(APPEND WebCore_SOURCES > platform/graphics/cg/TransformationMatrixCG.cpp > platform/graphics/cg/UTIRegistry.cpp > >- platform/graphics/cocoa/GPUBufferMetal.mm >- platform/graphics/cocoa/GPUCommandBufferMetal.mm >- platform/graphics/cocoa/GPUCommandQueueMetal.mm >- platform/graphics/cocoa/GPUComputeCommandEncoderMetal.mm >- platform/graphics/cocoa/GPUComputePipelineStateMetal.mm >- platform/graphics/cocoa/GPUDepthStencilDescriptorMetal.mm >- platform/graphics/cocoa/GPUDepthStencilStateMetal.mm >- platform/graphics/cocoa/GPUDeviceMetal.mm >- platform/graphics/cocoa/GPUDrawableMetal.mm >- platform/graphics/cocoa/GPUFunctionMetal.mm >- platform/graphics/cocoa/GPULibraryMetal.mm >- platform/graphics/cocoa/GPURenderCommandEncoderMetal.mm >- platform/graphics/cocoa/GPURenderPassAttachmentDescriptorMetal.mm >- platform/graphics/cocoa/GPURenderPassColorAttachmentDescriptorMetal.mm >- platform/graphics/cocoa/GPURenderPassDepthAttachmentDescriptorMetal.mm >- platform/graphics/cocoa/GPURenderPassDescriptorMetal.mm >- platform/graphics/cocoa/GPURenderPipelineColorAttachmentDescriptorMetal.mm >- platform/graphics/cocoa/GPURenderPipelineDescriptorMetal.mm >- platform/graphics/cocoa/GPURenderPipelineStateMetal.mm >- platform/graphics/cocoa/GPUTextureDescriptorMetal.mm >- platform/graphics/cocoa/GPUTextureMetal.mm > platform/graphics/cocoa/GraphicsContext3DCocoa.mm > platform/graphics/cocoa/GraphicsContextCocoa.mm > platform/graphics/cocoa/FontCacheCoreText.cpp >@@ -357,6 +336,28 @@ list(APPEND WebCore_SOURCES > platform/graphics/mac/SimpleFontDataCoreText.cpp > platform/graphics/mac/WebLayer.mm > >+ platform/graphics/metal/GPUBufferMetal.mm >+ platform/graphics/metal/GPUCommandBufferMetal.mm >+ platform/graphics/metal/GPUCommandQueueMetal.mm >+ platform/graphics/metal/GPUComputeCommandEncoderMetal.mm >+ platform/graphics/metal/GPUComputePipelineStateMetal.mm >+ platform/graphics/metal/GPUDepthStencilDescriptorMetal.mm >+ platform/graphics/metal/GPUDepthStencilStateMetal.mm >+ platform/graphics/metal/GPUDeviceMetal.mm >+ platform/graphics/metal/GPUDrawableMetal.mm >+ platform/graphics/metal/GPUFunctionMetal.mm >+ platform/graphics/metal/GPULibraryMetal.mm >+ platform/graphics/metal/GPURenderCommandEncoderMetal.mm >+ platform/graphics/metal/GPURenderPassAttachmentDescriptorMetal.mm >+ platform/graphics/metal/GPURenderPassColorAttachmentDescriptorMetal.mm >+ platform/graphics/metal/GPURenderPassDepthAttachmentDescriptorMetal.mm >+ platform/graphics/metal/GPURenderPassDescriptorMetal.mm >+ platform/graphics/metal/GPURenderPipelineColorAttachmentDescriptorMetal.mm >+ platform/graphics/metal/GPURenderPipelineDescriptorMetal.mm >+ platform/graphics/metal/GPURenderPipelineStateMetal.mm >+ platform/graphics/metal/GPUTextureDescriptorMetal.mm >+ platform/graphics/metal/GPUTextureMetal.mm >+ > platform/graphics/opengl/Extensions3DOpenGL.cpp > platform/graphics/opengl/Extensions3DOpenGLCommon.cpp > platform/graphics/opengl/GraphicsContext3DOpenGL.cpp >diff --git a/Source/WebCore/SourcesCocoa.txt b/Source/WebCore/SourcesCocoa.txt >index f0b8e9448bc0b458857ee9c0329fa35dbe36b431..e352e53b8d61fcb80a2f2a0ca6cefe5c1a91b93d 100644 >--- a/Source/WebCore/SourcesCocoa.txt >+++ b/Source/WebCore/SourcesCocoa.txt >@@ -292,27 +292,6 @@ platform/graphics/cg/SubimageCacheWithTimer.cpp > platform/graphics/cg/TransformationMatrixCG.cpp > platform/graphics/cg/UTIRegistry.cpp > >-platform/graphics/cocoa/GPUBufferMetal.mm >-platform/graphics/cocoa/GPUCommandBufferMetal.mm >-platform/graphics/cocoa/GPUCommandQueueMetal.mm >-platform/graphics/cocoa/GPUComputeCommandEncoderMetal.mm >-platform/graphics/cocoa/GPUComputePipelineStateMetal.mm >-platform/graphics/cocoa/GPUDepthStencilDescriptorMetal.mm >-platform/graphics/cocoa/GPUDepthStencilStateMetal.mm >-platform/graphics/cocoa/GPUDeviceMetal.mm >-platform/graphics/cocoa/GPUDrawableMetal.mm >-platform/graphics/cocoa/GPUFunctionMetal.mm >-platform/graphics/cocoa/GPULibraryMetal.mm >-platform/graphics/cocoa/GPURenderCommandEncoderMetal.mm >-platform/graphics/cocoa/GPURenderPassAttachmentDescriptorMetal.mm >-platform/graphics/cocoa/GPURenderPassColorAttachmentDescriptorMetal.mm >-platform/graphics/cocoa/GPURenderPassDepthAttachmentDescriptorMetal.mm >-platform/graphics/cocoa/GPURenderPassDescriptorMetal.mm >-platform/graphics/cocoa/GPURenderPipelineColorAttachmentDescriptorMetal.mm >-platform/graphics/cocoa/GPURenderPipelineDescriptorMetal.mm >-platform/graphics/cocoa/GPURenderPipelineStateMetal.mm >-platform/graphics/cocoa/GPUTextureDescriptorMetal.mm >-platform/graphics/cocoa/GPUTextureMetal.mm > platform/graphics/cocoa/GraphicsContext3DCocoa.mm > platform/graphics/cocoa/GraphicsContextCocoa.mm > platform/graphics/cocoa/FontCacheCoreText.cpp >@@ -360,6 +339,28 @@ platform/graphics/mac/SimpleFontDataCoreText.cpp > platform/graphics/mac/WebLayer.mm > platform/graphics/mac/WebKitNSImageExtras.mm > >+platform/graphics/metal/GPUBufferMetal.mm >+platform/graphics/metal/GPUCommandBufferMetal.mm >+platform/graphics/metal/GPUCommandQueueMetal.mm >+platform/graphics/metal/GPUComputeCommandEncoderMetal.mm >+platform/graphics/metal/GPUComputePipelineStateMetal.mm >+platform/graphics/metal/GPUDepthStencilDescriptorMetal.mm >+platform/graphics/metal/GPUDepthStencilStateMetal.mm >+platform/graphics/metal/GPUDeviceMetal.mm >+platform/graphics/metal/GPUDrawableMetal.mm >+platform/graphics/metal/GPUFunctionMetal.mm >+platform/graphics/metal/GPULibraryMetal.mm >+platform/graphics/metal/GPURenderCommandEncoderMetal.mm >+platform/graphics/metal/GPURenderPassAttachmentDescriptorMetal.mm >+platform/graphics/metal/GPURenderPassColorAttachmentDescriptorMetal.mm >+platform/graphics/metal/GPURenderPassDepthAttachmentDescriptorMetal.mm >+platform/graphics/metal/GPURenderPassDescriptorMetal.mm >+platform/graphics/metal/GPURenderPipelineColorAttachmentDescriptorMetal.mm >+platform/graphics/metal/GPURenderPipelineDescriptorMetal.mm >+platform/graphics/metal/GPURenderPipelineStateMetal.mm >+platform/graphics/metal/GPUTextureDescriptorMetal.mm >+platform/graphics/metal/GPUTextureMetal.mm >+ > platform/graphics/opengl/Extensions3DOpenGL.cpp > platform/graphics/opengl/Extensions3DOpenGLCommon.cpp > platform/graphics/opengl/GraphicsContext3DOpenGL.cpp >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index 49206e40216931fcd1216a9193716a4bdb4280db..fc1fa1d2ecf8e035d25482fefb759fcfa1eb5561 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -919,22 +919,22 @@ > 316BDB951E70C89700DE0D5A /* GPUFunction.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDB931E70C89700DE0D5A /* GPUFunction.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 316BDB9B1E70CBBF00DE0D5A /* GPULibrary.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDB991E70CBBF00DE0D5A /* GPULibrary.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 316BDBAA1E71FA9300DE0D5A /* GPUBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBA81E71FA9300DE0D5A /* GPUBuffer.h */; settings = {ATTRIBUTES = (Private, ); }; }; >- 316BDBB21E7354BB00DE0D5A /* GPUTexture.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBB01E7354BB00DE0D5A /* GPUTexture.h */; settings = {ATTRIBUTES = (Private, ); }; }; >- 316BDBB81E7357CB00DE0D5A /* GPUTextureDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBB61E7357CB00DE0D5A /* GPUTextureDescriptor.h */; settings = {ATTRIBUTES = (Private, ); }; }; >+ 316BDBB21E7354BB00DE0D5A /* GPUTexture.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBB01E7354BB00DE0D5A /* GPUTexture.h */; }; >+ 316BDBB81E7357CB00DE0D5A /* GPUTextureDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBB61E7357CB00DE0D5A /* GPUTextureDescriptor.h */; }; > 316BDBBC1E73880600DE0D5A /* GPUCommandQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBBA1E73880600DE0D5A /* GPUCommandQueue.h */; settings = {ATTRIBUTES = (Private, ); }; }; >- 316BDBCD1E75F18400DE0D5A /* GPUDrawable.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBCB1E75F17600DE0D5A /* GPUDrawable.h */; settings = {ATTRIBUTES = (Private, ); }; }; >- 316BDBCE1E75F18A00DE0D5A /* GPUCommandBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBC51E75EE2400DE0D5A /* GPUCommandBuffer.h */; settings = {ATTRIBUTES = (Private, ); }; }; >- 316BDBD31E75F7B600DE0D5A /* GPURenderPassDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBD11E75F7AE00DE0D5A /* GPURenderPassDescriptor.h */; settings = {ATTRIBUTES = (Private, ); }; }; >- 316BDBDB1E7612E200DE0D5A /* GPURenderPassColorAttachmentDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBD91E7612DB00DE0D5A /* GPURenderPassColorAttachmentDescriptor.h */; settings = {ATTRIBUTES = (Private, ); }; }; >+ 316BDBCD1E75F18400DE0D5A /* GPUDrawable.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBCB1E75F17600DE0D5A /* GPUDrawable.h */; }; >+ 316BDBCE1E75F18A00DE0D5A /* GPUCommandBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBC51E75EE2400DE0D5A /* GPUCommandBuffer.h */; }; >+ 316BDBD31E75F7B600DE0D5A /* GPURenderPassDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBD11E75F7AE00DE0D5A /* GPURenderPassDescriptor.h */; }; >+ 316BDBDB1E7612E200DE0D5A /* GPURenderPassColorAttachmentDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBD91E7612DB00DE0D5A /* GPURenderPassColorAttachmentDescriptor.h */; }; > 316BDBDF1E76137500DE0D5A /* GPURenderPassAttachmentDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBDD1E76136C00DE0D5A /* GPURenderPassAttachmentDescriptor.h */; }; >- 316BDBE41E761F0500DE0D5A /* GPURenderPassDepthAttachmentDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBE31E761EFF00DE0D5A /* GPURenderPassDepthAttachmentDescriptor.h */; settings = {ATTRIBUTES = (Private, ); }; }; >- 316BDBEB1E76244D00DE0D5A /* GPURenderCommandEncoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBE91E76244400DE0D5A /* GPURenderCommandEncoder.h */; settings = {ATTRIBUTES = (Private, ); }; }; >- 316BDBF01E76292000DE0D5A /* GPUDepthStencilState.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBEF1E76291B00DE0D5A /* GPUDepthStencilState.h */; settings = {ATTRIBUTES = (Private, ); }; }; >- 316BDBF71E762AD500DE0D5A /* GPUDepthStencilDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBF51E762ACD00DE0D5A /* GPUDepthStencilDescriptor.h */; settings = {ATTRIBUTES = (Private, ); }; }; >- 316BDBFB1E762D0400DE0D5A /* GPUEnums.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBFA1E762D0400DE0D5A /* GPUEnums.h */; settings = {ATTRIBUTES = (Private, ); }; }; >- 316BDC021E762F6400DE0D5A /* GPURenderPipelineDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBFD1E762F5700DE0D5A /* GPURenderPipelineDescriptor.h */; settings = {ATTRIBUTES = (Private, ); }; }; >- 316BDC031E762F6900DE0D5A /* GPURenderPipelineState.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBFF1E762F5700DE0D5A /* GPURenderPipelineState.h */; settings = {ATTRIBUTES = (Private, ); }; }; >- 316BDC0D1E7634D200DE0D5A /* GPURenderPipelineColorAttachmentDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDC091E76342700DE0D5A /* GPURenderPipelineColorAttachmentDescriptor.h */; settings = {ATTRIBUTES = (Private, ); }; }; >+ 316BDBE41E761F0500DE0D5A /* GPURenderPassDepthAttachmentDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBE31E761EFF00DE0D5A /* GPURenderPassDepthAttachmentDescriptor.h */; }; >+ 316BDBEB1E76244D00DE0D5A /* GPURenderCommandEncoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBE91E76244400DE0D5A /* GPURenderCommandEncoder.h */; }; >+ 316BDBF01E76292000DE0D5A /* GPUDepthStencilState.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBEF1E76291B00DE0D5A /* GPUDepthStencilState.h */; }; >+ 316BDBF71E762AD500DE0D5A /* GPUDepthStencilDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBF51E762ACD00DE0D5A /* GPUDepthStencilDescriptor.h */; }; >+ 316BDBFB1E762D0400DE0D5A /* GPUEnums.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBFA1E762D0400DE0D5A /* GPUEnums.h */; }; >+ 316BDC021E762F6400DE0D5A /* GPURenderPipelineDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBFD1E762F5700DE0D5A /* GPURenderPipelineDescriptor.h */; }; >+ 316BDC031E762F6900DE0D5A /* GPURenderPipelineState.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBFF1E762F5700DE0D5A /* GPURenderPipelineState.h */; }; >+ 316BDC0D1E7634D200DE0D5A /* GPURenderPipelineColorAttachmentDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDC091E76342700DE0D5A /* GPURenderPipelineColorAttachmentDescriptor.h */; }; > 316DCB201E78CA55001B5F87 /* JSRTCOfferAnswerOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 316DCB1A1E78CA55001B5F87 /* JSRTCOfferAnswerOptions.h */; }; > 316DCB221E78CA55001B5F87 /* JSRTCRtpTransceiverDirection.h in Headers */ = {isa = PBXBuildFile; fileRef = 316DCB1C1E78CA55001B5F87 /* JSRTCRtpTransceiverDirection.h */; }; > 316DCB4C1E7910A6001B5F87 /* JSRTCIceConnectionState.h in Headers */ = {isa = PBXBuildFile; fileRef = 316DCB461E7910A6001B5F87 /* JSRTCIceConnectionState.h */; }; >@@ -2597,6 +2597,9 @@ > 93A806171E03B51C008A1F26 /* LongRange.h in Headers */ = {isa = PBXBuildFile; fileRef = 93A806131E03B51C008A1F26 /* LongRange.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 93A8061E1E03B585008A1F26 /* JSDoubleRange.h in Headers */ = {isa = PBXBuildFile; fileRef = 93A8061A1E03B585008A1F26 /* JSDoubleRange.h */; }; > 93A806201E03B585008A1F26 /* JSLongRange.h in Headers */ = {isa = PBXBuildFile; fileRef = 93A8061C1E03B585008A1F26 /* JSLongRange.h */; }; >+ 93A953B020EBD3C900A619F6 /* GPUComputePipelineState.h in Headers */ = {isa = PBXBuildFile; fileRef = 381E35EC1E8E23E40043E850 /* GPUComputePipelineState.h */; }; >+ 93A953B420EBD43200A619F6 /* GPUComputeCommandEncoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 381E35EA1E8E20D90043E850 /* GPUComputeCommandEncoder.h */; }; >+ 93A953B520EC9C3F00A619F6 /* GPUSize.h in Headers */ = {isa = PBXBuildFile; fileRef = 381E35F61E8E4D0E0043E850 /* GPUSize.h */; }; > 93B2D8160F9920D2006AE6B2 /* SuddenTermination.h in Headers */ = {isa = PBXBuildFile; fileRef = 93B2D8150F9920D2006AE6B2 /* SuddenTermination.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 93B6A0E60B0BCA5C00F5027A /* ContextMenu.h in Headers */ = {isa = PBXBuildFile; fileRef = 93B6A0E50B0BCA5C00F5027A /* ContextMenu.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 93B70D6409EB0C7C009D8468 /* JSDOMBinding.h in Headers */ = {isa = PBXBuildFile; fileRef = 93B70D4809EB0C7C009D8468 /* JSDOMBinding.h */; settings = {ATTRIBUTES = (Private, ); }; }; >@@ -5696,14 +5699,14 @@ > 0FDF45A81BD1C82500E4FA8C /* TimingFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TimingFunction.cpp; sourceTree = "<group>"; }; > 0FE5806119327A6200DE32EB /* ScrollingTreeMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollingTreeMac.cpp; sourceTree = "<group>"; }; > 0FE5806219327A6200DE32EB /* ScrollingTreeMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollingTreeMac.h; sourceTree = "<group>"; }; >- 0FE5FBCA1C3DD51E0007A2CA /* DisplayList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DisplayList.cpp; path = displaylists/DisplayList.cpp; sourceTree = "<group>"; }; >- 0FE5FBCB1C3DD51E0007A2CA /* DisplayList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DisplayList.h; path = displaylists/DisplayList.h; sourceTree = "<group>"; }; >- 0FE5FBCC1C3DD51E0007A2CA /* DisplayListItems.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DisplayListItems.cpp; path = displaylists/DisplayListItems.cpp; sourceTree = "<group>"; }; >- 0FE5FBCD1C3DD51E0007A2CA /* DisplayListItems.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DisplayListItems.h; path = displaylists/DisplayListItems.h; sourceTree = "<group>"; }; >- 0FE5FBCE1C3DD51E0007A2CA /* DisplayListRecorder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DisplayListRecorder.cpp; path = displaylists/DisplayListRecorder.cpp; sourceTree = "<group>"; }; >- 0FE5FBCF1C3DD51E0007A2CA /* DisplayListRecorder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DisplayListRecorder.h; path = displaylists/DisplayListRecorder.h; sourceTree = "<group>"; }; >- 0FE5FBD01C3DD51E0007A2CA /* DisplayListReplayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DisplayListReplayer.cpp; path = displaylists/DisplayListReplayer.cpp; sourceTree = "<group>"; }; >- 0FE5FBD11C3DD51E0007A2CA /* DisplayListReplayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DisplayListReplayer.h; path = displaylists/DisplayListReplayer.h; sourceTree = "<group>"; }; >+ 0FE5FBCA1C3DD51E0007A2CA /* DisplayList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayList.cpp; sourceTree = "<group>"; }; >+ 0FE5FBCB1C3DD51E0007A2CA /* DisplayList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisplayList.h; sourceTree = "<group>"; }; >+ 0FE5FBCC1C3DD51E0007A2CA /* DisplayListItems.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayListItems.cpp; sourceTree = "<group>"; }; >+ 0FE5FBCD1C3DD51E0007A2CA /* DisplayListItems.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisplayListItems.h; sourceTree = "<group>"; }; >+ 0FE5FBCE1C3DD51E0007A2CA /* DisplayListRecorder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayListRecorder.cpp; sourceTree = "<group>"; }; >+ 0FE5FBCF1C3DD51E0007A2CA /* DisplayListRecorder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisplayListRecorder.h; sourceTree = "<group>"; }; >+ 0FE5FBD01C3DD51E0007A2CA /* DisplayListReplayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayListReplayer.cpp; sourceTree = "<group>"; }; >+ 0FE5FBD11C3DD51E0007A2CA /* DisplayListReplayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisplayListReplayer.h; sourceTree = "<group>"; }; > 0FE6C76B1FBFB7A60025C053 /* ColorUtilities.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ColorUtilities.cpp; sourceTree = "<group>"; }; > 0FE6C76C1FBFB7A60025C053 /* ColorUtilities.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ColorUtilities.h; sourceTree = "<group>"; }; > 0FE71403142170B800DB33BA /* ScrollbarThemeMock.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollbarThemeMock.cpp; sourceTree = "<group>"; }; >@@ -13054,7 +13057,6 @@ > C280B3FD1EF4608900D35135 /* FontFamilySpecificationNull.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontFamilySpecificationNull.cpp; sourceTree = "<group>"; }; > C2AB0AF41E6B3C6C001348C5 /* FontSelectionAlgorithm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontSelectionAlgorithm.cpp; sourceTree = "<group>"; }; > C2AB0AF51E6B3C6C001348C5 /* FontSelectionAlgorithm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontSelectionAlgorithm.h; sourceTree = "<group>"; }; >- C2AB0B021E6DE32B001348C5 /* FontSelectionKeywordValues.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontSelectionKeywordValues.h; sourceTree = "<group>"; }; > C2AB0B031E6DE92C001348C5 /* FontSelectionValueInlines.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontSelectionValueInlines.h; sourceTree = "<group>"; }; > C2C2CF551EF3761A004281A8 /* FontFamilySpecificationNull.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontFamilySpecificationNull.h; sourceTree = "<group>"; }; > C2E38EFB1E8396FD00CA3ADF /* CSSFontStyleValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSFontStyleValue.cpp; sourceTree = "<group>"; }; >@@ -13243,28 +13245,28 @@ > CD669D671D232E10004D1866 /* MediaSessionManagerMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaSessionManagerMac.h; sourceTree = "<group>"; }; > CD78A2EC1F75648600DE371B /* CDMInstanceFairPlayStreamingAVFObjC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CDMInstanceFairPlayStreamingAVFObjC.mm; sourceTree = "<group>"; }; > CD78A2EE1F75648600DE371B /* CDMInstanceFairPlayStreamingAVFObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDMInstanceFairPlayStreamingAVFObjC.h; sourceTree = "<group>"; }; >- CD7D33411C7A123F00041293 /* PixelBufferConformerCV.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PixelBufferConformerCV.cpp; path = ../cv/PixelBufferConformerCV.cpp; sourceTree = "<group>"; }; >- CD7D33421C7A123F00041293 /* PixelBufferConformerCV.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PixelBufferConformerCV.h; path = ../cv/PixelBufferConformerCV.h; sourceTree = "<group>"; }; >+ CD7D33411C7A123F00041293 /* PixelBufferConformerCV.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PixelBufferConformerCV.cpp; sourceTree = "<group>"; }; >+ CD7D33421C7A123F00041293 /* PixelBufferConformerCV.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PixelBufferConformerCV.h; sourceTree = "<group>"; }; > CD7D33451C7A16BF00041293 /* CoreVideoSoftLink.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CoreVideoSoftLink.cpp; sourceTree = "<group>"; }; > CD7D33461C7A16BF00041293 /* CoreVideoSoftLink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CoreVideoSoftLink.h; sourceTree = "<group>"; }; > CD7DBB2618CA11FF00C11066 /* CSSGridLineNamesValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSGridLineNamesValue.cpp; sourceTree = "<group>"; }; > CD7DBB2718CA11FF00C11066 /* CSSGridLineNamesValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSGridLineNamesValue.h; sourceTree = "<group>"; }; > CD7E05201651A84100C1201F /* WebCoreAVFResourceLoader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebCoreAVFResourceLoader.h; sourceTree = "<group>"; }; > CD7E05211651A84100C1201F /* WebCoreAVFResourceLoader.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreAVFResourceLoader.mm; sourceTree = "<group>"; }; >- CD871C5C1FB52B6300F0B965 /* ISOSchemeTypeBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ISOSchemeTypeBox.h; path = platform/graphics/iso/ISOSchemeTypeBox.h; sourceTree = SOURCE_ROOT; }; >- CD871C5E1FB52B6400F0B965 /* ISOProtectionSchemeInfoBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ISOProtectionSchemeInfoBox.cpp; path = platform/graphics/iso/ISOProtectionSchemeInfoBox.cpp; sourceTree = SOURCE_ROOT; }; >- CD871C5F1FB52B6400F0B965 /* ISOSchemeTypeBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ISOSchemeTypeBox.cpp; path = platform/graphics/iso/ISOSchemeTypeBox.cpp; sourceTree = SOURCE_ROOT; }; >- CD871C601FB52B6500F0B965 /* ISOProtectionSchemeInfoBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ISOProtectionSchemeInfoBox.h; path = platform/graphics/iso/ISOProtectionSchemeInfoBox.h; sourceTree = SOURCE_ROOT; }; >- CD871C611FB52B6500F0B965 /* ISOTrackEncryptionBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ISOTrackEncryptionBox.cpp; path = platform/graphics/iso/ISOTrackEncryptionBox.cpp; sourceTree = SOURCE_ROOT; }; >- CD871C621FB52B6500F0B965 /* ISOBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ISOBox.h; path = platform/graphics/iso/ISOBox.h; sourceTree = SOURCE_ROOT; }; >- CD871C631FB52B6600F0B965 /* ISOSchemeInformationBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ISOSchemeInformationBox.cpp; path = platform/graphics/iso/ISOSchemeInformationBox.cpp; sourceTree = SOURCE_ROOT; }; >- CD871C641FB52B6700F0B965 /* ISOSchemeInformationBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ISOSchemeInformationBox.h; path = platform/graphics/iso/ISOSchemeInformationBox.h; sourceTree = SOURCE_ROOT; }; >- CD871C651FB52B6700F0B965 /* ISOVTTCue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ISOVTTCue.h; path = platform/graphics/iso/ISOVTTCue.h; sourceTree = SOURCE_ROOT; }; >- CD871C661FB52B6800F0B965 /* ISOTrackEncryptionBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ISOTrackEncryptionBox.h; path = platform/graphics/iso/ISOTrackEncryptionBox.h; sourceTree = SOURCE_ROOT; }; >- CD871C671FB52B6800F0B965 /* ISOOriginalFormatBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ISOOriginalFormatBox.h; path = platform/graphics/iso/ISOOriginalFormatBox.h; sourceTree = SOURCE_ROOT; }; >- CD871C681FB52B6900F0B965 /* ISOBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ISOBox.cpp; path = platform/graphics/iso/ISOBox.cpp; sourceTree = SOURCE_ROOT; }; >- CD871C691FB52B6900F0B965 /* ISOVTTCue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ISOVTTCue.cpp; path = platform/graphics/iso/ISOVTTCue.cpp; sourceTree = SOURCE_ROOT; }; >- CD871C6A1FB52B6A00F0B965 /* ISOOriginalFormatBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ISOOriginalFormatBox.cpp; path = platform/graphics/iso/ISOOriginalFormatBox.cpp; sourceTree = SOURCE_ROOT; }; >+ CD871C5C1FB52B6300F0B965 /* ISOSchemeTypeBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ISOSchemeTypeBox.h; sourceTree = "<group>"; }; >+ CD871C5E1FB52B6400F0B965 /* ISOProtectionSchemeInfoBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ISOProtectionSchemeInfoBox.cpp; sourceTree = "<group>"; }; >+ CD871C5F1FB52B6400F0B965 /* ISOSchemeTypeBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ISOSchemeTypeBox.cpp; sourceTree = "<group>"; }; >+ CD871C601FB52B6500F0B965 /* ISOProtectionSchemeInfoBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ISOProtectionSchemeInfoBox.h; sourceTree = "<group>"; }; >+ CD871C611FB52B6500F0B965 /* ISOTrackEncryptionBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ISOTrackEncryptionBox.cpp; sourceTree = "<group>"; }; >+ CD871C621FB52B6500F0B965 /* ISOBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ISOBox.h; sourceTree = "<group>"; }; >+ CD871C631FB52B6600F0B965 /* ISOSchemeInformationBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ISOSchemeInformationBox.cpp; sourceTree = "<group>"; }; >+ CD871C641FB52B6700F0B965 /* ISOSchemeInformationBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ISOSchemeInformationBox.h; sourceTree = "<group>"; }; >+ CD871C651FB52B6700F0B965 /* ISOVTTCue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ISOVTTCue.h; sourceTree = "<group>"; }; >+ CD871C661FB52B6800F0B965 /* ISOTrackEncryptionBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ISOTrackEncryptionBox.h; sourceTree = "<group>"; }; >+ CD871C671FB52B6800F0B965 /* ISOOriginalFormatBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ISOOriginalFormatBox.h; sourceTree = "<group>"; }; >+ CD871C681FB52B6900F0B965 /* ISOBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ISOBox.cpp; sourceTree = "<group>"; }; >+ CD871C691FB52B6900F0B965 /* ISOVTTCue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ISOVTTCue.cpp; sourceTree = "<group>"; }; >+ CD871C6A1FB52B6A00F0B965 /* ISOOriginalFormatBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ISOOriginalFormatBox.cpp; sourceTree = "<group>"; }; > CD8A7BB9197735FE00CBD643 /* AudioSourceProviderAVFObjC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AudioSourceProviderAVFObjC.mm; sourceTree = "<group>"; }; > CD8A7BBA197735FE00CBD643 /* AudioSourceProviderAVFObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioSourceProviderAVFObjC.h; sourceTree = "<group>"; }; > CD8ACA861D237AA200ECC59E /* RemoteCommandListenerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RemoteCommandListenerMac.mm; sourceTree = "<group>"; }; >@@ -13293,10 +13295,10 @@ > CD94A5D61F71CB6D00F525C5 /* CDMMessageType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDMMessageType.h; sourceTree = "<group>"; }; > CD94A5DA1F71CBB000F525C5 /* CDMClearKey.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDMClearKey.h; sourceTree = "<group>"; }; > CD94A5DB1F71CBB000F525C5 /* CDMClearKey.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CDMClearKey.cpp; sourceTree = "<group>"; }; >- CD9D82731C7AE535006FF066 /* TextureCacheCV.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TextureCacheCV.mm; path = ../cv/TextureCacheCV.mm; sourceTree = "<group>"; }; >- CD9D82741C7AE535006FF066 /* TextureCacheCV.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TextureCacheCV.h; path = ../cv/TextureCacheCV.h; sourceTree = "<group>"; }; >- CD9D82771C7B8EE1006FF066 /* VideoTextureCopierCV.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = VideoTextureCopierCV.cpp; path = ../cv/VideoTextureCopierCV.cpp; sourceTree = "<group>"; }; >- CD9D82781C7B8EE1006FF066 /* VideoTextureCopierCV.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VideoTextureCopierCV.h; path = ../cv/VideoTextureCopierCV.h; sourceTree = "<group>"; }; >+ CD9D82731C7AE535006FF066 /* TextureCacheCV.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TextureCacheCV.mm; sourceTree = "<group>"; }; >+ CD9D82741C7AE535006FF066 /* TextureCacheCV.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextureCacheCV.h; sourceTree = "<group>"; }; >+ CD9D82771C7B8EE1006FF066 /* VideoTextureCopierCV.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VideoTextureCopierCV.cpp; sourceTree = "<group>"; }; >+ CD9D82781C7B8EE1006FF066 /* VideoTextureCopierCV.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoTextureCopierCV.h; sourceTree = "<group>"; }; > CD9DE17217AAC74C00EA386D /* JSMediaSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMediaSource.cpp; sourceTree = "<group>"; }; > CD9DE17317AAC74C00EA386D /* JSMediaSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMediaSource.h; sourceTree = "<group>"; }; > CD9DE17617AAC75B00EA386D /* JSSourceBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSourceBuffer.cpp; sourceTree = "<group>"; }; >@@ -15711,7 +15713,7 @@ > 0FE5FBD01C3DD51E0007A2CA /* DisplayListReplayer.cpp */, > 0FE5FBD11C3DD51E0007A2CA /* DisplayListReplayer.h */, > ); >- name = displaylists; >+ path = displaylists; > sourceTree = "<group>"; > }; > 115CFA66208AF720001E6991 /* layout */ = { >@@ -20352,6 +20354,34 @@ > path = filters; > sourceTree = "<group>"; > }; >+ 9368C49120F9B57200434D61 /* metal */ = { >+ isa = PBXGroup; >+ children = ( >+ 316BDBA51E71FA6F00DE0D5A /* GPUBufferMetal.mm */, >+ 316BDBC61E75EE3D00DE0D5A /* GPUCommandBufferMetal.mm */, >+ 316BDBBD1E73881300DE0D5A /* GPUCommandQueueMetal.mm */, >+ 381E35E91E8E20AC0043E850 /* GPUComputeCommandEncoderMetal.mm */, >+ 381E35EE1E8E24CB0043E850 /* GPUComputePipelineStateMetal.mm */, >+ 316BDBF81E762BEF00DE0D5A /* GPUDepthStencilDescriptorMetal.mm */, >+ 316BDBF21E76293700DE0D5A /* GPUDepthStencilStateMetal.mm */, >+ 316BDB881E6E141C00DE0D5A /* GPUDeviceMetal.mm */, >+ 316BDBC91E75F16200DE0D5A /* GPUDrawableMetal.mm */, >+ 316BDB961E70CA2400DE0D5A /* GPUFunctionMetal.mm */, >+ 316BDB9C1E70CD9000DE0D5A /* GPULibraryMetal.mm */, >+ 316BDBEC1E76246B00DE0D5A /* GPURenderCommandEncoderMetal.mm */, >+ 316BDBE01E761CB500DE0D5A /* GPURenderPassAttachmentDescriptorMetal.mm */, >+ 316BDBD61E7612C400DE0D5A /* GPURenderPassColorAttachmentDescriptorMetal.mm */, >+ 316BDBE61E761F2700DE0D5A /* GPURenderPassDepthAttachmentDescriptorMetal.mm */, >+ 316BDBD41E75F7CA00DE0D5A /* GPURenderPassDescriptorMetal.mm */, >+ 316BDC0A1E76343600DE0D5A /* GPURenderPipelineColorAttachmentDescriptorMetal.mm */, >+ 316BDC041E762F7E00DE0D5A /* GPURenderPipelineDescriptorMetal.mm */, >+ 316BDC051E762F7E00DE0D5A /* GPURenderPipelineStateMetal.mm */, >+ 316BDBB31E7357B000DE0D5A /* GPUTextureDescriptorMetal.mm */, >+ 316BDBAD1E73549C00DE0D5A /* GPUTextureMetal.mm */, >+ ); >+ path = metal; >+ sourceTree = "<group>"; >+ }; > 93A1EAA20A5634D8006960A0 /* mac */ = { > isa = PBXGroup; > children = ( >@@ -23554,6 +23584,7 @@ > 441AF0A70EBA7BBF0044ED4B /* ios */, > CD892F5A1FB52ACF009333D2 /* iso */, > B27535490B053814002CE64F /* mac */, >+ 9368C49120F9B57200434D61 /* metal */, > FBC220DD1237FBEB00BCF788 /* opengl */, > 3721493318F0B6D600156EDC /* opentype */, > 49E911B20EF86D27009D0CAF /* transforms */, >@@ -23620,7 +23651,6 @@ > 371F4FFA0D25E7F300ECE0D5 /* FontRanges.h */, > C2AB0AF41E6B3C6C001348C5 /* FontSelectionAlgorithm.cpp */, > C2AB0AF51E6B3C6C001348C5 /* FontSelectionAlgorithm.h */, >- C2AB0B021E6DE32B001348C5 /* FontSelectionKeywordValues.h */, > B2C3DA5A0D006CD600EF6F26 /* FontSelector.h */, > E419041E1CC6486B00C35F5D /* FontSelectorClient.h */, > 4A6E9FC513C17D570046A7F8 /* FontTaggedSettings.cpp */, >@@ -23867,27 +23897,6 @@ > 1C12AC281EE778AE0079E0A0 /* FontFamilySpecificationCoreText.cpp */, > 1C12AC291EE778AE0079E0A0 /* FontFamilySpecificationCoreText.h */, > B5320D6A122A24E9002D1440 /* FontPlatformDataCocoa.mm */, >- 316BDBA51E71FA6F00DE0D5A /* GPUBufferMetal.mm */, >- 316BDBC61E75EE3D00DE0D5A /* GPUCommandBufferMetal.mm */, >- 316BDBBD1E73881300DE0D5A /* GPUCommandQueueMetal.mm */, >- 381E35E91E8E20AC0043E850 /* GPUComputeCommandEncoderMetal.mm */, >- 381E35EE1E8E24CB0043E850 /* GPUComputePipelineStateMetal.mm */, >- 316BDBF81E762BEF00DE0D5A /* GPUDepthStencilDescriptorMetal.mm */, >- 316BDBF21E76293700DE0D5A /* GPUDepthStencilStateMetal.mm */, >- 316BDB881E6E141C00DE0D5A /* GPUDeviceMetal.mm */, >- 316BDBC91E75F16200DE0D5A /* GPUDrawableMetal.mm */, >- 316BDB961E70CA2400DE0D5A /* GPUFunctionMetal.mm */, >- 316BDB9C1E70CD9000DE0D5A /* GPULibraryMetal.mm */, >- 316BDBEC1E76246B00DE0D5A /* GPURenderCommandEncoderMetal.mm */, >- 316BDBE01E761CB500DE0D5A /* GPURenderPassAttachmentDescriptorMetal.mm */, >- 316BDBD61E7612C400DE0D5A /* GPURenderPassColorAttachmentDescriptorMetal.mm */, >- 316BDBE61E761F2700DE0D5A /* GPURenderPassDepthAttachmentDescriptorMetal.mm */, >- 316BDBD41E75F7CA00DE0D5A /* GPURenderPassDescriptorMetal.mm */, >- 316BDC0A1E76343600DE0D5A /* GPURenderPipelineColorAttachmentDescriptorMetal.mm */, >- 316BDC041E762F7E00DE0D5A /* GPURenderPipelineDescriptorMetal.mm */, >- 316BDC051E762F7E00DE0D5A /* GPURenderPipelineStateMetal.mm */, >- 316BDBB31E7357B000DE0D5A /* GPUTextureDescriptorMetal.mm */, >- 316BDBAD1E73549C00DE0D5A /* GPUTextureMetal.mm */, > 49FFBF1C11C8550E006A7118 /* GraphicsContext3DCocoa.mm */, > B277B4030B22F37C0004BEC6 /* GraphicsContextCocoa.mm */, > 2D0B4AA918DA1CCD00434DE1 /* IOSurface.h */, >@@ -24686,8 +24695,7 @@ > CD871C691FB52B6900F0B965 /* ISOVTTCue.cpp */, > CD871C651FB52B6700F0B965 /* ISOVTTCue.h */, > ); >- name = iso; >- path = "New Group"; >+ path = iso; > sourceTree = "<group>"; > }; > CD94A5CB1F71CB4600F525C5 /* encryptedmedia */ = { >@@ -24742,8 +24750,7 @@ > CD9D82771C7B8EE1006FF066 /* VideoTextureCopierCV.cpp */, > CD9D82781C7B8EE1006FF066 /* VideoTextureCopierCV.h */, > ); >- name = cv; >- path = cg; >+ path = cv; > sourceTree = "<group>"; > }; > CDA98DBD16014E0800FEA3B1 /* encryptedmedia */ = { >@@ -28057,6 +28064,8 @@ > 316BDBAA1E71FA9300DE0D5A /* GPUBuffer.h in Headers */, > 316BDBCE1E75F18A00DE0D5A /* GPUCommandBuffer.h in Headers */, > 316BDBBC1E73880600DE0D5A /* GPUCommandQueue.h in Headers */, >+ 93A953B420EBD43200A619F6 /* GPUComputeCommandEncoder.h in Headers */, >+ 93A953B020EBD3C900A619F6 /* GPUComputePipelineState.h in Headers */, > 316BDBF71E762AD500DE0D5A /* GPUDepthStencilDescriptor.h in Headers */, > 316BDBF01E76292000DE0D5A /* GPUDepthStencilState.h in Headers */, > 316BDB861E6E0A2700DE0D5A /* GPUDevice.h in Headers */, >@@ -28072,6 +28081,7 @@ > 316BDC0D1E7634D200DE0D5A /* GPURenderPipelineColorAttachmentDescriptor.h in Headers */, > 316BDC021E762F6400DE0D5A /* GPURenderPipelineDescriptor.h in Headers */, > 316BDC031E762F6900DE0D5A /* GPURenderPipelineState.h in Headers */, >+ 93A953B520EC9C3F00A619F6 /* GPUSize.h in Headers */, > 316BDBB21E7354BB00DE0D5A /* GPUTexture.h in Headers */, > 316BDBB81E7357CB00DE0D5A /* GPUTextureDescriptor.h in Headers */, > BC53C5F50DA56B920021EB5D /* Gradient.h in Headers */, >diff --git a/Source/WebCore/bindings/js/JSWebGPURenderPassAttachmentDescriptorCustom.cpp b/Source/WebCore/bindings/js/JSWebGPURenderPassAttachmentDescriptorCustom.cpp >index 965b3ec452dfdc613c13e8d10af0451f21fa474f..7af643649054c3246879e847de32812d3c25eca1 100644 >--- a/Source/WebCore/bindings/js/JSWebGPURenderPassAttachmentDescriptorCustom.cpp >+++ b/Source/WebCore/bindings/js/JSWebGPURenderPassAttachmentDescriptorCustom.cpp >@@ -30,17 +30,17 @@ > > #include "JSDOMBinding.h" > #include "JSWebGPURenderPassColorAttachmentDescriptor.h" >+#include "JSWebGPURenderPassDepthAttachmentDescriptor.h" > #include "WebGPURenderPassColorAttachmentDescriptor.h" >- >+#include "WebGPURenderPassDepthAttachmentDescriptor.h" > > namespace WebCore { >-using namespace JSC; > > JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<WebGPURenderPassAttachmentDescriptor>&& object) > { > if (object->isColorAttachmentDescriptor()) > return createWrapper<WebGPURenderPassColorAttachmentDescriptor>(globalObject, WTFMove(object)); >- return createWrapper<WebGPURenderPassAttachmentDescriptor>(globalObject, WTFMove(object)); >+ return createWrapper<WebGPURenderPassDepthAttachmentDescriptor>(globalObject, WTFMove(object)); > } > > JSValue toJS(ExecState* state, JSDOMGlobalObject* globalObject, WebGPURenderPassAttachmentDescriptor& object) >diff --git a/Source/WebCore/html/canvas/WebGPUBuffer.cpp b/Source/WebCore/html/canvas/WebGPUBuffer.cpp >index 536f556db223ea5b6d9716957cc532e198350d86..75f9765e6c0dacacd3d163a28334be04349c0cd3 100644 >--- a/Source/WebCore/html/canvas/WebGPUBuffer.cpp >+++ b/Source/WebCore/html/canvas/WebGPUBuffer.cpp >@@ -28,39 +28,20 @@ > > #if ENABLE(WEBGPU) > >-#include "GPUBuffer.h" > #include "WebGPURenderingContext.h" >-#include <JavaScriptCore/ArrayBuffer.h> > > namespace WebCore { > >-Ref<WebGPUBuffer> WebGPUBuffer::create(WebGPURenderingContext* context, ArrayBufferView* data) >+RefPtr<WebGPUBuffer> WebGPUBuffer::create(WebGPURenderingContext& context, const JSC::ArrayBufferView& data) > { >+ // FIXME: Consider returning null rather than a buffer with length 0 and contents null when creation fails. > return adoptRef(*new WebGPUBuffer(context, data)); > } > >-WebGPUBuffer::WebGPUBuffer(WebGPURenderingContext* context, ArrayBufferView* data) >- : WebGPUObject(context) >+WebGPUBuffer::WebGPUBuffer(WebGPURenderingContext& context, const JSC::ArrayBufferView& data) >+ : WebGPUObject { &context } >+ , m_buffer { context.device(), data } > { >- m_buffer = context->device()->createBufferFromData(data); >-} >- >-WebGPUBuffer::~WebGPUBuffer() = default; >- >-unsigned long WebGPUBuffer::length() const >-{ >- if (!m_buffer) >- return 0; >- >- return m_buffer->length(); >-} >- >-RefPtr<ArrayBuffer> WebGPUBuffer::contents() const >-{ >- if (!m_buffer) >- return nullptr; >- >- return m_buffer->contents(); > } > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPUBuffer.h b/Source/WebCore/html/canvas/WebGPUBuffer.h >index 68bcd305816f12a26e50b793ee394e09fb7df577..ae59391b67f356e6992ee1bd0ce9a2e1ae08436f 100644 >--- a/Source/WebCore/html/canvas/WebGPUBuffer.h >+++ b/Source/WebCore/html/canvas/WebGPUBuffer.h >@@ -27,25 +27,24 @@ > > #if ENABLE(WEBGPU) > >+#include "GPUBuffer.h" > #include "WebGPUObject.h" > > namespace WebCore { > >-class GPUBuffer; >- > class WebGPUBuffer : public WebGPUObject { > public: >- virtual ~WebGPUBuffer(); >- static Ref<WebGPUBuffer> create(WebGPURenderingContext*, ArrayBufferView*); >+ static RefPtr<WebGPUBuffer> create(WebGPURenderingContext&, const JSC::ArrayBufferView&); > >- unsigned long length() const; >- RefPtr<ArrayBuffer> contents() const; >+ unsigned length() const { return m_buffer.length(); } >+ JSC::ArrayBuffer& contents() const { return *m_buffer.contents(); } > >- GPUBuffer* buffer() { return m_buffer.get(); } >+ const GPUBuffer& buffer() const { return m_buffer; } > > private: >- WebGPUBuffer(WebGPURenderingContext*, ArrayBufferView*); >- RefPtr<GPUBuffer> m_buffer; >+ WebGPUBuffer(WebGPURenderingContext&, const JSC::ArrayBufferView&); >+ >+ GPUBuffer m_buffer; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPUCommandBuffer.cpp b/Source/WebCore/html/canvas/WebGPUCommandBuffer.cpp >index 8e4ddbc1b8a793e1289ca863e5a4cde80ccb9e54..47bf01025b0171a015146c1cf00517b6baa59257 100644 >--- a/Source/WebCore/html/canvas/WebGPUCommandBuffer.cpp >+++ b/Source/WebCore/html/canvas/WebGPUCommandBuffer.cpp >@@ -32,7 +32,6 @@ > #include "GPUCommandBuffer.h" > #include "GPUCommandQueue.h" > #include "Logging.h" >-#include "WebGPUCommandQueue.h" > #include "WebGPUComputeCommandEncoder.h" > #include "WebGPUDrawable.h" > #include "WebGPURenderCommandEncoder.h" >@@ -41,16 +40,16 @@ > > namespace WebCore { > >-Ref<WebGPUCommandBuffer> WebGPUCommandBuffer::create(WebGPURenderingContext* context, WebGPUCommandQueue* queue) >+Ref<WebGPUCommandBuffer> WebGPUCommandBuffer::create(WebGPURenderingContext& context, const GPUCommandQueue& queue) > { > return adoptRef(*new WebGPUCommandBuffer(context, queue)); > } > >-WebGPUCommandBuffer::WebGPUCommandBuffer(WebGPURenderingContext* context, WebGPUCommandQueue* queue) >- : WebGPUObject(context) >+WebGPUCommandBuffer::WebGPUCommandBuffer(WebGPURenderingContext& context, const GPUCommandQueue& queue) >+ : WebGPUObject { &context } >+ , m_buffer { queue, [this] () { m_completed.resolve(); } } > { > LOG(WebGPU, "WebGPUCommandBuffer::WebGPUCommandBuffer()"); >- m_commandBuffer = queue->commandQueue()->createCommandBuffer(); > } > > WebGPUCommandBuffer::~WebGPUCommandBuffer() >@@ -61,36 +60,28 @@ WebGPUCommandBuffer::~WebGPUCommandBuffer() > void WebGPUCommandBuffer::commit() > { > LOG(WebGPU, "WebGPUCommandBuffer::commit()"); >- if (!m_commandBuffer) >- return; >- >- return m_commandBuffer->commit(); >+ m_buffer.commit(); > } > > void WebGPUCommandBuffer::presentDrawable(WebGPUDrawable& drawable) > { > LOG(WebGPU, "WebGPUCommandBuffer::presentDrawable()"); >- if (!m_commandBuffer) >- return; >- >- return m_commandBuffer->presentDrawable(drawable.drawable()); >+ m_buffer.presentDrawable(drawable.drawable()); > } > >-RefPtr<WebGPURenderCommandEncoder> WebGPUCommandBuffer::createRenderCommandEncoderWithDescriptor(WebGPURenderPassDescriptor& descriptor) >+Ref<WebGPURenderCommandEncoder> WebGPUCommandBuffer::createRenderCommandEncoderWithDescriptor(WebGPURenderPassDescriptor& descriptor) > { >- RefPtr<WebGPURenderCommandEncoder> commandEncoder = WebGPURenderCommandEncoder::create(this->context(), this, &descriptor); >- return commandEncoder; >+ return WebGPURenderCommandEncoder::create(*context(), m_buffer, descriptor.descriptor()); > } > >-RefPtr<WebGPUComputeCommandEncoder> WebGPUCommandBuffer::createComputeCommandEncoder() >+Ref<WebGPUComputeCommandEncoder> WebGPUCommandBuffer::createComputeCommandEncoder() > { >- RefPtr<WebGPUComputeCommandEncoder> commandEncoder = WebGPUComputeCommandEncoder::create(this->context(), this); >- return commandEncoder; >+ return WebGPUComputeCommandEncoder::create(*context(), m_buffer); > } > > DOMPromiseProxy<IDLVoid>& WebGPUCommandBuffer::completed() > { >- return m_commandBuffer->completed(); >+ return m_completed; > } > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPUCommandBuffer.h b/Source/WebCore/html/canvas/WebGPUCommandBuffer.h >index e8725db03419b4e832aabd31625e038216b020e1..0187614eaafeb7d7181779409260b3eba981e15f 100644 >--- a/Source/WebCore/html/canvas/WebGPUCommandBuffer.h >+++ b/Source/WebCore/html/canvas/WebGPUCommandBuffer.h >@@ -28,39 +28,37 @@ > > #if ENABLE(WEBGPU) > >+#include "GPUCommandBuffer.h" > #include "DOMPromiseProxy.h" > #include "WebGPUObject.h" > >-#include <wtf/Vector.h> >- > namespace WebCore { > >-class GPUCommandBuffer; >-class WebGPUCommandQueue; >+class WebGPUComputeCommandEncoder; > class WebGPUDrawable; >-class WebGPUFunction; > class WebGPURenderCommandEncoder; > class WebGPURenderPassDescriptor; >-class WebGPUComputeCommandEncoder; > > class WebGPUCommandBuffer : public WebGPUObject { > public: > virtual ~WebGPUCommandBuffer(); >- static Ref<WebGPUCommandBuffer> create(WebGPURenderingContext*, WebGPUCommandQueue*); >+ static Ref<WebGPUCommandBuffer> create(WebGPURenderingContext&, const GPUCommandQueue&); > > void commit(); > void presentDrawable(WebGPUDrawable&); > >- RefPtr<WebGPURenderCommandEncoder> createRenderCommandEncoderWithDescriptor(WebGPURenderPassDescriptor&); >- RefPtr<WebGPUComputeCommandEncoder> createComputeCommandEncoder(); >- >- GPUCommandBuffer* commandBuffer() { return m_commandBuffer.get(); } >+ Ref<WebGPURenderCommandEncoder> createRenderCommandEncoderWithDescriptor(WebGPURenderPassDescriptor&); >+ Ref<WebGPUComputeCommandEncoder> createComputeCommandEncoder(); > > DOMPromiseProxy<IDLVoid>& completed(); > >+ const GPUCommandBuffer& buffer() const { return m_buffer; } >+ > private: >- WebGPUCommandBuffer(WebGPURenderingContext*, WebGPUCommandQueue*); >- RefPtr<GPUCommandBuffer> m_commandBuffer; >+ WebGPUCommandBuffer(WebGPURenderingContext&, const GPUCommandQueue&); >+ >+ GPUCommandBuffer m_buffer; >+ DOMPromiseProxy<IDLVoid> m_completed; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPUCommandQueue.cpp b/Source/WebCore/html/canvas/WebGPUCommandQueue.cpp >index 5fdd9dfaa60c995d16b765d92cd5979af23d371f..ca6fdb22a19f9c5a4727a2ad04ba2b44e475bb34 100644 >--- a/Source/WebCore/html/canvas/WebGPUCommandQueue.cpp >+++ b/Source/WebCore/html/canvas/WebGPUCommandQueue.cpp >@@ -28,45 +28,27 @@ > > #if ENABLE(WEBGPU) > >-#include "GPUCommandQueue.h" > #include "WebGPUCommandBuffer.h" > #include "WebGPURenderingContext.h" > > namespace WebCore { > >-Ref<WebGPUCommandQueue> WebGPUCommandQueue::create(WebGPURenderingContext* context) >+Ref<WebGPUCommandQueue> WebGPUCommandQueue::create(WebGPURenderingContext& context) > { > return adoptRef(*new WebGPUCommandQueue(context)); > } > >-WebGPUCommandQueue::WebGPUCommandQueue(WebGPURenderingContext* context) >- : WebGPUObject(context) >+WebGPUCommandQueue::WebGPUCommandQueue(WebGPURenderingContext& context) >+ : WebGPUObject { &context } >+ , m_queue { context.device() } > { >- m_commandQueue = context->device()->createCommandQueue(); > } > > WebGPUCommandQueue::~WebGPUCommandQueue() = default; > >-String WebGPUCommandQueue::label() const >+Ref<WebGPUCommandBuffer> WebGPUCommandQueue::createCommandBuffer() > { >- if (!m_commandQueue) >- return emptyString(); >- >- return m_commandQueue->label(); >-} >- >-void WebGPUCommandQueue::setLabel(const String& label) >-{ >- if (!m_commandQueue) >- return; >- >- m_commandQueue->setLabel(label); >-} >- >-RefPtr<WebGPUCommandBuffer> WebGPUCommandQueue::createCommandBuffer() >-{ >- RefPtr<WebGPUCommandBuffer> buffer = WebGPUCommandBuffer::create(this->context(), this); >- return buffer; >+ return WebGPUCommandBuffer::create(*context(), m_queue); > } > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPUCommandQueue.h b/Source/WebCore/html/canvas/WebGPUCommandQueue.h >index b93b93c06d880a929ba483d743e566ae5b6974c9..a78fb96cf2306bd97014e0269eb976450c790128 100644 >--- a/Source/WebCore/html/canvas/WebGPUCommandQueue.h >+++ b/Source/WebCore/html/canvas/WebGPUCommandQueue.h >@@ -27,32 +27,27 @@ > > #if ENABLE(WEBGPU) > >+#include "GPUCommandQueue.h" > #include "WebGPUObject.h" > >-#include <wtf/Vector.h> >- > namespace WebCore { > >-class GPUCommandBuffer; >-class GPUCommandQueue; > class WebGPUCommandBuffer; > > class WebGPUCommandQueue : public WebGPUObject { > public: > virtual ~WebGPUCommandQueue(); >- static Ref<WebGPUCommandQueue> create(WebGPURenderingContext*); >- >- String label() const; >- void setLabel(const String&); >+ static Ref<WebGPUCommandQueue> create(WebGPURenderingContext&); > >- RefPtr<WebGPUCommandBuffer> createCommandBuffer(); >+ String label() const { return m_queue.label(); } >+ void setLabel(const String& label) { m_queue.setLabel(label); } > >- GPUCommandQueue* commandQueue() { return m_commandQueue.get(); } >+ Ref<WebGPUCommandBuffer> createCommandBuffer(); > > private: >- WebGPUCommandQueue(WebGPURenderingContext*); >+ explicit WebGPUCommandQueue(WebGPURenderingContext&); > >- RefPtr<GPUCommandQueue> m_commandQueue; >+ GPUCommandQueue m_queue; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPUCommandQueue.idl b/Source/WebCore/html/canvas/WebGPUCommandQueue.idl >index c1689b766586eecc4c0624614c8f047e927d18d0..d63cbef6256bb461c7f2e092d3ad5f01d1948787 100644 >--- a/Source/WebCore/html/canvas/WebGPUCommandQueue.idl >+++ b/Source/WebCore/html/canvas/WebGPUCommandQueue.idl >@@ -30,6 +30,6 @@ > > attribute DOMString label; > >- WebGPUCommandBuffer? createCommandBuffer(); >+ WebGPUCommandBuffer createCommandBuffer(); > > }; >diff --git a/Source/WebCore/html/canvas/WebGPUComputeCommandEncoder.cpp b/Source/WebCore/html/canvas/WebGPUComputeCommandEncoder.cpp >index 3d55ee57c14253d988fafc08a261b3584f6f8dac..297b4cc0ff6ac2f6452d775cb997aa0c57f0a8d4 100644 >--- a/Source/WebCore/html/canvas/WebGPUComputeCommandEncoder.cpp >+++ b/Source/WebCore/html/canvas/WebGPUComputeCommandEncoder.cpp >@@ -37,53 +37,43 @@ > #include "WebGPURenderingContext.h" > > namespace WebCore { >- >-inline GPUSize GPUSizeMake(WebGPUSize size) >+ >+static inline GPUSize GPUSizeMake(WebGPUSize size) > { >- return {size.width, size.height, size.depth}; >+ return { size.width, size.height, size.depth }; > } > >-Ref<WebGPUComputeCommandEncoder> WebGPUComputeCommandEncoder::create(WebGPURenderingContext* context, WebGPUCommandBuffer* buffer) >+Ref<WebGPUComputeCommandEncoder> WebGPUComputeCommandEncoder::create(WebGPURenderingContext& context, const GPUCommandBuffer& buffer) > { > return adoptRef(*new WebGPUComputeCommandEncoder(context, buffer)); > } > >-WebGPUComputeCommandEncoder::WebGPUComputeCommandEncoder(WebGPURenderingContext* context, WebGPUCommandBuffer* buffer) >- : WebGPUObject(context) >+WebGPUComputeCommandEncoder::WebGPUComputeCommandEncoder(WebGPURenderingContext& context, const GPUCommandBuffer& buffer) >+ : WebGPUObject { &context } >+ , m_encoder { buffer } > { >- m_computeCommandEncoder = buffer->commandBuffer()->createComputeCommandEncoder(); > } >- >-WebGPUComputeCommandEncoder::~WebGPUComputeCommandEncoder() = default; >- >+ > void WebGPUComputeCommandEncoder::setComputePipelineState(WebGPUComputePipelineState& pipelineState) > { >- if (!m_computeCommandEncoder) >- return; >- m_computeCommandEncoder->setComputePipelineState(pipelineState.computePipelineState()); >+ m_encoder.setComputePipelineState(pipelineState.state()); > } >- >+ > void WebGPUComputeCommandEncoder::setBuffer(WebGPUBuffer& buffer, unsigned offset, unsigned index) > { >- if (!m_computeCommandEncoder) >- return; >- m_computeCommandEncoder->setBuffer(buffer.buffer(), offset, index); >+ m_encoder.setBuffer(buffer.buffer(), offset, index); > } >- >+ > void WebGPUComputeCommandEncoder::dispatch(WebGPUSize threadgroupsPerGrid, WebGPUSize threadsPerThreadgroup) > { >- if (!m_computeCommandEncoder) >- return; >- m_computeCommandEncoder->dispatch(GPUSizeMake(threadgroupsPerGrid), GPUSizeMake(threadsPerThreadgroup)); >+ m_encoder.dispatch(GPUSizeMake(threadgroupsPerGrid), GPUSizeMake(threadsPerThreadgroup)); > } >- >+ > void WebGPUComputeCommandEncoder::endEncoding() > { >- if (!m_computeCommandEncoder) >- return; >- m_computeCommandEncoder->endEncoding(); >+ m_encoder.endEncoding(); > } >- >+ > } // namespace WebCore > > #endif >diff --git a/Source/WebCore/html/canvas/WebGPUComputeCommandEncoder.h b/Source/WebCore/html/canvas/WebGPUComputeCommandEncoder.h >index 2f37e26eda0e821bf84a3ef766c4328d1595b397..6a0c1b7d31c9dd53d4a8ca1b3c4425793208225a 100644 >--- a/Source/WebCore/html/canvas/WebGPUComputeCommandEncoder.h >+++ b/Source/WebCore/html/canvas/WebGPUComputeCommandEncoder.h >@@ -25,38 +25,30 @@ > > #pragma once > >-#include "WebGPUSize.h" >- > #if ENABLE(WEBGPU) > >+#include "GPUComputeCommandEncoder.h" > #include "WebGPUObject.h" >- >-#include <wtf/Vector.h> >+#include "WebGPUSize.h" > > namespace WebCore { > >-class GPUComputeCommandEncoder; > class WebGPUBuffer; >-class WebGPUCommandBuffer; > class WebGPUComputePipelineState; >-class WebGPURenderingContext; > > class WebGPUComputeCommandEncoder : public WebGPUObject { >- > public: >- virtual ~WebGPUComputeCommandEncoder(); >- static Ref<WebGPUComputeCommandEncoder> create(WebGPURenderingContext*, WebGPUCommandBuffer*); >+ static Ref<WebGPUComputeCommandEncoder> create(WebGPURenderingContext&, const GPUCommandBuffer&); > > void setComputePipelineState(WebGPUComputePipelineState&); > void setBuffer(WebGPUBuffer&, unsigned, unsigned); > void dispatch(WebGPUSize, WebGPUSize); > void endEncoding(); > >- GPUComputeCommandEncoder* computeCommandEncoder() { return m_computeCommandEncoder.get(); } >- > private: >- WebGPUComputeCommandEncoder(WebGPURenderingContext*, WebGPUCommandBuffer*); >- RefPtr<GPUComputeCommandEncoder> m_computeCommandEncoder; >+ WebGPUComputeCommandEncoder(WebGPURenderingContext&, const GPUCommandBuffer&); >+ >+ GPUComputeCommandEncoder m_encoder; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPUComputePipelineState.cpp b/Source/WebCore/html/canvas/WebGPUComputePipelineState.cpp >index 57c03e7b62e891ab6decff9981a558ab4355c15a..a6e8d090adb715c1885ecc8551bd1f0caa40e56e 100644 >--- a/Source/WebCore/html/canvas/WebGPUComputePipelineState.cpp >+++ b/Source/WebCore/html/canvas/WebGPUComputePipelineState.cpp >@@ -28,27 +28,19 @@ > > #if ENABLE(WEBGPU) > >-#include "GPUComputePipelineState.h" >-#include "WebGPUFunction.h" >-#include "WebGPURenderingContext.h" >- > namespace WebCore { > >-Ref<WebGPUComputePipelineState> WebGPUComputePipelineState::create(WebGPURenderingContext* context, WebGPUFunction* function) >+Ref<WebGPUComputePipelineState> WebGPUComputePipelineState::create(WebGPURenderingContext& context, const GPUFunction& function) > { > return adoptRef(*new WebGPUComputePipelineState(context, function)); > } > >-WebGPUComputePipelineState::WebGPUComputePipelineState(WebGPURenderingContext* context, WebGPUFunction* function) >- : WebGPUObject(context) >+WebGPUComputePipelineState::WebGPUComputePipelineState(WebGPURenderingContext& context, const GPUFunction& function) >+ : WebGPUObject { &context } >+ , m_state { context.device(), function } > { >- if (!context || !function) >- return; >- m_computePipelineState = GPUComputePipelineState::create(context->device().get(), function->function()); > } > >-WebGPUComputePipelineState::~WebGPUComputePipelineState() = default; >- > } // namespace WebCore > > #endif >diff --git a/Source/WebCore/html/canvas/WebGPUComputePipelineState.h b/Source/WebCore/html/canvas/WebGPUComputePipelineState.h >index 77596ff31c88b0b21cb98a6e4b5812bf4e4e86ad..c09ead0f14faf91eb76368666467c6987f68156c 100644 >--- a/Source/WebCore/html/canvas/WebGPUComputePipelineState.h >+++ b/Source/WebCore/html/canvas/WebGPUComputePipelineState.h >@@ -27,24 +27,23 @@ > > #if ENABLE(WEBGPU) > >+#include "GPUComputePipelineState.h" > #include "WebGPUObject.h" > >-#include <wtf/Vector.h> >- > namespace WebCore { > >-class GPUComputePipelineState; > class WebGPUFunction; > > class WebGPUComputePipelineState : public WebGPUObject { > public: >- virtual ~WebGPUComputePipelineState(); >- static Ref<WebGPUComputePipelineState> create(WebGPURenderingContext*, WebGPUFunction*); >- GPUComputePipelineState* computePipelineState() { return m_computePipelineState.get(); } >+ static Ref<WebGPUComputePipelineState> create(WebGPURenderingContext&, const GPUFunction&); >+ >+ GPUComputePipelineState& state() { return m_state; } > > private: >- WebGPUComputePipelineState(WebGPURenderingContext*, WebGPUFunction*); >- RefPtr<GPUComputePipelineState> m_computePipelineState; >+ WebGPUComputePipelineState(WebGPURenderingContext&, const GPUFunction&); >+ >+ GPUComputePipelineState m_state; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPUDepthStencilDescriptor.cpp b/Source/WebCore/html/canvas/WebGPUDepthStencilDescriptor.cpp >index 2b901452fb7c5ee0f011b1cc3cd4f9ac345a512e..3cb359910abf7bdae9911ffe2684647d99832621 100644 >--- a/Source/WebCore/html/canvas/WebGPUDepthStencilDescriptor.cpp >+++ b/Source/WebCore/html/canvas/WebGPUDepthStencilDescriptor.cpp >@@ -28,41 +28,26 @@ > > #if ENABLE(WEBGPU) > >-#include "GPUDepthStencilDescriptor.h" > #include "WebGPURenderingContext.h" > > namespace WebCore { > > Ref<WebGPUDepthStencilDescriptor> WebGPUDepthStencilDescriptor::create() > { >- return adoptRef(*new WebGPUDepthStencilDescriptor()); >+ return adoptRef(*new WebGPUDepthStencilDescriptor); > } > >-WebGPUDepthStencilDescriptor::WebGPUDepthStencilDescriptor() >- : WebGPUObject() >-{ >- m_depthStencilDescriptor = GPUDepthStencilDescriptor::create(); >-} >- >-WebGPUDepthStencilDescriptor::~WebGPUDepthStencilDescriptor() = default; >- > bool WebGPUDepthStencilDescriptor::depthWriteEnabled() const > { >- if (!m_depthStencilDescriptor) >- return false; >- >- return m_depthStencilDescriptor->depthWriteEnabled(); >+ return m_descriptor.depthWriteEnabled(); > } > > void WebGPUDepthStencilDescriptor::setDepthWriteEnabled(bool newDepthWriteEnabled) > { >- if (!m_depthStencilDescriptor) >- return; >- >- m_depthStencilDescriptor->setDepthWriteEnabled(newDepthWriteEnabled); >+ m_descriptor.setDepthWriteEnabled(newDepthWriteEnabled); > } > >-auto WebGPUDepthStencilDescriptor::depthCompareFunction() const -> WebGPUCompareFunction >+WebGPUCompareFunction WebGPUDepthStencilDescriptor::depthCompareFunction() const > { > return m_depthCompareFunction; > } >@@ -70,7 +55,7 @@ auto WebGPUDepthStencilDescriptor::depthCompareFunction() const -> WebGPUCompare > void WebGPUDepthStencilDescriptor::setDepthCompareFunction(CompareFunction newDepthCompareFunction) > { > m_depthCompareFunction = newDepthCompareFunction; >- m_depthStencilDescriptor->setDepthCompareFunction(toGPUCompareFunction(m_depthCompareFunction)); >+ m_descriptor.setDepthCompareFunction(toGPUCompareFunction(m_depthCompareFunction)); > } > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPUDepthStencilDescriptor.h b/Source/WebCore/html/canvas/WebGPUDepthStencilDescriptor.h >index 4cdb401c1ada43211bb000b39b319db0433ba458..617474f9623d54fb4c9eade7f690983f2fc5fa5b 100644 >--- a/Source/WebCore/html/canvas/WebGPUDepthStencilDescriptor.h >+++ b/Source/WebCore/html/canvas/WebGPUDepthStencilDescriptor.h >@@ -27,18 +27,14 @@ > > #if ENABLE(WEBGPU) > >+#include "GPUDepthStencilDescriptor.h" > #include "WebGPUEnums.h" > #include "WebGPUObject.h" > >-#include <wtf/Vector.h> >- > namespace WebCore { > >-class GPUDepthStencilDescriptor; >- > class WebGPUDepthStencilDescriptor : public WebGPUObject { > public: >- virtual ~WebGPUDepthStencilDescriptor(); > static Ref<WebGPUDepthStencilDescriptor> create(); > > bool depthWriteEnabled() const; >@@ -48,13 +44,18 @@ public: > CompareFunction depthCompareFunction() const; > void setDepthCompareFunction(CompareFunction); > >- GPUDepthStencilDescriptor* depthStencilDescriptor() { return m_depthStencilDescriptor.get(); } >+ GPUDepthStencilDescriptor& descriptor() { return m_descriptor; } > > private: >- WebGPUDepthStencilDescriptor(); >+ WebGPUDepthStencilDescriptor() = default; >+ >+ // FIXME: The default value of "Always" is defined both here and in the >+ // GPUDepthStencilDescriptor class's implementation. Might be better to not >+ // store the compare function separately here, translate it instead, and then >+ // there would be no need for a default value here. > >- WebGPUCompareFunction m_depthCompareFunction; >- RefPtr<GPUDepthStencilDescriptor> m_depthStencilDescriptor; >+ WebGPUCompareFunction m_depthCompareFunction { WebGPUCompareFunction::Always }; >+ GPUDepthStencilDescriptor m_descriptor; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPUDepthStencilState.cpp b/Source/WebCore/html/canvas/WebGPUDepthStencilState.cpp >index 2de9cf64bc23011f5d1e42cf39bee573a6829b15..e7289a3ed540682cd7a027824c52a7882b2d3b1c 100644 >--- a/Source/WebCore/html/canvas/WebGPUDepthStencilState.cpp >+++ b/Source/WebCore/html/canvas/WebGPUDepthStencilState.cpp >@@ -28,41 +28,30 @@ > > #if ENABLE(WEBGPU) > >-#include "GPUDepthStencilState.h" > #include "WebGPUDepthStencilDescriptor.h" > #include "WebGPURenderingContext.h" > > namespace WebCore { > >-Ref<WebGPUDepthStencilState> WebGPUDepthStencilState::create(WebGPURenderingContext* context, WebGPUDepthStencilDescriptor* descriptor) >+Ref<WebGPUDepthStencilState> WebGPUDepthStencilState::create(WebGPURenderingContext& context, const GPUDepthStencilDescriptor& descriptor) > { > return adoptRef(*new WebGPUDepthStencilState(context, descriptor)); > } > >-WebGPUDepthStencilState::WebGPUDepthStencilState(WebGPURenderingContext* context, WebGPUDepthStencilDescriptor* descriptor) >- : WebGPUObject(context) >+WebGPUDepthStencilState::WebGPUDepthStencilState(WebGPURenderingContext& context, const GPUDepthStencilDescriptor& descriptor) >+ : WebGPUObject { &context } >+ , m_state { context.device(), descriptor } > { >- if (!context || !descriptor) >- return; >- m_depthStencilState = GPUDepthStencilState::create(context->device().get(), descriptor->depthStencilDescriptor()); > } > >-WebGPUDepthStencilState::~WebGPUDepthStencilState() = default; >- > String WebGPUDepthStencilState::label() const > { >- if (!m_depthStencilState) >- return emptyString(); >- >- return m_depthStencilState->label(); >+ return m_state.label(); > } > > void WebGPUDepthStencilState::setLabel(const String& label) > { >- if (!m_depthStencilState) >- return; >- >- m_depthStencilState->setLabel(label); >+ m_state.setLabel(label); > } > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPUDepthStencilState.h b/Source/WebCore/html/canvas/WebGPUDepthStencilState.h >index ba97b86801579a24893d5d180de4a96a41b0a5c7..9155c2da045010bcc97f6547fd127bb2d489c4a7 100644 >--- a/Source/WebCore/html/canvas/WebGPUDepthStencilState.h >+++ b/Source/WebCore/html/canvas/WebGPUDepthStencilState.h >@@ -27,29 +27,24 @@ > > #if ENABLE(WEBGPU) > >+#include "GPUDepthStencilState.h" > #include "WebGPUObject.h" > >-#include <wtf/Vector.h> >- > namespace WebCore { > >-class GPUDepthStencilState; >-class WebGPUDepthStencilDescriptor; >- > class WebGPUDepthStencilState : public WebGPUObject { > public: >- virtual ~WebGPUDepthStencilState(); >- static Ref<WebGPUDepthStencilState> create(WebGPURenderingContext*, WebGPUDepthStencilDescriptor*); >+ static Ref<WebGPUDepthStencilState> create(WebGPURenderingContext&, const GPUDepthStencilDescriptor&); > > String label() const; > void setLabel(const String&); > >- GPUDepthStencilState* depthStencilState() { return m_depthStencilState.get(); } >+ GPUDepthStencilState& state() { return m_state; } > > private: >- WebGPUDepthStencilState(WebGPURenderingContext*, WebGPUDepthStencilDescriptor*); >+ WebGPUDepthStencilState(WebGPURenderingContext&, const GPUDepthStencilDescriptor&); > >- RefPtr<GPUDepthStencilState> m_depthStencilState; >+ GPUDepthStencilState m_state; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPUDrawable.cpp b/Source/WebCore/html/canvas/WebGPUDrawable.cpp >index e1d12b9ce17775ba4771d185214ba2c307d03d17..913268d83cef722952c3a893dc2ab4c11ab48d2f 100644 >--- a/Source/WebCore/html/canvas/WebGPUDrawable.cpp >+++ b/Source/WebCore/html/canvas/WebGPUDrawable.cpp >@@ -28,39 +28,26 @@ > > #if ENABLE(WEBGPU) > >-#include "GPUDrawable.h" > #include "GPUTexture.h" > #include "WebGPURenderingContext.h" > #include "WebGPUTexture.h" > > namespace WebCore { > >-Ref<WebGPUDrawable> WebGPUDrawable::create(WebGPURenderingContext* context) >+Ref<WebGPUDrawable> WebGPUDrawable::create(WebGPURenderingContext& context) > { > return adoptRef(*new WebGPUDrawable(context)); > } > >-WebGPUDrawable::WebGPUDrawable(WebGPURenderingContext* context) >- : WebGPUObject(context) >+WebGPUDrawable::WebGPUDrawable(WebGPURenderingContext& context) >+ : WebGPUObject { &context } >+ , m_drawable { context.device() } >+ , m_texture { WebGPUTexture::createFromDrawableTexture(context, GPUTexture { m_drawable }) } > { >- m_drawable = context->device()->getFramebuffer(); >- if (!m_drawable) >- return; >- >- auto drawableTexture = GPUTexture::createFromDrawable(m_drawable.get()); >- m_texture = WebGPUTexture::createFromDrawableTexture(context, WTFMove(drawableTexture)); > } > > WebGPUDrawable::~WebGPUDrawable() = default; > >-WebGPUTexture* WebGPUDrawable::texture() >-{ >- if (!m_texture) >- return nullptr; >- >- return m_texture.get(); >-} >- > } // namespace WebCore > > #endif >diff --git a/Source/WebCore/html/canvas/WebGPUDrawable.h b/Source/WebCore/html/canvas/WebGPUDrawable.h >index bcc1f8bc6371cdd1ddda12d5be38dad8928f3967..fc520558e8b807be7218b35b8eb94f5c10288684 100644 >--- a/Source/WebCore/html/canvas/WebGPUDrawable.h >+++ b/Source/WebCore/html/canvas/WebGPUDrawable.h >@@ -27,26 +27,26 @@ > > #if ENABLE(WEBGPU) > >+#include "GPUDrawable.h" > #include "WebGPUObject.h" > > namespace WebCore { > >-class GPUDrawable; > class WebGPUTexture; > > class WebGPUDrawable : public WebGPUObject { > public: > virtual ~WebGPUDrawable(); >- static Ref<WebGPUDrawable> create(WebGPURenderingContext*); >+ static Ref<WebGPUDrawable> create(WebGPURenderingContext&); > >- WebGPUTexture* texture(); >- >- GPUDrawable* drawable() { return m_drawable.get(); } >+ GPUDrawable& drawable() { return m_drawable; } >+ WebGPUTexture& texture() { return m_texture.get(); } > > private: >- WebGPUDrawable(WebGPURenderingContext*); >- RefPtr<GPUDrawable> m_drawable; >- RefPtr<WebGPUTexture> m_texture; >+ explicit WebGPUDrawable(WebGPURenderingContext&); >+ >+ GPUDrawable m_drawable; >+ Ref<WebGPUTexture> m_texture; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPUEnums.cpp b/Source/WebCore/html/canvas/WebGPUEnums.cpp >index 2659014537dbe1d020ce7d84d8358feee4b4774f..46636ff46cfc28579533a6722f5faf7757649581 100644 >--- a/Source/WebCore/html/canvas/WebGPUEnums.cpp >+++ b/Source/WebCore/html/canvas/WebGPUEnums.cpp >@@ -55,7 +55,7 @@ std::optional<WebGPUCompareFunction> toWebGPUCompareFunction(const String& name) > return std::nullopt; > } > >-String web3DCompareFunctionName(const WebGPUCompareFunction value) >+String web3DCompareFunctionName(WebGPUCompareFunction value) > { > if (value == WebGPUCompareFunction::Never) > return "never"_s; >diff --git a/Source/WebCore/html/canvas/WebGPUEnums.h b/Source/WebCore/html/canvas/WebGPUEnums.h >index 5f9faa585c763ee12d8d0faf5696145c2467bb64..43504e5d8de226be3343388292e1e7d9f897cea3 100644 >--- a/Source/WebCore/html/canvas/WebGPUEnums.h >+++ b/Source/WebCore/html/canvas/WebGPUEnums.h >@@ -27,8 +27,8 @@ > > #if ENABLE(WEBGPU) > >+#include <wtf/Forward.h> > #include <wtf/Optional.h> >-#include <wtf/text/WTFString.h> > > namespace WebCore { > >@@ -46,8 +46,8 @@ enum class WebGPUCompareFunction { > }; > > std::optional<WebGPUCompareFunction> toWebGPUCompareFunction(const String&); >-String web3DCompareFunctionName(const WebGPUCompareFunction); >-GPUCompareFunction toGPUCompareFunction(const WebGPUCompareFunction); >+String web3DCompareFunctionName(WebGPUCompareFunction); >+GPUCompareFunction toGPUCompareFunction(WebGPUCompareFunction); > > } // namespace WebCore > >diff --git a/Source/WebCore/html/canvas/WebGPUFunction.cpp b/Source/WebCore/html/canvas/WebGPUFunction.cpp >index a7aa406208b988ff73feec0ce941bb17d6df8b07..8eab63cb466d5f9390a23ced3bbaa4d30c5168c1 100644 >--- a/Source/WebCore/html/canvas/WebGPUFunction.cpp >+++ b/Source/WebCore/html/canvas/WebGPUFunction.cpp >@@ -28,32 +28,20 @@ > > #if ENABLE(WEBGPU) > >-#include "GPUFunction.h" >-#include "GPULibrary.h" > #include "WebGPULibrary.h" > #include "WebGPURenderingContext.h" > > namespace WebCore { > >-Ref<WebGPUFunction> WebGPUFunction::create(WebGPURenderingContext* context, WebGPULibrary* library, const String& name) >+Ref<WebGPUFunction> WebGPUFunction::create(WebGPURenderingContext& context, GPUFunction&& function) > { >- return adoptRef(*new WebGPUFunction(context, library, name)); >+ return adoptRef(*new WebGPUFunction(context, WTFMove(function))); > } > >-WebGPUFunction::WebGPUFunction(WebGPURenderingContext* context, WebGPULibrary* library, const String& name) >- : WebGPUObject(context) >+WebGPUFunction::WebGPUFunction(WebGPURenderingContext& context, GPUFunction&& function) >+ : WebGPUObject { &context } >+ , m_function { WTFMove(function) } > { >- m_function = library->library()->functionWithName(name); >-} >- >-WebGPUFunction::~WebGPUFunction() = default; >- >-String WebGPUFunction::name() const >-{ >- if (!m_function) >- return emptyString(); >- >- return m_function->name(); > } > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPUFunction.h b/Source/WebCore/html/canvas/WebGPUFunction.h >index 9f17d484ab15b10d1dc321181c2250d7d8ae8d1e..153fc891819d7f6263d0d4eca283f89004ee8f3e 100644 >--- a/Source/WebCore/html/canvas/WebGPUFunction.h >+++ b/Source/WebCore/html/canvas/WebGPUFunction.h >@@ -27,26 +27,22 @@ > > #if ENABLE(WEBGPU) > >+#include "GPUFunction.h" > #include "WebGPUObject.h" > > namespace WebCore { > >-class GPUFunction; >-class WebGPULibrary; >- > class WebGPUFunction : public WebGPUObject { > public: >- virtual ~WebGPUFunction(); >- static Ref<WebGPUFunction> create(WebGPURenderingContext*, WebGPULibrary*, const String& name); >- >- String name() const; >+ static Ref<WebGPUFunction> create(WebGPURenderingContext&, GPUFunction&&); > >- GPUFunction* function() const { return m_function.get(); } >+ String name() const { return m_function.name(); } >+ const GPUFunction& function() const { return m_function; } > > private: >- WebGPUFunction(WebGPURenderingContext*, WebGPULibrary*, const String& name); >+ WebGPUFunction(WebGPURenderingContext&, GPUFunction&&); > >- RefPtr<GPUFunction> m_function; >+ GPUFunction m_function; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPULibrary.cpp b/Source/WebCore/html/canvas/WebGPULibrary.cpp >index d198edb6a53d8cb344b127ce38b9319790d075d0..6fa9e9778eb3dac18642c3593dbba02c97431a21 100644 >--- a/Source/WebCore/html/canvas/WebGPULibrary.cpp >+++ b/Source/WebCore/html/canvas/WebGPULibrary.cpp >@@ -28,59 +28,34 @@ > > #if ENABLE(WEBGPU) > >-#include "GPULibrary.h" > #include "WebGPUFunction.h" > #include "WebGPURenderingContext.h" > > namespace WebCore { > >-Ref<WebGPULibrary> WebGPULibrary::create(WebGPURenderingContext* context, const String& sourceCode) >+Ref<WebGPULibrary> WebGPULibrary::create(WebGPURenderingContext& context, const String& sourceCode) > { > return adoptRef(*new WebGPULibrary(context, sourceCode)); > } > >-WebGPULibrary::WebGPULibrary(WebGPURenderingContext* context, const String& sourceCode) >- : WebGPUObject(context) >- , m_sourceCode(sourceCode) >+WebGPULibrary::WebGPULibrary(WebGPURenderingContext& context, const String& sourceCode) >+ : WebGPUObject { &context } >+ , m_sourceCode { sourceCode } >+ , m_library { context.device(), sourceCode } > { >- m_library = context->device()->createLibrary(sourceCode); > } > >-WebGPULibrary::~WebGPULibrary() = default; >- >-String WebGPULibrary::label() const >-{ >- if (!m_library) >- return emptyString(); >- >- return m_library->label(); >-} >- >-void WebGPULibrary::setLabel(const String& label) >-{ >- if (!m_library) >- return; >- >- m_library->setLabel(label); >-} >- >-Vector<String> WebGPULibrary::functionNames() >+Vector<String> WebGPULibrary::functionNames() const > { >- if (!m_library) >- return Vector<String>(); >- >- return m_library->functionNames(); >+ return m_library.functionNames(); > } > >-RefPtr<WebGPUFunction> WebGPULibrary::functionWithName(const String& name) >+RefPtr<WebGPUFunction> WebGPULibrary::functionWithName(const String& name) const > { >- if (!m_library) >- return nullptr; >- >- RefPtr<WebGPUFunction> function = WebGPUFunction::create(this->context(), this, name); >- if (!function->function()) >+ GPUFunction function { m_library, name }; >+ if (!function) > return nullptr; >- return function; >+ return WebGPUFunction::create(*context(), WTFMove(function)); > } > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPULibrary.h b/Source/WebCore/html/canvas/WebGPULibrary.h >index b5ffab57a1bc7d913e488173a0a81a7db6e8bb29..0d2a1634e3c9efda0d42cc5a32c511d745371d4d 100644 >--- a/Source/WebCore/html/canvas/WebGPULibrary.h >+++ b/Source/WebCore/html/canvas/WebGPULibrary.h >@@ -27,36 +27,31 @@ > > #if ENABLE(WEBGPU) > >+#include "GPULibrary.h" > #include "WebGPUObject.h" > >-#include <wtf/Vector.h> >-#include <wtf/text/WTFString.h> >- > namespace WebCore { > >-class GPULibrary; > class WebGPUFunction; > > class WebGPULibrary : public WebGPUObject { > public: >- virtual ~WebGPULibrary(); >- static Ref<WebGPULibrary> create(WebGPURenderingContext*, const String& sourceCode); >+ static Ref<WebGPULibrary> create(WebGPURenderingContext&, const String& sourceCode); > >- String sourceCode() const { return m_sourceCode; } >- String label() const; >- void setLabel(const String&); >+ const String& sourceCode() const { return m_sourceCode; } > >- Vector<String> functionNames(); >+ String label() const { return m_library.label(); } >+ void setLabel(const String& label) { m_library.setLabel(label); } > >- RefPtr<WebGPUFunction> functionWithName(const String&); >+ Vector<String> functionNames() const; > >- GPULibrary* library() { return m_library.get(); } >+ RefPtr<WebGPUFunction> functionWithName(const String&) const; > > private: >- WebGPULibrary(WebGPURenderingContext*, const String& sourceCode); >+ WebGPULibrary(WebGPURenderingContext&, const String& sourceCode); > > String m_sourceCode; >- RefPtr<GPULibrary> m_library; >+ GPULibrary m_library; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPUObject.cpp b/Source/WebCore/html/canvas/WebGPUObject.cpp >index 1a68ca89b76194f1591fbe326fcd440b03781723..8acb81e9af131847a894750b6783320faeb89b89 100644 >--- a/Source/WebCore/html/canvas/WebGPUObject.cpp >+++ b/Source/WebCore/html/canvas/WebGPUObject.cpp >@@ -33,17 +33,12 @@ > namespace WebCore { > > WebGPUObject::WebGPUObject(WebGPURenderingContext* context) >- : m_context(context) >+ : m_context { context } > { > } > > WebGPUObject::~WebGPUObject() = default; > >-void WebGPUObject::deleteObject(GPUDevice*) >-{ >- m_deleted = true; >-} >- > } > > #endif >diff --git a/Source/WebCore/html/canvas/WebGPUObject.h b/Source/WebCore/html/canvas/WebGPUObject.h >index de2a73201be144af544048735dc97e52043736e7..c913003ffb1f02a0a025786a77577a0c730fb1fe 100644 >--- a/Source/WebCore/html/canvas/WebGPUObject.h >+++ b/Source/WebCore/html/canvas/WebGPUObject.h >@@ -27,9 +27,8 @@ > > #if ENABLE(WEBGPU) > >-#include "GPUDevice.h" >- > #include <wtf/RefCounted.h> >+#include <wtf/RefPtr.h> > > namespace WebCore { > >@@ -39,19 +38,15 @@ class WebGPUObject : public RefCounted<WebGPUObject> { > public: > virtual ~WebGPUObject(); > >- void deleteObject(GPUDevice*); >- bool isDeleted() const { return m_deleted; } >- >- WebGPURenderingContext* context() { return m_context.get(); } >+ WebGPURenderingContext* context() const { return m_context.get(); } > > protected: >- WebGPUObject(WebGPURenderingContext* = nullptr); >+ explicit WebGPUObject(WebGPURenderingContext* = nullptr); > > bool hasContext() const { return m_context; } > > private: > RefPtr<WebGPURenderingContext> m_context; >- bool m_deleted { false }; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPURenderCommandEncoder.cpp b/Source/WebCore/html/canvas/WebGPURenderCommandEncoder.cpp >index 6ebd674f9193b141a848f0e0a269730f6fa7f822..79ca7822423a6ba71d25e1a205cabf555859f7f4 100644 >--- a/Source/WebCore/html/canvas/WebGPURenderCommandEncoder.cpp >+++ b/Source/WebCore/html/canvas/WebGPURenderCommandEncoder.cpp >@@ -29,7 +29,6 @@ > #if ENABLE(WEBGPU) > > #include "GPUCommandBuffer.h" >-#include "GPURenderCommandEncoder.h" > #include "GPURenderPassDescriptor.h" > #include "WebGPUBuffer.h" > #include "WebGPUCommandBuffer.h" >@@ -40,64 +39,47 @@ > > namespace WebCore { > >-Ref<WebGPURenderCommandEncoder> WebGPURenderCommandEncoder::create(WebGPURenderingContext* context, WebGPUCommandBuffer* buffer, WebGPURenderPassDescriptor* descriptor) >+Ref<WebGPURenderCommandEncoder> WebGPURenderCommandEncoder::create(WebGPURenderingContext& context, const GPUCommandBuffer& buffer, const GPURenderPassDescriptor& descriptor) > { > return adoptRef(*new WebGPURenderCommandEncoder(context, buffer, descriptor)); > } > >-WebGPURenderCommandEncoder::WebGPURenderCommandEncoder(WebGPURenderingContext* context, WebGPUCommandBuffer* buffer, WebGPURenderPassDescriptor* descriptor) >- : WebGPUObject(context) >+WebGPURenderCommandEncoder::WebGPURenderCommandEncoder(WebGPURenderingContext& context, const GPUCommandBuffer& buffer, const GPURenderPassDescriptor& descriptor) >+ : WebGPUObject { &context } >+ , m_encoder { buffer, descriptor } > { >- m_renderCommandEncoder = buffer->commandBuffer()->createRenderCommandEncoder(descriptor->renderPassDescriptor()); > } > > WebGPURenderCommandEncoder::~WebGPURenderCommandEncoder() = default; > > void WebGPURenderCommandEncoder::setRenderPipelineState(WebGPURenderPipelineState& pipelineState) > { >- if (!m_renderCommandEncoder) >- return; >- >- m_renderCommandEncoder->setRenderPipelineState(pipelineState.renderPipelineState()); >+ m_encoder.setRenderPipelineState(pipelineState.state()); > } > > void WebGPURenderCommandEncoder::setDepthStencilState(WebGPUDepthStencilState& depthStencilState) > { >- if (!m_renderCommandEncoder) >- return; >- >- m_renderCommandEncoder->setDepthStencilState(depthStencilState.depthStencilState()); >+ m_encoder.setDepthStencilState(depthStencilState.state()); > } > > void WebGPURenderCommandEncoder::setVertexBuffer(WebGPUBuffer& buffer, unsigned offset, unsigned index) > { >- if (!m_renderCommandEncoder) >- return; >- >- m_renderCommandEncoder->setVertexBuffer(buffer.buffer(), offset, index); >+ m_encoder.setVertexBuffer(buffer.buffer(), offset, index); > } > > void WebGPURenderCommandEncoder::setFragmentBuffer(WebGPUBuffer& buffer, unsigned offset, unsigned index) > { >- if (!m_renderCommandEncoder) >- return; >- >- m_renderCommandEncoder->setFragmentBuffer(buffer.buffer(), offset, index); >+ m_encoder.setFragmentBuffer(buffer.buffer(), offset, index); > } > > void WebGPURenderCommandEncoder::drawPrimitives(unsigned type, unsigned start, unsigned count) > { >- if (!m_renderCommandEncoder) >- return; >- >- m_renderCommandEncoder->drawPrimitives(type, start, count); >+ m_encoder.drawPrimitives(type, start, count); > } > > void WebGPURenderCommandEncoder::endEncoding() > { >- if (!m_renderCommandEncoder) >- return; >- return m_renderCommandEncoder->endEncoding(); >+ return m_encoder.endEncoding(); > } > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPURenderCommandEncoder.h b/Source/WebCore/html/canvas/WebGPURenderCommandEncoder.h >index 66cec5974dec5a7fbee25ce3a944234f7ed936d5..f1c1aae0b4da897ea8dcd98ffc132902c90bc315 100644 >--- a/Source/WebCore/html/canvas/WebGPURenderCommandEncoder.h >+++ b/Source/WebCore/html/canvas/WebGPURenderCommandEncoder.h >@@ -27,27 +27,19 @@ > > #if ENABLE(WEBGPU) > >+#include "GPURenderCommandEncoder.h" > #include "WebGPUObject.h" > >-#include <wtf/Vector.h> >- > namespace WebCore { > >-class GPURenderCommandEncoder; >-class GPUBuffer; >-class GPURenderPipelineState; >-class GPUDepthStencilState; >-class WebGPUCommandBuffer; > class WebGPUDepthStencilState; >-class WebGPURenderPassDescriptor; >-class WebGPUFunction; > class WebGPURenderPipelineState; > class WebGPUBuffer; > > class WebGPURenderCommandEncoder : public WebGPUObject { > public: > virtual ~WebGPURenderCommandEncoder(); >- static Ref<WebGPURenderCommandEncoder> create(WebGPURenderingContext*, WebGPUCommandBuffer*, WebGPURenderPassDescriptor*); >+ static Ref<WebGPURenderCommandEncoder> create(WebGPURenderingContext&, const GPUCommandBuffer&, const GPURenderPassDescriptor&); > > void setRenderPipelineState(WebGPURenderPipelineState&); > void setDepthStencilState(WebGPUDepthStencilState&); >@@ -56,11 +48,12 @@ public: > void drawPrimitives(unsigned type, unsigned start, unsigned count); > void endEncoding(); > >- GPURenderCommandEncoder* renderCommandEncoder() { return m_renderCommandEncoder.get(); } >+ GPURenderCommandEncoder& encoder() { return m_encoder; } > > private: >- WebGPURenderCommandEncoder(WebGPURenderingContext*, WebGPUCommandBuffer*, WebGPURenderPassDescriptor*); >- RefPtr<GPURenderCommandEncoder> m_renderCommandEncoder; >+ WebGPURenderCommandEncoder(WebGPURenderingContext&, const GPUCommandBuffer&, const GPURenderPassDescriptor&); >+ >+ GPURenderCommandEncoder m_encoder; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPURenderPassAttachmentDescriptor.cpp b/Source/WebCore/html/canvas/WebGPURenderPassAttachmentDescriptor.cpp >index eab332038592023ebd9e86463603cf93321fd721..58978c6e69625f93365c6c85f1d9a94251e8bad9 100644 >--- a/Source/WebCore/html/canvas/WebGPURenderPassAttachmentDescriptor.cpp >+++ b/Source/WebCore/html/canvas/WebGPURenderPassAttachmentDescriptor.cpp >@@ -35,60 +35,47 @@ > > namespace WebCore { > >-WebGPURenderPassAttachmentDescriptor::WebGPURenderPassAttachmentDescriptor(WebGPURenderingContext* context, GPURenderPassAttachmentDescriptor* descriptor) >- : WebGPUObject(context) >- , m_renderPassAttachmentDescriptor(descriptor) >+WebGPURenderPassAttachmentDescriptor::WebGPURenderPassAttachmentDescriptor(WebGPURenderingContext& context) >+ : WebGPUObject { &context } > { > } > > WebGPURenderPassAttachmentDescriptor::~WebGPURenderPassAttachmentDescriptor() = default; > >-unsigned long WebGPURenderPassAttachmentDescriptor::loadAction() const >+unsigned WebGPURenderPassAttachmentDescriptor::loadAction() const > { >- if (!m_renderPassAttachmentDescriptor) >- return 0; // FIXME: probably a real value for unknown >- >- return m_renderPassAttachmentDescriptor->loadAction(); >+ return descriptor().loadAction(); > } > >-void WebGPURenderPassAttachmentDescriptor::setLoadAction(unsigned long newLoadAction) >+void WebGPURenderPassAttachmentDescriptor::setLoadAction(unsigned newLoadAction) > { >- if (!m_renderPassAttachmentDescriptor) >- return; >- >- m_renderPassAttachmentDescriptor->setLoadAction(newLoadAction); >+ descriptor().setLoadAction(newLoadAction); > } > >-unsigned long WebGPURenderPassAttachmentDescriptor::storeAction() const >+unsigned WebGPURenderPassAttachmentDescriptor::storeAction() const > { >- if (!m_renderPassAttachmentDescriptor) >- return 0; // FIXME: probably a real value for unknown >- >- return m_renderPassAttachmentDescriptor->storeAction(); >+ return descriptor().storeAction(); > } > >-void WebGPURenderPassAttachmentDescriptor::setStoreAction(unsigned long newStoreAction) >+void WebGPURenderPassAttachmentDescriptor::setStoreAction(unsigned newStoreAction) > { >- if (!m_renderPassAttachmentDescriptor) >- return; >- >- m_renderPassAttachmentDescriptor->setStoreAction(newStoreAction); >+ descriptor().setStoreAction(newStoreAction); > } > >-RefPtr<WebGPUTexture> WebGPURenderPassAttachmentDescriptor::texture() const >+WebGPUTexture* WebGPURenderPassAttachmentDescriptor::texture() const > { >- return m_texture; >+ return m_texture.get(); > } > >-void WebGPURenderPassAttachmentDescriptor::setTexture(RefPtr<WebGPUTexture> newTexture) >+void WebGPURenderPassAttachmentDescriptor::setTexture(RefPtr<WebGPUTexture>&& newTexture) > { >+ // FIXME: Why can't we set this to null? > if (!newTexture) > return; > >- m_texture = newTexture; >- >- if (m_renderPassAttachmentDescriptor) >- m_renderPassAttachmentDescriptor->setTexture(newTexture->texture()); >+ m_texture = WTFMove(newTexture); >+ >+ descriptor().setTexture(m_texture->texture()); > } > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPURenderPassAttachmentDescriptor.h b/Source/WebCore/html/canvas/WebGPURenderPassAttachmentDescriptor.h >index a6253f4f8e2bebf8e016739af8385393dd61b3c0..a35a32519df0353fe207c9baacd09c271ed022e9 100644 >--- a/Source/WebCore/html/canvas/WebGPURenderPassAttachmentDescriptor.h >+++ b/Source/WebCore/html/canvas/WebGPURenderPassAttachmentDescriptor.h >@@ -29,8 +29,6 @@ > > #include "WebGPUObject.h" > >-#include <wtf/Vector.h> >- > namespace WebCore { > > class GPURenderPassAttachmentDescriptor; >@@ -40,30 +38,26 @@ class WebGPURenderPassAttachmentDescriptor : public WebGPUObject { > public: > virtual ~WebGPURenderPassAttachmentDescriptor(); > >- unsigned long loadAction() const; >- void setLoadAction(unsigned long); >- >- unsigned long storeAction() const; >- void setStoreAction(unsigned long); >+ unsigned loadAction() const; >+ void setLoadAction(unsigned); > >- RefPtr<WebGPUTexture> texture() const; >- void setTexture(RefPtr<WebGPUTexture>); >+ unsigned storeAction() const; >+ void setStoreAction(unsigned); > >- GPURenderPassAttachmentDescriptor* renderPassAttachmentDescriptor() const { return m_renderPassAttachmentDescriptor.get(); } >+ WebGPUTexture* texture() const; >+ void setTexture(RefPtr<WebGPUTexture>&&); > >- virtual bool isColorAttachmentDescriptor() const { return false; } >+ virtual bool isColorAttachmentDescriptor() const = 0; > > protected: >- >- WebGPURenderPassAttachmentDescriptor(WebGPURenderingContext*, GPURenderPassAttachmentDescriptor*); >- >+ explicit WebGPURenderPassAttachmentDescriptor(WebGPURenderingContext&); > > private: >+ virtual const GPURenderPassAttachmentDescriptor& descriptor() const = 0; > >- RefPtr<GPURenderPassAttachmentDescriptor> m_renderPassAttachmentDescriptor; > RefPtr<WebGPUTexture> m_texture; > }; >- >+ > } // namespace WebCore > > #endif >diff --git a/Source/WebCore/html/canvas/WebGPURenderPassColorAttachmentDescriptor.cpp b/Source/WebCore/html/canvas/WebGPURenderPassColorAttachmentDescriptor.cpp >index 83cdda6aabf09f9c1dce2e7840246e5407ff222e..3ec3d4f58d8b27118103f685ae79d263311296d3 100644 >--- a/Source/WebCore/html/canvas/WebGPURenderPassColorAttachmentDescriptor.cpp >+++ b/Source/WebCore/html/canvas/WebGPURenderPassColorAttachmentDescriptor.cpp >@@ -28,47 +28,38 @@ > > #if ENABLE(WEBGPU) > >-#include "GPURenderPassColorAttachmentDescriptor.h" > #include "GPUTexture.h" > #include "WebGPURenderingContext.h" > #include "WebGPUTexture.h" > > namespace WebCore { > >-Ref<WebGPURenderPassColorAttachmentDescriptor> WebGPURenderPassColorAttachmentDescriptor::create(WebGPURenderingContext* context, GPURenderPassColorAttachmentDescriptor* descriptor) >+Ref<WebGPURenderPassColorAttachmentDescriptor> WebGPURenderPassColorAttachmentDescriptor::create(WebGPURenderingContext& context, GPURenderPassColorAttachmentDescriptor&& descriptor) > { >- return adoptRef(*new WebGPURenderPassColorAttachmentDescriptor(context, descriptor)); >+ return adoptRef(*new WebGPURenderPassColorAttachmentDescriptor(context, WTFMove(descriptor))); > } > >-WebGPURenderPassColorAttachmentDescriptor::WebGPURenderPassColorAttachmentDescriptor(WebGPURenderingContext* context, GPURenderPassColorAttachmentDescriptor* descriptor) >- : WebGPURenderPassAttachmentDescriptor(context, descriptor) >+WebGPURenderPassColorAttachmentDescriptor::WebGPURenderPassColorAttachmentDescriptor(WebGPURenderingContext& context, GPURenderPassColorAttachmentDescriptor&& descriptor) >+ : WebGPURenderPassAttachmentDescriptor(context) >+ , m_descriptor(WTFMove(descriptor)) > { > } > > WebGPURenderPassColorAttachmentDescriptor::~WebGPURenderPassColorAttachmentDescriptor() = default; > >-GPURenderPassColorAttachmentDescriptor* WebGPURenderPassColorAttachmentDescriptor::renderPassColorAttachmentDescriptor() const >+const GPURenderPassAttachmentDescriptor& WebGPURenderPassColorAttachmentDescriptor::descriptor() const > { >- return static_cast<GPURenderPassColorAttachmentDescriptor*>(renderPassAttachmentDescriptor()); >+ return m_descriptor; > } > > Vector<float> WebGPURenderPassColorAttachmentDescriptor::clearColor() const > { >- RefPtr<GPURenderPassColorAttachmentDescriptor> descriptor = renderPassColorAttachmentDescriptor(); >- if (!descriptor) { >- Vector<float> black = { 0.0, 0.0, 0.0, 1.0 }; >- return black; >- } >- return descriptor->clearColor(); >+ return m_descriptor.clearColor(); > } > > void WebGPURenderPassColorAttachmentDescriptor::setClearColor(const Vector<float>& newClearColor) > { >- RefPtr<GPURenderPassColorAttachmentDescriptor> descriptor = renderPassColorAttachmentDescriptor(); >- if (!descriptor) >- return; >- >- descriptor->setClearColor(newClearColor); >+ m_descriptor.setClearColor(newClearColor); > } > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPURenderPassColorAttachmentDescriptor.h b/Source/WebCore/html/canvas/WebGPURenderPassColorAttachmentDescriptor.h >index ee8971605924aef37aa89b1e8d2fa83cd8567e09..5646faa79939f2cddc1f88ec6a75af263e13ba26 100644 >--- a/Source/WebCore/html/canvas/WebGPURenderPassColorAttachmentDescriptor.h >+++ b/Source/WebCore/html/canvas/WebGPURenderPassColorAttachmentDescriptor.h >@@ -27,30 +27,26 @@ > > #if ENABLE(WEBGPU) > >-#include "WebGPUObject.h" >+#include "GPURenderPassColorAttachmentDescriptor.h" > #include "WebGPURenderPassAttachmentDescriptor.h" > >-#include <wtf/Vector.h> >- > namespace WebCore { > >-class GPURenderPassColorAttachmentDescriptor; >- > class WebGPURenderPassColorAttachmentDescriptor : public WebGPURenderPassAttachmentDescriptor { > public: > virtual ~WebGPURenderPassColorAttachmentDescriptor(); >- static Ref<WebGPURenderPassColorAttachmentDescriptor> create(WebGPURenderingContext*, GPURenderPassColorAttachmentDescriptor*); >+ static Ref<WebGPURenderPassColorAttachmentDescriptor> create(WebGPURenderingContext&, GPURenderPassColorAttachmentDescriptor&&); > > Vector<float> clearColor() const; > void setClearColor(const Vector<float>&); > >- GPURenderPassColorAttachmentDescriptor* renderPassColorAttachmentDescriptor() const; >- >- bool isColorAttachmentDescriptor() const override { return true; } >- > private: >- WebGPURenderPassColorAttachmentDescriptor(WebGPURenderingContext*, GPURenderPassColorAttachmentDescriptor*); >+ WebGPURenderPassColorAttachmentDescriptor(WebGPURenderingContext&, GPURenderPassColorAttachmentDescriptor&&); >+ >+ const GPURenderPassAttachmentDescriptor& descriptor() const final; >+ bool isColorAttachmentDescriptor() const final { return true; } > >+ GPURenderPassColorAttachmentDescriptor m_descriptor; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPURenderPassDepthAttachmentDescriptor.cpp b/Source/WebCore/html/canvas/WebGPURenderPassDepthAttachmentDescriptor.cpp >index 5c4f8347a4530a6bb77787f94dbe0c44d7b6aaa8..692167986b075c3842139a9da9a1cf4781cbf64b 100644 >--- a/Source/WebCore/html/canvas/WebGPURenderPassDepthAttachmentDescriptor.cpp >+++ b/Source/WebCore/html/canvas/WebGPURenderPassDepthAttachmentDescriptor.cpp >@@ -28,20 +28,19 @@ > > #if ENABLE(WEBGPU) > >-#include "GPURenderPassDepthAttachmentDescriptor.h" >-#include "GPUTexture.h" > #include "WebGPURenderingContext.h" > #include "WebGPUTexture.h" > > namespace WebCore { > >-Ref<WebGPURenderPassDepthAttachmentDescriptor> WebGPURenderPassDepthAttachmentDescriptor::create(WebGPURenderingContext* context, GPURenderPassDepthAttachmentDescriptor* descriptor) >+Ref<WebGPURenderPassDepthAttachmentDescriptor> WebGPURenderPassDepthAttachmentDescriptor::create(WebGPURenderingContext& context, GPURenderPassDepthAttachmentDescriptor&& descriptor) > { >- return adoptRef(*new WebGPURenderPassDepthAttachmentDescriptor(context, descriptor)); >+ return adoptRef(*new WebGPURenderPassDepthAttachmentDescriptor(context, WTFMove(descriptor))); > } > >-WebGPURenderPassDepthAttachmentDescriptor::WebGPURenderPassDepthAttachmentDescriptor(WebGPURenderingContext* context, GPURenderPassDepthAttachmentDescriptor* descriptor) >- : WebGPURenderPassAttachmentDescriptor(context, descriptor) >+WebGPURenderPassDepthAttachmentDescriptor::WebGPURenderPassDepthAttachmentDescriptor(WebGPURenderingContext& context, GPURenderPassDepthAttachmentDescriptor&& descriptor) >+ : WebGPURenderPassAttachmentDescriptor(context) >+ , m_descriptor(WTFMove(descriptor)) > { > } > >@@ -49,25 +48,17 @@ WebGPURenderPassDepthAttachmentDescriptor::~WebGPURenderPassDepthAttachmentDescr > > double WebGPURenderPassDepthAttachmentDescriptor::clearDepth() const > { >- RefPtr<GPURenderPassDepthAttachmentDescriptor> descriptor = renderPassDepthAttachmentDescriptor(); >- if (!descriptor) >- return 0; >- >- return descriptor->clearDepth(); >+ return m_descriptor.clearDepth(); > } > > void WebGPURenderPassDepthAttachmentDescriptor::setClearDepth(double newClearDepth) > { >- RefPtr<GPURenderPassDepthAttachmentDescriptor> descriptor = renderPassDepthAttachmentDescriptor(); >- if (!descriptor) >- return; >- >- descriptor->setClearDepth(newClearDepth); >+ m_descriptor.setClearDepth(newClearDepth); > } > >-GPURenderPassDepthAttachmentDescriptor* WebGPURenderPassDepthAttachmentDescriptor::renderPassDepthAttachmentDescriptor() const >+const GPURenderPassAttachmentDescriptor& WebGPURenderPassDepthAttachmentDescriptor::descriptor() const > { >- return static_cast<GPURenderPassDepthAttachmentDescriptor*>(renderPassAttachmentDescriptor()); >+ return m_descriptor; > } > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPURenderPassDepthAttachmentDescriptor.h b/Source/WebCore/html/canvas/WebGPURenderPassDepthAttachmentDescriptor.h >index 603154c6c9fff1d1486105a650455552bf92af35..a419366491662ea6154603a32bb34190388376bc 100644 >--- a/Source/WebCore/html/canvas/WebGPURenderPassDepthAttachmentDescriptor.h >+++ b/Source/WebCore/html/canvas/WebGPURenderPassDepthAttachmentDescriptor.h >@@ -27,26 +27,26 @@ > > #if ENABLE(WEBGPU) > >-#include "WebGPUObject.h" >+#include "GPURenderPassDepthAttachmentDescriptor.h" > #include "WebGPURenderPassAttachmentDescriptor.h" > > namespace WebCore { > >-class GPURenderPassDepthAttachmentDescriptor; >- >-class WebGPURenderPassDepthAttachmentDescriptor : public WebGPURenderPassAttachmentDescriptor { >+class WebGPURenderPassDepthAttachmentDescriptor final : public WebGPURenderPassAttachmentDescriptor { > public: > virtual ~WebGPURenderPassDepthAttachmentDescriptor(); >- static Ref<WebGPURenderPassDepthAttachmentDescriptor> create(WebGPURenderingContext*, GPURenderPassDepthAttachmentDescriptor*); >+ static Ref<WebGPURenderPassDepthAttachmentDescriptor> create(WebGPURenderingContext&, GPURenderPassDepthAttachmentDescriptor&&); > > double clearDepth() const; > void setClearDepth(double); > >- GPURenderPassDepthAttachmentDescriptor* renderPassDepthAttachmentDescriptor() const; >- > private: >- WebGPURenderPassDepthAttachmentDescriptor(WebGPURenderingContext*, GPURenderPassDepthAttachmentDescriptor*); >+ WebGPURenderPassDepthAttachmentDescriptor(WebGPURenderingContext&, GPURenderPassDepthAttachmentDescriptor&&); >+ >+ const GPURenderPassAttachmentDescriptor& descriptor() const final; >+ bool isColorAttachmentDescriptor() const final { return false; } > >+ GPURenderPassDepthAttachmentDescriptor m_descriptor; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPURenderPassDescriptor.cpp b/Source/WebCore/html/canvas/WebGPURenderPassDescriptor.cpp >index e7bef852c9ccde6f73f4e635a0a0356c376d47f4..4f5595ad493d40da55f90fedc077c93c5e3658d3 100644 >--- a/Source/WebCore/html/canvas/WebGPURenderPassDescriptor.cpp >+++ b/Source/WebCore/html/canvas/WebGPURenderPassDescriptor.cpp >@@ -28,51 +28,34 @@ > > #if ENABLE(WEBGPU) > >-#include "GPURenderPassColorAttachmentDescriptor.h" >-#include "GPURenderPassDepthAttachmentDescriptor.h" >-#include "GPURenderPassDescriptor.h" >-#include "WebGPURenderPassColorAttachmentDescriptor.h" >-#include "WebGPURenderPassDepthAttachmentDescriptor.h" >-#include "WebGPURenderingContext.h" >- > namespace WebCore { > > Ref<WebGPURenderPassDescriptor> WebGPURenderPassDescriptor::create() > { >- return adoptRef(*new WebGPURenderPassDescriptor()); >+ return adoptRef(*new WebGPURenderPassDescriptor); > } > >-WebGPURenderPassDescriptor::WebGPURenderPassDescriptor() >- : WebGPUObject() >-{ >- m_renderPassDescriptor = GPURenderPassDescriptor::create(); >-} >+WebGPURenderPassDescriptor::WebGPURenderPassDescriptor() = default; > > WebGPURenderPassDescriptor::~WebGPURenderPassDescriptor() = default; > >-RefPtr<WebGPURenderPassDepthAttachmentDescriptor> WebGPURenderPassDescriptor::depthAttachment() >+WebGPURenderPassDepthAttachmentDescriptor& WebGPURenderPassDescriptor::depthAttachment() > { >- if (!m_renderPassDescriptor) >- return nullptr; >- >- if (!m_depthAttachmentDescriptor) { >- RefPtr<GPURenderPassDepthAttachmentDescriptor> platformDepthAttachment = m_renderPassDescriptor->depthAttachment(); >- m_depthAttachmentDescriptor = WebGPURenderPassDepthAttachmentDescriptor::create(this->context(), platformDepthAttachment.get()); >- } >- return m_depthAttachmentDescriptor; >+ if (!m_depthAttachment) >+ m_depthAttachment = WebGPURenderPassDepthAttachmentDescriptor::create(*context(), m_descriptor.depthAttachment()); >+ return *m_depthAttachment; > } > >-Vector<RefPtr<WebGPURenderPassColorAttachmentDescriptor>> WebGPURenderPassDescriptor::colorAttachments() >+const Vector<RefPtr<WebGPURenderPassColorAttachmentDescriptor>>& WebGPURenderPassDescriptor::colorAttachments() > { >- if (!m_renderPassDescriptor) >- return Vector<RefPtr<WebGPURenderPassColorAttachmentDescriptor>>(); >- >- if (!m_colorAttachmentDescriptors.size()) { >- Vector<RefPtr<GPURenderPassColorAttachmentDescriptor>> platformColorAttachments = m_renderPassDescriptor->colorAttachments(); >- for (auto& attachment : platformColorAttachments) >- m_colorAttachmentDescriptors.append(WebGPURenderPassColorAttachmentDescriptor::create(this->context(), attachment.get())); >+ if (m_colorAttachments.isEmpty()) { >+ auto attachments = m_descriptor.colorAttachments(); >+ ASSERT(!attachments.isEmpty()); >+ m_colorAttachments.reserveInitialCapacity(attachments.size()); >+ for (auto& attachment : attachments) >+ m_colorAttachments.uncheckedAppend(WebGPURenderPassColorAttachmentDescriptor::create(*context(), WTFMove(attachment))); > } >- return m_colorAttachmentDescriptors; >+ return m_colorAttachments; > } > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPURenderPassDescriptor.h b/Source/WebCore/html/canvas/WebGPURenderPassDescriptor.h >index b9d187273a06d31f9b79cc98dae0c0b6de11f9a7..d135faff67506cad6a75d8742c680eeeeb6a99fc 100644 >--- a/Source/WebCore/html/canvas/WebGPURenderPassDescriptor.h >+++ b/Source/WebCore/html/canvas/WebGPURenderPassDescriptor.h >@@ -27,35 +27,31 @@ > > #if ENABLE(WEBGPU) > >+#include "GPURenderPassDescriptor.h" > #include "WebGPUObject.h" > #include "WebGPURenderPassColorAttachmentDescriptor.h" > #include "WebGPURenderPassDepthAttachmentDescriptor.h" >- > #include <wtf/Vector.h> > > namespace WebCore { > >-class GPURenderPassDescriptor; >-class WebGPURenderPassColorAttachmentDescriptor; >-class WebGPURenderPassDepthAttachmentDescriptor; >- > class WebGPURenderPassDescriptor : public WebGPUObject { > public: > virtual ~WebGPURenderPassDescriptor(); > static Ref<WebGPURenderPassDescriptor> create(); > >- RefPtr<WebGPURenderPassDepthAttachmentDescriptor> depthAttachment(); >- Vector<RefPtr<WebGPURenderPassColorAttachmentDescriptor>> colorAttachments(); >+ WebGPURenderPassDepthAttachmentDescriptor& depthAttachment(); >+ const Vector<RefPtr<WebGPURenderPassColorAttachmentDescriptor>>& colorAttachments(); > >- GPURenderPassDescriptor* renderPassDescriptor() { return m_renderPassDescriptor.get(); } >+ const GPURenderPassDescriptor& descriptor() const { return m_descriptor; } > > private: > WebGPURenderPassDescriptor(); > >- Vector<RefPtr<WebGPURenderPassColorAttachmentDescriptor>> m_colorAttachmentDescriptors; >- RefPtr<WebGPURenderPassDepthAttachmentDescriptor> m_depthAttachmentDescriptor; >+ Vector<RefPtr<WebGPURenderPassColorAttachmentDescriptor>> m_colorAttachments; >+ RefPtr<WebGPURenderPassDepthAttachmentDescriptor> m_depthAttachment; > >- RefPtr<GPURenderPassDescriptor> m_renderPassDescriptor; >+ GPURenderPassDescriptor m_descriptor; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPURenderPipelineColorAttachmentDescriptor.cpp b/Source/WebCore/html/canvas/WebGPURenderPipelineColorAttachmentDescriptor.cpp >index f868882b2fe9de8f9940c136cc479933996c166d..9491196026bee723b06576fe4c6b1ca49dc19c61 100644 >--- a/Source/WebCore/html/canvas/WebGPURenderPipelineColorAttachmentDescriptor.cpp >+++ b/Source/WebCore/html/canvas/WebGPURenderPipelineColorAttachmentDescriptor.cpp >@@ -28,38 +28,27 @@ > > #if ENABLE(WEBGPU) > >-#include "GPURenderPipelineColorAttachmentDescriptor.h" >-#include "WebGPURenderingContext.h" >- > namespace WebCore { > >-Ref<WebGPURenderPipelineColorAttachmentDescriptor> WebGPURenderPipelineColorAttachmentDescriptor::create(WebGPURenderingContext* context, GPURenderPipelineColorAttachmentDescriptor* descriptor) >+Ref<WebGPURenderPipelineColorAttachmentDescriptor> WebGPURenderPipelineColorAttachmentDescriptor::create(WebGPURenderingContext& context, GPURenderPipelineColorAttachmentDescriptor&& descriptor) > { >- return adoptRef(*new WebGPURenderPipelineColorAttachmentDescriptor(context, descriptor)); >+ return adoptRef(*new WebGPURenderPipelineColorAttachmentDescriptor(context, WTFMove(descriptor))); > } > >-WebGPURenderPipelineColorAttachmentDescriptor::WebGPURenderPipelineColorAttachmentDescriptor(WebGPURenderingContext* context, GPURenderPipelineColorAttachmentDescriptor* descriptor) >- : WebGPUObject(context) >- , m_renderPipelineColorAttachmentDescriptor(descriptor) >+WebGPURenderPipelineColorAttachmentDescriptor::WebGPURenderPipelineColorAttachmentDescriptor(WebGPURenderingContext& context, GPURenderPipelineColorAttachmentDescriptor&& descriptor) >+ : WebGPUObject { &context } >+ , m_descriptor { WTFMove(descriptor) } > { > } > >-WebGPURenderPipelineColorAttachmentDescriptor::~WebGPURenderPipelineColorAttachmentDescriptor() = default; >- >-unsigned long WebGPURenderPipelineColorAttachmentDescriptor::pixelFormat() const >+unsigned WebGPURenderPipelineColorAttachmentDescriptor::pixelFormat() const > { >- if (!m_renderPipelineColorAttachmentDescriptor) >- return 0; // FIXME: probably a real value for unknown >- >- return m_renderPipelineColorAttachmentDescriptor->pixelFormat(); >+ return m_descriptor.pixelFormat(); > } > >-void WebGPURenderPipelineColorAttachmentDescriptor::setPixelFormat(unsigned long newPixelFormat) >+void WebGPURenderPipelineColorAttachmentDescriptor::setPixelFormat(unsigned newPixelFormat) > { >- if (!m_renderPipelineColorAttachmentDescriptor) >- return; >- >- m_renderPipelineColorAttachmentDescriptor->setPixelFormat(newPixelFormat); >+ m_descriptor.setPixelFormat(newPixelFormat); > } > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPURenderPipelineColorAttachmentDescriptor.h b/Source/WebCore/html/canvas/WebGPURenderPipelineColorAttachmentDescriptor.h >index 7a4aaff5c487050d8b17fdb0e61f54fea5ce2ec1..12e18595b7e12ac721c3affd72f8c2a5061be7e7 100644 >--- a/Source/WebCore/html/canvas/WebGPURenderPipelineColorAttachmentDescriptor.h >+++ b/Source/WebCore/html/canvas/WebGPURenderPipelineColorAttachmentDescriptor.h >@@ -27,27 +27,22 @@ > > #if ENABLE(WEBGPU) > >+#include "GPURenderPipelineColorAttachmentDescriptor.h" > #include "WebGPUObject.h" > >- > namespace WebCore { > >-class GPURenderPipelineColorAttachmentDescriptor; >- > class WebGPURenderPipelineColorAttachmentDescriptor : public WebGPUObject { > public: >- virtual ~WebGPURenderPipelineColorAttachmentDescriptor(); >- static Ref<WebGPURenderPipelineColorAttachmentDescriptor> create(WebGPURenderingContext*, GPURenderPipelineColorAttachmentDescriptor*); >- >- unsigned long pixelFormat() const; >- void setPixelFormat(unsigned long); >+ static Ref<WebGPURenderPipelineColorAttachmentDescriptor> create(WebGPURenderingContext&, GPURenderPipelineColorAttachmentDescriptor&&); > >- GPURenderPipelineColorAttachmentDescriptor* renderPipelineColorAttachmentDescriptor() { return m_renderPipelineColorAttachmentDescriptor.get(); } >+ unsigned pixelFormat() const; >+ void setPixelFormat(unsigned); > > private: >- WebGPURenderPipelineColorAttachmentDescriptor(WebGPURenderingContext*, GPURenderPipelineColorAttachmentDescriptor*); >+ WebGPURenderPipelineColorAttachmentDescriptor(WebGPURenderingContext&, GPURenderPipelineColorAttachmentDescriptor&&); > >- RefPtr<GPURenderPipelineColorAttachmentDescriptor> m_renderPipelineColorAttachmentDescriptor; >+ GPURenderPipelineColorAttachmentDescriptor m_descriptor; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPURenderPipelineDescriptor.cpp b/Source/WebCore/html/canvas/WebGPURenderPipelineDescriptor.cpp >index be29c8ba5305008b4161809c5f26c73242755256..9eff795287cb164397053c2c09f55881d9b5ae77 100644 >--- a/Source/WebCore/html/canvas/WebGPURenderPipelineDescriptor.cpp >+++ b/Source/WebCore/html/canvas/WebGPURenderPipelineDescriptor.cpp >@@ -30,7 +30,6 @@ > > #include "GPUFunction.h" > #include "GPURenderPipelineColorAttachmentDescriptor.h" >-#include "GPURenderPipelineDescriptor.h" > #include "WebGPUFunction.h" > #include "WebGPURenderPipelineColorAttachmentDescriptor.h" > #include "WebGPURenderingContext.h" >@@ -39,83 +38,72 @@ namespace WebCore { > > Ref<WebGPURenderPipelineDescriptor> WebGPURenderPipelineDescriptor::create() > { >- return adoptRef(*new WebGPURenderPipelineDescriptor()); >+ return adoptRef(*new WebGPURenderPipelineDescriptor); > } > >-WebGPURenderPipelineDescriptor::WebGPURenderPipelineDescriptor() >- : WebGPUObject() >-{ >- m_renderPipelineDescriptor = GPURenderPipelineDescriptor::create(); >-} >+WebGPURenderPipelineDescriptor::WebGPURenderPipelineDescriptor() = default; > > WebGPURenderPipelineDescriptor::~WebGPURenderPipelineDescriptor() = default; > >-RefPtr<WebGPUFunction> WebGPURenderPipelineDescriptor::vertexFunction() const >+WebGPUFunction* WebGPURenderPipelineDescriptor::vertexFunction() const > { >- return m_vertexFunction; >+ return m_vertexFunction.get(); > } > >-void WebGPURenderPipelineDescriptor::setVertexFunction(RefPtr<WebGPUFunction> newVertexFunction) >+void WebGPURenderPipelineDescriptor::setVertexFunction(RefPtr<WebGPUFunction>&& newVertexFunction) > { >+ // FIXME: Why can't we set this to null? > if (!newVertexFunction) > return; > >- m_vertexFunction = newVertexFunction; >+ m_vertexFunction = WTFMove(newVertexFunction); > >- if (m_renderPipelineDescriptor) >- m_renderPipelineDescriptor->setVertexFunction(newVertexFunction->function()); >+ m_descriptor.setVertexFunction(m_vertexFunction->function()); > } > >-RefPtr<WebGPUFunction> WebGPURenderPipelineDescriptor::fragmentFunction() const >+WebGPUFunction* WebGPURenderPipelineDescriptor::fragmentFunction() const > { >- return m_fragmentFunction; >+ return m_fragmentFunction.get(); > } > >-void WebGPURenderPipelineDescriptor::setFragmentFunction(RefPtr<WebGPUFunction> newFragmentFunction) >+void WebGPURenderPipelineDescriptor::setFragmentFunction(RefPtr<WebGPUFunction>&& newFragmentFunction) > { >+ // FIXME: Why can't we set this to null? > if (!newFragmentFunction) > return; > >- m_fragmentFunction = newFragmentFunction; >+ m_fragmentFunction = WTFMove(newFragmentFunction); > >- if (m_renderPipelineDescriptor) >- m_renderPipelineDescriptor->setFragmentFunction(newFragmentFunction->function()); >+ m_descriptor.setFragmentFunction(m_fragmentFunction->function()); > } > >-Vector<RefPtr<WebGPURenderPipelineColorAttachmentDescriptor>> WebGPURenderPipelineDescriptor::colorAttachments() >+const Vector<RefPtr<WebGPURenderPipelineColorAttachmentDescriptor>>& WebGPURenderPipelineDescriptor::colorAttachments() > { >- if (!m_renderPipelineDescriptor) >- return Vector<RefPtr<WebGPURenderPipelineColorAttachmentDescriptor>>(); >- >- if (!m_colorAttachmentDescriptors.size()) { >- Vector<RefPtr<GPURenderPipelineColorAttachmentDescriptor>> platformColorAttachments = m_renderPipelineDescriptor->colorAttachments(); >- for (auto& attachment : platformColorAttachments) >- m_colorAttachmentDescriptors.append(WebGPURenderPipelineColorAttachmentDescriptor::create(this->context(), attachment.get())); >+ if (!m_colorAttachments.size()) { >+ auto attachments = m_descriptor.colorAttachments(); >+ m_colorAttachments.reserveInitialCapacity(attachments.size()); >+ for (auto& attachment : attachments) >+ m_colorAttachments.uncheckedAppend(WebGPURenderPipelineColorAttachmentDescriptor::create(*context(), WTFMove(attachment))); > } >- return m_colorAttachmentDescriptors; >+ return m_colorAttachments; > } > >-unsigned long WebGPURenderPipelineDescriptor::depthAttachmentPixelFormat() const >+unsigned WebGPURenderPipelineDescriptor::depthAttachmentPixelFormat() const > { >- if (!m_renderPipelineDescriptor) >- return 0; // FIXME: probably a real value for unknown >- >- return m_renderPipelineDescriptor->depthAttachmentPixelFormat(); >- >+ return m_descriptor.depthAttachmentPixelFormat(); > } > >-void WebGPURenderPipelineDescriptor::setDepthAttachmentPixelFormat(unsigned long newPixelFormat) >+void WebGPURenderPipelineDescriptor::setDepthAttachmentPixelFormat(unsigned newPixelFormat) > { >- if (!m_renderPipelineDescriptor) >- return; >- >- m_renderPipelineDescriptor->setDepthAttachmentPixelFormat(newPixelFormat); >+ m_descriptor.setDepthAttachmentPixelFormat(newPixelFormat); > } > > void WebGPURenderPipelineDescriptor::reset() > { > m_vertexFunction = nullptr; > m_fragmentFunction = nullptr; >+ >+ // FIXME: Why doesn't this clear out the functions on m_descriptor? > } > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPURenderPipelineDescriptor.h b/Source/WebCore/html/canvas/WebGPURenderPipelineDescriptor.h >index 874e3df0c10c686d10b3077db03025e41096078f..c293492d65dbd27cea05d0c02c58b107fb2de240 100644 >--- a/Source/WebCore/html/canvas/WebGPURenderPipelineDescriptor.h >+++ b/Source/WebCore/html/canvas/WebGPURenderPipelineDescriptor.h >@@ -27,9 +27,9 @@ > > #if ENABLE(WEBGPU) > >+#include "GPURenderPipelineDescriptor.h" > #include "WebGPUObject.h" > #include "WebGPURenderPipelineColorAttachmentDescriptor.h" >- > #include <wtf/Vector.h> > > namespace WebCore { >@@ -44,20 +44,20 @@ public: > virtual ~WebGPURenderPipelineDescriptor(); > static Ref<WebGPURenderPipelineDescriptor> create(); > >- RefPtr<WebGPUFunction> vertexFunction() const; >- void setVertexFunction(RefPtr<WebGPUFunction>); >+ WebGPUFunction* vertexFunction() const; >+ void setVertexFunction(RefPtr<WebGPUFunction>&&); > >- RefPtr<WebGPUFunction> fragmentFunction() const; >- void setFragmentFunction(RefPtr<WebGPUFunction>); >+ WebGPUFunction* fragmentFunction() const; >+ void setFragmentFunction(RefPtr<WebGPUFunction>&&); > >- Vector<RefPtr<WebGPURenderPipelineColorAttachmentDescriptor>> colorAttachments(); >+ const Vector<RefPtr<WebGPURenderPipelineColorAttachmentDescriptor>>& colorAttachments(); > >- unsigned long depthAttachmentPixelFormat() const; >- void setDepthAttachmentPixelFormat(unsigned long); >+ unsigned depthAttachmentPixelFormat() const; >+ void setDepthAttachmentPixelFormat(unsigned); > > void reset(); > >- GPURenderPipelineDescriptor* renderPipelineDescriptor() { return m_renderPipelineDescriptor.get(); } >+ const GPURenderPipelineDescriptor& descriptor() { return m_descriptor; } > > private: > WebGPURenderPipelineDescriptor(); >@@ -65,9 +65,9 @@ private: > RefPtr<WebGPUFunction> m_vertexFunction; > RefPtr<WebGPUFunction> m_fragmentFunction; > >- Vector<RefPtr<WebGPURenderPipelineColorAttachmentDescriptor>> m_colorAttachmentDescriptors; >+ Vector<RefPtr<WebGPURenderPipelineColorAttachmentDescriptor>> m_colorAttachments; > >- RefPtr<GPURenderPipelineDescriptor> m_renderPipelineDescriptor; >+ GPURenderPipelineDescriptor m_descriptor; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPURenderPipelineState.cpp b/Source/WebCore/html/canvas/WebGPURenderPipelineState.cpp >index e2b1afd0e90703fd67bbee443cbd6cfa7c29151d..f3c713ebb05c567d44f9cb3ea45a15075b756a75 100644 >--- a/Source/WebCore/html/canvas/WebGPURenderPipelineState.cpp >+++ b/Source/WebCore/html/canvas/WebGPURenderPipelineState.cpp >@@ -28,41 +28,30 @@ > > #if ENABLE(WEBGPU) > >-#include "GPURenderPipelineState.h" > #include "WebGPURenderPipelineDescriptor.h" > #include "WebGPURenderingContext.h" > > namespace WebCore { > >-Ref<WebGPURenderPipelineState> WebGPURenderPipelineState::create(WebGPURenderingContext* context, WebGPURenderPipelineDescriptor* descriptor) >+Ref<WebGPURenderPipelineState> WebGPURenderPipelineState::create(WebGPURenderingContext& context, const GPURenderPipelineDescriptor& descriptor) > { > return adoptRef(*new WebGPURenderPipelineState(context, descriptor)); > } > >-WebGPURenderPipelineState::WebGPURenderPipelineState(WebGPURenderingContext* context, WebGPURenderPipelineDescriptor* descriptor) >- : WebGPUObject(context) >+WebGPURenderPipelineState::WebGPURenderPipelineState(WebGPURenderingContext& context, const GPURenderPipelineDescriptor& descriptor) >+ : WebGPUObject { &context } >+ , m_state { context.device(), descriptor } > { >- if (!context || !descriptor) >- return; >- m_renderPipelineState = GPURenderPipelineState::create(context->device().get(), descriptor->renderPipelineDescriptor()); > } > >-WebGPURenderPipelineState::~WebGPURenderPipelineState() = default; >- > String WebGPURenderPipelineState::label() const > { >- if (!m_renderPipelineState) >- return emptyString(); >- >- return m_renderPipelineState->label(); >+ return m_state.label(); > } > > void WebGPURenderPipelineState::setLabel(const String& label) > { >- if (!m_renderPipelineState) >- return; >- >- m_renderPipelineState->setLabel(label); >+ m_state.setLabel(label); > } > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPURenderPipelineState.h b/Source/WebCore/html/canvas/WebGPURenderPipelineState.h >index 464c064563c5d3dede03b6292b1e679bbf980b14..f27dad8a834ce4ea0dfd669443707355b186a8fa 100644 >--- a/Source/WebCore/html/canvas/WebGPURenderPipelineState.h >+++ b/Source/WebCore/html/canvas/WebGPURenderPipelineState.h >@@ -27,29 +27,24 @@ > > #if ENABLE(WEBGPU) > >+#include "GPURenderPipelineState.h" > #include "WebGPUObject.h" > >-#include <wtf/Vector.h> >- > namespace WebCore { > >-class GPURenderPipelineState; >-class WebGPURenderPipelineDescriptor; >- > class WebGPURenderPipelineState : public WebGPUObject { > public: >- virtual ~WebGPURenderPipelineState(); >- static Ref<WebGPURenderPipelineState> create(WebGPURenderingContext*, WebGPURenderPipelineDescriptor*); >+ static Ref<WebGPURenderPipelineState> create(WebGPURenderingContext&, const GPURenderPipelineDescriptor&); > > String label() const; > void setLabel(const String&); > >- GPURenderPipelineState* renderPipelineState() { return m_renderPipelineState.get(); } >+ const GPURenderPipelineState& state() const { return m_state; } > > private: >- WebGPURenderPipelineState(WebGPURenderingContext*, WebGPURenderPipelineDescriptor*); >+ WebGPURenderPipelineState(WebGPURenderingContext&, const GPURenderPipelineDescriptor&); > >- RefPtr<GPURenderPipelineState> m_renderPipelineState; >+ GPURenderPipelineState m_state; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPURenderingContext.cpp b/Source/WebCore/html/canvas/WebGPURenderingContext.cpp >index c161aa849ad336da4e9ec206af4526667f7d7fae..fe74779476b76ef2e99491e01375eb3882c00ec9 100644 >--- a/Source/WebCore/html/canvas/WebGPURenderingContext.cpp >+++ b/Source/WebCore/html/canvas/WebGPURenderingContext.cpp >@@ -46,7 +46,6 @@ > #include "WebGPURenderPipelineState.h" > #include "WebGPUTexture.h" > #include "WebGPUTextureDescriptor.h" >- > #include <JavaScriptCore/ArrayBuffer.h> > #include <JavaScriptCore/JSCInlines.h> > #include <JavaScriptCore/TypedArrayInlines.h> >@@ -71,17 +70,16 @@ namespace WebCore { > > static const int kMaxTextureSize = 4096; > >- > std::unique_ptr<WebGPURenderingContext> WebGPURenderingContext::create(CanvasBase& canvas) > { >- RefPtr<GPUDevice> device(GPUDevice::create()); >+ GPUDevice device; > > if (!device) { > // FIXME: WebGPU - dispatch an event here for the failure. > return nullptr; > } > >- auto renderingContext = std::unique_ptr<WebGPURenderingContext>(new WebGPURenderingContext(canvas, device.releaseNonNull())); >+ auto renderingContext = std::unique_ptr<WebGPURenderingContext>(new WebGPURenderingContext(canvas, WTFMove(device))); > renderingContext->suspendIfNeeded(); > > InspectorInstrumentation::didCreateCanvasRenderingContext(*renderingContext); >@@ -89,7 +87,7 @@ std::unique_ptr<WebGPURenderingContext> WebGPURenderingContext::create(CanvasBas > return renderingContext; > } > >-WebGPURenderingContext::WebGPURenderingContext(CanvasBase& canvas, Ref<GPUDevice>&& device) >+WebGPURenderingContext::WebGPURenderingContext(CanvasBase& canvas, GPUDevice&& device) > : GPUBasedCanvasRenderingContext(canvas) > , m_device(WTFMove(device)) > { >@@ -109,7 +107,7 @@ void WebGPURenderingContext::initializeNewContext() > // FIXME: WebGPU - Maybe we should reset a bunch of stuff here. > > IntSize canvasSize = clampedCanvasSize(); >- m_device->reshape(canvasSize.width(), canvasSize.height()); >+ m_device.reshape(canvasSize.width(), canvasSize.height()); > } > > IntSize WebGPURenderingContext::clampedCanvasSize() const >@@ -139,66 +137,58 @@ bool WebGPURenderingContext::canSuspendForDocumentSuspension() const > > PlatformLayer* WebGPURenderingContext::platformLayer() const > { >- return m_device->platformLayer(); >+ return m_device.platformLayer(); > } > > void WebGPURenderingContext::markLayerComposited() > { >- m_device->markLayerComposited(); >+ m_device.markLayerComposited(); > } > > void WebGPURenderingContext::reshape(int width, int height) > { > // FIXME: WebGPU - Do we need to reset stuff here? >- m_device->reshape(width, height); >+ m_device.reshape(width, height); > } > >-RefPtr<WebGPULibrary> WebGPURenderingContext::createLibrary(const String sourceCode) >+Ref<WebGPULibrary> WebGPURenderingContext::createLibrary(const String& sourceCode) > { >- RefPtr<WebGPULibrary> library = WebGPULibrary::create(this, sourceCode); >- return library; >+ return WebGPULibrary::create(*this, sourceCode); > } > >-RefPtr<WebGPURenderPipelineState> WebGPURenderingContext::createRenderPipelineState(WebGPURenderPipelineDescriptor& descriptor) >+Ref<WebGPURenderPipelineState> WebGPURenderingContext::createRenderPipelineState(WebGPURenderPipelineDescriptor& descriptor) > { >- RefPtr<WebGPURenderPipelineState> state = WebGPURenderPipelineState::create(this, &descriptor); >- return state; >+ return WebGPURenderPipelineState::create(*this, descriptor.descriptor()); > } > >-RefPtr<WebGPUDepthStencilState> WebGPURenderingContext::createDepthStencilState(WebGPUDepthStencilDescriptor& descriptor) >+Ref<WebGPUDepthStencilState> WebGPURenderingContext::createDepthStencilState(WebGPUDepthStencilDescriptor& descriptor) > { >- RefPtr<WebGPUDepthStencilState> state = WebGPUDepthStencilState::create(this, &descriptor); >- return state; >+ return WebGPUDepthStencilState::create(*this, descriptor.descriptor()); > } > >-RefPtr<WebGPUComputePipelineState> WebGPURenderingContext::createComputePipelineState(WebGPUFunction& function) >+Ref<WebGPUComputePipelineState> WebGPURenderingContext::createComputePipelineState(WebGPUFunction& function) > { >- RefPtr<WebGPUComputePipelineState> state = WebGPUComputePipelineState::create(this, &function); >- return state; >+ return WebGPUComputePipelineState::create(*this, function.function()); > } > >-RefPtr<WebGPUCommandQueue> WebGPURenderingContext::createCommandQueue() >+Ref<WebGPUCommandQueue> WebGPURenderingContext::createCommandQueue() > { >- RefPtr<WebGPUCommandQueue> queue = WebGPUCommandQueue::create(this); >- return queue; >+ return WebGPUCommandQueue::create(*this); > } > >-RefPtr<WebGPUDrawable> WebGPURenderingContext::nextDrawable() >+Ref<WebGPUDrawable> WebGPURenderingContext::nextDrawable() > { >- RefPtr<WebGPUDrawable> drawable = WebGPUDrawable::create(this); >- return drawable; >+ return WebGPUDrawable::create(*this); > } > >-RefPtr<WebGPUBuffer> WebGPURenderingContext::createBuffer(ArrayBufferView& data) >+RefPtr<WebGPUBuffer> WebGPURenderingContext::createBuffer(JSC::ArrayBufferView& data) > { >- RefPtr<WebGPUBuffer> buffer = WebGPUBuffer::create(this, &data); >- return buffer; >+ return WebGPUBuffer::create(*this, data); > } > >-RefPtr<WebGPUTexture> WebGPURenderingContext::createTexture(WebGPUTextureDescriptor& descriptor) >+Ref<WebGPUTexture> WebGPURenderingContext::createTexture(WebGPUTextureDescriptor& descriptor) > { >- RefPtr<WebGPUTexture> texture = WebGPUTexture::create(this, &descriptor); >- return texture; >+ return WebGPUTexture::create(*this, descriptor.descriptor()); > } > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPURenderingContext.h b/Source/WebCore/html/canvas/WebGPURenderingContext.h >index 33cd166fded098ac81953dcac90d7fb9861f7637..75658045ced311315ed72c011cc1025e22dff50b 100644 >--- a/Source/WebCore/html/canvas/WebGPURenderingContext.h >+++ b/Source/WebCore/html/canvas/WebGPURenderingContext.h >@@ -30,72 +30,62 @@ > > #include "GPUBasedCanvasRenderingContext.h" > #include "GPUDevice.h" >-#include <JavaScriptCore/ArrayBuffer.h> >+ >+namespace JSC { >+class ArrayBufferView; >+} > > namespace WebCore { > >+class WebGPUBuffer; > class WebGPUCommandQueue; > class WebGPUComputePipelineState; >+class WebGPUDepthStencilDescriptor; >+class WebGPUDepthStencilState; >+class WebGPUDrawable; > class WebGPUFunction; > class WebGPULibrary; > class WebGPURenderPipelineDescriptor; > class WebGPURenderPipelineState; >-class WebGPUDepthStencilDescriptor; >-class WebGPUDepthStencilState; >-class WebGPURenderPassDescriptor; >-class WebGPUDrawable; >-class WebGPUBuffer; > class WebGPUTexture; > class WebGPUTextureDescriptor; > >-class WebGPURenderingContext : public GPUBasedCanvasRenderingContext { >+class WebGPURenderingContext final : public GPUBasedCanvasRenderingContext { > public: > static std::unique_ptr<WebGPURenderingContext> create(CanvasBase&); > >+ // FIXME: IDL file says this is not nullable, but this function can return null. > HTMLCanvasElement* canvas() const; > >- bool isWebGPU() const final { return true; } >- >- void reshape(int width, int height) final; >- >- void markLayerComposited() final; >- >- PlatformLayer* platformLayer() const override; >+ Ref<WebGPULibrary> createLibrary(const String&); >+ Ref<WebGPURenderPipelineState> createRenderPipelineState(WebGPURenderPipelineDescriptor&); >+ Ref<WebGPUDepthStencilState> createDepthStencilState(WebGPUDepthStencilDescriptor&); >+ Ref<WebGPUComputePipelineState> createComputePipelineState(WebGPUFunction&); >+ Ref<WebGPUCommandQueue> createCommandQueue(); >+ Ref<WebGPUDrawable> nextDrawable(); >+ RefPtr<WebGPUBuffer> createBuffer(JSC::ArrayBufferView&); >+ Ref<WebGPUTexture> createTexture(WebGPUTextureDescriptor&); > >- RefPtr<GPUDevice> device() { return m_device; } >+ const GPUDevice& device() const { return m_device; } > >- // WebGPU entry points >- >- RefPtr<WebGPULibrary> createLibrary(const String); >- >- RefPtr<WebGPURenderPipelineState> createRenderPipelineState(WebGPURenderPipelineDescriptor&); >- >- RefPtr<WebGPUDepthStencilState> createDepthStencilState(WebGPUDepthStencilDescriptor&); >- >- RefPtr<WebGPUComputePipelineState> createComputePipelineState(WebGPUFunction&); >- >- RefPtr<WebGPUCommandQueue> createCommandQueue(); >- >- RefPtr<WebGPUDrawable> nextDrawable(); >- >- RefPtr<WebGPUBuffer> createBuffer(ArrayBufferView& data); >- >- RefPtr<WebGPUTexture> createTexture(WebGPUTextureDescriptor&); >+private: >+ WebGPURenderingContext(CanvasBase&, GPUDevice&&); > >-protected: >- // ActiveDOMObject >- bool hasPendingActivity() const override; >- void stop() override; >- const char* activeDOMObjectName() const override; >- bool canSuspendForDocumentSuspension() const override; >+ bool hasPendingActivity() const final; >+ void stop() final; >+ const char* activeDOMObjectName() const final; >+ bool canSuspendForDocumentSuspension() const final; > > IntSize clampedCanvasSize() const; > void initializeNewContext(); > >-private: >- WebGPURenderingContext(CanvasBase&, Ref<GPUDevice>&&); >+ bool isWebGPU() const final { return true; } >+ >+ void reshape(int width, int height) final; >+ void markLayerComposited() final; >+ PlatformLayer* platformLayer() const final; > >- RefPtr<GPUDevice> m_device; >+ GPUDevice m_device; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPURenderingContext.idl b/Source/WebCore/html/canvas/WebGPURenderingContext.idl >index 618ec041dd065109216bd138bcce77212cda75b7..f20454eb2e06dabd5cf9e0d4555e5c828ca23cee 100644 >--- a/Source/WebCore/html/canvas/WebGPURenderingContext.idl >+++ b/Source/WebCore/html/canvas/WebGPURenderingContext.idl >@@ -100,16 +100,16 @@ > > WebGPULibrary createLibrary(DOMString sourceCode); > >- WebGPURenderPipelineState? createRenderPipelineState(WebGPURenderPipelineDescriptor descriptor); >- WebGPUDepthStencilState? createDepthStencilState(WebGPUDepthStencilDescriptor descriptor); >- WebGPUComputePipelineState? createComputePipelineState(WebGPUFunction function); >+ WebGPURenderPipelineState createRenderPipelineState(WebGPURenderPipelineDescriptor descriptor); >+ WebGPUDepthStencilState createDepthStencilState(WebGPUDepthStencilDescriptor descriptor); >+ WebGPUComputePipelineState createComputePipelineState(WebGPUFunction function); > >- WebGPUCommandQueue? createCommandQueue(); >+ WebGPUCommandQueue createCommandQueue(); > >- WebGPUDrawable? nextDrawable(); >+ WebGPUDrawable nextDrawable(); > > WebGPUBuffer? createBuffer(ArrayBufferView data); > >- WebGPUTexture? createTexture(WebGPUTextureDescriptor descriptor); >+ WebGPUTexture createTexture(WebGPUTextureDescriptor descriptor); > > }; >diff --git a/Source/WebCore/html/canvas/WebGPUSize.h b/Source/WebCore/html/canvas/WebGPUSize.h >index 4dd4ea374a30bae95fe11d0042e751bb3660666d..5c121c5d4fd0038fdf4b14bc964da027a0827194 100644 >--- a/Source/WebCore/html/canvas/WebGPUSize.h >+++ b/Source/WebCore/html/canvas/WebGPUSize.h >@@ -30,9 +30,9 @@ > namespace WebCore { > > struct WebGPUSize { >- unsigned long width; >- unsigned long height; >- unsigned long depth; >+ unsigned width; >+ unsigned height; >+ unsigned depth; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPUTexture.cpp b/Source/WebCore/html/canvas/WebGPUTexture.cpp >index 6588df8d80e367bb612046ab284dd1e5a0e066c7..9ec89f66aaad880fd6d60b3e47bf920ac40021b8 100644 >--- a/Source/WebCore/html/canvas/WebGPUTexture.cpp >+++ b/Source/WebCore/html/canvas/WebGPUTexture.cpp >@@ -28,50 +28,30 @@ > > #if ENABLE(WEBGPU) > >-#include "GPUTexture.h" > #include "WebGPURenderingContext.h" >-#include "WebGPUTextureDescriptor.h" > > namespace WebCore { > >-Ref<WebGPUTexture> WebGPUTexture::createFromDrawableTexture(WebGPURenderingContext* context, RefPtr<GPUTexture>&& drawableTexture) >+Ref<WebGPUTexture> WebGPUTexture::createFromDrawableTexture(WebGPURenderingContext& context, GPUTexture&& texture) > { >- return adoptRef(*new WebGPUTexture(context, WTFMove(drawableTexture))); >+ return adoptRef(*new WebGPUTexture(context, WTFMove(texture))); > } > >-Ref<WebGPUTexture> WebGPUTexture::create(WebGPURenderingContext* context, WebGPUTextureDescriptor* descriptor) >+Ref<WebGPUTexture> WebGPUTexture::create(WebGPURenderingContext& context, const GPUTextureDescriptor& descriptor) > { > return adoptRef(*new WebGPUTexture(context, descriptor)); > } > >-WebGPUTexture::WebGPUTexture(WebGPURenderingContext* context, RefPtr<GPUTexture>&& drawableTexture) >- : WebGPUObject(context) >- , m_texture(WTFMove(drawableTexture)) >+WebGPUTexture::WebGPUTexture(WebGPURenderingContext& context, GPUTexture&& texture) >+ : WebGPUObject { &context } >+ , m_texture { WTFMove(texture) } > { > } > >-WebGPUTexture::WebGPUTexture(WebGPURenderingContext* context, WebGPUTextureDescriptor* descriptor) >- : WebGPUObject(context) >+WebGPUTexture::WebGPUTexture(WebGPURenderingContext& context, const GPUTextureDescriptor& descriptor) >+ : WebGPUObject { &context } >+ , m_texture { context.device(), descriptor } > { >- m_texture = context->device()->createTexture(descriptor->textureDescriptor()); >-} >- >-WebGPUTexture::~WebGPUTexture() = default; >- >-unsigned long WebGPUTexture::width() const >-{ >- if (!m_texture) >- return 0; >- >- return m_texture->width(); >-} >- >-unsigned long WebGPUTexture::height() const >-{ >- if (!m_texture) >- return 0; >- >- return m_texture->height(); > } > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPUTexture.h b/Source/WebCore/html/canvas/WebGPUTexture.h >index 30f2e4d1cac8d3c0151f6275952cca2d17979af5..5740128b49e6e78a28d8cdb36e9d068778f8b06e 100644 >--- a/Source/WebCore/html/canvas/WebGPUTexture.h >+++ b/Source/WebCore/html/canvas/WebGPUTexture.h >@@ -27,29 +27,28 @@ > > #if ENABLE(WEBGPU) > >+#include "GPUTexture.h" > #include "WebGPUObject.h" > > namespace WebCore { > >-class GPUTexture; >-class WebGPUTextureDescriptor; >+class GPUTextureDescriptor; > > class WebGPUTexture : public WebGPUObject { > public: >- virtual ~WebGPUTexture(); >- static Ref<WebGPUTexture> createFromDrawableTexture(WebGPURenderingContext*, RefPtr<GPUTexture>&&); >- static Ref<WebGPUTexture> create(WebGPURenderingContext*, WebGPUTextureDescriptor*); >+ static Ref<WebGPUTexture> createFromDrawableTexture(WebGPURenderingContext&, GPUTexture&&); >+ static Ref<WebGPUTexture> create(WebGPURenderingContext&, const GPUTextureDescriptor&); > >- unsigned long width() const; >- unsigned long height() const; >+ unsigned width() const { return m_texture.width(); } >+ unsigned height() const { return m_texture.height(); } > >- GPUTexture* texture() const { return m_texture.get(); } >+ const GPUTexture& texture() const { return m_texture; } > > private: >- WebGPUTexture(WebGPURenderingContext*, RefPtr<GPUTexture>&&); >- WebGPUTexture(WebGPURenderingContext*, WebGPUTextureDescriptor*); >+ WebGPUTexture(WebGPURenderingContext&, GPUTexture&&); >+ WebGPUTexture(WebGPURenderingContext&, const GPUTextureDescriptor&); > >- RefPtr<GPUTexture> m_texture; >+ GPUTexture m_texture; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPUTextureDescriptor.cpp b/Source/WebCore/html/canvas/WebGPUTextureDescriptor.cpp >index f7a33c62fef2d051b08234a3d5c85a284c08d24f..b8d735be839be048f3637e330330e617ae5a62bc 100644 >--- a/Source/WebCore/html/canvas/WebGPUTextureDescriptor.cpp >+++ b/Source/WebCore/html/canvas/WebGPUTextureDescriptor.cpp >@@ -28,118 +28,76 @@ > > #if ENABLE(WEBGPU) > >-#include "GPUTextureDescriptor.h" >-#include "WebGPURenderingContext.h" >- > namespace WebCore { > >-Ref<WebGPUTextureDescriptor> WebGPUTextureDescriptor::create(unsigned long pixelFormat, unsigned long width, unsigned long height, bool mipmapped) >+Ref<WebGPUTextureDescriptor> WebGPUTextureDescriptor::create(unsigned pixelFormat, unsigned width, unsigned height, bool mipmapped) > { > return adoptRef(*new WebGPUTextureDescriptor(pixelFormat, width, height, mipmapped)); > } > >-WebGPUTextureDescriptor::WebGPUTextureDescriptor(unsigned long pixelFormat, unsigned long width, unsigned long height, bool mipmapped) >- : WebGPUObject() >+WebGPUTextureDescriptor::WebGPUTextureDescriptor(unsigned pixelFormat, unsigned width, unsigned height, bool mipmapped) >+ : m_descriptor { pixelFormat, width, height, mipmapped } > { >- m_textureDescriptor = GPUTextureDescriptor::create(pixelFormat, width, height, mipmapped); > } > >-WebGPUTextureDescriptor::~WebGPUTextureDescriptor() = default; >- >-unsigned long WebGPUTextureDescriptor::width() const >+unsigned WebGPUTextureDescriptor::width() const > { >- if (!m_textureDescriptor) >- return 0; >- >- return m_textureDescriptor->width(); >+ return m_descriptor.width(); > } > >-void WebGPUTextureDescriptor::setWidth(unsigned long width) >+void WebGPUTextureDescriptor::setWidth(unsigned width) > { >- if (!m_textureDescriptor) >- return; >- >- m_textureDescriptor->setWidth(width); >+ m_descriptor.setWidth(width); > } > >-unsigned long WebGPUTextureDescriptor::height() const >+unsigned WebGPUTextureDescriptor::height() const > { >- if (!m_textureDescriptor) >- return 0; >- >- return m_textureDescriptor->height(); >+ return m_descriptor.height(); > } > >-void WebGPUTextureDescriptor::setHeight(unsigned long height) >+void WebGPUTextureDescriptor::setHeight(unsigned height) > { >- if (!m_textureDescriptor) >- return; >- >- m_textureDescriptor->setHeight(height); >+ m_descriptor.setHeight(height); > } > >-unsigned long WebGPUTextureDescriptor::sampleCount() const >+unsigned WebGPUTextureDescriptor::sampleCount() const > { >- if (!m_textureDescriptor) >- return 0; >- >- return m_textureDescriptor->sampleCount(); >+ return m_descriptor.sampleCount(); > } > >-void WebGPUTextureDescriptor::setSampleCount(unsigned long sampleCount) >+void WebGPUTextureDescriptor::setSampleCount(unsigned sampleCount) > { >- if (!m_textureDescriptor) >- return; >- >- m_textureDescriptor->setSampleCount(sampleCount); >+ m_descriptor.setSampleCount(sampleCount); > } > >-unsigned long WebGPUTextureDescriptor::textureType() const >+unsigned WebGPUTextureDescriptor::textureType() const > { >- if (!m_textureDescriptor) >- return 0; >- >- return m_textureDescriptor->textureType(); >+ return m_descriptor.textureType(); > } > >-void WebGPUTextureDescriptor::setTextureType(unsigned long textureType) >+void WebGPUTextureDescriptor::setTextureType(unsigned textureType) > { >- if (!m_textureDescriptor) >- return; >- >- m_textureDescriptor->setTextureType(textureType); >+ m_descriptor.setTextureType(textureType); > } > >-unsigned long WebGPUTextureDescriptor::storageMode() const >+unsigned WebGPUTextureDescriptor::storageMode() const > { >- if (!m_textureDescriptor) >- return 0; >- >- return m_textureDescriptor->storageMode(); >+ return m_descriptor.storageMode(); > } > >-void WebGPUTextureDescriptor::setStorageMode(unsigned long storageMode) >+void WebGPUTextureDescriptor::setStorageMode(unsigned storageMode) > { >- if (!m_textureDescriptor) >- return; >- >- m_textureDescriptor->setStorageMode(storageMode); >+ m_descriptor.setStorageMode(storageMode); > } > >-unsigned long WebGPUTextureDescriptor::usage() const >+unsigned WebGPUTextureDescriptor::usage() const > { >- if (!m_textureDescriptor) >- return 0; >- >- return m_textureDescriptor->usage(); >+ return m_descriptor.usage(); > } > >-void WebGPUTextureDescriptor::setUsage(unsigned long usage) >+void WebGPUTextureDescriptor::setUsage(unsigned usage) > { >- if (!m_textureDescriptor) >- return; >- >- m_textureDescriptor->setUsage(usage); >+ m_descriptor.setUsage(usage); > } > > } // namespace WebCore >diff --git a/Source/WebCore/html/canvas/WebGPUTextureDescriptor.h b/Source/WebCore/html/canvas/WebGPUTextureDescriptor.h >index 8ae264e61ad18ec0c6f0469902773d1540bbc41f..9b6b6c8b2b27a9f62371424631b6d168a878de8e 100644 >--- a/Source/WebCore/html/canvas/WebGPUTextureDescriptor.h >+++ b/Source/WebCore/html/canvas/WebGPUTextureDescriptor.h >@@ -27,44 +27,39 @@ > > #if ENABLE(WEBGPU) > >-#include "WebGPUEnums.h" >+#include "GPUTextureDescriptor.h" > #include "WebGPUObject.h" > >-#include <wtf/Vector.h> >- > namespace WebCore { > >-class GPUTextureDescriptor; >- > class WebGPUTextureDescriptor : public WebGPUObject { > public: >- virtual ~WebGPUTextureDescriptor(); >- static Ref<WebGPUTextureDescriptor> create(unsigned long pixelFormat, unsigned long width, unsigned long height, bool mipmapped); >+ static Ref<WebGPUTextureDescriptor> create(unsigned pixelFormat, unsigned width, unsigned height, bool mipmapped); > >- unsigned long width() const; >- void setWidth(unsigned long); >+ unsigned width() const; >+ void setWidth(unsigned); > >- unsigned long height() const; >- void setHeight(unsigned long); >+ unsigned height() const; >+ void setHeight(unsigned); > >- unsigned long sampleCount() const; >- void setSampleCount(unsigned long); >+ unsigned sampleCount() const; >+ void setSampleCount(unsigned); > >- unsigned long textureType() const; >- void setTextureType(unsigned long); >+ unsigned textureType() const; >+ void setTextureType(unsigned); > >- unsigned long storageMode() const; >- void setStorageMode(unsigned long); >+ unsigned storageMode() const; >+ void setStorageMode(unsigned); > >- unsigned long usage() const; >- void setUsage(unsigned long); >+ unsigned usage() const; >+ void setUsage(unsigned); > >- GPUTextureDescriptor* textureDescriptor() { return m_textureDescriptor.get(); } >+ const GPUTextureDescriptor& descriptor() { return m_descriptor; } > > private: >- WebGPUTextureDescriptor(unsigned long pixelFormat, unsigned long width, unsigned long height, bool mipmapped); >+ WebGPUTextureDescriptor(unsigned pixelFormat, unsigned width, unsigned height, bool mipmapped); > >- RefPtr<GPUTextureDescriptor> m_textureDescriptor; >+ GPUTextureDescriptor m_descriptor; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/platform/graphics/cocoa/GPUBufferMetal.mm b/Source/WebCore/platform/graphics/cocoa/GPUBufferMetal.mm >deleted file mode 100644 >index ad46220b25a3fdd1e8566351f0f1ecf3ae11993e..0000000000000000000000000000000000000000 >--- a/Source/WebCore/platform/graphics/cocoa/GPUBufferMetal.mm >+++ /dev/null >@@ -1,82 +0,0 @@ >-/* >- * Copyright (C) 2017 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#import "config.h" >-#import "GPUBuffer.h" >- >-#if ENABLE(WEBGPU) >- >-#import "GPUDevice.h" >-#import "Logging.h" >-#import <Metal/Metal.h> >-#import <wtf/Gigacage.h> >-#import <wtf/PageBlock.h> >- >-namespace WebCore { >- >-GPUBuffer::GPUBuffer(GPUDevice* device, ArrayBufferView* data) >-{ >- LOG(WebGPU, "GPUBuffer::GPUBuffer()"); >- >- if (!device || !device->platformDevice() || !data) >- return; >- >- size_t pageSize = WTF::pageSize(); >- size_t pageAlignedSize = roundUpToMultipleOf(pageSize, data->byteLength()); >- void* pageAlignedCopy = Gigacage::tryAlignedMalloc(Gigacage::Primitive, pageSize, pageAlignedSize); >- if (!pageAlignedCopy) >- return; >- memcpy(pageAlignedCopy, data->baseAddress(), data->byteLength()); >- m_contents = ArrayBuffer::createFromBytes(pageAlignedCopy, data->byteLength(), [] (void* ptr) { Gigacage::alignedFree(Gigacage::Primitive, ptr); }); >- m_contents->ref(); >- ArrayBuffer* capturedContents = m_contents.get(); >- m_buffer = adoptNS((MTLBuffer *)[device->platformDevice() newBufferWithBytesNoCopy:m_contents->data() length:pageAlignedSize options:MTLResourceOptionCPUCacheModeDefault deallocator:^(void*, NSUInteger) { capturedContents->deref(); }]); >- if (!m_buffer) { >- m_contents->deref(); >- m_contents = nullptr; >- } >-} >- >-unsigned long GPUBuffer::length() const >-{ >- if (!m_buffer) >- return 0; >- >- return m_contents->byteLength(); >-} >- >-RefPtr<ArrayBuffer> GPUBuffer::contents() >-{ >- return m_contents; >-} >- >-MTLBuffer *GPUBuffer::platformBuffer() >-{ >- return m_buffer.get(); >-} >- >-} // namespace WebCore >- >-#endif >diff --git a/Source/WebCore/platform/graphics/cocoa/GPUCommandBufferMetal.mm b/Source/WebCore/platform/graphics/cocoa/GPUCommandBufferMetal.mm >deleted file mode 100644 >index 12546f7ffa7d3a071a679ef3f9ec4cdf4d3b7d5e..0000000000000000000000000000000000000000 >--- a/Source/WebCore/platform/graphics/cocoa/GPUCommandBufferMetal.mm >+++ /dev/null >@@ -1,89 +0,0 @@ >-/* >- * Copyright (C) 2017 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#import "config.h" >-#import "GPUCommandBuffer.h" >- >-#if ENABLE(WEBGPU) >- >-#import "GPUCommandQueue.h" >-#import "GPUDevice.h" >-#import "GPUDrawable.h" >-#import "Logging.h" >- >-#import <Metal/Metal.h> >-#import <wtf/BlockPtr.h> >- >-namespace WebCore { >- >-GPUCommandBuffer::GPUCommandBuffer(GPUCommandQueue* queue) >-{ >- LOG(WebGPU, "GPUCommandBuffer::GPUCommandBuffer()"); >- >- if (!queue || !queue->platformCommandQueue()) >- return; >- >- m_commandBuffer = (MTLCommandBuffer *)[queue->platformCommandQueue() commandBuffer]; >-} >- >-MTLCommandBuffer *GPUCommandBuffer::platformCommandBuffer() >-{ >- return m_commandBuffer.get(); >-} >- >-void GPUCommandBuffer::presentDrawable(GPUDrawable* drawable) >-{ >- if (!m_commandBuffer || !drawable->platformDrawable()) >- return; >- >- [m_commandBuffer presentDrawable:static_cast<id<MTLDrawable>>(drawable->platformDrawable())]; >- drawable->release(); >-} >- >-void GPUCommandBuffer::commit() >-{ >- if (!m_commandBuffer) >- return; >- >- [m_commandBuffer commit]; >-} >- >-DOMPromiseProxy<IDLVoid>& GPUCommandBuffer::completed() >-{ >- if (!m_commandBuffer) >- return m_completedPromise; >- >- [m_commandBuffer addCompletedHandler:BlockPtr<void (id<MTLCommandBuffer>)>::fromCallable([this, protectedThis = makeRef(*this)] (id<MTLCommandBuffer>) { >- callOnMainThread([this, protectedThis = makeRef(*this)] { >- this->m_completedPromise.resolve(); >- }); >- }).get()]; >- >- return m_completedPromise; >-} >- >-} // namespace WebCore >- >-#endif >diff --git a/Source/WebCore/platform/graphics/cocoa/GPUCommandQueueMetal.mm b/Source/WebCore/platform/graphics/cocoa/GPUCommandQueueMetal.mm >deleted file mode 100644 >index a9aa4aa804867e44bb1adf91f87b2dae4b1d9554..0000000000000000000000000000000000000000 >--- a/Source/WebCore/platform/graphics/cocoa/GPUCommandQueueMetal.mm >+++ /dev/null >@@ -1,81 +0,0 @@ >-/* >- * Copyright (C) 2017 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#import "config.h" >-#import "GPUCommandQueue.h" >- >-#if ENABLE(WEBGPU) >- >-#import "GPUDevice.h" >-#import "Logging.h" >- >-#import <Metal/Metal.h> >- >-static NSString *webkitPrefix = @"com.apple.WebKit"; >- >-namespace WebCore { >- >-GPUCommandQueue::GPUCommandQueue(GPUDevice* device) >-{ >- LOG(WebGPU, "GPUCommandQueue::GPUCommandQueue()"); >- >- if (!device || !device->platformDevice()) >- return; >- >- m_commandQueue = adoptNS((MTLCommandQueue *)[device->platformDevice() newCommandQueue]); >- setLabel(emptyString()); >-} >- >-String GPUCommandQueue::label() const >-{ >- if (!m_commandQueue) >- return emptyString(); >- >- NSString *prefixedLabel = [m_commandQueue label]; >- >- if ([prefixedLabel isEqualToString:webkitPrefix]) >- return emptyString(); >- >- ASSERT(prefixedLabel.length >= (webkitPrefix.length + 1)); >- return [prefixedLabel substringFromIndex:(webkitPrefix.length + 1)]; >-} >- >-void GPUCommandQueue::setLabel(const String& label) >-{ >- ASSERT(m_commandQueue); >- if (label.isEmpty()) >- [m_commandQueue setLabel:webkitPrefix]; >- else >- [m_commandQueue setLabel:[NSString stringWithFormat:@"%@.%@", webkitPrefix, static_cast<NSString *>(label)]]; >-} >- >-MTLCommandQueue *GPUCommandQueue::platformCommandQueue() >-{ >- return m_commandQueue.get(); >-} >- >-} // namespace WebCore >- >-#endif >diff --git a/Source/WebCore/platform/graphics/cocoa/GPUComputeCommandEncoderMetal.mm b/Source/WebCore/platform/graphics/cocoa/GPUComputeCommandEncoderMetal.mm >deleted file mode 100644 >index c0c187149542450510f88fa11dfe50382b03a468..0000000000000000000000000000000000000000 >--- a/Source/WebCore/platform/graphics/cocoa/GPUComputeCommandEncoderMetal.mm >+++ /dev/null >@@ -1,92 +0,0 @@ >-/* >- * Copyright (C) 2017 Yuichiro Kikura (y.kikura@gmail.com) >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#import "config.h" >-#import "GPUComputeCommandEncoder.h" >- >-#if ENABLE(WEBGPU) >- >-#import "GPUBuffer.h" >-#import "GPUCommandBuffer.h" >-#import "GPUComputePipelineState.h" >-#import "GPUSize.h" >-#import "Logging.h" >- >-#import <Metal/Metal.h> >- >-namespace WebCore { >- >-inline MTLSize MTLSizeMake(GPUSize size) >-{ >- return {size.width, size.height, size.depth}; >-} >- >-GPUComputeCommandEncoder::GPUComputeCommandEncoder(GPUCommandBuffer* buffer) >-{ >- LOG(WebGPU, "GPUComputeCommandEncoder::GPUComputeCommandEncoder()"); >- >- if (!buffer || !buffer->platformCommandBuffer()) >- return; >- >- m_computeCommandEncoder = (MTLComputeCommandEncoder *)[buffer->platformCommandBuffer() computeCommandEncoder]; >-} >- >-void GPUComputeCommandEncoder::setComputePipelineState(GPUComputePipelineState* computePipelineState) >-{ >- if (!m_computeCommandEncoder || !computePipelineState) >- return; >- >- [m_computeCommandEncoder setComputePipelineState:static_cast<id<MTLComputePipelineState>>(computePipelineState->platformComputePipelineState())]; >-} >- >-void GPUComputeCommandEncoder::setBuffer(GPUBuffer* buffer, unsigned offset, unsigned index) >-{ >- if (!m_computeCommandEncoder || !buffer) >- return; >- >- [m_computeCommandEncoder setBuffer:static_cast<id<MTLBuffer>>(buffer->platformBuffer()) offset:offset atIndex:index]; >-} >- >-void GPUComputeCommandEncoder::dispatch(GPUSize threadgroupsPerGrid, GPUSize threadsPerThreadgroup) >-{ >- if (!m_computeCommandEncoder) >- return; >- >- [m_computeCommandEncoder dispatchThreadgroups:MTLSizeMake(threadgroupsPerGrid) threadsPerThreadgroup:MTLSizeMake(threadsPerThreadgroup)]; >-} >- >-void GPUComputeCommandEncoder::endEncoding() >-{ >- [m_computeCommandEncoder endEncoding]; >-} >- >-MTLComputeCommandEncoder *GPUComputeCommandEncoder::platformComputeCommandEncoder() >-{ >- return m_computeCommandEncoder.get(); >-} >- >-} // namespace WebCore >- >-#endif >diff --git a/Source/WebCore/platform/graphics/cocoa/GPUComputePipelineStateMetal.mm b/Source/WebCore/platform/graphics/cocoa/GPUComputePipelineStateMetal.mm >deleted file mode 100644 >index bd7ab6849c9a4e1d4710205af3f5ab5efb759cba..0000000000000000000000000000000000000000 >--- a/Source/WebCore/platform/graphics/cocoa/GPUComputePipelineStateMetal.mm >+++ /dev/null >@@ -1,56 +0,0 @@ >-/* >- * Copyright (C) 2017 Yuichiro Kikura (y.kikura@gmail.com) >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#import "config.h" >-#import "GPUComputePipelineState.h" >- >-#if ENABLE(WEBGPU) >- >-#import "GPUDevice.h" >-#import "GPUFunction.h" >-#import "Logging.h" >- >-#import <Metal/Metal.h> >- >-namespace WebCore { >- >-GPUComputePipelineState::GPUComputePipelineState(GPUDevice* device, GPUFunction* function) >-{ >- LOG(WebGPU, "GPUComputePipelineState::GPUComputePipelineState()"); >- >- if (!device || !device->platformDevice() || !function || !function->platformFunction()) >- return; >- >- m_computePipelineState = adoptNS((MTLComputePipelineState *)[device->platformDevice() newComputePipelineStateWithFunction:(id<MTLFunction>)function->platformFunction() error:nil]); >-} >- >-MTLComputePipelineState *GPUComputePipelineState::platformComputePipelineState() >-{ >- return m_computePipelineState.get(); >-} >- >-} // namespace WebCore >- >-#endif >diff --git a/Source/WebCore/platform/graphics/cocoa/GPUDepthStencilDescriptorMetal.mm b/Source/WebCore/platform/graphics/cocoa/GPUDepthStencilDescriptorMetal.mm >deleted file mode 100644 >index 2fd814612832d84be68c253f7c7bf34cb5dedc0d..0000000000000000000000000000000000000000 >--- a/Source/WebCore/platform/graphics/cocoa/GPUDepthStencilDescriptorMetal.mm >+++ /dev/null >@@ -1,80 +0,0 @@ >-/* >- * Copyright (C) 2017 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#import "config.h" >-#import "GPUDepthStencilDescriptor.h" >- >-#if ENABLE(WEBGPU) >- >-#import "GPUEnums.h" >-#import "Logging.h" >- >-#import <Metal/Metal.h> >- >-namespace WebCore { >- >-GPUDepthStencilDescriptor::GPUDepthStencilDescriptor() >-{ >- LOG(WebGPU, "GPUDepthStencilDescriptor::GPUDepthStencilDescriptor()"); >- >- m_depthStencilDescriptor = adoptNS((MTLDepthStencilDescriptor *)[MTLDepthStencilDescriptor new]); >-} >- >-bool GPUDepthStencilDescriptor::depthWriteEnabled() const >-{ >- if (!m_depthStencilDescriptor) >- return false; >- >- return [m_depthStencilDescriptor isDepthWriteEnabled]; >-} >- >-void GPUDepthStencilDescriptor::setDepthWriteEnabled(bool newDepthWriteEnabled) >-{ >- ASSERT(m_depthStencilDescriptor); >- [m_depthStencilDescriptor setDepthWriteEnabled:newDepthWriteEnabled]; >-} >- >-GPUCompareFunction GPUDepthStencilDescriptor::depthCompareFunction() const >-{ >- if (!m_depthStencilDescriptor) >- return GPUCompareFunction::Never; >- >- return static_cast<GPUCompareFunction>([m_depthStencilDescriptor depthCompareFunction]); >-} >- >-void GPUDepthStencilDescriptor::setDepthCompareFunction(GPUCompareFunction newFunction) >-{ >- ASSERT(m_depthStencilDescriptor); >- [m_depthStencilDescriptor setDepthCompareFunction:static_cast<MTLCompareFunction>(newFunction)]; >-} >- >-MTLDepthStencilDescriptor *GPUDepthStencilDescriptor::platformDepthStencilDescriptor() >-{ >- return m_depthStencilDescriptor.get(); >-} >- >-} // namespace WebCore >- >-#endif >diff --git a/Source/WebCore/platform/graphics/cocoa/GPUDepthStencilStateMetal.mm b/Source/WebCore/platform/graphics/cocoa/GPUDepthStencilStateMetal.mm >deleted file mode 100644 >index 203e8617f220fe71de2d393bc574f7f97da5405f..0000000000000000000000000000000000000000 >--- a/Source/WebCore/platform/graphics/cocoa/GPUDepthStencilStateMetal.mm >+++ /dev/null >@@ -1,70 +0,0 @@ >-/* >- * Copyright (C) 2017 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#import "config.h" >-#import "GPUDepthStencilState.h" >- >-#if ENABLE(WEBGPU) >- >-#import "GPUDepthStencilDescriptor.h" >-#import "GPUDevice.h" >-#import "Logging.h" >- >-#import <Metal/Metal.h> >- >-namespace WebCore { >- >-GPUDepthStencilState::GPUDepthStencilState(GPUDevice* device, GPUDepthStencilDescriptor* descriptor) >-{ >- LOG(WebGPU, "GPUDepthStencilState::GPUDepthStencilState()"); >- >- if (!device || !device->platformDevice() || !descriptor || !descriptor->platformDepthStencilDescriptor()) >- return; >- >- m_depthStencilState = adoptNS((MTLDepthStencilState *)[device->platformDevice() newDepthStencilStateWithDescriptor:descriptor->platformDepthStencilDescriptor()]); >-} >- >-String GPUDepthStencilState::label() const >-{ >- if (!m_depthStencilState) >- return emptyString(); >- >- return [m_depthStencilState label]; >-} >- >-void GPUDepthStencilState::setLabel(const String& label) >-{ >- ASSERT(m_depthStencilState); >- [m_depthStencilState setLabel:label]; >-} >- >-MTLDepthStencilState *GPUDepthStencilState::platformDepthStencilState() >-{ >- return m_depthStencilState.get(); >-} >- >-} // namespace WebCore >- >-#endif >diff --git a/Source/WebCore/platform/graphics/cocoa/GPUDeviceMetal.mm b/Source/WebCore/platform/graphics/cocoa/GPUDeviceMetal.mm >deleted file mode 100644 >index f9ce8c529d83e5bbdb713b11e991411306619bee..0000000000000000000000000000000000000000 >--- a/Source/WebCore/platform/graphics/cocoa/GPUDeviceMetal.mm >+++ /dev/null >@@ -1,83 +0,0 @@ >-/* >- * Copyright (C) 2017 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#import "config.h" >-#import "GPUDevice.h" >- >-#import "Logging.h" >-#import "WebGPULayer.h" >- >-#import <JavaScriptCore/ArrayBuffer.h> >-#import <Metal/Metal.h> >-#import <wtf/BlockObjCExceptions.h> >- >-#if ENABLE(WEBGPU) >- >-namespace WebCore { >- >-GPUDevice::GPUDevice() >-{ >- m_device = MTLCreateSystemDefaultDevice(); >- >- if (!m_device) { >- LOG(WebGPU, "GPUDevice::GPUDevice -- could not create the device. This usually means Metal is not available on this hardware."); >- return; >- } >- >- LOG(WebGPU, "GPUDevice::GPUDevice Metal device is %p", m_device.get()); >- >- BEGIN_BLOCK_OBJC_EXCEPTIONS >- m_layer = [[WebGPULayer alloc] initWithGPUDevice:this]; >- [m_layer setOpaque:0]; >- [m_layer setName:@"WebGPU Layer"]; >- >- // FIXME: WebGPU - Should this be in the WebGPULayer initializer? >- [m_layer setDevice:(id<MTLDevice>)m_device.get()]; >- [m_layer setPixelFormat:MTLPixelFormatBGRA8Unorm]; >- [m_layer setFramebufferOnly:YES]; >- END_BLOCK_OBJC_EXCEPTIONS >-} >- >-void GPUDevice::reshape(int width, int height) >-{ >- if (!m_device) >- return; >- >- if (m_layer) { >- [m_layer setBounds:CGRectMake(0, 0, width, height)]; >- [m_layer setDrawableSize:CGSizeMake(width, height)]; >- } >- >- // FIXME: WebGPU - Lots of reshape stuff should go here. See GC3D. >-} >- >-id GPUDevice::platformDevice() >-{ >- return m_device.get(); >-} >- >-} // namespace WebCore >- >-#endif >diff --git a/Source/WebCore/platform/graphics/cocoa/GPUDrawableMetal.mm b/Source/WebCore/platform/graphics/cocoa/GPUDrawableMetal.mm >deleted file mode 100644 >index 425e59ffa779b1a47a3c188d160ad43659958693..0000000000000000000000000000000000000000 >--- a/Source/WebCore/platform/graphics/cocoa/GPUDrawableMetal.mm >+++ /dev/null >@@ -1,69 +0,0 @@ >-/* >- * Copyright (C) 2017 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#import "config.h" >-#import "GPUDrawable.h" >- >-#if ENABLE(WEBGPU) >- >-#import "GPUDevice.h" >-#import "Logging.h" >- >-#import <Metal/Metal.h> >-#import <QuartzCore/QuartzCore.h> >- >-namespace WebCore { >- >-GPUDrawable::GPUDrawable(GPUDevice* device) >-{ >- LOG(WebGPU, "GPUDrawable::GPUDrawable()"); >- >- if (!device || !device->platformDevice()) >- return; >- >- m_drawable = (MTLDrawable *)[static_cast<CAMetalLayer*>(device->platformLayer()) nextDrawable]; >-} >- >-void GPUDrawable::release() >-{ >- LOG(WebGPU, "GPUDrawable::release()"); >- m_drawable = nullptr; >-} >- >-MTLDrawable *GPUDrawable::platformDrawable() >-{ >- return m_drawable.get(); >-} >- >-MTLTexture *GPUDrawable::platformTexture() >-{ >- if (!m_drawable) >- return nullptr; >- return (MTLTexture *)[(id<CAMetalDrawable>)m_drawable.get() texture]; >-} >- >-} // namespace WebCore >- >-#endif >diff --git a/Source/WebCore/platform/graphics/cocoa/GPUFunctionMetal.mm b/Source/WebCore/platform/graphics/cocoa/GPUFunctionMetal.mm >deleted file mode 100644 >index 19dbbf6cee019084b356b43dfa88d3c0170d6950..0000000000000000000000000000000000000000 >--- a/Source/WebCore/platform/graphics/cocoa/GPUFunctionMetal.mm >+++ /dev/null >@@ -1,62 +0,0 @@ >-/* >- * Copyright (C) 2017 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#import "config.h" >-#import "GPUFunction.h" >- >-#if ENABLE(WEBGPU) >- >-#import "GPULibrary.h" >-#import "Logging.h" >-#import <Metal/Metal.h> >- >-namespace WebCore { >- >-GPUFunction::GPUFunction(GPULibrary* library, const String& name) >-{ >- LOG(WebGPU, "GPUFunction::GPUFunction()"); >- >- if (!library || !library->platformLibrary()) >- return; >- >- m_function = adoptNS((MTLFunction *)[library->platformLibrary() newFunctionWithName:name]); >-} >- >-String GPUFunction::name() const >-{ >- if (!m_function) >- return emptyString(); >- >- return [m_function name]; >-} >- >-MTLFunction *GPUFunction::platformFunction() >-{ >- return m_function.get(); >-} >- >-} // namespace WebCore >- >-#endif >diff --git a/Source/WebCore/platform/graphics/cocoa/GPULibraryMetal.mm b/Source/WebCore/platform/graphics/cocoa/GPULibraryMetal.mm >deleted file mode 100644 >index fb8f8249e82edf6b81f61e11df14157e456e94a5..0000000000000000000000000000000000000000 >--- a/Source/WebCore/platform/graphics/cocoa/GPULibraryMetal.mm >+++ /dev/null >@@ -1,86 +0,0 @@ >-/* >- * Copyright (C) 2017 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#import "config.h" >-#import "GPULibrary.h" >- >-#if ENABLE(WEBGPU) >- >-#import "GPUDevice.h" >-#import "Logging.h" >- >-#import <Metal/Metal.h> >- >-namespace WebCore { >- >-GPULibrary::GPULibrary(GPUDevice* device, const String& sourceCode) >-{ >- LOG(WebGPU, "GPULibrary::GPULibrary()"); >- >- if (!device || !device->platformDevice()) >- return; >- >- NSError *error = [NSError errorWithDomain:@"com.apple.WebKit.GPU" code:1 userInfo:nil]; >- m_library = adoptNS((MTLLibrary *)[device->platformDevice() newLibraryWithSource:sourceCode options:nil error:&error]); >- if (!m_library) >- LOG(WebGPU, "Compilation error: %s", [[error localizedDescription] UTF8String]); >-} >- >-String GPULibrary::label() const >-{ >- if (!m_library) >- return emptyString(); >- >- return [m_library label]; >-} >- >-void GPULibrary::setLabel(const String& label) >-{ >- ASSERT(m_library); >- [m_library setLabel:label]; >-} >- >-Vector<String> GPULibrary::functionNames() >-{ >- if (!m_library) >- return Vector<String>(); >- >- Vector<String> names; >- >- NSArray<NSString*> *functionNames = [m_library functionNames]; >- for (NSString *string in functionNames) >- names.append(string); >- >- return names; >-} >- >-MTLLibrary *GPULibrary::platformLibrary() >-{ >- return m_library.get(); >-} >- >-} // namespace WebCore >- >-#endif >diff --git a/Source/WebCore/platform/graphics/cocoa/GPURenderCommandEncoderMetal.mm b/Source/WebCore/platform/graphics/cocoa/GPURenderCommandEncoderMetal.mm >deleted file mode 100644 >index 23cb1aab3e8970e6fcfeae40327984d36cc6bf2b..0000000000000000000000000000000000000000 >--- a/Source/WebCore/platform/graphics/cocoa/GPURenderCommandEncoderMetal.mm >+++ /dev/null >@@ -1,106 +0,0 @@ >-/* >- * Copyright (C) 2017 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#import "config.h" >-#import "GPURenderCommandEncoder.h" >- >-#if ENABLE(WEBGPU) >- >-#import "GPUBuffer.h" >-#import "GPUCommandBuffer.h" >-#import "GPUDepthStencilState.h" >-#import "GPURenderPassDescriptor.h" >-#import "GPURenderPipelineState.h" >-#import "Logging.h" >- >-#import <Metal/Metal.h> >- >-namespace WebCore { >- >-GPURenderCommandEncoder::GPURenderCommandEncoder(GPUCommandBuffer* buffer, GPURenderPassDescriptor* descriptor) >-{ >- LOG(WebGPU, "GPURenderCommandEncoder::GPURenderCommandEncoder()"); >- >- if (!buffer || !buffer->platformCommandBuffer() || !descriptor || !descriptor->platformRenderPassDescriptor()) >- return; >- >- m_renderCommandEncoder = (MTLRenderCommandEncoder *)[buffer->platformCommandBuffer() renderCommandEncoderWithDescriptor:descriptor->platformRenderPassDescriptor()]; >-} >- >-void GPURenderCommandEncoder::setRenderPipelineState(GPURenderPipelineState* renderPipelineState) >-{ >- if (!m_renderCommandEncoder || !renderPipelineState) >- return; >- >- // We need to cast to MTLRenderCommandEncoder explicitly because the compiler gets >- // confused by a protocol with a similar signature. >- [(id<MTLRenderCommandEncoder>)m_renderCommandEncoder.get() setRenderPipelineState:static_cast<id<MTLRenderPipelineState>>(renderPipelineState->platformRenderPipelineState())]; >-} >- >-void GPURenderCommandEncoder::setDepthStencilState(GPUDepthStencilState* depthStencilState) >-{ >- if (!m_renderCommandEncoder || !depthStencilState) >- return; >- >- [m_renderCommandEncoder setDepthStencilState:static_cast<id<MTLDepthStencilState>>(depthStencilState->platformDepthStencilState())]; >-} >- >-void GPURenderCommandEncoder::setVertexBuffer(GPUBuffer* buffer, unsigned offset, unsigned index) >-{ >- if (!m_renderCommandEncoder || !buffer) >- return; >- >- [m_renderCommandEncoder setVertexBuffer:static_cast<id<MTLBuffer>>(buffer->platformBuffer()) offset:offset atIndex:index]; >-} >- >-void GPURenderCommandEncoder::setFragmentBuffer(GPUBuffer* buffer, unsigned offset, unsigned index) >-{ >- if (!m_renderCommandEncoder || !buffer) >- return; >- >- [m_renderCommandEncoder setFragmentBuffer:static_cast<id<MTLBuffer>>(buffer->platformBuffer()) offset:offset atIndex:index]; >-} >- >-void GPURenderCommandEncoder::drawPrimitives(unsigned type, unsigned start, unsigned count) >-{ >- if (!m_renderCommandEncoder || !count) >- return; >- >- [m_renderCommandEncoder drawPrimitives:static_cast<MTLPrimitiveType>(type) vertexStart:start vertexCount:count]; >-} >- >-void GPURenderCommandEncoder::endEncoding() >-{ >- [m_renderCommandEncoder endEncoding]; >-} >- >-MTLRenderCommandEncoder *GPURenderCommandEncoder::platformRenderCommandEncoder() >-{ >- return m_renderCommandEncoder.get(); >-} >- >-} // namespace WebCore >- >-#endif >diff --git a/Source/WebCore/platform/graphics/cocoa/GPURenderPassAttachmentDescriptorMetal.mm b/Source/WebCore/platform/graphics/cocoa/GPURenderPassAttachmentDescriptorMetal.mm >deleted file mode 100644 >index 3c712c99feb4bcaa362a3797be1931b28d7a4262..0000000000000000000000000000000000000000 >--- a/Source/WebCore/platform/graphics/cocoa/GPURenderPassAttachmentDescriptorMetal.mm >+++ /dev/null >@@ -1,92 +0,0 @@ >-/* >- * Copyright (C) 2017 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#import "config.h" >-#import "GPURenderPassAttachmentDescriptor.h" >- >-#if ENABLE(WEBGPU) >- >-#import "GPUTexture.h" >-#import "Logging.h" >- >-#import <Metal/Metal.h> >- >-namespace WebCore { >- >-GPURenderPassAttachmentDescriptor::GPURenderPassAttachmentDescriptor(MTLRenderPassAttachmentDescriptor *attachmentDescriptor) >-{ >- LOG(WebGPU, "GPURenderPassAttachmentDescriptor::GPURenderPassAttachmentDescriptor()"); >- >- m_renderPassAttachmentDescriptor = attachmentDescriptor; >-} >- >-unsigned long GPURenderPassAttachmentDescriptor::loadAction() const >-{ >- if (!m_renderPassAttachmentDescriptor) >- return 0; // FIXME: WebGPU - There is probably a real value for this. >- >- return [m_renderPassAttachmentDescriptor loadAction]; >-} >- >-void GPURenderPassAttachmentDescriptor::setLoadAction(unsigned long newLoadAction) >-{ >- if (!m_renderPassAttachmentDescriptor) >- return; >- >- [m_renderPassAttachmentDescriptor setLoadAction:static_cast<MTLLoadAction>(newLoadAction)]; >-} >- >-unsigned long GPURenderPassAttachmentDescriptor::storeAction() const >-{ >- if (!m_renderPassAttachmentDescriptor) >- return 0; // FIXME: WebGPU - There is probably a real value for this. >- >- return [m_renderPassAttachmentDescriptor storeAction]; >-} >- >-void GPURenderPassAttachmentDescriptor::setStoreAction(unsigned long newStoreAction) >-{ >- if (!m_renderPassAttachmentDescriptor) >- return; >- >- [m_renderPassAttachmentDescriptor setStoreAction:static_cast<MTLStoreAction>(newStoreAction)]; >-} >- >-void GPURenderPassAttachmentDescriptor::setTexture(RefPtr<GPUTexture> texture) >-{ >- if (!m_renderPassAttachmentDescriptor) >- return; >- >- [m_renderPassAttachmentDescriptor setTexture:static_cast<id<MTLTexture>>(texture->platformTexture())]; >-} >- >-MTLRenderPassAttachmentDescriptor *GPURenderPassAttachmentDescriptor::platformRenderPassAttachmentDescriptor() >-{ >- return m_renderPassAttachmentDescriptor.get(); >-} >- >-} // namespace WebCore >- >-#endif >diff --git a/Source/WebCore/platform/graphics/cocoa/GPURenderPassColorAttachmentDescriptorMetal.mm b/Source/WebCore/platform/graphics/cocoa/GPURenderPassColorAttachmentDescriptorMetal.mm >deleted file mode 100644 >index 592cf652ad51f4f4a7a345ada9d2085f4e0c62de..0000000000000000000000000000000000000000 >--- a/Source/WebCore/platform/graphics/cocoa/GPURenderPassColorAttachmentDescriptorMetal.mm >+++ /dev/null >@@ -1,77 +0,0 @@ >-/* >- * Copyright (C) 2017 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#import "config.h" >-#import "GPURenderPassColorAttachmentDescriptor.h" >- >-#if ENABLE(WEBGPU) >- >-#import "GPURenderPassAttachmentDescriptor.h" >-#import "Logging.h" >- >-#import <Metal/Metal.h> >- >-namespace WebCore { >- >-RefPtr<GPURenderPassColorAttachmentDescriptor> GPURenderPassColorAttachmentDescriptor::create(MTLRenderPassColorAttachmentDescriptor *colorAttachmentDescriptor) >-{ >- RefPtr<GPURenderPassColorAttachmentDescriptor> descriptor = adoptRef(new GPURenderPassColorAttachmentDescriptor(colorAttachmentDescriptor)); >- return descriptor; >-} >- >-GPURenderPassColorAttachmentDescriptor::GPURenderPassColorAttachmentDescriptor(MTLRenderPassColorAttachmentDescriptor *attachmentDescriptor) >- : GPURenderPassAttachmentDescriptor(attachmentDescriptor) >-{ >- LOG(WebGPU, "GPURenderPassColorAttachmentDescriptor::GPURenderPassColorAttachmentDescriptor()"); >-} >- >-Vector<float> GPURenderPassColorAttachmentDescriptor::clearColor() const >-{ >- MTLRenderPassColorAttachmentDescriptor *colorAttachmentDescriptor = static_cast<MTLRenderPassColorAttachmentDescriptor *>(m_renderPassAttachmentDescriptor.get()); >- if (!colorAttachmentDescriptor) >- return Vector<float>(); >- >- MTLClearColor color = [colorAttachmentDescriptor clearColor]; >- return Vector<float>({static_cast<float>(color.red), static_cast<float>(color.green), static_cast<float>(color.blue), static_cast<float>(color.alpha)}); >-} >- >-void GPURenderPassColorAttachmentDescriptor::setClearColor(const Vector<float>& newClearColor) >-{ >- MTLRenderPassColorAttachmentDescriptor *colorAttachmentDescriptor = platformRenderPassColorAttachmentDescriptor(); >- if (!colorAttachmentDescriptor || newClearColor.size() != 4) >- return; >- >- MTLClearColor clearColor = MTLClearColorMake(newClearColor[0], newClearColor[1], newClearColor[2], newClearColor[3]); >- [colorAttachmentDescriptor setClearColor:clearColor]; >-} >- >-MTLRenderPassColorAttachmentDescriptor *GPURenderPassColorAttachmentDescriptor::platformRenderPassColorAttachmentDescriptor() >-{ >- return static_cast<MTLRenderPassColorAttachmentDescriptor *>(platformRenderPassAttachmentDescriptor()); >-} >- >-} // namespace WebCore >- >-#endif >diff --git a/Source/WebCore/platform/graphics/cocoa/GPURenderPassDepthAttachmentDescriptorMetal.mm b/Source/WebCore/platform/graphics/cocoa/GPURenderPassDepthAttachmentDescriptorMetal.mm >deleted file mode 100644 >index 582d891e99323caf9aae147510d3ad0fecfb64c8..0000000000000000000000000000000000000000 >--- a/Source/WebCore/platform/graphics/cocoa/GPURenderPassDepthAttachmentDescriptorMetal.mm >+++ /dev/null >@@ -1,72 +0,0 @@ >-/* >- * Copyright (C) 2017 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#import "config.h" >-#import "GPURenderPassDepthAttachmentDescriptor.h" >- >-#if ENABLE(WEBGPU) >- >-#import "GPURenderPassAttachmentDescriptor.h" >-#import "Logging.h" >- >-#import <Metal/Metal.h> >- >-namespace WebCore { >- >-RefPtr<GPURenderPassDepthAttachmentDescriptor> GPURenderPassDepthAttachmentDescriptor::create(MTLRenderPassDepthAttachmentDescriptor *depthAttachmentDescriptor) >-{ >- RefPtr<GPURenderPassDepthAttachmentDescriptor> descriptor = adoptRef(new GPURenderPassDepthAttachmentDescriptor(depthAttachmentDescriptor)); >- return descriptor; >-} >- >-GPURenderPassDepthAttachmentDescriptor::GPURenderPassDepthAttachmentDescriptor(MTLRenderPassDepthAttachmentDescriptor *attachmentDescriptor) >- : GPURenderPassAttachmentDescriptor(attachmentDescriptor) >-{ >- LOG(WebGPU, "GPURenderPassDepthAttachmentDescriptor::GPURenderPassDepthAttachmentDescriptor()"); >-} >- >-double GPURenderPassDepthAttachmentDescriptor::clearDepth() const >-{ >- MTLRenderPassDepthAttachmentDescriptor *depthAttachmentDescriptor = static_cast<MTLRenderPassDepthAttachmentDescriptor *>(m_renderPassAttachmentDescriptor.get()); >- if (!depthAttachmentDescriptor) >- return 0; >- >- return [depthAttachmentDescriptor clearDepth]; >-} >- >-void GPURenderPassDepthAttachmentDescriptor::setClearDepth(double newClearDepth) >-{ >- MTLRenderPassDepthAttachmentDescriptor *depthAttachmentDescriptor = platformRenderPassDepthAttachmentDescriptor(); >- [depthAttachmentDescriptor setClearDepth:newClearDepth]; >-} >- >-MTLRenderPassDepthAttachmentDescriptor *GPURenderPassDepthAttachmentDescriptor::platformRenderPassDepthAttachmentDescriptor() >-{ >- return static_cast<MTLRenderPassDepthAttachmentDescriptor *>(platformRenderPassAttachmentDescriptor()); >-} >- >-} // namespace WebCore >- >-#endif >diff --git a/Source/WebCore/platform/graphics/cocoa/GPURenderPassDescriptorMetal.mm b/Source/WebCore/platform/graphics/cocoa/GPURenderPassDescriptorMetal.mm >deleted file mode 100644 >index 97983eb04029f4e47c0ac53af42f18c611a4cae6..0000000000000000000000000000000000000000 >--- a/Source/WebCore/platform/graphics/cocoa/GPURenderPassDescriptorMetal.mm >+++ /dev/null >@@ -1,74 +0,0 @@ >-/* >- * Copyright (C) 2017 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#import "config.h" >-#import "GPURenderPassDescriptor.h" >- >-#if ENABLE(WEBGPU) >- >-#import "GPURenderPassColorAttachmentDescriptor.h" >-#import "GPURenderPassDepthAttachmentDescriptor.h" >-#import "Logging.h" >- >-#import <Metal/Metal.h> >- >-namespace WebCore { >- >-GPURenderPassDescriptor::GPURenderPassDescriptor() >-{ >- LOG(WebGPU, "GPURenderPassDescriptor::GPURenderPassDescriptor()"); >- >- m_renderPassDescriptor = adoptNS((MTLRenderPassDescriptor *)[MTLRenderPassDescriptor new]); >-} >- >-Vector<RefPtr<GPURenderPassColorAttachmentDescriptor>> GPURenderPassDescriptor::colorAttachments() >-{ >- if (!m_renderPassDescriptor) >- return Vector<RefPtr<GPURenderPassColorAttachmentDescriptor>>(); >- >- Vector<RefPtr<GPURenderPassColorAttachmentDescriptor>> platformColorAttachments; >- platformColorAttachments.append(GPURenderPassColorAttachmentDescriptor::create([[m_renderPassDescriptor colorAttachments] objectAtIndexedSubscript:0])); >- return platformColorAttachments; >-} >- >-RefPtr<GPURenderPassDepthAttachmentDescriptor> GPURenderPassDescriptor::depthAttachment() >-{ >- if (!m_renderPassDescriptor) >- return nullptr; >- >- if (!m_depthAttachment) >- m_depthAttachment = GPURenderPassDepthAttachmentDescriptor::create([m_renderPassDescriptor depthAttachment]); >- >- return m_depthAttachment; >-} >- >-MTLRenderPassDescriptor *GPURenderPassDescriptor::platformRenderPassDescriptor() >-{ >- return m_renderPassDescriptor.get(); >-} >- >-} // namespace WebCore >- >-#endif >diff --git a/Source/WebCore/platform/graphics/cocoa/GPURenderPipelineColorAttachmentDescriptorMetal.mm b/Source/WebCore/platform/graphics/cocoa/GPURenderPipelineColorAttachmentDescriptorMetal.mm >deleted file mode 100644 >index 06627f6f446db6969de23313f375cdce133e4500..0000000000000000000000000000000000000000 >--- a/Source/WebCore/platform/graphics/cocoa/GPURenderPipelineColorAttachmentDescriptorMetal.mm >+++ /dev/null >@@ -1,71 +0,0 @@ >-/* >- * Copyright (C) 2017 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#import "config.h" >-#import "GPURenderPipelineColorAttachmentDescriptor.h" >- >-#if ENABLE(WEBGPU) >- >-#import "Logging.h" >- >-#import <Metal/Metal.h> >- >-namespace WebCore { >- >-RefPtr<GPURenderPipelineColorAttachmentDescriptor> GPURenderPipelineColorAttachmentDescriptor::create(MTLRenderPipelineColorAttachmentDescriptor *attachmentDescriptor) >-{ >- RefPtr<GPURenderPipelineColorAttachmentDescriptor> descriptor = adoptRef(new GPURenderPipelineColorAttachmentDescriptor(attachmentDescriptor)); >- return descriptor; >-} >- >-GPURenderPipelineColorAttachmentDescriptor::GPURenderPipelineColorAttachmentDescriptor(MTLRenderPipelineColorAttachmentDescriptor *attachmentDescriptor) >-{ >- LOG(WebGPU, "GPURenderPipelineColorAttachmentDescriptor::GPURenderPipelineColorAttachmentDescriptor()"); >- >- m_renderPipelineColorAttachmentDescriptor = attachmentDescriptor; >-} >- >-unsigned long GPURenderPipelineColorAttachmentDescriptor::pixelFormat() const >-{ >- if (!m_renderPipelineColorAttachmentDescriptor) >- return 0; // FIXME: WebGPU - There is probably a real value for this. >- >- return [m_renderPipelineColorAttachmentDescriptor pixelFormat]; >-} >- >-void GPURenderPipelineColorAttachmentDescriptor::setPixelFormat(unsigned long newPixelFormat) >-{ >- ASSERT(m_renderPipelineColorAttachmentDescriptor); >- [m_renderPipelineColorAttachmentDescriptor setPixelFormat:static_cast<MTLPixelFormat>(newPixelFormat)]; >-} >- >-MTLRenderPipelineColorAttachmentDescriptor *GPURenderPipelineColorAttachmentDescriptor::platformRenderPipelineColorAttachmentDescriptor() >-{ >- return m_renderPipelineColorAttachmentDescriptor.get(); >-} >- >-} // namespace WebCore >- >-#endif >diff --git a/Source/WebCore/platform/graphics/cocoa/GPURenderPipelineDescriptorMetal.mm b/Source/WebCore/platform/graphics/cocoa/GPURenderPipelineDescriptorMetal.mm >deleted file mode 100644 >index 1e0b637270f7071e3f04d7978b4fa0acc702a803..0000000000000000000000000000000000000000 >--- a/Source/WebCore/platform/graphics/cocoa/GPURenderPipelineDescriptorMetal.mm >+++ /dev/null >@@ -1,96 +0,0 @@ >-/* >- * Copyright (C) 2017 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#import "config.h" >-#import "GPURenderPipelineDescriptor.h" >- >-#if ENABLE(WEBGPU) >- >-#import "GPUFunction.h" >-#import "GPURenderPipelineColorAttachmentDescriptor.h" >-#import "Logging.h" >- >-#import <Metal/Metal.h> >- >-namespace WebCore { >- >-GPURenderPipelineDescriptor::GPURenderPipelineDescriptor() >-{ >- LOG(WebGPU, "GPURenderPipelineDescriptor::GPURenderPipelineDescriptor()"); >- >- m_renderPipelineDescriptor = adoptNS((MTLRenderPipelineDescriptor *)[MTLRenderPipelineDescriptor new]); >-} >- >-unsigned long GPURenderPipelineDescriptor::depthAttachmentPixelFormat() const >-{ >- if (!m_renderPipelineDescriptor) >- return 0; >- return [m_renderPipelineDescriptor depthAttachmentPixelFormat]; >-} >- >-void GPURenderPipelineDescriptor::setDepthAttachmentPixelFormat(unsigned long newPixelFormat) >-{ >- ASSERT(m_renderPipelineDescriptor); >- [m_renderPipelineDescriptor setDepthAttachmentPixelFormat:static_cast<MTLPixelFormat>(newPixelFormat)]; >-} >- >-void GPURenderPipelineDescriptor::setVertexFunction(RefPtr<GPUFunction> newFunction) >-{ >- ASSERT(m_renderPipelineDescriptor); >- [m_renderPipelineDescriptor setVertexFunction:(id<MTLFunction>)newFunction->platformFunction()]; >-} >- >-void GPURenderPipelineDescriptor::setFragmentFunction(RefPtr<GPUFunction> newFunction) >-{ >- ASSERT(m_renderPipelineDescriptor); >- [m_renderPipelineDescriptor setFragmentFunction:(id<MTLFunction>)newFunction->platformFunction()]; >-} >- >-Vector<RefPtr<GPURenderPipelineColorAttachmentDescriptor>> GPURenderPipelineDescriptor::colorAttachments() >-{ >- if (!m_renderPipelineDescriptor) >- return Vector<RefPtr<GPURenderPipelineColorAttachmentDescriptor>>(); >- >- Vector<RefPtr<GPURenderPipelineColorAttachmentDescriptor>> platformColorAttachments; >- platformColorAttachments.append(GPURenderPipelineColorAttachmentDescriptor::create([[m_renderPipelineDescriptor colorAttachments] objectAtIndexedSubscript:0])); >- return platformColorAttachments; >-} >- >-void GPURenderPipelineDescriptor::reset() >-{ >- if (!m_renderPipelineDescriptor) >- return; >- >- [m_renderPipelineDescriptor reset]; >-} >- >-MTLRenderPipelineDescriptor *GPURenderPipelineDescriptor::platformRenderPipelineDescriptor() >-{ >- return m_renderPipelineDescriptor.get(); >-} >- >-} // namespace WebCore >- >-#endif >diff --git a/Source/WebCore/platform/graphics/cocoa/GPURenderPipelineStateMetal.mm b/Source/WebCore/platform/graphics/cocoa/GPURenderPipelineStateMetal.mm >deleted file mode 100644 >index a3418a46d24856a502c517f88685abfa09cf69bc..0000000000000000000000000000000000000000 >--- a/Source/WebCore/platform/graphics/cocoa/GPURenderPipelineStateMetal.mm >+++ /dev/null >@@ -1,70 +0,0 @@ >-/* >- * Copyright (C) 2017 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#import "config.h" >-#import "GPURenderPipelineState.h" >- >-#if ENABLE(WEBGPU) >- >-#import "GPUDevice.h" >-#import "GPURenderPipelineDescriptor.h" >-#import "Logging.h" >- >-#import <Metal/Metal.h> >- >-namespace WebCore { >- >-GPURenderPipelineState::GPURenderPipelineState(GPUDevice* device, GPURenderPipelineDescriptor* descriptor) >-{ >- LOG(WebGPU, "GPURenderPipelineState::GPURenderPipelineState()"); >- >- if (!device || !device->platformDevice() || !descriptor || !descriptor->platformRenderPipelineDescriptor()) >- return; >- >- m_renderPipelineState = adoptNS((MTLRenderPipelineState *)[device->platformDevice() newRenderPipelineStateWithDescriptor:descriptor->platformRenderPipelineDescriptor() error:nil]); >-} >- >-String GPURenderPipelineState::label() const >-{ >- if (!m_renderPipelineState) >- return emptyString(); >- >- return [m_renderPipelineState label]; >-} >- >-void GPURenderPipelineState::setLabel(const String& label) >-{ >- ASSERT(m_renderPipelineState); >- [m_renderPipelineState setLabel:label]; >-} >- >-MTLRenderPipelineState *GPURenderPipelineState::platformRenderPipelineState() >-{ >- return m_renderPipelineState.get(); >-} >- >-} // namespace WebCore >- >-#endif >diff --git a/Source/WebCore/platform/graphics/cocoa/GPUTextureDescriptorMetal.mm b/Source/WebCore/platform/graphics/cocoa/GPUTextureDescriptorMetal.mm >deleted file mode 100644 >index a3877c741f7c1034fc4dfb8dc86c018df2ff344f..0000000000000000000000000000000000000000 >--- a/Source/WebCore/platform/graphics/cocoa/GPUTextureDescriptorMetal.mm >+++ /dev/null >@@ -1,129 +0,0 @@ >-/* >- * Copyright (C) 2017 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#import "config.h" >-#import "GPUTextureDescriptor.h" >- >-#if ENABLE(WEBGPU) >- >-#import "Logging.h" >- >-#import <Metal/Metal.h> >- >-namespace WebCore { >- >-GPUTextureDescriptor::GPUTextureDescriptor(unsigned long pixelFormat, unsigned long width, unsigned long height, bool mipmapped) >-{ >- LOG(WebGPU, "GPUTextureDescriptor::GPUTextureDescriptor()"); >- >- m_textureDescriptor = (MTLTextureDescriptor *)[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:static_cast<MTLPixelFormat>(pixelFormat) width:width height:height mipmapped:mipmapped]; >-} >- >-unsigned long GPUTextureDescriptor::width() const >-{ >- if (!m_textureDescriptor) >- return 0; >- return [m_textureDescriptor width]; >-} >- >-void GPUTextureDescriptor::setWidth(unsigned long newWidth) >-{ >- ASSERT(m_textureDescriptor); >- [m_textureDescriptor setWidth:newWidth]; >-} >- >-unsigned long GPUTextureDescriptor::height() const >-{ >- if (!m_textureDescriptor) >- return 0; >- return [m_textureDescriptor height]; >-} >- >-void GPUTextureDescriptor::setHeight(unsigned long newHeight) >-{ >- ASSERT(m_textureDescriptor); >- [m_textureDescriptor setHeight:newHeight]; >-} >- >-unsigned long GPUTextureDescriptor::sampleCount() const >-{ >- if (!m_textureDescriptor) >- return 0; >- return [m_textureDescriptor sampleCount]; >-} >- >-void GPUTextureDescriptor::setSampleCount(unsigned long newSampleCount) >-{ >- ASSERT(m_textureDescriptor); >- [m_textureDescriptor setSampleCount:newSampleCount]; >-} >- >-unsigned long GPUTextureDescriptor::textureType() const >-{ >- if (!m_textureDescriptor) >- return 0; >- return [m_textureDescriptor textureType]; >-} >- >-void GPUTextureDescriptor::setTextureType(unsigned long newTextureType) >-{ >- ASSERT(m_textureDescriptor); >- [m_textureDescriptor setTextureType:static_cast<MTLTextureType>(newTextureType)]; >-} >- >-unsigned long GPUTextureDescriptor::storageMode() const >-{ >- if (!m_textureDescriptor) >- return 0; >- return [m_textureDescriptor storageMode]; >-} >- >-void GPUTextureDescriptor::setStorageMode(unsigned long newStorageMode) >-{ >- ASSERT(m_textureDescriptor); >- [m_textureDescriptor setStorageMode:static_cast<MTLStorageMode>(newStorageMode)]; >-} >- >-unsigned long GPUTextureDescriptor::usage() const >-{ >- if (!m_textureDescriptor) >- return 0; >- return [m_textureDescriptor usage]; >-} >- >-void GPUTextureDescriptor::setUsage(unsigned long newUsage) >-{ >- ASSERT(m_textureDescriptor); >- [m_textureDescriptor setUsage:newUsage]; >-} >- >-MTLTextureDescriptor *GPUTextureDescriptor::platformTextureDescriptor() >-{ >- return m_textureDescriptor.get(); >-} >- >-} // namespace WebCore >- >-#endif >diff --git a/Source/WebCore/platform/graphics/cocoa/GPUTextureMetal.mm b/Source/WebCore/platform/graphics/cocoa/GPUTextureMetal.mm >deleted file mode 100644 >index b1d0f78a7dac77dfd407cbd68cc7dabe6a93de58..0000000000000000000000000000000000000000 >--- a/Source/WebCore/platform/graphics/cocoa/GPUTextureMetal.mm >+++ /dev/null >@@ -1,82 +0,0 @@ >-/* >- * Copyright (C) 2017 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#import "config.h" >-#import "GPUTexture.h" >- >-#if ENABLE(WEBGPU) >- >-#import "GPUDevice.h" >-#import "GPUDrawable.h" >-#import "GPUTextureDescriptor.h" >-#import "Logging.h" >- >-#import <Metal/Metal.h> >- >-namespace WebCore { >- >-GPUTexture::GPUTexture(GPUDevice* device, GPUTextureDescriptor* descriptor) >-{ >- LOG(WebGPU, "GPUTexture::GPUTexture()"); >- >- if (!device || !device->platformDevice() || !descriptor || !descriptor->platformTextureDescriptor()) >- return; >- >- m_texture = adoptNS((MTLTexture *)[device->platformDevice() newTextureWithDescriptor:descriptor->platformTextureDescriptor()]); >-} >- >-GPUTexture::GPUTexture(GPUDrawable* other) >-{ >- LOG(WebGPU, "GPUTexture::GPUTexture()"); >- >- m_texture = other->platformTexture(); >-} >- >-unsigned long GPUTexture::width() const >-{ >- if (!m_texture) >- return 0; >- >- id<MTLTexture> texture = static_cast<id<MTLTexture>>(m_texture.get()); >- return texture.width; >-} >- >-unsigned long GPUTexture::height() const >-{ >- if (!m_texture) >- return 0; >- >- id<MTLTexture> texture = static_cast<id<MTLTexture>>(m_texture.get()); >- return texture.height; >-} >- >-MTLTexture *GPUTexture::platformTexture() >-{ >- return m_texture.get(); >-} >- >-} // namespace WebCore >- >-#endif >diff --git a/Source/WebCore/platform/graphics/cocoa/WebCoreDecompressionSession.mm b/Source/WebCore/platform/graphics/cocoa/WebCoreDecompressionSession.mm >index b762ea94cac2917db06476b61f7ebb3b097d4e40..f0debc03e5f07cf6dfc75fbb48b2f46257168628 100644 >--- a/Source/WebCore/platform/graphics/cocoa/WebCoreDecompressionSession.mm >+++ b/Source/WebCore/platform/graphics/cocoa/WebCoreDecompressionSession.mm >@@ -33,13 +33,14 @@ > #import <CoreMedia/CMBufferQueue.h> > #import <CoreMedia/CMFormatDescription.h> > #import <pal/avfoundation/MediaTimeAVFoundation.h> >+#import <pal/cf/CoreMediaSoftLink.h> > #import <wtf/MainThread.h> > #import <wtf/MediaTime.h> >+#import <wtf/MonotonicTime.h> > #import <wtf/StringPrintStream.h> > #import <wtf/Vector.h> > #import <wtf/cf/TypeCastsCF.h> > >-#import <pal/cf/CoreMediaSoftLink.h> > #import "CoreVideoSoftLink.h" > #import "VideoToolboxSoftLink.h" > >diff --git a/Source/WebCore/platform/graphics/gpu/GPUBuffer.cpp b/Source/WebCore/platform/graphics/gpu/GPUBuffer.cpp >index 516156a30652d956d48a6438cae4ad766c37d417..01b1ee73543a0360426eb02109248c1836da0486 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPUBuffer.cpp >+++ b/Source/WebCore/platform/graphics/gpu/GPUBuffer.cpp >@@ -28,37 +28,20 @@ > > #if ENABLE(WEBGPU) > >-#include "GPUDevice.h" > #include "Logging.h" >+#include <JavaScriptCore/ArrayBuffer.h> > > namespace WebCore { > >-RefPtr<GPUBuffer> GPUBuffer::create(GPUDevice* device, ArrayBufferView* arrayBuffer) >-{ >- RefPtr<GPUBuffer> buffer = adoptRef(new GPUBuffer(device, arrayBuffer)); >- return buffer; >-} >- > GPUBuffer::~GPUBuffer() > { > LOG(WebGPU, "GPUBuffer::~GPUBuffer()"); > } > >-#if !PLATFORM(COCOA) >-unsigned long GPUBuffer::length() const >-{ >- return 0; >-} >- >-RefPtr<ArrayBuffer> GPUBuffer::contents() >+unsigned GPUBuffer::length() const > { >- if (m_contents) >- return m_contents; >- >- m_contents = ArrayBuffer::create(nullptr, 1); >- return m_contents; >+ return m_contents ? m_contents->byteLength() : 0; > } >-#endif > > } // namespace WebCore > >diff --git a/Source/WebCore/platform/graphics/gpu/GPUBuffer.h b/Source/WebCore/platform/graphics/gpu/GPUBuffer.h >index 5fab99a05a765f80d83ee331d559fe0c99903b44..b572133ca288eb085d939cb50798cee827041162 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPUBuffer.h >+++ b/Source/WebCore/platform/graphics/gpu/GPUBuffer.h >@@ -27,38 +27,39 @@ > > #if ENABLE(WEBGPU) > >-#include <JavaScriptCore/ArrayBufferView.h> > #include <wtf/RefPtr.h> > #include <wtf/RetainPtr.h> > >-#if PLATFORM(COCOA) >-OBJC_CLASS MTLBuffer; >-#endif >+OBJC_PROTOCOL(MTLBuffer); >+ >+namespace JSC { >+class ArrayBuffer; >+class ArrayBufferView; >+} > > namespace WebCore { > > class GPUDevice; > >-class GPUBuffer : public RefCounted<GPUBuffer> { >+class GPUBuffer { > public: >- static RefPtr<GPUBuffer> create(GPUDevice*, ArrayBufferView*); >+ WEBCORE_EXPORT GPUBuffer(const GPUDevice&, const JSC::ArrayBufferView&); > WEBCORE_EXPORT ~GPUBuffer(); > >- WEBCORE_EXPORT unsigned long length() const; >- WEBCORE_EXPORT RefPtr<ArrayBuffer> contents(); >+ WEBCORE_EXPORT unsigned length() const; >+ JSC::ArrayBuffer* contents() const { return m_contents.get(); } > >-#if PLATFORM(COCOA) >- WEBCORE_EXPORT MTLBuffer *platformBuffer(); >+#if USE(METAL) >+ MTLBuffer *metal() const { return m_metal.get(); } > #endif > > private: >- GPUBuffer(GPUDevice*, ArrayBufferView*); >- >-#if PLATFORM(COCOA) >- RetainPtr<MTLBuffer> m_buffer; >+#if USE(METAL) >+ RetainPtr<MTLBuffer> m_metal; > #endif >- RefPtr<ArrayBuffer> m_contents; >+ RefPtr<JSC::ArrayBuffer> m_contents; > }; > > } // namespace WebCore >+ > #endif >diff --git a/Source/WebCore/platform/graphics/gpu/GPUCommandBuffer.cpp b/Source/WebCore/platform/graphics/gpu/GPUCommandBuffer.cpp >index 3b693608d0cd79103fb3ea6bc8491e70332a9828..282c8290833385eaf7fac2efca83a6f7e17cdb29 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPUCommandBuffer.cpp >+++ b/Source/WebCore/platform/graphics/gpu/GPUCommandBuffer.cpp >@@ -29,47 +29,15 @@ > > #if ENABLE(WEBGPU) > >-#include "GPUCommandQueue.h" >-#include "GPUComputeCommandEncoder.h" >-#include "GPUDevice.h" >-#include "GPURenderCommandEncoder.h" >-#include "GPURenderPassDescriptor.h" > #include "Logging.h" > > namespace WebCore { > >-RefPtr<GPUCommandBuffer> GPUCommandBuffer::create(GPUCommandQueue* queue) >-{ >- RefPtr<GPUCommandBuffer> buffer = adoptRef(new GPUCommandBuffer(queue)); >- return buffer; >-} >- > GPUCommandBuffer::~GPUCommandBuffer() > { > LOG(WebGPU, "GPUCommandBuffer::~GPUCommandBuffer()"); > } > >-RefPtr<GPURenderCommandEncoder> GPUCommandBuffer::createRenderCommandEncoder(GPURenderPassDescriptor* descriptor) >-{ >- return GPURenderCommandEncoder::create(this, descriptor); >-} >- >-RefPtr<GPUComputeCommandEncoder> GPUCommandBuffer::createComputeCommandEncoder() >-{ >- return GPUComputeCommandEncoder::create(this); >-} >- >-#if !PLATFORM(COCOA) >-void GPUCommandBuffer::presentDrawable(GPUDrawable*) >-{ >-} >- >-DOMPromiseProxy<IDLVoid>& GPUCommandBuffer::completed(); >-{ >- return m_completedPromise; >-} >-#endif >- > } // namespace WebCore > > #endif >diff --git a/Source/WebCore/platform/graphics/gpu/GPUCommandBuffer.h b/Source/WebCore/platform/graphics/gpu/GPUCommandBuffer.h >index dced276f23a6d1d4d2e0c00e884d2c2096b90493..456cf4899ccdd4dabcc79e1622309868016fba65 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPUCommandBuffer.h >+++ b/Source/WebCore/platform/graphics/gpu/GPUCommandBuffer.h >@@ -28,48 +28,34 @@ > > #if ENABLE(WEBGPU) > >-#include "DOMPromiseProxy.h" >-#include <wtf/RefCounted.h> >-#include <wtf/RefPtr.h> >+#include <wtf/Function.h> > #include <wtf/RetainPtr.h> > >-#if PLATFORM(COCOA) >-OBJC_CLASS MTLCommandBuffer; >-#endif >+OBJC_PROTOCOL(MTLCommandBuffer); > > namespace WebCore { > > class GPUCommandQueue; >-class GPUComputeCommandEncoder; > class GPUDrawable; >-class GPURenderCommandEncoder; >-class GPURenderPassDescriptor; > >-class GPUCommandBuffer : public RefCounted<GPUCommandBuffer> { >+class GPUCommandBuffer { > public: >- static RefPtr<GPUCommandBuffer> create(GPUCommandQueue*); >- WEBCORE_EXPORT ~GPUCommandBuffer(); >- >- WEBCORE_EXPORT void commit(); >- WEBCORE_EXPORT void presentDrawable(GPUDrawable*); >+ explicit GPUCommandBuffer(const GPUCommandQueue&, Function<void()>&& completedCallback); >+ ~GPUCommandBuffer(); > >- WEBCORE_EXPORT RefPtr<GPURenderCommandEncoder> createRenderCommandEncoder(GPURenderPassDescriptor*); >- WEBCORE_EXPORT RefPtr<GPUComputeCommandEncoder> createComputeCommandEncoder(); >- WEBCORE_EXPORT DOMPromiseProxy<IDLVoid>& completed(); >+ void commit() const; >+ void presentDrawable(GPUDrawable&) const; > >-#if PLATFORM(COCOA) >- WEBCORE_EXPORT MTLCommandBuffer *platformCommandBuffer(); >+#if USE(METAL) >+ MTLCommandBuffer *metal() const { return m_metal.get(); } > #endif > >+#if USE(METAL) > private: >- GPUCommandBuffer(GPUCommandQueue*); >- >-#if PLATFORM(COCOA) >- RetainPtr<MTLCommandBuffer> m_commandBuffer; >+ RetainPtr<MTLCommandBuffer> m_metal; > #endif >- >- DOMPromiseProxy<IDLVoid> m_completedPromise; > }; > > } // namespace WebCore >+ > #endif >diff --git a/Source/WebCore/platform/graphics/gpu/GPUCommandQueue.cpp b/Source/WebCore/platform/graphics/gpu/GPUCommandQueue.cpp >index ee357b2ac081331d7f512640e92b8d29c2b195e5..8222ace88c54abbb81e8a42cf774093c0b0baf69 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPUCommandQueue.cpp >+++ b/Source/WebCore/platform/graphics/gpu/GPUCommandQueue.cpp >@@ -28,39 +28,15 @@ > > #if ENABLE(WEBGPU) > >-#include "GPUCommandBuffer.h" >-#include "GPUDevice.h" > #include "Logging.h" > > namespace WebCore { > >-RefPtr<GPUCommandQueue> GPUCommandQueue::create(GPUDevice* device) >-{ >- RefPtr<GPUCommandQueue> queue = adoptRef(new GPUCommandQueue(device)); >- return queue; >-} >- > GPUCommandQueue::~GPUCommandQueue() > { > LOG(WebGPU, "GPUCommandQueue::~GPUCommandQueue()"); > } > >-RefPtr<GPUCommandBuffer> GPUCommandQueue::createCommandBuffer() >-{ >- return GPUCommandBuffer::create(this); >-} >- >-#if !PLATFORM(COCOA) >-String GPUCommandQueue::label() const >-{ >- return emptyString(); >-} >- >-void GPUCommandQueue::setLabel(const String&) >-{ >-} >-#endif >- > } // namespace WebCore > > #endif >diff --git a/Source/WebCore/platform/graphics/gpu/GPUCommandQueue.h b/Source/WebCore/platform/graphics/gpu/GPUCommandQueue.h >index 2a19e7250fabb1b85e173a7c361f9b8fe90dc8dd..e3d1e4c85b1aac7c0317ada3e3aeb4558de17d71 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPUCommandQueue.h >+++ b/Source/WebCore/platform/graphics/gpu/GPUCommandQueue.h >@@ -27,41 +27,32 @@ > > #if ENABLE(WEBGPU) > >-#include <wtf/RefCounted.h> >-#include <wtf/RefPtr.h> > #include <wtf/RetainPtr.h> >-#include <wtf/text/WTFString.h> > >-#if PLATFORM(COCOA) >-OBJC_CLASS MTLCommandQueue; >-#endif >+OBJC_PROTOCOL(MTLCommandQueue); > > namespace WebCore { > >-class GPUCommandBuffer; > class GPUDevice; > >-class GPUCommandQueue : public RefCounted<GPUCommandQueue> { >+class GPUCommandQueue { > public: >- static RefPtr<GPUCommandQueue> create(GPUDevice*); >+ WEBCORE_EXPORT explicit GPUCommandQueue(const GPUDevice&); > WEBCORE_EXPORT ~GPUCommandQueue(); > > WEBCORE_EXPORT String label() const; >- WEBCORE_EXPORT void setLabel(const String&); >- >- WEBCORE_EXPORT RefPtr<GPUCommandBuffer> createCommandBuffer(); >+ WEBCORE_EXPORT void setLabel(const String&) const; > >-#if PLATFORM(COCOA) >- WEBCORE_EXPORT MTLCommandQueue *platformCommandQueue(); >+#if USE(METAL) >+ MTLCommandQueue *metal() const { return m_metal.get(); } > #endif > >+#if USE(METAL) > private: >- GPUCommandQueue(GPUDevice*); >- >-#if PLATFORM(COCOA) >- RetainPtr<MTLCommandQueue> m_commandQueue; >+ RetainPtr<MTLCommandQueue> m_metal; > #endif > }; > > } // namespace WebCore >+ > #endif >diff --git a/Source/WebCore/platform/graphics/gpu/GPUComputeCommandEncoder.cpp b/Source/WebCore/platform/graphics/gpu/GPUComputeCommandEncoder.cpp >index cb8591a607a5cdf4a60185fe24f17d17acb7708b..c1b835362051585cc504858d19dfb91f040cd246 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPUComputeCommandEncoder.cpp >+++ b/Source/WebCore/platform/graphics/gpu/GPUComputeCommandEncoder.cpp >@@ -28,42 +28,15 @@ > > #if ENABLE(WEBGPU) > >-#include "GPUBuffer.h" >-#include "GPUCommandBuffer.h" >-#include "GPUComputePipelineState.h" > #include "Logging.h" > > namespace WebCore { > >-RefPtr<GPUComputeCommandEncoder> GPUComputeCommandEncoder::create(GPUCommandBuffer* buffer) >-{ >- RefPtr<GPUComputeCommandEncoder> encoder = adoptRef(new GPUComputeCommandEncoder(buffer)); >- return encoder; >-} >- > GPUComputeCommandEncoder::~GPUComputeCommandEncoder() > { > LOG(WebGPU, "GPUComputeCommandEncoder::~GPUComputeCommandEncoder()"); > } > >-#if !PLATFORM(COCOA) >-void GPUComputeCommandEncoder::setComputePipelineState(GPUComputePipelineState*) >-{ >-} >- >-void GPUComputeCommandEncoder::setBuffer(GPUBuffer*, unsigned, unsigned) >-{ >-} >- >-void GPUComputeCommandEncoder::dispatch(GPUSize threadgroupsPerGrid, GPUSize threadsPerThreadgroup); >-{ >-} >- >-void GPUComputeCommandEncoder::endEncoding() >-{ >-} >-#endif >- > } // namespace WebCore > > #endif >diff --git a/Source/WebCore/platform/graphics/gpu/GPUComputeCommandEncoder.h b/Source/WebCore/platform/graphics/gpu/GPUComputeCommandEncoder.h >index c6cad3223dce4f391a9a96a0a7e1fd96d731268e..cf167c34a6c36cc412b201f57e10ad7ac762ceae 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPUComputeCommandEncoder.h >+++ b/Source/WebCore/platform/graphics/gpu/GPUComputeCommandEncoder.h >@@ -27,14 +27,9 @@ > > #if ENABLE(WEBGPU) > >-#include "GPUSize.h" >-#include <wtf/RefCounted.h> >-#include <wtf/RefPtr.h> > #include <wtf/RetainPtr.h> > >-#if PLATFORM(COCOA) >-OBJC_CLASS MTLComputeCommandEncoder; >-#endif >+OBJC_PROTOCOL(MTLComputeCommandEncoder); > > namespace WebCore { > >@@ -42,27 +37,24 @@ class GPUBuffer; > class GPUCommandBuffer; > class GPUComputePipelineState; > >-class GPUComputeCommandEncoder : public RefCounted<GPUComputeCommandEncoder> { >+struct GPUSize; >+ >+class GPUComputeCommandEncoder { > public: >- static RefPtr<GPUComputeCommandEncoder> create(GPUCommandBuffer*); >- WEBCORE_EXPORT ~GPUComputeCommandEncoder(); >- >- WEBCORE_EXPORT void setComputePipelineState(GPUComputePipelineState*); >- WEBCORE_EXPORT void setBuffer(GPUBuffer*, unsigned, unsigned); >- WEBCORE_EXPORT void dispatch(GPUSize, GPUSize); >- WEBCORE_EXPORT void endEncoding(); >- >-#if PLATFORM(COCOA) >- WEBCORE_EXPORT MTLComputeCommandEncoder *platformComputeCommandEncoder(); >-#endif >- >+ explicit GPUComputeCommandEncoder(const GPUCommandBuffer&); >+ ~GPUComputeCommandEncoder(); >+ >+ void setComputePipelineState(const GPUComputePipelineState&) const; >+ void setBuffer(const GPUBuffer&, unsigned, unsigned) const; >+ void dispatch(GPUSize, GPUSize) const; >+ void endEncoding() const; >+ >+#if USE(METAL) > private: >- GPUComputeCommandEncoder(GPUCommandBuffer*); >- >-#if PLATFORM(COCOA) >- RetainPtr<MTLComputeCommandEncoder> m_computeCommandEncoder; >+ RetainPtr<MTLComputeCommandEncoder> m_metal; > #endif > }; > > } // namespace WebCore >+ > #endif >diff --git a/Source/WebCore/platform/graphics/gpu/GPUComputePipelineState.cpp b/Source/WebCore/platform/graphics/gpu/GPUComputePipelineState.cpp >index 864e98fa4bfcf0d3f49ba47a2c0859259fbf0980..c15829a94ab4023bcfa717f29cf2b29d4c2466ed 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPUComputePipelineState.cpp >+++ b/Source/WebCore/platform/graphics/gpu/GPUComputePipelineState.cpp >@@ -28,17 +28,10 @@ > > #if ENABLE(WEBGPU) > >-#include "GPUDevice.h" > #include "Logging.h" > > namespace WebCore { > >-RefPtr<GPUComputePipelineState> GPUComputePipelineState::create(GPUDevice* device, GPUFunction* function) >-{ >- RefPtr<GPUComputePipelineState> state = adoptRef(new GPUComputePipelineState(device, function)); >- return state; >-} >- > GPUComputePipelineState::~GPUComputePipelineState() > { > LOG(WebGPU, "GPUComputePipelineState::~GPUComputePipelineState()"); >diff --git a/Source/WebCore/platform/graphics/gpu/GPUComputePipelineState.h b/Source/WebCore/platform/graphics/gpu/GPUComputePipelineState.h >index fe184c1c8e2f30126a48e8331e7cf160d5999e23..10e0b4d76ed24eaf53e428eb2dbb488455686c80 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPUComputePipelineState.h >+++ b/Source/WebCore/platform/graphics/gpu/GPUComputePipelineState.h >@@ -27,36 +27,31 @@ > > #if ENABLE(WEBGPU) > >-#include <wtf/RefCounted.h> >-#include <wtf/RefPtr.h> > #include <wtf/RetainPtr.h> >-#include <wtf/text/WTFString.h> > >-#if PLATFORM(COCOA) >-OBJC_CLASS MTLComputePipelineState; >-#endif >+OBJC_PROTOCOL(MTLComputePipelineState); > > namespace WebCore { > > class GPUDevice; > class GPUFunction; > >-class GPUComputePipelineState : public RefCounted<GPUComputePipelineState> { >+class GPUComputePipelineState { > public: >- static RefPtr<GPUComputePipelineState> create(GPUDevice*, GPUFunction*); >- WEBCORE_EXPORT ~GPUComputePipelineState(); >+ GPUComputePipelineState() = default; >+ GPUComputePipelineState(const GPUDevice&, const GPUFunction&); >+ ~GPUComputePipelineState(); > >-#if PLATFORM(COCOA) >- WEBCORE_EXPORT MTLComputePipelineState *platformComputePipelineState(); >+#if USE(METAL) >+ MTLComputePipelineState *metal() const { return m_metal.get(); } > #endif > >+#if USE(METAL) > private: >- GPUComputePipelineState(GPUDevice*, GPUFunction*); >- >-#if PLATFORM(COCOA) >- RetainPtr<MTLComputePipelineState> m_computePipelineState; >+ RetainPtr<MTLComputePipelineState> m_metal; > #endif > }; > > } // namespace WebCore >+ > #endif >diff --git a/Source/WebCore/platform/graphics/gpu/GPUDepthStencilDescriptor.cpp b/Source/WebCore/platform/graphics/gpu/GPUDepthStencilDescriptor.cpp >index 202c65c16718b58eda61c3730c2aa500fa77cf0f..8525468f2ae6e07491fe9e4cb16152520f13e729 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPUDepthStencilDescriptor.cpp >+++ b/Source/WebCore/platform/graphics/gpu/GPUDepthStencilDescriptor.cpp >@@ -28,41 +28,15 @@ > > #if ENABLE(WEBGPU) > >-#include "GPUTexture.h" > #include "Logging.h" > > namespace WebCore { > >-RefPtr<GPUDepthStencilDescriptor> GPUDepthStencilDescriptor::create() >-{ >- RefPtr<GPUDepthStencilDescriptor> descriptor = adoptRef(new GPUDepthStencilDescriptor()); >- return descriptor; >-} >- > GPUDepthStencilDescriptor::~GPUDepthStencilDescriptor() > { > LOG(WebGPU, "GPUDepthStencilDescriptor::~GPUDepthStencilDescriptor()"); > } > >-#if !PLATFORM(COCOA) >-bool GPUDepthStencilDescriptor::depthWriteEnabled() const >-{ >- return false; >-} >- >-void GPUDepthStencilDescriptor::setDepthWriteEnabled(bool) >-{ >-} >- >-GPUCompareFunction GPUDepthStencilDescriptor::depthCompareFunction() const >-{ >-} >- >-void GPUDepthStencilDescriptor::setDepthCompareFunction(GPUCompareFunction) >-{ >-} >-#endif >- > } // namespace WebCore > > #endif >diff --git a/Source/WebCore/platform/graphics/gpu/GPUDepthStencilDescriptor.h b/Source/WebCore/platform/graphics/gpu/GPUDepthStencilDescriptor.h >index 89c4531e8fa77dc199a2f87c124db15b1cd35fd1..0579a66b81c69c4dda2975e7bba7fa18af3d52c9 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPUDepthStencilDescriptor.h >+++ b/Source/WebCore/platform/graphics/gpu/GPUDepthStencilDescriptor.h >@@ -27,38 +27,35 @@ > > #if ENABLE(WEBGPU) > >-#include "GPUEnums.h" >-#include <wtf/RefCounted.h> >-#include <wtf/RefPtr.h> > #include <wtf/RetainPtr.h> > >-#if PLATFORM(COCOA) > OBJC_CLASS MTLDepthStencilDescriptor; >-#endif > > namespace WebCore { > >-class GPUDepthStencilDescriptor : public RefCounted<GPUDepthStencilDescriptor> { >+enum class GPUCompareFunction; >+ >+class GPUDepthStencilDescriptor { > public: >- static RefPtr<GPUDepthStencilDescriptor> create(); >- WEBCORE_EXPORT ~GPUDepthStencilDescriptor(); >+ GPUDepthStencilDescriptor(); >+ ~GPUDepthStencilDescriptor(); > >- WEBCORE_EXPORT bool depthWriteEnabled() const; >- WEBCORE_EXPORT void setDepthWriteEnabled(bool); >+ bool depthWriteEnabled() const; >+ void setDepthWriteEnabled(bool) const; > >- WEBCORE_EXPORT GPUCompareFunction depthCompareFunction() const; >- WEBCORE_EXPORT void setDepthCompareFunction(GPUCompareFunction); >+ GPUCompareFunction depthCompareFunction() const; >+ void setDepthCompareFunction(GPUCompareFunction) const; > >-#if PLATFORM(COCOA) >- WEBCORE_EXPORT MTLDepthStencilDescriptor *platformDepthStencilDescriptor(); >+#if USE(METAL) >+ MTLDepthStencilDescriptor *metal() const { return m_metal.get(); } > #endif > >+#if USE(METAL) > private: >- GPUDepthStencilDescriptor(); >-#if PLATFORM(COCOA) >- RetainPtr<MTLDepthStencilDescriptor> m_depthStencilDescriptor; >+ RetainPtr<MTLDepthStencilDescriptor> m_metal; > #endif > }; > > } // namespace WebCore >+ > #endif >diff --git a/Source/WebCore/platform/graphics/gpu/GPUDepthStencilState.cpp b/Source/WebCore/platform/graphics/gpu/GPUDepthStencilState.cpp >index 6965d9dfc1cc3810323b19246d7b7790e2e4bc10..571edaeb1d73f5067da6566c42e5887e7abf188b 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPUDepthStencilState.cpp >+++ b/Source/WebCore/platform/graphics/gpu/GPUDepthStencilState.cpp >@@ -28,34 +28,15 @@ > > #if ENABLE(WEBGPU) > >-#include "GPUDepthStencilDescriptor.h" >-#include "GPUDevice.h" > #include "Logging.h" > > namespace WebCore { > >-RefPtr<GPUDepthStencilState> GPUDepthStencilState::create(GPUDevice* device, GPUDepthStencilDescriptor* descriptor) >-{ >- RefPtr<GPUDepthStencilState> state = adoptRef(new GPUDepthStencilState(device, descriptor)); >- return state; >-} >- > GPUDepthStencilState::~GPUDepthStencilState() > { > LOG(WebGPU, "GPUDepthStencilState::~GPUDepthStencilState()"); > } > >-#if !PLATFORM(COCOA) >-String GPUDepthStencilState::label() const >-{ >- return emptyString(); >-} >- >-void GPUDepthStencilState::setLabel(const String&) >-{ >-} >-#endif >- > } // namespace WebCore > > #endif >diff --git a/Source/WebCore/platform/graphics/gpu/GPUDepthStencilState.h b/Source/WebCore/platform/graphics/gpu/GPUDepthStencilState.h >index 98d40284af63ac50a188f06ee3be9b3e43a6f5ff..15b5cf826ce8e293c1f0fd945f189560333ffa0d 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPUDepthStencilState.h >+++ b/Source/WebCore/platform/graphics/gpu/GPUDepthStencilState.h >@@ -27,39 +27,34 @@ > > #if ENABLE(WEBGPU) > >-#include <wtf/RefCounted.h> >-#include <wtf/RefPtr.h> > #include <wtf/RetainPtr.h> >-#include <wtf/text/WTFString.h> > >-#if PLATFORM(COCOA) >-OBJC_CLASS MTLDepthStencilState; >-#endif >+OBJC_PROTOCOL(MTLDepthStencilState); > > namespace WebCore { > > class GPUDevice; > class GPUDepthStencilDescriptor; > >-class GPUDepthStencilState : public RefCounted<GPUDepthStencilState> { >+class GPUDepthStencilState { > public: >- static RefPtr<GPUDepthStencilState> create(GPUDevice*, GPUDepthStencilDescriptor*); >- WEBCORE_EXPORT ~GPUDepthStencilState(); >+ GPUDepthStencilState() = default; >+ GPUDepthStencilState(const GPUDevice&, const GPUDepthStencilDescriptor&); >+ ~GPUDepthStencilState(); > >- WEBCORE_EXPORT String label() const; >- WEBCORE_EXPORT void setLabel(const String&); >+ String label() const; >+ void setLabel(const String&) const; > >-#if PLATFORM(COCOA) >- WEBCORE_EXPORT MTLDepthStencilState *platformDepthStencilState(); >+#if USE(METAL) >+ MTLDepthStencilState *metal() const { return m_metal.get(); } > #endif > >+#if USE(METAL) > private: >- GPUDepthStencilState(GPUDevice*, GPUDepthStencilDescriptor*); >- >-#if PLATFORM(COCOA) >- RetainPtr<MTLDepthStencilState> m_depthStencilState; >+ RetainPtr<MTLDepthStencilState> m_metal; > #endif > }; > > } // namespace WebCore >+ > #endif >diff --git a/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp b/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp >index a1565227ec06c17affa2969ac4c667a8b27b5be0..5448fbcc3d845af8bbe6f36ab2589120bf9de2ed 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp >+++ b/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp >@@ -28,74 +28,16 @@ > > #if ENABLE(WEBGPU) > >-#include "GPUBuffer.h" >-#include "GPUCommandQueue.h" >-#include "GPUDrawable.h" >-#include "GPULibrary.h" >-#include "GPUTexture.h" >-#include "GPUTextureDescriptor.h" > #include "Logging.h" > > namespace WebCore { > >-RefPtr<GPUDevice> GPUDevice::create() >-{ >- RefPtr<GPUDevice> device = adoptRef(new GPUDevice()); >- >-#if PLATFORM(COCOA) >- if (!device->platformDevice()) { >- LOG(WebGPU, "GPUDevice::create() was unable to create the low-level device"); >- return nullptr; >- } >-#endif >- >- LOG(WebGPU, "GPUDevice::create() device is %p", device.get()); >- return device; >-} >- > GPUDevice::~GPUDevice() > { > LOG(WebGPU, "GPUDevice::~GPUDevice()"); >+ disconnect(); > } > >-RefPtr<GPUCommandQueue> GPUDevice::createCommandQueue() >-{ >- return GPUCommandQueue::create(this); >-} >- >-RefPtr<GPULibrary> GPUDevice::createLibrary(const String& sourceCode) >-{ >- return GPULibrary::create(this, sourceCode); >-} >- >-RefPtr<GPUBuffer> GPUDevice::createBufferFromData(ArrayBufferView* data) >-{ >- return GPUBuffer::create(this, data); >-} >- >-RefPtr<GPUTexture> GPUDevice::createTexture(GPUTextureDescriptor* descriptor) >-{ >- return GPUTexture::create(this, descriptor); >-} >- >-RefPtr<GPUDrawable> GPUDevice::getFramebuffer() >-{ >- return GPUDrawable::create(this); >-} >- >-#if !PLATFORM(COCOA) >- >-GPUDevice::GPUDevice() >-{ >- >-} >- >-void GPUDevice::reshape(int, int) >-{ >-} >- >-#endif >- > } // namespace WebCore > > #endif >diff --git a/Source/WebCore/platform/graphics/gpu/GPUDevice.h b/Source/WebCore/platform/graphics/gpu/GPUDevice.h >index df194eb23a6a35abddf7e56fb61aa8abeca280c1..d9870f9298c3bd6ec7c5e21080927ff1ee6e0059 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPUDevice.h >+++ b/Source/WebCore/platform/graphics/gpu/GPUDevice.h >@@ -27,60 +27,38 @@ > > #if ENABLE(WEBGPU) > >-#include "PlatformLayer.h" >-#include <JavaScriptCore/ArrayBufferView.h> >-#include <wtf/Forward.h> >-#include <wtf/RefCounted.h> >+#include <wtf/RetainPtr.h> > >-#if USE(CA) >-#include "PlatformCALayer.h" >-#endif >- >-#if PLATFORM(COCOA) >-typedef struct objc_object* id; > OBJC_CLASS CALayer; > OBJC_CLASS WebGPULayer; >-#else >-class WebGPULayer; >-#endif > >-namespace WebCore { >+OBJC_PROTOCOL(MTLDevice); > >-class GPUBuffer; >-class GPUCommandQueue; >-class GPUDrawable; >-class GPULibrary; >-class GPUTexture; >-class GPUTextureDescriptor; >+namespace WebCore { > >-class GPUDevice : public RefCounted<GPUDevice> { >+class GPUDevice { > public: >- WEBCORE_EXPORT static RefPtr<GPUDevice> create(); >+ WEBCORE_EXPORT GPUDevice(); > WEBCORE_EXPORT ~GPUDevice(); > >- void reshape(int width, int height); >- >-#if PLATFORM(COCOA) >- WebGPULayer* layer() { return m_layer.get(); } >- CALayer* platformLayer() const { return reinterpret_cast<CALayer*>(m_layer.get()); } >- WEBCORE_EXPORT id platformDevice(); >-#endif >+ WEBCORE_EXPORT bool operator!() const; > >- WEBCORE_EXPORT RefPtr<GPUCommandQueue> createCommandQueue(); >- WEBCORE_EXPORT RefPtr<GPULibrary> createLibrary(const String& sourceCode); >- WEBCORE_EXPORT RefPtr<GPUBuffer> createBufferFromData(ArrayBufferView* data); >- WEBCORE_EXPORT RefPtr<GPUTexture> createTexture(GPUTextureDescriptor*); >+ void reshape(int width, int height) const; > >- RefPtr<GPUDrawable> getFramebuffer(); >+#if USE(METAL) >+ WebGPULayer *layer() const { return m_layer.get(); } >+ WEBCORE_EXPORT CALayer *platformLayer() const; >+ MTLDevice *metal() const { return m_metal.get(); } >+#endif > >- void markLayerComposited() { } >+ void markLayerComposited() const { } > > private: >- GPUDevice(); >+ void disconnect(); > >-#if PLATFORM(COCOA) >+#if USE(METAL) > RetainPtr<WebGPULayer> m_layer; >- RetainPtr<id> m_device; >+ RetainPtr<MTLDevice> m_metal; > #endif > }; > >diff --git a/Source/WebCore/platform/graphics/gpu/GPUDrawable.cpp b/Source/WebCore/platform/graphics/gpu/GPUDrawable.cpp >index 563a75d1b1836e6b4e149966c0a887049a0ca4bb..8d8ea4c3cffeb1d788035514a1e72cec812738b7 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPUDrawable.cpp >+++ b/Source/WebCore/platform/graphics/gpu/GPUDrawable.cpp >@@ -28,29 +28,15 @@ > > #if ENABLE(WEBGPU) > >-#include "GPUCommandBuffer.h" >-#include "GPUDevice.h" > #include "Logging.h" > > namespace WebCore { > >-RefPtr<GPUDrawable> GPUDrawable::create(GPUDevice* device) >-{ >- RefPtr<GPUDrawable> drawable = adoptRef(new GPUDrawable(device)); >- return drawable; >-} >- > GPUDrawable::~GPUDrawable() > { > LOG(WebGPU, "GPUDrawable::~GPUDrawable()"); > } > >-#if !PLATFORM(COCOA) >-void GPUDrawable::release() >-{ >-} >-#endif >- > } // namespace WebCore > > #endif >diff --git a/Source/WebCore/platform/graphics/gpu/GPUDrawable.h b/Source/WebCore/platform/graphics/gpu/GPUDrawable.h >index cca2bcf0014540633d46e712711bea3f7b98eba1..6f4329233f724e6727146c95a7fc94907f9dd532 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPUDrawable.h >+++ b/Source/WebCore/platform/graphics/gpu/GPUDrawable.h >@@ -27,38 +27,32 @@ > > #if ENABLE(WEBGPU) > >-#include <wtf/RefCounted.h> >-#include <wtf/RefPtr.h> > #include <wtf/RetainPtr.h> > >-#if PLATFORM(COCOA) >-OBJC_CLASS MTLDrawable; >-OBJC_CLASS MTLTexture; >-#endif >+OBJC_PROTOCOL(MTLDrawable); >+OBJC_PROTOCOL(MTLTexture); > > namespace WebCore { > >-class GPUTexture; > class GPUDevice; > >-class GPUDrawable : public RefCounted<GPUDrawable> { >+class GPUDrawable { > public: >- static RefPtr<GPUDrawable> create(GPUDevice*); >- WEBCORE_EXPORT ~GPUDrawable(); >+ explicit GPUDrawable(const GPUDevice&); >+ ~GPUDrawable(); >+ >+ void release(); > >- WEBCORE_EXPORT void release(); >+#if USE(METAL) >+ MTLDrawable *metal() const; > >-#if PLATFORM(COCOA) >- WEBCORE_EXPORT MTLDrawable *platformDrawable(); > // FIXME: WebGPU - not all drawables should have this. Only the framebuffer. >- WEBCORE_EXPORT MTLTexture *platformTexture(); >+ MTLTexture *texture() const; > #endif > >+#if USE(METAL) > private: >- GPUDrawable(GPUDevice*); >- >-#if PLATFORM(COCOA) >- RetainPtr<MTLDrawable> m_drawable; >+ RetainPtr<MTLDrawable> m_metal; > #endif > }; > >diff --git a/Source/WebCore/platform/graphics/gpu/GPUEnums.h b/Source/WebCore/platform/graphics/gpu/GPUEnums.h >index aace62d510f57d87cafac13dc0b7ec2a31683deb..6def60aa31f7714571b8cf06e92315ddcbf27a18 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPUEnums.h >+++ b/Source/WebCore/platform/graphics/gpu/GPUEnums.h >@@ -41,4 +41,5 @@ enum class GPUCompareFunction { > }; > > } // namespace WebCore >+ > #endif >diff --git a/Source/WebCore/platform/graphics/gpu/GPUFunction.cpp b/Source/WebCore/platform/graphics/gpu/GPUFunction.cpp >index 3f27aefcb92b94ea84620dbd521da9a346d124f3..0d0b399450cb7ba09bf26d70872f93fde7225be8 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPUFunction.cpp >+++ b/Source/WebCore/platform/graphics/gpu/GPUFunction.cpp >@@ -28,40 +28,15 @@ > > #if ENABLE(WEBGPU) > >-#include "GPULibrary.h" > #include "Logging.h" > > namespace WebCore { > >-RefPtr<GPUFunction> GPUFunction::create(GPULibrary* library, const String& name) >-{ >- RefPtr<GPUFunction> function = adoptRef(new GPUFunction(library, name)); >-#if PLATFORM(COCOA) >- if (!function->platformFunction()) >- return nullptr; >-#endif >- return function; >-} >- > GPUFunction::~GPUFunction() > { > LOG(WebGPU, "GPUFunction::~GPUFunction()"); > } > >-#if !PLATFORM(COCOA) >-GPUFunction::GPUFunction(GPULibrary*, const String&) >-{ >- LOG(WebGPU, "GPUFunction::GPUFunction()"); >-} >- >-String GPUFunction::name() const >-{ >- return emptyString(); >-} >-#endif >- >- > } // namespace WebCore > > #endif >- >diff --git a/Source/WebCore/platform/graphics/gpu/GPUFunction.h b/Source/WebCore/platform/graphics/gpu/GPUFunction.h >index 7d7fdf15cf21140c3526175414b1fef3f45ebf9c..96fa492e182a1be3cab785ec409216c368a46475 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPUFunction.h >+++ b/Source/WebCore/platform/graphics/gpu/GPUFunction.h >@@ -27,35 +27,30 @@ > > #if ENABLE(WEBGPU) > >-#include <wtf/RefCounted.h> >-#include <wtf/RefPtr.h> >-#include <wtf/Vector.h> >-#include <wtf/text/WTFString.h> >+#include <wtf/RetainPtr.h> > >-#if PLATFORM(COCOA) >-OBJC_CLASS MTLFunction; >-#endif >+OBJC_PROTOCOL(MTLFunction); > > namespace WebCore { > > class GPULibrary; > >-class GPUFunction : public RefCounted<GPUFunction> { >+class GPUFunction { > public: >- static RefPtr<GPUFunction> create(GPULibrary*, const String& name); >+ WEBCORE_EXPORT GPUFunction(const GPULibrary&, const String& name); > WEBCORE_EXPORT ~GPUFunction(); > >+ bool operator!() const; >+ > WEBCORE_EXPORT String name() const; > >-#if PLATFORM(COCOA) >- WEBCORE_EXPORT MTLFunction *platformFunction(); >+#if USE(METAL) >+ MTLFunction *metal() const { return m_metal.get(); } > #endif > >+#if USE(METAL) > private: >- GPUFunction(GPULibrary*, const String& name); >- >-#if PLATFORM(COCOA) >- RetainPtr<MTLFunction> m_function; >+ RetainPtr<MTLFunction> m_metal; > #endif > }; > >diff --git a/Source/WebCore/platform/graphics/gpu/GPULibrary.cpp b/Source/WebCore/platform/graphics/gpu/GPULibrary.cpp >index 17939c02706729b7fd3d9c4fdb3ab676cce35a73..9062488592654d900a502f1acb421967334fff58 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPULibrary.cpp >+++ b/Source/WebCore/platform/graphics/gpu/GPULibrary.cpp >@@ -28,46 +28,15 @@ > > #if ENABLE(WEBGPU) > >-#include "GPUDevice.h" >-#include "GPUFunction.h" > #include "Logging.h" > > namespace WebCore { > >-RefPtr<GPULibrary> GPULibrary::create(GPUDevice* device, const String& sourceCode) >-{ >- RefPtr<GPULibrary> library = adoptRef(new GPULibrary(device, sourceCode)); >- return library; >-} >- > GPULibrary::~GPULibrary() > { > LOG(WebGPU, "GPULibrary::~GPULibrary()"); > } > >-#if !PLATFORM(COCOA) >- >-String GPULibrary::label() const >-{ >- return emptyString(); >-} >- >-void GPULibrary::setLabel(const String&) >-{ >-} >- >-Vector<String> GPULibrary::functionNames() >-{ >- return { }; >-} >- >-#endif >- >-RefPtr<GPUFunction> GPULibrary::functionWithName(const String& name) >-{ >- return GPUFunction::create(this, name); >-} >- > } // namespace WebCore > > #endif >diff --git a/Source/WebCore/platform/graphics/gpu/GPULibrary.h b/Source/WebCore/platform/graphics/gpu/GPULibrary.h >index 985b96eb0b49fc0d2dbb9ccf3d2ef8f9063e07ff..f35d5ba146a94bd5bb50f2d1841540e6ecf6c8f5 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPULibrary.h >+++ b/Source/WebCore/platform/graphics/gpu/GPULibrary.h >@@ -27,43 +27,34 @@ > > #if ENABLE(WEBGPU) > >-#include <wtf/RefCounted.h> >-#include <wtf/RefPtr.h> >-#include <wtf/Vector.h> >-#include <wtf/text/WTFString.h> >+#include <wtf/RetainPtr.h> > >-#if PLATFORM(COCOA) >-OBJC_CLASS MTLLibrary; >-#endif >+OBJC_PROTOCOL(MTLLibrary); > > namespace WebCore { > > class GPUDevice; >-class GPUFunction; > >-class GPULibrary : public RefCounted<GPULibrary> { >+class GPULibrary { > public: >- static RefPtr<GPULibrary> create(GPUDevice*, const String& sourceCode); >+ WEBCORE_EXPORT GPULibrary(const GPUDevice&, const String& sourceCode); > WEBCORE_EXPORT ~GPULibrary(); > > WEBCORE_EXPORT String label() const; >- WEBCORE_EXPORT void setLabel(const String&); >- >- WEBCORE_EXPORT Vector<String> functionNames(); >+ WEBCORE_EXPORT void setLabel(const String&) const; > >- WEBCORE_EXPORT RefPtr<GPUFunction> functionWithName(const String&); >+ WEBCORE_EXPORT Vector<String> functionNames() const; > >-#if PLATFORM(COCOA) >- WEBCORE_EXPORT MTLLibrary *platformLibrary(); >+#if USE(METAL) >+ MTLLibrary *metal() const { return m_metal.get(); } > #endif > >+#if USE(METAL) > private: >- GPULibrary(GPUDevice*, const String& sourceCode); >- >-#if PLATFORM(COCOA) >- RetainPtr<MTLLibrary> m_library; >+ RetainPtr<MTLLibrary> m_metal; > #endif > }; > > } // namespace WebCore >+ > #endif >diff --git a/Source/WebCore/platform/graphics/gpu/GPURenderCommandEncoder.cpp b/Source/WebCore/platform/graphics/gpu/GPURenderCommandEncoder.cpp >index 9d19044f8f3e452006b7e143b0953fcda2e9ac6b..6d1f53b9472e17350587f77432b4da235e3aa1f9 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPURenderCommandEncoder.cpp >+++ b/Source/WebCore/platform/graphics/gpu/GPURenderCommandEncoder.cpp >@@ -28,49 +28,15 @@ > > #if ENABLE(WEBGPU) > >-#include "GPUCommandBuffer.h" >-#include "GPURenderPassDescriptor.h" > #include "Logging.h" > > namespace WebCore { > >-RefPtr<GPURenderCommandEncoder> GPURenderCommandEncoder::create(GPUCommandBuffer* buffer, GPURenderPassDescriptor* descriptor) >-{ >- RefPtr<GPURenderCommandEncoder> encoder = adoptRef(new GPURenderCommandEncoder(buffer, descriptor)); >- return encoder; >-} >- > GPURenderCommandEncoder::~GPURenderCommandEncoder() > { > LOG(WebGPU, "GPURenderCommandEncoder::~GPURenderCommandEncoder()"); > } > >-#if !PLATFORM(COCOA) >-void GPURenderCommandEncoder::setRenderPipelineState(GPURenderPipelineState*) >-{ >-} >- >-void GPURenderCommandEncoder::setDepthStencilState(GPUDepthStencilState*) >-{ >-} >- >-void GPURenderCommandEncoder::setVertexBuffer(GPUBuffer*, unsigned, unsigned) >-{ >-} >- >-void GPURenderCommandEncoder::setFragmentBuffer(GPUBuffer*, unsigned, unsigned) >-{ >-} >- >-void GPURenderCommandEncoder::drawPrimitives(unsigned, unsigned, unsigned) >-{ >-} >- >-void GPURenderCommandEncoder::endEncoding() >-{ >-} >-#endif >- > } // namespace WebCore > > #endif >diff --git a/Source/WebCore/platform/graphics/gpu/GPURenderCommandEncoder.h b/Source/WebCore/platform/graphics/gpu/GPURenderCommandEncoder.h >index 378edd2abeb3d80eba6f44dcdbd6d688cbcad1aa..f9053cec5b0c9b9630b5d7b632c6d9b7b31bf49e 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPURenderCommandEncoder.h >+++ b/Source/WebCore/platform/graphics/gpu/GPURenderCommandEncoder.h >@@ -27,13 +27,9 @@ > > #if ENABLE(WEBGPU) > >-#include <wtf/RefCounted.h> >-#include <wtf/RefPtr.h> > #include <wtf/RetainPtr.h> > >-#if PLATFORM(COCOA) >-OBJC_CLASS MTLRenderCommandEncoder; >-#endif >+OBJC_PROTOCOL(MTLRenderCommandEncoder); > > namespace WebCore { > >@@ -43,29 +39,24 @@ class GPUDepthStencilState; > class GPURenderPassDescriptor; > class GPURenderPipelineState; > >-class GPURenderCommandEncoder : public RefCounted<GPURenderCommandEncoder> { >+class GPURenderCommandEncoder { > public: >- static RefPtr<GPURenderCommandEncoder> create(GPUCommandBuffer*, GPURenderPassDescriptor*); >- WEBCORE_EXPORT ~GPURenderCommandEncoder(); >- >- WEBCORE_EXPORT void setRenderPipelineState(GPURenderPipelineState*); >- WEBCORE_EXPORT void setDepthStencilState(GPUDepthStencilState*); >- WEBCORE_EXPORT void setVertexBuffer(GPUBuffer*, unsigned offset, unsigned index); >- WEBCORE_EXPORT void setFragmentBuffer(GPUBuffer*, unsigned offset, unsigned index); >- WEBCORE_EXPORT void drawPrimitives(unsigned type, unsigned start, unsigned count); >- WEBCORE_EXPORT void endEncoding(); >+ GPURenderCommandEncoder(const GPUCommandBuffer&, const GPURenderPassDescriptor&); >+ ~GPURenderCommandEncoder(); > >-#if PLATFORM(COCOA) >- WEBCORE_EXPORT MTLRenderCommandEncoder *platformRenderCommandEncoder(); >-#endif >+ void setRenderPipelineState(const GPURenderPipelineState&) const; >+ void setDepthStencilState(const GPUDepthStencilState&) const; >+ void setVertexBuffer(const GPUBuffer&, unsigned offset, unsigned index) const; >+ void setFragmentBuffer(const GPUBuffer&, unsigned offset, unsigned index) const; >+ void drawPrimitives(unsigned type, unsigned start, unsigned count) const; >+ void endEncoding() const; > >+#if USE(METAL) > private: >- GPURenderCommandEncoder(GPUCommandBuffer*, GPURenderPassDescriptor*); >- >-#if PLATFORM(COCOA) >- RetainPtr<MTLRenderCommandEncoder> m_renderCommandEncoder; >+ RetainPtr<MTLRenderCommandEncoder> m_metal; > #endif > }; > > } // namespace WebCore >+ > #endif >diff --git a/Source/WebCore/platform/graphics/gpu/GPURenderPassAttachmentDescriptor.cpp b/Source/WebCore/platform/graphics/gpu/GPURenderPassAttachmentDescriptor.cpp >index 599e3772623cb17b4a1f0f726eade3cb9d68aba6..75d89e99844ce04b3fb8a56264a65438a9c55a05 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPURenderPassAttachmentDescriptor.cpp >+++ b/Source/WebCore/platform/graphics/gpu/GPURenderPassAttachmentDescriptor.cpp >@@ -38,35 +38,6 @@ GPURenderPassAttachmentDescriptor::~GPURenderPassAttachmentDescriptor() > LOG(WebGPU, "GPURenderPassAttachmentDescriptor::~GPURenderPassAttachmentDescriptor()"); > } > >-#if !PLATFORM(COCOA) >-GPURenderPassAttachmentDescriptor::GPURenderPassAttachmentDescriptor() >-{ >- LOG(WebGPU, "GPURenderPassAttachmentDescriptor::GPURenderPassAttachmentDescriptor()"); >-} >- >-unsigned long GPURenderPassAttachmentDescriptor::loadAction() const >-{ >- return 0; >-} >- >-void GPURenderPassAttachmentDescriptor::setLoadAction(unsigned long) >-{ >-} >- >-unsigned long GPURenderPassAttachmentDescriptor::storeAction() const >-{ >- return 0; >-} >- >-void GPURenderPassAttachmentDescriptor::setStoreAction(unsigned long) >-{ >-} >- >-void GPURenderPassAttachmentDescriptor::setTexture(RefPtr<GPUTexture>) >-{ >-} >-#endif >- > } // namespace WebCore > > #endif >diff --git a/Source/WebCore/platform/graphics/gpu/GPURenderPassAttachmentDescriptor.h b/Source/WebCore/platform/graphics/gpu/GPURenderPassAttachmentDescriptor.h >index 3d488569d0aca9548af21acd5c5efea88f4dd494..fef7094a9ce3299c409674c9a7f57469bad9a6b8 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPURenderPassAttachmentDescriptor.h >+++ b/Source/WebCore/platform/graphics/gpu/GPURenderPassAttachmentDescriptor.h >@@ -27,42 +27,39 @@ > > #if ENABLE(WEBGPU) > >-#include <wtf/RefCounted.h> >-#include <wtf/RefPtr.h> > #include <wtf/RetainPtr.h> > >-#if PLATFORM(COCOA) > OBJC_CLASS MTLRenderPassAttachmentDescriptor; >-#endif > > namespace WebCore { > > class GPUTexture; > >-class GPURenderPassAttachmentDescriptor : public RefCounted<GPURenderPassAttachmentDescriptor> { >+class GPURenderPassAttachmentDescriptor { > public: >- WEBCORE_EXPORT ~GPURenderPassAttachmentDescriptor(); >+ ~GPURenderPassAttachmentDescriptor(); > >- WEBCORE_EXPORT unsigned long loadAction() const; >- WEBCORE_EXPORT void setLoadAction(unsigned long); >+ unsigned loadAction() const; >+ void setLoadAction(unsigned) const; > >- WEBCORE_EXPORT unsigned long storeAction() const; >- WEBCORE_EXPORT void setStoreAction(unsigned long); >+ unsigned storeAction() const; >+ void setStoreAction(unsigned) const; > >- WEBCORE_EXPORT void setTexture(RefPtr<GPUTexture>); >+ void setTexture(const GPUTexture&) const; > >-#if PLATFORM(COCOA) >- WEBCORE_EXPORT MTLRenderPassAttachmentDescriptor *platformRenderPassAttachmentDescriptor(); >+#if USE(METAL) >+ MTLRenderPassAttachmentDescriptor *metal() const; > #endif > >+#if USE(METAL) > protected: >-#if PLATFORM(COCOA) >- GPURenderPassAttachmentDescriptor(MTLRenderPassAttachmentDescriptor *); >- RetainPtr<MTLRenderPassAttachmentDescriptor> m_renderPassAttachmentDescriptor; >-#else >- GPURenderPassAttachmentDescriptor(); >+ explicit GPURenderPassAttachmentDescriptor(MTLRenderPassAttachmentDescriptor *); >+ >+private: >+ RetainPtr<MTLRenderPassAttachmentDescriptor> m_metal; > #endif > }; > > } // namespace WebCore >+ > #endif >diff --git a/Source/WebCore/platform/graphics/gpu/GPURenderPassColorAttachmentDescriptor.cpp b/Source/WebCore/platform/graphics/gpu/GPURenderPassColorAttachmentDescriptor.cpp >index 5c7152e3ebe2e04072f0a40e7d25b7f114f45729..2f5ac788f218db3ca71a501ad1113e839d1d74b9 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPURenderPassColorAttachmentDescriptor.cpp >+++ b/Source/WebCore/platform/graphics/gpu/GPURenderPassColorAttachmentDescriptor.cpp >@@ -28,41 +28,15 @@ > > #if ENABLE(WEBGPU) > >-#include "GPURenderPassAttachmentDescriptor.h" > #include "Logging.h" > > namespace WebCore { > >-#if !PLATFORM(COCOA) >-RefPtr<GPURenderPassColorAttachmentDescriptor> GPURenderPassColorAttachmentDescriptor::create() >-{ >- RefPtr<GPURenderPassColorAttachmentDescriptor> descriptor = adoptRef(new GPURenderPassColorAttachmentDescriptor()); >- return descriptor; >-} >- >-GPURenderPassColorAttachmentDescriptor::GPURenderPassColorAttachmentDescriptor() >- : GPURenderPassAttachmentDescriptor() >-{ >- LOG(WebGPU, "GPURenderPassColorAttachmentDescriptor::GPURenderPassColorAttachmentDescriptor()"); >-} >-#endif >- > GPURenderPassColorAttachmentDescriptor::~GPURenderPassColorAttachmentDescriptor() > { > LOG(WebGPU, "GPURenderPassColorAttachmentDescriptor::~GPURenderPassColorAttachmentDescriptor()"); > } > >-#if !PLATFORM(COCOA) >-Vector<float> GPURenderPassColorAttachmentDescriptor::clearColor() const >-{ >- return Vector<float>(); >-} >- >-void GPURenderPassColorAttachmentDescriptor::setClearColor(const Vector<float>&) >-{ >-} >-#endif >- > } // namespace WebCore > > #endif >diff --git a/Source/WebCore/platform/graphics/gpu/GPURenderPassColorAttachmentDescriptor.h b/Source/WebCore/platform/graphics/gpu/GPURenderPassColorAttachmentDescriptor.h >index 7b07ab937b9a68fe58e783092462044ea0952e8d..31aee8fb62bc971da02c96e58c44aacd5388aff6 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPURenderPassColorAttachmentDescriptor.h >+++ b/Source/WebCore/platform/graphics/gpu/GPURenderPassColorAttachmentDescriptor.h >@@ -28,40 +28,26 @@ > #if ENABLE(WEBGPU) > > #include "GPURenderPassAttachmentDescriptor.h" >-#include <wtf/RefCounted.h> >-#include <wtf/RefPtr.h> >-#include <wtf/RetainPtr.h> >-#include <wtf/Vector.h> > >-#if PLATFORM(COCOA) > OBJC_CLASS MTLRenderPassColorAttachmentDescriptor; >-#endif > > namespace WebCore { > > class GPURenderPassColorAttachmentDescriptor : public GPURenderPassAttachmentDescriptor { > public: >-#if PLATFORM(COCOA) >- static RefPtr<GPURenderPassColorAttachmentDescriptor> create(MTLRenderPassColorAttachmentDescriptor *); >-#else >- static RefPtr<GPURenderPassColorAttachmentDescriptor> create(); >+#if USE(METAL) >+ GPURenderPassColorAttachmentDescriptor(MTLRenderPassColorAttachmentDescriptor *); > #endif >- WEBCORE_EXPORT ~GPURenderPassColorAttachmentDescriptor(); >- >- WEBCORE_EXPORT Vector<float> clearColor() const; >- WEBCORE_EXPORT void setClearColor(const Vector<float>&); >+ ~GPURenderPassColorAttachmentDescriptor(); > >-#if PLATFORM(COCOA) >- WEBCORE_EXPORT MTLRenderPassColorAttachmentDescriptor *platformRenderPassColorAttachmentDescriptor(); >-#endif >+ Vector<float> clearColor() const; >+ void setClearColor(const Vector<float>&) const; > >-private: >-#if PLATFORM(COCOA) >- GPURenderPassColorAttachmentDescriptor(MTLRenderPassColorAttachmentDescriptor *); >-#else >- GPURenderPassColorAttachmentDescriptor(); >+#if USE(METAL) >+ MTLRenderPassColorAttachmentDescriptor *metal() const; > #endif > }; > > } // namespace WebCore >+ > #endif >diff --git a/Source/WebCore/platform/graphics/gpu/GPURenderPassDepthAttachmentDescriptor.cpp b/Source/WebCore/platform/graphics/gpu/GPURenderPassDepthAttachmentDescriptor.cpp >index aa4e457d476065b09c236e53929e739074c16a64..4c1ca67167a1ff5f09fa7b055d4725a86f18691a 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPURenderPassDepthAttachmentDescriptor.cpp >+++ b/Source/WebCore/platform/graphics/gpu/GPURenderPassDepthAttachmentDescriptor.cpp >@@ -28,41 +28,15 @@ > > #if ENABLE(WEBGPU) > >-#include "GPURenderPassAttachmentDescriptor.h" > #include "Logging.h" > > namespace WebCore { > >-#if !PLATFORM(COCOA) >-RefPtr<GPURenderPassDepthAttachmentDescriptor> GPURenderPassDepthAttachmentDescriptor::create() >-{ >- RefPtr<GPURenderPassDepthAttachmentDescriptor> descriptor = adoptRef(new GPURenderPassDepthAttachmentDescriptor()); >- return descriptor; >-} >- >-GPURenderPassDepthAttachmentDescriptor::GPURenderPassDepthAttachmentDescriptor() >- : GPURenderPassAttachmentDescriptor() >-{ >- LOG(WebGPU, "GPURenderPassDepthAttachmentDescriptor::GPURenderPassDepthAttachmentDescriptor()"); >-} >-#endif >- > GPURenderPassDepthAttachmentDescriptor::~GPURenderPassDepthAttachmentDescriptor() > { > LOG(WebGPU, "GPURenderPassDepthAttachmentDescriptor::~GPURenderPassDepthAttachmentDescriptor()"); > } > >-#if !PLATFORM(COCOA) >-double GPURenderPassDepthAttachmentDescriptor::clearDepth() const >-{ >- return 0; >-} >- >-void GPURenderPassDepthAttachmentDescriptor::setClearDepth(double) >-{ >-} >-#endif >- > } // namespace WebCore > > #endif >diff --git a/Source/WebCore/platform/graphics/gpu/GPURenderPassDepthAttachmentDescriptor.h b/Source/WebCore/platform/graphics/gpu/GPURenderPassDepthAttachmentDescriptor.h >index 8b0ecd40761edff2f27dc69f9500f59d923e9c46..b4c517289714670fbad7582e6e590d763808281e 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPURenderPassDepthAttachmentDescriptor.h >+++ b/Source/WebCore/platform/graphics/gpu/GPURenderPassDepthAttachmentDescriptor.h >@@ -28,40 +28,27 @@ > #if ENABLE(WEBGPU) > > #include "GPURenderPassAttachmentDescriptor.h" >-#include <wtf/RefCounted.h> >-#include <wtf/RefPtr.h> >-#include <wtf/RetainPtr.h> >-#include <wtf/Vector.h> > >-#if PLATFORM(COCOA) > OBJC_CLASS MTLRenderPassDepthAttachmentDescriptor; >-#endif > > namespace WebCore { > > class GPURenderPassDepthAttachmentDescriptor : public GPURenderPassAttachmentDescriptor { > public: >-#if PLATFORM(COCOA) >- static RefPtr<GPURenderPassDepthAttachmentDescriptor> create(MTLRenderPassDepthAttachmentDescriptor *); >-#else >- static RefPtr<GPURenderPassDepthAttachmentDescriptor> create(); >+#if USE(METAL) >+ GPURenderPassDepthAttachmentDescriptor(MTLRenderPassDepthAttachmentDescriptor *); > #endif >- WEBCORE_EXPORT ~GPURenderPassDepthAttachmentDescriptor(); >+ ~GPURenderPassDepthAttachmentDescriptor(); > > double clearDepth() const; >- void setClearDepth(double); >- >-#if PLATFORM(COCOA) >- WEBCORE_EXPORT MTLRenderPassDepthAttachmentDescriptor *platformRenderPassDepthAttachmentDescriptor(); >-#endif >+ void setClearDepth(double) const; > >+#if USE(METAL) > private: >-#if PLATFORM(COCOA) >- GPURenderPassDepthAttachmentDescriptor(MTLRenderPassDepthAttachmentDescriptor *); >-#else >- GPURenderPassDepthAttachmentDescriptor(); >+ MTLRenderPassDepthAttachmentDescriptor *metal() const; > #endif > }; > > } // namespace WebCore >+ > #endif >diff --git a/Source/WebCore/platform/graphics/gpu/GPURenderPassDescriptor.cpp b/Source/WebCore/platform/graphics/gpu/GPURenderPassDescriptor.cpp >index f9f9963dae495366ce15a958c7bf0a5d4d8eb9f6..fa4abc9e1c9d2667c9897cb1f66067430a5b6c08 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPURenderPassDescriptor.cpp >+++ b/Source/WebCore/platform/graphics/gpu/GPURenderPassDescriptor.cpp >@@ -33,24 +33,11 @@ > > namespace WebCore { > >-RefPtr<GPURenderPassDescriptor> GPURenderPassDescriptor::create() >-{ >- RefPtr<GPURenderPassDescriptor> descriptor = adoptRef(new GPURenderPassDescriptor()); >- return descriptor; >-} >- > GPURenderPassDescriptor::~GPURenderPassDescriptor() > { > LOG(WebGPU, "GPURenderPassDescriptor::~GPURenderPassDescriptor()"); > } > >-#if !PLATFORM(COCOA) >-RefPtr<GPURenderPassDepthAttachmentDescriptor> GPURenderPassDescriptor::depthAttachment() >-{ >- return nullptr; >-} >-#endif >- > } // namespace WebCore > > #endif >diff --git a/Source/WebCore/platform/graphics/gpu/GPURenderPassDescriptor.h b/Source/WebCore/platform/graphics/gpu/GPURenderPassDescriptor.h >index 36ac79b6ea2330be0ba0911ad0f17bb09757e081..54dae242fb5e4f8110846a8c2ad8f0cce460f802 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPURenderPassDescriptor.h >+++ b/Source/WebCore/platform/graphics/gpu/GPURenderPassDescriptor.h >@@ -27,40 +27,33 @@ > > #if ENABLE(WEBGPU) > >-#include <wtf/RefCounted.h> >-#include <wtf/RefPtr.h> > #include <wtf/RetainPtr.h> >-#include <wtf/Vector.h> > >-#if PLATFORM(COCOA) > OBJC_CLASS MTLRenderPassDescriptor; >-#endif > > namespace WebCore { > > class GPURenderPassColorAttachmentDescriptor; > class GPURenderPassDepthAttachmentDescriptor; > >-class GPURenderPassDescriptor : public RefCounted<GPURenderPassDescriptor> { >+class GPURenderPassDescriptor { > public: >- static RefPtr<GPURenderPassDescriptor> create(); >- WEBCORE_EXPORT ~GPURenderPassDescriptor(); >+ GPURenderPassDescriptor(); >+ ~GPURenderPassDescriptor(); > >- Vector<RefPtr<GPURenderPassColorAttachmentDescriptor>> colorAttachments(); >- RefPtr<GPURenderPassDepthAttachmentDescriptor> depthAttachment(); >+ Vector<GPURenderPassColorAttachmentDescriptor> colorAttachments() const; >+ GPURenderPassDepthAttachmentDescriptor depthAttachment() const; > >-#if PLATFORM(COCOA) >- WEBCORE_EXPORT MTLRenderPassDescriptor *platformRenderPassDescriptor(); >+#if USE(METAL) >+ MTLRenderPassDescriptor *metal() const; > #endif > >+#if USE(METAL) > private: >- GPURenderPassDescriptor(); >- >-#if PLATFORM(COCOA) >- RetainPtr<MTLRenderPassDescriptor> m_renderPassDescriptor; >+ RetainPtr<MTLRenderPassDescriptor> m_metal; > #endif >- RefPtr<GPURenderPassDepthAttachmentDescriptor> m_depthAttachment; > }; > > } // namespace WebCore >+ > #endif >diff --git a/Source/WebCore/platform/graphics/gpu/GPURenderPipelineColorAttachmentDescriptor.cpp b/Source/WebCore/platform/graphics/gpu/GPURenderPipelineColorAttachmentDescriptor.cpp >index 6af411987e243e32e1bcb24f4661542d3aab3625..a758780094411c07f71165cba214d4ca24780785 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPURenderPipelineColorAttachmentDescriptor.cpp >+++ b/Source/WebCore/platform/graphics/gpu/GPURenderPipelineColorAttachmentDescriptor.cpp >@@ -28,7 +28,6 @@ > > #if ENABLE(WEBGPU) > >-#include "GPUTexture.h" > #include "Logging.h" > > namespace WebCore { >@@ -38,22 +37,6 @@ GPURenderPipelineColorAttachmentDescriptor::~GPURenderPipelineColorAttachmentDes > LOG(WebGPU, "GPURenderPipelineColorAttachmentDescriptor::~GPURenderPipelineColorAttachmentDescriptor()"); > } > >-#if !PLATFORM(COCOA) >-GPURenderPipelineColorAttachmentDescriptor::GPURenderPipelineColorAttachmentDescriptor() >-{ >- LOG(WebGPU, "GPURenderPipelineColorAttachmentDescriptor::GPURenderPipelineColorAttachmentDescriptor()"); >-} >- >-unsigned long GPURenderPipelineColorAttachmentDescriptor::pixelFormat() const >-{ >- return 0; >-} >- >-void GPURenderPipelineColorAttachmentDescriptor::setPixelFormat(unsigned long) >-{ >-} >-#endif >- > } // namespace WebCore > > #endif >diff --git a/Source/WebCore/platform/graphics/gpu/GPURenderPipelineColorAttachmentDescriptor.h b/Source/WebCore/platform/graphics/gpu/GPURenderPipelineColorAttachmentDescriptor.h >index f1c1a705d27913b8e08a52749bbfc879355e2759..a80a5d00e6b06d3e7cc829041b89959d781ec55a 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPURenderPipelineColorAttachmentDescriptor.h >+++ b/Source/WebCore/platform/graphics/gpu/GPURenderPipelineColorAttachmentDescriptor.h >@@ -27,43 +27,32 @@ > > #if ENABLE(WEBGPU) > >-#include <wtf/RefCounted.h> >-#include <wtf/RefPtr.h> > #include <wtf/RetainPtr.h> > >-#if PLATFORM(COCOA) > OBJC_CLASS MTLRenderPipelineColorAttachmentDescriptor; >-#endif > > namespace WebCore { > >-class GPUTexture; >- >-class GPURenderPipelineColorAttachmentDescriptor : public RefCounted<GPURenderPipelineColorAttachmentDescriptor> { >+class GPURenderPipelineColorAttachmentDescriptor { > public: >-#if PLATFORM(COCOA) >- static RefPtr<GPURenderPipelineColorAttachmentDescriptor> create(MTLRenderPipelineColorAttachmentDescriptor *); >-#else >- static RefPtr<GPURenderPipelineColorAttachmentDescriptor> create(); >+#if USE(METAL) >+ GPURenderPipelineColorAttachmentDescriptor(MTLRenderPipelineColorAttachmentDescriptor *); > #endif >+ ~GPURenderPipelineColorAttachmentDescriptor(); > >- WEBCORE_EXPORT ~GPURenderPipelineColorAttachmentDescriptor(); >+ unsigned pixelFormat() const; >+ void setPixelFormat(unsigned) const; > >- WEBCORE_EXPORT unsigned long pixelFormat() const; >- WEBCORE_EXPORT void setPixelFormat(unsigned long); >- >-#if PLATFORM(COCOA) >- WEBCORE_EXPORT MTLRenderPipelineColorAttachmentDescriptor *platformRenderPipelineColorAttachmentDescriptor(); >+#if USE(METAL) >+ MTLRenderPipelineColorAttachmentDescriptor *metal() const; > #endif > >-protected: >-#if PLATFORM(COCOA) >- GPURenderPipelineColorAttachmentDescriptor(MTLRenderPipelineColorAttachmentDescriptor *); >- RetainPtr<MTLRenderPipelineColorAttachmentDescriptor> m_renderPipelineColorAttachmentDescriptor; >-#else >- GPURenderPipelineColorAttachmentDescriptor(); >+#if USE(METAL) >+private: >+ RetainPtr<MTLRenderPipelineColorAttachmentDescriptor> m_metal; > #endif > }; > > } // namespace WebCore >+ > #endif >diff --git a/Source/WebCore/platform/graphics/gpu/GPURenderPipelineDescriptor.cpp b/Source/WebCore/platform/graphics/gpu/GPURenderPipelineDescriptor.cpp >index 7cc89842d20372f9f1c8b04c51685369482dabbb..968cc45361eb0064235feef0dcf8a83420a5634d 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPURenderPipelineDescriptor.cpp >+++ b/Source/WebCore/platform/graphics/gpu/GPURenderPipelineDescriptor.cpp >@@ -28,48 +28,15 @@ > > #if ENABLE(WEBGPU) > >-#include "GPUFunction.h" >-#include "GPURenderPipelineColorAttachmentDescriptor.h" >-#include "GPUTexture.h" > #include "Logging.h" > > namespace WebCore { > >-RefPtr<GPURenderPipelineDescriptor> GPURenderPipelineDescriptor::create() >-{ >- RefPtr<GPURenderPipelineDescriptor> descriptor = adoptRef(new GPURenderPipelineDescriptor()); >- return descriptor; >-} >- > GPURenderPipelineDescriptor::~GPURenderPipelineDescriptor() > { > LOG(WebGPU, "GPURenderPipelineDescriptor::~GPURenderPipelineDescriptor()"); > } > >-#if !PLATFORM(COCOA) >-unsigned long GPURenderPipelineDescriptor::depthAttachmentPixelFormat() const >-{ >- return false; >-} >- >-void GPURenderPipelineDescriptor::setDepthAttachmentPixelFormat(unsigned long) >-{ >-} >- >-void GPURenderPipelineDescriptor::setVertexFunction(RefPtr<GPUFunction>) >-{ >-} >- >-void GPURenderPipelineDescriptor::setFragmentFunction(RefPtr<GPUFunction>) >-{ >-} >- >-Vector<RefPtr<GPURenderPipelineColorAttachmentDescriptor>> GPURenderPipelineDescriptor::colorAttachments() >-{ >- return Vector<RefPtr<GPURenderPipelineColorAttachmentDescriptor>>(); >-} >-#endif >- > } // namespace WebCore > > #endif >diff --git a/Source/WebCore/platform/graphics/gpu/GPURenderPipelineDescriptor.h b/Source/WebCore/platform/graphics/gpu/GPURenderPipelineDescriptor.h >index 302f1fc0c8ec005e9b21eef94881d61d97e31c2b..1fde92788f55da4fd7885182d7cab3b488e3628b 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPURenderPipelineDescriptor.h >+++ b/Source/WebCore/platform/graphics/gpu/GPURenderPipelineDescriptor.h >@@ -27,46 +27,40 @@ > > #if ENABLE(WEBGPU) > >-#include "GPUEnums.h" >-#include <wtf/RefCounted.h> >-#include <wtf/RefPtr.h> > #include <wtf/RetainPtr.h> >-#include <wtf/Vector.h> > >-#if PLATFORM(COCOA) > OBJC_CLASS MTLRenderPipelineDescriptor; >-#endif > > namespace WebCore { > > class GPUFunction; > class GPURenderPipelineColorAttachmentDescriptor; > >-class GPURenderPipelineDescriptor : public RefCounted<GPURenderPipelineDescriptor> { >+class GPURenderPipelineDescriptor { > public: >- static RefPtr<GPURenderPipelineDescriptor> create(); >- WEBCORE_EXPORT ~GPURenderPipelineDescriptor(); >+ GPURenderPipelineDescriptor(); >+ ~GPURenderPipelineDescriptor(); > >- WEBCORE_EXPORT void setVertexFunction(RefPtr<GPUFunction>); >- WEBCORE_EXPORT void setFragmentFunction(RefPtr<GPUFunction>); >+ void setVertexFunction(const GPUFunction&) const; >+ void setFragmentFunction(const GPUFunction&) const; > >- WEBCORE_EXPORT unsigned long depthAttachmentPixelFormat() const; >- WEBCORE_EXPORT void setDepthAttachmentPixelFormat(unsigned long); >+ unsigned depthAttachmentPixelFormat() const; >+ void setDepthAttachmentPixelFormat(unsigned) const; > >- WEBCORE_EXPORT Vector<RefPtr<GPURenderPipelineColorAttachmentDescriptor>> colorAttachments(); >+ Vector<GPURenderPipelineColorAttachmentDescriptor> colorAttachments() const; > >- WEBCORE_EXPORT void reset(); >+ void reset() const; > >-#if PLATFORM(COCOA) >- WEBCORE_EXPORT MTLRenderPipelineDescriptor *platformRenderPipelineDescriptor(); >+#if USE(METAL) >+ MTLRenderPipelineDescriptor *metal() const; > #endif > >+#if USE(METAL) > private: >- GPURenderPipelineDescriptor(); >-#if PLATFORM(COCOA) >- RetainPtr<MTLRenderPipelineDescriptor> m_renderPipelineDescriptor; >+ RetainPtr<MTLRenderPipelineDescriptor> m_metal; > #endif > }; >- >+ > } // namespace WebCore >+ > #endif >diff --git a/Source/WebCore/platform/graphics/gpu/GPURenderPipelineState.cpp b/Source/WebCore/platform/graphics/gpu/GPURenderPipelineState.cpp >index 9fee38cc212023f2753d8f3cda1794aad5a45d03..69dc4105d1fe0f443d1c36b246e0f77f31af94dc 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPURenderPipelineState.cpp >+++ b/Source/WebCore/platform/graphics/gpu/GPURenderPipelineState.cpp >@@ -28,34 +28,15 @@ > > #if ENABLE(WEBGPU) > >-#include "GPUDevice.h" >-#include "GPURenderPipelineDescriptor.h" > #include "Logging.h" > > namespace WebCore { > >-RefPtr<GPURenderPipelineState> GPURenderPipelineState::create(GPUDevice* device, GPURenderPipelineDescriptor* descriptor) >-{ >- RefPtr<GPURenderPipelineState> state = adoptRef(new GPURenderPipelineState(device, descriptor)); >- return state; >-} >- > GPURenderPipelineState::~GPURenderPipelineState() > { > LOG(WebGPU, "GPURenderPipelineState::~GPURenderPipelineState()"); > } > >-#if !PLATFORM(COCOA) >-String GPURenderPipelineState::label() const >-{ >- return emptyString(); >-} >- >-void GPURenderPipelineState::setLabel(const String&) >-{ >-} >-#endif >- > } // namespace WebCore > > #endif >diff --git a/Source/WebCore/platform/graphics/gpu/GPURenderPipelineState.h b/Source/WebCore/platform/graphics/gpu/GPURenderPipelineState.h >index 3a7a63d1c6513ebb4975a5728b28bf79b7a3d52e..c8832496e87a5df67a10898e172d06833f1c17b4 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPURenderPipelineState.h >+++ b/Source/WebCore/platform/graphics/gpu/GPURenderPipelineState.h >@@ -1,5 +1,5 @@ > /* >- * Copyright (C) 2017 Apple Inc. All rights reserved. >+ * Copyright (C) 2017-2018 Apple Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions >@@ -27,39 +27,34 @@ > > #if ENABLE(WEBGPU) > >-#include <wtf/RefCounted.h> >-#include <wtf/RefPtr.h> > #include <wtf/RetainPtr.h> >-#include <wtf/text/WTFString.h> > >-#if PLATFORM(COCOA) >-OBJC_CLASS MTLRenderPipelineState; >-#endif >+OBJC_PROTOCOL(MTLRenderPipelineState); > > namespace WebCore { > > class GPUDevice; > class GPURenderPipelineDescriptor; > >-class GPURenderPipelineState : public RefCounted<GPURenderPipelineState> { >+class GPURenderPipelineState { > public: >- static RefPtr<GPURenderPipelineState> create(GPUDevice*, GPURenderPipelineDescriptor*); >- WEBCORE_EXPORT ~GPURenderPipelineState(); >+ GPURenderPipelineState() = default; >+ GPURenderPipelineState(const GPUDevice&, const GPURenderPipelineDescriptor&); >+ ~GPURenderPipelineState(); > >- WEBCORE_EXPORT String label() const; >- WEBCORE_EXPORT void setLabel(const String&); >+ String label() const; >+ void setLabel(const String&) const; > >-#if PLATFORM(COCOA) >- WEBCORE_EXPORT MTLRenderPipelineState *platformRenderPipelineState(); >+#if USE(METAL) >+ MTLRenderPipelineState *metal() const; > #endif > >+#if USE(METAL) > private: >- GPURenderPipelineState(GPUDevice*, GPURenderPipelineDescriptor*); >- >-#if PLATFORM(COCOA) >- RetainPtr<MTLRenderPipelineState> m_renderPipelineState; >+ RetainPtr<MTLRenderPipelineState> m_metal; > #endif > }; > > } // namespace WebCore >+ > #endif >diff --git a/Source/WebCore/platform/graphics/gpu/GPUSize.h b/Source/WebCore/platform/graphics/gpu/GPUSize.h >index f489f443eb50731c9ec0e3f02c0404f9a68f2954..3958e83bf3be8c8143b692555d8268065b9594cb 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPUSize.h >+++ b/Source/WebCore/platform/graphics/gpu/GPUSize.h >@@ -30,10 +30,11 @@ > namespace WebCore { > > struct GPUSize { >- unsigned long width; >- unsigned long height; >- unsigned long depth; >+ unsigned width; >+ unsigned height; >+ unsigned depth; > }; > > } // namespace WebCore >+ > #endif >diff --git a/Source/WebCore/platform/graphics/gpu/GPUTexture.cpp b/Source/WebCore/platform/graphics/gpu/GPUTexture.cpp >index 47714c18039aaf3ec20ea3e00ca29a8f16fbeabf..bcc5e8a31dbe71d3326b14ab1da483e3d352bf3d 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPUTexture.cpp >+++ b/Source/WebCore/platform/graphics/gpu/GPUTexture.cpp >@@ -28,41 +28,15 @@ > > #if ENABLE(WEBGPU) > >-#include "GPUDevice.h" >-#include "GPUDrawable.h" > #include "Logging.h" > > namespace WebCore { > >-RefPtr<GPUTexture> GPUTexture::create(GPUDevice* device, GPUTextureDescriptor* descriptor) >-{ >- RefPtr<GPUTexture> texture = adoptRef(new GPUTexture(device, descriptor)); >- return texture; >-} >- >-RefPtr<GPUTexture> GPUTexture::createFromDrawable(GPUDrawable* other) >-{ >- RefPtr<GPUTexture> texture = adoptRef(new GPUTexture(other)); >- return texture; >-} >- > GPUTexture::~GPUTexture() > { > LOG(WebGPU, "GPUTexture::~GPUTexture()"); > } > >-#if !PLATFORM(COCOA) >-unsigned long GPUTexture::width() const >-{ >- return 0; >-} >- >-unsigned long GPUTexture::height() const >-{ >- return 0; >-} >-#endif >- > } // namespace WebCore > > #endif >diff --git a/Source/WebCore/platform/graphics/gpu/GPUTexture.h b/Source/WebCore/platform/graphics/gpu/GPUTexture.h >index 2894b4eadc0edd551e039beda1c71f9836593d22..d036791cee6c2e52353c98e6a851a2841336f747 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPUTexture.h >+++ b/Source/WebCore/platform/graphics/gpu/GPUTexture.h >@@ -27,13 +27,9 @@ > > #if ENABLE(WEBGPU) > >-#include <wtf/RefCounted.h> >-#include <wtf/RefPtr.h> > #include <wtf/RetainPtr.h> > >-#if PLATFORM(COCOA) >-OBJC_CLASS MTLTexture; >-#endif >+OBJC_PROTOCOL(MTLTexture); > > namespace WebCore { > >@@ -41,28 +37,25 @@ class GPUDevice; > class GPUDrawable; > class GPUTextureDescriptor; > >-class GPUTexture : public RefCounted<GPUTexture> { >+class GPUTexture { > public: >- static RefPtr<GPUTexture> create(GPUDevice*, GPUTextureDescriptor*); >- static RefPtr<GPUTexture> createFromDrawable(GPUDrawable*); >- >- WEBCORE_EXPORT ~GPUTexture(); >+ GPUTexture(const GPUDevice&, const GPUTextureDescriptor&); >+ explicit GPUTexture(const GPUDrawable&); >+ ~GPUTexture(); > >- WEBCORE_EXPORT unsigned long width() const; >- WEBCORE_EXPORT unsigned long height() const; >+ unsigned width() const; >+ unsigned height() const; > >-#if PLATFORM(COCOA) >- WEBCORE_EXPORT MTLTexture *platformTexture(); >+#if USE(METAL) >+ MTLTexture *metal() const; > #endif > >+#if USE(METAL) > private: >- GPUTexture(GPUDevice*, GPUTextureDescriptor*); >- GPUTexture(GPUDrawable*); >- >-#if PLATFORM(COCOA) >- RetainPtr<MTLTexture> m_texture; >+ RetainPtr<MTLTexture> m_metal; > #endif > }; > > } // namespace WebCore >+ > #endif >diff --git a/Source/WebCore/platform/graphics/gpu/GPUTextureDescriptor.cpp b/Source/WebCore/platform/graphics/gpu/GPUTextureDescriptor.cpp >index 80ce12dd7ef0c8d4c35cf548d740a5335bfbd0f8..df675a4cd1494cae62060b7392e4d906a6dce6c9 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPUTextureDescriptor.cpp >+++ b/Source/WebCore/platform/graphics/gpu/GPUTextureDescriptor.cpp >@@ -32,73 +32,11 @@ > > namespace WebCore { > >-RefPtr<GPUTextureDescriptor> GPUTextureDescriptor::create(unsigned long pixelFormat, unsigned long width, unsigned long height, bool mipmapped) >-{ >- RefPtr<GPUTextureDescriptor> descriptor = adoptRef(new GPUTextureDescriptor(pixelFormat, width, height, mipmapped)); >- return descriptor; >-} >- > GPUTextureDescriptor::~GPUTextureDescriptor() > { > LOG(WebGPU, "GPUTextureDescriptor::~GPUTextureDescriptor()"); > } > >-#if !PLATFORM(COCOA) >-unsigned long GPUTextureDescriptor::width() const >-{ >- return 0; >-} >- >-void GPUTextureDescriptor::setWidth(unsigned long) >-{ >-} >- >-unsigned long GPUTextureDescriptor::height() const >-{ >- return 0; >-} >- >-void GPUTextureDescriptor::setHeight(unsigned long) >-{ >-} >- >-unsigned long GPUTextureDescriptor::sampleCount() const >-{ >- return 0; >-} >- >-void GPUTextureDescriptor::setSampleCount(unsigned long) >-{ >-} >- >-unsigned long GPUTextureDescriptor::textureType() const >-{ >- return 0; >-} >- >-void GPUTextureDescriptor::setTextureType(unsigned long) >-{ >-} >- >-unsigned long GPUTextureDescriptor::storageMode() const >-{ >- return 0; >-} >- >-void GPUTextureDescriptor::setStorageMode(unsigned long) >-{ >-} >- >-unsigned long GPUTextureDescriptor::usage() const >-{ >- return 0; >-} >- >-void GPUTextureDescriptor::setUsage(unsigned long) >-{ >-} >-#endif >- > } // namespace WebCore > > #endif >diff --git a/Source/WebCore/platform/graphics/gpu/GPUTextureDescriptor.h b/Source/WebCore/platform/graphics/gpu/GPUTextureDescriptor.h >index 7e21ba28a86c6c0099170230d54bca5bd1bf4e9b..24111fcfaf26c457c0052bbb5e8bf7d11ed53362 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPUTextureDescriptor.h >+++ b/Source/WebCore/platform/graphics/gpu/GPUTextureDescriptor.h >@@ -27,48 +27,42 @@ > > #if ENABLE(WEBGPU) > >-#include <wtf/RefCounted.h> >-#include <wtf/RefPtr.h> > #include <wtf/RetainPtr.h> > >-#if PLATFORM(COCOA) > OBJC_CLASS MTLTextureDescriptor; >-#endif > > namespace WebCore { > >-class GPUTextureDescriptor : public RefCounted<GPUTextureDescriptor> { >+class GPUTextureDescriptor { > public: >- static RefPtr<GPUTextureDescriptor> create(unsigned long pixelFormat, unsigned long width, unsigned long height, bool mipmapped); >- WEBCORE_EXPORT ~GPUTextureDescriptor(); >+ GPUTextureDescriptor(unsigned pixelFormat, unsigned width, unsigned height, bool mipmapped); >+ ~GPUTextureDescriptor(); > >- WEBCORE_EXPORT unsigned long width() const; >- WEBCORE_EXPORT void setWidth(unsigned long); >+ unsigned width() const; >+ void setWidth(unsigned) const; > >- WEBCORE_EXPORT unsigned long height() const; >- WEBCORE_EXPORT void setHeight(unsigned long); >+ unsigned height() const; >+ void setHeight(unsigned) const; > >- WEBCORE_EXPORT unsigned long sampleCount() const; >- WEBCORE_EXPORT void setSampleCount(unsigned long); >+ unsigned sampleCount() const; >+ void setSampleCount(unsigned) const; > >- WEBCORE_EXPORT unsigned long textureType() const; >- WEBCORE_EXPORT void setTextureType(unsigned long); >+ unsigned textureType() const; >+ void setTextureType(unsigned) const; > >- WEBCORE_EXPORT unsigned long storageMode() const; >- WEBCORE_EXPORT void setStorageMode(unsigned long); >+ unsigned storageMode() const; >+ void setStorageMode(unsigned) const; > >- WEBCORE_EXPORT unsigned long usage() const; >- WEBCORE_EXPORT void setUsage(unsigned long); >+ unsigned usage() const; >+ void setUsage(unsigned) const; > >-#if PLATFORM(COCOA) >- WEBCORE_EXPORT MTLTextureDescriptor *platformTextureDescriptor(); >+#if USE(METAL) >+ MTLTextureDescriptor *metal() const; > #endif > >+#if USE(METAL) > private: >- GPUTextureDescriptor(unsigned long pixelFormat, unsigned long width, unsigned long height, bool mipmapped); >- >-#if PLATFORM(COCOA) >- RetainPtr<MTLTextureDescriptor> m_textureDescriptor; >+ RetainPtr<MTLTextureDescriptor> m_metal; > #endif > }; > >diff --git a/Source/WebCore/platform/graphics/metal/GPUBufferMetal.mm b/Source/WebCore/platform/graphics/metal/GPUBufferMetal.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..4a119c7d9f4fc59e6c964d2fbea03b2753ccbbcd >--- /dev/null >+++ b/Source/WebCore/platform/graphics/metal/GPUBufferMetal.mm >@@ -0,0 +1,69 @@ >+/* >+ * Copyright (C) 2017 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#import "config.h" >+#import "GPUBuffer.h" >+ >+#if ENABLE(WEBGPU) >+ >+#import "GPUDevice.h" >+#import "Logging.h" >+#import <JavaScriptCore/ArrayBufferView.h> >+#import <Metal/Metal.h> >+#import <wtf/Gigacage.h> >+#import <wtf/PageBlock.h> >+ >+namespace WebCore { >+ >+GPUBuffer::GPUBuffer(const GPUDevice& device, const JSC::ArrayBufferView& data) >+{ >+ LOG(WebGPU, "GPUBuffer::GPUBuffer()"); >+ >+ if (!device.metal()) >+ return; >+ >+ size_t pageSize = WTF::pageSize(); >+ size_t pageAlignedSize = roundUpToMultipleOf(pageSize, data.byteLength()); >+ void* pageAlignedCopy = Gigacage::tryAlignedMalloc(Gigacage::Primitive, pageSize, pageAlignedSize); >+ if (!pageAlignedCopy) >+ return; >+ memcpy(pageAlignedCopy, data.baseAddress(), data.byteLength()); >+ m_contents = ArrayBuffer::createFromBytes(pageAlignedCopy, data.byteLength(), [] (void* ptr) { >+ Gigacage::alignedFree(Gigacage::Primitive, ptr); >+ }); >+ m_contents->ref(); >+ ArrayBuffer* capturedContents = m_contents.get(); >+ m_metal = adoptNS([device.metal() newBufferWithBytesNoCopy:m_contents->data() length:pageAlignedSize options:MTLResourceOptionCPUCacheModeDefault deallocator:^(void*, NSUInteger) { >+ capturedContents->deref(); >+ }]); >+ if (!m_metal) { >+ m_contents->deref(); >+ m_contents = nullptr; >+ } >+} >+ >+} // namespace WebCore >+ >+#endif >diff --git a/Source/WebCore/platform/graphics/metal/GPUCommandBufferMetal.mm b/Source/WebCore/platform/graphics/metal/GPUCommandBufferMetal.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..ff16dbd495e30c7a863674fe0dd92de3c3ec3607 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/metal/GPUCommandBufferMetal.mm >@@ -0,0 +1,66 @@ >+/* >+ * Copyright (C) 2017 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#import "config.h" >+#import "GPUCommandBuffer.h" >+ >+#if ENABLE(WEBGPU) >+ >+#import "GPUCommandQueue.h" >+#import "GPUDrawable.h" >+#import "Logging.h" >+#import <Metal/Metal.h> >+#import <wtf/BlockPtr.h> >+#import <wtf/MainThread.h> >+ >+namespace WebCore { >+ >+GPUCommandBuffer::GPUCommandBuffer(const GPUCommandQueue& queue, Function<void()>&& completedCallback) >+ : m_metal { [queue.metal() commandBuffer] } >+{ >+ LOG(WebGPU, "GPUCommandBuffer::GPUCommandBuffer()"); >+ >+ [m_metal addCompletedHandler:BlockPtr<void (id<MTLCommandBuffer>)>::fromCallable([&completedCallback] (id<MTLCommandBuffer>) { >+ callOnMainThread(WTFMove(completedCallback)); >+ }).get()]; >+} >+ >+void GPUCommandBuffer::presentDrawable(GPUDrawable& drawable) const >+{ >+ if (!m_metal || !drawable.metal()) >+ return; >+ >+ [m_metal presentDrawable:drawable.metal()]; >+ drawable.release(); >+} >+ >+void GPUCommandBuffer::commit() const >+{ >+ [m_metal commit]; >+} >+ >+} // namespace WebCore >+ >+#endif >diff --git a/Source/WebCore/platform/graphics/metal/GPUCommandQueueMetal.mm b/Source/WebCore/platform/graphics/metal/GPUCommandQueueMetal.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..820af8bc16db3b4865e79b7b824db2c7b4df3ecc >--- /dev/null >+++ b/Source/WebCore/platform/graphics/metal/GPUCommandQueueMetal.mm >@@ -0,0 +1,72 @@ >+/* >+ * Copyright (C) 2017 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#import "config.h" >+#import "GPUCommandQueue.h" >+ >+#if ENABLE(WEBGPU) >+ >+#import "GPUDevice.h" >+#import "Logging.h" >+#import <Metal/Metal.h> >+ >+namespace WebCore { >+ >+static NSString * const commandQueueDefaultLabel = @"com.apple.WebKit"; >+static NSString * const commandQueueLabelPrefix = @"com.apple.WebKit."; >+ >+GPUCommandQueue::GPUCommandQueue(const GPUDevice& device) >+ : m_metal { adoptNS([device.metal() newCommandQueue]) } >+{ >+ LOG(WebGPU, "GPUCommandQueue::GPUCommandQueue()"); >+ >+ [m_metal setLabel:commandQueueDefaultLabel]; >+} >+ >+String GPUCommandQueue::label() const >+{ >+ if (!m_metal) >+ return emptyString(); >+ >+ NSString *prefixedLabel = [m_metal label]; >+ >+ if ([prefixedLabel isEqualToString:commandQueueDefaultLabel]) >+ return emptyString(); >+ >+ ASSERT(prefixedLabel.length > commandQueueLabelPrefix.length); >+ return [prefixedLabel substringFromIndex:commandQueueLabelPrefix.length]; >+} >+ >+void GPUCommandQueue::setLabel(const String& label) const >+{ >+ if (label.isEmpty()) >+ [m_metal setLabel:commandQueueDefaultLabel]; >+ else >+ [m_metal setLabel:[commandQueueLabelPrefix stringByAppendingString:label]]; >+} >+ >+} // namespace WebCore >+ >+#endif >diff --git a/Source/WebCore/platform/graphics/metal/GPUComputeCommandEncoderMetal.mm b/Source/WebCore/platform/graphics/metal/GPUComputeCommandEncoderMetal.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..1a05bbdb9e78a27069341690e35470fa579ea492 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/metal/GPUComputeCommandEncoderMetal.mm >@@ -0,0 +1,79 @@ >+/* >+ * Copyright (C) 2017 Yuichiro Kikura (y.kikura@gmail.com) >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#import "config.h" >+#import "GPUComputeCommandEncoder.h" >+ >+#if ENABLE(WEBGPU) >+ >+#import "GPUBuffer.h" >+#import "GPUCommandBuffer.h" >+#import "GPUComputePipelineState.h" >+#import "GPUSize.h" >+#import "Logging.h" >+#import <Metal/Metal.h> >+ >+namespace WebCore { >+ >+static inline MTLSize MTLSizeMake(GPUSize size) >+{ >+ return { size.width, size.height, size.depth }; >+} >+ >+GPUComputeCommandEncoder::GPUComputeCommandEncoder(const GPUCommandBuffer& buffer) >+ : m_metal { [buffer.metal() computeCommandEncoder] } >+{ >+ LOG(WebGPU, "GPUComputeCommandEncoder::GPUComputeCommandEncoder()"); >+} >+ >+void GPUComputeCommandEncoder::setComputePipelineState(const GPUComputePipelineState& computePipelineState) const >+{ >+ if (!computePipelineState.metal()) >+ return; >+ >+ [m_metal setComputePipelineState:computePipelineState.metal()]; >+} >+ >+void GPUComputeCommandEncoder::setBuffer(const GPUBuffer& buffer, unsigned offset, unsigned index) const >+{ >+ if (!buffer.metal()) >+ return; >+ >+ [m_metal setBuffer:buffer.metal() offset:offset atIndex:index]; >+} >+ >+void GPUComputeCommandEncoder::dispatch(GPUSize threadgroupsPerGrid, GPUSize threadsPerThreadgroup) const >+{ >+ [m_metal dispatchThreadgroups:MTLSizeMake(threadgroupsPerGrid) threadsPerThreadgroup:MTLSizeMake(threadsPerThreadgroup)]; >+} >+ >+void GPUComputeCommandEncoder::endEncoding() const >+{ >+ [m_metal endEncoding]; >+} >+ >+} // namespace WebCore >+ >+#endif >diff --git a/Source/WebCore/platform/graphics/metal/GPUComputePipelineStateMetal.mm b/Source/WebCore/platform/graphics/metal/GPUComputePipelineStateMetal.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..501beee7d1c4c3b4a2fc7ef03a0da9e59059b61b >--- /dev/null >+++ b/Source/WebCore/platform/graphics/metal/GPUComputePipelineStateMetal.mm >@@ -0,0 +1,50 @@ >+/* >+ * Copyright (C) 2017 Yuichiro Kikura (y.kikura@gmail.com) >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#import "config.h" >+#import "GPUComputePipelineState.h" >+ >+#if ENABLE(WEBGPU) >+ >+#import "GPUDevice.h" >+#import "GPUFunction.h" >+#import "Logging.h" >+#import <Metal/Metal.h> >+ >+namespace WebCore { >+ >+GPUComputePipelineState::GPUComputePipelineState(const GPUDevice& device, const GPUFunction& function) >+{ >+ LOG(WebGPU, "GPUComputePipelineState::GPUComputePipelineState()"); >+ >+ if (!function.metal()) >+ return; >+ >+ m_metal = adoptNS([device.metal() newComputePipelineStateWithFunction:function.metal() error:nil]); >+} >+ >+} // namespace WebCore >+ >+#endif >diff --git a/Source/WebCore/platform/graphics/metal/GPUDepthStencilDescriptorMetal.mm b/Source/WebCore/platform/graphics/metal/GPUDepthStencilDescriptorMetal.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..d4a9882cd2910d5fb6c3781dcff9b7930a222b2f >--- /dev/null >+++ b/Source/WebCore/platform/graphics/metal/GPUDepthStencilDescriptorMetal.mm >@@ -0,0 +1,66 @@ >+/* >+ * Copyright (C) 2017 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#import "config.h" >+#import "GPUDepthStencilDescriptor.h" >+ >+#if ENABLE(WEBGPU) >+ >+#import "GPUEnums.h" >+#import "Logging.h" >+#import <Metal/Metal.h> >+ >+namespace WebCore { >+ >+GPUDepthStencilDescriptor::GPUDepthStencilDescriptor() >+ : m_metal { adoptNS([MTLDepthStencilDescriptor new]) } >+{ >+ LOG(WebGPU, "GPUDepthStencilDescriptor::GPUDepthStencilDescriptor()"); >+} >+ >+bool GPUDepthStencilDescriptor::depthWriteEnabled() const >+{ >+ return [m_metal isDepthWriteEnabled]; >+} >+ >+void GPUDepthStencilDescriptor::setDepthWriteEnabled(bool newDepthWriteEnabled) const >+{ >+ [m_metal setDepthWriteEnabled:newDepthWriteEnabled]; >+} >+ >+GPUCompareFunction GPUDepthStencilDescriptor::depthCompareFunction() const >+{ >+ return static_cast<GPUCompareFunction>([m_metal depthCompareFunction]); >+} >+ >+void GPUDepthStencilDescriptor::setDepthCompareFunction(GPUCompareFunction newFunction) const >+{ >+ // FIXME: Do we need to check if the function value is in range before casting to MTLCompareFunction? >+ [m_metal setDepthCompareFunction:static_cast<MTLCompareFunction>(newFunction)]; >+} >+ >+} // namespace WebCore >+ >+#endif >diff --git a/Source/WebCore/platform/graphics/metal/GPUDepthStencilStateMetal.mm b/Source/WebCore/platform/graphics/metal/GPUDepthStencilStateMetal.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..725f25ae63430540eb0aa893fbfa007156287445 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/metal/GPUDepthStencilStateMetal.mm >@@ -0,0 +1,62 @@ >+/* >+ * Copyright (C) 2017 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#import "config.h" >+#import "GPUDepthStencilState.h" >+ >+#if ENABLE(WEBGPU) >+ >+#import "GPUDepthStencilDescriptor.h" >+#import "GPUDevice.h" >+#import "Logging.h" >+#import <Metal/Metal.h> >+#import <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+GPUDepthStencilState::GPUDepthStencilState(const GPUDevice& device, const GPUDepthStencilDescriptor& descriptor) >+ : m_metal { adoptNS([device.metal() newDepthStencilStateWithDescriptor:descriptor.metal()]) } >+{ >+ LOG(WebGPU, "GPUDepthStencilState::GPUDepthStencilState()"); >+} >+ >+String GPUDepthStencilState::label() const >+{ >+ if (!m_metal) >+ return emptyString(); >+ >+ return [m_metal label]; >+} >+ >+void GPUDepthStencilState::setLabel(const String&) const >+{ >+ // FIXME: The MTLDepthStencilState protocol does not allow setting the label. >+ // The label has to be set on the descriptor when creating the state object. >+ // We should consider changing the WebGPU interface to not require this! >+} >+ >+} // namespace WebCore >+ >+#endif >diff --git a/Source/WebCore/platform/graphics/metal/GPUDeviceMetal.mm b/Source/WebCore/platform/graphics/metal/GPUDeviceMetal.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..8addfe9accfc7d949dd6c9e0f5988b853b1022ce >--- /dev/null >+++ b/Source/WebCore/platform/graphics/metal/GPUDeviceMetal.mm >@@ -0,0 +1,90 @@ >+/* >+ * Copyright (C) 2017 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#import "config.h" >+#import "GPUDevice.h" >+ >+#if ENABLE(WEBGPU) >+ >+#import "Logging.h" >+#import "WebGPULayer.h" >+#import <JavaScriptCore/ArrayBuffer.h> >+#import <Metal/Metal.h> >+#import <wtf/BlockObjCExceptions.h> >+ >+namespace WebCore { >+ >+GPUDevice::GPUDevice() >+ : m_metal { adoptNS(MTLCreateSystemDefaultDevice()) } >+{ >+ >+ if (!m_metal) { >+ LOG(WebGPU, "GPUDevice::GPUDevice -- could not create the device. This usually means Metal is not available on this hardware."); >+ return; >+ } >+ >+ LOG(WebGPU, "GPUDevice::GPUDevice Metal device is %p", m_metal.get()); >+ >+ BEGIN_BLOCK_OBJC_EXCEPTIONS >+ >+ m_layer = adoptNS([[WebGPULayer alloc] initWithGPUDevice:this]); >+ [m_layer setOpaque:0]; >+ [m_layer setName:@"WebGPU Layer"]; >+ >+ // FIXME: WebGPU - Should this be in the WebGPULayer initializer? >+ [m_layer setDevice:m_metal.get()]; >+ [m_layer setPixelFormat:MTLPixelFormatBGRA8Unorm]; >+ [m_layer setFramebufferOnly:YES]; >+ >+ END_BLOCK_OBJC_EXCEPTIONS >+} >+ >+void GPUDevice::disconnect() >+{ >+ m_layer.get().context = nullptr; >+ // FIXME: Should we also clear out the device property, which has the MTLDevice? >+} >+ >+void GPUDevice::reshape(int width, int height) const >+{ >+ [m_layer setBounds:CGRectMake(0, 0, width, height)]; >+ [m_layer setDrawableSize:CGSizeMake(width, height)]; >+ >+ // FIXME: WebGPU - Lots of reshape stuff should go here. See GC3D. >+} >+ >+CALayer *GPUDevice::platformLayer() const >+{ >+ return m_layer.get(); >+} >+ >+bool GPUDevice::operator!() const >+{ >+ return !m_metal; >+} >+ >+} // namespace WebCore >+ >+#endif >diff --git a/Source/WebCore/platform/graphics/metal/GPUDrawableMetal.mm b/Source/WebCore/platform/graphics/metal/GPUDrawableMetal.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..2b09ffd05f10aa9852b07bc67637c4ddd2c72c5c >--- /dev/null >+++ b/Source/WebCore/platform/graphics/metal/GPUDrawableMetal.mm >@@ -0,0 +1,66 @@ >+/* >+ * Copyright (C) 2017 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#import "config.h" >+#import "GPUDrawable.h" >+ >+#if ENABLE(WEBGPU) >+ >+#import "GPUDevice.h" >+#import "Logging.h" >+#import <Metal/Metal.h> >+#import <QuartzCore/QuartzCore.h> >+ >+namespace WebCore { >+ >+GPUDrawable::GPUDrawable(const GPUDevice& device) >+ : m_metal { [device.layer() nextDrawable] } >+{ >+ LOG(WebGPU, "GPUDrawable::GPUDrawable()"); >+} >+ >+void GPUDrawable::release() >+{ >+ LOG(WebGPU, "GPUDrawable::release()"); >+ m_metal = nil; >+} >+ >+MTLDrawable *GPUDrawable::metal() const >+{ >+ return m_metal.get(); >+} >+ >+MTLTexture *GPUDrawable::texture() const >+{ >+ if (![m_metal conformsToProtocol:@protocol(CAMetalDrawable)]) { >+ ASSERT(!m_metal); >+ return nil; >+ } >+ return [(id<CAMetalDrawable>)m_metal.get() texture]; >+} >+ >+} // namespace WebCore >+ >+#endif >diff --git a/Source/WebCore/platform/graphics/metal/GPUFunctionMetal.mm b/Source/WebCore/platform/graphics/metal/GPUFunctionMetal.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..08232099af658e994faa9c81580798d237f3724a >--- /dev/null >+++ b/Source/WebCore/platform/graphics/metal/GPUFunctionMetal.mm >@@ -0,0 +1,59 @@ >+/* >+ * Copyright (C) 2017 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#import "config.h" >+#import "GPUFunction.h" >+ >+#if ENABLE(WEBGPU) >+ >+#import "GPULibrary.h" >+#import "Logging.h" >+#import <Metal/Metal.h> >+#import <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+GPUFunction::GPUFunction(const GPULibrary& library, const String& name) >+ : m_metal { adoptNS([library.metal() newFunctionWithName:name]) } >+{ >+ LOG(WebGPU, "GPUFunction::GPUFunction()"); >+} >+ >+String GPUFunction::name() const >+{ >+ if (!m_metal) >+ return emptyString(); >+ >+ return [m_metal name]; >+} >+ >+bool GPUFunction::operator!() const >+{ >+ return !m_metal; >+} >+ >+} // namespace WebCore >+ >+#endif >diff --git a/Source/WebCore/platform/graphics/metal/GPULibraryMetal.mm b/Source/WebCore/platform/graphics/metal/GPULibraryMetal.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..8ae887af2860e93a9ef0c7682efadefcb094bb76 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/metal/GPULibraryMetal.mm >@@ -0,0 +1,78 @@ >+/* >+ * Copyright (C) 2017 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#import "config.h" >+#import "GPULibrary.h" >+ >+#if ENABLE(WEBGPU) >+ >+#import "GPUDevice.h" >+#import "Logging.h" >+#import <Metal/Metal.h> >+#import <wtf/Vector.h> >+#import <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+GPULibrary::GPULibrary(const GPUDevice& device, const String& sourceCode) >+{ >+ LOG(WebGPU, "GPULibrary::GPULibrary()"); >+ >+ if (!device.metal()) >+ return; >+ >+ NSError *error = [NSError errorWithDomain:@"com.apple.WebKit.GPU" code:1 userInfo:nil]; >+ m_metal = adoptNS([device.metal() newLibraryWithSource:sourceCode options:nil error:&error]); >+ if (!m_metal) >+ LOG(WebGPU, "Compilation error: %s", [[error localizedDescription] UTF8String]); >+} >+ >+String GPULibrary::label() const >+{ >+ if (!m_metal) >+ return emptyString(); >+ >+ return [m_metal label]; >+} >+ >+void GPULibrary::setLabel(const String& label) const >+{ >+ ASSERT(m_metal); >+ [m_metal setLabel:label]; >+} >+ >+Vector<String> GPULibrary::functionNames() const >+{ >+ auto array = [m_metal functionNames]; >+ Vector<String> vector; >+ vector.reserveInitialCapacity(array.count); >+ for (NSString *string in array) >+ vector.uncheckedAppend(string); >+ return vector; >+} >+ >+} // namespace WebCore >+ >+#endif >diff --git a/Source/WebCore/platform/graphics/metal/GPURenderCommandEncoderMetal.mm b/Source/WebCore/platform/graphics/metal/GPURenderCommandEncoderMetal.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..c1e62b3e17a6f21c747633b498799aa62f85c3dc >--- /dev/null >+++ b/Source/WebCore/platform/graphics/metal/GPURenderCommandEncoderMetal.mm >@@ -0,0 +1,99 @@ >+/* >+ * Copyright (C) 2017 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#import "config.h" >+#import "GPURenderCommandEncoder.h" >+ >+#if ENABLE(WEBGPU) >+ >+#import "GPUBuffer.h" >+#import "GPUCommandBuffer.h" >+#import "GPUDepthStencilState.h" >+#import "GPURenderPassDescriptor.h" >+#import "GPURenderPipelineState.h" >+#import "Logging.h" >+#import <Metal/Metal.h> >+ >+namespace WebCore { >+ >+GPURenderCommandEncoder::GPURenderCommandEncoder(const GPUCommandBuffer& buffer, const GPURenderPassDescriptor& descriptor) >+{ >+ LOG(WebGPU, "GPURenderCommandEncoder::GPURenderCommandEncoder()"); >+ >+ if (!descriptor.metal()) >+ return; >+ >+ m_metal = [buffer.metal() renderCommandEncoderWithDescriptor:descriptor.metal()]; >+} >+ >+void GPURenderCommandEncoder::setRenderPipelineState(const GPURenderPipelineState& renderPipelineState) const >+{ >+ if (!renderPipelineState.metal()) >+ return; >+ >+ [m_metal setRenderPipelineState:renderPipelineState.metal()]; >+} >+ >+void GPURenderCommandEncoder::setDepthStencilState(const GPUDepthStencilState& depthStencilState) const >+{ >+ if (!depthStencilState.metal()) >+ return; >+ >+ [m_metal setDepthStencilState:depthStencilState.metal()]; >+} >+ >+void GPURenderCommandEncoder::setVertexBuffer(const GPUBuffer& buffer, unsigned offset, unsigned index) const >+{ >+ if (!buffer.metal()) >+ return; >+ >+ [m_metal setVertexBuffer:buffer.metal() offset:offset atIndex:index]; >+} >+ >+void GPURenderCommandEncoder::setFragmentBuffer(const GPUBuffer& buffer, unsigned offset, unsigned index) const >+{ >+ if (!buffer.metal()) >+ return; >+ >+ [m_metal setFragmentBuffer:buffer.metal() offset:offset atIndex:index]; >+} >+ >+void GPURenderCommandEncoder::drawPrimitives(unsigned type, unsigned start, unsigned count) const >+{ >+ // FIXME: Why do we need a specially optimized path for count of 0? >+ if (!count) >+ return; >+ >+ [m_metal drawPrimitives:static_cast<MTLPrimitiveType>(type) vertexStart:start vertexCount:count]; >+} >+ >+void GPURenderCommandEncoder::endEncoding() const >+{ >+ [m_metal endEncoding]; >+} >+ >+} // namespace WebCore >+ >+#endif >diff --git a/Source/WebCore/platform/graphics/metal/GPURenderPassAttachmentDescriptorMetal.mm b/Source/WebCore/platform/graphics/metal/GPURenderPassAttachmentDescriptorMetal.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..730e70f37865eca44e85fa0fb5bc491b00e6f270 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/metal/GPURenderPassAttachmentDescriptorMetal.mm >@@ -0,0 +1,78 @@ >+/* >+ * Copyright (C) 2017 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#import "config.h" >+#import "GPURenderPassAttachmentDescriptor.h" >+ >+#if ENABLE(WEBGPU) >+ >+#import "GPUTexture.h" >+#import "Logging.h" >+ >+#import <Metal/Metal.h> >+ >+namespace WebCore { >+ >+GPURenderPassAttachmentDescriptor::GPURenderPassAttachmentDescriptor(MTLRenderPassAttachmentDescriptor *metal) >+ : m_metal { metal } >+{ >+ LOG(WebGPU, "GPURenderPassAttachmentDescriptor::GPURenderPassAttachmentDescriptor()"); >+} >+ >+unsigned GPURenderPassAttachmentDescriptor::loadAction() const >+{ >+ return [m_metal loadAction]; >+} >+ >+void GPURenderPassAttachmentDescriptor::setLoadAction(unsigned newLoadAction) const >+{ >+ // FIXME: Should this range check for legitimate values? >+ [m_metal setLoadAction:static_cast<MTLLoadAction>(newLoadAction)]; >+} >+ >+unsigned GPURenderPassAttachmentDescriptor::storeAction() const >+{ >+ return [m_metal storeAction]; >+} >+ >+void GPURenderPassAttachmentDescriptor::setStoreAction(unsigned newStoreAction) const >+{ >+ // FIXME: Should this range check for legitimate values? >+ [m_metal setStoreAction:static_cast<MTLStoreAction>(newStoreAction)]; >+} >+ >+void GPURenderPassAttachmentDescriptor::setTexture(const GPUTexture& texture) const >+{ >+ [m_metal setTexture:texture.metal()]; >+} >+ >+MTLRenderPassAttachmentDescriptor *GPURenderPassAttachmentDescriptor::metal() const >+{ >+ return m_metal.get(); >+} >+ >+} // namespace WebCore >+ >+#endif >diff --git a/Source/WebCore/platform/graphics/metal/GPURenderPassColorAttachmentDescriptorMetal.mm b/Source/WebCore/platform/graphics/metal/GPURenderPassColorAttachmentDescriptorMetal.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..1f5a36953249a26376a5ba58f0ecb288166aaa04 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/metal/GPURenderPassColorAttachmentDescriptorMetal.mm >@@ -0,0 +1,69 @@ >+/* >+ * Copyright (C) 2017 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#import "config.h" >+#import "GPURenderPassColorAttachmentDescriptor.h" >+ >+#if ENABLE(WEBGPU) >+ >+#import "FloatConversion.h" >+#import "Logging.h" >+#import <Metal/Metal.h> >+#import <wtf/Vector.h> >+ >+namespace WebCore { >+ >+GPURenderPassColorAttachmentDescriptor::GPURenderPassColorAttachmentDescriptor(MTLRenderPassColorAttachmentDescriptor *metal) >+ : GPURenderPassAttachmentDescriptor { metal } >+{ >+ LOG(WebGPU, "GPURenderPassColorAttachmentDescriptor::GPURenderPassColorAttachmentDescriptor()"); >+} >+ >+Vector<float> GPURenderPassColorAttachmentDescriptor::clearColor() const >+{ >+ auto* metal = this->metal(); >+ if (!metal) >+ return { }; >+ >+ auto color = [metal clearColor]; >+ return { narrowPrecisionToFloat(color.red), narrowPrecisionToFloat(color.green), narrowPrecisionToFloat(color.blue), narrowPrecisionToFloat(color.alpha) }; >+} >+ >+void GPURenderPassColorAttachmentDescriptor::setClearColor(const Vector<float>& newClearColor) const >+{ >+ if (newClearColor.size() != 4) >+ return; >+ >+ [metal() setClearColor:MTLClearColorMake(newClearColor[0], newClearColor[1], newClearColor[2], newClearColor[3])]; >+} >+ >+MTLRenderPassColorAttachmentDescriptor *GPURenderPassColorAttachmentDescriptor::metal() const >+{ >+ return static_cast<MTLRenderPassColorAttachmentDescriptor *>(GPURenderPassAttachmentDescriptor::metal()); >+} >+ >+} // namespace WebCore >+ >+#endif >diff --git a/Source/WebCore/platform/graphics/metal/GPURenderPassDepthAttachmentDescriptorMetal.mm b/Source/WebCore/platform/graphics/metal/GPURenderPassDepthAttachmentDescriptorMetal.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..3765b1a2a949d612a83c0e09fa5ff0ff75a8a785 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/metal/GPURenderPassDepthAttachmentDescriptorMetal.mm >@@ -0,0 +1,64 @@ >+/* >+ * Copyright (C) 2017 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#import "config.h" >+#import "GPURenderPassDepthAttachmentDescriptor.h" >+ >+#if ENABLE(WEBGPU) >+ >+#import "GPURenderPassAttachmentDescriptor.h" >+#import "Logging.h" >+#import <Metal/Metal.h> >+ >+namespace WebCore { >+ >+GPURenderPassDepthAttachmentDescriptor::GPURenderPassDepthAttachmentDescriptor(MTLRenderPassDepthAttachmentDescriptor *metal) >+ : GPURenderPassAttachmentDescriptor { metal } >+{ >+ LOG(WebGPU, "GPURenderPassDepthAttachmentDescriptor::GPURenderPassDepthAttachmentDescriptor()"); >+} >+ >+double GPURenderPassDepthAttachmentDescriptor::clearDepth() const >+{ >+ auto* metal = this->metal(); >+ if (!metal) >+ return 0; >+ >+ return [metal clearDepth]; >+} >+ >+void GPURenderPassDepthAttachmentDescriptor::setClearDepth(double newClearDepth) const >+{ >+ [metal() setClearDepth:newClearDepth]; >+} >+ >+MTLRenderPassDepthAttachmentDescriptor *GPURenderPassDepthAttachmentDescriptor::metal() const >+{ >+ return static_cast<MTLRenderPassDepthAttachmentDescriptor *>(GPURenderPassAttachmentDescriptor::metal()); >+} >+ >+} // namespace WebCore >+ >+#endif >diff --git a/Source/WebCore/platform/graphics/metal/GPURenderPassDescriptorMetal.mm b/Source/WebCore/platform/graphics/metal/GPURenderPassDescriptorMetal.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..33566acfae5367f3197c793ffaae361d39b9d854 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/metal/GPURenderPassDescriptorMetal.mm >@@ -0,0 +1,65 @@ >+/* >+ * Copyright (C) 2017 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#import "config.h" >+#import "GPURenderPassDescriptor.h" >+ >+#if ENABLE(WEBGPU) >+ >+#import "GPURenderPassColorAttachmentDescriptor.h" >+#import "GPURenderPassDepthAttachmentDescriptor.h" >+#import "Logging.h" >+#import <Metal/Metal.h> >+ >+namespace WebCore { >+ >+GPURenderPassDescriptor::GPURenderPassDescriptor() >+ : m_metal { adoptNS([MTLRenderPassDescriptor new]) } >+{ >+ LOG(WebGPU, "GPURenderPassDescriptor::GPURenderPassDescriptor()"); >+} >+ >+Vector<GPURenderPassColorAttachmentDescriptor> GPURenderPassDescriptor::colorAttachments() const >+{ >+ if (!m_metal) >+ return { }; >+ >+ // FIXME: Why is it correct to return one color here? >+ return { { [[m_metal colorAttachments] objectAtIndexedSubscript:0] } }; >+} >+ >+GPURenderPassDepthAttachmentDescriptor GPURenderPassDescriptor::depthAttachment() const >+{ >+ return [m_metal depthAttachment]; >+} >+ >+MTLRenderPassDescriptor *GPURenderPassDescriptor::metal() const >+{ >+ return m_metal.get(); >+} >+ >+} // namespace WebCore >+ >+#endif >diff --git a/Source/WebCore/platform/graphics/metal/GPURenderPipelineColorAttachmentDescriptorMetal.mm b/Source/WebCore/platform/graphics/metal/GPURenderPipelineColorAttachmentDescriptorMetal.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..db8e52d6fc971ef7f2524382dfe7f6676480f17f >--- /dev/null >+++ b/Source/WebCore/platform/graphics/metal/GPURenderPipelineColorAttachmentDescriptorMetal.mm >@@ -0,0 +1,60 @@ >+/* >+ * Copyright (C) 2017 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#import "config.h" >+#import "GPURenderPipelineColorAttachmentDescriptor.h" >+ >+#if ENABLE(WEBGPU) >+ >+#import "Logging.h" >+#import <Metal/Metal.h> >+ >+namespace WebCore { >+ >+GPURenderPipelineColorAttachmentDescriptor::GPURenderPipelineColorAttachmentDescriptor(MTLRenderPipelineColorAttachmentDescriptor *metal) >+ : m_metal { metal } >+{ >+ LOG(WebGPU, "GPURenderPipelineColorAttachmentDescriptor::GPURenderPipelineColorAttachmentDescriptor()"); >+} >+ >+unsigned GPURenderPipelineColorAttachmentDescriptor::pixelFormat() const >+{ >+ return [m_metal pixelFormat]; >+} >+ >+void GPURenderPipelineColorAttachmentDescriptor::setPixelFormat(unsigned newPixelFormat) const >+{ >+ // FIXME: Should we check for enumeration values out of range before calling the method? >+ [m_metal setPixelFormat:static_cast<MTLPixelFormat>(newPixelFormat)]; >+} >+ >+MTLRenderPipelineColorAttachmentDescriptor *GPURenderPipelineColorAttachmentDescriptor::metal() const >+{ >+ return m_metal.get(); >+} >+ >+} // namespace WebCore >+ >+#endif >diff --git a/Source/WebCore/platform/graphics/metal/GPURenderPipelineDescriptorMetal.mm b/Source/WebCore/platform/graphics/metal/GPURenderPipelineDescriptorMetal.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..26333776b0a8b89c83a534da39972b170573ec61 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/metal/GPURenderPipelineDescriptorMetal.mm >@@ -0,0 +1,83 @@ >+/* >+ * Copyright (C) 2017 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#import "config.h" >+#import "GPURenderPipelineDescriptor.h" >+ >+#if ENABLE(WEBGPU) >+ >+#import "GPUFunction.h" >+#import "GPURenderPipelineColorAttachmentDescriptor.h" >+#import "Logging.h" >+#import <Metal/Metal.h> >+#import <wtf/Vector.h> >+ >+namespace WebCore { >+ >+GPURenderPipelineDescriptor::GPURenderPipelineDescriptor() >+ : m_metal { adoptNS([MTLRenderPipelineDescriptor new]) } >+{ >+ LOG(WebGPU, "GPURenderPipelineDescriptor::GPURenderPipelineDescriptor()"); >+} >+ >+unsigned GPURenderPipelineDescriptor::depthAttachmentPixelFormat() const >+{ >+ return [m_metal depthAttachmentPixelFormat]; >+} >+ >+void GPURenderPipelineDescriptor::setDepthAttachmentPixelFormat(unsigned newPixelFormat) const >+{ >+ [m_metal setDepthAttachmentPixelFormat:static_cast<MTLPixelFormat>(newPixelFormat)]; >+} >+ >+void GPURenderPipelineDescriptor::setVertexFunction(const GPUFunction& newFunction) const >+{ >+ [m_metal setVertexFunction:newFunction.metal()]; >+} >+ >+void GPURenderPipelineDescriptor::setFragmentFunction(const GPUFunction& newFunction) const >+{ >+ [m_metal setFragmentFunction:newFunction.metal()]; >+} >+ >+Vector<GPURenderPipelineColorAttachmentDescriptor> GPURenderPipelineDescriptor::colorAttachments() const >+{ >+ // FIXME: Why is it always OK to return exactly one attachment? >+ return { { [[m_metal colorAttachments] objectAtIndexedSubscript:0] } }; >+} >+ >+void GPURenderPipelineDescriptor::reset() const >+{ >+ [m_metal reset]; >+} >+ >+MTLRenderPipelineDescriptor *GPURenderPipelineDescriptor::metal() const >+{ >+ return m_metal.get(); >+} >+ >+} // namespace WebCore >+ >+#endif >diff --git a/Source/WebCore/platform/graphics/metal/GPURenderPipelineStateMetal.mm b/Source/WebCore/platform/graphics/metal/GPURenderPipelineStateMetal.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..ee7798683c2ca1f7c7a2371046c45f38f54d2fd1 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/metal/GPURenderPipelineStateMetal.mm >@@ -0,0 +1,66 @@ >+/* >+ * Copyright (C) 2017 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#import "config.h" >+#import "GPURenderPipelineState.h" >+ >+#if ENABLE(WEBGPU) >+ >+#import "GPUDevice.h" >+#import "GPURenderPipelineDescriptor.h" >+#import "Logging.h" >+#import <Metal/Metal.h> >+#import <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+GPURenderPipelineState::GPURenderPipelineState(const GPUDevice& device, const GPURenderPipelineDescriptor& descriptor) >+ : m_metal { adoptNS([device.metal() newRenderPipelineStateWithDescriptor:descriptor.metal() error:nil]) } >+{ >+ LOG(WebGPU, "GPURenderPipelineState::GPURenderPipelineState()"); >+} >+ >+String GPURenderPipelineState::label() const >+{ >+ if (!m_metal) >+ return emptyString(); >+ return [m_metal label]; >+} >+ >+void GPURenderPipelineState::setLabel(const String&) const >+{ >+ // FIXME: The MTLRenderPipelineState protocol does not allow setting the label. >+ // The label has to be set on the descriptor when creating the state object. >+ // We should consider changing the WebGPU interface to not require this! >+} >+ >+MTLRenderPipelineState *GPURenderPipelineState::metal() const >+{ >+ return m_metal.get(); >+} >+ >+} // namespace WebCore >+ >+#endif >diff --git a/Source/WebCore/platform/graphics/metal/GPUTextureDescriptorMetal.mm b/Source/WebCore/platform/graphics/metal/GPUTextureDescriptorMetal.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..732806f7425244c9e4af6b527b748811d003fb9f >--- /dev/null >+++ b/Source/WebCore/platform/graphics/metal/GPUTextureDescriptorMetal.mm >@@ -0,0 +1,114 @@ >+/* >+ * Copyright (C) 2017 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#import "config.h" >+#import "GPUTextureDescriptor.h" >+ >+#if ENABLE(WEBGPU) >+ >+#import "Logging.h" >+#import <Metal/Metal.h> >+ >+namespace WebCore { >+ >+GPUTextureDescriptor::GPUTextureDescriptor(unsigned pixelFormat, unsigned width, unsigned height, bool mipmapped) >+ : m_metal { [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:static_cast<MTLPixelFormat>(pixelFormat) width:width height:height mipmapped:mipmapped] } >+{ >+ LOG(WebGPU, "GPUTextureDescriptor::GPUTextureDescriptor()"); >+} >+ >+unsigned GPUTextureDescriptor::width() const >+{ >+ return [m_metal width]; >+} >+ >+void GPUTextureDescriptor::setWidth(unsigned newWidth) const >+{ >+ ASSERT(m_metal); >+ [m_metal setWidth:newWidth]; >+} >+ >+unsigned GPUTextureDescriptor::height() const >+{ >+ return [m_metal height]; >+} >+ >+void GPUTextureDescriptor::setHeight(unsigned newHeight) const >+{ >+ ASSERT(m_metal); >+ [m_metal setHeight:newHeight]; >+} >+ >+unsigned GPUTextureDescriptor::sampleCount() const >+{ >+ return [m_metal sampleCount]; >+} >+ >+void GPUTextureDescriptor::setSampleCount(unsigned newSampleCount) const >+{ >+ ASSERT(m_metal); >+ [m_metal setSampleCount:newSampleCount]; >+} >+ >+unsigned GPUTextureDescriptor::textureType() const >+{ >+ return [m_metal textureType]; >+} >+ >+void GPUTextureDescriptor::setTextureType(unsigned newTextureType) const >+{ >+ ASSERT(m_metal); >+ [m_metal setTextureType:static_cast<MTLTextureType>(newTextureType)]; >+} >+ >+unsigned GPUTextureDescriptor::storageMode() const >+{ >+ return [m_metal storageMode]; >+} >+ >+void GPUTextureDescriptor::setStorageMode(unsigned newStorageMode) const >+{ >+ [m_metal setStorageMode:static_cast<MTLStorageMode>(newStorageMode)]; >+} >+ >+unsigned GPUTextureDescriptor::usage() const >+{ >+ return [m_metal usage]; >+} >+ >+void GPUTextureDescriptor::setUsage(unsigned newUsage) const >+{ >+ ASSERT(m_metal); >+ [m_metal setUsage:newUsage]; >+} >+ >+MTLTextureDescriptor *GPUTextureDescriptor::metal() const >+{ >+ return m_metal.get(); >+} >+ >+} // namespace WebCore >+ >+#endif >diff --git a/Source/WebCore/platform/graphics/metal/GPUTextureMetal.mm b/Source/WebCore/platform/graphics/metal/GPUTextureMetal.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..1107fc3bc2d1c7d8197904369849322581362270 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/metal/GPUTextureMetal.mm >@@ -0,0 +1,72 @@ >+/* >+ * Copyright (C) 2017 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#import "config.h" >+#import "GPUTexture.h" >+ >+#if ENABLE(WEBGPU) >+ >+#import "GPUDevice.h" >+#import "GPUDrawable.h" >+#import "GPUTextureDescriptor.h" >+#import "Logging.h" >+#import <Metal/Metal.h> >+ >+namespace WebCore { >+ >+GPUTexture::GPUTexture(const GPUDevice& device, const GPUTextureDescriptor& descriptor) >+{ >+ LOG(WebGPU, "GPUTexture::GPUTexture()"); >+ >+ if (!descriptor.metal()) >+ return; >+ >+ m_metal = adoptNS([device.metal() newTextureWithDescriptor:descriptor.metal()]); >+} >+ >+GPUTexture::GPUTexture(const GPUDrawable& other) >+ : m_metal { other.texture() } >+{ >+ LOG(WebGPU, "GPUTexture::GPUTexture()"); >+} >+ >+unsigned GPUTexture::width() const >+{ >+ return m_metal.get().width; >+} >+ >+unsigned GPUTexture::height() const >+{ >+ return m_metal.get().height; >+} >+ >+MTLTexture *GPUTexture::metal() const >+{ >+ return m_metal.get(); >+} >+ >+} // namespace WebCore >+ >+#endif >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 1db6131902bc6228836d892e837fd76fb4c0c918..ab398e36d03c0c1d9ad29bd8d19cc706ad778674 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,16 @@ >+2018-07-04 Darin Adler <darin@apple.com> >+ >+ Improve WebGPU implementation, including using Metal Objective-C protocols more simply and correctly >+ https://bugs.webkit.org/show_bug.cgi?id=187333 >+ >+ Reviewed by Sam Weinig. >+ >+ * TestWebKitAPI/Tests/WebCore/mac/GPUBuffer.mm: Updated. >+ * TestWebKitAPI/Tests/WebCore/mac/GPUCommandQueue.mm: Updated. >+ * TestWebKitAPI/Tests/WebCore/mac/GPUDevice.mm: Updated. >+ * TestWebKitAPI/Tests/WebCore/mac/GPUFunction.mm: Updated. >+ * TestWebKitAPI/Tests/WebCore/mac/GPULibrary.mm: Updated. >+ > 2018-07-25 Aakash Jain <aakash_jain@apple.com> > > [ews-build] Add build steps DownloadBuiltProduct and ExtractBuiltProduct >diff --git a/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUBuffer.mm b/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUBuffer.mm >index 5ef1ba5dc61567acef323fdd1acf37f9433ccab3..7fe3eb6b872331ddbe43b91ab7c5298277671384 100644 >--- a/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUBuffer.mm >+++ b/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUBuffer.mm >@@ -44,39 +44,35 @@ namespace TestWebKitAPI { > > TEST_F(GPU, BufferCreate) > { >- auto device = GPUDevice::create(); >+ GPUDevice device; >+ > // Not all hardware supports Metal, so it is possible > // that we were unable to create the MTLDevice object. > // In that case, the device should be null. > if (!device) > return; > >- id<MTLDevice> mtlDevice = (id<MTLDevice>)device->platformDevice(); >- EXPECT_NOT_NULL(mtlDevice); >+ EXPECT_NOT_NULL(device.metal()); > > auto bufferView = JSC::Uint8Array::create(1024); > >- uint8_t* data = bufferView->data(); >+ auto data = bufferView->data(); > memset(data, 1, bufferView->byteLength()); > >- auto buffer = device->createBufferFromData(bufferView.get()); >- EXPECT_NOT_NULL(buffer); >- EXPECT_EQ(buffer->length(), static_cast<unsigned long>(1024)); >+ GPUBuffer buffer { device, *bufferView }; >+ EXPECT_EQ(1024U, buffer.length()); > >- auto contents = buffer->contents(); >+ auto contents = buffer.contents(); > EXPECT_NOT_NULL(contents); >- EXPECT_EQ(contents->byteLength(), static_cast<unsigned long>(1024)); >- >- uint8_t* contentsData = static_cast<uint8_t*>(contents->data()); >- EXPECT_NE(contentsData, data); >- EXPECT_EQ(contentsData[0], 1); >- EXPECT_EQ(contentsData[512], 1); >- EXPECT_EQ(contentsData[1023], 1); >- >- MTLBuffer *mtlBuffer = buffer->platformBuffer(); >- EXPECT_NOT_NULL(mtlBuffer); >+ EXPECT_EQ(1024U, contents->byteLength()); > >+ auto contentsData = static_cast<uint8_t*>(contents->data()); >+ EXPECT_NE(data, contentsData); >+ EXPECT_EQ(1U, contentsData[0]); >+ EXPECT_EQ(1U, contentsData[512]); >+ EXPECT_EQ(1U, contentsData[1023]); > >+ EXPECT_NOT_NULL(buffer.metal()); > } > > } // namespace TestWebKitAPI >diff --git a/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUCommandQueue.mm b/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUCommandQueue.mm >index 156d8fb7ed3db037d5c4ff06cb34daa40c5d58b8..507b87e5b4e4264c23a90ec65a1064bfe7ac0f5f 100644 >--- a/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUCommandQueue.mm >+++ b/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUCommandQueue.mm >@@ -39,31 +39,29 @@ namespace TestWebKitAPI { > > TEST_F(GPU, CommandQueueCreate) > { >- auto device = GPUDevice::create(); >+ GPUDevice device; >+ > // Not all hardware supports Metal, so it is possible > // that we were unable to create the MTLDevice object. > // In that case, the device should be null. > if (!device) > return; > >- auto commandQueue = device->createCommandQueue(); >- EXPECT_NOT_NULL(commandQueue); >- EXPECT_WK_STREQ(commandQueue->label(), emptyString()); >+ GPUCommandQueue commandQueue { device }; >+ EXPECT_WK_STREQ("", commandQueue.label()); > >- id<MTLCommandQueue> mtlCommandQueue = (id<MTLCommandQueue>)commandQueue->platformCommandQueue(); >- EXPECT_NOT_NULL(mtlCommandQueue); >+ EXPECT_NOT_NULL(commandQueue.metal()); > > // If you haven't set a label, we just use the prefix. >- EXPECT_STREQ("com.apple.WebKit", [mtlCommandQueue.label UTF8String]); >+ EXPECT_STREQ("com.apple.WebKit", commandQueue.metal().label.UTF8String); > >- String testLabel("this.is.a.test"_s); >- commandQueue->setLabel(testLabel); >+ commandQueue.setLabel("this.is.a.test"_s); > > // The WebKit API doesn't prefix. >- EXPECT_WK_STREQ(commandQueue->label(), testLabel); >+ EXPECT_WK_STREQ("this.is.a.test", commandQueue.label()); > > // But the underlying Metal object label will have one. >- EXPECT_STREQ("com.apple.WebKit.this.is.a.test", [mtlCommandQueue.label UTF8String]); >+ EXPECT_STREQ("com.apple.WebKit.this.is.a.test", commandQueue.metal().label.UTF8String); > } > > } // namespace TestWebKitAPI >diff --git a/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUDevice.mm b/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUDevice.mm >index 276a7cbdd2d1200d14275d7f78ac4f6a3875d770..6a61f0d20c2fea580ebf79899b35055a706ac941 100644 >--- a/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUDevice.mm >+++ b/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUDevice.mm >@@ -37,21 +37,18 @@ namespace TestWebKitAPI { > > TEST_F(GPU, DeviceCreate) > { >- auto device = GPUDevice::create(); >+ GPUDevice device; >+ > // Not all hardware supports Metal, so it is possible > // that we were unable to create the MTLDevice object. > // In that case, the device should be null. > if (!device) > return; > >- EXPECT_NOT_NULL(device->layer()); >- EXPECT_NOT_NULL(device->platformLayer()); >- >- id<MTLDevice> mtlDevice = (id<MTLDevice>)device->platformDevice(); >- EXPECT_NOT_NULL(mtlDevice); >- >- NSString *deviceName = mtlDevice.name; >- EXPECT_GT(deviceName.length, static_cast<unsigned long>(0)); >+ EXPECT_NOT_NULL(device.layer()); >+ EXPECT_NOT_NULL(device.platformLayer()); >+ EXPECT_NOT_NULL(device.metal()); >+ EXPECT_LT(0U, device.metal().name.length); > } > > } // namespace TestWebKitAPI >diff --git a/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUFunction.mm b/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUFunction.mm >index adef73eacdafdc1f792d63ea0493b30192b31746..3f95af2f6cd9df7d10fd3a6e086d9b08695fff2a 100644 >--- a/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUFunction.mm >+++ b/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUFunction.mm >@@ -29,6 +29,7 @@ > #if ENABLE(WEBGPU) > > #import "GPUTest.h" >+#import "PlatformUtilities.h" > #import <Metal/Metal.h> > #import <WebCore/GPUDevice.h> > #import <WebCore/GPUFunction.h> >@@ -40,29 +41,28 @@ namespace TestWebKitAPI { > > TEST_F(GPU, FunctionAccessByName) > { >- auto device = GPUDevice::create(); >+ GPUDevice device; >+ > // Not all hardware supports Metal, so it is possible > // that we were unable to create the MTLDevice object. > // In that case, the device should be null. > if (!device) > return; > >- id<MTLDevice> mtlDevice = (id<MTLDevice>)device->platformDevice(); >- EXPECT_NOT_NULL(mtlDevice); >+ EXPECT_NOT_NULL(device.metal()); > >- auto library = device->createLibrary(librarySourceCode()); >- EXPECT_NOT_NULL(library); >+ GPULibrary library { device, librarySourceCode() }; > >- auto vertexFunction = library->functionWithName("vertex_main"); >- EXPECT_NOT_NULL(vertexFunction); >- EXPECT_EQ("vertex_main", vertexFunction->name()); >+ GPUFunction vertexFunction { library, "vertex_main"_s }; >+ EXPECT_NOT_NULL(vertexFunction.metal()); >+ EXPECT_WK_STREQ("vertex_main", vertexFunction.name()); > >- auto fragmentFunction = library->functionWithName("fragment_main"); >- EXPECT_NOT_NULL(fragmentFunction); >- EXPECT_EQ("fragment_main", fragmentFunction->name()); >+ GPUFunction fragmentFunction { library, "fragment_main"_s }; >+ EXPECT_NOT_NULL(fragmentFunction.metal()); >+ EXPECT_WK_STREQ("fragment_main", fragmentFunction.name()); > >- auto nonExistentFunction = library->functionWithName("name_that_is_not_in_library"); >- EXPECT_NULL(nonExistentFunction); >+ GPUFunction nonexistentFunction { library, "name_that_is_not_in_library"_s }; >+ EXPECT_NULL(nonexistentFunction.metal()); > } > > } // namespace TestWebKitAPI >diff --git a/Tools/TestWebKitAPI/Tests/WebCore/mac/GPULibrary.mm b/Tools/TestWebKitAPI/Tests/WebCore/mac/GPULibrary.mm >index b5c0271f579bb0a1f1868b309e40b67801773ed1..bd129295f2052d142c5b8d1865d24a682ba51997 100644 >--- a/Tools/TestWebKitAPI/Tests/WebCore/mac/GPULibrary.mm >+++ b/Tools/TestWebKitAPI/Tests/WebCore/mac/GPULibrary.mm >@@ -28,6 +28,7 @@ > #if ENABLE(WEBGPU) > > #import "GPUTest.h" >+#import "PlatformUtilities.h" > #import <Metal/Metal.h> > #import <WebCore/GPUDevice.h> > #import <WebCore/GPULibrary.h> >@@ -38,46 +39,46 @@ namespace TestWebKitAPI { > > TEST_F(GPU, LibraryCreate) > { >- auto device = GPUDevice::create(); >+ GPUDevice device; >+ > // Not all hardware supports Metal, so it is possible > // that we were unable to create the MTLDevice object. > // In that case, the device should be null. > if (!device) > return; > >- id<MTLDevice> mtlDevice = (id<MTLDevice>)device->platformDevice(); >- EXPECT_NOT_NULL(mtlDevice); >+ EXPECT_NOT_NULL(device.metal()); > >- auto library = device->createLibrary(librarySourceCode()); >- EXPECT_NOT_NULL(library); >+ GPULibrary library { device, librarySourceCode() }; >+ EXPECT_NOT_NULL(library.metal()); > } > > TEST_F(GPU, LibrarySetLabel) > { >- auto device = GPUDevice::create(); >+ GPUDevice device; > if (!device) > return; > >- auto library = device->createLibrary(librarySourceCode()); >- EXPECT_NOT_NULL(library); >+ GPULibrary library { device, librarySourceCode() }; >+ EXPECT_NOT_NULL(library.metal()); > >- library->setLabel("TestLabel"); >- EXPECT_EQ("TestLabel", library->label()); >+ library.setLabel("TestLabel"_s); >+ EXPECT_EQ("TestLabel", library.label()); > } > > TEST_F(GPU, LibraryFunctionNames) > { >- auto device = GPUDevice::create(); >+ GPUDevice device; > if (!device) > return; > >- auto library = device->createLibrary(librarySourceCode()); >- EXPECT_NOT_NULL(library); >+ GPULibrary library { device, librarySourceCode() }; >+ EXPECT_NOT_NULL(library.metal()); > >- auto functionNames = library->functionNames(); >- EXPECT_EQ(functionNames.size(), static_cast<unsigned long>(2)); >- EXPECT_EQ("vertex_main", functionNames[0]); >- EXPECT_EQ("fragment_main", functionNames[1]); >+ auto functionNames = library.functionNames(); >+ EXPECT_EQ(2U, functionNames.size()); >+ EXPECT_WK_STREQ("vertex_main", functionNames[0]); >+ EXPECT_WK_STREQ("fragment_main", functionNames[1]); > } > > } // namespace TestWebKitAPI
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
ews-watchlist
:
commit-queue-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 187333
:
344304
|
344305
|
344306
|
344307
|
345020
|
345021
|
345025
|
345029
|
345745
|
345817
|
345823
|
345824
|
345825