Skip to content

Commit

Permalink
wgpu-core: Only produce StageError::InputNotConsumed on DX11/DX12 (#4222
Browse files Browse the repository at this point in the history
)

Co-authored-by: Aaron Hill <aa1ronham@gmail.com>
  • Loading branch information
torokati44 and Aaron1011 authored Oct 11, 2023
1 parent 75b41fe commit 49d16f7
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 2 deletions.
7 changes: 7 additions & 0 deletions deno_webgpu/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,9 @@ fn deserialize_features(features: &wgpu_types::Features) -> Vec<&'static str> {
if features.contains(wgpu_types::Features::SHADER_EARLY_DEPTH_TEST) {
return_features.push("shader-early-depth-test");
}
if features.contains(wgpu_types::Features::SHADER_UNUSED_VERTEX_OUTPUT) {
return_features.push("shader-unused-vertex-output");
}

return_features
}
Expand Down Expand Up @@ -624,6 +627,10 @@ impl From<GpuRequiredFeatures> for wgpu_types::Features {
wgpu_types::Features::SHADER_EARLY_DEPTH_TEST,
required_features.0.contains("shader-early-depth-test"),
);
features.set(
wgpu_types::Features::SHADER_UNUSED_VERTEX_OUTPUT,
required_features.0.contains("shader-unused-vertex-output"),
);

features
}
Expand Down
7 changes: 6 additions & 1 deletion wgpu-core/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,12 @@ impl Interface {
}

// Check all vertex outputs and make sure the fragment shader consumes them.
if shader_stage == naga::ShaderStage::Fragment {
// This requirement is removed if the `SHADER_UNUSED_VERTEX_OUTPUT` feature is enabled.
if shader_stage == naga::ShaderStage::Fragment
&& !self
.features
.contains(wgt::Features::SHADER_UNUSED_VERTEX_OUTPUT)
{
for &index in inputs.keys() {
// This is a linear scan, but the count should be low enough
// that this should be fine.
Expand Down
1 change: 1 addition & 0 deletions wgpu-hal/src/gles/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ impl super::Adapter {
ver >= (3, 2) || extensions.contains("OES_geometry_shader"),
);
features.set(wgt::Features::SHADER_EARLY_DEPTH_TEST, ver >= (3, 1));
features.set(wgt::Features::SHADER_UNUSED_VERTEX_OUTPUT, true);
let gles_bcn_exts = [
"GL_EXT_texture_compression_s3tc_srgb",
"GL_EXT_texture_compression_rgtc",
Expand Down
1 change: 1 addition & 0 deletions wgpu-hal/src/metal/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,7 @@ impl super::PrivateCapabilities {
features.set(F::ADDRESS_MODE_CLAMP_TO_ZERO, true);

features.set(F::RG11B10UFLOAT_RENDERABLE, self.format_rg11b10_all);
features.set(F::SHADER_UNUSED_VERTEX_OUTPUT, true);

features
}
Expand Down
1 change: 1 addition & 0 deletions wgpu-hal/src/vulkan/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ impl PhysicalDeviceFeatures {
| vk::FormatFeatureFlags::COLOR_ATTACHMENT_BLEND,
);
features.set(F::RG11B10UFLOAT_RENDERABLE, rg11b10ufloat_renderable);
features.set(F::SHADER_UNUSED_VERTEX_OUTPUT, true);

(features, dl_flags)
}
Expand Down
11 changes: 10 additions & 1 deletion wgpu-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,16 @@ bitflags::bitflags! {
/// This is a native only feature.
const VERTEX_ATTRIBUTE_64BIT = 1 << 53;

// 54..59 available
/// Allows vertex shaders to have outputs which are not consumed
/// by the fragment shader.
///
/// Supported platforms:
/// - Vulkan
/// - Metal
/// - OpenGL
const SHADER_UNUSED_VERTEX_OUTPUT = 1 << 54;

// 55..59 available

// Shader:

Expand Down

0 comments on commit 49d16f7

Please sign in to comment.