/webgpu-shader-module-transform

Javascript polyfill to support optional shader source and transform members for GPUShaderModule creation

Primary LanguageTypeScriptMIT LicenseMIT

WebGPU Shader Module Transform

Overview

webgpu-shader-module-transform is a light polyfill which extends the GPUShaderModuleDescriptor of the WebGPU API to support an optional transform member.

interface GPUDevice {
  createShaderModule(descriptor: GPUShaderModuleDescriptor & {
    transform?: (code: any) => GPUShaderModuleDescriptor["code"],
  }): GPUShaderModule;
}

If transform is provided in a call to GPUDevice.createShaderModule, transform is invoked on code and the result is replaced as the code member of the GPUShaderModuleDescriptor.