1#![warn(
4 missing_debug_implementations,
5 missing_copy_implementations,
6 missing_docs,
7 trivial_casts,
8 trivial_numeric_casts,
9 unused_extern_crates,
10 unused_import_braces,
11 unused_qualifications
12)]
13
14macro_rules! family_owned {
15 ($type:ident<B, C $(, $args:ident)*> @ $getter:expr) => {
16 #[allow(unused_qualifications)]
17 impl<B, C $(, $args)*> $type<B, C $(, $args)*>
18 where
19 B: rendy_core::hal::Backend,
20 {
21 pub fn family_id(&self) -> $crate::FamilyId {
23 ($getter)(self)
24 }
25
26 pub fn assert_family_owner(&self, family: &$crate::Family<B, C>) {
28 assert_eq!(self.family_id(), family.id(), "Resource is not owned by specified family");
29 }
30
31 pub fn assert_device_owner(&self, device: &$crate::core::Device<B>) {
33 assert_eq!(self.family_id().device, device.id(), "Resource is not owned by specified device");
34 }
35
36 pub fn assert_instance_owner(&self, instance: &$crate::core::Instance<B>) {
38 assert_eq!(self.family_id().device.instance, instance.id(), "Resource is not owned by specified instance");
39 }
40 }
41 };
42
43 ($type:ident<B, C $(, $args:ident)*>) => {
44 family_owned!($type<B, C $(, $args)*> @ |s: &Self| s.family);
45 };
46
47 (@NOCAP $type:ident<B $(, $args:ident)*> @ $getter:expr) => {
48 #[allow(unused_qualifications)]
49 impl<B, $(, $args)*> $type<B, $(, $args)*>
50 where
51 B: rendy_core::hal::Backend,
52 {
53 pub fn family_id(&self) -> $crate::FamilyId {
55 ($getter)(self)
56 }
57
58 pub fn assert_family_owner<C>(&self, family: &$crate::Family<B, C>) {
60 assert_eq!(self.family_id(), family.id(), "Resource is not owned by specified family");
61 }
62
63 pub fn assert_device_owner(&self, device: &$crate::core::Device<B>) {
65 assert_eq!(self.family_id().device, device.id(), "Resource is not owned by specified device");
66 }
67
68 pub fn assert_instance_owner(&self, instance: &$crate::core::Instance<B>) {
70 assert_eq!(self.family_id().device.instance, instance.id(), "Resource is not owned by specified instance");
71 }
72 }
73 };
74
75 (@NOCAP $type:ident<B, $(, $args:ident)*>) => {
76 family_owned!(@NOCAP $type<B, C $(, $args)*> @ |s: &Self| s.family);
77 };
78}
79
80use rendy_core as core;
81
82mod buffer;
83mod capability;
84mod family;
85mod fence;
86mod pool;
87
88pub use crate::{buffer::*, capability::*, family::*, fence::*, pool::*};