[webkit-changes] [WebKit/WebKit] afb7b7: [WGSL] Add pass to validate attributes

Tadeu Zagallo noreply at github.com
Tue Oct 24 08:23:19 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: afb7b79b764ae2b7f806c51abea387b19fec98d3
      https://github.com/WebKit/WebKit/commit/afb7b79b764ae2b7f806c51abea387b19fec98d3
  Author: Tadeu Zagallo <tzagallo at apple.com>
  Date:   2023-10-24 (Tue, 24 Oct 2023)

  Changed paths:
    M Source/WebGPU/WGSL/AST/AST.h
    M Source/WebGPU/WGSL/AST/ASTBuiltinAttribute.h
    A Source/WebGPU/WGSL/AST/ASTDiagnosticAttribute.h
    M Source/WebGPU/WGSL/AST/ASTForward.h
    M Source/WebGPU/WGSL/AST/ASTFunction.h
    M Source/WebGPU/WGSL/AST/ASTInterpolateAttribute.h
    A Source/WebGPU/WGSL/AST/ASTMustUseAttribute.h
    M Source/WebGPU/WGSL/AST/ASTNode.h
    M Source/WebGPU/WGSL/AST/ASTParameter.h
    M Source/WebGPU/WGSL/AST/ASTStageAttribute.h
    M Source/WebGPU/WGSL/AST/ASTStringDumper.cpp
    M Source/WebGPU/WGSL/AST/ASTStructureMember.h
    M Source/WebGPU/WGSL/AST/ASTVariable.h
    M Source/WebGPU/WGSL/AST/ASTVisitor.cpp
    M Source/WebGPU/WGSL/AST/ASTVisitor.h
    M Source/WebGPU/WGSL/AST/ASTWorkgroupSizeAttribute.h
    A Source/WebGPU/WGSL/AttributeValidator.cpp
    A Source/WebGPU/WGSL/AttributeValidator.h
    M Source/WebGPU/WGSL/CallGraph.cpp
    M Source/WebGPU/WGSL/CallGraph.h
    M Source/WebGPU/WGSL/EntryPointRewriter.cpp
    M Source/WebGPU/WGSL/GlobalVariableRewriter.cpp
    M Source/WebGPU/WGSL/Metal/MetalFunctionWriter.cpp
    M Source/WebGPU/WGSL/Parser.cpp
    M Source/WebGPU/WGSL/TypeCheck.cpp
    M Source/WebGPU/WGSL/WGSL.cpp
    M Source/WebGPU/WGSL/WGSL.h
    M Source/WebGPU/WGSL/WGSLEnums.cpp
    M Source/WebGPU/WGSL/WGSLEnums.h
    A Source/WebGPU/WGSL/tests/invalid/attribute-validation.wgsl
    M Source/WebGPU/WebGPU.xcodeproj/project.pbxproj
    M Tools/TestWebKitAPI/Tests/WGSL/ParserTests.cpp

  Log Message:
  -----------
  [WGSL] Add pass to validate attributes
https://bugs.webkit.org/show_bug.cgi?id=263558
rdar://117372130

Reviewed by Mike Wyrzykowski and Dan Glastonbury.

Add a new compiler pass with 2 responsibilities:
- perform all the attribute-related validations according to the spec[1]
- save the computed values of the attributes in their parent node, so that subsequent
  passes no longer need to keep traversing the list of attributes and checking if it
  contains a given node they are looking for.

[1]: https://www.w3.org/TR/WGSL/#attributes

* Source/WebGPU/WGSL/AST/AST.h:
* Source/WebGPU/WGSL/AST/ASTBuiltinAttribute.h:
* Source/WebGPU/WGSL/AST/ASTDiagnosticAttribute.h: Copied from Source/WebGPU/WGSL/AST/ASTStageAttribute.h.
* Source/WebGPU/WGSL/AST/ASTForward.h:
* Source/WebGPU/WGSL/AST/ASTFunction.h:
* Source/WebGPU/WGSL/AST/ASTInterpolateAttribute.h:
* Source/WebGPU/WGSL/AST/ASTMustUseAttribute.h: Copied from Source/WebGPU/WGSL/AST/ASTBuiltinAttribute.h.
* Source/WebGPU/WGSL/AST/ASTNode.h:
* Source/WebGPU/WGSL/AST/ASTParameter.h:
* Source/WebGPU/WGSL/AST/ASTStageAttribute.h:
* Source/WebGPU/WGSL/AST/ASTStringDumper.cpp:
(WGSL::AST::StringDumper::visit):
* Source/WebGPU/WGSL/AST/ASTStructureMember.h:
* Source/WebGPU/WGSL/AST/ASTVariable.h:
* Source/WebGPU/WGSL/AST/ASTVisitor.cpp:
(WGSL::AST::Visitor::visit):
* Source/WebGPU/WGSL/AST/ASTVisitor.h:
(WGSL::AST::Visitor::visit): Deleted.
* Source/WebGPU/WGSL/AST/ASTWorkgroupSizeAttribute.h:
* Source/WebGPU/WGSL/AttributeValidator.cpp: Added.
(WGSL::AttributeValidator::AttributeValidator):
(WGSL::AttributeValidator::validate):
(WGSL::AttributeValidator::visit):
(WGSL::AttributeValidator::parseBuiltin):
(WGSL::AttributeValidator::parseInterpolate):
(WGSL::AttributeValidator::parseInvariant):
(WGSL::AttributeValidator::parseLocation):
(WGSL::AttributeValidator::validateInterpolation):
(WGSL::AttributeValidator::validateInvariant):
(WGSL::AttributeValidator::update):
(WGSL::AttributeValidator::set):
(WGSL::AttributeValidator::error):
(WGSL::validateAttributes):
* Source/WebGPU/WGSL/AttributeValidator.h: Copied from Source/WebGPU/WGSL/CallGraph.h.
* Source/WebGPU/WGSL/CallGraph.cpp:
(WGSL::CallGraphBuilder::initializeMappings):
* Source/WebGPU/WGSL/CallGraph.h:
* Source/WebGPU/WGSL/EntryPointRewriter.cpp:
(WGSL::EntryPointRewriter::EntryPointRewriter):
(WGSL::EntryPointRewriter::checkReturnType):
(WGSL::EntryPointRewriter::constructInputStruct):
* Source/WebGPU/WGSL/GlobalVariableRewriter.cpp:
(WGSL::RewriteGlobalVariables::collectGlobals):
(WGSL::RewriteGlobalVariables::visitEntryPoint):
(WGSL::RewriteGlobalVariables::usesOverride):
* Source/WebGPU/WGSL/Metal/MetalFunctionWriter.cpp:
(WGSL::Metal::FunctionDefinitionWriter::visit):
(WGSL::Metal::convertToSampleMode):
* Source/WebGPU/WGSL/Parser.cpp:
(WGSL::Parser<Lexer>::parseAttribute):
* Source/WebGPU/WGSL/TypeCheck.cpp:
(WGSL::TypeChecker::visitVariable):
(WGSL::TypeChecker::visit):
* Source/WebGPU/WGSL/WGSL.cpp:
(WGSL::staticCheck):
* Source/WebGPU/WGSL/WGSL.h:
* Source/WebGPU/WGSL/WGSLEnums.cpp:
* Source/WebGPU/WGSL/WGSLEnums.h:
* Source/WebGPU/WGSL/tests/invalid/attribute-validation.wgsl: Added.
* Source/WebGPU/WebGPU.xcodeproj/project.pbxproj:

Canonical link: https://commits.webkit.org/269714@main




More information about the webkit-changes mailing list