Last active
June 13, 2018 16:53
-
-
Save MaikKlein/1b17ebe766969550afc84e6e8d2fd6b7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub trait SpirvVector { | |
type Intrinsic: Intrinsic; | |
} | |
unsafe trait Intrinsic {} | |
// This type has the metainformation | |
#[spirv(Vector3)] | |
struct SpirvVec3; | |
unsafe impl Intrinsic for SpirvVec3{} | |
impl SpirvVector for SomeExternalMathVec3 { | |
type Intrinsic = SpirvVec3; | |
} | |
// Check if a given type implements SpirvVector, if it does then access the Intrinsic type which | |
// has the metainformation to generate a specific OpVector type. | |
// Some pseudo code | |
let trait_impl: Option<TraitImpl> = tcx.get_impl_of_trait(ty, def_id); | |
let associated_ty: Option<Ty> = trait_impl.and_then(|trait_impl| trait_impl.associated_types_iter().first()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment