Skip to content
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

Don't require 1:1 mapping between OpTypeStructs and their names. #406

Merged
merged 1 commit into from
Feb 1, 2021
Merged

Don't require 1:1 mapping between OpTypeStructs and their names. #406

merged 1 commit into from
Feb 1, 2021

Conversation

eddyb
Copy link
Contributor

@eddyb eddyb commented Feb 1, 2021

The linker deduplicates types based on their definition anyway (though maybe we should do less of that - see #398 (comment)), so the main side-effect of SpirvType::Adt having contained a name: String was that some types would be considered different during codegen itself (even when otherwise compatible). Specifically, the added test used to fail with:

error: Cannot cast between pointer types
   --> /home/eddy/.cargo/registry/src/github.jparrowsec.cn-1ecc6299db9ec823/glam-0.12.0/src/mat3.rs:462:1
    |
462 | impl_mat3_traits!(f32, mat3, Mat3, Vec3);
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: from: *{Function} struct spirv_std::glam::Mat3 { 0: struct spirv_std::glam::core::storage::Vector3x3<spirv_std::glam::XYZ<f32>> { x_axis: f32x3, y_axis: f32x3, z_axis: f32x3 } }
    = note: to: *{Function} struct spirv_std::glam::core::storage::Vector3x3<spirv_std::glam::Vec3> { x_axis: f32x3, y_axis: f32x3, z_axis: f32x3 }

But with this PR, a single type definition is generated, and it gets two OpNames, instead:

OpName %5 "spirv_std::glam::core::storage::Vector3x3<spirv_std::glam::XYZ<f32>>"
OpName %5 "spirv_std::glam::core::storage::Vector3x3<spirv_std::glam::Vec3>"

(snippet obtained via DUMP_PRE_LINK, to avoid linker deduplication, #398, etc.)

If we had some compile failure tests akin to ui tests in rust-lang/rust, it would've been useful to see how bad the "show the first name" approach can get. If we think printing SpirvTypes in errors is relatively rare, we could show all names even etc.

@eddyb eddyb requested a review from khyperia February 1, 2021 13:24
@mergify mergify bot merged commit 3a4d140 into EmbarkStudios:main Feb 1, 2021
@eddyb eddyb deleted the struct-known-by-many-names branch February 1, 2021 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants