Add SHADERINT_16 feature to allow 16bit ints in Vulkan shaders (#3401)

* add support for vulkan SHADER_INT16

* changelog

* deno shader-i16

* better INT16 docs

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>

* fix typo

---------

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
This commit is contained in:
Elabajaba 2023-02-01 21:00:22 -05:00 committed by GitHub
parent 2562f323bb
commit c5e2f5a7b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 3 deletions

View File

@ -264,6 +264,10 @@ By @jimblandy in [#3254](https://github.com/gfx-rs/wgpu/pull/3254).
- 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)

View File

@ -134,6 +134,7 @@
"clear-commands",
"spirv-shader-passthrough",
"shader-primitive-index",
"shader-i16",
],
);

View File

@ -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
}
@ -380,6 +383,10 @@ impl From<GpuRequiredFeatures> 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-i16"),
);
features.set(
wgpu_types::Features::VERTEX_ATTRIBUTE_64BIT,
required_features.0.contains("vertex-attribute-64bit"),

View File

@ -176,7 +176,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(),
@ -420,7 +420,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()) {

View File

@ -674,6 +674,13 @@ 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`.
///
/// Supported platforms:
/// - Vulkan
///
/// This is a native-only feature.
const SHADER_INT16 = 1 << 42;
}
}