Closed MaikKlein closed 6 years ago
I declared the entry point interface like this back then
struct TeapotVarying {
#[inspirv(location = 0)] v_normal: Float3,
#[inspirv(builtin = "Position")]
#[inspirv(location = 1)] pos: Float4,
}
#[inspirv(descriptor(set = 0, binding = 0))]
struct Data {
world: Float4x4,
view: Float4x4,
proj: Float4x4,
}
#[inspirv(entry_point = "vertex")]
fn main(vertex: Attributes<TeapotVertex>, uniforms: Cbuffer<Data>) -> TeapotVarying {
let worldview = uniforms.view * uniforms.world;
let v_normal = worldview * Float4::from_3_1(vertex.normal, 0.0);
let pos = uniforms.proj * worldview * Float4::from_3_1(vertex.position, 1.0);
TeapotVarying {
v_normal: v_normal.swizzle3(0, 1, 2),
pos: pos,
}
}
Single output struct for each shader with annotated struct fields, allowing to glue these things together.
@msiglreith Yes I think that looks pretty good, but it does bind types to specific information like type qualifiers. I posted some ideas in https://github.com/MaikKlein/rlsl/issues/26 to make this more "reusable".
Of course my "new" proposed syntax might seem too alien
Update:
#[inspirv(descriptor(set = 0, binding = 0))]
struct Data {
world: Float4x4,
view: Float4x4,
proj: Float4x4,
}
This ties Data
always to set 0 and binding 0. Where my proposal would be
struct Data {
world: Float4x4,
view: Float4x4,
proj: Float4x4,
}
type SomeName = Descriptor<0, 0, Data>;
where Descriptor will toughly look like this
#[spirv(Descriptor)]
pub struct Descriptor<Set: Const, Binding: Const, T> {
set: Set,
binding: Binding,
data: T
}
In the future there will be only const generics inside the Descriptor
.
Currently this is how
PerVertex
is implementedAn alternative would be to output the PerVertex information
Then there are other builtin variables