Closed
Description
The following 3 tests all fail:
#[test]
fn push_constant_single_vulkan() {
val_vulkan(
r#"
#[derive(Copy, Clone)]
pub struct ShaderConstants {
pub time: f32,
}
#[allow(unused_attributes)]
#[spirv(fragment)]
pub fn main(constants: PushConstant<ShaderConstants>) {
let _constants = constants.load();
}
"#,
);
}
thread 'test::basic::push_constant_single_vulkan' panicked at 'Vulkan validation failed:
invalid id:0:0 - PushConstant OpVariable <id> '2[%constants]' has illegal type.
From Vulkan spec, section 14.5.1:
Such variables must be typed as OpTypeStruct, or an array of this type
%constants = OpVariable %_ptr_PushConstant_float PushConstant
', crates/spirv-builder/src/test/mod.rs:109:9
stack backtrace:
0: rust_begin_unwind
at /rustc/d32c320d7eee56706486fef6be778495303afe9e/library/std/src/panicking.rs:493:5
1: std::panicking::begin_panic_fmt
at /rustc/d32c320d7eee56706486fef6be778495303afe9e/library/std/src/panicking.rs:435:5
2: spirv_builder::test::val_vulkan
at ./src/test/mod.rs:109:9
3: spirv_builder::test::basic::push_constant_single_vulkan
at ./src/test/basic.rs:233:5
4: spirv_builder::test::basic::push_constant_single_vulkan::{{closure}}
at ./src/test/basic.rs:232:1
5: core::ops::function::FnOnce::call_once
at /home/ashley/.rustup/toolchains/nightly-2020-12-11-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
6: core::ops::function::FnOnce::call_once
at /rustc/d32c320d7eee56706486fef6be778495303afe9e/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
#[test]
fn push_constant_single_block_vulkan() {
val_vulkan(
r#"
#[derive(Copy, Clone)]
#[allow(unused_attributes)]
#[spirv(block)]
pub struct ShaderConstants {
pub time: f32,
}
#[allow(unused_attributes)]
#[spirv(fragment)]
pub fn main(constants: PushConstant<ShaderConstants>) {
let _constants = constants.load();
}
"#,
);
}
error: `#[spirv(block)]` can only be used for `Sized` aggregates, but `ShaderConstants` has `Abi::Scalar(Scalar { value: F32, valid_range: 0..=4294967295 })`
--> /home/ashley/projects/rust-gpu/crates/spirv-std/src/storage_class.rs:57:1
|
57 | / storage_class! {
58 | | /// Graphics uniform memory. OpenCL constant memory.
59 | | ///
60 | | /// Shared externally, visible across all functions in all invocations in
... |
202 | | #[spirv(physical_storage_buffer)] writeable storage_class PhysicalStorageBuffer;
203 | | }
| |_^
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
#[test]
fn push_constant_value_vulkan() {
val_vulkan(
r#"
#[allow(unused_attributes)]
#[spirv(fragment)]
pub fn main(constants: PushConstant<f32>) {
let _constants = constants.load();
}
"#,
);
}
---- test::basic::push_constant_value_vulkan stdout ----
thread 'test::basic::push_constant_value_vulkan' panicked at 'Vulkan validation failed:
invalid id:0:0 - PushConstant OpVariable <id> '2[%constants]' has illegal type.
From Vulkan spec, section 14.5.1:
Such variables must be typed as OpTypeStruct, or an array of this type
%constants = OpVariable %_ptr_PushConstant_float PushConstant
', crates/spirv-builder/src/test/mod.rs:109:9
stack backtrace:
0: rust_begin_unwind
at /rustc/d32c320d7eee56706486fef6be778495303afe9e/library/std/src/panicking.rs:493:5
1: std::panicking::begin_panic_fmt
at /rustc/d32c320d7eee56706486fef6be778495303afe9e/library/std/src/panicking.rs:435:5
2: spirv_builder::test::val_vulkan
at ./src/test/mod.rs:109:9
3: spirv_builder::test::basic::push_constant_value_vulkan
at ./src/test/basic.rs:270:5
4: spirv_builder::test::basic::push_constant_value_vulkan::{{closure}}
at ./src/test/basic.rs:269:1
5: core::ops::function::FnOnce::call_once
at /home/ashley/.rustup/toolchains/nightly-2020-12-11-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
6: core::ops::function::FnOnce::call_once
at /rustc/d32c320d7eee56706486fef6be778495303afe9e/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
I think it's alright for the 3rd one to fail, using PushConstants
with primitives seems a little dodgy to me, but it'd be nice to fix either test 1 or 2.