compileModule abstract method

Object compileModule(
  1. String name,
  2. String wgsl
)

The module for wgsl, or a throw naming name and quoting the compiler.

A throw is allowed and cannot be required, and the difference is a fact about this API. GPUDevice.createShaderModule returns a module for text that does not compile: WGSL errors arrive out of band, through an error scope or getCompilationInfo, both of which are promises. So the device's implementation cannot know synchronously whether the text was good, and it does the next honest thing — it records the browser's verdict, with the stage's name and the line, where WebGpuDevice.debugDrainErrors will find it. Otherwise the complaint arrives at the first pipeline built from the module as "invalid due to a previous error", naming neither the stage nor the line, which is exactly the mystery the WebGL2 backend refuses to leave behind when a compile fails.

A compiler that can decide — a test's, or an ahead-of-time one — throws StateError, and the reload in webgpu_loaded_shaders.dart turns that into a refusal naming the bundle.

Implementation

Object compileModule(String name, String wgsl);