-
Notifications
You must be signed in to change notification settings - Fork 250
Add location
decoration attribute
#354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Does this provide an error? Because if so, I think it's fine as is. This is also the case with enums in Rust, so having it behave similarly makes sense. enum Foo {
Bar = 1,
Baz = 0,
Test,
}
|
I don't believe so, would probably clash after the build during validation or at runtime. But I can try to construct similar error outputs. |
I think I'd prefer this to be implemented in a way that either no arguments have an explicit location, or all of them do - mix and matching sounds like a really bad idea, and should be an error (I can't think of a good use case to do so). Also, having error checking for duplicate locations is important. |
@msiglreith Do you plan on updating this with the feedback, or should we just close this? |
Oh sorry, gonna close it as I currently don't need it and interface might change in the future anyway |
Hi, just popping in to say that this would be pretty useful for the specific case where you've got matrix attributes (e.g. for instancing). at the moment if you have #[spirv(vertex)]
pub fn vertex(
position: Vec3,
normal: Vec3,
uv: Vec2,
material: u32,
translation: Vec3,
rotation: Mat3,
scale: f32,
... Then you get a validation error:
as the location of Having this would fix the problem: #[spirv(vertex)]
pub fn vertex(
position: Vec3,
normal: Vec3,
uv: Vec2,
material: u32,
translation: Vec3,
rotation: Mat3,
#[spirv(location = 8)] scale: f32,
... The other way to handle this would be to skip some locations when an attribute is quite big, like a matrix. |
Although if you are using Vulkan, instancing through attributes is essentially obsolete. Put all your instance data (matrices, whatever you want) in a storage buffer and index into it by instance ID, no need to bind extra vertex streams. (Doesn't mean assigning locations manually is useless though, I'm sure there are cases where it's desirable). |
Just chiming in that the error around not properly auto-calculating |
Oh nice. I might have a go at reviving that. |
Allows to explicity specify locations decorations for shader interfaces.
It's implemented backwards compatible in the way that locations will still be incremented for relevant interface types but specifying it explicitly will adjust the counter.
Example
There is one case where this can lead to issues right now: