Bug 217095 - [WebGPU] Add platform guards
Summary: [WebGPU] Add platform guards
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebGPU (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Don Olmstead
URL:
Keywords: InRadar
Depends on:
Blocks: 216712
  Show dependency treegraph
 
Reported: 2020-09-29 10:33 PDT by Don Olmstead
Modified: 2020-09-29 19:00 PDT (History)
8 users (show)

See Also:


Attachments
Patch (16.33 KB, patch)
2020-09-29 10:51 PDT, Don Olmstead
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (16.33 KB, patch)
2020-09-29 11:07 PDT, Don Olmstead
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (16.16 KB, patch)
2020-09-29 11:16 PDT, Don Olmstead
no flags Details | Formatted Diff | Diff
Patch (16.14 KB, patch)
2020-09-29 11:29 PDT, Don Olmstead
darin: review+
Details | Formatted Diff | Diff
Patch (16.49 KB, patch)
2020-09-29 17:30 PDT, Don Olmstead
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Don Olmstead 2020-09-29 10:33:35 PDT
Compiling WebGPU currently assumes Metal is present
Comment 1 Don Olmstead 2020-09-29 10:51:13 PDT Comment hidden (obsolete)
Comment 2 Don Olmstead 2020-09-29 11:07:26 PDT Comment hidden (obsolete)
Comment 3 Don Olmstead 2020-09-29 11:16:28 PDT Comment hidden (obsolete)
Comment 4 Don Olmstead 2020-09-29 11:29:03 PDT
Created attachment 410026 [details]
Patch
Comment 5 Darin Adler 2020-09-29 13:26:04 PDT
Comment on attachment 410026 [details]
Patch

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

Not totally thrilled with details of the approach. Happy that we are adding the #if USE(METAL).

> Source/WebCore/platform/graphics/gpu/GPUBindGroupAllocator.h:40
> +#if USE(METAL)
> +#include <objc/NSObjCRuntime.h>
>  #include <wtf/RetainPtr.h>
>  
>  OBJC_PROTOCOL(MTLArgumentEncoder);
>  OBJC_PROTOCOL(MTLBuffer);
> +#endif

I’d prefer we use two separate #if/#endif pairs here. Same feedback over and over again. Nicer to have all includes together, then all forward declarations together, rather than trying to group into platforms.

> Source/WebCore/platform/graphics/gpu/GPUBuffer.h:62
>  #else
> -using PlatformBuffer = void;
> +#error Unsupported configuration

I think we’ll get errors without an explicit #error, so maybe don’t bother with the #else.

Not the biggest fan of platform-specifics with a chain of #if/#elif/#endif. Seems like we can just define these types separately as needed.

But more, generally speaking, I am not so fond of these types; how much platform-independent code to handle platform-specific types really needs to exist at all? I’d rather see #if around multiple definitions of m_platformBuffer, because I don’t really see this as a platform-independent abstraction. Very little platform-independent code needs to deal with these; the platform-specific code does need to.

One exception is the constructor, I guess?

We can do better.

Same comment repeatedly about other cases below.

> Source/WebCore/platform/graphics/gpu/GPUSwapChain.h:35
> +// PlatformLayer implementation needed otherwise compiling derived sources will fail

Please add a period.
Comment 6 Dean Jackson 2020-09-29 16:40:57 PDT
Comment on attachment 410026 [details]
Patch

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

>> Source/WebCore/platform/graphics/gpu/GPUBuffer.h:62
>> +#error Unsupported configuration
> 
> I think we’ll get errors without an explicit #error, so maybe don’t bother with the #else.
> 
> Not the biggest fan of platform-specifics with a chain of #if/#elif/#endif. Seems like we can just define these types separately as needed.
> 
> But more, generally speaking, I am not so fond of these types; how much platform-independent code to handle platform-specific types really needs to exist at all? I’d rather see #if around multiple definitions of m_platformBuffer, because I don’t really see this as a platform-independent abstraction. Very little platform-independent code needs to deal with these; the platform-specific code does need to.
> 
> One exception is the constructor, I guess?
> 
> We can do better.
> 
> Same comment repeatedly about other cases below.

+1 to what Darin said. I find the PlatformType stuff fairly confusing, because it means you have to redirect to work out what the actual type is.
Comment 7 Don Olmstead 2020-09-29 17:30:16 PDT
Created attachment 410071 [details]
Patch
Comment 8 Don Olmstead 2020-09-29 18:03:05 PDT
(In reply to Dean Jackson from comment #6)
> Comment on attachment 410026 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=410026&action=review
> 
> >> Source/WebCore/platform/graphics/gpu/GPUBuffer.h:62
> >> +#error Unsupported configuration
> > 
> > I think we’ll get errors without an explicit #error, so maybe don’t bother with the #else.
> > 
> > Not the biggest fan of platform-specifics with a chain of #if/#elif/#endif. Seems like we can just define these types separately as needed.
> > 
> > But more, generally speaking, I am not so fond of these types; how much platform-independent code to handle platform-specific types really needs to exist at all? I’d rather see #if around multiple definitions of m_platformBuffer, because I don’t really see this as a platform-independent abstraction. Very little platform-independent code needs to deal with these; the platform-specific code does need to.
> > 
> > One exception is the constructor, I guess?
> > 
> > We can do better.
> > 
> > Same comment repeatedly about other cases below.
> 
> +1 to what Darin said. I find the PlatformType stuff fairly confusing,
> because it means you have to redirect to work out what the actual type is.

When I'm going through the actual implementation with Dawn I'll revisit the PlatformType stuff.
Comment 9 EWS 2020-09-29 18:59:38 PDT
Committed r267777: <https://trac.webkit.org/changeset/267777>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 410071 [details].
Comment 10 Radar WebKit Bug Importer 2020-09-29 19:00:29 PDT
<rdar://problem/69773470>