WebGPU: add shader_float16 extension
This patch exposes the shader_shader16 extension, which allows use
of 16-bit floating-point types in shaders for arithmetic operations
and use of 16-bit types in buffers.
Bug: 996713
Change-Id: Ib09301fb9d396a85926952f9df396f426b15ee1b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2324318
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804020}
diff --git a/gpu/command_buffer/service/webgpu_decoder_impl.cc b/gpu/command_buffer/service/webgpu_decoder_impl.cc
index b6eb2d3..d8d31f4 100644
--- a/gpu/command_buffer/service/webgpu_decoder_impl.cc
+++ b/gpu/command_buffer/service/webgpu_decoder_impl.cc
@@ -648,6 +648,9 @@
if (request_device_properties.textureCompressionBC) {
device_descriptor.requiredExtensions.push_back("texture_compression_bc");
}
+ if (request_device_properties.shaderFloat16) {
+ device_descriptor.requiredExtensions.push_back("shader_float16");
+ }
WGPUDevice wgpu_device =
dawn_adapters_[requested_adapter_index].CreateDevice(&device_descriptor);
diff --git a/third_party/blink/renderer/modules/webgpu/gpu_adapter.cc b/third_party/blink/renderer/modules/webgpu/gpu_adapter.cc
index d2ea6c7..969f89b 100644
--- a/third_party/blink/renderer/modules/webgpu/gpu_adapter.cc
+++ b/third_party/blink/renderer/modules/webgpu/gpu_adapter.cc
@@ -28,6 +28,8 @@
requested_device_properties.textureCompressionBC =
extension_set.Contains("texture-compression-bc") ||
extension_set.Contains("textureCompressionBC");
+ requested_device_properties.shaderFloat16 =
+ extension_set.Contains("shader-float16");
return requested_device_properties;
}
@@ -76,6 +78,9 @@
extension_name_list_.emplace_back("texture-compression-bc");
extension_name_list_.emplace_back("textureCompressionBC");
}
+ if (adapter_properties_.shaderFloat16) {
+ extension_name_list_.emplace_back("shader-float16");
+ }
}
ScriptPromise GPUAdapter::requestDevice(ScriptState* script_state,
diff --git a/third_party/blink/renderer/modules/webgpu/gpu_adapter.idl b/third_party/blink/renderer/modules/webgpu/gpu_adapter.idl
index 40e4002bb..4c71723 100644
--- a/third_party/blink/renderer/modules/webgpu/gpu_adapter.idl
+++ b/third_party/blink/renderer/modules/webgpu/gpu_adapter.idl
@@ -7,7 +7,8 @@
enum GPUExtensionName {
"texture-compression-bc",
// Non-standard extension name string. Remove after a transition period.
- "textureCompressionBC"
+ "textureCompressionBC",
+ "shader-float16"
};
[