-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Gate @interpolate(linear) behind a downlevel flag
#9972
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
emilk
wants to merge
4
commits into
gfx-rs:trunk
Choose a base branch
from
emilk:emilk/interpolate-linear-downlevel-flag
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
047379c
Gate `@interpolate(linear)` behind a capability instead of failing at…
emilk f9d61d4
rm comment
emilk e32b579
Set `DownlevelFlags::LINEAR_INTERPOLATION` on Vulkan, and fix snapsho…
emilk 3e68644
Drop the redundant gpu test for linear interpolation
emilk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| targets = "SPIRV | METAL | HLSL | WGSL" | ||
| capabilities = "LINEAR_INTERPOLATION" | ||
|
|
||
| [glsl] | ||
| version.Desktop = 400 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| capabilities = "LINEAR_INTERPOLATION" | ||
|
|
||
| [glsl] | ||
| version.Desktop = 400 | ||
| writer_flags = "" | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| use wgpu_test::{ | ||
| apply, fail, gpu_test, GpuTestConfiguration, GpuTestInitializer, TestParameters, TestingContext, | ||
| }; | ||
|
|
||
| pub fn all_tests(vec: &mut Vec<GpuTestInitializer>) { | ||
| vec.push(LINEAR_INTERPOLATION_GATED); | ||
| } | ||
|
|
||
| const SHADER_SRC: &str = " | ||
| @vertex | ||
| fn vs_main(@builtin(vertex_index) vertex_index: u32) -> VertexOutput { | ||
| var out: VertexOutput; | ||
| out.pos = vec4f(f32(vertex_index), 0.0, 0.0, 1.0); | ||
| out.v = 1.0; | ||
| return out; | ||
| } | ||
|
|
||
| struct VertexOutput { | ||
| @builtin(position) pos: vec4f, | ||
| @location(0) @interpolate(linear) v: f32, | ||
| } | ||
|
|
||
| @fragment | ||
| fn fs_main(in: VertexOutput) -> @location(0) vec4f { | ||
| return vec4f(in.v); | ||
| } | ||
| "; | ||
|
|
||
| /// `@interpolate(linear)` has no GLSL ES equivalent, so on adapters without | ||
| /// [`wgpu::DownlevelFlags::LINEAR_INTERPOLATION`] it must be rejected up front by | ||
| /// `create_shader_module`, instead of failing later during pipeline creation with an | ||
| /// internal naga bitflag name. | ||
| /// | ||
| /// Regression test for <https://github.com/gfx-rs/wgpu/issues/9971>. | ||
| fn linear_interpolation_gated(ctx: TestingContext) { | ||
| let supported = ctx | ||
| .adapter | ||
| .get_downlevel_capabilities() | ||
| .flags | ||
| .contains(wgpu::DownlevelFlags::LINEAR_INTERPOLATION); | ||
|
|
||
| let create = || { | ||
| ctx.device | ||
| .create_shader_module(wgpu::ShaderModuleDescriptor { | ||
| label: Some("linear-interpolation"), | ||
| source: wgpu::ShaderSource::Wgsl(SHADER_SRC.into()), | ||
| }) | ||
| }; | ||
|
|
||
| if supported { | ||
| create(); | ||
| } else { | ||
| fail(&ctx.device, create, Some("LINEAR_INTERPOLATION")); | ||
| } | ||
| } | ||
|
|
||
| #[apply(gpu_test!)] | ||
| static LINEAR_INTERPOLATION_GATED: GpuTestConfiguration = GpuTestConfiguration::new() | ||
| .parameters( | ||
| TestParameters::default() | ||
| .downlevel_flags(wgpu::DownlevelFlags::empty()) | ||
| .limits(wgpu::Limits::downlevel_webgl2_defaults()), | ||
| ) | ||
| .run_sync(linear_interpolation_gated); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.