Bug 200748 - [WHLSL] Make "operator cast" constructors native
Summary: [WHLSL] Make "operator cast" constructors native
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebGPU (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Saam Barati
URL:
Keywords: InRadar
Depends on:
Blocks: 200699
  Show dependency treegraph
 
Reported: 2019-08-14 18:49 PDT by Saam Barati
Modified: 2019-08-16 21:14 PDT (History)
10 users (show)

See Also:


Attachments
patch (32.64 KB, patch)
2019-08-16 17:47 PDT, Saam Barati
mmaxfield: review+
Details | Formatted Diff | Diff
patch for landing (33.40 KB, patch)
2019-08-16 20:29 PDT, Saam Barati
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Saam Barati 2019-08-14 18:49:11 PDT
...
Comment 1 Saam Barati 2019-08-16 17:32:22 PDT
patch forthcoming
Comment 2 Saam Barati 2019-08-16 17:47:09 PDT
Created attachment 376571 [details]
patch
Comment 3 EWS Watchlist 2019-08-16 17:49:31 PDT
Attachment 376571 [details] did not pass style-queue:


ERROR: Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp:169:  Multi line control clauses should use braces.  [whitespace/braces] [4]
Total errors found: 1 in 8 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 4 Myles C. Maxfield 2019-08-16 19:51:03 PDT
Comment on attachment 376571 [details]
patch

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

> Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp:140
> +        return WTF::get<AST::ConstantExpression>(matrixType.typeArguments()[typeArgumentIndex]).integerLiteral().value();

Can we move this to Intrinsics? I don't think this is the only place where this kind of computation is performed.

> Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp:211
> +            if (nativeFunctionDeclaration.parameters().size() == numRows) {
> +                // operator matrixMxN (vectorN, ..., vectorN)
> +                for (unsigned i = 0; i < numRows; ++i) {
> +                    for (unsigned j = 0; j < numColumns; ++j)
> +                        stringBuilder.flexibleAppend("x[", j * numRows + i, "] = ", args[i], "[", j, "];\n");
> +                }
> +
> +            } else {
> +                // operator matrixMxN (scalar, ..., scalar)
> +                unsigned index = 0;
> +                for (unsigned i = 0; i < numRows; ++i) {
> +                    for (unsigned j = 0; j < numColumns; ++j) {
> +                        stringBuilder.flexibleAppend("x[", j * numRows + i, "] = ", args[index], ";\n");
> +                        ++index;
> +                    }
> +                }
> +            }

Is there reason you're not just calling the MSL constructors because MSL and HLSL define their matrices with different major-ness? This is probably worth a comment.

> Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp:327
> +        auto& result = downcast<AST::NativeTypeDeclaration>(downcast<AST::TypeReference>(downcast<AST::TypeDefinition>(typeReference.resolvedType()).type()).resolvedType());

Can this be shared with the lambda above?
Comment 5 Saam Barati 2019-08-16 19:56:26 PDT
Comment on attachment 376571 [details]
patch

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

>> Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp:140
>> +        return WTF::get<AST::ConstantExpression>(matrixType.typeArguments()[typeArgumentIndex]).integerLiteral().value();
> 
> Can we move this to Intrinsics? I don't think this is the only place where this kind of computation is performed.

We should put it on NativeTypeDeclaration.

>> Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp:327
>> +        auto& result = downcast<AST::NativeTypeDeclaration>(downcast<AST::TypeReference>(downcast<AST::TypeDefinition>(typeReference.resolvedType()).type()).resolvedType());
> 
> Can this be shared with the lambda above?

it could, but I don't think having more functions in this limited scenario is gonna make anything more clear.
Comment 6 Saam Barati 2019-08-16 20:29:42 PDT
Created attachment 376586 [details]
patch for landing
Comment 7 WebKit Commit Bot 2019-08-16 21:13:12 PDT
Comment on attachment 376586 [details]
patch for landing

Clearing flags on attachment: 376586

Committed r248814: <https://trac.webkit.org/changeset/248814>
Comment 8 WebKit Commit Bot 2019-08-16 21:13:14 PDT
All reviewed patches have been landed.  Closing bug.
Comment 9 Radar WebKit Bug Importer 2019-08-16 21:14:18 PDT
<rdar://problem/54419405>