Nalgebra vector fails to be recongized
オープン
まだ誰も着手していません。
bug
- 主要言語
- Rust
- スター
- 3.4k
- フォーク
- 126
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
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]
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
最小限のシェーダーエントリポイント main_vs と main_fs から始め、nalgebra::Vector4 を使って Vulkan の検証失敗を再現します。生成された mesh-main_vs.spv とその Position 変数を調べ、ベクトル表現が正しく出力されているかどうかを確認します。main_vs を有効にした状態でシェーダーの検証に成功すれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- rust
- 領域
- compilers, computer-graphics
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100