webgpu-wgsl-uniformity

Fix WGSL uniformity and directive errors in WebGPU shaders.

Updated May 20, 2026
One-click install
npx skills add https://github.com/Impertio-Studio/WebGPU-Claude-Skill-Package --skill webgpu-wgsl-uniformity
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: webgpu-wgsl-uniformity
Source: https://github.com/Impertio-Studio/WebGPU-Claude-Skill-Package/tree/main/skills/source/webgpu-wgsl/webgpu-wgsl-uniformity
Command: npx skills add https://github.com/Impertio-Studio/WebGPU-Claude-Skill-Package --skill webgpu-wgsl-uniformity

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Use this Skill when WGSL shaders fail uniformity analysis or when optional language and device features need to be enabled safely. It prevents shader-creation errors caused by sampling, derivatives, barriers, or diagnostics being placed in the wrong control flow.

Core Features & Use Cases

  • Uniformity Fixes: Identifies when texture sampling, derivatives, or workgroup barriers must be moved into uniform control flow.
  • Directive Guidance: Explains how to place enable, requires, and diagnostic directives correctly at the top of a shader.
  • Feature Gating: Helps pair shader features with host-side device checks so f16, subgroups, and other optional capabilities compile reliably.
  • Use Case: Debug a fragment shader that triggers derivative_uniformity, then rewrite it so sampling is hoisted safely and the shader validates on WebGPU.

Quick Start

Ask for help fixing a WGSL shader that triggers a uniformity diagnostic, and the Skill will show the correct control-flow rewrite, directive placement, and feature gating.

Frequently Asked Questions about webgpu-wgsl-uniformity

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does my WebGPU shader fail uniformity validation when texture sampling?

WebGPU shader uniformity validation fails when texture sampling, derivatives, or workgroup barriers are placed inside non-uniform control flow. You must hoist these operations into uniform control flow paths so the shader validates correctly and executes safely across invocations.

How do I fix derivative_uniformity errors in a WGSL fragment shader?

To fix derivative_uniformity errors in a WGSL fragment shader, you need to rewrite the control flow so derivatives are computed uniformly. This involves hoisting texture sampling operations out of divergent branches and using explicit level or gradient sampling where needed.

Where do enable and requires directives go in a WGSL shader?

Enable and requires directives must be placed correctly at the top of a WGSL shader file. Proper directive placement ensures optional language features like f16 or subgroups compile reliably without triggering shader-creation errors during validation.

How do I use compute barriers in WGSL without triggering uniformity errors?

Compute barriers in WGSL trigger uniformity errors if called inside divergent control flow. Workgroup barriers must be moved into uniform control flow paths to ensure all threads execute the barrier consistently, preventing shader validation failures.

Do I need host-side feature detection for WGSL enable extensions?

Yes, you need host-side feature detection for WGSL enable extensions. Pairing shader features with host-side device checks ensures optional capabilities like f16 and subgroups compile reliably and are supported by the target WebGPU device.

What is the best way to debug subgroup diagnostics in WGSL?

The best way to debug subgroup diagnostics in WGSL is to analyze uniformity requirements and ensure subgroup operations are placed in uniform control flow. Correcting directive placement and feature gating resolves diagnostic errors during shader authoring.