Bug 191663 - [WebGPU] WebGPUCommandBuffer prototype
Summary: [WebGPU] WebGPUCommandBuffer prototype
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Justin Fan
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-11-14 15:45 PST by Justin Fan
Modified: 2018-11-15 13:21 PST (History)
3 users (show)

See Also:


Attachments
Patch (51.85 KB, patch)
2018-11-14 16:03 PST, Justin Fan
no flags Details | Formatted Diff | Diff
Patch (52.77 KB, patch)
2018-11-15 12:26 PST, Justin Fan
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Justin Fan 2018-11-14 15:45:29 PST
[WebGPU] WebGPUCommandBuffer prototype
Comment 1 Justin Fan 2018-11-14 16:03:17 PST
Created attachment 354864 [details]
Patch
Comment 2 Justin Fan 2018-11-14 16:06:57 PST
Patch doesn't apply because it relies on 191383, which will land soon.
Comment 3 Dean Jackson 2018-11-14 16:36:40 PST
Comment on attachment 354864 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=354864&action=review

> Source/WebCore/ChangeLog:8
> +        Begin implementation of WebGPUCommandBuffers as well as GPUQueues (MTLCommandBuffer, MTLCommandQueue).

This patch has a bit more than just that.

Also, I suggest you get into the habit of writing more detail in the section below, file by file. Look at one of Darin's patches for an example of how helpful that is. There isn't a good reason to simply list the set of files changed without explaining what happened.

> Source/WebCore/Modules/webgpu/GPUCommandBuffer.h:2
> +/*
> + * Copyright (C) 2018 Apple Inc. All rights reserved.

Not for this patch, but I think all the GPU* files should be under platform, not modules. The WebGPU* files can live here.

> Source/WebCore/Modules/webgpu/GPUDevice.h:31
> +#include "GPUCommandBuffer.h"
> +#include "GPUQueue.h"

Can't we just forward declare these?

> Source/WebCore/Modules/webgpu/GPUQueue.h:47
> +    PlatformQueue *platformQueue() const { return m_platformQueue.get(); }

Nit: * after PlatformQueue

> Source/WebCore/Modules/webgpu/WebGPUCommandBuffer.cpp:46
> +    UNUSED_PARAM(m_commandBuffer);

Why do you need this? Is it because the member variable is never used?

> Source/WebCore/Modules/webgpu/cocoa/GPUCommandBufferMetal.mm:57
> +    buffer = [mtlQueue commandBuffer];

Don't you need to adoptNS on this?

> Source/WebCore/Modules/webgpu/cocoa/GPUQueueMetal.mm:50
> +    queue = [device.platformDevice() newCommandQueue];

Needs adoptNS

> LayoutTests/webgpu/command-buffers.html:38
> +<script id="library" type="x-shader/x-metal">
> +    #include <metal_stdlib>
> +    
> +    using namespace metal;
> +    
> +    struct Vertex
> +    {
> +        float4 position [[position]];
> +    };
> +    
> +    vertex Vertex vertex_main(uint vid [[vertex_id]])
> +    {
> +        Vertex v;
> +        switch (vid) {
> +        case 0:
> +            v.position = float4(-.75, -.75, 0, 1);
> +            break;
> +        case 1:
> +            v.position = float4(.75, -.75, 0, 1);
> +            break;
> +        case 2:
> +            v.position = float4(0, .75, 0, 1);
> +            break;
> +        default:
> +            v.position = float4(0, 0, 0, 1);
> +        }
> +        return v;
> +    }
> +    
> +    fragment float4 fragment_main(Vertex vertexIn [[stage_in]])
> +    {
> +        return float4(1.0, 0.0, 0.0, 1.0);
> +    }
> +</script>

You don't need a shader for this test.

> LayoutTests/webgpu/command-buffers.html:40
> +'use strict';

Unimportant, but this isn't necessary here.

> LayoutTests/webgpu/webgpu-basics.html:91
> +function render() {

How is this different from the test above? Shouldn't it have a more accurate name for the moment?
Comment 4 Justin Fan 2018-11-14 20:20:03 PST
(In reply to Dean Jackson from comment #3)
> Comment on attachment 354864 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=354864&action=review
> 
> > Source/WebCore/Modules/webgpu/GPUDevice.h:31
> > +#include "GPUCommandBuffer.h"
> > +#include "GPUQueue.h"
> 
> Can't we just forward declare these?


Hmm, the only other place I can put them and have my code still compile (problems in Ref.h template code) is WebGPUDevice.h, and that makes even less sense since there is no mention of either class.
Comment 5 Justin Fan 2018-11-15 12:26:47 PST
Created attachment 354970 [details]
Patch
Comment 6 Justin Fan 2018-11-15 12:27:54 PST
(In reply to Dean Jackson from comment #3)
> Comment on attachment 354864 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=354864&action=review
> 
> > Source/WebCore/ChangeLog:8
> > +        Begin implementation of WebGPUCommandBuffers as well as GPUQueues (MTLCommandBuffer, MTLCommandQueue).
> 
> This patch has a bit more than just that.

Hmm, I can't really come up with a better description for this. Suggestions?

There's a lot of code but the fact is, implementing this stuff is quite a bit of boilerplate.
Comment 7 Dean Jackson 2018-11-15 12:38:38 PST
Comment on attachment 354970 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=354970&action=review

> Source/WebCore/Modules/webgpu/cocoa/GPUQueueMetal.mm:50
> +    queue = adoptNS([device.platformDevice() newCommandQueue]);

Why did you use retainPtr in the other file and adoptNS here?
Comment 8 WebKit Commit Bot 2018-11-15 13:20:36 PST
Comment on attachment 354970 [details]
Patch

Clearing flags on attachment: 354970

Committed r238245: <https://trac.webkit.org/changeset/238245>
Comment 9 WebKit Commit Bot 2018-11-15 13:20:37 PST
All reviewed patches have been landed.  Closing bug.
Comment 10 Radar WebKit Bug Importer 2018-11-15 13:21:29 PST
<rdar://problem/46105786>