Skip to content

wgsl interpolate(flat) always results in value of 0 #1775

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

Closed
rukai opened this issue Aug 7, 2021 · 16 comments
Closed

wgsl interpolate(flat) always results in value of 0 #1775

rukai opened this issue Aug 7, 2021 · 16 comments
Labels
area: correctness We're behaving incorrectly external: driver-bug A driver is causing the bug, though we may still want to work around it

Comments

@rukai
Copy link
Contributor

rukai commented Aug 7, 2021

Description
wgsl interpolate(flat) always results in value of 0, I think, at least the repro is very concise
Issue does not occur with the equivalent glsl

Repro steps
rukai@5c29302

Expected vs observed behavior
I expect blue output but get red

Platform
wgpu master, linux, vulkan

@rukai
Copy link
Contributor Author

rukai commented Aug 7, 2021

I discovered in the wgsl spec that flat cannot be used on u32, as integer types are always flat.
In that case we should make the following changes to naga:

  • Error when flat is used on an int.
  • Fix the repro provided, naga master seems to be outputting spirv with flat regardless of whether interpolate(flat) is used, so possibly the 0 value is caused by something else.

@kvark
Copy link
Member

kvark commented Aug 8, 2021

Does renderdoc capture show anything interesting?

@kvark kvark added area: correctness We're behaving incorrectly help required We need community help to make this happen. type: bug Something isn't working labels Aug 8, 2021
@rukai
Copy link
Contributor Author

rukai commented Aug 8, 2021

renderdoc is showing the correct value is output by the vertex shader:
image

But I dont think there is a way to inspect the values received by the fragment shader.

@kvark
Copy link
Member

kvark commented Aug 8, 2021

You can debug the fragment shaders.

@rukai
Copy link
Contributor Author

rukai commented Aug 8, 2021

there was a history and debug button but they were greyed out, I think its not supported yet or something, its strange because the docs indicate it should be supported
image

@kvark
Copy link
Member

kvark commented Aug 11, 2021

I see the same thing, unfortunately :(
What GPU are you testing this on?

@kvark
Copy link
Member

kvark commented Aug 11, 2021

This looks like a driver bug. Running your sample code on Windows/AMD shows the correct result.

@kvark kvark added external: driver-bug A driver is causing the bug, though we may still want to work around it and removed type: bug Something isn't working labels Aug 11, 2021
@kvark
Copy link
Member

kvark commented Aug 11, 2021

@rukai are you on NVidia proprietary driver by any chance? What's the GPU?

@kvark
Copy link
Member

kvark commented Aug 11, 2021

I submitted this issue to NVidia Vulkan support and already got a weak confirmation that this may be fixed soon 🚀
Unfortunately, no reference number. I'll update once I know more.

@rukai
Copy link
Contributor Author

rukai commented Aug 11, 2021

Yes the card is Nvidia GTX 960 and I am using the Nvidia proprietary driver.
I had incorrectly assumed it wasnt a driver bug considering it worked with glsl.
Thanks for reporting the issue to Nvidia!

@kvark
Copy link
Member

kvark commented Aug 12, 2021

More specifically, the driver is confused about the presence of multiple location=1 varyings, and isn't able to ignore the ones that need to be ignored (based on the entry point interface). Generally people don't make SPIR-V with multiple entry points, so that driver path was undertested.

@kvark kvark removed the help required We need community help to make this happen. label Aug 12, 2021
@kvark
Copy link
Member

kvark commented Sep 7, 2021

@rukai could you try on 470.62.02 drivers please? The issue is supposedly fixed there. https://developer.nvidia.com/vulkan-driver

@rukai
Copy link
Contributor Author

rukai commented Sep 9, 2021

I am on the latest driver used by arch https://archlinux.org/packages/extra/x86_64/nvidia-utils/ and its on 470.63.01-01
The issue is not fixed.

@kvark
Copy link
Member

kvark commented Sep 9, 2021

@rukai looks like this driver is from 2021.8.10, it's an older driver (with somehow newer minor version?).
The one we need only came out yesterday - https://www.gamingonlinux.com/2021/09/nvidia-vulkan-beta-driver-version-4706202-is-out-now

The newest stable versions of the main NVIDIA driver for Linux are at NVIDIA 470.63.01 released on July 19, 2021 from their "Production Branch" series or 465.31 released on April 29, 2020 from their "New Feature" series. Confused? It's a lot of numbers to remember but both Production and New Feature series are fine for normal use.

@rukai
Copy link
Contributor Author

rukai commented Sep 9, 2021

Ok I'll test it when that driver makes its way onto arch.

@rukai
Copy link
Contributor Author

rukai commented Oct 13, 2021

Can now confirm this has been fixed! 🎉

@rukai rukai closed this as completed Oct 13, 2021
cwfitzgerald pushed a commit that referenced this issue Oct 25, 2023
Fixes #1745: Support out-of-order module scope declarations in WGSL
Fixes #1044: Forbid local variable shadowing in WGSL
Fixes #2076: [wgsl-in] no error for duplicated type definition
Fixes #2071: Global item does not support 'const'
Fixes #2105: [wgsl-in] Type aliases for a vecN<T> doesn't work when constructing vec from a single argument
Fixes #1775: Referencing a function without a return type yields an unknown identifier error.
Fixes #2089: Error span reported on the declaration of a variable instead of its use
Fixes #1996: [wgsl-in] Confusing error: "expected unsigned/signed integer literal, found '1'"

Separate parsing from lowering by generating an AST, which desugars as
much as possible down to something like Naga IR. The AST is then used
to resolve identifiers while lowering to Naga IR.

Co-authored-by: Teodor Tanasoaia <[email protected]>
Co-authored-by: Jim Blandy <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: correctness We're behaving incorrectly external: driver-bug A driver is causing the bug, though we may still want to work around it
Projects
None yet
Development

No branches or pull requests

2 participants