[webkit-changes] [WebKit/WebKit] c4287b: [WebGPU] Support module constants in vertex and fr...

mwyrzykowski noreply at github.com
Wed Jan 11 15:48:58 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: c4287bb1ee99f7e34944ec7e8a962df6e452bbc9
      https://github.com/WebKit/WebKit/commit/c4287bb1ee99f7e34944ec7e8a962df6e452bbc9
  Author: Mike Wyrzykowski <mwyrzykowski at apple.com>
  Date:   2023-01-11 (Wed, 11 Jan 2023)

  Changed paths:
    M Source/WebGPU/WebGPU/RenderPipeline.mm
    M Source/WebGPU/WebGPU/ShaderModule.h
    M Source/WebGPU/WebGPU/ShaderModule.mm
    A Websites/webkit.org/demos/webgpu/scripts/textured-cube-shader-constants.js
    A Websites/webkit.org/demos/webgpu/textured-cube-shader-constants.html

  Log Message:
  -----------
  [WebGPU] Support module constants in vertex and fragment shaders
https://bugs.webkit.org/show_bug.cgi?id=249793
<radar://103490403>

Reviewed by Myles C. Maxfield.

There are multiple ways to support module constants. One way
is to use MTLFunctionConstantValues which allows for shader
specialization after the shader is already compiled, however
it does require invoking the compiling again.

This is what this patch implements.

Alternatively we could defer compilation to render pipeline
creation, but that has the drawback of more compilations when
many pipeline objects are created.

* Source/WebGPU/WebGPU/RenderPipeline.mm:
(WebGPU::Device::validateRenderPipeline):
(WebGPU::buildKeyValueReplacements):
(WebGPU::Device::createRenderPipeline):
Build a hash map containing the names of the constants and their values.

* Source/WebGPU/WebGPU/ShaderModule.h:
* Source/WebGPU/WebGPU/ShaderModule.mm:
(WebGPU::ShaderModule::getNamedFunction const):
Support named function constants. In the future, we need to get the correct
type information from the compiler instead of assuming the type is float.

* Websites/webkit.org/demos/webgpu/scripts/textured-cube-shader-constants.js: Added.
(async helloCube.frameUpdate):
(async helloCube):
* Websites/webkit.org/demos/webgpu/textured-cube-shader-constants.html: Added.
Add a test which illustrates in the behavior.

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




More information about the webkit-changes mailing list