可过滤的 32 位浮点纹理
32 位浮点纹理用于存储高精度数据,例如 HDR 图像和深度图。对于高端游戏和专业应用中使用的 GPU,它们尤其重要。
可过滤的 32 位浮点纹理支持描述了 GPU 过滤 32 位浮点纹理的能力。这意味着 GPU 可以平滑浮点纹理的边缘,使其看起来不那么锯齿状。它类似于 WebGL 中的“OES_texture_float_linear”扩展程序。
并非所有 GPU 都支持可过滤的 32 位浮点纹理。当 "float32-filterable" 功能在 GPUAdapter 中可用时,您现在可以使用此功能请求 GPUDevice,并使用“r32float”“rg32float”和“rgba32float”格式过滤纹理。请参阅以下示例和问题 dawn:1664。
const adapter = await navigator.gpu.requestAdapter(); if (!adapter.features.has("float32-filterable")) { throw new Error("Filterable 32-bit float textures support is not available"); } // Explicitly request filterable 32-bit float textures support. const device = await adapter.requestDevice({ requiredFeatures: ["float32-filterable"], }); // Create a sampler with linear filtering. const sampler = device.createSampler({ magFilter: "linear", }); // Create a texture with rgba32float format. const texture = device.createTexture({ size: [100, 100], format: "rgba32float", usage: GPUTextureUsage.COPY_DST | GPUTextureUsage.TEXTURE_BINDING, }); // Write data to texture, create a bindgroup with sampler and texture and // send the appropriate commands to the GPU.... unorm10-10-10-2 顶点格式
WebGPU 规范中新增了一种名为“unorm10-10-10-2”(也称为“rgb10a2”)的顶点格式。它由一个打包的 32 位值组成,其中包含四个归一化的无符号整数值,按 10 位、10 位、10 位和 2 位排列。请参阅以下示例和问题 dawn:2044。
// Define the layout of vertex attribute data with unorm10-10-10-2 format. const buffers = [ { arrayStride: 0, attributes: [ { format: "unorm10-10-10-2", offset: 0, shaderLocation: 0 }, ], }, ]; // Describe the vertex shader entry point and its input buffer layouts. const vertex = { module: myVertexShaderModule, entryPoint: "main", buffers, }; // Pass vertex to device.createRenderPipeline() and // use vec4<f32> type in WGSL shader code to manipulate data. rgb10a2uint 纹理格式
WebGPU 规范中新增了一种名为“rgb10a2uint”的纹理格式。它是一种 32 位打包像素格式,包含四个无符号整数分量:10 位红色、10 位绿色、10 位蓝色和 2 位 Alpha。请参阅以下示例并发布 dawn:1936。
// Create a texture with rgb10a2uint format. const texture = device.createTexture({ size: [100, 100], format: "rgb10a2uint", usage: GPUTextureUsage.COPY_DST | GPUTextureUsage.TEXTURE_BINDING, }); // Write data to texture, create a bindgroup with texture and // send the appropriate commands to the GPU.... Dawn 更新
时间戳查询可让 WebGPU 应用精确(精确到纳秒)测量其 GPU 命令的执行时间。已更新用于捕获通行证开始和结束时的时间戳查询的 API 形状,以符合 WebGPU 规范。请参阅以下示例并发布 dawn:1800。
// Create a timestamp query set that will store the timestamp values. wgpu::QuerySetDescriptor querySetDescriptor = { .count = 2, .type = wgpu::QueryType::Timestamp}; wgpu::QuerySet querySet = device.CreateQuerySet(&querySetDescriptor); wgpu::RenderPassTimestampWrites timestampWrites = { .querySet = querySet, .beginningOfPassWriteIndex = 0, .endOfPassWriteIndex = 1}; wgpu::ComputePassDescriptor pass{.timestampWrites = ×tampWrites}; // Write the queue timestamp into beginningOfPassWriteIndex and // endOfPassWriteIndex of myQuerySet respectively before and after the pass // commands execute. myEncoder.BeginComputePass(&pass); 这仅涵盖了部分重要亮点。查看详尽的提交列表。
WebGPU 的新变化
WebGPU 新变化系列中涵盖的所有内容。
Chrome 142
Chrome 141
Chrome 140
- 设备请求会消耗适配器
- 使用纹理视图时使用纹理的简写形式
- WGSL textureSampleLevel 支持一维纹理
- 弃用 bgra8unorm 只读存储纹理用法
- 移除 GPUAdapter isFallbackAdapter 属性
- Dawn 更新
Chrome 139
Chrome 138
Chrome 137
- 使用纹理视图进行 externalTexture 绑定
- 复制缓冲区,但不指定偏移量和大小
- 使用指向原子变量的指针的 WGSL workgroupUniformLoad
- GPUAdapterInfo powerPreference 属性
- 移除 GPURequestAdapterOptions compatibilityMode 属性
- Dawn 更新
Chrome 136
Chrome 135
- 允许创建具有 null bind 组布局的流水线布局
- 允许视口超出渲染目标边界
- 更轻松地访问 Android 上的实验性兼容性模式
- 移除 maxInterStageShaderComponents 限制
- Dawn 更新
Chrome 134
Chrome 133
- 新增了 unorm8x4-bgra 和 1 分量顶点格式
- 允许请求具有未定义值的未知限制
- WGSL 对齐规则变更
- 使用 discard 时的 WGSL 性能增益
- 针对外部纹理使用 VideoFrame displaySize
- 使用 copyExternalImageToTexture 处理具有非默认方向的图片
- 改善开发者体验
- 启用与 featureLevel 的兼容模式
- 清理实验性子群组功能
- 弃用 maxInterStageShaderComponents 限制
- Dawn 更新
Chrome 132
- 纹理视图使用情况
- 32 位浮点纹理混合
- GPUDevice adapterInfo 属性
- 使用无效格式配置画布上下文时抛出 JavaScript 错误
- 纹理的过滤采样器限制
- 扩展子群组实验
- 改善开发者体验
- 实验性支持 16 位归一化纹理格式
- Dawn 更新
Chrome 131
- 剪裁 WGSL 中的距离
- GPUCanvasContext getConfiguration()
- 点和线图元不得具有深度偏移
- 子群组的包含性扫描内置函数
- 对多重绘制间接调用的实验性支持
- 着色器模块编译选项 strict math
- 移除 GPUAdapter requestAdapterInfo()
- Dawn 更新
Chrome 130
Chrome 129
Chrome 128
Chrome 127
Chrome 126
Chrome 125
Chrome 124
Chrome 123
Chrome 122
Chrome 121
- 在 Android 上支持 WebGPU
- 在 Windows 上使用 DXC 而不是 FXC 进行着色器编译
- 计算和渲染通道中的时间戳查询
- 着色器模块的默认入口点
- 支持将 display-p3 用作 GPUExternalTexture 色彩空间
- 内存堆信息
- Dawn 更新
Chrome 120
Chrome 119
Chrome 118
Chrome 117
Chrome 116
- WebCodecs 集成
- 由 GPUAdapter
requestDevice()返回的丢失设备 - 如果调用了
importExternalTexture(),则保持视频播放流畅 - 规范一致性
- 改善开发者体验
- Dawn 更新
Chrome 115
Chrome 114
Chrome 113
- 在
importExternalTexture()中使用 WebCodecs VideoFrame 来源