Branch: refs/heads/main Home: https://github.com/WebKit/WebKit Commit: 021a45c18eba49cfc45b5cad694f05095c138414 https://github.com/WebKit/WebKit/commit/021a45c18eba49cfc45b5cad694f05095c138414 Author: Tadeu Zagallo <tzaga...@apple.com> Date: 2023-01-20 (Fri, 20 Jan 2023)
Changed paths: M Source/WebGPU/WGSL/AST/ASTAttribute.h M Source/WebGPU/WGSL/AST/ASTBuiltinAttribute.h M Source/WebGPU/WGSL/AST/ASTCallableExpression.h M Source/WebGPU/WGSL/AST/ASTForward.h M Source/WebGPU/WGSL/AST/ASTFunctionDecl.h M Source/WebGPU/WGSL/AST/ASTNode.h M Source/WebGPU/WGSL/AST/ASTStringDumper.cpp M Source/WebGPU/WGSL/AST/ASTStringDumper.h M Source/WebGPU/WGSL/AST/ASTStructureDecl.h M Source/WebGPU/WGSL/AST/ASTTypeDecl.h M Source/WebGPU/WGSL/AST/ASTVariableDecl.h M Source/WebGPU/WGSL/AST/ASTVisitor.cpp M Source/WebGPU/WGSL/AST/ASTVisitor.h A Source/WebGPU/WGSL/EntryPointRewriter.cpp A Source/WebGPU/WGSL/EntryPointRewriter.h M Source/WebGPU/WGSL/Metal/MetalFunctionWriter.cpp M Source/WebGPU/WGSL/Parser.cpp M Source/WebGPU/WGSL/ParserPrivate.h A Source/WebGPU/WGSL/PhaseTimer.h A Source/WebGPU/WGSL/ResolveTypeReferences.cpp A Source/WebGPU/WGSL/ResolveTypeReferences.h M Source/WebGPU/WGSL/WGSL.cpp M Source/WebGPU/WebGPU.xcodeproj/project.pbxproj M Tools/TestWebKitAPI/Tests/WGSL/ParserTests.cpp M Websites/webkit.org/demos/webgpu/scripts/hello-triangle.js Log Message: ----------- [WGSL] Add pass to rewrite entry points to be compatible with Metal https://bugs.webkit.org/show_bug.cgi?id=250832 <rdar://problem/104425157> Reviewed by Myles C. Maxfield. For entry point function, builtin inputs contained in structs must be hoisted into function parameters, and any non-builtin parameters must be moved into a `stage_in` struct. The implementation can't quite handle absolutely every use case yet, but the patch was getting pretty large so I thought I pause here and commit something that works. A couple other things had to happen to get this initial implementation working: - I needed some basic type information, so I added a very rudimentary pass to resolve type names and a new struct type. - I also had to modify the AST to use `Ref`/`RefPtr` instead of `UniqueRef`/`unique_ptr` for types, since we need to be able to copy nodes when moving parameters around. - Fixed a couple small serialization bugs with missing semicolons in MetalFunctionWriter and added serialization for matrix types. * Source/WebGPU/WGSL/AST/ASTAttribute.h: * Source/WebGPU/WGSL/AST/ASTBuiltinAttribute.h: * Source/WebGPU/WGSL/AST/ASTCallableExpression.h: * Source/WebGPU/WGSL/AST/ASTForward.h: * Source/WebGPU/WGSL/AST/ASTFunctionDecl.h: * Source/WebGPU/WGSL/AST/ASTNode.h: * Source/WebGPU/WGSL/AST/ASTStringDumper.cpp: (WGSL::AST::StringDumper::visit): * Source/WebGPU/WGSL/AST/ASTStringDumper.h: * Source/WebGPU/WGSL/AST/ASTStructureDecl.h: * Source/WebGPU/WGSL/AST/ASTTypeDecl.h: (WGSL::AST::ParameterizedType::ParameterizedType): (isType): * Source/WebGPU/WGSL/AST/ASTVariableDecl.h: * Source/WebGPU/WGSL/AST/ASTVisitor.cpp: (WGSL::AST::Visitor::visit): * Source/WebGPU/WGSL/AST/ASTVisitor.h: * Source/WebGPU/WGSL/EntryPointRewriter.cpp: Added. (WGSL::EntryPointRewriter::EntryPointRewriter): (WGSL::EntryPointRewriter::getResolvedType): (WGSL::EntryPointRewriter::rewrite): (WGSL::EntryPointRewriter::collectParameters): (WGSL::EntryPointRewriter::constructInputStruct): (WGSL::EntryPointRewriter::materialize): (WGSL::EntryPointRewriter::visit): (WGSL::EntryPointRewriter::appendBuiltins): (WGSL::RewriteEntryPoints::RewriteEntryPoints): (WGSL::RewriteEntryPoints::visit): (WGSL::rewriteEntryPoints): * Source/WebGPU/WGSL/EntryPointRewriter.h: Added. * Source/WebGPU/WGSL/Metal/MetalFunctionWriter.cpp: (WGSL::Metal::FunctionDefinitionWriter::visit): * Source/WebGPU/WGSL/Parser.cpp: (WGSL::Parser<Lexer>::parseAttribute): (WGSL::Parser<Lexer>::parseTypeDecl): (WGSL::Parser<Lexer>::parseTypeDeclAfterIdentifier): (WGSL::Parser<Lexer>::parseArrayType): (WGSL::Parser<Lexer>::parseVariableDeclWithAttributes): (WGSL::Parser<Lexer>::parseFunctionDecl): (WGSL::Parser<Lexer>::parseStatement): (WGSL::Parser<Lexer>::parseUnaryExpression): (WGSL::Parser<Lexer>::parsePrimaryExpression): (WGSL::Parser<Lexer>::parseCoreLHSExpression): * Source/WebGPU/WGSL/ParserPrivate.h: * Source/WebGPU/WGSL/PhaseTimer.h: Added. (WGSL::dumpASTIfNeeded): (WGSL::dumpASTAfterParsingIfNeeded): (WGSL::dumpASTBetweenEachPassIfNeeded): (WGSL::dumpASTAtEndIfNeeded): (WGSL::logPhaseTimes): (WGSL::PhaseTimer::PhaseTimer): (WGSL::PhaseTimer::~PhaseTimer): * Source/WebGPU/WGSL/ResolveTypeReferences.cpp: Added. (WGSL::ResolveTypeReferences::ResolveTypeReferences): (WGSL::ResolveTypeReferences::visit): (WGSL::resolveTypeReferences): * Source/WebGPU/WGSL/ResolveTypeReferences.h: Added. * Source/WebGPU/WGSL/WGSL.cpp: (WGSL::prepare): * Source/WebGPU/WebGPU.xcodeproj/project.pbxproj: * Tools/TestWebKitAPI/Tests/WGSL/ParserTests.cpp: (TestWGSLAPI::TEST): * Websites/webkit.org/demos/webgpu/scripts/hello-triangle.js: (async helloTriangle): Canonical link: https://commits.webkit.org/259149@main _______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-changes