From bdd4539d036f0045a2e0f897f55c40aa762dedce Mon Sep 17 00:00:00 2001 From: Elabajaba Date: Wed, 18 Jan 2023 19:25:33 -0500 Subject: [PATCH 1/5] add support for vulkan SHADER_INT16 --- deno_webgpu/src/lib.rs | 4 ++++ wgpu-hal/src/vulkan/adapter.rs | 4 ++-- wgpu-types/src/lib.rs | 7 +++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/deno_webgpu/src/lib.rs b/deno_webgpu/src/lib.rs index 23c49ac679..38114bcccc 100644 --- a/deno_webgpu/src/lib.rs +++ b/deno_webgpu/src/lib.rs @@ -380,6 +380,10 @@ impl From for wgpu_types::Features { wgpu_types::Features::SHADER_FLOAT64, required_features.0.contains("shader-float64"), ); + features.set( + wgpu_types::Features::SHADER_INT16, + required_features.0.contains("shader-int16"), + ); features.set( wgpu_types::Features::VERTEX_ATTRIBUTE_64BIT, required_features.0.contains("vertex-attribute-64bit"), diff --git a/wgpu-hal/src/vulkan/adapter.rs b/wgpu-hal/src/vulkan/adapter.rs index 827f651c73..10cbe3d1b3 100644 --- a/wgpu-hal/src/vulkan/adapter.rs +++ b/wgpu-hal/src/vulkan/adapter.rs @@ -172,7 +172,7 @@ impl PhysicalDeviceFeatures { //.shader_cull_distance(requested_features.contains(wgt::Features::SHADER_CULL_DISTANCE)) .shader_float64(requested_features.contains(wgt::Features::SHADER_FLOAT64)) //.shader_int64(requested_features.contains(wgt::Features::SHADER_INT64)) - //.shader_int16(requested_features.contains(wgt::Features::SHADER_INT16)) + .shader_int16(requested_features.contains(wgt::Features::SHADER_INT16)) //.shader_resource_residency(requested_features.contains(wgt::Features::SHADER_RESOURCE_RESIDENCY)) .geometry_shader(requested_features.contains(wgt::Features::SHADER_PRIMITIVE_INDEX)) .build(), @@ -409,7 +409,7 @@ impl PhysicalDeviceFeatures { //if self.core.shader_cull_distance != 0 { features.set(F::SHADER_FLOAT64, self.core.shader_float64 != 0); //if self.core.shader_int64 != 0 { - //if self.core.shader_int16 != 0 { + features.set(F::SHADER_INT16, self.core.shader_int16 != 0); //if caps.supports_extension(vk::KhrSamplerMirrorClampToEdgeFn::name()) { //if caps.supports_extension(vk::ExtSamplerFilterMinmaxFn::name()) { diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index 0e9fee6fa8..dca951d484 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -674,6 +674,13 @@ bitflags::bitflags! { /// - DX12 /// - Metal (Intel and AMD GPUs) const WRITE_TIMESTAMP_INSIDE_PASSES = 1 << 41; + /// Allows shaders to acquire the INT16 ability + /// + /// Supported platforms: + /// - Vulkan + /// + /// This is a native-only feature. + const SHADER_INT16 = 1 << 42; } } From 52e34d3076b32794da241aa239a5dda48758fbd9 Mon Sep 17 00:00:00 2001 From: Elabajaba Date: Wed, 18 Jan 2023 19:37:42 -0500 Subject: [PATCH 2/5] changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d47d9c42cb..ab6ffe3c20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -217,6 +217,10 @@ let texture = device.create_texture(&wgpu::TextureDescriptor { - Support alpha to coverage. By @Wumpf in [#3156](https://github.com/gfx-rs/wgpu/pull/3156) - Support filtering f32 textures. By @expenses in [#3261](https://github.com/gfx-rs/wgpu/pull/3261) +#### Vulkan + +- Add `SHADER_INT16` feature to enable the `shaderInt16` VkPhysicalDeviceFeature. By @Elabajaba in [#3401](https://github.com/gfx-rs/wgpu/pull/3401) + #### WebGPU - Add `MULTISAMPLE_X2`, `MULTISAMPLE_X4` and `MULTISAMPLE_X8` to `TextureFormatFeatureFlags`. By @39ali in [3140](https://github.com/gfx-rs/wgpu/pull/3140) From e58a661e1fa2b97d517418e1e2efd17be2c5dbc2 Mon Sep 17 00:00:00 2001 From: Elabajaba Date: Fri, 20 Jan 2023 17:03:10 -0500 Subject: [PATCH 3/5] deno shader-i16 --- deno_webgpu/src/02_idl_types.js | 1 + deno_webgpu/src/lib.rs | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/deno_webgpu/src/02_idl_types.js b/deno_webgpu/src/02_idl_types.js index c927f10a5a..d07dc68fcd 100644 --- a/deno_webgpu/src/02_idl_types.js +++ b/deno_webgpu/src/02_idl_types.js @@ -134,6 +134,7 @@ "clear-commands", "spirv-shader-passthrough", "shader-primitive-index", + "shader-i16", ], ); diff --git a/deno_webgpu/src/lib.rs b/deno_webgpu/src/lib.rs index 38114bcccc..d798eefa4b 100644 --- a/deno_webgpu/src/lib.rs +++ b/deno_webgpu/src/lib.rs @@ -164,7 +164,7 @@ fn deserialize_features(features: &wgpu_types::Features) -> Vec<&'static str> { return_features.push("indirect-first-instance"); } if features.contains(wgpu_types::Features::SHADER_FLOAT16) { - return_features.push("shader-f16") + return_features.push("shader-f16"); } // extended from spec @@ -214,6 +214,9 @@ fn deserialize_features(features: &wgpu_types::Features) -> Vec<&'static str> { if features.contains(wgpu_types::Features::PARTIALLY_BOUND_BINDING_ARRAY) { return_features.push("shader-primitive-index"); } + if features.contains(wgpu_types::Features::SHADER_INT16) { + return_features.push("shader-i16"); + } return_features } @@ -382,7 +385,7 @@ impl From for wgpu_types::Features { ); features.set( wgpu_types::Features::SHADER_INT16, - required_features.0.contains("shader-int16"), + required_features.0.contains("shader-i16"), ); features.set( wgpu_types::Features::VERTEX_ATTRIBUTE_64BIT, From 8ecb43169eb9c51cd70e4930701c7430fb9f4624 Mon Sep 17 00:00:00 2001 From: Elabajaba Date: Thu, 2 Feb 2023 01:41:21 +0000 Subject: [PATCH 4/5] better INT16 docs Co-authored-by: Connor Fitzgerald --- wgpu-types/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index dca951d484..68b44339c4 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -674,7 +674,7 @@ bitflags::bitflags! { /// - DX12 /// - Metal (Intel and AMD GPUs) const WRITE_TIMESTAMP_INSIDE_PASSES = 1 << 41; - /// Allows shaders to acquire the INT16 ability + /// Allows shaders to use i16. Not currently supported in naga, only available through spirv-passthrough.``` /// /// Supported platforms: /// - Vulkan From 242bce34e30f060b082c936f8dbc8259d3b5bcd1 Mon Sep 17 00:00:00 2001 From: Elabajaba Date: Wed, 1 Feb 2023 20:47:24 -0500 Subject: [PATCH 5/5] fix typo --- wgpu-types/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index 68b44339c4..67cca4b19c 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -674,7 +674,7 @@ bitflags::bitflags! { /// - DX12 /// - Metal (Intel and AMD GPUs) const WRITE_TIMESTAMP_INSIDE_PASSES = 1 << 41; - /// Allows shaders to use i16. Not currently supported in naga, only available through spirv-passthrough.``` + /// Allows shaders to use i16. Not currently supported in naga, only available through `spirv-passthrough`. /// /// Supported platforms: /// - Vulkan