[webkit-changes] [WebKit/WebKit] de2c00: [WGSL] Global declarations cannot be stored separa...

Tadeu Zagallo noreply at github.com
Fri Dec 8 09:17:16 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: de2c00fe5fb19529682712f557f044b731fff003
      https://github.com/WebKit/WebKit/commit/de2c00fe5fb19529682712f557f044b731fff003
  Author: Tadeu Zagallo <tzagallo at apple.com>
  Date:   2023-12-08 (Fri, 08 Dec 2023)

  Changed paths:
    M Source/WebGPU/WGSL/AST/ASTDeclaration.h
    M Source/WebGPU/WGSL/AST/ASTForward.h
    M Source/WebGPU/WGSL/AST/ASTFunction.h
    M Source/WebGPU/WGSL/AST/ASTStringDumper.cpp
    M Source/WebGPU/WGSL/AST/ASTStructure.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/CallGraph.cpp
    M Source/WebGPU/WGSL/EntryPointRewriter.cpp
    M Source/WebGPU/WGSL/GlobalSorting.cpp
    M Source/WebGPU/WGSL/GlobalVariableRewriter.cpp
    M Source/WebGPU/WGSL/MangleNames.cpp
    M Source/WebGPU/WGSL/Metal/MetalFunctionWriter.cpp
    M Source/WebGPU/WGSL/Parser.cpp
    M Source/WebGPU/WGSL/ParserPrivate.h
    M Source/WebGPU/WGSL/TypeCheck.cpp
    M Source/WebGPU/WGSL/WGSLShaderModule.h
    A Source/WebGPU/WGSL/tests/invalid/redeclaration-reordering.wgsl
    A Source/WebGPU/WGSL/tests/invalid/redeclaration-type-checking.wgsl
    R Source/WebGPU/WGSL/tests/invalid/redeclaration.wgsl
    A Source/WebGPU/WGSL/tests/invalid/reordering-cycle-struct-const.wgsl
    M Source/WebGPU/WebGPU/ShaderModule.mm
    M Tools/TestWebKitAPI/Tests/WGSL/ASTStringDumperTests.cpp
    M Tools/TestWebKitAPI/Tests/WGSL/ParserTests.cpp

  Log Message:
  -----------
  [WGSL] Global declarations cannot be stored separately
https://bugs.webkit.org/show_bug.cgi?id=265960
rdar://119270455

Reviewed by Mike Wyrzykowski.

We stored functions, global variables and structures in separate lists in the
AST.  That simplified a lot of things, but unfortunately breaks down when there
are dependencies between constants and structs. The fix is to move them all into
a list of global declarations.

* Source/WebGPU/WGSL/AST/ASTDeclaration.h:
* Source/WebGPU/WGSL/AST/ASTForward.h:
* Source/WebGPU/WGSL/AST/ASTFunction.h:
* Source/WebGPU/WGSL/AST/ASTStringDumper.cpp:
(WGSL::AST::StringDumper::visit):
* Source/WebGPU/WGSL/AST/ASTStructure.h:
* Source/WebGPU/WGSL/AST/ASTVariable.h:
* Source/WebGPU/WGSL/AST/ASTVisitor.cpp:
(WGSL::AST::Visitor::visit):
* Source/WebGPU/WGSL/AST/ASTVisitor.h:
* Source/WebGPU/WGSL/CallGraph.cpp:
(WGSL::CallGraphBuilder::initializeMappings):
* Source/WebGPU/WGSL/EntryPointRewriter.cpp:
(WGSL::EntryPointRewriter::checkReturnType):
(WGSL::EntryPointRewriter::constructInputStruct):
* Source/WebGPU/WGSL/GlobalSorting.cpp:
(WGSL::Graph::Node::Node):
(WGSL::Graph::Node::index const):
(WGSL::Graph::Node::astNode const):
(WGSL::Graph::Node::incomingEdges):
(WGSL::Graph::Node::outgoingEdges):
(WGSL::Graph::addNode):
(WGSL::GraphBuilder::visit):
(WGSL::GraphBuilder::GraphBuilder):
(WGSL::GraphBuilder::introduceVariable):
(WGSL::GraphBuilder::readVariable const):
(WGSL::reorder):
(WGSL::reorderGlobals):
(WGSL::Graph::Edge::remove): Deleted.
(WGSL::GraphBuilder<ASTNode>::visit): Deleted.
(WGSL::GraphBuilder<ASTNode>::GraphBuilder): Deleted.
(WGSL::GraphBuilder<ASTNode>::introduceVariable): Deleted.
(WGSL::GraphBuilder<ASTNode>::readVariable const): Deleted.
* Source/WebGPU/WGSL/GlobalVariableRewriter.cpp:
(WGSL::RewriteGlobalVariables::collectGlobals):
(WGSL::RewriteGlobalVariables::packStructType):
(WGSL::RewriteGlobalVariables::finalizeArgumentBufferStruct):
* Source/WebGPU/WGSL/MangleNames.cpp:
(WGSL::NameManglerVisitor::run):
(WGSL::NameManglerVisitor::visit):
* Source/WebGPU/WGSL/Metal/MetalFunctionWriter.cpp:
(WGSL::Metal::FunctionDefinitionWriter::write):
* Source/WebGPU/WGSL/Parser.cpp:
(WGSL::Parser<Lexer>::parseShader):
(WGSL::Parser<Lexer>::parseDeclaration):
(WGSL::Parser<Lexer>::parseGlobalDecl): Deleted.
* Source/WebGPU/WGSL/ParserPrivate.h:
* Source/WebGPU/WGSL/TypeCheck.cpp:
(WGSL::TypeChecker::check):
(WGSL::TypeChecker::visit):
* Source/WebGPU/WGSL/WGSLShaderModule.h:
(WGSL::ShaderModule::declarations):
(WGSL::ShaderModule::directives):
(WGSL::ShaderModule::functions): Deleted.
(WGSL::ShaderModule::structures): Deleted.
(WGSL::ShaderModule::variables): Deleted.
* Source/WebGPU/WGSL/tests/invalid/redeclaration-reordering.wgsl: Added.
* Source/WebGPU/WGSL/tests/invalid/redeclaration-type-checking.wgsl: Renamed from Source/WebGPU/WGSL/tests/invalid/redeclaration.wgsl.
* Source/WebGPU/WGSL/tests/invalid/reordering-cycle-struct-const.wgsl: Added.

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




More information about the webkit-changes mailing list