Erroneous association of outputs when code is in a single spirv file.
Makogan opened this issue · 2 comments
Makogan commented
I am using rust gpu to compile shaders. rust-gpu generates a single spirv for all stages. I am having the following issue I have this shader:
#![deny(warnings)]
mod shared;
extern crate spirv_std;
extern crate bytemuck;
use shared::glam::{Vec4, Vec3};
use spirv_std::spirv;
#[spirv(fragment)]
// pub fn main_fs(next_pos: Vec4, output: &mut Vec4)
pub fn main_fs(output: &mut Vec4)
{
// *output = Vec4::new(1.0, 0.0001 * next_pos.x, 0.0, 1.0);
*output = Vec4::new(1.0, 0.0001, 0.0, 1.0);
}
#[spirv(vertex)]
pub fn main_vs(
#[spirv(vertex_index)] vert_id: i32,
#[spirv(uniform, descriptor_set = 1, binding = 0)] toggle: &u32,
#[spirv(position, invariant)] out_pos: &mut Vec4,
position: Vec3,
offset_bind2: Vec3,
n_pos: &mut Vec4,
) {
*out_pos = Vec4::new(
(vert_id - 1) as f32 + (position.x + offset_bind2.x) * 0.000001,
((vert_id & 1) * 2 - 1) as f32,
0.0,
if *toggle == 0 { 1.0 } else { 0.0 },
);
*n_pos = *out_pos;
}
I am then parsing the generated spirv with spirq:
Variable::Output { name, location, ty } =>
{
if entry_point.exec_model != ExecutionModel::Fragment
{
continue;
}
println!("{:?}", ty);
println!("{:?}", name);
println!("{:?}", entry_point.exec_model);
attachment_outputs.push(parse_fragment_output(&ty));
}
Which is printing:
Vector(VectorType { scalar_ty: Float { bits: 32 }, nscalar: 4 })
Some("output")
Fragment
Vector(VectorType { scalar_ty: Float { bits: 32 }, nscalar: 4 })
Some("n_pos")
Fragment
So it seems that spirq is assigning all outputs from all shader stages to each entry point, instead of just those defined for that entry point alone.
PENGUINLIONG commented
Did you call ReflectConfig::ref_all_rscs()
with true when you start the reflection? If so, it ought to be binding interfaces to all the entry points. If not then it is confirmed a bug and I can work on this one.
PENGUINLIONG commented
Could you upload an compiled artifact for example? Tried it a little bit but I found it difficult to make spirv-std compiling.