Nalgebra vector fails to be recongized
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Rust
- Estrellas
- 3.4k
- Forks
- 126
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
I tried using nalgebra (no-std) for types in shaders, but the simplest shaders fails to compile.
use nalgebra::Vector4;
use spirv_std::spirv;
#[allow(dead_code)]
#[spirv(fragment)]
pub fn main_fs(output: &mut Vector4<f32>) {
*output = Vector4::new(1.0, 0.0, 0.0, 1.0);
}
#[allow(dead_code)]
#[spirv(vertex)]
pub fn main_vs(
#[spirv(vertex_index)] vert_id: i32,
#[spirv(position, invariant)] out_pos: &mut Vector4<f32>,
) {
*out_pos = Vector4::new(
(vert_id - 1) as f32,
((vert_id & 1) * 2 - 1) as f32,
0.0,
1.0,
);
}
Is the module I am trying to compile, and the error received is:
error: [VUID-Position-Position-04321] According to the Vulkan spec BuiltIn Position variable needs to be a 4-component 32-bit float vector. ID <3> (OpVariable) is not a float vector.
|
= note: module `/home/marios/proj/hestia_vk/target/spirv-builder/spirv-unknown-vulkan1.2/release/deps/shaders.spvs/mesh-main_vs.spv`
warning: an unknown error occurred
|
= note: spirv-opt failed, leaving as unoptimized
= note: module `/home/marios/proj/hestia_vk/target/spirv-builder/spirv-unknown-vulkan1.2/release/deps/shaders.spvs/mesh-main_vs.spv`
error: error:0:0 - [VUID-Position-Position-04321] According to the Vulkan spec BuiltIn Position variable needs to be a 4-component 32-bit float vector. ID <3> (OpVariable) is not a float vector.
%50 = OpInBoundsAccessChain %_ptr_Output__arr_float_uint_4 %out_pos %uint_0 %uint_0 %uint_0
|
= note: spirv-val failed
If I comment out the main_vs function all is well.
It seems like the Vector4 type isnt being interpreted as a [f32;4]
I am wondering if this is because of the underlying type: pub struct ArrayStorage<T, const R: usize, const C: usize>(pub [[T; R]; C]);
It evaluates with R=4, C=1, making the inner type [[f32; 4],1]
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza con los puntos de entrada mínimos del shader main_vs y main_fs y reproduce el fallo de validación de Vulkan usando nalgebra::Vector4. Inspecciona el archivo generado mesh-main_vs.spv y su variable Position para determinar si la representación del vector se emite correctamente; se considera terminado cuando el shader se valida con main_vs habilitado.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- rust
- Área
- compilers, computer-graphics
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100