一键导入
typegpu-wgsl-types
Rules for TypeGPU and WGSL data schemas, type conversions, and avoiding implicit casting warnings.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Rules for TypeGPU and WGSL data schemas, type conversions, and avoiding implicit casting warnings.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | typegpu-wgsl-types |
| description | Rules for TypeGPU and WGSL data schemas, type conversions, and avoiding implicit casting warnings. |
When working with TypeGPU and WGSL in this repository, strict typing rules apply. Follow these guidelines to avoid shader compilation errors and implicit conversion warnings.
f32 vs i32)WGSL does not support implicit conversion between concrete numeric types (e.g., you cannot directly assign an i32 to an f32 or add them together).
.0 for float literals. e.g., use 2.0 instead of 2. Bare integers like 2 or 0 can be interpreted as i32, which leads to implicit conversion warnings when used in f32 contexts.f32(value) or i32(value) for explicit conversions.
f32 or i32 from 'typegpu/data' and use it like a function: f32(myVariable).0.0 instead of 0. E.g., vec2f(0.0) instead of vec2f(0).WGSL does not have a ? : ternary operator. While TypeGPU attempts to resolve ternaries, it only supports them for comptime-known checks.
If you use a ternary operator for runtime values, you will get the error:
Ternary operator is only supported for comptime-known checks ... For runtime checks, please use 'std.select' or if/else statements.
Inside 'use gpu' blocks, you have two options for runtime branching:
Option 1: Standard if / else (Preferred for readability and complex logic)
TypeGPU correctly parses standard TypeScript if and else blocks into WGSL branching.
let result = falseValue
if (condition) {
result = trueValue
}
Option 2: select function
Use the select function from 'typegpu/std'.
import { select } from 'typegpu/std';
// Note the order: select(false_value, true_value, condition)
const result = select(falseValue, trueValue, condition);
TypeGPU provides data schemas like d.u32, d.vec3f, d.i32, d.f32 that help marshal data between JS/TS and WGSL.
f32(31.1) returns 31. Wait, no, u32(31.1) returns 31. f32(true) returns 1.0.select with bare literalsWhen using select(0, 1, condition), TypeGPU may infer the return type as i32 because 0 and 1 are integers.
f32 return type: select(0.0, 1.0, condition).If you declare const z = 0.0, TypeGPU might still treat z as an i32 literal if context allows it, causing a (z * z): i32 warning.
const z = f32(0.0).Optimize this Claude Code instance — max effort, prune stale memory, proper compact window. Use at the start of any session. Trigger when asked to "set up claude", "optimize agent", "declutter", or "tune settings".
TypeGPU is type-safe WebGPU in TypeScript. Use whenever the user writes, debugs, or designs TypeGPU code: 'use gpu' shader functions, tgpu.fn, buffers, textures, bind groups, compute and render pipelines, vertex layouts, slots, accessors, and any TypeGPU API. Shader logic and CPU-side resources are tightly coupled - handle both sides here even if the user only mentions one (e.g. "how do I write a shader", "how do I create a buffer"). Trigger on any mention of typegpu, tgpu, "use gpu", TypedGPU, or WebGPU code written using TypeGPU's schema API (d.*, tgpu.*, std.*). Do NOT trigger for raw WebGPU (using GPUDevice/GPURenderPipeline directly without tgpu), WGSL-only questions, Three.js, Babylon.js, or WebGL.
Rules for variation/preview galleries in this SolidJS + WebGPU app — cross-browser (Chrome/Firefox) CSS tile sizing & scrollbars, and visibility-gated preview mounting so off-screen tiles never spawn GPU canvases. Trigger whenever editing a gallery/preview grid (QuickVariationPicker, VariationSelector, FlameRandomizerCard/GalleryGrid) or any WebGPU canvas preview.
Explicit rules and workflow preferences for how to assist the user on the chaos-master-fp project. Trigger this whenever performing file modifications or terminal operations.