Changeset 238741 in webkit


Ignore:
Timestamp:
Nov 30, 2018 10:14:52 AM (5 years ago)
Author:
Justin Fan
Message:

[WebGPU] Flesh out WebGPURenderPassDescriptor to match the WebGPU IDL
https://bugs.webkit.org/show_bug.cgi?id=192213

Reviewed by Dean Jackson.

Source/WebCore:

WebGPU prototype now uses WebGPURenderPassColorAttachmentDescriptor in WebGPURenderPassDescriptor to match the WebGPU Sketch.
WebGPU developer can now also set the clearColor in WebGPURenderPassDescriptor.

No new tests. Older WebGPURenderPass* tests updated.

  • CMakeLists.txt:
  • DerivedSources.make:
  • Modules/webgpu/WebGPUColor.h: Added. Typedef'd to GPUColor.h.
  • Modules/webgpu/WebGPUColor.idl: Added.
  • Modules/webgpu/WebGPUCommandBuffer.cpp:

(WebCore::WebGPUCommandBuffer::beginRenderPass): Updated to error check and support the new structure of WebGPURenderPassDescriptor.

  • Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.h: Added.
  • Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.idl: Added.
  • Modules/webgpu/WebGPURenderPassDescriptor.h:
  • Modules/webgpu/WebGPURenderPassDescriptor.idl: Updated to match the sketch IDL.
  • Sources.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • platform/graphics/gpu/GPUColor.h: Added.
  • platform/graphics/gpu/GPURenderPassColorAttachmentDescriptor.h: Added. Backing struct for WebGPU.
  • platform/graphics/gpu/GPURenderPassDescriptor.h: Updated to match new WebGPURenderPassDescriptor.
  • platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm:

(WebCore::GPURenderPassEncoder::create): Now also uses clearColor set by developer.

LayoutTests:

Updating some tests to match the updated WebGPURenderPassDescriptor.

  • webgpu/js/basic-webgpu-functions.js:

(render):

  • webgpu/render-command-encoding.html:
  • webgpu/render-passes.html:
Location:
trunk
Files:
16 edited
6 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r238737 r238741  
     12018-11-30  Justin Fan  <justin_fan@apple.com>
     2
     3        [WebGPU] Flesh out WebGPURenderPassDescriptor to match the WebGPU IDL
     4        https://bugs.webkit.org/show_bug.cgi?id=192213
     5
     6        Reviewed by Dean Jackson.
     7
     8        Updating some tests to match the updated WebGPURenderPassDescriptor.
     9
     10        * webgpu/js/basic-webgpu-functions.js:
     11        (render):
     12        * webgpu/render-command-encoding.html:
     13        * webgpu/render-passes.html:
     14
    1152018-11-30  Zalan Bujtas  <zalan@apple.com>
    216
  • trunk/LayoutTests/webgpu/js/basic-webgpu-functions.js

    r238687 r238741  
    138138    }
    139139
    140     // FIXME: Flesh out the rest of WebGPURenderPassDescriptor.
    141     // Default a loadOp, storeOp, and clearColor in the implementation for now.
     140    // FIXME: Default a loadOp, and storeOp in the implementation for now.
     141    const colorAttachmentDescriptor = {
     142        attachment : textureView,
     143        clearColor : { r:0.35, g:0.65, b:0.85, a:1.0 }
     144    }
     145
    142146    let renderPassDescriptor = {
    143         attachment : textureView
     147        colorAttachments : [colorAttachmentDescriptor]
    144148    }
    145149
  • trunk/LayoutTests/webgpu/render-command-encoding.html

    r238687 r238741  
    1313
    1414function beginPass() {
    15     // FIXME: Flesh out the rest of WebGPURenderPassDescriptor.
    16     // Default a loadOp, storeOp, and clearColor in the implementation for now.
    17     const renderPassDescriptor = {
    18         attachment : context.getNextTexture().createDefaultTextureView()
     15    // Default a loadOp, storeOp in the implementation for now.
     16    const colorAttachmentDescriptor = {
     17        attachment: context.getNextTexture().createDefaultTextureView(),
     18        clearColor: { r: 0.35, g: 0.65, b: 0.85, a: 1.0 }
     19    }
     20
     21    let renderPassDescriptor = {
     22        colorAttachments : [colorAttachmentDescriptor]
    1923    }
    2024
  • trunk/LayoutTests/webgpu/render-passes.html

    r238687 r238741  
    1111function setUpBasicRenderPassEncoder() {
    1212    commandBuffer = defaultDevice.createCommandBuffer();
    13     const texture = context.getNextTexture();
    14     const textureView = texture.createDefaultTextureView();
    1513
    16     // FIXME: Flesh out the rest of WebGPURenderPassDescriptor.
    17     // Default a loadOp, storeOp, and clearColor in the implementation for now.
    18     const renderPassDescriptor = {
    19         attachment : textureView
     14    // Default a loadOp, storeOp in the implementation for now.
     15    const colorAttachmentDescriptor = {
     16        attachment: context.getNextTexture().createDefaultTextureView(),
     17        clearColor: { r: 0.35, g: 0.65, b: 0.85, a: 1.0 }
     18    }
     19
     20    let renderPassDescriptor = {
     21        colorAttachments: [colorAttachmentDescriptor]
    2022    }
    2123
  • trunk/Source/WebCore/CMakeLists.txt

    r238629 r238741  
    459459    Modules/webgpu/WebGPUAdapter.idl
    460460    Modules/webgpu/WebGPUAdapterDescriptor.idl
     461    Modules/webgpu/WebGPUColor.idl
    461462    Modules/webgpu/WebGPUCommandBuffer.idl
    462463    Modules/webgpu/WebGPUDevice.idl
     
    465466    Modules/webgpu/WebGPUProgrammablePassEncoder.idl
    466467    Modules/webgpu/WebGPUQueue.idl
     468    Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.idl
    467469    Modules/webgpu/WebGPURenderPassDescriptor.idl
    468470    Modules/webgpu/WebGPURenderPassEncoder.idl
  • trunk/Source/WebCore/ChangeLog

    r238739 r238741  
     12018-11-30  Justin Fan  <justin_fan@apple.com>
     2
     3        [WebGPU] Flesh out WebGPURenderPassDescriptor to match the WebGPU IDL
     4        https://bugs.webkit.org/show_bug.cgi?id=192213
     5
     6        Reviewed by Dean Jackson.
     7
     8        WebGPU prototype now uses WebGPURenderPassColorAttachmentDescriptor in WebGPURenderPassDescriptor to match the WebGPU Sketch.
     9        WebGPU developer can now also set the clearColor in WebGPURenderPassDescriptor.
     10
     11        No new tests. Older WebGPURenderPass* tests updated.
     12
     13        * CMakeLists.txt:
     14        * DerivedSources.make:
     15        * Modules/webgpu/WebGPUColor.h: Added. Typedef'd to GPUColor.h.
     16        * Modules/webgpu/WebGPUColor.idl: Added.
     17        * Modules/webgpu/WebGPUCommandBuffer.cpp:
     18        (WebCore::WebGPUCommandBuffer::beginRenderPass): Updated to error check and support the new structure of WebGPURenderPassDescriptor.
     19        * Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.h: Added.
     20        * Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.idl: Added.
     21        * Modules/webgpu/WebGPURenderPassDescriptor.h:
     22        * Modules/webgpu/WebGPURenderPassDescriptor.idl: Updated to match the sketch IDL.
     23        * Sources.txt:
     24        * WebCore.xcodeproj/project.pbxproj:
     25        * platform/graphics/gpu/GPUColor.h: Added.
     26        * platform/graphics/gpu/GPURenderPassColorAttachmentDescriptor.h: Added. Backing struct for WebGPU__.
     27        * platform/graphics/gpu/GPURenderPassDescriptor.h: Updated to match new WebGPURenderPassDescriptor.
     28        * platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm:
     29        (WebCore::GPURenderPassEncoder::create): Now also uses clearColor set by developer.
     30
    1312018-11-30  Andy Estes  <aestes@apple.com>
    232
  • trunk/Source/WebCore/DerivedSources.make

    r238739 r238741  
    376376    $(WebCore)/Modules/webgpu/WebGPUAdapter.idl \
    377377    $(WebCore)/Modules/webgpu/WebGPUAdapterDescriptor.idl \
     378    $(WebCore)/Modules/webgpu/WebGPUColor.idl \
    378379    $(WebCore)/Modules/webgpu/WebGPUCommandBuffer.idl \
    379380    $(WebCore)/Modules/webgpu/WebGPUDevice.idl \
     
    382383    $(WebCore)/Modules/webgpu/WebGPUPipelineStageDescriptor.idl \
    383384    $(WebCore)/Modules/webgpu/WebGPUProgrammablePassEncoder.idl \
     385    $(WebCore)/Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.idl \
    384386    $(WebCore)/Modules/webgpu/WebGPURenderPassDescriptor.idl \
    385387    $(WebCore)/Modules/webgpu/WebGPURenderPassEncoder.idl \
  • trunk/Source/WebCore/Modules/webgpu/WebGPUColor.h

    r238740 r238741  
    2828#if ENABLE(WEBGPU)
    2929
    30 #include "GPUTexture.h"
     30#include "GPUColor.h"
    3131
    3232namespace WebCore {
    3333
    34 struct GPURenderPassDescriptor {
    35     Ref<GPUTexture> attachment;
    36 };
     34using WebGPUColor = GPUColor;
    3735
    3836} // namespace WebCore
  • trunk/Source/WebCore/Modules/webgpu/WebGPUColor.idl

    r238740 r238741  
    2323 * THE POSSIBILITY OF SUCH DAMAGE.
    2424 */
     25// https://github.com/gpuweb/gpuweb/blob/master/design/sketch.webidl
    2526
    26 #pragma once
    27 
    28 #if ENABLE(WEBGPU)
    29 
    30 #include "GPUTexture.h"
    31 
    32 namespace WebCore {
    33 
    34 struct GPURenderPassDescriptor {
    35     Ref<GPUTexture> attachment;
     27[
     28    Conditional=WEBGPU,
     29    EnabledAtRuntime=WebGPU
     30] dictionary WebGPUColor {
     31    float r;
     32    float g;
     33    float b;
     34    float a;
    3635};
    37 
    38 } // namespace WebCore
    39 
    40 #endif // ENABLE(WEBGPU)
  • trunk/Source/WebCore/Modules/webgpu/WebGPUCommandBuffer.cpp

    r238687 r238741  
    5454{
    5555    // FIXME: Improve error checking as WebGPURenderPassDescriptor is implemented.
    56     if (!descriptor.attachment) {
    57         LOG(WebGPU, "WebGPUCommandBuffer::create(): No attachment specified for WebGPURenderPassDescriptor!");
     56    if (descriptor.colorAttachments.isEmpty()) {
     57        LOG(WebGPU, "WebGPUCommandBuffer::create(): No attachments specified for WebGPURenderPassDescriptor!");
    5858        return nullptr;
    5959    }
    60    
    61     auto encoder = GPURenderPassEncoder::create(m_commandBuffer.get(), GPURenderPassDescriptor { descriptor.attachment->texture() });
     60
     61    GPURenderPassDescriptor gpuRenderPassDescriptor;
     62
     63    for (const auto& colorAttachment : descriptor.colorAttachments) {
     64        if (!colorAttachment.attachment) {
     65            LOG(WebGPU, "WebGPUCommandBuffer::create(): Invalid attachment in WebGPURenderPassColorAttachmentDescriptor!");
     66            return nullptr;
     67        }
     68        gpuRenderPassDescriptor.colorAttachments.append(GPURenderPassColorAttachmentDescriptor { colorAttachment.attachment->texture(), colorAttachment.clearColor });
     69    }
     70
     71    auto encoder = GPURenderPassEncoder::create(m_commandBuffer.get(), WTFMove(gpuRenderPassDescriptor));
    6272
    6373    if (!encoder)
  • trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.h

    r238740 r238741  
    2828#if ENABLE(WEBGPU)
    2929
     30#include "WebGPUColor.h"
    3031#include "WebGPUTextureView.h"
    3132
    3233namespace WebCore {
    3334
    34 struct WebGPURenderPassDescriptor {
    35     // FIXME: Temporary shortcut implementation for prototyping.
     35struct WebGPURenderPassColorAttachmentDescriptor {
    3636    RefPtr<WebGPUTextureView> attachment;
     37
     38    WebGPUColor clearColor;
    3739};
    3840
  • trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassColorAttachmentDescriptor.idl

    r238740 r238741  
    2828    Conditional=WEBGPU,
    2929    EnabledAtRuntime=WebGPU
    30 ] dictionary WebGPURenderPassDescriptor {
    31     // FIXME: Temporary shortcut implementation for prototyping.
     30] dictionary WebGPURenderPassColorAttachmentDescriptor {
    3231    WebGPUTextureView attachment;
    3332
    34 /* Not Yet Implemented:
    35     sequence<WebGPURenderPassColorAttachmentDescriptor> colorAttachments;
    36     WebGPURenderPassDepthStencilAttachmentDescriptor depthStencilAttachment;
    37 */
     33    // Not Yet Implemented
     34    // WebGPULoadOp loadOp;
     35    // WebGPUStoreOp storeOp;
     36    WebGPUColor clearColor;
    3837};
  • trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.h

    r238629 r238741  
    2828#if ENABLE(WEBGPU)
    2929
    30 #include "WebGPUTextureView.h"
     30#include "WebGPURenderPassColorAttachmentDescriptor.h"
     31
     32#include <wtf/Vector.h>
    3133
    3234namespace WebCore {
    3335
    3436struct WebGPURenderPassDescriptor {
    35     // FIXME: Temporary shortcut implementation for prototyping.
    36     RefPtr<WebGPUTextureView> attachment;
     37    Vector<WebGPURenderPassColorAttachmentDescriptor> colorAttachments;
    3738};
    3839
  • trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.idl

    r238629 r238741  
    2929    EnabledAtRuntime=WebGPU
    3030] dictionary WebGPURenderPassDescriptor {
    31     // FIXME: Temporary shortcut implementation for prototyping.
    32     WebGPUTextureView attachment;
    33 
    34 /* Not Yet Implemented:
    3531    sequence<WebGPURenderPassColorAttachmentDescriptor> colorAttachments;
    36     WebGPURenderPassDepthStencilAttachmentDescriptor depthStencilAttachment;
    37 */
     32    // WebGPURenderPassDepthStencilAttachmentDescriptor depthStencilAttachment;
    3833};
  • trunk/Source/WebCore/Modules/webgpu/WebGPUTexture.cpp

    r238687 r238741  
    2929#if ENABLE(WEBGPU)
    3030
    31 #include "GPUTexture.h"
    3231#include "WebGPUTextureView.h"
    3332
  • trunk/Source/WebCore/Modules/webgpu/WebGPUTexture.h

    r238687 r238741  
    2828#if ENABLE(WEBGPU)
    2929
     30#include "GPUTexture.h"
     31
    3032#include <wtf/RefCounted.h>
    3133#include <wtf/RefPtr.h>
     
    3335namespace WebCore {
    3436
    35 class GPUTexture;
    3637class WebGPUTextureView;
    3738
  • trunk/Source/WebCore/Sources.txt

    r238667 r238741  
    32223222JSWebGPUAdapterDescriptor.cpp
    32233223JSWebGPUCommandBuffer.cpp
     3224JSWebGPUColor.cpp
    32243225JSWebGPUDevice.cpp
    32253226JSWebGPUQueue.cpp
     
    32283229JSWebGPUProgrammablePassEncoder.cpp
    32293230JSWebGPURenderingContext.cpp
     3231JSWebGPURenderPassColorAttachmentDescriptor.cpp
    32303232JSWebGPURenderPassDescriptor.cpp
    32313233JSWebGPURenderPassEncoder.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r238739 r238741  
    1370413704                D000ED2511C1B9CD00C47726 /* SubframeLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SubframeLoader.cpp; sourceTree = "<group>"; };
    1370513705                D000ED2611C1B9CD00C47726 /* SubframeLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SubframeLoader.h; sourceTree = "<group>"; };
     13706                D001D9A921B0C6730023B9BC /* GPURenderPassColorAttachmentDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPURenderPassColorAttachmentDescriptor.h; sourceTree = "<group>"; };
     13707                D001D9AB21B0C7BF0023B9BC /* GPUColor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUColor.h; sourceTree = "<group>"; };
     13708                D001D9AC21B0C81A0023B9BC /* WebGPUColor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUColor.h; sourceTree = "<group>"; };
     13709                D001D9AD21B0C81A0023B9BC /* WebGPUColor.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUColor.idl; sourceTree = "<group>"; };
     13710                D001D9B021B0C8A80023B9BC /* WebGPURenderPassColorAttachmentDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPURenderPassColorAttachmentDescriptor.h; sourceTree = "<group>"; };
     13711                D001D9B121B0C8A80023B9BC /* WebGPURenderPassColorAttachmentDescriptor.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPURenderPassColorAttachmentDescriptor.idl; sourceTree = "<group>"; };
    1370613712                D00F5940216ECC7A000D71DB /* DOMWindowWebGPU.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DOMWindowWebGPU.h; sourceTree = "<group>"; };
    1370713713                D00F5941216ECC7A000D71DB /* DOMWindowWebGPU.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DOMWindowWebGPU.cpp; sourceTree = "<group>"; };
     
    1801118017                                D087CE3721ACA94200BDE174 /* cocoa */,
    1801218018                                312FF8CE21A4C33F00EB199D /* legacy */,
     18019                                D001D9AB21B0C7BF0023B9BC /* GPUColor.h */,
    1801318020                                312FF8BD21A4C2F100EB199D /* GPUCommandBuffer.h */,
    1801418021                                312FF8BF21A4C2F100EB199D /* GPUDevice.cpp */,
     
    1801818025                                D03211CF21AC954E00763CF2 /* GPUProgrammablePassEncoder.h */,
    1801918026                                312FF8C121A4C2F200EB199D /* GPUQueue.h */,
     18027                                D001D9A921B0C6730023B9BC /* GPURenderPassColorAttachmentDescriptor.h */,
    1802018028                                D03211D021AC954F00763CF2 /* GPURenderPassDescriptor.h */,
    1802118029                                D03211CE21AC954E00763CF2 /* GPURenderPassEncoder.h */,
     
    2549925507                                D02C26912181416D00D818E4 /* WebGPUAdapterDescriptor.h */,
    2550025508                                D02C26922181416D00D818E4 /* WebGPUAdapterDescriptor.idl */,
     25509                                D001D9AC21B0C81A0023B9BC /* WebGPUColor.h */,
     25510                                D001D9AD21B0C81A0023B9BC /* WebGPUColor.idl */,
    2550125511                                D0EACF7721937228000FA75C /* WebGPUCommandBuffer.cpp */,
    2550225512                                D0EACF7621937228000FA75C /* WebGPUCommandBuffer.h */,
     
    2551825528                                D093D225217951D400329217 /* WebGPURenderingContext.h */,
    2551925529                                D093D227217951D400329217 /* WebGPURenderingContext.idl */,
     25530                                D001D9B021B0C8A80023B9BC /* WebGPURenderPassColorAttachmentDescriptor.h */,
     25531                                D001D9B121B0C8A80023B9BC /* WebGPURenderPassColorAttachmentDescriptor.idl */,
    2552025532                                D0EACF8C219403C9000FA75C /* WebGPURenderPassDescriptor.h */,
    2552125533                                D0EACF8D219403C9000FA75C /* WebGPURenderPassDescriptor.idl */,
  • trunk/Source/WebCore/platform/graphics/gpu/GPUColor.h

    r238740 r238741  
    2828#if ENABLE(WEBGPU)
    2929
    30 #include "GPUTexture.h"
    31 
    3230namespace WebCore {
    3331
    34 struct GPURenderPassDescriptor {
    35     Ref<GPUTexture> attachment;
     32struct GPUColor {
     33    float r;
     34    float g;
     35    float b;
     36    float a;
    3637};
    3738
  • trunk/Source/WebCore/platform/graphics/gpu/GPURenderPassColorAttachmentDescriptor.h

    r238740 r238741  
    2828#if ENABLE(WEBGPU)
    2929
     30#include "GPUColor.h"
    3031#include "GPUTexture.h"
    3132
    3233namespace WebCore {
    3334
    34 struct GPURenderPassDescriptor {
     35struct GPURenderPassColorAttachmentDescriptor {
    3536    Ref<GPUTexture> attachment;
     37
     38    GPUColor clearColor;
    3639};
    3740
  • trunk/Source/WebCore/platform/graphics/gpu/GPURenderPassDescriptor.h

    r238629 r238741  
    2828#if ENABLE(WEBGPU)
    2929
    30 #include "GPUTexture.h"
     30#include "GPURenderPassColorAttachmentDescriptor.h"
     31
     32#include <wtf/Vector.h>
    3133
    3234namespace WebCore {
    3335
    3436struct GPURenderPassDescriptor {
    35     Ref<GPUTexture> attachment;
     37    Vector<GPURenderPassColorAttachmentDescriptor> colorAttachments;
    3638};
    3739
  • trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm

    r238687 r238741  
    4343    PlatformRenderPassEncoderSmartPtr mtlEncoder;
    4444
     45    // FIXME: Default to colorAttachments[0] and this loadOp, storeOp for now.
     46    const auto& attachmentDescriptor = descriptor.colorAttachments[0];
     47    const auto& color = attachmentDescriptor.clearColor;
     48
    4549    BEGIN_BLOCK_OBJC_EXCEPTIONS;
    4650
    4751    auto mtlDescriptor = adoptNS([MTLRenderPassDescriptor new]);
    4852
    49     // FIXME: Default to colorAttachments[0] and this loadOp, storeOp, clearColor for now.
    50     mtlDescriptor.get().colorAttachments[0].texture = descriptor.attachment->platformTexture();
     53    mtlDescriptor.get().colorAttachments[0].texture = attachmentDescriptor.attachment->platformTexture();
    5154    mtlDescriptor.get().colorAttachments[0].loadAction = MTLLoadActionClear;
    5255    mtlDescriptor.get().colorAttachments[0].storeAction = MTLStoreActionStore;
    53     mtlDescriptor.get().colorAttachments[0].clearColor = MTLClearColorMake(0.35, 0.65, 0.85, 1.0);
     56    mtlDescriptor.get().colorAttachments[0].clearColor = MTLClearColorMake(color.r, color.g, color.b, color.a);
    5457
    5558    mtlEncoder = retainPtr([buffer.platformCommandBuffer() renderCommandEncoderWithDescriptor:mtlDescriptor.get()]);
Note: See TracChangeset for help on using the changeset viewer.