Rust-GPU / Rust-GPU/rust-gpu

Nalgebra vector fails to be recongized

Aperta
#247 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

bug
Lingua principale
Rust
Stelle
3.4k
Fork
126
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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]

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con i punti di ingresso minimi dello shader main_vs e main_fs e riproduci il fallimento della validazione di Vulkan usando nalgebra::Vector4. Ispeziona il file generato mesh-main_vs.spv e la relativa variabile Position per determinare se la rappresentazione del vettore viene emessa correttamente; il lavoro è completo quando lo shader viene validato con main_vs abilitato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
rust
Ambito
compilers, computer-graphics
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.