Skip to content
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

spirv-val fails for a module using derived Eq::eq to the target spirv-unknown-vulkan1.2 #748

Closed
hatoo opened this issue Sep 4, 2021 · 3 comments · Fixed by #793
Closed
Assignees
Labels
t: bug Something isn't working

Comments

@hatoo
Copy link
Contributor

hatoo commented Sep 4, 2021

Expected Behaviour

#![cfg_attr(
    target_arch = "spirv",
    no_std,
    feature(register_attr),
    register_attr(spirv)
)]

#[cfg(not(target_arch = "spirv"))]
use spirv_std::macros::spirv;

use spirv_std as _;

#[derive(PartialEq, Eq)]
struct T(u32);

#[spirv(fragment)]
pub fn main(out: &mut f32) {
    if T(0) == T(0) {
        *out = 1.0;
    }
}

will succeed to compile and pass spirv-val to "spirv-unknown-vulkan1.2".
It's Ok if the target is "spirv-unknown-spv1.3".

Example & Steps To Reproduce

  1. clone https://github.com/hatoo/rust-gpu-issue/tree/error-vulkan-12 (note: error-vulkan-12 branch)
  2. cargo build
  3. errors
> cargo build
   Compiling builder v0.1.0 (C:\Users\hato2\Desktop\rust-gpu-issue\builder)
error: failed to run custom build command for `builder v0.1.0 (C:\Users\hato2\Desktop\rust-gpu-issue\builder)`

Caused by:
  process didn't exit successfully: `C:\Users\hato2\Desktop\rust-gpu-issue\target\debug\build\builder-a70f151e87e6f8ef\build-script-build` (exit code: 1)
  --- stderr
     Compiling shader v0.1.0 (C:\Users\hato2\Desktop\rust-gpu-issue\shader)
  error: Interface variable id <12> is used by entry point 'main' id <1>, but is not listed as an interface
    %12 = OpVariable %_ptr_Private_uint Private %uint_0

    |
    = note: module `C:\Users\hato2\Desktop\rust-gpu-issue\target\spirv-builder\spirv-unknown-vulkan1.2\release\deps\shader.spv.dir\module`

  warning: an unknown error occurred
    |
    = note: spirv-opt failed, leaving as unoptimized
    = note: module `C:\Users\hato2\Desktop\rust-gpu-issue\target\spirv-builder\spirv-unknown-vulkan1.2\release\deps\shader.spv.dir\module`

  error: error:0:0 - Interface variable id <12> is used by entry point 'main' id <1>, but is not listed as an interface
    %12 = OpVariable %_ptr_Private_uint Private %uint_0

    |
    = note: spirv-val failed
    = note: module `C:\Users\hato2\Desktop\rust-gpu-issue\target\spirv-builder\spirv-unknown-vulkan1.2\release\deps\shader.spv.dir\module`

  warning: `shader` (lib) generated 1 warning
  error: could not compile `shader` due to 2 previous errors; 1 warning emitted
  Error: BuildFailed

It's Ok if the target is "spirv-unknown-spv1.3".

System Info

  • Rust: 1.56.0-nightly (ae90dcf02 2021-08-09)
  • OS: Windows 11 Pro
  • GPU: RTX 2080ti
  • SPIR-V: v2021.2-dev v2021.1-42-g5dd2f769

Backtrace

Backtrace

<backtrace>

@hatoo hatoo added the t: bug Something isn't working label Sep 4, 2021
@msiglreith
Copy link
Contributor

msiglreith commented Sep 4, 2021

fwiw I wrote some linker pass to collect the necessary variables for the entrypoint supporting spv1.4+, right now only Input/Output storage class variables are listed in entrypoints. entrypoint parameters are added
msiglreith@668e40b

edit: thanks to khyperia for correction

@khyperia
Copy link
Contributor

khyperia commented Sep 8, 2021

right now only Input/Output storage class variables are listed in entrypoints.

This isn't correct - to clarify, we support adding all relevant variables in the entrypoint function to the interface list for versions >= 1.4. That code is here.

The issue is specifically with constants that contain pointers to other constants, which are generated as Private variables here. The issue here is that there is a reference taken to a constant, &T(0) (Eq takes its arguments by reference), and that constant needs to be added to the interface list, even though it's not part of any interface.

@eddyb
Copy link
Contributor

eddyb commented Nov 3, 2021

There's a quick repro in-tree FWIW:

cargo compiletest --target-env vulkan1.2
failures:
    [ui] ui/arch/debug_printf.rs
    [ui] ui/arch/ray_query_initialize_khr.rs
    [ui] ui/dis/asm_op_decorate.rs
    [ui] ui/dis/complex_image_sample_inst.rs
    [ui] ui/image/sample_depth_reference/sample_lod.rs
    [ui] ui/lang/consts/nested-ref.rs
    [ui] ui/lang/consts/shallow-ref.rs
    [ui] ui/lang/core/ops/range-contains.rs

test result: FAILED. 164 passed; 8 failed; 0 ignored; 0 measured; 0 filtered out; finished in 8.61s

6 out of those 8 failures are this error, so it's generally getting in the way of vulkan1.2 support at this moment (the other 2 are unrelated minor oversights in the tests, where newer Vulkan forces better validation AFAICT).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants