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

Update to rust-gpu main #82

Merged
merged 3 commits into from
Sep 11, 2023
Merged

Update to rust-gpu main #82

merged 3 commits into from
Sep 11, 2023

Conversation

SneakyBerry
Copy link
Contributor

Checklist

  • I have read the Contributor Guide
  • I have read and agree to the Code of Conduct
  • I have added a description of my changes and why I'd like them included in the section below

Description of Changes

Update dependencies and rust toolchain to rust-gpu main HEAD

@h3r2tic
Copy link
Collaborator

h3r2tic commented Sep 1, 2023

Thanks for the contribution!

Do do Rust shaders actually compile for you with this PR? Ignoring the clippy warnings in CI, I'm still getting the following when running the view binary:

[2023-09-01 23:04:57][kajiya_backend::rust_shader_compiler][ERROR] Failed to build Rust-GPU shaders. Falling back to the previously compiled ones. Error: Shader builder failed:
 
    Finished release [optimized] target(s) in 0.05s
warning: the following packages contain code that will be rejected by a future version of Rust: nanoserde-derive v0.1.18
note: to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id 1`
     Running `target/release/builder`
   Compiling rust-shaders-shared v0.1.0 (/home/h3/code/h3/kajiya/crates/lib/rust-shaders-shared)
error[E0277]: the trait bound `glam::Vec2: Vector<f32, 2>` is not satisfied
  --> crates/lib/rust-shaders-shared/src/gbuffer.rs:42:31
   |
42 |                   vec2_to_f16x2(vec2(
   |  _________________-------------_^
   | |                 |
   | |                 required by a bound introduced by this call
43 | |                     roughness_to_perceptual_roughness(self.roughness),
44 | |                     self.metalness,
45 | |                 )),
   | |_________________^ the trait `Vector<f32, 2>` is not implemented for `glam::Vec2`
   |
   = help: the following other types implement trait `Vector<T, N>`:
             <spirv_std::glam::DVec2 as Vector<f64, 2>>
             <spirv_std::glam::DVec3 as Vector<f64, 3>>
             <spirv_std::glam::DVec4 as Vector<f64, 4>>
             <spirv_std::glam::IVec2 as Vector<i32, 2>>
             <spirv_std::glam::IVec3 as Vector<i32, 3>>
             <spirv_std::glam::IVec4 as Vector<i32, 4>>
             <spirv_std::glam::UVec2 as Vector<u32, 2>>
             <spirv_std::glam::UVec3 as Vector<u32, 3>>
           and 5 others
note: required by a bound in `vec2_to_f16x2`
  --> /home/h3/.cargo/git/checkouts/rust-gpu-e0a37a82a46176e6/e87c324/crates/spirv-std/src/float.rs:28:32
   |
28 | pub fn vec2_to_f16x2(vec: impl Vector<f32, 2>) -> u32 {
   |                                ^^^^^^^^^^^^^^ required by this bound in `vec2_to_f16x2`

error[E0277]: the trait bound `glam::Vec2: Vector<f32, 2>` is not satisfied
  --> crates/lib/rust-shaders-shared/src/gbuffer.rs:57:41
   |
57 |         let roughness_metalness: Vec2 = f16x2_to_vec2(self.v.z);
   |                                         ^^^^^^^^^^^^^ the trait `Vector<f32, 2>` is not implemented for `glam::Vec2`
   |
   = help: the following other types implement trait `Vector<T, N>`:
             <spirv_std::glam::DVec2 as Vector<f64, 2>>
             <spirv_std::glam::DVec3 as Vector<f64, 3>>
             <spirv_std::glam::DVec4 as Vector<f64, 4>>
             <spirv_std::glam::IVec2 as Vector<i32, 2>>
             <spirv_std::glam::IVec3 as Vector<i32, 3>>
             <spirv_std::glam::IVec4 as Vector<i32, 4>>
             <spirv_std::glam::UVec2 as Vector<u32, 2>>
             <spirv_std::glam::UVec3 as Vector<u32, 3>>
           and 5 others
note: required by a bound in `f16x2_to_vec2`
  --> /home/h3/.cargo/git/checkouts/rust-gpu-e0a37a82a46176e6/e87c324/crates/spirv-std/src/float.rs:47:25
   |
47 | pub fn f16x2_to_vec2<V: Vector<f32, 2>>(int: u32) -> V {
   |                         ^^^^^^^^^^^^^^ required by this bound in `f16x2_to_vec2`

For more information about this error, try `rustc --explain E0277`.
error: could not compile `rust-shaders-shared` (lib) due to 2 previous errors
Error: Build failed

@SneakyBerry
Copy link
Contributor Author

Thanks for the contribution!

Do do Rust shaders actually compile for you with this PR? Ignoring the clippy warnings in CI, I'm still getting the following when running the view binary:


[2023-09-01 23:04:57][kajiya_backend::rust_shader_compiler][ERROR] Failed to build Rust-GPU shaders. Falling back to the previously compiled ones. Error: Shader builder failed:

 

    Finished release [optimized] target(s) in 0.05s

warning: the following packages contain code that will be rejected by a future version of Rust: nanoserde-derive v0.1.18

note: to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id 1`

     Running `target/release/builder`

   Compiling rust-shaders-shared v0.1.0 (/home/h3/code/h3/kajiya/crates/lib/rust-shaders-shared)

error[E0277]: the trait bound `glam::Vec2: Vector<f32, 2>` is not satisfied

  --> crates/lib/rust-shaders-shared/src/gbuffer.rs:42:31

   |

42 |                   vec2_to_f16x2(vec2(

   |  _________________-------------_^

   | |                 |

   | |                 required by a bound introduced by this call

43 | |                     roughness_to_perceptual_roughness(self.roughness),

44 | |                     self.metalness,

45 | |                 )),

   | |_________________^ the trait `Vector<f32, 2>` is not implemented for `glam::Vec2`

   |

   = help: the following other types implement trait `Vector<T, N>`:

             <spirv_std::glam::DVec2 as Vector<f64, 2>>

             <spirv_std::glam::DVec3 as Vector<f64, 3>>

             <spirv_std::glam::DVec4 as Vector<f64, 4>>

             <spirv_std::glam::IVec2 as Vector<i32, 2>>

             <spirv_std::glam::IVec3 as Vector<i32, 3>>

             <spirv_std::glam::IVec4 as Vector<i32, 4>>

             <spirv_std::glam::UVec2 as Vector<u32, 2>>

             <spirv_std::glam::UVec3 as Vector<u32, 3>>

           and 5 others

note: required by a bound in `vec2_to_f16x2`

  --> /home/h3/.cargo/git/checkouts/rust-gpu-e0a37a82a46176e6/e87c324/crates/spirv-std/src/float.rs:28:32

   |

28 | pub fn vec2_to_f16x2(vec: impl Vector<f32, 2>) -> u32 {

   |                                ^^^^^^^^^^^^^^ required by this bound in `vec2_to_f16x2`



error[E0277]: the trait bound `glam::Vec2: Vector<f32, 2>` is not satisfied

  --> crates/lib/rust-shaders-shared/src/gbuffer.rs:57:41

   |

57 |         let roughness_metalness: Vec2 = f16x2_to_vec2(self.v.z);

   |                                         ^^^^^^^^^^^^^ the trait `Vector<f32, 2>` is not implemented for `glam::Vec2`

   |

   = help: the following other types implement trait `Vector<T, N>`:

             <spirv_std::glam::DVec2 as Vector<f64, 2>>

             <spirv_std::glam::DVec3 as Vector<f64, 3>>

             <spirv_std::glam::DVec4 as Vector<f64, 4>>

             <spirv_std::glam::IVec2 as Vector<i32, 2>>

             <spirv_std::glam::IVec3 as Vector<i32, 3>>

             <spirv_std::glam::IVec4 as Vector<i32, 4>>

             <spirv_std::glam::UVec2 as Vector<u32, 2>>

             <spirv_std::glam::UVec3 as Vector<u32, 3>>

           and 5 others

note: required by a bound in `f16x2_to_vec2`

  --> /home/h3/.cargo/git/checkouts/rust-gpu-e0a37a82a46176e6/e87c324/crates/spirv-std/src/float.rs:47:25

   |

47 | pub fn f16x2_to_vec2<V: Vector<f32, 2>>(int: u32) -> V {

   |                         ^^^^^^^^^^^^^^ required by this bound in `f16x2_to_vec2`



For more information about this error, try `rustc --explain E0277`.

error: could not compile `rust-shaders-shared` (lib) due to 2 previous errors

Error: Build failed

Yes, i've compiled shaders but see no difference after that. But otherwise it compiles without an error (if you set default toolchain to specific nightly)

@h3r2tic
Copy link
Collaborator

h3r2tic commented Sep 11, 2023

Ah, I see, so won't work with stable that I'm on. Seeing as this is certainly more useful than the definitely broken main, let's get it in!

@h3r2tic h3r2tic merged commit d373f76 into EmbarkStudios:main Sep 11, 2023
2 of 3 checks passed
@eddyb
Copy link

eddyb commented Oct 30, 2023

@h3r2tic @SneakyBerry Hi, just saw this randomly and wanted to quickly check: any reason not to use the latest release (0.9)? Ever since we started releasing more often over the past year, the main branch is not necessarily that useful (and may even be confusing wrt rust-toolchain).

(See also https://github.com/EmbarkStudios/rust-gpu/releases)

I will note, however, that before Rust-GPU 0.10 comes out (hopefully soon), you'll want this:

[patch.crates-io]
# HACK(eddyb) using https://github.com/EmbarkStudios/spirt/pull/48 before a new release.
spirt = { git = "https://github.com/EmbarkStudios/spirt", rev = "521c2418076309a4aee9b949a00e77dcbe2fc6b1" }

To specifically get this fix (it's been a long-time problem, but recent Rust-GPU has exacerbated it):

With that fix, Rust-GPU loops should match HLSL/DXC semantics (I'd almost say "exactly" but idk if there's some edge cases I'm unfamiliar with).

@h3r2tic
Copy link
Collaborator

h3r2tic commented Nov 9, 2023

Thanks for the hint, @eddyb! 🙇 Not much has happened in kajiya in the past year, but should stuff begin happening again, I'll keep this in mind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants