[webkit-changes] [WebKit/WebKit] 2e6c18: [WGSL] override expressions as array lengths do no...

Tadeu Zagallo noreply at github.com
Thu Feb 8 10:27:39 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 2e6c189562a8c6a3c3bc460f399d45ae801a0bd2
      https://github.com/WebKit/WebKit/commit/2e6c189562a8c6a3c3bc460f399d45ae801a0bd2
  Author: Tadeu Zagallo <tzagallo at apple.com>
  Date:   2024-02-08 (Thu, 08 Feb 2024)

  Changed paths:
    M Source/WebGPU/WGSL/CallGraph.cpp
    M Source/WebGPU/WGSL/CallGraph.h
    A Source/WebGPU/WGSL/CompilationScope.cpp
    A Source/WebGPU/WGSL/CompilationScope.h
    M Source/WebGPU/WGSL/ConstantFunctions.h
    M Source/WebGPU/WGSL/GlobalVariableRewriter.cpp
    M Source/WebGPU/WGSL/MangleNames.cpp
    M Source/WebGPU/WGSL/MangleNames.h
    M Source/WebGPU/WGSL/Metal/MetalCodeGenerator.cpp
    M Source/WebGPU/WGSL/Metal/MetalCodeGenerator.h
    M Source/WebGPU/WGSL/Metal/MetalFunctionWriter.cpp
    M Source/WebGPU/WGSL/Metal/MetalFunctionWriter.h
    M Source/WebGPU/WGSL/Overload.cpp
    M Source/WebGPU/WGSL/TypeCheck.cpp
    M Source/WebGPU/WGSL/TypeStore.cpp
    M Source/WebGPU/WGSL/TypeStore.h
    M Source/WebGPU/WGSL/Types.cpp
    M Source/WebGPU/WGSL/Types.h
    M Source/WebGPU/WGSL/WGSL.cpp
    M Source/WebGPU/WGSL/WGSL.h
    M Source/WebGPU/WGSL/WGSLShaderModule.h
    M Source/WebGPU/WGSL/wgslc.cpp
    M Source/WebGPU/WebGPU.xcodeproj/project.pbxproj
    M Source/WebGPU/WebGPU/ComputePipeline.mm
    M Source/WebGPU/WebGPU/Pipeline.h
    M Source/WebGPU/WebGPU/Pipeline.mm
    M Source/WebGPU/WebGPU/RenderPipeline.mm
    M Source/WebGPU/WebGPU/ShaderModule.mm
    M Tools/TestWebKitAPI/Tests/WGSL/MetalGenerationTests.cpp

  Log Message:
  -----------
  [WGSL] override expressions as array lengths do not compile
https://bugs.webkit.org/show_bug.cgi?id=268425
rdar://121971104

Reviewed by Mike Wyrzykowski.

Allow overrides to be used as array length. This required a series of changes:
- validating that runtime expressions aren't used in a constant/override context
- breaking the compiler API into 3 parts to expose the necessary information to
  the API so it can feed the constants back to the compiler
- changing the type representation for arrays so it can encode 1) fixed-sized arrays,
  2) override-sized arrays and 3) runtime-sized arrays

* Source/WebGPU/WGSL/CallGraph.cpp:
(WGSL::CallGraphBuilder::CallGraphBuilder):
(WGSL::CallGraphBuilder::initializeMappings):
(WGSL::buildCallGraph):
* Source/WebGPU/WGSL/CallGraph.h:
* Source/WebGPU/WGSL/CompilationScope.cpp: Copied from Source/WebGPU/WGSL/MangleNames.h.
(WGSL::CompilationScope::CompilationScope):
(WGSL::CompilationScope::~CompilationScope):
* Source/WebGPU/WGSL/CompilationScope.h: Copied from Source/WebGPU/WGSL/MangleNames.h.
* Source/WebGPU/WGSL/ConstantFunctions.h:
(WGSL::zeroValue):
* Source/WebGPU/WGSL/GlobalVariableRewriter.cpp:
(WGSL::RewriteGlobalVariables::collectGlobals):
(WGSL::RewriteGlobalVariables::storeInitialValue):
(WGSL::RewriteGlobalVariables::containsRuntimeArray): Deleted.
* Source/WebGPU/WGSL/MangleNames.cpp:
(WGSL::NameManglerVisitor::NameManglerVisitor):
(WGSL::NameManglerVisitor::visit):
(WGSL::mangleNames):
* Source/WebGPU/WGSL/MangleNames.h:
* Source/WebGPU/WGSL/Metal/MetalCodeGenerator.cpp:
(WGSL::Metal::generateMetalCode):
* Source/WebGPU/WGSL/Metal/MetalCodeGenerator.h:
* Source/WebGPU/WGSL/Metal/MetalFunctionWriter.cpp:
(WGSL::Metal::FunctionDefinitionWriter::FunctionDefinitionWriter):
(WGSL::Metal::FunctionDefinitionWriter::visitGlobal):
(WGSL::Metal::FunctionDefinitionWriter::visit):
(WGSL::Metal::emitMetalFunctions):
* Source/WebGPU/WGSL/Metal/MetalFunctionWriter.h:
* Source/WebGPU/WGSL/Overload.cpp:
(WGSL::OverloadResolver::materialize const):
(WGSL::OverloadResolver::unify):
* Source/WebGPU/WGSL/TypeCheck.cpp:
(WGSL::evaluationToString):
(WGSL::TypeChecker::visit):
(WGSL::TypeChecker::visitVariable):
(WGSL::TypeChecker::bitcast):
(WGSL::TypeChecker::chooseOverload):
(WGSL::TypeChecker::infer):
(WGSL::TypeChecker::introduceType):
(WGSL::TypeChecker::introduceValue):
(WGSL::TypeChecker::introduceFunction):
(WGSL::TypeChecker::texelFormat):
(WGSL::TypeChecker::accessMode):
(WGSL::TypeChecker::addressSpace):
* Source/WebGPU/WGSL/TypeStore.cpp:
(WGSL::ArrayKey::encode const):
(WGSL::TypeStore::arrayType):
* Source/WebGPU/WGSL/TypeStore.h:
* Source/WebGPU/WGSL/Types.cpp:
(WGSL::Type::dump const):
(WGSL::Type::size const):
(WGSL::Type::isConstructible const):
(WGSL::Type::isStorable const):
(WGSL::Type::isHostShareable const):
(WGSL::Type::hasFixedFootprint const):
(WGSL::Type::hasCreationFixedFootprint const):
(WGSL::Type::containsRuntimeArray const):
(WGSL::Type::containsOverrideArray const):
* Source/WebGPU/WGSL/Types.h:
(WGSL::Types::Array::isRuntimeSized const):
(WGSL::Types::Array::isCreationFixed const):
(WGSL::Types::Array::isOverrideSized const):
* Source/WebGPU/WGSL/WGSL.cpp:
(WGSL::prepareImpl):
(WGSL::generate):
(WGSL::evaluate):
* Source/WebGPU/WGSL/WGSL.h:
* Source/WebGPU/WGSL/WGSLShaderModule.h:
(WGSL::ShaderModule::Compilation::Compilation): Deleted.
(WGSL::ShaderModule::Compilation::~Compilation): Deleted.
* Source/WebGPU/WGSL/wgslc.cpp:
(runWGSL):
* Source/WebGPU/WebGPU.xcodeproj/project.pbxproj:
* Source/WebGPU/WebGPU/ComputePipeline.mm:
(WebGPU::Device::createComputePipeline):
* Source/WebGPU/WebGPU/Pipeline.h:
* Source/WebGPU/WebGPU/Pipeline.mm:
(WebGPU::createLibrary):
(WebGPU::createFunction):
* Source/WebGPU/WebGPU/RenderPipeline.mm:
(WebGPU::Device::createRenderPipeline):
* Source/WebGPU/WebGPU/ShaderModule.mm:
(WebGPU::earlyCompileShaderModule):

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




More information about the webkit-changes mailing list