Webgpu and WGSL
Total Page:16
File Type:pdf, Size:1020Kb
WebGPU And WGSL Modern 3D on the web; Spec; Adapters/Devices, Buffers, Textures, Layouts, Commands, Pipelines WebGPU is the rapidly maturing next-generation 3D Shaders are written using the brand new WGSL specification for the standard web platform. WebGPU (WebGPU Shader Language). WebGPU is suitable for has been created by the W3C’s GPU For the Web both graphics- and compute-workloads. A significant Community Group with the active participation of all subset of the graphics functionality of modern GPUs is major browser vendors – Google, Mozilla, Microsoft also of great interest for non-graphics (e.g. machine and Apple. Most modern client devices (including learning) programming (e.g. heavy-duty matrix modern mobile devices) now have some form of 3D multiplication). The intent of this code-intensive course hardware and correctly exposing this to web apps in a is to bring already experienced web application secure and high-performant way is the goal. WebGPU developers up to speed with all things WebGPU and works the way modern graphics is intended to be have them create their own web applications using programmed – with a Web IDL-defined API running on WebGPU that lerverages the available underlying 3D the CPU and a shader running directly on the GPU. hardware as much as possible. Contents of One-Day Training Course Review of WebGPU Standard Samplers What does it offer: the most advanced Role of samplers Target Audience compute and 3D rendering pipeline createSampler Web application Clearly focused on securely exposing GPUSamplerDescriptor developers and 3D modern graphics hardware to web apps Addressing modes / filters framework developers What does it not cover: shading, AR/VR, Layout seeking to leverage the 2D, audio, input/touch:see other specs “A GPUBindGroupLayout defines the latest 3D technology on WebGPU API Technical Tour interface between a set of resources bound the standard web. Command Buffers / GPU buffers in a GPUBindGroup and their accessibility Pipelines and shaders in shader stages.“ [link] Devices and adapters createBindGroup[|Layout] Prerequisites Textures / resources / Rendering GPUBindGroup[|Layout]Descriptor createPipelineLayout Developers experienced GPUAdapter and GPUDevice GPUPipelineLayoutDescriptor with web programming navigator.gpu (worker / main thread) ShaderModule & Pipeline and 3D graphics. GPUAdapter (the GPU hardware) Shaders & WebGPU Access via call to gpu.requestAdapter createShaderModule Sample code and lab Config: GPURequestAdapterOptions GPUShaderModuleDescriptor exercises will be in (power setting for now, future:expandable) create[Compute|Render]Pipeline TypeScript, so knowledge GPUDevice: context to interact with GPU GPU[Compute| Render]PipelineDescriptor of this language is Access via adapter.requestDevice WGSL-WebGPU Shader Language required. May be multiple “devices” per adapter Close relationship to SPIR-V Has “create” function for all constructs Suitable for many targets Buffer Will be universally supported Managed blocks of memory WGSL data types and syntax createBuffer[|Mapped|MappedAsync] Mapped means accessible as ArrayBuffer Encoders createCommandEncoder GPUBufferDescriptor (size + usage) GPUCommandEncoderDescriptor Usage flags – e.g. map_read, copy_dst createRenderBundleEncoder Textures GPURenderBundleEncoderDescriptor Create textures using createTexture Development with WebGPU GPUTextureDescriptor Exploring development issues when Create views: GPUTexture.createView creating web applications using WebGPU Review of texture formats App architecture suggestions.