-
Notifications
You must be signed in to change notification settings - Fork 195
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
[glsl-out] Emit globals of any type, as required by Naga IR. #1823
[glsl-out] Emit globals of any type, as required by Naga IR. #1823
Conversation
Draft because:
|
0ef61e4
to
4cd8f0a
Compare
// unsized arrays can only be in storage buffers, for which we use `ByteAddressBuffer` anyway. | ||
continue; | ||
} | ||
if module.types[members.last().unwrap().ty] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An empty struct in input shader will break this code? I think it would be better to use if let Some(member) = members.last() ....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty structures are forbidden in WGSL, and I thought the validator enforced this - but it does not. GLSL doesn't allow empty structures either, but SPIR-V does (and Vulkan doesn't seem to add any further restrictions about that).
But for the time being, since we do have empty structs passing through Naga, I'll change this and the other sites.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we avoid unwrap here and return EmptyStruct
error instead? In case where validation is disabled (it disabled by default).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The general stance backends have over panicking is that it's fine if the IR is illegal there are multiple cases where we panic if the IR isn't good, just grep unwrap
, if validation isn't enabled it's the responsibility of the user to ensure it's legal, otherwise the behavior may include panics.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That principle makes sense; I've submitted #1828 to write it down.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides what Gordon already pointed out I have some more worries about this changes.
e8a29bb
to
cd83790
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
everything looks good on my part now
Use it in HLSL and GLSL back ends.
No change in behavior. Exhaustive matches aid error detection, and are clearer when the number of match arms isn't excessive.
"Storage qualifier" is the term used in the GLSL ES specification.
Delete `GlobalTypeKind`. Break out `Writer::write_global`'s code into two new functions, `write_simple_global` and `write_interface_block`. This introduces some repeated code, but the way we need to produce interface blocks and normal globals are sufficiently different that I think it's clearer overall to just separate them entirely. Much of the details are handled by their callees. Loosen the interface block code to support arbitrary types.
cd83790
to
b36b67e
Compare
Fixes #1811.